diff --git a/SPTInstaller/Converters/StateSpinnerStateToColorConverter.cs b/SPTInstaller/Converters/StateSpinnerStateToColorConverter.cs
new file mode 100644
index 0000000..685e963
--- /dev/null
+++ b/SPTInstaller/Converters/StateSpinnerStateToColorConverter.cs
@@ -0,0 +1,39 @@
+using System.Globalization;
+using Avalonia.Data.Converters;
+using Avalonia.Media;
+using SPTInstaller.CustomControls;
+
+namespace SPTInstaller.Converters;
+
+public class StateSpinnerStateToColorConverter : IValueConverter
+{
+ public object? Convert(object? value, Type targetType, object? parameter, CultureInfo culture)
+ {
+ if (value == null)
+ return null;
+
+ if (value is not StatusSpinner.SpinnerState state)
+ return null;
+
+ switch (state)
+ {
+ case StatusSpinner.SpinnerState.Pending:
+ return new SolidColorBrush(Colors.Gray);
+ case StatusSpinner.SpinnerState.Running:
+ return new SolidColorBrush(Colors.DodgerBlue);
+ case StatusSpinner.SpinnerState.OK:
+ return new SolidColorBrush(Colors.ForestGreen);
+ case StatusSpinner.SpinnerState.Warning:
+ return new SolidColorBrush(Colors.Goldenrod);
+ case StatusSpinner.SpinnerState.Error:
+ return new SolidColorBrush(Colors.Crimson);
+ default:
+ throw new ArgumentOutOfRangeException();
+ }
+ }
+
+ public object? ConvertBack(object? value, Type targetType, object? parameter, CultureInfo culture)
+ {
+ return value;
+ }
+}
\ No newline at end of file
diff --git a/SPTInstaller/CustomControls/PreCheckDetails.axaml b/SPTInstaller/CustomControls/PreCheckDetails.axaml
index 676448c..0af7991 100644
--- a/SPTInstaller/CustomControls/PreCheckDetails.axaml
+++ b/SPTInstaller/CustomControls/PreCheckDetails.axaml
@@ -2,41 +2,60 @@
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:model="using:SPTInstaller.Models"
+ xmlns:cvt="using:SPTInstaller.Converters"
mc:Ignorable="d" d:DesignWidth="800" d:DesignHeight="450"
x:Class="SPTInstaller.CustomControls.PreCheckDetails">
+
+
+
+
+
-
+
-
-
-
-
-
-
-
-
-
-
-
-
-
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
diff --git a/SPTInstaller/CustomControls/PreCheckDetails.axaml.cs b/SPTInstaller/CustomControls/PreCheckDetails.axaml.cs
index c248d3e..a5f8b30 100644
--- a/SPTInstaller/CustomControls/PreCheckDetails.axaml.cs
+++ b/SPTInstaller/CustomControls/PreCheckDetails.axaml.cs
@@ -1,6 +1,7 @@
-using System.Windows.Input;
+using System.Collections.ObjectModel;
using Avalonia;
using Avalonia.Controls;
+using SPTInstaller.Models;
namespace SPTInstaller.CustomControls;
@@ -11,57 +12,21 @@ public partial class PreCheckDetails : UserControl
InitializeComponent();
}
- public static readonly StyledProperty PreCheckNameProperty =
- AvaloniaProperty.Register(nameof(PreCheckName));
+ public static readonly StyledProperty> PreChecksProperty =
+ AvaloniaProperty.Register>(nameof(PreChecks));
- public string PreCheckName
+ public ObservableCollection PreChecks
{
- get => GetValue(PreCheckNameProperty);
- set => SetValue(PreCheckNameProperty, value);
+ get => GetValue(PreChecksProperty);
+ set => SetValue(PreChecksProperty, value);
}
- public static readonly StyledProperty DetailsProperty =
- AvaloniaProperty.Register(nameof(Details));
+ public static readonly StyledProperty HasSelectionProperty =
+ AvaloniaProperty.Register(nameof(HasSelection));
- public string Details
+ public bool HasSelection
{
- get => GetValue(DetailsProperty);
- set => SetValue(DetailsProperty, value);
- }
-
- public static readonly StyledProperty ActionButtonTextProperty =
- AvaloniaProperty.Register(nameof(ActionButtonText));
-
- public string ActionButtonText
- {
- get => GetValue(ActionButtonTextProperty);
- set => SetValue(ActionButtonTextProperty, value);
- }
-
- public static readonly StyledProperty ActionCommandProperty =
- AvaloniaProperty.Register(nameof(ActionCommand));
-
- public ICommand ActionCommand
- {
- get => GetValue(ActionCommandProperty);
- set => SetValue(ActionCommandProperty, value);
- }
-
- public static readonly StyledProperty ShowActionProperty =
- AvaloniaProperty.Register(nameof(ShowAction));
-
- public bool ShowAction
- {
- get => GetValue(ShowActionProperty);
- set => SetValue(ShowActionProperty, value);
- }
-
- public static readonly StyledProperty BarColorProperty =
- AvaloniaProperty.Register(nameof(BarColor));
-
- public string BarColor
- {
- get => GetValue(BarColorProperty);
- set => SetValue(BarColorProperty, value);
+ get => GetValue(HasSelectionProperty);
+ set => SetValue(HasSelectionProperty, value);
}
}
\ No newline at end of file
diff --git a/SPTInstaller/ViewModels/PreChecksViewModel.cs b/SPTInstaller/ViewModels/PreChecksViewModel.cs
index 265669f..a60b2e9 100644
--- a/SPTInstaller/ViewModels/PreChecksViewModel.cs
+++ b/SPTInstaller/ViewModels/PreChecksViewModel.cs
@@ -19,7 +19,13 @@ namespace SPTInstaller.ViewModels;
public class PreChecksViewModel : ViewModelBase
{
- public PreCheckDetailInfo SelectedPreCheck { get; set; } = new();
+ private bool _hasPreCheckSelected;
+
+ public bool HasPreCheckSelected
+ {
+ get => _hasPreCheckSelected;
+ set => this.RaiseAndSetIfChanged(ref _hasPreCheckSelected, value);
+ }
public ObservableCollection PreChecks { get; set; } = new(ServiceHelper.GetAll());
@@ -202,30 +208,8 @@ public class PreChecksViewModel : ViewModelBase
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;
- }
+ HasPreCheckSelected = true;
continue;
}
diff --git a/SPTInstaller/Views/PreChecksView.axaml b/SPTInstaller/Views/PreChecksView.axaml
index f7aac04..fda83d3 100644
--- a/SPTInstaller/Views/PreChecksView.axaml
+++ b/SPTInstaller/Views/PreChecksView.axaml
@@ -20,14 +20,10 @@
/>
-
+