Add clear all button & missing functions

This commit is contained in:
azakhi 2018-09-05 17:55:16 +03:00
parent 2ff9ebf242
commit 99a011c78c
2 changed files with 40 additions and 3 deletions

View File

@ -21,6 +21,9 @@ namespace Filtration.ViewModels.ToolPanes
public BlockGroupBrowserViewModel() : base("Block Group Browser") public BlockGroupBrowserViewModel() : base("Block Group Browser")
{ {
FilterToSelectedBlockGroupCommand = new RelayCommand(OnFilterToSelectedBlockGroupCommand, () => SelectedBlockGroupViewModel != null); FilterToSelectedBlockGroupCommand = new RelayCommand(OnFilterToSelectedBlockGroupCommand, () => SelectedBlockGroupViewModel != null);
ClearAllFiltersCommand = new RelayCommand(OnClearAllFiltersCommand);
ExpandAllCommand = new RelayCommand(OnExpandAllCommand);
CollapseAllCommand = new RelayCommand(OnCollapseAllCommand);
ContentId = ToolContentId; ContentId = ToolContentId;
var icon = new BitmapImage(); var icon = new BitmapImage();
@ -71,7 +74,13 @@ namespace Filtration.ViewModels.ToolPanes
} }
public RelayCommand FilterToSelectedBlockGroupCommand { get; } public RelayCommand FilterToSelectedBlockGroupCommand { get; }
public RelayCommand ClearAllFiltersCommand { get; }
public RelayCommand ExpandAllCommand { get; }
public RelayCommand CollapseAllCommand { get; }
public ObservableCollection<ItemFilterBlockGroupViewModel> BlockGroupViewModels public ObservableCollection<ItemFilterBlockGroupViewModel> BlockGroupViewModels
{ {
get => _blockGroupViewModelViewModels; get => _blockGroupViewModelViewModels;
@ -107,5 +116,26 @@ namespace Filtration.ViewModels.ToolPanes
AvalonDockWorkspaceViewModel.ActiveScriptViewModel.BlockFilterPredicate = AvalonDockWorkspaceViewModel.ActiveScriptViewModel.BlockFilterPredicate =
b => b.Block.HasBlockGroupInParentHierarchy(SelectedBlockGroupViewModel.SourceBlockGroup, b.Block.BlockGroup); b => b.Block.HasBlockGroupInParentHierarchy(SelectedBlockGroupViewModel.SourceBlockGroup, b.Block.BlockGroup);
} }
private void OnClearAllFiltersCommand()
{
AvalonDockWorkspaceViewModel.ActiveScriptViewModel?.ClearFilterCommand.Execute(null);
}
private void OnExpandAllCommand()
{
foreach (var vm in BlockGroupViewModels)
{
vm.IsExpanded = true;
}
}
private void OnCollapseAllCommand()
{
foreach (var vm in BlockGroupViewModels)
{
vm.IsExpanded = false;
}
}
} }
} }

View File

@ -21,13 +21,20 @@
</Grid.RowDefinitions> </Grid.RowDefinitions>
<ToolBar Grid.Row="0"> <ToolBar Grid.Row="0">
<Button Height="20" Command="{Binding FilterToSelectedBlockGroupCommand}" Content="{StaticResource FilterIcon}" ToolTip="Filter to Selected Block Group" /> <Button Height="20" Command="{Binding FilterToSelectedBlockGroupCommand}" Content="{StaticResource FilterIcon}" ToolTip="Filter to Selected Block Group" />
<Button Height="20" Content="{StaticResource ExpandIcon}" ToolTip="Expand All (Not Implemented)" Name="ExpandAllButton" /> <Button Height="20" Command="{Binding ClearAllFiltersCommand}" Content="{StaticResource ClearFilterIcon}" ToolTip="Clear All Filters" />
<Button Height="20" Content="{StaticResource CollapseIcon}" ToolTip="Collapse All (Not Implemented)" Name="CollapseAllButton" /> <Button Height="20" Command="{Binding ExpandAllCommand}" Content="{StaticResource ExpandIcon}" ToolTip="Expand All" Name="ExpandAllButton" />
<Button Height="20" Command="{Binding CollapseAllCommand}" Content="{StaticResource CollapseIcon}" ToolTip="Collapse All" Name="CollapseAllButton" />
</ToolBar> </ToolBar>
<TreeView Grid.Row="1" ItemsSource="{Binding BlockGroupViewModels}" Name="TreeView"> <TreeView Grid.Row="1" ItemsSource="{Binding BlockGroupViewModels}" Name="TreeView">
<i:Interaction.Behaviors> <i:Interaction.Behaviors>
<behaviors:BindableSelectedItemBehavior SelectedItem="{Binding SelectedBlockGroupViewModel, Mode=OneWayToSource}" /> <behaviors:BindableSelectedItemBehavior SelectedItem="{Binding SelectedBlockGroupViewModel, Mode=OneWayToSource}" />
</i:Interaction.Behaviors> </i:Interaction.Behaviors>
<TreeView.ItemContainerStyle>
<Style TargetType="{x:Type TreeViewItem}">
<Setter Property="IsExpanded" Value="{Binding IsExpanded, Mode=TwoWay, UpdateSourceTrigger=PropertyChanged}">
</Setter>
</Style>
</TreeView.ItemContainerStyle>
<TreeView.Resources> <TreeView.Resources>
<HierarchicalDataTemplate DataType="{x:Type viewModels:ItemFilterBlockGroupViewModel}" ItemsSource="{Binding ChildGroups}"> <HierarchicalDataTemplate DataType="{x:Type viewModels:ItemFilterBlockGroupViewModel}" ItemsSource="{Binding ChildGroups}">
<WrapPanel> <WrapPanel>