Browse Source

Rename `InstalledPackage.Name` to `DisplayName`

pull/5/head
Ionite 1 year ago
parent
commit
185863121d
No known key found for this signature in database
  1. 4
      StabilityMatrix/Helper/SettingsManager.cs
  2. 2
      StabilityMatrix/LaunchPage.xaml
  3. 2
      StabilityMatrix/Models/InstalledPackage.cs
  4. 2
      StabilityMatrix/Models/Packages/BaseGitPackage.cs
  5. 135
      StabilityMatrix/PackageManagerPage.xaml
  6. 2
      StabilityMatrix/ViewModels/InstallerViewModel.cs
  7. 2
      StabilityMatrix/ViewModels/LaunchViewModel.cs
  8. 10
      StabilityMatrix/ViewModels/PackageManagerViewModel.cs
  9. 2
      StabilityMatrix/ViewModels/SettingsViewModel.cs

4
StabilityMatrix/Helper/SettingsManager.cs

@ -65,7 +65,7 @@ public class SettingsManager : ISettingsManager
public void UpdatePackageVersionNumber(string name, string? newVersion)
{
var package = Settings.InstalledPackages.FirstOrDefault(x => x.Name == name);
var package = Settings.InstalledPackages.FirstOrDefault(x => x.DisplayName == name);
if (package == null || newVersion == null)
{
return;
@ -77,7 +77,7 @@ public class SettingsManager : ISettingsManager
public void SetLastUpdateCheck(InstalledPackage package)
{
Settings.InstalledPackages.First(p => p.Name == package.Name).LastUpdateCheck = package.LastUpdateCheck;
Settings.InstalledPackages.First(p => p.DisplayName == package.DisplayName).LastUpdateCheck = package.LastUpdateCheck;
SaveSettings();
}

2
StabilityMatrix/LaunchPage.xaml

@ -181,7 +181,7 @@
<TextBlock
Margin="0,5,0,5"
Name="NameTextBlock"
Text="{Binding Name}" />
Text="{Binding DisplayName}" />
</StackPanel>
</DataTemplate>
</ComboBox.ItemTemplate>

2
StabilityMatrix/Models/InstalledPackage.cs

@ -12,7 +12,7 @@ public class InstalledPackage
// Unique ID for the installation
public Guid Id { get; set; }
// User defined name
public string? Name { get; set; }
public string? DisplayName { get; set; }
// Package name
public string? PackageName { get; set; }
// Package version

2
StabilityMatrix/Models/Packages/BaseGitPackage.cs

@ -237,7 +237,7 @@ public abstract class BaseGitPackage : BasePackage
public override async Task<bool> CheckForUpdates(string installedPackageName)
{
var currentVersion = SettingsManager.Settings.InstalledPackages.FirstOrDefault(x => x.Name == installedPackageName)
var currentVersion = SettingsManager.Settings.InstalledPackages.FirstOrDefault(x => x.DisplayName == installedPackageName)
?.PackageVersion;
if (string.IsNullOrWhiteSpace(currentVersion))
{

135
StabilityMatrix/PackageManagerPage.xaml

@ -1,17 +1,17 @@
<Page
Background="{DynamicResource ApplicationBackgroundBrush}"
Foreground="{DynamicResource TextFillColorPrimaryBrush}"
Loaded="InstallPage_OnLoaded"
d:DesignHeight="450"
d:DesignWidth="700"
mc:Ignorable="d"
x:Class="StabilityMatrix.PackageManagerPage"
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
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="450"
d:DesignWidth="700"
Loaded="InstallPage_OnLoaded"
Background="{DynamicResource ApplicationBackgroundBrush}"
Foreground="{DynamicResource TextFillColorPrimaryBrush}"
mc:Ignorable="d">
xmlns:ui="http://schemas.lepo.co/wpfui/2022/xaml"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml">
<Grid Margin="16">
<Grid.RowDefinitions>
@ -19,37 +19,50 @@
<RowDefinition Height="*" />
</Grid.RowDefinitions>
<StackPanel Grid.Row="0" Orientation="Vertical"
Visibility="{Binding ProgressBarVisibility, FallbackValue=Visible}">
<StackPanel
Grid.Row="0"
Orientation="Vertical"
Visibility="{Binding ProgressBarVisibility, FallbackValue=Visible}">
<ProgressBar Value="{Binding ProgressValue, FallbackValue=10}"
IsIndeterminate="{Binding IsIndeterminate, FallbackValue=False}"
Maximum="100" Width="500" />
<TextBlock Text="{Binding ProgressText, FallbackValue=Installing...}"
HorizontalAlignment="Center" Padding="8" />
<ProgressBar
IsIndeterminate="{Binding IsIndeterminate, FallbackValue=False}"
Maximum="100"
Value="{Binding ProgressValue, FallbackValue=10}"
Width="500" />
<TextBlock
HorizontalAlignment="Center"
Padding="8"
Text="{Binding ProgressText, FallbackValue=Installing...}" />
</StackPanel>
<StackPanel Grid.Row="1" Orientation="Horizontal"
Margin="16" HorizontalAlignment="Left">
<StackPanel
Grid.Row="1"
HorizontalAlignment="Left"
Margin="16"
Orientation="Horizontal">
<StackPanel Orientation="Vertical">
<ui:Button Command="{Binding ShowInstallWindowCommand}"
IsEnabled="{Binding InstallButtonEnabled, FallbackValue=true}"
Height="40"
HorizontalAlignment="Stretch"
Foreground="{ui:ThemeResource TextFillColorPrimaryBrush}"
Margin="0,0,0,16"
VerticalContentAlignment="Center"
Background="Green">
<ui:Button
Background="Green"
Command="{Binding ShowInstallWindowCommand}"
Foreground="{ui:ThemeResource TextFillColorPrimaryBrush}"
Height="40"
HorizontalAlignment="Stretch"
IsEnabled="{Binding InstallButtonEnabled, FallbackValue=true}"
Margin="0,0,0,16"
VerticalContentAlignment="Center">
<StackPanel Orientation="Horizontal">
<ui:SymbolIcon Symbol="Add24" />
<Label Margin="8,4,0,0"
Content="Add Package" VerticalContentAlignment="Center" />
<Label
Content="Add Package"
Margin="8,4,0,0"
VerticalContentAlignment="Center" />
</StackPanel>
</ui:Button>
<ListView ItemsSource="{Binding Packages}"
Visibility="{Binding InstallButtonVisibility, FallbackValue=Visible}"
SelectedItem="{Binding SelectedPackage, Mode=TwoWay}">
<ListView
ItemsSource="{Binding Packages}"
SelectedItem="{Binding SelectedPackage, Mode=TwoWay}"
Visibility="{Binding InstallButtonVisibility, FallbackValue=Visible}">
<ListView.Style>
<Style TargetType="ListView">
@ -59,8 +72,10 @@
<ListView.Template>
<ControlTemplate>
<Border CornerRadius="5" BorderThickness="1"
BorderBrush="{ui:ThemeResource KeyboardFocusBorderColorBrush}">
<Border
BorderBrush="{ui:ThemeResource KeyboardFocusBorderColorBrush}"
BorderThickness="1"
CornerRadius="5">
<ItemsPresenter />
</Border>
</ControlTemplate>
@ -68,39 +83,47 @@
<ListView.ItemTemplate>
<DataTemplate DataType="{x:Type models:InstalledPackage}">
<StackPanel VerticalAlignment="Top" Margin="8">
<TextBlock Text="{Binding Name}" Margin="0,5,0,5" />
<TextBlock Text="{Binding PackageVersion}" Margin="0,0,0,5" />
<StackPanel Margin="8" VerticalAlignment="Top">
<TextBlock Margin="0,5,0,5" Text="{Binding DisplayName}" />
<TextBlock Margin="0,0,0,5" Text="{Binding PackageVersion}" />
</StackPanel>
</DataTemplate>
</ListView.ItemTemplate>
</ListView>
</StackPanel>
<StackPanel Orientation="Vertical" Margin="32,0,0,0">
<TextBlock Text="{Binding SelectedPackage.Name, FallbackValue=Stable Diffusion Web UI}"
FontSize="24" FontWeight="Bold" />
<TextBlock FontSize="12" Margin="0,5, 0, 5">
<StackPanel Margin="32,0,0,0" Orientation="Vertical">
<TextBlock
FontSize="24"
FontWeight="Bold"
Text="{Binding SelectedPackage.Name, FallbackValue=Stable Diffusion Web UI}" />
<TextBlock FontSize="12" Margin="0,5,0,5">
<Run Text="{Binding SelectedPackage.PackageName, FallbackValue=stable-diffusion-webui}" />
<Run Text="{Binding SelectedPackage.PackageVersion, FallbackValue=v1.3.37}" />
</TextBlock>
<TextBlock Text="{Binding SelectedPackage.Path, FallbackValue=C:\Users\Example\Downloads}"
FontSize="12" Margin="0,5, 0, 5" />
<StackPanel Orientation="Horizontal" Margin="0,16,0,0">
<ui:Button Content="{Binding InstallButtonText, FallbackValue=Install}"
Command="{Binding InstallCommand}"
Visibility="{Binding InstallButtonVisibility, FallbackValue=Visible}"
IsEnabled="{Binding InstallButtonEnabled, FallbackValue=true}"
Width="100" Height="50"
Background="Green"
VerticalAlignment="Top" />
<ui:Button Content="Uninstall"
Command="{Binding UninstallCommand}"
Visibility="{Binding InstallButtonVisibility, FallbackValue=Visible}"
Width="100" Height="50"
Background="DarkRed"
Margin="16,0,0,0"
VerticalAlignment="Top" />
<TextBlock
FontSize="12"
Margin="0,5,0,5"
Text="{Binding SelectedPackage.Path, FallbackValue=C:\Users\Example\Downloads}" />
<StackPanel Margin="0,16,0,0" Orientation="Horizontal">
<ui:Button
Background="Green"
Command="{Binding InstallCommand}"
Content="{Binding InstallButtonText, FallbackValue=Install}"
Height="50"
IsEnabled="{Binding InstallButtonEnabled, FallbackValue=true}"
VerticalAlignment="Top"
Visibility="{Binding InstallButtonVisibility, FallbackValue=Visible}"
Width="100" />
<ui:Button
Background="DarkRed"
Command="{Binding UninstallCommand}"
Content="Uninstall"
Height="50"
Margin="16,0,0,0"
VerticalAlignment="Top"
Visibility="{Binding InstallButtonVisibility, FallbackValue=Visible}"
Width="100" />
</StackPanel>
</StackPanel>
</StackPanel>

2
StabilityMatrix/ViewModels/InstallerViewModel.cs

@ -243,7 +243,7 @@ public partial class InstallerViewModel : ObservableObject
var package = new InstalledPackage
{
Name = SelectedPackage.DisplayName,
DisplayName = SelectedPackage.DisplayName,
Path = SelectedPackage.InstallLocation,
Id = Guid.NewGuid(),
PackageName = SelectedPackage.Name,

2
StabilityMatrix/ViewModels/LaunchViewModel.cs

@ -127,7 +127,7 @@ public partial class LaunchViewModel : ObservableObject
public async Task ConfigAsync()
{
var activeInstall = SelectedPackage;
var name = activeInstall?.Name;
var name = activeInstall?.PackageName;
if (name == null || activeInstall == null)
{
logger.LogWarning($"Selected package is null");

10
StabilityMatrix/ViewModels/PackageManagerViewModel.cs

@ -74,7 +74,7 @@ public partial class PackageManagerViewModel : ObservableObject
{
SelectedPackage = new InstalledPackage
{
Name = "Click \"Add Package\" to install a package"
DisplayName = "Click \"Add Package\" to install a package"
};
InstallButtonVisibility = Visibility.Collapsed;
}
@ -100,7 +100,7 @@ public partial class PackageManagerViewModel : ObservableObject
DateTimeOffset.Now;
if (canCheckUpdate)
{
var hasUpdate = await basePackage.CheckForUpdates(packageToUpdate.Name);
var hasUpdate = await basePackage.CheckForUpdates(packageToUpdate.DisplayName);
packageToUpdate.UpdateAvailable = hasUpdate;
packageToUpdate.LastUpdateCheck = DateTimeOffset.Now;
settingsManager.SetLastUpdateCheck(packageToUpdate);
@ -195,7 +195,7 @@ public partial class PackageManagerViewModel : ObservableObject
return;
}
ProgressText = $"Updating {SelectedPackage.Name} to latest version...";
ProgressText = $"Updating {SelectedPackage.DisplayName} to latest version...";
package.InstallLocation = SelectedPackage.Path!;
package.UpdateProgressChanged += SelectedPackageOnProgressChanged;
package.UpdateComplete += (_, _) =>
@ -206,7 +206,7 @@ public partial class PackageManagerViewModel : ObservableObject
UpdateAvailable = false;
};
var updateResult = await package.Update();
settingsManager.UpdatePackageVersionNumber(SelectedPackage.Name!, updateResult!);
settingsManager.UpdatePackageVersionNumber(SelectedPackage.DisplayName!, updateResult!);
await OnLoaded();
}
@ -228,7 +228,7 @@ public partial class PackageManagerViewModel : ObservableObject
{
IsIndeterminate = false;
ProgressValue = progress;
ProgressText = $"Updating {SelectedPackage.Name} to latest version... {progress}%";
ProgressText = $"Updating {SelectedPackage.DisplayName} to latest version... {progress}%";
}
EventManager.Instance.OnGlobalProgressChanged(progress);

2
StabilityMatrix/ViewModels/SettingsViewModel.cs

@ -97,7 +97,7 @@ public partial class SettingsViewModel : ObservableObject
var package = new InstalledPackage
{
Id = Guid.NewGuid(),
Name = Path.GetFileName(path),
DisplayName = Path.GetFileName(path),
Path = path,
PackageName = "dank-diffusion",
PackageVersion = "v1.0.0",

Loading…
Cancel
Save