diff --git a/Filtration.ObjectModel.Tests/ThemeEditor/TestThemeComponentCollection.cs b/Filtration.ObjectModel.Tests/ThemeEditor/TestThemeComponentCollection.cs new file mode 100644 index 0000000..f927352 --- /dev/null +++ b/Filtration.ObjectModel.Tests/ThemeEditor/TestThemeComponentCollection.cs @@ -0,0 +1,30 @@ +using System.Windows.Media; +using Filtration.ObjectModel.Enums; +using Filtration.ObjectModel.ThemeEditor; +using NUnit.Framework; + +namespace Filtration.ObjectModel.Tests.ThemeEditor +{ + [TestFixture] + public class TestThemeComponentCollection + { + [Test] + public void AddComponent_ReturnsFirstAddedComponent_WhenComponentAddedTwice() + { + // Arrange + + var testInputTargetType = ThemeComponentType.TextColor; + var testInputComponentName = "testComponent"; + var testInputColor = new Color(); + + var componentCollection = new ThemeComponentCollection(); + + // Act + var firstResult = componentCollection.AddComponent(testInputTargetType, testInputComponentName, testInputColor); + var secondResult = componentCollection.AddComponent(testInputTargetType, testInputComponentName, testInputColor); + + // Assert + Assert.AreSame(firstResult, secondResult); + } + } +} diff --git a/Filtration.ObjectModel/BlockItemBaseTypes/ColorBlockItem.cs b/Filtration.ObjectModel/BlockItemBaseTypes/ColorBlockItem.cs index 7fb925a..f0c39b5 100644 --- a/Filtration.ObjectModel/BlockItemBaseTypes/ColorBlockItem.cs +++ b/Filtration.ObjectModel/BlockItemBaseTypes/ColorBlockItem.cs @@ -1,4 +1,4 @@ -using System.ComponentModel; +using System; using System.Windows.Media; using Filtration.ObjectModel.ThemeEditor; @@ -38,6 +38,19 @@ namespace Filtration.ObjectModel.BlockItemBaseTypes 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(); } @@ -55,5 +68,15 @@ namespace Filtration.ObjectModel.BlockItemBaseTypes OnPropertyChanged(); } } + + private void OnThemeComponentUpdated(object sender, EventArgs e) + { + Color = ((ThemeComponent) sender).Color; + } + + private void OnThemeComponentDeleted(object sender, EventArgs e) + { + ThemeComponent = null; + } } } diff --git a/Filtration.ObjectModel/ThemeEditor/ThemeComponent.cs b/Filtration.ObjectModel/ThemeEditor/ThemeComponent.cs index fad12ef..19835ae 100644 --- a/Filtration.ObjectModel/ThemeEditor/ThemeComponent.cs +++ b/Filtration.ObjectModel/ThemeEditor/ThemeComponent.cs @@ -1,12 +1,17 @@ using System; +using System.ComponentModel; +using System.Runtime.CompilerServices; using System.Windows.Media; +using Filtration.ObjectModel.Annotations; using Filtration.ObjectModel.Enums; namespace Filtration.ObjectModel.ThemeEditor { [Serializable] - public class ThemeComponent + public class ThemeComponent : INotifyPropertyChanged { + private Color _color; + public ThemeComponent() { @@ -24,8 +29,41 @@ namespace Filtration.ObjectModel.ThemeEditor ComponentName = componentName; } + public event EventHandler ThemeComponentUpdated; + public event EventHandler ThemeComponentDeleted; + public string ComponentName { get; set; } - public ThemeComponentType ComponentType{ get; set; } - public Color Color { get; set; } + public ThemeComponentType ComponentType{ get; private set; } + + public Color Color + { + get { return _color; } + set + { + _color = value; + OnPropertyChanged(); + if (ThemeComponentUpdated != null) + { + ThemeComponentUpdated.Invoke(this, EventArgs.Empty); + } + } + } + + public void TerminateComponent() + { + if (ThemeComponentDeleted != null) + { + ThemeComponentDeleted.Invoke(this, EventArgs.Empty); + } + } + + public event PropertyChangedEventHandler PropertyChanged; + + [NotifyPropertyChangedInvocator] + protected virtual void OnPropertyChanged([CallerMemberName] string propertyName = null) + { + var handler = PropertyChanged; + if (handler != null) handler(this, new PropertyChangedEventArgs(propertyName)); + } } } diff --git a/Filtration.ObjectModel/ThemeEditor/ThemeComponentCollection.cs b/Filtration.ObjectModel/ThemeEditor/ThemeComponentCollection.cs index 6cc1cfd..12eaf7e 100644 --- a/Filtration.ObjectModel/ThemeEditor/ThemeComponentCollection.cs +++ b/Filtration.ObjectModel/ThemeEditor/ThemeComponentCollection.cs @@ -5,7 +5,7 @@ using Filtration.ObjectModel.Enums; namespace Filtration.ObjectModel.ThemeEditor { - public class ThemeComponentCollection : Collection + public class ThemeComponentCollection : ObservableCollection { public bool IsMasterCollection { get; set; } diff --git a/Filtration.ThemeEditor/Filtration.ThemeEditor.csproj b/Filtration.ThemeEditor/Filtration.ThemeEditor.csproj index 9bab1d8..53598ec 100644 --- a/Filtration.ThemeEditor/Filtration.ThemeEditor.csproj +++ b/Filtration.ThemeEditor/Filtration.ThemeEditor.csproj @@ -101,12 +101,12 @@ - + ThemeComponentControl.xaml - - ThemeControl.xaml + + ThemeEditorView.xaml @@ -132,7 +132,7 @@ Designer MSBuild:Compile - + Designer MSBuild:Compile diff --git a/Filtration.ThemeEditor/Providers/ThemeProvider.cs b/Filtration.ThemeEditor/Providers/ThemeProvider.cs index 4724284..712baba 100644 --- a/Filtration.ThemeEditor/Providers/ThemeProvider.cs +++ b/Filtration.ThemeEditor/Providers/ThemeProvider.cs @@ -1,4 +1,6 @@ using System.Collections.ObjectModel; +using System.IO; +using System.Linq; using AutoMapper; using Filtration.ObjectModel; using Filtration.ObjectModel.ThemeEditor; @@ -9,10 +11,11 @@ namespace Filtration.ThemeEditor.Providers { public interface IThemeProvider { - IThemeViewModel NewThemeForScript(ItemFilterScript script); - IThemeViewModel LoadThemeFromFile(string filePath); + IThemeEditorViewModel NewThemeForScript(ItemFilterScript script); + IThemeEditorViewModel MasterThemeForScript(ItemFilterScript script); + IThemeEditorViewModel LoadThemeFromFile(string filePath); Theme LoadThemeModelFromFile(string filePath); - void SaveTheme(IThemeViewModel themeViewModel, string filePath); + void SaveTheme(IThemeEditorViewModel themeEditorViewModel, string filePath); } internal class ThemeProvider : IThemeProvider @@ -26,20 +29,35 @@ namespace Filtration.ThemeEditor.Providers _themePersistenceService = themePersistenceService; } - public IThemeViewModel NewThemeForScript(ItemFilterScript script) + public IThemeEditorViewModel NewThemeForScript(ItemFilterScript script) { - var themeComponentViewModels = Mapper.Map>(script.ThemeComponents); + var themeComponentCollection = script.ThemeComponents.Aggregate(new ThemeComponentCollection(), + (c, component) => + { + c.Add(new ThemeComponent(component.ComponentType, component.ComponentName, component.Color)); + return c; + }); + var themeViewModel = _themeViewModelFactory.Create(); - themeViewModel.Initialise(themeComponentViewModels, true); + themeViewModel.Initialise(themeComponentCollection, true); themeViewModel.FilePath = "Untitled.filtertheme"; return themeViewModel; } - public IThemeViewModel LoadThemeFromFile(string filePath) + public IThemeEditorViewModel MasterThemeForScript(ItemFilterScript script) + { + var themeViewModel = _themeViewModelFactory.Create(); + themeViewModel.Initialise(script.ThemeComponents, true); + themeViewModel.FilePath = " " + Path.GetFileName(script.FilePath); + + return themeViewModel; + } + + public IThemeEditorViewModel LoadThemeFromFile(string filePath) { var model = _themePersistenceService.LoadTheme(filePath); - var viewModel = Mapper.Map(model); + var viewModel = Mapper.Map(model); viewModel.FilePath = filePath; return viewModel; } @@ -49,9 +67,9 @@ namespace Filtration.ThemeEditor.Providers return _themePersistenceService.LoadTheme(filePath); } - public void SaveTheme(IThemeViewModel themeViewModel, string filePath) + public void SaveTheme(IThemeEditorViewModel themeEditorViewModel, string filePath) { - var theme = Mapper.Map(themeViewModel); + var theme = Mapper.Map(themeEditorViewModel); _themePersistenceService.SaveTheme(theme, filePath); } } diff --git a/Filtration.ThemeEditor/ViewModels/IThemeViewModelFactory.cs b/Filtration.ThemeEditor/ViewModels/IThemeViewModelFactory.cs index e27d1de..ff39b2d 100644 --- a/Filtration.ThemeEditor/ViewModels/IThemeViewModelFactory.cs +++ b/Filtration.ThemeEditor/ViewModels/IThemeViewModelFactory.cs @@ -2,7 +2,7 @@ { public interface IThemeViewModelFactory { - IThemeViewModel Create(); - void Release(IThemeViewModel themeViewModel); + IThemeEditorViewModel Create(); + void Release(IThemeEditorViewModel themeEditorViewModel); } } diff --git a/Filtration.ThemeEditor/ViewModels/ThemeViewModel.cs b/Filtration.ThemeEditor/ViewModels/ThemeEditorViewModel.cs similarity index 58% rename from Filtration.ThemeEditor/ViewModels/ThemeViewModel.cs rename to Filtration.ThemeEditor/ViewModels/ThemeEditorViewModel.cs index e2ba179..21f9f2c 100644 --- a/Filtration.ThemeEditor/ViewModels/ThemeViewModel.cs +++ b/Filtration.ThemeEditor/ViewModels/ThemeEditorViewModel.cs @@ -1,29 +1,36 @@ using System; -using System.Collections.ObjectModel; using System.IO; using System.Windows; using System.Windows.Forms; +using System.Windows.Media; using System.Windows.Media.Imaging; using Filtration.Common.Services; using Filtration.Common.ViewModels; using Filtration.Interface; +using Filtration.ObjectModel.Enums; +using Filtration.ObjectModel.ThemeEditor; using Filtration.ThemeEditor.Providers; +using GalaSoft.MvvmLight.CommandWpf; using NLog; -using MessageBox = System.Windows.MessageBox; namespace Filtration.ThemeEditor.ViewModels { - public interface IThemeViewModel : IEditableDocument + public interface IThemeEditorViewModel : IEditableDocument { - void Initialise(ObservableCollection themeComponentViewModels, bool newTheme); + RelayCommand AddThemeComponentCommand { get; } + RelayCommand DeleteThemeComponentCommand { get; } + + void Initialise(ThemeComponentCollection themeComponentCollection, bool newTheme); + bool EditEnabled { get; } string Title { get; } string FilePath { get; set; } string Filename { get; } string Name { get; set; } - ObservableCollection Components { get; set; } + ThemeComponentCollection Components { get; set; } + ThemeComponent SelectedThemeComponent { get; } } - public class ThemeViewModel : PaneViewModel, IThemeViewModel + public class ThemeEditorViewModel : PaneViewModel, IThemeEditorViewModel { private static readonly Logger _logger = LogManager.GetCurrentClassLogger(); @@ -31,15 +38,17 @@ namespace Filtration.ThemeEditor.ViewModels private readonly IMessageBoxService _messageBoxService; private bool _filenameIsFake; private string _filePath; + private ThemeComponent _selectedThemeComponent; - public ThemeViewModel(IThemeProvider themeProvider, + public ThemeEditorViewModel(IThemeProvider themeProvider, IMessageBoxService messageBoxService) { _themeProvider = themeProvider; _messageBoxService = messageBoxService; - Components = new ObservableCollection(); - + AddThemeComponentCommand = new RelayCommand(OnAddThemeComponentCommand, t => EditEnabled); + DeleteThemeComponentCommand = new RelayCommand(OnDeleteThemeComponentCommand, + t => EditEnabled && SelectedThemeComponent != null); var icon = new BitmapImage(); icon.BeginInit(); @@ -48,9 +57,17 @@ namespace Filtration.ThemeEditor.ViewModels IconSource = icon; } - public void Initialise(ObservableCollection themeComponentViewModels, bool newTheme) + public RelayCommand AddThemeComponentCommand { get; private set; } + public RelayCommand DeleteThemeComponentCommand { get; private set; } + + public bool EditEnabled { - Components = themeComponentViewModels; + get { return Components.IsMasterCollection; } + } + + public void Initialise(ThemeComponentCollection themeComponentCollection, bool newTheme) + { + Components = themeComponentCollection; _filenameIsFake = newTheme; } @@ -70,12 +87,22 @@ namespace Filtration.ThemeEditor.ViewModels public string Filename { - get { return Path.GetFileName(FilePath); } + get { return _filenameIsFake ? FilePath : Path.GetFileName(FilePath); } } public string Name { get; set; } - public ObservableCollection Components { get; set; } + public ThemeComponentCollection Components { get; set; } + + public ThemeComponent SelectedThemeComponent + { + get { return _selectedThemeComponent; } + set + { + _selectedThemeComponent = value; + RaisePropertyChanged(); + } + } public void Save() { @@ -138,5 +165,19 @@ namespace Filtration.ThemeEditor.ViewModels { throw new NotImplementedException(); } + + private void OnAddThemeComponentCommand(ThemeComponentType themeComponentType) + { + Components.Add(new ThemeComponent(themeComponentType, "Untitled Component", + new Color {A = 255, R = 255, G = 255, B = 255})); + } + + private void OnDeleteThemeComponentCommand(ThemeComponent themeComponent) + { + if (themeComponent == null) return; + + themeComponent.TerminateComponent(); + Components.Remove(themeComponent); + } } } diff --git a/Filtration.ThemeEditor/Views/ThemeComponentControl.xaml b/Filtration.ThemeEditor/Views/ThemeComponentControl.xaml index 16070f3..bc323b3 100644 --- a/Filtration.ThemeEditor/Views/ThemeComponentControl.xaml +++ b/Filtration.ThemeEditor/Views/ThemeComponentControl.xaml @@ -3,11 +3,12 @@ xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml" xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006" xmlns:d="http://schemas.microsoft.com/expression/blend/2008" - xmlns:viewModels="clr-namespace:Filtration.ThemeEditor.ViewModels" xmlns:xctk="http://schemas.xceed.com/wpf/xaml/toolkit" xmlns:converters="clr-namespace:Filtration.ThemeEditor.Converters" + xmlns:themeEditor="clr-namespace:Filtration.ObjectModel.ThemeEditor;assembly=Filtration.ObjectModel" + xmlns:views="clr-namespace:Filtration.ThemeEditor.Views" mc:Ignorable="d" - d:DataContext="{d:DesignInstance Type=viewModels:ThemeComponentViewModel}" + d:DataContext="{d:DesignInstance Type=themeEditor:ThemeComponent}" d:DesignHeight="40" d:DesignWidth="200"> @@ -18,8 +19,30 @@ + + + + + + + + - + + + + + + diff --git a/Filtration.ThemeEditor/Views/ThemeControl.xaml.cs b/Filtration.ThemeEditor/Views/ThemeControl.xaml.cs deleted file mode 100644 index ffc9063..0000000 --- a/Filtration.ThemeEditor/Views/ThemeControl.xaml.cs +++ /dev/null @@ -1,28 +0,0 @@ -using System; -using System.Collections.Generic; -using System.Linq; -using System.Text; -using System.Threading.Tasks; -using System.Windows; -using System.Windows.Controls; -using System.Windows.Data; -using System.Windows.Documents; -using System.Windows.Input; -using System.Windows.Media; -using System.Windows.Media.Imaging; -using System.Windows.Navigation; -using System.Windows.Shapes; - -namespace Filtration.ThemeEditor.Views -{ - /// - /// Interaction logic for ThemeControl.xaml - /// - public partial class ThemeControl : UserControl - { - public ThemeControl() - { - InitializeComponent(); - } - } -} diff --git a/Filtration.ThemeEditor/Views/ThemeControl.xaml b/Filtration.ThemeEditor/Views/ThemeEditorView.xaml similarity index 53% rename from Filtration.ThemeEditor/Views/ThemeControl.xaml rename to Filtration.ThemeEditor/Views/ThemeEditorView.xaml index d565157..f61494b 100644 --- a/Filtration.ThemeEditor/Views/ThemeControl.xaml +++ b/Filtration.ThemeEditor/Views/ThemeEditorView.xaml @@ -1,4 +1,4 @@ - @@ -21,13 +21,35 @@ - - + + + + + - - + + @@ -35,13 +57,13 @@ - - + + - - + + diff --git a/Filtration.ThemeEditor/Views/ThemeEditorView.xaml.cs b/Filtration.ThemeEditor/Views/ThemeEditorView.xaml.cs new file mode 100644 index 0000000..f865620 --- /dev/null +++ b/Filtration.ThemeEditor/Views/ThemeEditorView.xaml.cs @@ -0,0 +1,10 @@ +namespace Filtration.ThemeEditor.Views +{ + public partial class ThemeEditorView + { + public ThemeEditorView() + { + InitializeComponent(); + } + } +} diff --git a/Filtration.ThemeEditor/WindsorInstallers/ViewModelsInstaller.cs b/Filtration.ThemeEditor/WindsorInstallers/ViewModelsInstaller.cs index 6a03806..92981ab 100644 --- a/Filtration.ThemeEditor/WindsorInstallers/ViewModelsInstaller.cs +++ b/Filtration.ThemeEditor/WindsorInstallers/ViewModelsInstaller.cs @@ -11,8 +11,8 @@ namespace Filtration.ThemeEditor.WindsorInstallers public void Install(IWindsorContainer container, IConfigurationStore store) { container.Register( - Component.For() - .ImplementedBy() + Component.For() + .ImplementedBy() .LifeStyle.Transient); container.Register( diff --git a/Filtration/App.xaml b/Filtration/App.xaml index 878922d..d18e923 100644 --- a/Filtration/App.xaml +++ b/Filtration/App.xaml @@ -20,6 +20,7 @@ + diff --git a/Filtration/App.xaml.cs b/Filtration/App.xaml.cs index fff22e5..4bb9604 100644 --- a/Filtration/App.xaml.cs +++ b/Filtration/App.xaml.cs @@ -58,9 +58,9 @@ namespace Filtration .ForMember(dest => dest.IsExpanded, opts => opts.UseValue(false)); - Mapper.CreateMap().ConstructUsingServiceLocator(); + Mapper.CreateMap().ConstructUsingServiceLocator(); Mapper.CreateMap().ReverseMap(); - Mapper.CreateMap(); + Mapper.CreateMap(); Mapper.AssertConfigurationIsValid(); diff --git a/Filtration/ViewModels/AvalonDockWorkspaceViewModel.cs b/Filtration/ViewModels/AvalonDockWorkspaceViewModel.cs index 8867e62..59f200c 100644 --- a/Filtration/ViewModels/AvalonDockWorkspaceViewModel.cs +++ b/Filtration/ViewModels/AvalonDockWorkspaceViewModel.cs @@ -3,6 +3,7 @@ using System.Collections.Generic; using System.Collections.ObjectModel; using Filtration.Common.ViewModels; using Filtration.Interface; +using Filtration.ThemeEditor.ViewModels; using Filtration.ViewModels.ToolPanes; using GalaSoft.MvvmLight.Messaging; @@ -14,6 +15,7 @@ namespace Filtration.ViewModels IDocument ActiveDocument { get; set; } ReadOnlyObservableCollection OpenDocuments { get; } IItemFilterScriptViewModel ActiveScriptViewModel { get; } + IThemeEditorViewModel ActiveThemeViewModel { get; } ISectionBrowserViewModel SectionBrowserViewModel { get; } IBlockGroupBrowserViewModel BlockGroupBrowserViewModel { get; } IBlockOutputPreviewViewModel BlockOutputPreviewViewModel { get; } @@ -30,6 +32,7 @@ namespace Filtration.ViewModels private IDocument _activeDocument; private IItemFilterScriptViewModel _activeScriptViewModel; + private IThemeEditorViewModel _activeThemeViewModel; private readonly ObservableCollection _openDocuments; private readonly ReadOnlyObservableCollection _readOnlyOpenDocuments; @@ -72,9 +75,14 @@ namespace Filtration.ViewModels { _activeScriptViewModel = (IItemFilterScriptViewModel) value; } + else if (value.IsTheme) + { + _activeThemeViewModel = (IThemeEditorViewModel) value; + } else { _activeScriptViewModel = null; + _activeThemeViewModel = null; } if (ActiveDocumentChanged != null) @@ -91,6 +99,11 @@ namespace Filtration.ViewModels get { return _activeScriptViewModel; } } + public IThemeEditorViewModel ActiveThemeViewModel + { + get { return _activeThemeViewModel; } + } + public IBlockGroupBrowserViewModel BlockGroupBrowserViewModel { get { return _blockGroupBrowserViewModel; } @@ -107,6 +120,7 @@ namespace Filtration.ViewModels } private List _tools; + public IEnumerable Tools { @@ -127,6 +141,10 @@ namespace Filtration.ViewModels { _activeScriptViewModel = (IItemFilterScriptViewModel) document; } + else if (document.IsTheme) + { + _activeThemeViewModel = (IThemeEditorViewModel) document; + } _openDocuments.Add(document); ActiveDocument = document; diff --git a/Filtration/ViewModels/MainWindowViewModel.cs b/Filtration/ViewModels/MainWindowViewModel.cs index 63f1667..e7b941c 100644 --- a/Filtration/ViewModels/MainWindowViewModel.cs +++ b/Filtration/ViewModels/MainWindowViewModel.cs @@ -10,6 +10,7 @@ using Filtration.Common.Services; using Filtration.Common.ViewModels; using Filtration.Interface; using Filtration.Models; +using Filtration.ObjectModel.Enums; using Filtration.ObjectModel.ThemeEditor; using Filtration.Properties; using Filtration.Repositories; @@ -95,8 +96,18 @@ namespace Filtration.ViewModels OpenAboutWindowCommand = new RelayCommand(OnOpenAboutWindowCommand); ReplaceColorsCommand = new RelayCommand(OnReplaceColorsCommand, () => ActiveDocumentIsScript); + CreateThemeCommand = new RelayCommand(OnCreateThemeCommand, () => ActiveDocumentIsScript); ApplyThemeToScriptCommand = new RelayCommand(OnApplyThemeToScriptCommand, () => ActiveDocumentIsScript); + EditMasterThemeCommand = new RelayCommand(OnEditMasterThemeCommand, () => ActiveDocumentIsScript); + + AddTextColorThemeComponentCommand = new RelayCommand(OnAddTextColorThemeComponentCommand, () => ActiveDocumentIsTheme && ActiveThemeIsEditable); + AddBackgroundColorThemeComponentCommand = new RelayCommand(OnAddBackgroundColorThemeComponentCommand, () => ActiveDocumentIsTheme && ActiveThemeIsEditable); + AddBorderColorThemeComponentCommand = new RelayCommand(OnAddBorderColorThemeComponentCommand, () => ActiveDocumentIsTheme && ActiveThemeIsEditable); + DeleteThemeComponentCommand = new RelayCommand(OnDeleteThemeComponentCommand, + () => + ActiveDocumentIsTheme && ActiveDocumentIsTheme && + _avalonDockWorkspaceViewModel.ActiveThemeViewModel.SelectedThemeComponent != null); ExpandAllBlocksCommand = new RelayCommand(OnExpandAllBlocksCommand, () => ActiveDocumentIsScript); CollapseAllBlocksCommand = new RelayCommand(OnCollapseAllBlocksCommand, () => ActiveDocumentIsScript); @@ -129,6 +140,7 @@ namespace Filtration.ViewModels PasteCommand.RaiseCanExecuteChanged(); ReplaceColorsCommand.RaiseCanExecuteChanged(); ApplyThemeToScriptCommand.RaiseCanExecuteChanged(); + EditMasterThemeCommand.RaiseCanExecuteChanged(); CreateThemeCommand.RaiseCanExecuteChanged(); RaisePropertyChanged("ShowAdvancedStatus"); break; @@ -161,9 +173,16 @@ namespace Filtration.ViewModels public RelayCommand CloseCommand { get; private set; } public RelayCommand OpenAboutWindowCommand { get; private set; } public RelayCommand ReplaceColorsCommand { get; private set; } + + public RelayCommand EditMasterThemeCommand { get; private set; } public RelayCommand CreateThemeCommand { get; private set; } public RelayCommand ApplyThemeToScriptCommand { get; private set; } - + + public RelayCommand AddTextColorThemeComponentCommand { get; private set; } + public RelayCommand AddBackgroundColorThemeComponentCommand { get; private set; } + public RelayCommand AddBorderColorThemeComponentCommand { get; private set; } + public RelayCommand DeleteThemeComponentCommand { get; private set; } + public RelayCommand AddBlockCommand { get; private set; } public RelayCommand AddSectionCommand { get; private set; } public RelayCommand DeleteBlockCommand { get; private set; } @@ -262,7 +281,12 @@ namespace Filtration.ViewModels public bool ActiveDocumentIsTheme { - get { { return AvalonDockWorkspaceViewModel.ActiveDocument is ThemeViewModel; } } + get { return AvalonDockWorkspaceViewModel.ActiveDocument is ThemeEditorViewModel; } + } + + public bool ActiveThemeIsEditable + { + get { return AvalonDockWorkspaceViewModel.ActiveThemeViewModel.EditEnabled; } } private bool ActiveDocumentIsEditable() @@ -283,16 +307,23 @@ namespace Filtration.ViewModels var themeViewModel = _themeProvider.NewThemeForScript(AvalonDockWorkspaceViewModel.ActiveScriptViewModel.Script); OpenTheme(themeViewModel); } - - private void OpenTheme(IThemeViewModel themeViewModel) + + private void OnEditMasterThemeCommand() { - if (AvalonDockWorkspaceViewModel.OpenDocuments.Contains(themeViewModel)) + var themeViewModel = + _themeProvider.MasterThemeForScript(AvalonDockWorkspaceViewModel.ActiveScriptViewModel.Script); + OpenTheme(themeViewModel); + } + + private void OpenTheme(IThemeEditorViewModel themeEditorViewModel) + { + if (AvalonDockWorkspaceViewModel.OpenDocuments.Contains(themeEditorViewModel)) { - AvalonDockWorkspaceViewModel.SwitchActiveDocument(themeViewModel); + AvalonDockWorkspaceViewModel.SwitchActiveDocument(themeEditorViewModel); } else { - AvalonDockWorkspaceViewModel.AddDocument(themeViewModel); + AvalonDockWorkspaceViewModel.AddDocument(themeEditorViewModel); } } @@ -341,7 +372,7 @@ namespace Filtration.ViewModels return; } - IThemeViewModel loadedViewModel; + IThemeEditorViewModel loadedViewModel; try { @@ -536,5 +567,26 @@ namespace Filtration.ViewModels { _avalonDockWorkspaceViewModel.ActiveScriptViewModel.ClearFilterCommand.Execute(null); } + + private void OnAddTextColorThemeComponentCommand() + { + _avalonDockWorkspaceViewModel.ActiveThemeViewModel.AddThemeComponentCommand.Execute(ThemeComponentType.TextColor); + } + + private void OnAddBackgroundColorThemeComponentCommand() + { + _avalonDockWorkspaceViewModel.ActiveThemeViewModel.AddThemeComponentCommand.Execute(ThemeComponentType.BackgroundColor); + } + + private void OnAddBorderColorThemeComponentCommand() + { + _avalonDockWorkspaceViewModel.ActiveThemeViewModel.AddThemeComponentCommand.Execute(ThemeComponentType.BorderColor); + } + + private void OnDeleteThemeComponentCommand() + { + _avalonDockWorkspaceViewModel.ActiveThemeViewModel.DeleteThemeComponentCommand.Execute( + _avalonDockWorkspaceViewModel.ActiveThemeViewModel.SelectedThemeComponent); + } } } diff --git a/Filtration/Views/AvalonDock/AvalonDockWorkspaceView.xaml b/Filtration/Views/AvalonDock/AvalonDockWorkspaceView.xaml index 9c10d74..932a7a1 100644 --- a/Filtration/Views/AvalonDock/AvalonDockWorkspaceView.xaml +++ b/Filtration/Views/AvalonDock/AvalonDockWorkspaceView.xaml @@ -56,7 +56,7 @@ - + diff --git a/Filtration/Views/AvalonDock/PanesTemplateSelector.cs b/Filtration/Views/AvalonDock/PanesTemplateSelector.cs index 1c58bc7..777aac6 100644 --- a/Filtration/Views/AvalonDock/PanesTemplateSelector.cs +++ b/Filtration/Views/AvalonDock/PanesTemplateSelector.cs @@ -25,7 +25,7 @@ namespace Filtration.Views.AvalonDock return ItemFilterScriptTemplate; } - if (item is IThemeViewModel) + if (item is IThemeEditorViewModel) { return ThemeTemplate; } diff --git a/Filtration/Views/MainWindow.xaml b/Filtration/Views/MainWindow.xaml index c53add1..8f51aa7 100644 --- a/Filtration/Views/MainWindow.xaml +++ b/Filtration/Views/MainWindow.xaml @@ -58,6 +58,11 @@ BorderBrush="ForestGreen" x:Name="ScriptToolsGroup" Visibility="{Binding ActiveDocumentIsScript, Converter={StaticResource BooleanVisibilityConverterCopy}, Mode=OneWay}" /> + @@ -86,11 +91,22 @@ + + + + + + + + + + + @@ -104,3 +120,4 @@ + \ No newline at end of file