trying something WIP
trying to see if I can just get the selected index and bind to it... doesn't seem to be working though ...
This commit is contained in:
parent
a6cab6e898
commit
0aca296115
@ -5,38 +5,44 @@
|
|||||||
mc:Ignorable="d" d:DesignWidth="800" d:DesignHeight="450"
|
mc:Ignorable="d" d:DesignWidth="800" d:DesignHeight="450"
|
||||||
x:Class="SPTInstaller.CustomControls.PreCheckDetails">
|
x:Class="SPTInstaller.CustomControls.PreCheckDetails">
|
||||||
<Panel>
|
<Panel>
|
||||||
|
<StackPanel DataContext="{Binding RelativeSource={RelativeSource AncestorType=UserControl}}">
|
||||||
|
<Label Content="Testing"/>
|
||||||
|
<Label Content="{Binding PreChecks[SelectedIndex].Name}"/>
|
||||||
|
<Label Content="{Binding PreChecks[SelectedIndex].State}"/>
|
||||||
|
<Label Content="{Binding SelectedIndex}"/>
|
||||||
|
</StackPanel>
|
||||||
<!-- show when nothing is selected -->
|
<!-- show when nothing is selected -->
|
||||||
<Label Content="Select a Pre-Check to see more info" FontSize="20"
|
<!-- <Label Content="Select a Pre-Check to see more info" FontSize="20" -->
|
||||||
HorizontalAlignment="Center" VerticalAlignment="Center"
|
<!-- HorizontalAlignment="Center" VerticalAlignment="Center" -->
|
||||||
IsVisible="{Binding PreCheckName, RelativeSource={RelativeSource AncestorType=UserControl}, Converter={x:Static StringConverters.IsNullOrEmpty}}"
|
<!-- IsVisible="{Binding PreCheckName, RelativeSource={RelativeSource AncestorType=UserControl}, Converter={x:Static StringConverters.IsNullOrEmpty}}" -->
|
||||||
/>
|
<!-- /> -->
|
||||||
|
<!-- -->
|
||||||
<!-- selected precheck details -->
|
<!-- ~1~ selected precheck details @1@ -->
|
||||||
<Grid RowDefinitions="10, *, Auto, 10" ColumnDefinitions="10, 10, *, 10"
|
<!-- <Grid RowDefinitions="10, *, Auto, 10" ColumnDefinitions="10, 10, *, 10" -->
|
||||||
IsVisible="{Binding PreCheckName, RelativeSource={RelativeSource AncestorType=UserControl}, Converter={x:Static StringConverters.IsNotNullOrEmpty}}"
|
<!-- IsVisible="{Binding PreCheckName, RelativeSource={RelativeSource AncestorType=UserControl}, Converter={x:Static StringConverters.IsNotNullOrEmpty}}" -->
|
||||||
>
|
<!-- > -->
|
||||||
<Rectangle Grid.Row="1" Grid.Column="1" Width="3" Fill="{Binding BarColor, RelativeSource={RelativeSource AncestorType=UserControl}}" HorizontalAlignment="Left"/>
|
<!-- <Rectangle Grid.Row="1" Grid.Column="1" Width="3" Fill="{Binding BarColor, RelativeSource={RelativeSource AncestorType=UserControl}}" HorizontalAlignment="Left"/> -->
|
||||||
|
<!-- -->
|
||||||
<StackPanel Grid.Row="1" Grid.Column="2" HorizontalAlignment="Left">
|
<!-- <StackPanel Grid.Row="1" Grid.Column="2" HorizontalAlignment="Left"> -->
|
||||||
<Label Content="{Binding PreCheckName, RelativeSource={RelativeSource AncestorType=UserControl}}"
|
<!-- <Label Content="{Binding PreCheckName, RelativeSource={RelativeSource AncestorType=UserControl}}" -->
|
||||||
FontSize="20"
|
<!-- FontSize="20" -->
|
||||||
/>
|
<!-- /> -->
|
||||||
<Rectangle Height="1" Fill="Gray" Margin="0 10"/>
|
<!-- <Rectangle Height="1" Fill="Gray" Margin="0 10"/> -->
|
||||||
<TextBlock Text="{Binding Details, RelativeSource={RelativeSource AncestorType=UserControl}}"
|
<!-- <TextBlock Text="{Binding Details, RelativeSource={RelativeSource AncestorType=UserControl}}" -->
|
||||||
TextWrapping="Wrap"
|
<!-- TextWrapping="Wrap" -->
|
||||||
/>
|
<!-- /> -->
|
||||||
</StackPanel>
|
<!-- </StackPanel> -->
|
||||||
|
<!-- -->
|
||||||
<Button Grid.Row="2" Grid.Column="1" Grid.ColumnSpan="2" Classes="yellow"
|
<!-- <Button Grid.Row="2" Grid.Column="1" Grid.ColumnSpan="2" Classes="yellow" -->
|
||||||
IsVisible="{Binding ShowAction, RelativeSource={RelativeSource AncestorType=UserControl}}"
|
<!-- IsVisible="{Binding ShowAction, RelativeSource={RelativeSource AncestorType=UserControl}}" -->
|
||||||
CornerRadius="15"
|
<!-- CornerRadius="15" -->
|
||||||
Margin="0 10"
|
<!-- Margin="0 10" -->
|
||||||
Command="{Binding ActionCommand, RelativeSource={RelativeSource AncestorType=UserControl}}"
|
<!-- Command="{Binding ActionCommand, RelativeSource={RelativeSource AncestorType=UserControl}}" -->
|
||||||
Content="{Binding ActionButtonText, RelativeSource={RelativeSource AncestorType=UserControl}}"
|
<!-- Content="{Binding ActionButtonText, RelativeSource={RelativeSource AncestorType=UserControl}}" -->
|
||||||
HorizontalContentAlignment="Center" VerticalContentAlignment="Center"
|
<!-- HorizontalContentAlignment="Center" VerticalContentAlignment="Center" -->
|
||||||
HorizontalAlignment="Stretch"
|
<!-- HorizontalAlignment="Stretch" -->
|
||||||
/>
|
<!-- /> -->
|
||||||
|
<!-- -->
|
||||||
</Grid>
|
<!-- </Grid> -->
|
||||||
</Panel>
|
</Panel>
|
||||||
</UserControl>
|
</UserControl>
|
||||||
|
@ -1,6 +1,7 @@
|
|||||||
using System.Windows.Input;
|
using System.Collections.ObjectModel;
|
||||||
using Avalonia;
|
using Avalonia;
|
||||||
using Avalonia.Controls;
|
using Avalonia.Controls;
|
||||||
|
using SPTInstaller.Models;
|
||||||
|
|
||||||
namespace SPTInstaller.CustomControls;
|
namespace SPTInstaller.CustomControls;
|
||||||
|
|
||||||
@ -11,57 +12,21 @@ public partial class PreCheckDetails : UserControl
|
|||||||
InitializeComponent();
|
InitializeComponent();
|
||||||
}
|
}
|
||||||
|
|
||||||
public static readonly StyledProperty<string> PreCheckNameProperty =
|
public static readonly StyledProperty<ObservableCollection<PreCheckBase>> PreChecksProperty =
|
||||||
AvaloniaProperty.Register<PreCheckDetails, string>(nameof(PreCheckName));
|
AvaloniaProperty.Register<PreCheckDetails, ObservableCollection<PreCheckBase>>(nameof(PreChecks));
|
||||||
|
|
||||||
public string PreCheckName
|
public ObservableCollection<PreCheckBase> PreChecks
|
||||||
{
|
{
|
||||||
get => GetValue(PreCheckNameProperty);
|
get => GetValue(PreChecksProperty);
|
||||||
set => SetValue(PreCheckNameProperty, value);
|
set => SetValue(PreChecksProperty, value);
|
||||||
}
|
}
|
||||||
|
|
||||||
public static readonly StyledProperty<string> DetailsProperty =
|
public static readonly StyledProperty<int> SelectedIndexProperty =
|
||||||
AvaloniaProperty.Register<PreCheckDetails, string>(nameof(Details));
|
AvaloniaProperty.Register<PreCheckDetails, int>(nameof(SelectedIndex));
|
||||||
|
|
||||||
public string Details
|
public int SelectedIndex
|
||||||
{
|
{
|
||||||
get => GetValue(DetailsProperty);
|
get => GetValue(SelectedIndexProperty);
|
||||||
set => SetValue(DetailsProperty, value);
|
set => SetValue(SelectedIndexProperty, value);
|
||||||
}
|
|
||||||
|
|
||||||
public static readonly StyledProperty<string> ActionButtonTextProperty =
|
|
||||||
AvaloniaProperty.Register<PreCheckDetails, string>(nameof(ActionButtonText));
|
|
||||||
|
|
||||||
public string ActionButtonText
|
|
||||||
{
|
|
||||||
get => GetValue(ActionButtonTextProperty);
|
|
||||||
set => SetValue(ActionButtonTextProperty, value);
|
|
||||||
}
|
|
||||||
|
|
||||||
public static readonly StyledProperty<ICommand> ActionCommandProperty =
|
|
||||||
AvaloniaProperty.Register<PreCheckDetails, ICommand>(nameof(ActionCommand));
|
|
||||||
|
|
||||||
public ICommand ActionCommand
|
|
||||||
{
|
|
||||||
get => GetValue(ActionCommandProperty);
|
|
||||||
set => SetValue(ActionCommandProperty, value);
|
|
||||||
}
|
|
||||||
|
|
||||||
public static readonly StyledProperty<bool> ShowActionProperty =
|
|
||||||
AvaloniaProperty.Register<PreCheckDetails, bool>(nameof(ShowAction));
|
|
||||||
|
|
||||||
public bool ShowAction
|
|
||||||
{
|
|
||||||
get => GetValue(ShowActionProperty);
|
|
||||||
set => SetValue(ShowActionProperty, value);
|
|
||||||
}
|
|
||||||
|
|
||||||
public static readonly StyledProperty<string> BarColorProperty =
|
|
||||||
AvaloniaProperty.Register<PreCheckDetails, string>(nameof(BarColor));
|
|
||||||
|
|
||||||
public string BarColor
|
|
||||||
{
|
|
||||||
get => GetValue(BarColorProperty);
|
|
||||||
set => SetValue(BarColorProperty, value);
|
|
||||||
}
|
}
|
||||||
}
|
}
|
@ -19,7 +19,13 @@ namespace SPTInstaller.ViewModels;
|
|||||||
|
|
||||||
public class PreChecksViewModel : ViewModelBase
|
public class PreChecksViewModel : ViewModelBase
|
||||||
{
|
{
|
||||||
public PreCheckDetailInfo SelectedPreCheck { get; set; } = new();
|
private int _selectedPreCheckIndex;
|
||||||
|
|
||||||
|
public int SelectedPreCheckIndex
|
||||||
|
{
|
||||||
|
get => _selectedPreCheckIndex;
|
||||||
|
set => this.RaiseAndSetIfChanged(ref _selectedPreCheckIndex, value);
|
||||||
|
}
|
||||||
|
|
||||||
public ObservableCollection<PreCheckBase> PreChecks { get; set; } = new(ServiceHelper.GetAll<PreCheckBase>());
|
public ObservableCollection<PreCheckBase> PreChecks { get; set; } = new(ServiceHelper.GetAll<PreCheckBase>());
|
||||||
|
|
||||||
@ -202,30 +208,8 @@ public class PreChecksViewModel : ViewModelBase
|
|||||||
if (check.Id == precheck.Id)
|
if (check.Id == precheck.Id)
|
||||||
{
|
{
|
||||||
precheck.IsSelected = true;
|
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)
|
SelectedPreCheckIndex = PreChecks.IndexOf(precheck);
|
||||||
{
|
|
||||||
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;
|
continue;
|
||||||
}
|
}
|
||||||
|
@ -20,14 +20,10 @@
|
|||||||
/>
|
/>
|
||||||
|
|
||||||
<!-- selected precheck details grid -->
|
<!-- selected precheck details grid -->
|
||||||
<cc:PreCheckDetails Grid.Row="2" Grid.Column="1"
|
<cc:PreCheckDetails Grid.Row="2" Grid.Column="1"
|
||||||
PreCheckName="{Binding SelectedPreCheck.Name}"
|
PreChecks="{Binding PreChecks}"
|
||||||
Details="{Binding SelectedPreCheck.Details}"
|
SelectedIndex="{Binding SelectedPreCheckIndex}"
|
||||||
ActionButtonText="{Binding SelectedPreCheck.ActionButtonText}"
|
/>
|
||||||
ActionCommand="{Binding SelectedPreCheck.ActionButtonCommand}"
|
|
||||||
ShowAction="{Binding SelectedPreCheck.ShowActionButton}"
|
|
||||||
BarColor="{Binding SelectedPreCheck.BarColor}"
|
|
||||||
/>
|
|
||||||
|
|
||||||
<!-- info card vertical separator -->
|
<!-- info card vertical separator -->
|
||||||
<Rectangle Grid.Row="1" Grid.RowSpan="2" Grid.Column="2" VerticalAlignment="Stretch"
|
<Rectangle Grid.Row="1" Grid.RowSpan="2" Grid.Column="2" VerticalAlignment="Stretch"
|
||||||
|
Loading…
x
Reference in New Issue
Block a user