mirror of
https://github.com/ultrasn0w/app.git
synced 2025-12-13 19:09:53 +01:00
92 lines
2.4 KiB
C#
92 lines
2.4 KiB
C#
using System.Diagnostics;
|
|
using APP.DTO;
|
|
using APP.Utility;
|
|
|
|
namespace APP;
|
|
|
|
public partial class Main : Form
|
|
{
|
|
private ImageList _imageListSeason;
|
|
private List<SeasonAnime>? _seasonAnime;
|
|
private User? _user;
|
|
|
|
public Main()
|
|
{
|
|
InitializeComponent();
|
|
_imageListSeason = new ImageList();
|
|
Load += OnLoad;
|
|
}
|
|
|
|
private async void OnLoad(object? sender, EventArgs e)
|
|
{
|
|
await UpdateData();
|
|
}
|
|
|
|
private async Task UpdateData()
|
|
{
|
|
_seasonAnime = await BackendComms.GetSeason();
|
|
if (_seasonAnime == null)
|
|
{
|
|
ShowError("Fehler beim Season abrufen");
|
|
}
|
|
else
|
|
{
|
|
foreach (var anime in _seasonAnime)
|
|
{
|
|
//_imageListSeason.Images.Add("", new )
|
|
listViewSeason.Items.Add(new ListViewItem
|
|
{
|
|
Text = anime.Title
|
|
});
|
|
}
|
|
}
|
|
|
|
_user = await BackendComms.GetUser("ultrasn0w");
|
|
if (_user == null)
|
|
{
|
|
ShowError("Fehler beim User abrufen");
|
|
}
|
|
else
|
|
{
|
|
tabUser.Text = _user.Username;
|
|
userLabel.Text = _user.Username;
|
|
userLabel.Visible = true;
|
|
userLinkLabel.Text = _user.Url;
|
|
userLinkLabel.Visible = true;
|
|
userLabelInfo.Text = StringAssemble.UserInfo(_user);
|
|
userLabelInfo.Visible = true;
|
|
userLabelInfoData.Text = StringAssemble.UserData(_user);
|
|
userLabelInfoData.Visible = true;
|
|
userImage.LoadAsync(_user.ImageUrl);
|
|
}
|
|
}
|
|
|
|
private static void ShowError(string text)
|
|
{
|
|
MessageBox.Show(text, @"FEHLER", MessageBoxButtons.OK, MessageBoxIcon.Error);
|
|
}
|
|
|
|
private void loginToolStripMenuItem_Click(object sender, EventArgs e)
|
|
{
|
|
// TODO search for user in backend
|
|
}
|
|
|
|
private void userLinkLabel_LinkClicked(object sender, LinkLabelLinkClickedEventArgs e)
|
|
{
|
|
if (string.IsNullOrWhiteSpace(_user?.Url)) return;
|
|
try
|
|
{
|
|
var url = new Uri(_user.Url).ToString();
|
|
var sInfo = new ProcessStartInfo(url)
|
|
{
|
|
UseShellExecute = true
|
|
};
|
|
Process.Start(sInfo);
|
|
}
|
|
catch (Exception ex)
|
|
{
|
|
Console.Error.WriteLineAsync(ex.Message);
|
|
}
|
|
}
|
|
}
|