From 57775a9e228711dfc23548087656ad897ec118e1 Mon Sep 17 00:00:00 2001 From: azakhi Date: Sun, 19 Aug 2018 13:10:29 +0300 Subject: [PATCH] Start sections collapsed & restyle buttons --- .../ViewModels/ItemFilterScriptViewModel.cs | 31 +++++++++++++++++++ Filtration/ViewModels/MainWindowViewModel.cs | 16 ++++++++++ Filtration/Views/MainWindow.xaml | 7 +++-- 3 files changed, 52 insertions(+), 2 deletions(-) diff --git a/Filtration/ViewModels/ItemFilterScriptViewModel.cs b/Filtration/ViewModels/ItemFilterScriptViewModel.cs index dc333a2..06e99e3 100644 --- a/Filtration/ViewModels/ItemFilterScriptViewModel.cs +++ b/Filtration/ViewModels/ItemFilterScriptViewModel.cs @@ -65,6 +65,8 @@ namespace Filtration.ViewModels RelayCommand PasteBlockStyleCommand { get; } RelayCommand ExpandAllBlocksCommand { get; } RelayCommand CollapseAllBlocksCommand { get; } + RelayCommand ExpandAllSectionsCommand { get; } + RelayCommand CollapseAllSectionsCommand { get; } RelayCommand ToggleShowAdvancedCommand { get; } RelayCommand ClearFilterCommand { get; } @@ -148,6 +150,8 @@ namespace Filtration.ViewModels PasteBlockStyleCommand = new RelayCommand(OnPasteBlockStyleCommand, () => SelectedBlockViewModel != null); ExpandAllBlocksCommand = new RelayCommand(OnExpandAllBlocksCommand); CollapseAllBlocksCommand = new RelayCommand(OnCollapseAllBlocksCommand); + ExpandAllSectionsCommand = new RelayCommand(ExpandAllSections); + CollapseAllSectionsCommand = new RelayCommand(CollapseAllSections); var icon = new BitmapImage(); icon.BeginInit(); @@ -178,6 +182,7 @@ namespace Filtration.ViewModels Title = Filename; ContentId = "ScriptContentId"; + CollapseAllSections(); UpdateBlockModelsForView(); } @@ -272,6 +277,8 @@ namespace Filtration.ViewModels public RelayCommand PasteBlockStyleCommand { get; } public RelayCommand ExpandAllBlocksCommand { get; } public RelayCommand CollapseAllBlocksCommand { get; } + public RelayCommand ExpandAllSectionsCommand { get; } + public RelayCommand CollapseAllSectionsCommand { get; } public bool IsActiveDocument { @@ -1264,5 +1271,29 @@ namespace Filtration.ViewModels ViewItemFilterBlockViewModels = blocksForView; } + + private void CollapseAllSections() + { + for (int i = 0; i < ItemFilterBlockViewModels.Count; i++) + { + var block = ItemFilterBlockViewModels[i] as IItemFilterCommentBlockViewModel; + if (block != null && block.IsExpanded) + { + ToggleSection(block); + } + } + } + + private void ExpandAllSections() + { + for (int i = 0; i < ItemFilterBlockViewModels.Count; i++) + { + var block = ItemFilterBlockViewModels[i] as IItemFilterCommentBlockViewModel; + if (block != null && !block.IsExpanded) + { + ToggleSection(block); + } + } + } } } diff --git a/Filtration/ViewModels/MainWindowViewModel.cs b/Filtration/ViewModels/MainWindowViewModel.cs index bd77aea..358e797 100644 --- a/Filtration/ViewModels/MainWindowViewModel.cs +++ b/Filtration/ViewModels/MainWindowViewModel.cs @@ -119,6 +119,9 @@ namespace Filtration.ViewModels ExpandAllBlocksCommand = new RelayCommand(OnExpandAllBlocksCommand, () => ActiveDocumentIsScript); CollapseAllBlocksCommand = new RelayCommand(OnCollapseAllBlocksCommand, () => ActiveDocumentIsScript); + ExpandAllSectionsCommand = new RelayCommand(OnExpandAllSectionsCommand, () => ActiveDocumentIsScript); + CollapseAllSectionsCommand = new RelayCommand(OnCollapseAllSectionsCommand, () => ActiveDocumentIsScript); + ToggleShowAdvancedCommand = new RelayCommand(OnToggleShowAdvancedCommand, s => ActiveDocumentIsScript); ClearFiltersCommand = new RelayCommand(OnClearFiltersCommand, () => ActiveDocumentIsScript); @@ -230,6 +233,9 @@ namespace Filtration.ViewModels public RelayCommand ExpandAllBlocksCommand { get; } public RelayCommand CollapseAllBlocksCommand { get; } + public RelayCommand ExpandAllSectionsCommand { get; } + public RelayCommand CollapseAllSectionsCommand { get; } + public RelayCommand ToggleShowAdvancedCommand { get; } public RelayCommand ClearFiltersCommand { get; } @@ -636,6 +642,16 @@ namespace Filtration.ViewModels _avalonDockWorkspaceViewModel.ActiveScriptViewModel.CollapseAllBlocksCommand.Execute(null); } + private void OnExpandAllSectionsCommand() + { + _avalonDockWorkspaceViewModel.ActiveScriptViewModel.ExpandAllSectionsCommand.Execute(null); + } + + private void OnCollapseAllSectionsCommand() + { + _avalonDockWorkspaceViewModel.ActiveScriptViewModel.CollapseAllSectionsCommand.Execute(null); + } + private void OnToggleShowAdvancedCommand(bool showAdvanced) { _avalonDockWorkspaceViewModel.ActiveScriptViewModel.ToggleShowAdvancedCommand.Execute(showAdvanced); diff --git a/Filtration/Views/MainWindow.xaml b/Filtration/Views/MainWindow.xaml index ec8e882..6120def 100644 --- a/Filtration/Views/MainWindow.xaml +++ b/Filtration/Views/MainWindow.xaml @@ -101,10 +101,13 @@ + + - - + + +