Add clear styles button (#99)

This commit is contained in:
azakhi 2018-11-27 00:26:04 +03:00 committed by Ben Wallis
parent 05a994f562
commit 63236769aa
3 changed files with 29 additions and 1 deletions

View File

@ -76,6 +76,7 @@ namespace Filtration.ViewModels
RelayCommand CollapseAllSectionsCommand { get; }
RelayCommand<bool> ToggleShowAdvancedCommand { get; }
RelayCommand ClearFilterCommand { get; }
RelayCommand ClearStylesCommand { get; }
void AddCommentBlock(IItemFilterBlockViewModelBase targetBlockViewModelBase);
void AddBlock(IItemFilterBlockViewModelBase targetBlockViewModelBase);
@ -155,6 +156,7 @@ namespace Filtration.ViewModels
ToggleShowAdvancedCommand = new RelayCommand<bool>(OnToggleShowAdvancedCommand);
ClearFilterCommand = new RelayCommand(OnClearFilterCommand, () => BlockFilterPredicate != null);
ClearStylesCommand = new RelayCommand(OnClearStylesCommand, () => SelectedBlockViewModels.OfType<IItemFilterBlockViewModel>().Count() > 0);
CloseCommand = new RelayCommand(async () => await OnCloseCommand());
DeleteBlockCommand = new RelayCommand(OnDeleteBlockCommand, () => CanModifySelectedBlocks());
MoveBlockToTopCommand = new RelayCommand(OnMoveBlockToTopCommand, () => SelectedBlockViewModels.Count > 0 && CanModifySelectedBlocks());
@ -388,6 +390,7 @@ namespace Filtration.ViewModels
public RelayCommand<bool> ToggleShowAdvancedCommand { get; }
public RelayCommand ClearFilterCommand { get; }
public RelayCommand ClearStylesCommand { get; }
public RelayCommand CloseCommand { get; }
public RelayCommand DeleteBlockCommand { get; }
public RelayCommand MoveBlockToTopCommand { get; }
@ -853,6 +856,23 @@ namespace Filtration.ViewModels
BlockFilterPredicate = null;
}
private void OnClearStylesCommand()
{
ValidateSelectedBlocks();
foreach (var block in SelectedBlockViewModels.OfType<IItemFilterBlockViewModel>())
{
var blockItems = block.Block.BlockItems;
for (var i = 0; i < blockItems.Count; i++)
{
if (blockItems[i] is IAudioVisualBlockItem)
{
blockItems.RemoveAt(i--);
}
}
block.RefreshBlockPreview();
}
}
private void OnCopyBlockCommand()
{
var blocksToCopy = new List<IItemFilterBlockViewModelBase>();

View File

@ -142,6 +142,7 @@ namespace Filtration.ViewModels
ToggleShowAdvancedCommand = new RelayCommand<bool>(OnToggleShowAdvancedCommand, s => ActiveDocumentIsScript);
ClearFiltersCommand = new RelayCommand(OnClearFiltersCommand, () => ActiveDocumentIsScript);
ClearStylesCommand = new RelayCommand(OnClearStylesCommand, () => ActiveDocumentIsScript);
if (string.IsNullOrEmpty(_itemFilterScriptRepository.GetItemFilterScriptDirectory()))
{
@ -266,6 +267,7 @@ namespace Filtration.ViewModels
public RelayCommand<bool> ToggleShowAdvancedCommand { get; }
public RelayCommand ClearFiltersCommand { get; }
public RelayCommand ClearStylesCommand { get; }
public ImageSource Icon { get; private set; }
@ -746,6 +748,11 @@ namespace Filtration.ViewModels
_avalonDockWorkspaceViewModel.ActiveScriptViewModel.ClearFilterCommand.Execute(null);
}
private void OnClearStylesCommand()
{
_avalonDockWorkspaceViewModel.ActiveScriptViewModel.ClearStylesCommand.Execute(null);
}
private void OnAddTextColorThemeComponentCommand()
{
_avalonDockWorkspaceViewModel.ActiveThemeViewModel.AddThemeComponentCommand.Execute(ThemeComponentType.TextColor);

View File

@ -114,9 +114,10 @@
<fluent:Button Header="Expand All" Command="{Binding ExpandAllBlocksCommand}" SizeDefinition="Middle" Icon="{StaticResource ExpandIcon}" />
<fluent:Button Header="Collapse All" Command="{Binding CollapseAllBlocksCommand}" SizeDefinition="Middle" Icon="{StaticResource CollapseIcon}" />
</fluent:RibbonGroupBox>
<fluent:RibbonGroupBox Header="Filters">
<fluent:RibbonGroupBox Header="Filters &amp; Styles">
<fluent:ToggleButton Command="{Binding ToggleShowAdvancedCommand}" CommandParameter="{Binding Path=IsChecked, RelativeSource={RelativeSource Self}}" Header="Show Advanced Blocks" SizeDefinition="Middle" Icon="{StaticResource ShowAdvancedIcon}" IsChecked="{Binding ShowAdvancedStatus, Mode=OneWay}" />
<fluent:Button Header="Clear All Filters" Command="{Binding ClearFiltersCommand}" SizeDefinition="Middle" Icon="{StaticResource ClearFilterIcon}" />
<fluent:Button Header="Clear Styles" Command="{Binding ClearStylesCommand}" SizeDefinition="Middle" Icon="{StaticResource PasteStyleIcon}" />
</fluent:RibbonGroupBox>
<fluent:RibbonGroupBox Header="Themes">
<fluent:Button Header="Edit Master Theme" Command="{Binding EditMasterThemeCommand}" Icon="{StaticResource ThemeIcon}" LargeIcon="{StaticResource ThemeIcon}" />