Browse Source

Close installer when done installing package & also show uninstalling indicator

pull/5/head
JT 1 year ago
parent
commit
a9f2c54887
  1. 1
      StabilityMatrix/InstallerWindow.xaml
  2. 1
      StabilityMatrix/InstallerWindow.xaml.cs
  3. 11
      StabilityMatrix/PackageManagerPage.xaml
  4. 11
      StabilityMatrix/ViewModels/InstallerViewModel.cs
  5. 6
      StabilityMatrix/ViewModels/OneClickInstallViewModel.cs
  6. 5
      StabilityMatrix/ViewModels/PackageManagerViewModel.cs

1
StabilityMatrix/InstallerWindow.xaml

@ -10,6 +10,7 @@
d:DesignHeight="600"
d:DesignWidth="700"
WindowBackdropType="Mica"
WindowStartupLocation="CenterOwner"
d:DataContext="{d:DesignInstance Type=viewModels:InstallerViewModel,
IsDesignTimeCreatable=True}"
mc:Ignorable="d"

1
StabilityMatrix/InstallerWindow.xaml.cs

@ -19,6 +19,7 @@ namespace StabilityMatrix
this.viewModel = viewModel;
InitializeComponent();
DataContext = viewModel;
viewModel.PackageInstalled += (_, _) => Close();
}
private async void InstallPage_OnLoaded(object sender, RoutedEventArgs e)

11
StabilityMatrix/PackageManagerPage.xaml

@ -12,6 +12,10 @@
xmlns:models="clr-namespace:StabilityMatrix.Models"
xmlns:ui="http://schemas.lepo.co/wpfui/2022/xaml"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml">
<Page.Resources>
<BooleanToVisibilityConverter x:Key="BoolToVisConverter"/>
</Page.Resources>
<Grid Margin="16">
<Grid.RowDefinitions>
@ -125,6 +129,13 @@
Visibility="{Binding InstallButtonVisibility, FallbackValue=Visible}"
Width="100" />
</StackPanel>
<StackPanel Orientation="Horizontal" Visibility="{Binding IsUninstalling,
Converter={StaticResource BoolToVisConverter}}">
<ui:ProgressRing Height="24" Width="24" Margin="8, 16, 8, 8"
VerticalAlignment="Center"
IsIndeterminate="True" HorizontalAlignment="Left"/>
<TextBlock Text="Uninstalling..." VerticalAlignment="Center" Margin="0,8,0,0"/>
</StackPanel>
</StackPanel>
</StackPanel>
</Grid>

11
StabilityMatrix/ViewModels/InstallerViewModel.cs

@ -75,7 +75,9 @@ public partial class InstallerViewModel : ObservableObject
public Visibility ProgressBarVisibility => ProgressValue > 0 || IsIndeterminate ? Visibility.Visible : Visibility.Collapsed;
public string ReleaseLabelText => IsReleaseMode ? "Version" : "Branch";
internal event EventHandler? PackageInstalled;
public InstallerViewModel(ISettingsManager settingsManager, ILogger<InstallerViewModel> logger, IPyRunner pyRunner,
IPackageFactory packageFactory)
@ -104,6 +106,7 @@ public partial class InstallerViewModel : ObservableObject
private async Task Install()
{
await ActuallyInstall();
OnPackageInstalled();
}
public async Task OnLoaded()
@ -134,7 +137,7 @@ public partial class InstallerViewModel : ObservableObject
ReleaseNotes = string.Empty;
AvailableVersions?.Clear();
// This can swallow exceptions if you don't explicity try/catch
// This can swallow exceptions if you don't explicitly try/catch
// Idk how to make it better tho
Task.Run(async () =>
{
@ -311,5 +314,7 @@ public partial class InstallerViewModel : ObservableObject
EventManager.Instance.OnGlobalProgressChanged(progress);
}
private void OnPackageInstalled() => PackageInstalled?.Invoke(this, EventArgs.Empty);
}

6
StabilityMatrix/ViewModels/OneClickInstallViewModel.cs

@ -41,9 +41,11 @@ public partial class OneClickInstallViewModel : ObservableObject
this.logger = logger;
this.pyRunner = pyRunner;
HeaderText = "Click the Install button below to get started!";
HeaderText = "Welcome to Stability Matrix!";
SubHeaderText =
"This will install the latest version of Stable Diffusion WebUI by Automatic1111.\nIf you don't know what this means, don't worry, you'll be generating images soon!";
"Click the Install button below to get started!\n" +
"This will install the latest version of Stable Diffusion WebUI by Automatic1111.\n" +
"If you don't know what this means, don't worry, you'll be generating images soon!";
ShowInstallButton = true;
}

5
StabilityMatrix/ViewModels/PackageManagerViewModel.cs

@ -50,6 +50,9 @@ public partial class PackageManagerViewModel : ObservableObject
[ObservableProperty]
private Visibility installButtonVisibility;
[ObservableProperty]
private bool isUninstalling;
[ObservableProperty]
[NotifyPropertyChangedFor(nameof(SelectedPackage))]
private bool updateAvailable;
@ -170,6 +173,7 @@ public partial class PackageManagerViewModel : ObservableObject
if (result == ContentDialogResult.Primary)
{
IsUninstalling = true;
var deleteTask = DeleteDirectoryAsync(SelectedPackage.Path);
var taskResult = await dialogErrorHandler.TryAsync(deleteTask,
"Some files could not be deleted. Please close any open files in the package directory and try again.");
@ -178,6 +182,7 @@ public partial class PackageManagerViewModel : ObservableObject
settingsManager.RemoveInstalledPackage(SelectedPackage);
}
await OnLoaded();
IsUninstalling = false;
}
}

Loading…
Cancel
Save