mirror of
https://github.com/ultrasn0w/app.git
synced 2025-12-13 10:29:53 +01:00
Images
This commit is contained in:
@@ -1,8 +1,14 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<Project ToolsVersion="Current" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
|
||||
<ItemGroup>
|
||||
<Compile Update="LogWin.cs">
|
||||
<SubType>Form</SubType>
|
||||
</Compile>
|
||||
<Compile Update="Main.cs">
|
||||
<SubType>Form</SubType>
|
||||
</Compile>
|
||||
<Compile Update="RegisterWin.cs">
|
||||
<SubType>Form</SubType>
|
||||
</Compile>
|
||||
</ItemGroup>
|
||||
</Project>
|
||||
12
APP/Main.Designer.cs
generated
12
APP/Main.Designer.cs
generated
@@ -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")));
|
||||
|
||||
12
APP/Main.cs
12
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<Anime>? _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;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -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))
|
||||
{
|
||||
|
||||
@@ -17,7 +17,7 @@ internal static class BackendComms
|
||||
{
|
||||
var resp = await Client.GetAsync(ApiBaseUrl + "season");
|
||||
if (resp.IsSuccessStatusCode) return await resp.Content.ReadFromJsonAsync<List<Anime>>(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<Anime>(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<List<Anime>>(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<List<User>>(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<List<Watch>>(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<List<Watch>>(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<List<WatchExtended>>(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<List<WatchExtended>>(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<Register>(JsonSerializerOptions);
|
||||
LogBoy.AddToLog(resp.RequestMessage?.RequestUri + " " + resp.StatusCode);
|
||||
await LogBoy.LogResponse(resp);
|
||||
return null;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -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() + "] ");
|
||||
|
||||
@@ -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<Auth?> ReadAuth()
|
||||
{
|
||||
|
||||
12
APP/Utility/WebBoy.cs
Normal file
12
APP/Utility/WebBoy.cs
Normal file
@@ -0,0 +1,12 @@
|
||||
namespace APP.Utility;
|
||||
|
||||
internal static class WebBoy
|
||||
{
|
||||
private static readonly HttpClient Client = new();
|
||||
|
||||
internal static async Task<Bitmap> DownloadImage(string url)
|
||||
{
|
||||
await using var s = await Client.GetStreamAsync(url);
|
||||
return new Bitmap(s);
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user