From 512767f52c1b60f56581322055679541e949dcfe Mon Sep 17 00:00:00 2001 From: JT Date: Thu, 25 May 2023 00:34:15 -0700 Subject: [PATCH] Added DownloadPackage and a few other related stuff to BasePackage & implemented it in A3WebUI --- StabilityMatrix/Api/IGithubApi.cs | 12 +++ StabilityMatrix/App.xaml.cs | 4 + StabilityMatrix/Helper/SettingsManager.cs | 2 + StabilityMatrix/LaunchPage.xaml | 2 + StabilityMatrix/MainWindow.xaml | 95 ++++++++++--------- StabilityMatrix/MainWindow.xaml.cs | 30 ++---- StabilityMatrix/Models/Api/GithubRelease.cs | 9 ++ StabilityMatrix/Models/BasePackage.cs | 14 ++- StabilityMatrix/Models/Packages/A3WebUI.cs | 45 +++++++++ .../Models/Packages/DankDiffusion.cs | 10 +- StabilityMatrix/StabilityMatrix.csproj | 2 + .../ViewModels/InstallerViewModel.cs | 2 +- .../ViewModels/MainWindowViewModel.cs | 50 ++++++++++ .../ViewModels/SettingsViewModel.cs | 6 ++ 14 files changed, 214 insertions(+), 69 deletions(-) create mode 100644 StabilityMatrix/Api/IGithubApi.cs create mode 100644 StabilityMatrix/Models/Api/GithubRelease.cs create mode 100644 StabilityMatrix/ViewModels/MainWindowViewModel.cs diff --git a/StabilityMatrix/Api/IGithubApi.cs b/StabilityMatrix/Api/IGithubApi.cs new file mode 100644 index 00000000..bebad4a6 --- /dev/null +++ b/StabilityMatrix/Api/IGithubApi.cs @@ -0,0 +1,12 @@ +using System.Threading.Tasks; +using Refit; +using StabilityMatrix.Models.Api; + +namespace StabilityMatrix.Api; + +[Headers("User-Agent: StabilityMatrix")] +public interface IGithubApi +{ + [Get("/repos/{username}/{repository}/releases/latest")] + Task GetLatestRelease(string username, string repository); +} diff --git a/StabilityMatrix/App.xaml.cs b/StabilityMatrix/App.xaml.cs index f940fb1f..a6e28115 100644 --- a/StabilityMatrix/App.xaml.cs +++ b/StabilityMatrix/App.xaml.cs @@ -1,5 +1,7 @@ using System.Windows; using Microsoft.Extensions.DependencyInjection; +using Refit; +using StabilityMatrix.Api; using StabilityMatrix.Helper; using StabilityMatrix.Services; using StabilityMatrix.ViewModels; @@ -20,8 +22,10 @@ namespace StabilityMatrix serviceCollection.AddTransient(); serviceCollection.AddTransient(); serviceCollection.AddTransient(); + serviceCollection.AddTransient(); serviceCollection.AddSingleton(); serviceCollection.AddSingleton(); + serviceCollection.AddRefitClient(); var provider = serviceCollection.BuildServiceProvider(); var window = provider.GetRequiredService(); diff --git a/StabilityMatrix/Helper/SettingsManager.cs b/StabilityMatrix/Helper/SettingsManager.cs index 451892c2..913fa817 100644 --- a/StabilityMatrix/Helper/SettingsManager.cs +++ b/StabilityMatrix/Helper/SettingsManager.cs @@ -28,6 +28,8 @@ public class SettingsManager : ISettingsManager } LoadSettings(); + + } public void SetTheme(string theme) diff --git a/StabilityMatrix/LaunchPage.xaml b/StabilityMatrix/LaunchPage.xaml index 99e0393f..92666828 100644 --- a/StabilityMatrix/LaunchPage.xaml +++ b/StabilityMatrix/LaunchPage.xaml @@ -5,6 +5,8 @@ xmlns:d="http://schemas.microsoft.com/expression/blend/2008" xmlns:ui="http://schemas.lepo.co/wpfui/2022/xaml" xmlns:local="clr-namespace:StabilityMatrix" + Background="{DynamicResource ApplicationBackgroundBrush}" + Foreground="{DynamicResource TextFillColorPrimaryBrush}" mc:Ignorable="d" Title="LaunchPage" d:DesignHeight="700" d:DesignWidth="1100"> diff --git a/StabilityMatrix/MainWindow.xaml b/StabilityMatrix/MainWindow.xaml index 81d6d1ab..f36c9157 100644 --- a/StabilityMatrix/MainWindow.xaml +++ b/StabilityMatrix/MainWindow.xaml @@ -1,57 +1,64 @@ + xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation" + xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml" + xmlns:d="http://schemas.microsoft.com/expression/blend/2008" + xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006" + xmlns:local="clr-namespace:StabilityMatrix" + xmlns:ui="http://schemas.lepo.co/wpfui/2022/xaml" + mc:Ignorable="d" + Background="{DynamicResource ApplicationBackgroundBrush}" + Foreground="{DynamicResource TextFillColorPrimaryBrush}" + ExtendsContentIntoTitleBar="True" + WindowBackdropType="Mica" + Loaded="MainWindow_OnLoaded" + Title="Stability Matrix" Height="700" Width="1100"> - + - - - - - - - - - - - - - - - - - - - - - - - - - + + + + + + + + + + + + + + + + + + + + + + + + + + + + +