diff --git a/StabilityMatrix/Helper/EventManager.cs b/StabilityMatrix/Helper/EventManager.cs index 2a892ae6..6ddcf47b 100644 --- a/StabilityMatrix/Helper/EventManager.cs +++ b/StabilityMatrix/Helper/EventManager.cs @@ -14,7 +14,9 @@ public class EventManager public event EventHandler? GlobalProgressChanged; public event EventHandler? PageChangeRequested; public event EventHandler? InstalledPackagesChanged; + public event EventHandler? OneClickInstallFinished; public void OnGlobalProgressChanged(int progress) => GlobalProgressChanged?.Invoke(this, progress); public void RequestPageChange(Type pageType) => PageChangeRequested?.Invoke(this, pageType); public void OnInstalledPackagesChanged() => InstalledPackagesChanged?.Invoke(this, EventArgs.Empty); + public void OnOneClickInstallFinished() => OneClickInstallFinished?.Invoke(this, EventArgs.Empty); } diff --git a/StabilityMatrix/LaunchPage.xaml b/StabilityMatrix/LaunchPage.xaml index ab888e25..adb0dfc6 100644 --- a/StabilityMatrix/LaunchPage.xaml +++ b/StabilityMatrix/LaunchPage.xaml @@ -104,7 +104,7 @@ FontSize="18" Grid.Column="0" Grid.Row="0" - IsOpen="{Binding isLaunchTeachingTipsOpen, Mode=TwoWay}" + IsOpen="{Binding IsLaunchTeachingTipsOpen, Mode=TwoWay}" Placement="Bottom"> diff --git a/StabilityMatrix/ViewModels/LaunchViewModel.cs b/StabilityMatrix/ViewModels/LaunchViewModel.cs index 6d32b49c..a9b230de 100644 --- a/StabilityMatrix/ViewModels/LaunchViewModel.cs +++ b/StabilityMatrix/ViewModels/LaunchViewModel.cs @@ -85,10 +85,16 @@ public partial class LaunchViewModel : ObservableObject SetProcessRunning(false); EventManager.Instance.InstalledPackagesChanged += OnInstalledPackagesChanged; + EventManager.Instance.OneClickInstallFinished += OnOneClickInstallFinished; ToastNotificationManagerCompat.OnActivated += ToastNotificationManagerCompatOnOnActivated; } + private void OnOneClickInstallFinished(object? sender, EventArgs e) + { + IsLaunchTeachingTipsOpen = true; + } + private void OnInstalledPackagesChanged(object? sender, EventArgs e) { OnLoaded(); diff --git a/StabilityMatrix/ViewModels/MainWindowViewModel.cs b/StabilityMatrix/ViewModels/MainWindowViewModel.cs index 5270d08e..29276e85 100644 --- a/StabilityMatrix/ViewModels/MainWindowViewModel.cs +++ b/StabilityMatrix/ViewModels/MainWindowViewModel.cs @@ -10,6 +10,7 @@ using CommunityToolkit.Mvvm.Input; using Microsoft.Extensions.Logging; using StabilityMatrix.Helper; using StabilityMatrix.Models; +using StabilityMatrix.Python; using Wpf.Ui.Appearance; using EventManager = StabilityMatrix.Helper.EventManager; @@ -21,15 +22,17 @@ public partial class MainWindowViewModel : ObservableObject private readonly IPackageFactory packageFactory; private readonly IPrerequisiteHelper prerequisiteHelper; private readonly ILogger logger; + private readonly IPyRunner pyRunner; private const string DefaultPackageName = "stable-diffusion-webui"; public MainWindowViewModel(ISettingsManager settingsManager, IPackageFactory packageFactory, - IPrerequisiteHelper prerequisiteHelper, ILogger logger) + IPrerequisiteHelper prerequisiteHelper, ILogger logger, IPyRunner pyRunner) { this.settingsManager = settingsManager; this.packageFactory = packageFactory; this.prerequisiteHelper = prerequisiteHelper; this.logger = logger; + this.pyRunner = pyRunner; } [ObservableProperty] @@ -126,6 +129,19 @@ public partial class MainWindowViewModel : ObservableObject } } + SubHeaderText = "Installing prerequisites..."; + IsIndeterminate = true; + if (!PyRunner.PipInstalled) + { + await pyRunner.SetupPip(); + } + + if (!PyRunner.VenvInstalled) + { + await pyRunner.InstallPackage("virtualenv"); + } + IsIndeterminate = false; + // get latest version & download & install SubHeaderText = "Getting latest version..."; var latestVersion = await a1111.GetLatestVersion(); @@ -149,9 +165,15 @@ public partial class MainWindowViewModel : ObservableObject HeaderText = "Installation complete!"; OneClickInstallProgress = 100; - SubHeaderText = "Proceeding to Launch page in 5 seconds..."; - await Task.Delay(5000); + SubHeaderText = "Proceeding to Launch page in 3 seconds..."; + await Task.Delay(1000); + SubHeaderText = "Proceeding to Launch page in 2 seconds..."; + await Task.Delay(1000); + SubHeaderText = "Proceeding to Launch page in 1 second..."; + await Task.Delay(1000); + IsAdvancedMode = true; + EventManager.Instance.OnOneClickInstallFinished(); } private Task DownloadPackage(BasePackage selectedPackage, string version)