diff --git a/StabilityMatrix.Avalonia/ViewModels/Dialogs/InstallerViewModel.cs b/StabilityMatrix.Avalonia/ViewModels/Dialogs/InstallerViewModel.cs index 68c9b96b..cda3e11a 100644 --- a/StabilityMatrix.Avalonia/ViewModels/Dialogs/InstallerViewModel.cs +++ b/StabilityMatrix.Avalonia/ViewModels/Dialogs/InstallerViewModel.cs @@ -69,9 +69,11 @@ public partial class InstallerViewModel : ContentDialogViewModelBase private bool isAdvancedMode; [ObservableProperty] + [NotifyPropertyChangedFor(nameof(CanInstall))] private bool showDuplicateWarning; [ObservableProperty] + [NotifyPropertyChangedFor(nameof(CanInstall))] private string? installName; [ObservableProperty] @@ -108,6 +110,8 @@ public partial class InstallerViewModel : ContentDialogViewModelBase AvailableVersionTypes.HasFlag(PackageVersionType.GithubRelease); public bool ShowTorchVersionOptions => SelectedTorchVersion != TorchVersion.None; + public bool CanInstall => !string.IsNullOrWhiteSpace(InstallName) && !ShowDuplicateWarning; + public ProgressViewModel InstallProgress { get; } = new(); public IEnumerable Steps { get; set; } @@ -303,7 +307,7 @@ public partial class InstallerViewModel : ContentDialogViewModelBase version ??= AvailableVersions.FirstOrDefault(x => x.TagName == "main"); // If still not found, just use the first one - version ??= AvailableVersions[0]; + version ??= AvailableVersions.FirstOrDefault(); SelectedVersion = version; } @@ -388,14 +392,14 @@ public partial class InstallerViewModel : ContentDialogViewModelBase return; AvailableCommits = new ObservableCollection(commits); - SelectedCommit = AvailableCommits[0]; + SelectedCommit = AvailableCommits.FirstOrDefault(); UpdateSelectedVersionToLatestMain(); } InstallName = SelectedPackage.DisplayName; LatestVersionText = IsReleaseMode - ? $"Latest version: {SelectedVersion.TagName}" - : $"Branch: {SelectedVersion.TagName}"; + ? $"Latest version: {SelectedVersion?.TagName}" + : $"Branch: {SelectedVersion?.TagName}"; }) .SafeFireAndForget(); } diff --git a/StabilityMatrix.Avalonia/Views/Dialogs/InstallerDialog.axaml b/StabilityMatrix.Avalonia/Views/Dialogs/InstallerDialog.axaml index 261111ac..995eb4f2 100644 --- a/StabilityMatrix.Avalonia/Views/Dialogs/InstallerDialog.axaml +++ b/StabilityMatrix.Avalonia/Views/Dialogs/InstallerDialog.axaml @@ -197,7 +197,7 @@ Content="Install" Command="{Binding InstallCommand}" FontSize="20" - IsEnabled="{Binding !ShowDuplicateWarning}" + IsEnabled="{Binding CanInstall}" HorizontalAlignment="Center" Classes="success" Margin="4,0,8,0" diff --git a/StabilityMatrix.Avalonia/Views/Dialogs/PackageModificationDialog.axaml b/StabilityMatrix.Avalonia/Views/Dialogs/PackageModificationDialog.axaml index aa6c4018..308ae39e 100644 --- a/StabilityMatrix.Avalonia/Views/Dialogs/PackageModificationDialog.axaml +++ b/StabilityMatrix.Avalonia/Views/Dialogs/PackageModificationDialog.axaml @@ -13,8 +13,9 @@ + HorizontalAlignment="Stretch"/> diff --git a/StabilityMatrix.Avalonia/Views/Dialogs/PackageModificationDialog.axaml.cs b/StabilityMatrix.Avalonia/Views/Dialogs/PackageModificationDialog.axaml.cs index 16a59a56..2dd5053f 100644 --- a/StabilityMatrix.Avalonia/Views/Dialogs/PackageModificationDialog.axaml.cs +++ b/StabilityMatrix.Avalonia/Views/Dialogs/PackageModificationDialog.axaml.cs @@ -43,7 +43,7 @@ public partial class PackageModificationDialog : UserControlBase var editor = this.FindControl("Console"); if (editor?.Document == null) return; - var line = Math.Max(editor.Document.LineCount - 5, 1); + var line = Math.Max(editor.Document.LineCount - 1, 1); editor.ScrollToLine(line); }); };