mirror of
https://github.com/ultrasn0w/app.git
synced 2025-12-13 23:09:52 +01:00
First stuff
This commit is contained in:
96
APP/Main.cs
96
APP/Main.cs
@@ -1,25 +1,91 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.ComponentModel;
|
||||
using System.Data;
|
||||
using System.Drawing;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
using System.Windows.Forms;
|
||||
using System.Diagnostics;
|
||||
using APP.DTO;
|
||||
using APP.Utility;
|
||||
|
||||
namespace APP
|
||||
namespace APP;
|
||||
|
||||
public partial class Main : Form
|
||||
{
|
||||
public partial class Main : Form
|
||||
private ImageList _imageListSeason;
|
||||
private List<SeasonAnime>? _seasonAnime;
|
||||
private User? _user;
|
||||
|
||||
public Main()
|
||||
{
|
||||
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)
|
||||
{
|
||||
InitializeComponent();
|
||||
ShowError("Fehler beim Season abrufen");
|
||||
}
|
||||
else
|
||||
{
|
||||
foreach (var anime in _seasonAnime)
|
||||
{
|
||||
//_imageListSeason.Images.Add("", new )
|
||||
listViewSeason.Items.Add(new ListViewItem
|
||||
{
|
||||
Text = anime.Title
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
private void loginToolStripMenuItem_Click(object sender, EventArgs e)
|
||||
_user = await BackendComms.GetUser("ultrasn0w");
|
||||
if (_user == null)
|
||||
{
|
||||
// TODO search for user in backend
|
||||
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);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user