Bladeren bron

avalonia: Little more on the FOrmsList

Kenric Nugteren 4 maanden geleden
bovenliggende
commit
a9b89b67f3

+ 4 - 2
PRS.Avalonia/PRS.Avalonia/Components/FormsList/FormsList.axaml

@@ -52,7 +52,9 @@
 							<CheckBox Grid.Row="0" Grid.Column="0"
 									  Height="15"
 									  Classes="small"
-									  IsChecked="{Binding .,Converter={StaticResource ShellSelectedConverter}}"/>
+									  IsChecked="{Binding .,Converter={StaticResource ShellSelectedConverter}}"
+									  Command="{Binding $parent[local:FormsList].FormCheckedCommand}"
+									  CommandParameter="{Binding .}"/>
 							<Label Grid.Row="0" Grid.Column="1" Grid.ColumnSpan="3"
 								   Content="{Binding FormDescription}"
 								   FontSize="{StaticResource PrsFontSizeSmall}"
@@ -86,7 +88,7 @@
 		</TabStrip>
 		<Button Grid.Row="1" Grid.Column="1"
 				Background="Silver"
-				IsVisible="False"
+				IsVisible="{Binding SelectionMenuVisible}"
 				Command="{Binding $parent[local:FormsList].SelectionMenuCommand}"/>
 	</Grid>
 </UserControl>

+ 17 - 0
PRS.Avalonia/PRS.Avalonia/Components/FormsList/FormsList.axaml.cs

@@ -10,6 +10,7 @@ using InABox.Avalonia.Converters;
 using InABox.Core;
 using System;
 using System.Globalization;
+using System.Linq;
 using System.Threading.Tasks;
 using System.Windows.Input;
 
@@ -64,6 +65,9 @@ public partial class FormsList : UserControl
     public static readonly StyledProperty<bool> SeparateHistoryProperty =
         AvaloniaProperty.Register<FormsList, bool>(nameof(SeparateHistory), true);
 
+    public static readonly StyledProperty<bool> SelectionMenuVisibleProperty =
+        AvaloniaProperty.Register<FormsList, bool>(nameof(SelectionMenuVisible), true);
+
     public string SearchText { get; set; }
 
     public bool SeparateHistory
@@ -72,6 +76,12 @@ public partial class FormsList : UserControl
         set => SetValue(SeparateHistoryProperty, value);
     }
 
+    public bool SelectionMenuVisible
+    {
+        get => GetValue(SelectionMenuVisibleProperty);
+        set => SetValue(SelectionMenuVisibleProperty, value);
+    }
+
     public static readonly StyledProperty<ICoreRepository?> ModelProperty =
         AvaloniaProperty.Register<FormsList, ICoreRepository?>(nameof(Model));
 
@@ -97,6 +107,13 @@ public partial class FormsList : UserControl
     {
     }
 
+    [RelayCommand]
+    private void FormChecked(IDigitalFormInstanceShell form)
+    {
+        Model?.ToggleSelection(form);
+        SelectionMenuVisible = Model?.SelectedItems.OfType<IShell>().Any() == true;
+    }
+
     [RelayCommand]
     private void SelectionMenu(IDigitalFormInstanceShell form)
     {