From 94115fd7007391dcf06c9be63794c8dbcf78676a Mon Sep 17 00:00:00 2001 From: JT Date: Sun, 20 Aug 2023 16:01:08 -0700 Subject: [PATCH 1/8] Added Fooocus & select new data directory button --- CHANGELOG.md | 4 + StabilityMatrix.Avalonia/App.axaml.cs | 1 + .../StabilityMatrix.Avalonia.csproj | 2 +- .../Dialogs/SelectModelVersionViewModel.cs | 7 +- .../ViewModels/SettingsViewModel.cs | 36 +++++ .../Views/SettingsPage.axaml | 43 ++++-- StabilityMatrix.Core/Helper/HardwareHelper.cs | 10 ++ .../Models/Packages/Fooocus.cs | 124 ++++++++++++++++++ .../Models/Packages/VladAutomatic.cs | 18 +-- 9 files changed, 214 insertions(+), 31 deletions(-) create mode 100644 StabilityMatrix.Core/Models/Packages/Fooocus.cs diff --git a/CHANGELOG.md b/CHANGELOG.md index 764ee032..ebe4364c 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -6,6 +6,10 @@ The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.1.0/), and this project adheres to [Semantic Versioning 2.0](https://semver.org/spec/v2.0.0.html). ## v2.2.1 +### Added +- New installable Package - [Fooocus](https://github.com/lllyasviel/Fooocus) +- Added "Select New Data Directory" button to Settings + ### Fixed - Fixed SD.Next shared folders config not working with new config format, reverted to Junctions / Symlinks diff --git a/StabilityMatrix.Avalonia/App.axaml.cs b/StabilityMatrix.Avalonia/App.axaml.cs index 382f7274..487b73a0 100644 --- a/StabilityMatrix.Avalonia/App.axaml.cs +++ b/StabilityMatrix.Avalonia/App.axaml.cs @@ -308,6 +308,7 @@ public sealed class App : Application services.AddSingleton(); services.AddSingleton(); services.AddSingleton(); + services.AddSingleton(); } private static IServiceCollection ConfigureServices() diff --git a/StabilityMatrix.Avalonia/StabilityMatrix.Avalonia.csproj b/StabilityMatrix.Avalonia/StabilityMatrix.Avalonia.csproj index 2acc5271..f9d7a498 100644 --- a/StabilityMatrix.Avalonia/StabilityMatrix.Avalonia.csproj +++ b/StabilityMatrix.Avalonia/StabilityMatrix.Avalonia.csproj @@ -8,7 +8,7 @@ app.manifest true ./Assets/Icon.ico - 2.1.1-dev.1 + 2.3.0-dev.1 $(Version) true diff --git a/StabilityMatrix.Avalonia/ViewModels/Dialogs/SelectModelVersionViewModel.cs b/StabilityMatrix.Avalonia/ViewModels/Dialogs/SelectModelVersionViewModel.cs index d6435c85..082859db 100644 --- a/StabilityMatrix.Avalonia/ViewModels/Dialogs/SelectModelVersionViewModel.cs +++ b/StabilityMatrix.Avalonia/ViewModels/Dialogs/SelectModelVersionViewModel.cs @@ -42,8 +42,11 @@ public partial class SelectModelVersionViewModel : ContentDialogViewModelBase var firstImageUrl = value?.ModelVersion?.Images?.FirstOrDefault( img => nsfwEnabled || img.Nsfw == "None")?.Url; - Dispatcher.UIThread.InvokeAsync(async - () => await UpdateImage(firstImageUrl)); + Dispatcher.UIThread.InvokeAsync(async () => + { + SelectedFile = value?.CivitFileViewModels.FirstOrDefault(); + await UpdateImage(firstImageUrl); + }); } partial void OnSelectedFileChanged(CivitFileViewModel? value) diff --git a/StabilityMatrix.Avalonia/ViewModels/SettingsViewModel.cs b/StabilityMatrix.Avalonia/ViewModels/SettingsViewModel.cs index 54026801..7c013f2e 100644 --- a/StabilityMatrix.Avalonia/ViewModels/SettingsViewModel.cs +++ b/StabilityMatrix.Avalonia/ViewModels/SettingsViewModel.cs @@ -329,6 +329,42 @@ public partial class SettingsViewModel : PageViewModelBase "Stability Matrix has been added to the Start Menu for all users.", NotificationType.Success); } + public async Task PickNewDataDirectory() + { + var viewModel = dialogFactory.Get(); + var dialog = new BetterContentDialog + { + IsPrimaryButtonEnabled = false, + IsSecondaryButtonEnabled = false, + IsFooterVisible = false, + Content = new SelectDataDirectoryDialog + { + DataContext = viewModel + } + }; + + var result = await dialog.ShowAsync(); + if (result == ContentDialogResult.Primary) + { + // 1. For portable mode, call settings.SetPortableMode() + if (viewModel.IsPortableMode) + { + settingsManager.SetPortableMode(); + } + // 2. For custom path, call settings.SetLibraryPath(path) + else + { + settingsManager.SetLibraryPath(viewModel.DataDirectory); + } + + // Try to find library again, should be found now + if (!settingsManager.TryFindLibrary()) + { + throw new Exception("Could not find library after setting path"); + } + } + } + #endregion #region Debug Section diff --git a/StabilityMatrix.Avalonia/Views/SettingsPage.axaml b/StabilityMatrix.Avalonia/Views/SettingsPage.axaml index 8e3d6d0d..01443d17 100644 --- a/StabilityMatrix.Avalonia/Views/SettingsPage.axaml +++ b/StabilityMatrix.Avalonia/Views/SettingsPage.axaml @@ -6,6 +6,7 @@ xmlns:ui="using:FluentAvalonia.UI.Controls" xmlns:mocks="clr-namespace:StabilityMatrix.Avalonia.DesignData" xmlns:controls="clr-namespace:StabilityMatrix.Avalonia.Controls" + xmlns:avalonia="clr-namespace:Projektanker.Icons.Avalonia;assembly=Projektanker.Icons.Avalonia" mc:Ignorable="d" d:DesignWidth="800" d:DesignHeight="700" x:DataType="vm:SettingsViewModel" x:CompileBindings="True" @@ -124,7 +125,7 @@ - + + + + + + @@ -181,24 +200,24 @@ IconSource="Code" Command="{Binding LoadDebugInfo}" Header="Debug Options" - Margin="8, 0,8,4"> + Margin="8, 0,8,0"> + Margin="4, 0"> + Margin="4,0"> + Margin="4,0"> @@ -206,10 +225,9 @@ + Margin="4,0"> - @@ -223,30 +241,27 @@ + Margin="4,0">