diff --git a/StabilityMatrix/Helper/ISettingsManager.cs b/StabilityMatrix/Helper/ISettingsManager.cs index 5663023d..15f5ad86 100644 --- a/StabilityMatrix/Helper/ISettingsManager.cs +++ b/StabilityMatrix/Helper/ISettingsManager.cs @@ -10,4 +10,5 @@ public interface ISettingsManager void SetActiveInstalledPackage(InstalledPackage? p); void SetHasInstalledPip(bool hasInstalledPip); void SetHasInstalledVenv(bool hasInstalledVenv); + void SetNavExpanded(bool navExpanded); } diff --git a/StabilityMatrix/Helper/SettingsManager.cs b/StabilityMatrix/Helper/SettingsManager.cs index 55d957ae..5fbcd297 100644 --- a/StabilityMatrix/Helper/SettingsManager.cs +++ b/StabilityMatrix/Helper/SettingsManager.cs @@ -68,6 +68,12 @@ public class SettingsManager : ISettingsManager SaveSettings(); } + public void SetNavExpanded(bool navExpanded) + { + Settings.IsNavExpanded = navExpanded; + SaveSettings(); + } + private void LoadSettings() { var settingsContent = File.ReadAllText(SettingsPath); diff --git a/StabilityMatrix/InstallPage.xaml b/StabilityMatrix/InstallPage.xaml index c90029ed..bfafae7c 100644 --- a/StabilityMatrix/InstallPage.xaml +++ b/StabilityMatrix/InstallPage.xaml @@ -6,8 +6,8 @@ xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006" xmlns:ui="http://schemas.lepo.co/wpfui/2022/xaml" xmlns:models="clr-namespace:StabilityMatrix.Models" - d:DesignHeight="700" - d:DesignWidth="1100" + d:DesignHeight="450" + d:DesignWidth="700" Loaded="InstallPage_OnLoaded" Background="{DynamicResource ApplicationBackgroundBrush}" Foreground="{DynamicResource TextFillColorPrimaryBrush}" @@ -47,8 +47,18 @@ - - + + + + + + + + + diff --git a/StabilityMatrix/MainWindow.xaml b/StabilityMatrix/MainWindow.xaml index 51f65c3e..bd614c81 100644 --- a/StabilityMatrix/MainWindow.xaml +++ b/StabilityMatrix/MainWindow.xaml @@ -26,7 +26,9 @@ + IsBackButtonVisible="Collapsed" + PaneOpened="RootNavigation_OnPaneOpened" + PaneClosed="RootNavigation_OnPaneClosed"> $"{Environment.GetFolderPath(Environment.SpecialFolder.ApplicationData)}\\StabilityMatrix\\Packages\\{Name}.zip"; diff --git a/StabilityMatrix/Models/Packages/A3WebUI.cs b/StabilityMatrix/Models/Packages/A3WebUI.cs index 2a719f69..a773334d 100644 --- a/StabilityMatrix/Models/Packages/A3WebUI.cs +++ b/StabilityMatrix/Models/Packages/A3WebUI.cs @@ -17,6 +17,7 @@ public class A3WebUI: BasePackage public override string DisplayName => "Stable Diffusion WebUI"; public override string Author => "AUTOMATIC1111"; public override string GithubUrl => "https://github.com/AUTOMATIC1111/stable-diffusion-webui"; + public override async Task DownloadPackage() { var githubApi = RestService.For("https://api.github.com"); diff --git a/StabilityMatrix/Models/Settings.cs b/StabilityMatrix/Models/Settings.cs index ddb71aaa..a06e903f 100644 --- a/StabilityMatrix/Models/Settings.cs +++ b/StabilityMatrix/Models/Settings.cs @@ -10,4 +10,5 @@ public class Settings public Guid? ActiveInstalledPackage { get; set; } public bool HasInstalledPip { get; set; } public bool HasInstalledVenv { get; set; } + public bool IsNavExpanded { get; set; } } diff --git a/StabilityMatrix/ViewModels/InstallerViewModel.cs b/StabilityMatrix/ViewModels/InstallerViewModel.cs index 3045998d..6da1b29c 100644 --- a/StabilityMatrix/ViewModels/InstallerViewModel.cs +++ b/StabilityMatrix/ViewModels/InstallerViewModel.cs @@ -5,26 +5,29 @@ using StabilityMatrix.Helper; using StabilityMatrix.Models; using System.ComponentModel; using System.Diagnostics; -using System.Dynamic; using System.IO; using System.IO.Compression; using System.Runtime.CompilerServices; using StabilityMatrix.Models.Packages; using System.Linq; using System.Windows; +using CommunityToolkit.Mvvm.ComponentModel; using CommunityToolkit.Mvvm.Input; using Microsoft.Extensions.Logging; namespace StabilityMatrix.ViewModels; -public class InstallerViewModel : INotifyPropertyChanged +public partial class InstallerViewModel : ObservableObject { private readonly ILogger logger; private readonly ISettingsManager settingsManager; - private string installedText; private int progressValue; - private bool isIndeterminate; private BasePackage selectedPackage; + + [ObservableProperty] + private string installedText; + [ObservableProperty] + private bool isIndeterminate; public InstallerViewModel(ILogger logger, ISettingsManager settingsManager) { @@ -47,16 +50,9 @@ public class InstallerViewModel : INotifyPropertyChanged public ObservableCollection Packages { get; } - public string InstalledText - { - get => installedText; - private set - { - if (value == installedText) return; - installedText = value; - OnPropertyChanged(); - } - } + + [ObservableProperty] + private Visibility packageInstalledVisibility; public int ProgressValue { @@ -70,17 +66,6 @@ public class InstallerViewModel : INotifyPropertyChanged } } - public bool IsIndeterminate - { - get => isIndeterminate; - set - { - if (value == isIndeterminate) return; - isIndeterminate = value; - OnPropertyChanged(); - } - } - public BasePackage SelectedPackage { get => selectedPackage; @@ -88,6 +73,11 @@ public class InstallerViewModel : INotifyPropertyChanged { selectedPackage = value; OnPropertyChanged(); + + PackageInstalledVisibility = + settingsManager.Settings.InstalledPackages.Any(p => p.Name == selectedPackage.Name) + ? Visibility.Visible + : Visibility.Collapsed; } } @@ -222,9 +212,4 @@ public class InstallerViewModel : INotifyPropertyChanged } public event PropertyChangedEventHandler PropertyChanged; - - protected virtual void OnPropertyChanged([CallerMemberName] string propertyName = null) - { - PropertyChanged?.Invoke(this, new PropertyChangedEventArgs(propertyName)); - } }