diff --git a/Filtration.ObjectModel/BlockItemBaseTypes/StringBlockItem.cs b/Filtration.ObjectModel/BlockItemBaseTypes/StringBlockItem.cs index 162916d..fd70174 100644 --- a/Filtration.ObjectModel/BlockItemBaseTypes/StringBlockItem.cs +++ b/Filtration.ObjectModel/BlockItemBaseTypes/StringBlockItem.cs @@ -1,10 +1,13 @@ -using System.Windows.Media; +using System; +using System.Windows.Media; +using Filtration.ObjectModel.ThemeEditor; namespace Filtration.ObjectModel.BlockItemBaseTypes { - public abstract class StringBlockItem : BlockItemBase, IAudioVisualBlockItem + public abstract class StringBlockItem : BlockItemBase, IAudioVisualBlockItem, IBlockItemWithTheme { private string _value; + private ThemeComponent _themeComponent; protected StringBlockItem() { @@ -15,12 +18,36 @@ namespace Filtration.ObjectModel.BlockItemBaseTypes Value = value; } - public override string OutputText => PrefixText + " \"" + Value + "\""; + public override string OutputText => PrefixText + " \"" + Value + "\"" + + (ThemeComponent != null ? " # " + ThemeComponent.ComponentName : string.Empty); public override string SummaryText => string.Empty; public override Color SummaryBackgroundColor => Colors.Transparent; public override Color SummaryTextColor => Colors.Transparent; + public ThemeComponent ThemeComponent + { + get { return _themeComponent; } + set + { + if (_themeComponent == value) { return; } + + if (_themeComponent != null) + { + _themeComponent.ThemeComponentUpdated -= OnThemeComponentUpdated; + _themeComponent.ThemeComponentDeleted -= OnThemeComponentDeleted; + } + if (value != null) + { + value.ThemeComponentUpdated += OnThemeComponentUpdated; + value.ThemeComponentDeleted += OnThemeComponentDeleted; + } + + _themeComponent = value; + OnPropertyChanged(); + } + } + public string Value { get { return _value; } @@ -31,5 +58,15 @@ namespace Filtration.ObjectModel.BlockItemBaseTypes OnPropertyChanged(); } } + + private void OnThemeComponentUpdated(object sender, EventArgs e) + { + Value = ((StringThemeComponent)sender).Value; + } + + private void OnThemeComponentDeleted(object sender, EventArgs e) + { + ThemeComponent = null; + } } } \ No newline at end of file diff --git a/Filtration.ObjectModel/BlockItemTypes/CustomSoundBlockItem.cs b/Filtration.ObjectModel/BlockItemTypes/CustomSoundBlockItem.cs index 9aafd01..93768a8 100644 --- a/Filtration.ObjectModel/BlockItemTypes/CustomSoundBlockItem.cs +++ b/Filtration.ObjectModel/BlockItemTypes/CustomSoundBlockItem.cs @@ -6,7 +6,7 @@ namespace Filtration.ObjectModel.BlockItemTypes { public CustomSoundBlockItem() { - Value = ""; + Value = "placeholder.mp3"; } public CustomSoundBlockItem(string value) : base(value) diff --git a/Filtration.ObjectModel/Enums/ThemeComponentType.cs b/Filtration.ObjectModel/Enums/ThemeComponentType.cs index ac3b70b..a48299c 100644 --- a/Filtration.ObjectModel/Enums/ThemeComponentType.cs +++ b/Filtration.ObjectModel/Enums/ThemeComponentType.cs @@ -13,6 +13,8 @@ namespace Filtration.ObjectModel.Enums [Description("Font Size")] FontSize, [Description("Alert Sound")] - AlertSound + AlertSound, + [Description("Custom Sound")] + CustomSound } } diff --git a/Filtration.ObjectModel/Filtration.ObjectModel.csproj b/Filtration.ObjectModel/Filtration.ObjectModel.csproj index 04edeca..8022791 100644 --- a/Filtration.ObjectModel/Filtration.ObjectModel.csproj +++ b/Filtration.ObjectModel/Filtration.ObjectModel.csproj @@ -37,10 +37,26 @@ ..\packages\Castle.Windsor.3.4.0\lib\net45\Castle.Windsor.dll + + ..\packages\CommonServiceLocator.2.0.2\lib\net45\CommonServiceLocator.dll + + + ..\packages\MvvmLightLibs.5.3.0.0\lib\net45\GalaSoft.MvvmLight.dll + + + ..\packages\MvvmLightLibs.5.3.0.0\lib\net45\GalaSoft.MvvmLight.Extras.dll + + + ..\packages\MvvmLightLibs.5.3.0.0\lib\net45\GalaSoft.MvvmLight.Platform.dll + + + + ..\packages\MvvmLightLibs.5.3.0.0\lib\net45\System.Windows.Interactivity.dll + @@ -132,6 +148,7 @@ + @@ -141,6 +158,9 @@ + + + + + + + + + + + + diff --git a/Filtration/App.xaml.cs b/Filtration/App.xaml.cs index e5cb90a..a123909 100644 --- a/Filtration/App.xaml.cs +++ b/Filtration/App.xaml.cs @@ -49,6 +49,7 @@ namespace Filtration cfg.CreateMap().ReverseMap(); cfg.CreateMap().ReverseMap(); cfg.CreateMap().ReverseMap(); + cfg.CreateMap().ReverseMap(); cfg.CreateMap(); }); diff --git a/Filtration/Converters/AvailableThemeComponentsConverter.cs b/Filtration/Converters/AvailableThemeComponentsConverter.cs index 537ba56..77a6803 100644 --- a/Filtration/Converters/AvailableThemeComponentsConverter.cs +++ b/Filtration/Converters/AvailableThemeComponentsConverter.cs @@ -41,6 +41,10 @@ namespace Filtration.Converters { themeComponentType = ThemeComponentType.AlertSound; } + else if (blockItem.GetType() == typeof(CustomSoundBlockItem)) + { + themeComponentType = ThemeComponentType.CustomSound; + } else { return null; diff --git a/Filtration/UserControls/BlockItemControl.xaml b/Filtration/UserControls/BlockItemControl.xaml index 7a401b8..b8d42a4 100644 --- a/Filtration/UserControls/BlockItemControl.xaml +++ b/Filtration/UserControls/BlockItemControl.xaml @@ -185,15 +185,27 @@ - - - + + + + + + + + diff --git a/Filtration/UserControls/BlockItemControl.xaml.cs b/Filtration/UserControls/BlockItemControl.xaml.cs index bb90bd1..7679d1f 100644 --- a/Filtration/UserControls/BlockItemControl.xaml.cs +++ b/Filtration/UserControls/BlockItemControl.xaml.cs @@ -117,6 +117,10 @@ namespace Filtration.UserControls strIntBlockItem.Value = ((StrIntThemeComponent)strIntBlockItem.ThemeComponent).Value; strIntBlockItem.SecondValue = ((StrIntThemeComponent)strIntBlockItem.ThemeComponent).SecondValue; break; + case ThemeComponentType.CustomSound: + var stringBlockItem = BlockItem as StringBlockItem; + stringBlockItem.Value = ((StringThemeComponent)stringBlockItem.ThemeComponent).Value; + break; } } diff --git a/Filtration/UserControls/ThemeComponentSelectionControl.xaml b/Filtration/UserControls/ThemeComponentSelectionControl.xaml index 862390f..bd68cac 100644 --- a/Filtration/UserControls/ThemeComponentSelectionControl.xaml +++ b/Filtration/UserControls/ThemeComponentSelectionControl.xaml @@ -63,6 +63,10 @@ + + + + diff --git a/Filtration/ViewModels/ItemFilterBlockViewModel.cs b/Filtration/ViewModels/ItemFilterBlockViewModel.cs index fc74038..7284af5 100644 --- a/Filtration/ViewModels/ItemFilterBlockViewModel.cs +++ b/Filtration/ViewModels/ItemFilterBlockViewModel.cs @@ -83,7 +83,7 @@ namespace Filtration.ViewModels var customSoundBlockItem = blockItem as CustomSoundBlockItem; if (customSoundBlockItem != null) { - if (_customSoundsAvailable.IndexOf(customSoundBlockItem.Value) < 0) + if (!string.IsNullOrWhiteSpace(customSoundBlockItem.Value) && _customSoundsAvailable.IndexOf(customSoundBlockItem.Value) < 0) { _customSoundsAvailable.Add(customSoundBlockItem.Value); } @@ -454,6 +454,15 @@ namespace Filtration.ViewModels { IsDirty = true; } + var customSoundBlockItem = sender as CustomSoundBlockItem; + if (customSoundBlockItem != null) + { + if (!string.IsNullOrWhiteSpace(customSoundBlockItem.Value) && _customSoundsAvailable.IndexOf(customSoundBlockItem.Value) < 0) + { + _customSoundsAvailable.Add(customSoundBlockItem.Value); + } + RaisePropertyChanged(nameof(CustomSoundsAvailable)); + } Block.IsEdited = true; //if (sender is IAudioVisualBlockItem) //{ diff --git a/Filtration/ViewModels/MainWindowViewModel.cs b/Filtration/ViewModels/MainWindowViewModel.cs index 6e4fcce..8651c46 100644 --- a/Filtration/ViewModels/MainWindowViewModel.cs +++ b/Filtration/ViewModels/MainWindowViewModel.cs @@ -116,6 +116,7 @@ namespace Filtration.ViewModels AddBorderColorThemeComponentCommand = new RelayCommand(OnAddBorderColorThemeComponentCommand, () => ActiveDocumentIsTheme && ActiveThemeIsEditable); AddFontSizeThemeComponentCommand = new RelayCommand(OnAddFontSizeThemeComponentCommand, () => ActiveDocumentIsTheme && ActiveThemeIsEditable); AddAlertSoundThemeComponentCommand = new RelayCommand(OnAddAlertSoundThemeComponentCommand, () => ActiveDocumentIsTheme && ActiveThemeIsEditable); + AddCustomSoundThemeComponentCommand = new RelayCommand(OnAddCustomSoundThemeComponentCommand, () => ActiveDocumentIsTheme && ActiveThemeIsEditable); DeleteThemeComponentCommand = new RelayCommand(OnDeleteThemeComponentCommand, () => ActiveDocumentIsTheme && ActiveThemeIsEditable && _avalonDockWorkspaceViewModel.ActiveThemeViewModel.SelectedThemeComponent != null); ExpandAllBlocksCommand = new RelayCommand(OnExpandAllBlocksCommand, () => ActiveDocumentIsScript); @@ -217,6 +218,7 @@ namespace Filtration.ViewModels public RelayCommand AddBorderColorThemeComponentCommand { get; } public RelayCommand AddFontSizeThemeComponentCommand { get; } public RelayCommand AddAlertSoundThemeComponentCommand { get; } + public RelayCommand AddCustomSoundThemeComponentCommand { get; } public RelayCommand DeleteThemeComponentCommand { get; } public RelayCommand AddBlockCommand { get; } @@ -691,6 +693,11 @@ namespace Filtration.ViewModels _avalonDockWorkspaceViewModel.ActiveThemeViewModel.AddThemeComponentCommand.Execute(ThemeComponentType.AlertSound); } + private void OnAddCustomSoundThemeComponentCommand() + { + _avalonDockWorkspaceViewModel.ActiveThemeViewModel.AddThemeComponentCommand.Execute(ThemeComponentType.CustomSound); + } + private void OnDeleteThemeComponentCommand() { _avalonDockWorkspaceViewModel.ActiveThemeViewModel.DeleteThemeComponentCommand.Execute( diff --git a/Filtration/Views/MainWindow.xaml b/Filtration/Views/MainWindow.xaml index ed97dc0..0c4c1d9 100644 --- a/Filtration/Views/MainWindow.xaml +++ b/Filtration/Views/MainWindow.xaml @@ -131,6 +131,7 @@ +