Add enable/disable DropSound buttons.

This commit is contained in:
GlenCFL 2018-12-05 05:07:52 -05:00
parent a20c988380
commit 19957659d1
4 changed files with 105 additions and 7 deletions

View File

@ -77,6 +77,8 @@ namespace Filtration.ViewModels
RelayCommand<bool> ToggleShowAdvancedCommand { get; }
RelayCommand ClearFilterCommand { get; }
RelayCommand ClearStylesCommand { get; }
RelayCommand EnableDropSoundsCommand { get; }
RelayCommand DisableDropSoundsCommand { get; }
void AddCommentBlock(IItemFilterBlockViewModelBase targetBlockViewModelBase);
void AddBlock(IItemFilterBlockViewModelBase targetBlockViewModelBase);
@ -180,6 +182,8 @@ namespace Filtration.ViewModels
CollapseAllBlocksCommand = new RelayCommand(OnCollapseAllBlocksCommand);
ExpandAllSectionsCommand = new RelayCommand(ExpandAllSections);
CollapseAllSectionsCommand = new RelayCommand(CollapseAllSections);
EnableDropSoundsCommand = new RelayCommand(OnEnableDropSoundsCommand, CanModifySelectedBlocks);
DisableDropSoundsCommand = new RelayCommand(OnDisableDropSoundsCommand, CanModifySelectedBlocks);
var icon = new BitmapImage();
icon.BeginInit();
@ -421,6 +425,8 @@ namespace Filtration.ViewModels
public RelayCommand CollapseAllBlocksCommand { get; }
public RelayCommand ExpandAllSectionsCommand { get; }
public RelayCommand CollapseAllSectionsCommand { get; }
public RelayCommand EnableDropSoundsCommand { get; }
public RelayCommand DisableDropSoundsCommand { get; }
public bool IsActiveDocument
{
@ -1284,6 +1290,61 @@ namespace Filtration.ViewModels
SetDirtyFlag();
}
public void OnEnableDropSoundsCommand()
{
ValidateSelectedBlocks();
var modified = false;
foreach (var block in SelectedBlockViewModels.OfType<IItemFilterBlockViewModel>())
{
var blockItems= block.Block.BlockItems;
for (var i = 0; i < blockItems.Count; i++)
{
if (blockItems[i] is DisableDropSoundBlockItem)
{
blockItems.RemoveAt(i--);
modified = true;
}
}
}
if (modified)
{
SetDirtyFlag();
}
}
public void OnDisableDropSoundsCommand()
{
ValidateSelectedBlocks();
var modified = false;
foreach (var block in SelectedBlockViewModels.OfType<IItemFilterBlockViewModel>())
{
var blockItems = block.Block.BlockItems;
var found = false;
foreach (var item in blockItems)
{
if (item is DisableDropSoundBlockItem)
{
found = true;
}
}
if (!found) {
var item = new DisableDropSoundBlockItem(true);
blockItems.Add(item);
modified = true;
}
}
if (modified) {
SetDirtyFlag();
}
}
private void OnBlockBecameDirty(object sender, EventArgs e)
{
SetDirtyFlag();

View File

@ -129,6 +129,9 @@ namespace Filtration.ViewModels
ApplyThemeToScriptCommand = new RelayCommand(async () => await OnApplyThemeToScriptCommandAsync(), () => ActiveDocumentIsScript);
EditMasterThemeCommand = new RelayCommand(OnEditMasterThemeCommand, () => ActiveDocumentIsScript);
EnableDropSoundsCommand = new RelayCommand(OnEnableDropSoundsCommand, () => ActiveDocumentIsScript && ActiveScriptHasSelectedBlock && ActiveScriptCanModifySelectedBlocks);
DisableDropSoundsCommand = new RelayCommand(OnDisableDropSoundsCommand, () => ActiveDocumentIsScript && ActiveScriptHasSelectedBlock && ActiveScriptCanModifySelectedBlocks);
AddTextColorThemeComponentCommand = new RelayCommand(OnAddTextColorThemeComponentCommand, () => ActiveDocumentIsTheme && ActiveThemeIsEditable);
AddBackgroundColorThemeComponentCommand = new RelayCommand(OnAddBackgroundColorThemeComponentCommand, () => ActiveDocumentIsTheme && ActiveThemeIsEditable);
AddBorderColorThemeComponentCommand = new RelayCommand(OnAddBorderColorThemeComponentCommand, () => ActiveDocumentIsTheme && ActiveThemeIsEditable);
@ -230,6 +233,9 @@ namespace Filtration.ViewModels
public RelayCommand CreateThemeCommand { get; }
public RelayCommand ApplyThemeToScriptCommand { get; }
public RelayCommand EnableDropSoundsCommand { get; }
public RelayCommand DisableDropSoundsCommand { get; }
public RelayCommand AddTextColorThemeComponentCommand { get; }
public RelayCommand AddBackgroundColorThemeComponentCommand { get; }
public RelayCommand AddBorderColorThemeComponentCommand { get; }
@ -724,6 +730,32 @@ namespace Filtration.ViewModels
_avalonDockWorkspaceViewModel.ActiveThemeViewModel.SelectedThemeComponent);
}
private void OnEnableDropSoundsCommand()
{
var result = _messageBoxService.Show("Confirm",
"Are you sure you wish to enable drop sounds on all selected blocks?",
MessageBoxButton.YesNo, MessageBoxImage.Question);
if (result == MessageBoxResult.No)
{
return;
}
_avalonDockWorkspaceViewModel.ActiveScriptViewModel.EnableDropSoundsCommand.Execute(null);
}
private void OnDisableDropSoundsCommand()
{
var result = _messageBoxService.Show("Confirm",
"Are you sure you wish to disable drop sounds on all selected blocks?",
MessageBoxButton.YesNo, MessageBoxImage.Question);
if (result == MessageBoxResult.No)
{
return;
}
_avalonDockWorkspaceViewModel.ActiveScriptViewModel.DisableDropSoundsCommand.Execute(null);
}
public async Task<bool> CloseAllDocumentsAsync()
{
Settings.Default.LastOpenScripts = string.Join("|", _avalonDockWorkspaceViewModel.OpenDocuments.OfType<IItemFilterScriptViewModel>().Select(sc => sc.Script.FilePath));

View File

@ -35,4 +35,6 @@
<Image Source="/Filtration;component/Resources/Icons/ThemeComponentDelete.ico" x:Key="ThemeComponentDeleteIcon" x:Shared="False" />
<Image Source="/Filtration;component/Resources/Icons/standby_enabled_icon.png" x:Key="StandbyEnabledIcon" x:Shared="False" />
<Image Source="/Filtration;component/Resources/Icons/standby_disabled_icon.png" x:Key="StandbyDisabledIcon" x:Shared="False" />
<Image Source="/Filtration;component/Resources/Icons/standby_enabled_icon.png" x:Key="EnableDropSoundsIcon" x:Shared="False" />
<Image Source="/Filtration;component/Resources/Icons/standby_disabled_icon.png" x:Key="DisableDropSoundsIcon" x:Shared="False" />
</ResourceDictionary>

View File

@ -125,6 +125,10 @@
<fluent:Button Header="Create Theme" Command="{Binding CreateThemeCommand}" Icon="{StaticResource ThemeIcon}" LargeIcon="{StaticResource ThemeIcon}" />
<fluent:Button Header="Replace Colours" Command="{Binding ReplaceColorsCommand}" Icon="{StaticResource ReplaceColorsIcon}" LargeIcon="{StaticResource ReplaceColorsIcon}" />
</fluent:RibbonGroupBox>
<fluent:RibbonGroupBox Header="Helpers">
<fluent:Button Header="Enable Drop Sounds" Command="{Binding EnableDropSoundsCommand}" SizeDefinition="Middle" Icon="{StaticResource EnableDropSoundsIcon}" LargeIcon="{StaticResource EnableDropSoundsIcon}" />
<fluent:Button Header="Disable Drop Sounds" Command="{Binding DisableDropSoundsCommand}" SizeDefinition="Middle" Icon="{StaticResource DisableDropSoundsIcon}" LargeIcon="{StaticResource DisableDropSoundsIcon}" />
</fluent:RibbonGroupBox>
</fluent:RibbonTabItem>
<fluent:RibbonTabItem x:Name="ThemeToolsTabItem" Header="Theme Tools" Group="{Binding ElementName=ThemeToolsGroup}" Visibility="{Binding ActiveDocumentIsTheme, Converter={StaticResource BooleanVisibilityConverter}, Mode=OneWay}">
<fluent:RibbonGroupBox Header="Add Components">
@ -173,4 +177,3 @@
</DockPanel>
</fluent:RibbonWindow>