diff --git a/Filtration/ViewModels/ItemFilterScriptViewModel.cs b/Filtration/ViewModels/ItemFilterScriptViewModel.cs index 1d9e847..71481f4 100644 --- a/Filtration/ViewModels/ItemFilterScriptViewModel.cs +++ b/Filtration/ViewModels/ItemFilterScriptViewModel.cs @@ -77,6 +77,8 @@ namespace Filtration.ViewModels RelayCommand 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()) + { + 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()) + { + 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(); diff --git a/Filtration/ViewModels/MainWindowViewModel.cs b/Filtration/ViewModels/MainWindowViewModel.cs index 1aed815..2e44f5e 100644 --- a/Filtration/ViewModels/MainWindowViewModel.cs +++ b/Filtration/ViewModels/MainWindowViewModel.cs @@ -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; } @@ -402,7 +408,7 @@ namespace Filtration.ViewModels OpenTheme(themeViewModel); } } - + private void OpenTheme(IThemeEditorViewModel themeEditorViewModel) { if (AvalonDockWorkspaceViewModel.OpenDocuments.Contains(themeEditorViewModel)) @@ -724,11 +730,37 @@ 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 CloseAllDocumentsAsync() { Settings.Default.LastOpenScripts = string.Join("|", _avalonDockWorkspaceViewModel.OpenDocuments.OfType().Select(sc => sc.Script.FilePath)); var openDocuments = _avalonDockWorkspaceViewModel.OpenDocuments.OfType().ToList(); - + foreach (var document in openDocuments) { if (!_avalonDockWorkspaceViewModel.OpenDocuments.Contains(document)) diff --git a/Filtration/Views/IconsDictionary.xaml b/Filtration/Views/IconsDictionary.xaml index e3e426c..99b4398 100644 --- a/Filtration/Views/IconsDictionary.xaml +++ b/Filtration/Views/IconsDictionary.xaml @@ -35,4 +35,6 @@ + + \ No newline at end of file diff --git a/Filtration/Views/MainWindow.xaml b/Filtration/Views/MainWindow.xaml index 2b36d70..4203b58 100644 --- a/Filtration/Views/MainWindow.xaml +++ b/Filtration/Views/MainWindow.xaml @@ -2,7 +2,7 @@ x:ClassModifier="internal" xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation" xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml" - xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006" + xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006" xmlns:d="http://schemas.microsoft.com/expression/blend/2008" xmlns:fluent="clr-namespace:Fluent;assembly=Fluent" xmlns:viewModels="clr-namespace:Filtration.ViewModels" @@ -64,12 +64,12 @@ Background="ForestGreen" BorderBrush="ForestGreen" x:Name="ScriptToolsGroup" - IsVisibleChanged="ScriptToolsGroup_OnIsVisibleChanged" + IsVisibleChanged="ScriptToolsGroup_OnIsVisibleChanged" Visibility="{Binding ActiveDocumentIsScript, Converter={StaticResource BooleanVisibilityConverter}, Mode=OneWay}" /> @@ -125,6 +125,10 @@ + + + + @@ -172,5 +176,4 @@ - - \ No newline at end of file +