diff --git a/Filtration.Tests/Models/TestLootFilterScript.cs b/Filtration.Tests/Models/TestLootFilterScript.cs index a19eb3c..fb5f7b6 100644 --- a/Filtration.Tests/Models/TestLootFilterScript.cs +++ b/Filtration.Tests/Models/TestLootFilterScript.cs @@ -4,7 +4,9 @@ using System.Collections.ObjectModel; using System.Linq; using System.Text; using System.Threading.Tasks; +using System.Windows.Media; using Filtration.Models; +using Filtration.Models.BlockItemTypes; using NUnit.Framework; namespace Filtration.Tests.Models @@ -42,5 +44,94 @@ namespace Filtration.Tests.Models // Assert Assert.AreEqual(0, result.Count(r => r.Contains("A script must have at least one block"))); } + + [Test] + public void ReplaceColors_ReplacesBackgroundColorsCorrectly() + { + // Arrange + var oldColor = new Color {A = 255, R = 255, G = 0, B = 0}; + var newColor = new Color {A = 255, R = 0, G = 255, B = 100}; + + var testInputReplaceColors = new ReplaceColorsParameterSet + { + OldBackgroundColor = oldColor, + NewBackgroundColor = newColor, + ReplaceBackgroundColor = true + }; + + var testInputBlock1 = new LootFilterBlock(); + testInputBlock1.BlockItems.Add(new BackgroundColorBlockItem(new Color {A = 255, R = 255, G = 0, B = 0})); + var testInputBlock2 = new LootFilterBlock(); + testInputBlock2.BlockItems.Add(new BackgroundColorBlockItem(new Color { A = 255, R = 255, G = 1, B = 0 })); + var testInputBlock3 = new LootFilterBlock(); + testInputBlock3.BlockItems.Add(new BackgroundColorBlockItem(new Color { A = 255, R = 255, G = 0, B = 0 })); + + var script = new LootFilterScript() + { + LootFilterBlocks = new ObservableCollection + { + testInputBlock1, + testInputBlock2, + testInputBlock3 + } + }; + + // Act + script.ReplaceColors(testInputReplaceColors); + + // Assert + Assert.AreEqual(newColor, testInputBlock1.BlockItems.OfType().First().Color); + Assert.AreNotEqual(newColor, testInputBlock2.BlockItems.OfType().First().Color); + Assert.AreEqual(newColor, testInputBlock3.BlockItems.OfType().First().Color); + } + + [Test] + public void ReplaceColors_OnlyReplacesColorsWhenAllSetParametersMatched() + { + // Arrange + var oldBackgroundColor = new Color { A = 255, R = 255, G = 0, B = 0 }; + var newBackgroundColor = new Color { A = 255, R = 0, G = 255, B = 100 }; + + var oldTextColor = new Color { A = 255, R = 100, G = 0, B = 50 }; + var newTextColor = new Color { A = 255, R = 101, G = 255, B = 51 }; + + var testInputReplaceColors = new ReplaceColorsParameterSet + { + OldBackgroundColor = oldBackgroundColor, + NewBackgroundColor = newBackgroundColor, + OldTextColor = oldTextColor, + NewTextColor = newTextColor, + ReplaceBackgroundColor = true, + ReplaceTextColor = true + }; + + var testInputBlock1 = new LootFilterBlock(); + testInputBlock1.BlockItems.Add(new BackgroundColorBlockItem(oldBackgroundColor)); + testInputBlock1.BlockItems.Add(new TextColorBlockItem(oldTextColor)); + var testInputBlock2 = new LootFilterBlock(); + testInputBlock2.BlockItems.Add(new BackgroundColorBlockItem(oldBackgroundColor)); + testInputBlock2.BlockItems.Add(new TextColorBlockItem(new Color {A = 1, R = 2, G = 3, B = 4})); + + var script = new LootFilterScript + { + LootFilterBlocks = new ObservableCollection + { + testInputBlock1, + testInputBlock2 + } + }; + + // Act + script.ReplaceColors(testInputReplaceColors); + + // Assert + // First test block has had its colors changed + Assert.AreEqual(newBackgroundColor, testInputBlock1.BlockItems.OfType().First().Color); + Assert.AreEqual(newTextColor, testInputBlock1.BlockItems.OfType().First().Color); + + // Second test block has not had its colors changed + Assert.AreEqual(oldBackgroundColor, testInputBlock2.BlockItems.OfType().First().Color); + Assert.AreNotEqual(newTextColor, testInputBlock2.BlockItems.OfType().First().Color); + } } } diff --git a/Filtration/Filtration.csproj b/Filtration/Filtration.csproj index c85fc20..c84a4e2 100644 --- a/Filtration/Filtration.csproj +++ b/Filtration/Filtration.csproj @@ -34,6 +34,12 @@ prompt 4 + + Filtration.App + + + Resources\filtration.ico + ..\packages\Castle.Core.3.3.0\lib\net45\Castle.Core.dll @@ -129,6 +135,7 @@ + @@ -146,6 +153,7 @@ + @@ -166,6 +174,9 @@ AboutWindow.xaml + + ReplaceColorsWindow.xaml + @@ -228,6 +239,10 @@ Designer MSBuild:Compile + + Designer + MSBuild:Compile + @@ -282,6 +297,8 @@ + + Always diff --git a/Filtration/Models/BlockItemTypes/HeightBlockItem.cs b/Filtration/Models/BlockItemTypes/HeightBlockItem.cs index f21a13b..78352a3 100644 --- a/Filtration/Models/BlockItemTypes/HeightBlockItem.cs +++ b/Filtration/Models/BlockItemTypes/HeightBlockItem.cs @@ -37,12 +37,12 @@ namespace Filtration.Models.BlockItemTypes public override Color SummaryBackgroundColor { - get { return Colors.Plum; } + get { return Colors.LightBlue; } } public override Color SummaryTextColor { - get { return Colors.White; } + get { return Colors.Black; } } public override int SortOrder diff --git a/Filtration/Models/BlockItemTypes/WidthBlockItem.cs b/Filtration/Models/BlockItemTypes/WidthBlockItem.cs index 189632b..96215d3 100644 --- a/Filtration/Models/BlockItemTypes/WidthBlockItem.cs +++ b/Filtration/Models/BlockItemTypes/WidthBlockItem.cs @@ -40,7 +40,7 @@ namespace Filtration.Models.BlockItemTypes public override Color SummaryBackgroundColor { - get { return Colors.Tan; } + get { return Colors.MediumPurple; } } public override Color SummaryTextColor diff --git a/Filtration/Models/LootFilterBlock.cs b/Filtration/Models/LootFilterBlock.cs index a58b41b..d8cb7e9 100644 --- a/Filtration/Models/LootFilterBlock.cs +++ b/Filtration/Models/LootFilterBlock.cs @@ -3,6 +3,7 @@ using System.Collections.ObjectModel; using System.Linq; using Filtration.Enums; using Filtration.Models.BlockItemBaseTypes; +using Filtration.Models.BlockItemTypes; namespace Filtration.Models { @@ -41,5 +42,10 @@ namespace Filtration.Models var blockItem = (ILootFilterBlockItem)Activator.CreateInstance(type); return BlockCount(type) < blockItem.MaximumAllowed; } + + public bool HasBlockItemOfType() + { + return BlockItems.Count(b => b is T) > 0; + } } } diff --git a/Filtration/Models/LootFilterScript.cs b/Filtration/Models/LootFilterScript.cs index 17ee0da..d746bda 100644 --- a/Filtration/Models/LootFilterScript.cs +++ b/Filtration/Models/LootFilterScript.cs @@ -1,6 +1,8 @@ using System; using System.Collections.Generic; using System.Collections.ObjectModel; +using System.Linq; +using Filtration.Models.BlockItemTypes; namespace Filtration.Models { @@ -27,5 +29,65 @@ namespace Filtration.Models return validationErrors; } + + public void ReplaceColors(ReplaceColorsParameterSet replaceColorsParameterSet) + { + + foreach ( + var block in + LootFilterBlocks.Where(b => BlockIsColorReplacementCandidate(replaceColorsParameterSet, b))) + { + if (replaceColorsParameterSet.ReplaceTextColor) + { + var textColorBlockItem = block.BlockItems.OfType().First(); + textColorBlockItem.Color = replaceColorsParameterSet.NewTextColor; + } + if (replaceColorsParameterSet.ReplaceBackgroundColor) + { + var backgroundColorBlockItem = block.BlockItems.OfType().First(); + backgroundColorBlockItem.Color = replaceColorsParameterSet.NewBackgroundColor; + } + if (replaceColorsParameterSet.ReplaceBorderColor) + { + var borderColorBlockItem = block.BlockItems.OfType().First(); + borderColorBlockItem.Color = replaceColorsParameterSet.NewBorderColor; + } + } + + } + + private bool BlockIsColorReplacementCandidate(ReplaceColorsParameterSet replaceColorsParameterSet, LootFilterBlock block) + { + var textColorItem = block.HasBlockItemOfType() + ? block.BlockItems.OfType().First() + : null; + var backgroundColorItem = block.HasBlockItemOfType() + ? block.BlockItems.OfType().First() + : null; + var borderColorItem = block.HasBlockItemOfType() + ? block.BlockItems.OfType().First() + : null; + + // If we don't have all of the things we want to replace, then we aren't a candidate for replacing those things. + if ((textColorItem == null && replaceColorsParameterSet.ReplaceTextColor) || + (backgroundColorItem == null && replaceColorsParameterSet.ReplaceBackgroundColor) || + (borderColorItem == null && replaceColorsParameterSet.ReplaceBorderColor)) + { + return false; + } + + if ((replaceColorsParameterSet.ReplaceTextColor && + textColorItem.Color != replaceColorsParameterSet.OldTextColor) || + (replaceColorsParameterSet.ReplaceBackgroundColor && + backgroundColorItem.Color != replaceColorsParameterSet.OldBackgroundColor) || + (replaceColorsParameterSet.ReplaceBorderColor && + borderColorItem.Color != replaceColorsParameterSet.OldBorderColor)) + { + return false; + } + + return true; + } + } } diff --git a/Filtration/Models/ReplaceColorsParameterSet.cs b/Filtration/Models/ReplaceColorsParameterSet.cs new file mode 100644 index 0000000..60095d4 --- /dev/null +++ b/Filtration/Models/ReplaceColorsParameterSet.cs @@ -0,0 +1,17 @@ +using System.Windows.Media; + +namespace Filtration.Models +{ + internal class ReplaceColorsParameterSet + { + public Color OldTextColor { get; set; } + public Color NewTextColor { get; set; } + public Color OldBackgroundColor { get; set; } + public Color NewBackgroundColor { get; set; } + public Color OldBorderColor { get; set; } + public Color NewBorderColor { get; set; } + public bool ReplaceTextColor { get; set; } + public bool ReplaceBackgroundColor { get; set; } + public bool ReplaceBorderColor { get; set; } + } +} diff --git a/Filtration/Resources/Icons/replace_colors_icon.png b/Filtration/Resources/Icons/replace_colors_icon.png new file mode 100644 index 0000000..29a397d Binary files /dev/null and b/Filtration/Resources/Icons/replace_colors_icon.png differ diff --git a/Filtration/Resources/filtration.ico b/Filtration/Resources/filtration.ico new file mode 100644 index 0000000..5cdf14f Binary files /dev/null and b/Filtration/Resources/filtration.ico differ diff --git a/Filtration/ViewModels/LootFilterBlockViewModel.cs b/Filtration/ViewModels/LootFilterBlockViewModel.cs index 8c96ece..32d12d2 100644 --- a/Filtration/ViewModels/LootFilterBlockViewModel.cs +++ b/Filtration/ViewModels/LootFilterBlockViewModel.cs @@ -3,12 +3,11 @@ using System.Collections.Generic; using System.Collections.ObjectModel; using System.Collections.Specialized; using System.Linq; -using System.Windows; using System.Windows.Media; using Filtration.Models; using Filtration.Models.BlockItemTypes; using Filtration.Services; -using Filtration.Translators; +using Filtration.Views; using GalaSoft.MvvmLight.CommandWpf; namespace Filtration.ViewModels @@ -23,14 +22,17 @@ namespace Filtration.ViewModels internal class LootFilterBlockViewModel : FiltrationViewModelBase, ILootFilterBlockViewModel { private readonly IStaticDataService _staticDataService; + private readonly IReplaceColorsViewModel _replaceColorsViewModel; private readonly MediaPlayer _mediaPlayer = new MediaPlayer(); private LootFilterScriptViewModel _parentScriptViewModel; private bool _displaySettingsPopupOpen; - public LootFilterBlockViewModel(IStaticDataService staticDataService) + public LootFilterBlockViewModel(IStaticDataService staticDataService, IReplaceColorsViewModel replaceColorsViewModel) { _staticDataService = staticDataService; + _replaceColorsViewModel = replaceColorsViewModel; + CopyBlockCommand = new RelayCommand(OnCopyBlockCommand); PasteBlockCommand = new RelayCommand(OnPasteBlockCommand); AddBlockCommand = new RelayCommand(OnAddBlockCommand); @@ -40,6 +42,7 @@ namespace Filtration.ViewModels MoveBlockDownCommand = new RelayCommand(OnMoveBlockDownCommand); MoveBlockToTopCommand = new RelayCommand(OnMoveBlockToTopCommand); MoveBlockToBottomCommand = new RelayCommand(OnMoveBlockToBottomCommand); + ReplaceColorsCommand = new RelayCommand(OnReplaceColorsCommand); AddFilterBlockItemCommand = new RelayCommand(OnAddFilterBlockItemCommand); AddAudioVisualBlockItemCommand = new RelayCommand(OnAddAudioVisualBlockItemCommand); RemoveFilterBlockItemCommand = new RelayCommand(OnRemoveFilterBlockItemCommand); @@ -74,6 +77,7 @@ namespace Filtration.ViewModels public RelayCommand MoveBlockDownCommand { get; private set; } public RelayCommand MoveBlockToTopCommand { get; private set; } public RelayCommand MoveBlockToBottomCommand { get; private set; } + public RelayCommand ReplaceColorsCommand { get; private set; } public RelayCommand AddFilterBlockItemCommand { get; private set; } public RelayCommand AddAudioVisualBlockItemCommand { get; private set; } public RelayCommand RemoveFilterBlockItemCommand { get; private set; } @@ -188,7 +192,7 @@ namespace Filtration.ViewModels public bool HasTextColor { - get { return FilterBlockItems.Count(b => b is TextColorBlockItem) > 0; } + get { return Block.HasBlockItemOfType(); } } public Color DisplayTextColor @@ -203,7 +207,7 @@ namespace Filtration.ViewModels public bool HasBackgroundColor { - get { return FilterBlockItems.Count(b => b is BackgroundColorBlockItem) > 0; } + get { return Block.HasBlockItemOfType(); } } public Color DisplayBackgroundColor @@ -218,7 +222,7 @@ namespace Filtration.ViewModels public bool HasBorderColor { - get { return FilterBlockItems.Count(b => b is BorderColorBlockItem) > 0; } + get { return Block.HasBlockItemOfType(); } } public Color DisplayBorderColor @@ -233,12 +237,12 @@ namespace Filtration.ViewModels public bool HasFontSize { - get { return FilterBlockItems.Count(b => b is FontSizeBlockItem) > 0; } + get { return Block.HasBlockItemOfType(); } } public bool HasSound { - get { return FilterBlockItems.Count(b => b is SoundBlockItem) > 0; } + get { return Block.HasBlockItemOfType(); } } private void OnAddFilterBlockItemCommand(Type blockItemType) @@ -320,6 +324,13 @@ namespace Filtration.ViewModels { _parentScriptViewModel.MoveBlockToBottom(this); } + + private void OnReplaceColorsCommand() + { + _replaceColorsViewModel.Initialise(_parentScriptViewModel.Script, Block); + var replaceColorsWindow = new ReplaceColorsWindow { DataContext = _replaceColorsViewModel }; + replaceColorsWindow.ShowDialog(); + } private bool AddBlockItemAllowed(Type type) { diff --git a/Filtration/ViewModels/LootFilterScriptViewModel.cs b/Filtration/ViewModels/LootFilterScriptViewModel.cs index f6992b7..7a75a58 100644 --- a/Filtration/ViewModels/LootFilterScriptViewModel.cs +++ b/Filtration/ViewModels/LootFilterScriptViewModel.cs @@ -15,6 +15,7 @@ namespace Filtration.ViewModels LootFilterScript Script { get; } bool IsDirty { get; } string Description { get; set; } + string DisplayName { get; } void Initialise(LootFilterScript lootFilterScript); ILootFilterBlockViewModel SelectedBlockViewModel { get; set; } void RemoveDirtyFlag(); @@ -93,7 +94,10 @@ namespace Filtration.ViewModels public bool IsDirty { get { return _isDirty || HasDirtyChildren; } - set { _isDirty = value; } + set + { + _isDirty = value; + } } private bool HasDirtyChildren @@ -113,6 +117,8 @@ namespace Filtration.ViewModels { CleanChildren(); IsDirty = false; + RaisePropertyChanged("Filename"); + RaisePropertyChanged("DisplayName"); } public string DisplayName @@ -279,7 +285,7 @@ namespace Filtration.ViewModels var newBlock = new LootFilterBlock(); vm.Initialise(newBlock, this); - if (LootFilterBlockViewModels.Count > 0) + if (targetBlockViewModel != null) { Script.LootFilterBlocks.Insert(Script.LootFilterBlocks.IndexOf(targetBlockViewModel.Block) + 1, newBlock); LootFilterBlockViewModels.Insert(LootFilterBlockViewModels.IndexOf(targetBlockViewModel) + 1, vm); diff --git a/Filtration/ViewModels/MainWindowViewModel.cs b/Filtration/ViewModels/MainWindowViewModel.cs index ca97111..3b4cbf2 100644 --- a/Filtration/ViewModels/MainWindowViewModel.cs +++ b/Filtration/ViewModels/MainWindowViewModel.cs @@ -26,16 +26,19 @@ namespace Filtration.ViewModels private readonly ILootFilterScriptViewModelFactory _lootFilterScriptViewModelFactory; private readonly ILootFilterPersistenceService _persistenceService; private readonly ILootFilterScriptTranslator _lootFilterScriptTranslator; + private readonly IReplaceColorsViewModel _replaceColorsViewModel; private ILootFilterScriptViewModel _currentScriptViewModel; private readonly ObservableCollection _scriptViewModels; public MainWindowViewModel(ILootFilterScriptViewModelFactory lootFilterScriptViewModelFactory, ILootFilterPersistenceService persistenceService, - ILootFilterScriptTranslator lootFilterScriptTranslator) + ILootFilterScriptTranslator lootFilterScriptTranslator, + IReplaceColorsViewModel replaceColorsViewModel) { _lootFilterScriptViewModelFactory = lootFilterScriptViewModelFactory; _persistenceService = persistenceService; _lootFilterScriptTranslator = lootFilterScriptTranslator; + _replaceColorsViewModel = replaceColorsViewModel; _scriptViewModels = new ObservableCollection(); @@ -48,8 +51,9 @@ namespace Filtration.ViewModels PasteCommand = new RelayCommand(OnPasteCommand, () => CurrentScriptViewModel != null); NewScriptCommand = new RelayCommand(OnNewScriptCommand); CloseScriptCommand = new RelayCommand(OnCloseScriptCommand, v => CurrentScriptViewModel != null); + ReplaceColorsCommand = new RelayCommand(OnReplaceColorsCommand, () => CurrentScriptViewModel != null); - LoadScriptFromFile("C:\\ThioleLootFilter.txt"); + //LoadScriptFromFile("C:\\ThioleLootFilter.txt"); SetLootFilterScriptDirectory(); } @@ -63,6 +67,7 @@ namespace Filtration.ViewModels public RelayCommand NewScriptCommand { get; private set; } public RelayCommand CloseScriptCommand { get; private set; } public RelayCommand OpenAboutWindowCommand { get; private set; } + public RelayCommand ReplaceColorsCommand { get; private set; } public ObservableCollection ScriptViewModels { @@ -87,11 +92,17 @@ namespace Filtration.ViewModels { _currentScriptViewModel = value; RaisePropertyChanged(); + RaisePropertyChanged("NoScriptsOpen"); SaveScriptCommand.RaiseCanExecuteChanged(); SaveScriptAsCommand.RaiseCanExecuteChanged(); } } + public bool NoScriptsOpen + { + get { return _currentScriptViewModel == null; } + } + private void OnOpenAboutWindowCommand() { var aboutWindow = new AboutWindow(); @@ -206,6 +217,13 @@ namespace Filtration.ViewModels } } + private void OnReplaceColorsCommand() + { + _replaceColorsViewModel.Initialise(CurrentScriptViewModel.Script); + var replaceColorsWindow = new ReplaceColorsWindow {DataContext = _replaceColorsViewModel}; + replaceColorsWindow.ShowDialog(); + } + private bool ValidateScript() { var result = CurrentScriptViewModel.Script.Validate(); diff --git a/Filtration/ViewModels/ReplaceColorsViewModel.cs b/Filtration/ViewModels/ReplaceColorsViewModel.cs new file mode 100644 index 0000000..9809e61 --- /dev/null +++ b/Filtration/ViewModels/ReplaceColorsViewModel.cs @@ -0,0 +1,171 @@ +using System.Linq; +using System.Windows.Media; +using Filtration.Models; +using Filtration.Models.BlockItemTypes; +using GalaSoft.MvvmLight.CommandWpf; + +namespace Filtration.ViewModels +{ + internal interface IReplaceColorsViewModel + { + void Initialise(LootFilterScript lootFilterScript, LootFilterBlock initialiseFromBlock); + void Initialise(LootFilterScript lootFilterScript); + } + + internal class ReplaceColorsViewModel : FiltrationViewModelBase, IReplaceColorsViewModel + { + private LootFilterScript _lootFilterScript; + private ReplaceColorsParameterSet _replaceColorsParameterSet; + + public ReplaceColorsViewModel() + { + ReplaceColorsCommand = new RelayCommand(OnReplaceColorsCommand); + } + + public RelayCommand ReplaceColorsCommand { get; private set; } + + public void Initialise(LootFilterScript lootFilterScript, LootFilterBlock initialiseFromBlock) + { + _replaceColorsParameterSet = new ReplaceColorsParameterSet(); + + if (initialiseFromBlock.BlockItems.Count(b => b.GetType() == typeof (TextColorBlockItem)) > 0) + { + _replaceColorsParameterSet.ReplaceTextColor = true; + _replaceColorsParameterSet.OldTextColor = + ((TextColorBlockItem) + initialiseFromBlock.BlockItems.First(b => b.GetType() == typeof (TextColorBlockItem))).Color; + } + + if (initialiseFromBlock.BlockItems.Count(b => b.GetType() == typeof(BackgroundColorBlockItem)) > 0) + { + _replaceColorsParameterSet.ReplaceBackgroundColor = true; + _replaceColorsParameterSet.OldBackgroundColor = + ((BackgroundColorBlockItem) + initialiseFromBlock.BlockItems.First(b => b.GetType() == typeof(BackgroundColorBlockItem))).Color; + } + + if (initialiseFromBlock.BlockItems.Count(b => b.GetType() == typeof(BorderColorBlockItem)) > 0) + { + _replaceColorsParameterSet.ReplaceBorderColor = true; + _replaceColorsParameterSet.OldBorderColor = + ((BorderColorBlockItem) + initialiseFromBlock.BlockItems.First(b => b.GetType() == typeof(BorderColorBlockItem))).Color; + } + + _lootFilterScript = lootFilterScript; + } + + public Color NewTextColor + { + get { return _replaceColorsParameterSet.NewTextColor; } + set + { + _replaceColorsParameterSet.NewTextColor = value; + RaisePropertyChanged(); + RaisePropertyChanged("DisplayTextColor"); + } + } + + public Color DisplayTextColor + { + get + { + return _replaceColorsParameterSet.ReplaceTextColor + ? _replaceColorsParameterSet.NewTextColor + : new Color {A = 255, R = 255, G = 255, B = 255}; + } + } + + public bool ReplaceTextColor + { + get { return _replaceColorsParameterSet.ReplaceTextColor; } + set + { + _replaceColorsParameterSet.ReplaceTextColor = value; + RaisePropertyChanged("DisplayTextColor"); + } + } + + public Color NewBackgroundColor + { + get { return _replaceColorsParameterSet.NewBackgroundColor; } + set + { + _replaceColorsParameterSet.NewBackgroundColor = value; + RaisePropertyChanged(); + RaisePropertyChanged("DisplayBackgroundColor"); + } + } + + public Color DisplayBackgroundColor + { + get + { + return _replaceColorsParameterSet.ReplaceBackgroundColor + ? _replaceColorsParameterSet.NewBackgroundColor + : new Color { A = 255, R = 0, G = 0, B = 0 }; + } + } + + public bool ReplaceBackgroundColor + { + get { return _replaceColorsParameterSet.ReplaceBackgroundColor; } + set + { + _replaceColorsParameterSet.ReplaceBackgroundColor = value; + RaisePropertyChanged("DisplayBackgroundColor"); + } + } + + public Color NewBorderColor + { + get { return _replaceColorsParameterSet.NewBorderColor; } + set + { + _replaceColorsParameterSet.NewBorderColor = value; + RaisePropertyChanged(); + RaisePropertyChanged("DisplayBorderColor"); + } + } + + public Color DisplayBorderColor + { + get + { + return _replaceColorsParameterSet.ReplaceBorderColor + ? _replaceColorsParameterSet.NewBorderColor + : new Color { A = 255, R = 0, G = 0, B = 0 }; + } + } + + public bool ReplaceBorderColor + { + get { return _replaceColorsParameterSet.ReplaceBorderColor; } + set + { + _replaceColorsParameterSet.ReplaceBorderColor = value; + RaisePropertyChanged("DisplayBorderColor"); + } + } + + public ReplaceColorsParameterSet ReplaceColorsParameterSet + { + get + { + return _replaceColorsParameterSet; + } + } + + public void Initialise(LootFilterScript lootFilterScript) + { + _replaceColorsParameterSet = new ReplaceColorsParameterSet(); + _lootFilterScript = lootFilterScript; + } + + private void OnReplaceColorsCommand() + { + _lootFilterScript.ReplaceColors(_replaceColorsParameterSet); + } + + } +} diff --git a/Filtration/Views/IconsDictionary.xaml b/Filtration/Views/IconsDictionary.xaml index 35dcba0..6978cea 100644 --- a/Filtration/Views/IconsDictionary.xaml +++ b/Filtration/Views/IconsDictionary.xaml @@ -16,4 +16,5 @@ + \ No newline at end of file diff --git a/Filtration/Views/LootFilterBlockDisplaySettingsView.xaml b/Filtration/Views/LootFilterBlockDisplaySettingsView.xaml index 6a29ab0..34e78d2 100644 --- a/Filtration/Views/LootFilterBlockDisplaySettingsView.xaml +++ b/Filtration/Views/LootFilterBlockDisplaySettingsView.xaml @@ -92,7 +92,7 @@ diff --git a/Filtration/Views/LootFilterBlockView.xaml b/Filtration/Views/LootFilterBlockView.xaml index 300157f..f47e8cb 100644 --- a/Filtration/Views/LootFilterBlockView.xaml +++ b/Filtration/Views/LootFilterBlockView.xaml @@ -52,6 +52,8 @@ + + diff --git a/Filtration/Views/LootFilterScriptView.xaml b/Filtration/Views/LootFilterScriptView.xaml index 1d70de3..447cd12 100644 --- a/Filtration/Views/LootFilterScriptView.xaml +++ b/Filtration/Views/LootFilterScriptView.xaml @@ -32,7 +32,6 @@ - @@ -45,7 +44,6 @@ - diff --git a/Filtration/Views/MainWindow.xaml b/Filtration/Views/MainWindow.xaml index 0217603..6b714b6 100644 --- a/Filtration/Views/MainWindow.xaml +++ b/Filtration/Views/MainWindow.xaml @@ -11,6 +11,10 @@ mc:Ignorable="d" d:DataContext="{d:DesignInstance Type=viewModels:MainWindowViewModel}" Title="{Binding WindowTitle}" Height="707" Width="930" BorderThickness="1" BorderBrush="Black"> + + + + @@ -27,6 +31,9 @@ + + + @@ -38,22 +45,26 @@ + + diff --git a/Filtration/Views/ReplaceColorsWindow.xaml.cs b/Filtration/Views/ReplaceColorsWindow.xaml.cs new file mode 100644 index 0000000..b8cce0f --- /dev/null +++ b/Filtration/Views/ReplaceColorsWindow.xaml.cs @@ -0,0 +1,20 @@ +using System.Windows; + +namespace Filtration.Views +{ + public partial class ReplaceColorsWindow + { + public ReplaceColorsWindow() + { + InitializeComponent(); + } + + private void ReplaceColorsWindow_OnLoaded(object sender, RoutedEventArgs e) + { + var curApp = Application.Current; + var mainWindow = curApp.MainWindow; + Left = mainWindow.Left + (mainWindow.Width - ActualWidth) / 2; + Top = mainWindow.Top + (mainWindow.Height - ActualHeight) / 2; + } + } +} diff --git a/Filtration/WindsorInstallers/ViewModelsInstaller.cs b/Filtration/WindsorInstallers/ViewModelsInstaller.cs index c178199..e41c28e 100644 --- a/Filtration/WindsorInstallers/ViewModelsInstaller.cs +++ b/Filtration/WindsorInstallers/ViewModelsInstaller.cs @@ -25,6 +25,11 @@ namespace Filtration.WindsorInstallers .ImplementedBy() .LifeStyle.Transient); + container.Register( + Component.For() + .ImplementedBy() + .LifeStyle.Singleton); + container.AddFacility(); container.Register( Component.For().AsFactory());