diff --git a/APP/APP.csproj.user b/APP/APP.csproj.user index 29ee72d..97bd180 100644 --- a/APP/APP.csproj.user +++ b/APP/APP.csproj.user @@ -1,8 +1,14 @@ + + Form + Form + + Form + \ No newline at end of file diff --git a/APP/Main.Designer.cs b/APP/Main.Designer.cs index 5fc6d27..8f5cfd9 100644 --- a/APP/Main.Designer.cs +++ b/APP/Main.Designer.cs @@ -59,7 +59,7 @@ this.tabControl.Location = new System.Drawing.Point(0, 24); this.tabControl.Name = "tabControl"; this.tabControl.SelectedIndex = 0; - this.tabControl.Size = new System.Drawing.Size(828, 547); + this.tabControl.Size = new System.Drawing.Size(984, 837); this.tabControl.TabIndex = 0; // // tabUser @@ -144,7 +144,7 @@ this.tabSeason.Location = new System.Drawing.Point(4, 24); this.tabSeason.Name = "tabSeason"; this.tabSeason.Padding = new System.Windows.Forms.Padding(3); - this.tabSeason.Size = new System.Drawing.Size(820, 519); + this.tabSeason.Size = new System.Drawing.Size(976, 809); this.tabSeason.TabIndex = 1; this.tabSeason.Text = "Season"; // @@ -158,10 +158,10 @@ this.listViewSeason.Location = new System.Drawing.Point(3, 3); this.listViewSeason.Name = "listViewSeason"; this.listViewSeason.ShowGroups = false; - this.listViewSeason.Size = new System.Drawing.Size(814, 513); + this.listViewSeason.Size = new System.Drawing.Size(970, 803); this.listViewSeason.TabIndex = 0; + this.listViewSeason.TileSize = new System.Drawing.Size(300, 64); this.listViewSeason.UseCompatibleStateImageBehavior = false; - this.listViewSeason.View = System.Windows.Forms.View.Tile; // // tabAddAnime // @@ -182,7 +182,7 @@ this.logToolStripMenuItem}); this.menuStrip.Location = new System.Drawing.Point(0, 0); this.menuStrip.Name = "menuStrip"; - this.menuStrip.Size = new System.Drawing.Size(828, 24); + this.menuStrip.Size = new System.Drawing.Size(984, 24); this.menuStrip.TabIndex = 1; this.menuStrip.Text = "menuStrip"; // @@ -211,7 +211,7 @@ this.AutoScaleDimensions = new System.Drawing.SizeF(7F, 15F); this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font; this.BackColor = System.Drawing.Color.FromArgb(((int)(((byte)(64)))), ((int)(((byte)(64)))), ((int)(((byte)(64))))); - this.ClientSize = new System.Drawing.Size(828, 571); + this.ClientSize = new System.Drawing.Size(984, 861); this.Controls.Add(this.tabControl); this.Controls.Add(this.menuStrip); this.Icon = ((System.Drawing.Icon)(resources.GetObject("$this.Icon"))); diff --git a/APP/Main.cs b/APP/Main.cs index 93ba6a4..66b44ee 100644 --- a/APP/Main.cs +++ b/APP/Main.cs @@ -6,9 +6,9 @@ namespace APP; public partial class Main : Form { + private readonly ImageList _imageListSeason; private Auth? _auth; private bool _authSucc; - private ImageList _imageListSeason; private List? _seasonAnime; private User? _user; @@ -16,7 +16,9 @@ public partial class Main : Form { InitializeComponent(); _imageListSeason = new ImageList(); + _imageListSeason.ImageSize = new Size(128, 200); Load += OnLoadEv; + LogBoy.AddToLog("Hi"); } private async void OnLoadEv(object? sender, EventArgs e) @@ -61,14 +63,18 @@ public partial class Main : Form } else { + var count = 0; foreach (var anime in _seasonAnime) { - //_imageListSeason.Images.Add("", new ) + _imageListSeason.Images.Add(await WebBoy.DownloadImage(anime.ImageLarge)); listViewSeason.Items.Add(new ListViewItem { - Text = anime.Title + Text = anime.Title, + ImageIndex = count++ }); } + + listViewSeason.LargeImageList = _imageListSeason; } } diff --git a/APP/RegisterWin.cs b/APP/RegisterWin.cs index 244fee2..d971682 100644 --- a/APP/RegisterWin.cs +++ b/APP/RegisterWin.cs @@ -66,7 +66,7 @@ public partial class RegisterWin : Form Auth = new Auth { Username = _user.Username, - Secret = StringAssemble.CalcSha512(secretBox.Text) + Secret = StringAssemble.CalcSha512(StringAssemble.CalcSauce(_user.Id, _user.Username) + secretBox.Text) }; if (await PerformRegister(_user, Auth)) { diff --git a/APP/Utility/BackendComms.cs b/APP/Utility/BackendComms.cs index 7a6409d..c153f17 100644 --- a/APP/Utility/BackendComms.cs +++ b/APP/Utility/BackendComms.cs @@ -17,7 +17,7 @@ internal static class BackendComms { var resp = await Client.GetAsync(ApiBaseUrl + "season"); if (resp.IsSuccessStatusCode) return await resp.Content.ReadFromJsonAsync>(JsonSerializerOptions); - LogBoy.AddToLog(resp.RequestMessage?.RequestUri + " " + resp.StatusCode); + await LogBoy.LogResponse(resp); return null; } @@ -33,7 +33,7 @@ internal static class BackendComms var resp = await Client.SendAsync(msg); if (!resp.IsSuccessStatusCode) { - LogBoy.AddToLog(resp.RequestMessage?.RequestUri + " " + resp.StatusCode); + await LogBoy.LogResponse(resp); } return resp.IsSuccessStatusCode; @@ -43,7 +43,7 @@ internal static class BackendComms { var resp = await Client.GetAsync(ApiBaseUrl + "anime/" + animeId); if (resp.IsSuccessStatusCode) return await resp.Content.ReadFromJsonAsync(JsonSerializerOptions); - LogBoy.AddToLog(resp.RequestMessage?.RequestUri + " " + resp.StatusCode); + await LogBoy.LogResponse(resp); return null; } @@ -51,7 +51,7 @@ internal static class BackendComms { var resp = await Client.GetAsync(ApiBaseUrl + "animesearch?q=" + query); if (resp.IsSuccessStatusCode) return await resp.Content.ReadFromJsonAsync>(JsonSerializerOptions); - LogBoy.AddToLog(resp.RequestMessage?.RequestUri + " " + resp.StatusCode); + await LogBoy.LogResponse(resp); return null; } @@ -59,7 +59,7 @@ internal static class BackendComms { var resp = await Client.GetAsync(ApiBaseUrl + "user"); if (resp.IsSuccessStatusCode) return await resp.Content.ReadFromJsonAsync>(JsonSerializerOptions); - LogBoy.AddToLog(resp.RequestMessage?.RequestUri + " " + resp.StatusCode); + await LogBoy.LogResponse(resp); return null; } @@ -73,7 +73,7 @@ internal static class BackendComms var resp = await Client.GetAsync(ApiBaseUrl + "user/" + username); if (!resp.IsSuccessStatusCode) { - LogBoy.AddToLog(resp.RequestMessage?.RequestUri + " " + resp.StatusCode); + await LogBoy.LogResponse(resp); return null; } @@ -85,7 +85,7 @@ internal static class BackendComms { var resp = await Client.GetAsync(ApiBaseUrl + "watch"); if (resp.IsSuccessStatusCode) return await resp.Content.ReadFromJsonAsync>(JsonSerializerOptions); - LogBoy.AddToLog(resp.RequestMessage?.RequestUri + " " + resp.StatusCode); + await LogBoy.LogResponse(resp); return null; } @@ -98,7 +98,7 @@ internal static class BackendComms var resp = await Client.GetAsync(ApiBaseUrl + "watch/" + username); if (resp.IsSuccessStatusCode) return await resp.Content.ReadFromJsonAsync>(JsonSerializerOptions); - LogBoy.AddToLog(resp.RequestMessage?.RequestUri + " " + resp.StatusCode); + await LogBoy.LogResponse(resp); return null; } @@ -106,7 +106,7 @@ internal static class BackendComms { var resp = await Client.GetAsync(ApiBaseUrl + "watchext"); if (resp.IsSuccessStatusCode) return await resp.Content.ReadFromJsonAsync>(JsonSerializerOptions); - LogBoy.AddToLog(resp.RequestMessage?.RequestUri + " " + resp.StatusCode); + await LogBoy.LogResponse(resp); return null; } @@ -119,7 +119,7 @@ internal static class BackendComms var resp = await Client.GetAsync(ApiBaseUrl + "watchext/" + username); if (resp.IsSuccessStatusCode) return await resp.Content.ReadFromJsonAsync>(JsonSerializerOptions); - LogBoy.AddToLog(resp.RequestMessage?.RequestUri + " " + resp.StatusCode); + await LogBoy.LogResponse(resp); return null; } @@ -128,7 +128,7 @@ internal static class BackendComms using var content = new StringContent(JsonSerializer.Serialize(register), Encoding.UTF8, MediaTypeNames.Application.Json); using var resp = await Client.PostAsync(ApiBaseUrl + "register", content); if (resp.IsSuccessStatusCode) return await resp.Content.ReadFromJsonAsync(JsonSerializerOptions); - LogBoy.AddToLog(resp.RequestMessage?.RequestUri + " " + resp.StatusCode); + await LogBoy.LogResponse(resp); return null; } } diff --git a/APP/Utility/LogBoy.cs b/APP/Utility/LogBoy.cs index 45e33e0..16e8b05 100644 --- a/APP/Utility/LogBoy.cs +++ b/APP/Utility/LogBoy.cs @@ -6,6 +6,11 @@ internal static class LogBoy { private static readonly StringBuilder Log = new(); + internal static async Task LogResponse(HttpResponseMessage message) + { + AddToLog(message.RequestMessage?.RequestUri + " " + message.StatusCode + " " + await message.Content.ReadAsStringAsync()); + } + internal static void AddToLog(string text) { Log.Append('[' + DateTime.Now.ToShortTimeString() + "] "); diff --git a/APP/Utility/SaveBoy.cs b/APP/Utility/SaveBoy.cs index e5afe2a..e2bf438 100644 --- a/APP/Utility/SaveBoy.cs +++ b/APP/Utility/SaveBoy.cs @@ -5,7 +5,7 @@ namespace APP.Utility; internal static class SaveBoy { - private static readonly string AuthFile = ".." + Path.DirectorySeparatorChar + "reg.json"; + private const string AuthFile = "reg.json"; internal static async Task ReadAuth() { diff --git a/APP/Utility/WebBoy.cs b/APP/Utility/WebBoy.cs new file mode 100644 index 0000000..b02654c --- /dev/null +++ b/APP/Utility/WebBoy.cs @@ -0,0 +1,12 @@ +namespace APP.Utility; + +internal static class WebBoy +{ + private static readonly HttpClient Client = new(); + + internal static async Task DownloadImage(string url) + { + await using var s = await Client.GetStreamAsync(url); + return new Bitmap(s); + } +}