From cbba78d07d576f8d4f13e3a38f6d7969410b78d2 Mon Sep 17 00:00:00 2001 From: Dexrn ZacAttack Date: Mon, 3 Mar 2025 07:44:32 -0800 Subject: [PATCH] better about screen --- .gitignore | 1 + BuildScripts/build.bat | 1 + BuildScripts/contributors.py | 32 +++++++++++++++++ Controls/AppTile.xaml | 2 +- Controls/ApplicationInfo.xaml | 32 +++++++++++++++++ Controls/ApplicationInfo.xaml.cs | 60 ++++++++++++++++++++++++++++++++ Controls/ContributorInfo.xaml | 22 +++--------- Controls/ContributorInfo.xaml.cs | 8 +++-- MainWindow.xaml.cs | 2 +- Pages/AboutPage.xaml | 23 ++++-------- Pages/AboutPage.xaml.cs | 29 +++++++-------- WinDurango.csproj | 14 ++++++++ 12 files changed, 171 insertions(+), 55 deletions(-) create mode 100644 BuildScripts/build.bat create mode 100644 BuildScripts/contributors.py create mode 100644 Controls/ApplicationInfo.xaml create mode 100644 Controls/ApplicationInfo.xaml.cs diff --git a/.gitignore b/.gitignore index d01f5f9..903dd5f 100644 --- a/.gitignore +++ b/.gitignore @@ -399,3 +399,4 @@ FodyWeavers.xsd .idea # Other +Assets/contributors.txt diff --git a/BuildScripts/build.bat b/BuildScripts/build.bat new file mode 100644 index 0000000..fb8444e --- /dev/null +++ b/BuildScripts/build.bat @@ -0,0 +1 @@ +py BuildScripts\contributors.py \ No newline at end of file diff --git a/BuildScripts/contributors.py b/BuildScripts/contributors.py new file mode 100644 index 0000000..6f920aa --- /dev/null +++ b/BuildScripts/contributors.py @@ -0,0 +1,32 @@ +import json +import os + +f = open('Assets/contributors.txt', 'w+') + +try: + import requests +except ImportError: + # didn't even know you could do this + os.system("pip install requests") + import requests +except: + print("Requests is missing and the script couldn't install it...") + exit(0) + +try: + contribs = requests.get("https://api.github.com/repos/WinDurango/WinDurango.UI/contributors?anon=1&per_page=50") + + for contributor in contribs.json(): + # why tf did they call it login + name = contributor.get("login", None) + pfp = contributor.get("avatar_url", None) + url = contributor.get("html_url", None) + contribution_count = str(contributor.get("contributions", None)) + f.write(name.replace(";", "WD_CONTRIB_SEMICOLON") + ";" + pfp.replace(";", "WD_CONTRIB_SEMICOLON") + ";" + url.replace(";", "WD_CONTRIB_SEMICOLON") + ";" + contribution_count + "\n") +except: + print("Couldn't fetch contributor information.") + exit(0) + +f.close() + + diff --git a/Controls/AppTile.xaml b/Controls/AppTile.xaml index 705db40..62b53b2 100644 --- a/Controls/AppTile.xaml +++ b/Controls/AppTile.xaml @@ -11,7 +11,7 @@ - + diff --git a/Controls/ApplicationInfo.xaml b/Controls/ApplicationInfo.xaml new file mode 100644 index 0000000..caebfdc --- /dev/null +++ b/Controls/ApplicationInfo.xaml @@ -0,0 +1,32 @@ + + + + + + + WinDurango UI + + + + + Stars + Unknown + + + Watchers + Unknown + + + Forks + Unknown + + + + diff --git a/Controls/ApplicationInfo.xaml.cs b/Controls/ApplicationInfo.xaml.cs new file mode 100644 index 0000000..7df7cb4 --- /dev/null +++ b/Controls/ApplicationInfo.xaml.cs @@ -0,0 +1,60 @@ +using Microsoft.UI.Xaml; +using Microsoft.UI.Xaml.Controls; +using Microsoft.UI.Xaml.Controls.Primitives; +using Microsoft.UI.Xaml.Data; +using Microsoft.UI.Xaml.Input; +using Microsoft.UI.Xaml.Media; +using Microsoft.UI.Xaml.Media.Imaging; +using Microsoft.UI.Xaml.Navigation; +using System; +using System.Collections.Generic; +using System.IO; +using System.Linq; +using System.Net.Http; +using System.Runtime.InteropServices.WindowsRuntime; +using System.Security.Policy; +using System.Text.Json; +using System.Threading.Tasks; +using Windows.Foundation; +using Windows.Foundation.Collections; +using WinDurango.UI.Utils; + +namespace WinDurango.UI.Controls +{ + public sealed partial class ApplicationInfo : UserControl + { + public ApplicationInfo() + { + this.InitializeComponent(); + this.appPicture.ProfilePicture = new BitmapImage(new System.Uri("https://avatars.githubusercontent.com/WinDurango")); + this.appInfo.Text = $"Version {App.Version}"; + GetRepoInfo(); + } + + public async void GetRepoInfo() + { + using HttpClient client = new HttpClient(); + try + { + client.DefaultRequestHeaders.UserAgent.ParseAdd("Mozilla/5.0 (compatible; GitHubAPI/1.0)"); + string res = await client.GetStringAsync("https://api.github.com/repos/WinDurango/WinDurango.UI"); + using (JsonDocument doc = JsonDocument.Parse(res)) + { + JsonElement root = doc.RootElement; + int stars = root.GetProperty("stargazers_count").GetInt32(); + int forks = root.GetProperty("forks").GetInt32(); + int watchers = root.GetProperty("subscribers_count").GetInt32(); + + this.stars.Content = stars.ToString(); + this.forks.Content = forks.ToString(); + this.watchers.Content = watchers.ToString(); + } + } + catch (System.Exception ex) + { + Logger.WriteError("Couldn't fetch https://api.github.com/WinDurango/WinDurango.UI"); + Logger.WriteException(ex); + } + } + } +} diff --git a/Controls/ContributorInfo.xaml b/Controls/ContributorInfo.xaml index a373bdc..0cd1544 100644 --- a/Controls/ContributorInfo.xaml +++ b/Controls/ContributorInfo.xaml @@ -9,22 +9,8 @@ d:DesignHeight="300" d:DesignWidth="400"> - - - - - - - - - - - - - - - - - - + + + Name + diff --git a/Controls/ContributorInfo.xaml.cs b/Controls/ContributorInfo.xaml.cs index 8369767..de5f073 100644 --- a/Controls/ContributorInfo.xaml.cs +++ b/Controls/ContributorInfo.xaml.cs @@ -1,13 +1,17 @@ using Microsoft.UI.Xaml.Controls; +using Microsoft.UI.Xaml.Media.Imaging; +using System; namespace WinDurango.UI.Controls { public sealed partial class ContributorInfo : UserControl { - public ContributorInfo() + public ContributorInfo(string name, string pfp, string link) { this.InitializeComponent(); + this.developerName.Content = name; + this.developerPicture.ProfilePicture = new BitmapImage(new Uri(pfp)); + this.developerName.NavigateUri = new Uri(link); } - } } diff --git a/MainWindow.xaml.cs b/MainWindow.xaml.cs index ce31169..98463e6 100644 --- a/MainWindow.xaml.cs +++ b/MainWindow.xaml.cs @@ -39,7 +39,7 @@ namespace WinDurango.UI "AppsListPage" => typeof(AppsListPage), "AboutPage" => typeof(AboutPage), "NotImplementedPage" => typeof(NotImplementedPage), - _ => typeof(AppsListPage) + _ => typeof(NotImplementedPage) }; if (contentFrame.Content?.GetType() != pageType && contentFrame.Navigate(pageType) && contentFrame.Content is AppsListPage appsList) diff --git a/Pages/AboutPage.xaml b/Pages/AboutPage.xaml index 85cb934..2656637 100644 --- a/Pages/AboutPage.xaml +++ b/Pages/AboutPage.xaml @@ -9,22 +9,11 @@ mc:Ignorable="d"> - - - - - - - - + + + + + + diff --git a/Pages/AboutPage.xaml.cs b/Pages/AboutPage.xaml.cs index b366bca..49b09e2 100644 --- a/Pages/AboutPage.xaml.cs +++ b/Pages/AboutPage.xaml.cs @@ -1,33 +1,30 @@ using Microsoft.UI.Xaml.Controls; using Microsoft.UI.Xaml.Media.Imaging; using System; +using System.IO; +using WinDurango.UI.Controls; namespace WinDurango.UI.Pages { public sealed partial class AboutPage : Page { - private static Uri GetGitHubPfp(string username) - { - return new Uri($"https://github.com/{username}.png"); - } public AboutPage() { this.InitializeComponent(); - dexrn_Info.developerPicture.ProfilePicture = new BitmapImage(GetGitHubPfp("DexrnZacAttack")); - dexrn_Info.developerName.Content = "DexrnZacAttack"; - dexrn_Info.developerName.NavigateUri = new Uri("https://github.com/DexrnZacAttack"); - dexrn_Info.developerInfo.Text = "UI design, functionality, learning C#"; - danilwhale_Info.developerPicture.ProfilePicture = new BitmapImage(GetGitHubPfp("danilwhale")); - danilwhale_Info.developerName.Content = "danilwhale"; - danilwhale_Info.developerName.NavigateUri = new Uri("https://github.com/danilwhale"); - danilwhale_Info.developerInfo.Text = "Refactoring, teaching, bug fixing, etc"; - windurango_Info.developerInfo.Text = $"Version {App.Version}"; - windurango_Info.developerName.Content = "WinDurango.UI"; - windurango_Info.developerName.NavigateUri = new Uri("https://github.com/WinDurango/WinDurango.UI"); - windurango_Info.developerPicture.ProfilePicture = new BitmapImage(GetGitHubPfp("WinDurango")); + string[] lines = File.ReadAllLines("Assets/contributors.txt"); + foreach (var contributor in lines) + { + string[] info = contributor.Split(";"); + string name = info[0]; + string avatar = info[1]; + string link = info[2]; + string contributionCount = info[3]; + + contributorList.Children.Add(new ContributorInfo(name, avatar, link)); + } } } } diff --git a/WinDurango.csproj b/WinDurango.csproj index b7246c4..002744d 100644 --- a/WinDurango.csproj +++ b/WinDurango.csproj @@ -36,6 +36,7 @@ + @@ -105,6 +106,9 @@ + + Always + Always @@ -200,6 +204,12 @@ + + + MSBuild:Compile + + + MSBuild:Compile @@ -217,4 +227,8 @@ MSBuild:Compile + + + +