Browse Source

install prereqs & show tooltip after navigate

pull/5/head
JT 1 year ago
parent
commit
1e128d59ef
  1. 2
      StabilityMatrix/Helper/EventManager.cs
  2. 2
      StabilityMatrix/LaunchPage.xaml
  3. 6
      StabilityMatrix/ViewModels/LaunchViewModel.cs
  4. 28
      StabilityMatrix/ViewModels/MainWindowViewModel.cs

2
StabilityMatrix/Helper/EventManager.cs

@ -14,7 +14,9 @@ public class EventManager
public event EventHandler<int>? GlobalProgressChanged;
public event EventHandler<Type>? 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);
}

2
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">
<StackPanel Orientation="Horizontal">
<Grid HorizontalAlignment="Left">

6
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();

28
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<MainWindowViewModel> logger;
private readonly IPyRunner pyRunner;
private const string DefaultPackageName = "stable-diffusion-webui";
public MainWindowViewModel(ISettingsManager settingsManager, IPackageFactory packageFactory,
IPrerequisiteHelper prerequisiteHelper, ILogger<MainWindowViewModel> logger)
IPrerequisiteHelper prerequisiteHelper, ILogger<MainWindowViewModel> 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<string?> DownloadPackage(BasePackage selectedPackage, string version)

Loading…
Cancel
Save