diff --git a/.idea/.idea.SPTInstaller/.idea/avalonia.xml b/.idea/.idea.SPTInstaller/.idea/avalonia.xml index 9e7777d..743d6f8 100644 --- a/.idea/.idea.SPTInstaller/.idea/avalonia.xml +++ b/.idea/.idea.SPTInstaller/.idea/avalonia.xml @@ -5,8 +5,12 @@ + + + + diff --git a/SPTInstaller/CustomControls/DetailedPreCheckItem.axaml b/SPTInstaller/CustomControls/DetailedPreCheckItem.axaml deleted file mode 100644 index 87c5d05..0000000 --- a/SPTInstaller/CustomControls/DetailedPreCheckItem.axaml +++ /dev/null @@ -1,41 +0,0 @@ - - - - - - - - - - - - - diff --git a/SPTInstaller/CustomControls/PreCheckItem.axaml.cs b/SPTInstaller/CustomControls/PreCheckItem.axaml.cs index c531ccc..57ae999 100644 --- a/SPTInstaller/CustomControls/PreCheckItem.axaml.cs +++ b/SPTInstaller/CustomControls/PreCheckItem.axaml.cs @@ -1,4 +1,5 @@ -using Avalonia; +using System.Windows.Input; +using Avalonia; using Avalonia.Controls; namespace SPTInstaller.CustomControls; @@ -36,4 +37,23 @@ public partial class PreCheckItem : UserControl public static readonly StyledProperty StateProperty = AvaloniaProperty.Register(nameof(State)); + + + public static readonly StyledProperty IsSelectedProperty = + AvaloniaProperty.Register(nameof(IsSelected)); + + public bool IsSelected + { + get => GetValue(IsSelectedProperty); + set => SetValue(IsSelectedProperty, value); + } + + public static readonly StyledProperty SelectCommandProperty = + AvaloniaProperty.Register(nameof(SelectCommand)); + + public ICommand SelectCommand + { + get => GetValue(SelectCommandProperty); + set => SetValue(SelectCommandProperty, value); + } } \ No newline at end of file diff --git a/SPTInstaller/Installer Tasks/PreChecks/Net8PreCheck.cs b/SPTInstaller/Installer Tasks/PreChecks/Net8PreCheck.cs index f2474b1..74ff95c 100644 --- a/SPTInstaller/Installer Tasks/PreChecks/Net8PreCheck.cs +++ b/SPTInstaller/Installer Tasks/PreChecks/Net8PreCheck.cs @@ -33,7 +33,7 @@ public class Net8PreCheck : PreCheckBase try { - var result = ProcessHelper.RunAndReadProcessOutputs("dotnet", "--list-runtimes"); + var result = ProcessHelper.RunAndReadProcessOutputs(@"C:\Program Files\dotnet\dotnet.exe", "--list-runtimes"); if (!result.Succeeded) { diff --git a/SPTInstaller/Installer Tasks/PreChecks/NetCore6PreCheck.cs b/SPTInstaller/Installer Tasks/PreChecks/NetCore6PreCheck.cs index 856d457..bb2e996 100644 --- a/SPTInstaller/Installer Tasks/PreChecks/NetCore6PreCheck.cs +++ b/SPTInstaller/Installer Tasks/PreChecks/NetCore6PreCheck.cs @@ -33,7 +33,7 @@ public class NetCore6PreCheck : PreCheckBase try { - var result = ProcessHelper.RunAndReadProcessOutputs("dotnet", "--list-runtimes"); + var result = ProcessHelper.RunAndReadProcessOutputs(@"C:\Program Files\dotnet\dotnet.exe", "--list-runtimes"); if (!result.Succeeded) { diff --git a/SPTInstaller/Models/PreCheckBase.cs b/SPTInstaller/Models/PreCheckBase.cs index 6003e2c..871987f 100644 --- a/SPTInstaller/Models/PreCheckBase.cs +++ b/SPTInstaller/Models/PreCheckBase.cs @@ -16,6 +16,13 @@ public abstract class PreCheckBase : ReactiveObject, IPreCheck set => this.RaiseAndSetIfChanged(ref _id, value); } + private bool _isSelected; + public bool IsSelected + { + get => _isSelected; + set => this.RaiseAndSetIfChanged(ref _isSelected, value); + } + private string _name; public string Name { diff --git a/SPTInstaller/Models/PreCheckDetailInfo.cs b/SPTInstaller/Models/PreCheckDetailInfo.cs new file mode 100644 index 0000000..a282637 --- /dev/null +++ b/SPTInstaller/Models/PreCheckDetailInfo.cs @@ -0,0 +1,59 @@ +using System.Windows.Input; +using ReactiveUI; +using SPTInstaller.CustomControls; + +namespace SPTInstaller.Models; + +public class PreCheckDetailInfo : ReactiveObject +{ + public PreCheckDetailInfo() + { + _name = ""; + _details = ""; + _actionButtonText = ""; + _showActionButton = false; + } + + private string _name; + public string Name + { + get => _name; + set => this.RaiseAndSetIfChanged(ref _name, value); + } + + private string _details; + public string Details + { + get => _details; + set => this.RaiseAndSetIfChanged(ref _details, value); + } + + private string _actionButtonText; + public string ActionButtonText + { + get => _actionButtonText; + set => this.RaiseAndSetIfChanged(ref _actionButtonText, value); + } + + private ICommand _actionButtonCommand; + public ICommand ActionButtonCommand + { + get => _actionButtonCommand; + set => this.RaiseAndSetIfChanged(ref _actionButtonCommand, value); + } + + private bool _showActionButton; + public bool ShowActionButton + { + get => _showActionButton; + set => this.RaiseAndSetIfChanged(ref _showActionButton, value); + } + + private string _barColor; + + public string BarColor + { + get => _barColor; + set => this.RaiseAndSetIfChanged(ref _barColor, value); + } +} \ No newline at end of file diff --git a/SPTInstaller/Program.cs b/SPTInstaller/Program.cs index 5441b16..a5b2332 100644 --- a/SPTInstaller/Program.cs +++ b/SPTInstaller/Program.cs @@ -11,6 +11,7 @@ using SPTInstaller.Models; using System.Linq; using System.Reflection; using Serilog; +using SPTInstaller.CustomControls; namespace SPTInstaller; diff --git a/SPTInstaller/SPTInstaller.csproj b/SPTInstaller/SPTInstaller.csproj index 1672b24..4daf72c 100644 --- a/SPTInstaller/SPTInstaller.csproj +++ b/SPTInstaller/SPTInstaller.csproj @@ -9,8 +9,8 @@ icon.ico Assets\icon.ico Debug;Release;TEST - 2.45 - 2.45 + 2.50 + 2.50 SPT-AKI diff --git a/SPTInstaller/ViewModels/DetailedPreChecksViewModel.cs b/SPTInstaller/ViewModels/DetailedPreChecksViewModel.cs deleted file mode 100644 index dcd20d2..0000000 --- a/SPTInstaller/ViewModels/DetailedPreChecksViewModel.cs +++ /dev/null @@ -1,9 +0,0 @@ -using ReactiveUI; - -namespace SPTInstaller.ViewModels; -public class DetailedPreChecksViewModel : PreChecksViewModel -{ - public DetailedPreChecksViewModel(IScreen host, bool debugging) : base(host, debugging) - { - } -} diff --git a/SPTInstaller/ViewModels/PreChecksViewModel.cs b/SPTInstaller/ViewModels/PreChecksViewModel.cs index e651b58..265669f 100644 --- a/SPTInstaller/ViewModels/PreChecksViewModel.cs +++ b/SPTInstaller/ViewModels/PreChecksViewModel.cs @@ -19,9 +19,12 @@ namespace SPTInstaller.ViewModels; public class PreChecksViewModel : ViewModelBase { + public PreCheckDetailInfo SelectedPreCheck { get; set; } = new(); + public ObservableCollection PreChecks { get; set; } = new(ServiceHelper.GetAll()); + + public ICommand SelectPreCheckCommand { get; set; } public ICommand StartInstallCommand { get; set; } - public ICommand ShowDetailedViewCommand { get; set; } public ICommand UpdateInstallerCommand { get; set; } @@ -61,7 +64,7 @@ public class PreChecksViewModel : ViewModelBase set => this.RaiseAndSetIfChanged(ref _allowInstall, value); } - private bool _allowDetailsButton = false; + private bool _allowDetailsButton = false; public bool AllowDetailsButton { get => _allowDetailsButton; @@ -192,20 +195,51 @@ public class PreChecksViewModel : ViewModelBase } }); + SelectPreCheckCommand = ReactiveCommand.Create(async(PreCheckBase check) => + { + foreach (var precheck in PreChecks) + { + if (check.Id == precheck.Id) + { + precheck.IsSelected = true; + SelectedPreCheck.Name = precheck.Name; + SelectedPreCheck.Details = precheck.PreCheckDetails; + SelectedPreCheck.ActionButtonText = precheck.ActionButtonText; + SelectedPreCheck.ActionButtonCommand = precheck.ActionButtonCommand; + SelectedPreCheck.ShowActionButton = precheck.ActionButtonIsVisible; + + switch (precheck.State) + { + case StatusSpinner.SpinnerState.Pending: + SelectedPreCheck.BarColor = "gray"; + break; + case StatusSpinner.SpinnerState.Running: + SelectedPreCheck.BarColor = "dodgerblue"; + break; + case StatusSpinner.SpinnerState.OK: + SelectedPreCheck.BarColor = "forestgreen"; + break; + case StatusSpinner.SpinnerState.Warning: + SelectedPreCheck.BarColor = "gold"; + break; + case StatusSpinner.SpinnerState.Error: + SelectedPreCheck.BarColor = "red"; + break; + } + + continue; + } + + precheck.IsSelected = false; + } + }); + StartInstallCommand = ReactiveCommand.Create(async () => { UpdateInfo.ShowCard = false; NavigateTo(new InstallViewModel(HostScreen)); }); - ShowDetailedViewCommand = ReactiveCommand.Create(() => - { - UpdateInfo.ShowCard = false; - Log.Logger.Information("Opening Detailed PreCheck View"); - installer.RecheckRequested -= ReCheckRequested; - NavigateTo(new DetailedPreChecksViewModel(HostScreen, Debugging)); - }); - UpdateInstallerCommand = ReactiveCommand.Create(async () => { AllowDetailsButton = false; diff --git a/SPTInstaller/Views/DetailedPreChecksView.axaml b/SPTInstaller/Views/DetailedPreChecksView.axaml deleted file mode 100644 index 4e3de19..0000000 --- a/SPTInstaller/Views/DetailedPreChecksView.axaml +++ /dev/null @@ -1,67 +0,0 @@ - - - - - - diff --git a/SPTInstaller/Views/DetailedPreChecksView.axaml.cs b/SPTInstaller/Views/DetailedPreChecksView.axaml.cs deleted file mode 100644 index 90fbc02..0000000 --- a/SPTInstaller/Views/DetailedPreChecksView.axaml.cs +++ /dev/null @@ -1,11 +0,0 @@ -using Avalonia.ReactiveUI; -using SPTInstaller.ViewModels; - -namespace SPTInstaller.Views; -public partial class DetailedPreChecksView : ReactiveUserControl -{ - public DetailedPreChecksView() - { - InitializeComponent(); - } -} diff --git a/SPTInstaller/Views/PreChecksView.axaml b/SPTInstaller/Views/PreChecksView.axaml index 24a688c..9b73b86 100644 --- a/SPTInstaller/Views/PreChecksView.axaml +++ b/SPTInstaller/Views/PreChecksView.axaml @@ -5,80 +5,161 @@ xmlns:cc="using:SPTInstaller.CustomControls" mc:Ignorable="d" d:DesignWidth="800" d:DesignHeight="450" x:Class="SPTInstaller.Views.PreChecksView"> - - - - - - - - - - - - - - - - - - - - + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +