diff --git a/Filtration.Interface/IDocument.cs b/Filtration.Interface/IDocument.cs index 68d218e..e27b2ec 100644 --- a/Filtration.Interface/IDocument.cs +++ b/Filtration.Interface/IDocument.cs @@ -1,6 +1,4 @@ -using System.Windows.Media; - -namespace Filtration.Interface +namespace Filtration.Interface { public interface IDocument { diff --git a/Filtration.Tests/Translators/TestItemFilterBlockTranslator.cs b/Filtration.Tests/Translators/TestItemFilterBlockTranslator.cs index c844577..4393ff5 100644 --- a/Filtration.Tests/Translators/TestItemFilterBlockTranslator.cs +++ b/Filtration.Tests/Translators/TestItemFilterBlockTranslator.cs @@ -1,5 +1,6 @@ using System; using System.Collections.Generic; +using System.Collections.ObjectModel; using System.Linq; using System.Windows.Media; using Filtration.ObjectModel; @@ -1325,6 +1326,108 @@ namespace Filtration.Tests.Translators Assert.AreEqual(expectedResult, result); } + [Test] + public void ReplaceColorBlockItemsFromString_SingleLine_ReplacesColorBlock() + { + // Arrange + var testInputString = "SetTextColor 240 200 150 # Rarest Currency"; + + var testInputBlockItems = new ObservableCollection(); + var testInputBlockItem = new TextColorBlockItem(Colors.Red); + testInputBlockItems.Add(testInputBlockItem); + + // Act + _testUtility.Translator.ReplaceColorBlockItemsFromString(testInputBlockItems, testInputString); + + // Assert + var textColorBlockItem = testInputBlockItems.First(b => b is TextColorBlockItem) as TextColorBlockItem; + Assert.IsNotNull(textColorBlockItem); + Assert.AreNotSame(testInputBlockItem, textColorBlockItem); + Assert.AreEqual(new Color { R = 240, G = 200, B = 150, A = 255}, textColorBlockItem.Color); + } + + [Test] + public void ReplaceColorBlockItemsFromString_MalformedLine_DoesNothing() + { + // Arrange + var testInputString = "SetTextCsaolor 240 200 150 # Rarest Currency"; + + var testInputBlockItems = new ObservableCollection(); + var testInputBlockItem = new TextColorBlockItem(Colors.Red); + testInputBlockItems.Add(testInputBlockItem); + + // Act + _testUtility.Translator.ReplaceColorBlockItemsFromString(testInputBlockItems, testInputString); + + // Assert + var textColorBlockItem = testInputBlockItems.First(b => b is TextColorBlockItem) as TextColorBlockItem; + Assert.IsNotNull(textColorBlockItem); + Assert.AreSame(testInputBlockItem, textColorBlockItem); + } + + [Test] + public void ReplaceColorBlockItemsFromString_MultipleLines_ExistingBlockItems() + { + // Arrange + var testInputString = "SetTextColor 240 200 150 # Rarest Currency" + Environment.NewLine + + "SetBackgroundColor 0 0 0 # Rarest Currency Background" + Environment.NewLine + + "SetBorderColor 255 255 255 # Rarest Currency Border"; + + var testInputBlockItems = new ObservableCollection(); + var testInputTextColorBlockItem = new TextColorBlockItem(Colors.Red); + var testInputBackgroundColorBlockItem = new BackgroundColorBlockItem(Colors.Blue); + var testInpuBorderColorBlockItem = new BorderColorBlockItem(Colors.Yellow); + testInputBlockItems.Add(testInputTextColorBlockItem); + testInputBlockItems.Add(testInputBackgroundColorBlockItem); + testInputBlockItems.Add(testInpuBorderColorBlockItem); + + // Act + _testUtility.Translator.ReplaceColorBlockItemsFromString(testInputBlockItems, testInputString); + + // Assert + var textColorBlockItem = testInputBlockItems.First(b => b is TextColorBlockItem) as TextColorBlockItem; + Assert.IsNotNull(textColorBlockItem); + Assert.AreNotSame(testInputTextColorBlockItem, textColorBlockItem); + Assert.AreEqual(new Color {A = 255, R = 240, G = 200, B = 150}, textColorBlockItem.Color); + + var backgroundColorBlockItem = testInputBlockItems.First(b => b is BackgroundColorBlockItem) as BackgroundColorBlockItem; + Assert.IsNotNull(backgroundColorBlockItem); + Assert.AreNotSame(testInputBackgroundColorBlockItem, backgroundColorBlockItem); + Assert.AreEqual(new Color { A = 255, R = 0, G = 0, B = 0 }, backgroundColorBlockItem.Color); + + var borderColorBlockItem = testInputBlockItems.First(b => b is BorderColorBlockItem) as BorderColorBlockItem; + Assert.IsNotNull(borderColorBlockItem); + Assert.AreNotSame(testInpuBorderColorBlockItem, borderColorBlockItem); + Assert.AreEqual(new Color { A = 255, R = 255, G = 255, B = 255 }, borderColorBlockItem.Color); + } + + [Test] + public void ReplaceColorBlockItemsFromString_MultipleLines_NoExistingBlockItems() + { + // Arrange + var testInputString = "SetTextColor 240 200 150 # Rarest Currency" + Environment.NewLine + + "SetBackgroundColor 0 0 0 # Rarest Currency Background" + Environment.NewLine + + "SetBorderColor 255 255 255 # Rarest Currency Border"; + + var testInputBlockItems = new ObservableCollection(); + + // Act + _testUtility.Translator.ReplaceColorBlockItemsFromString(testInputBlockItems, testInputString); + + // Assert + var textColorBlockItem = testInputBlockItems.First(b => b is TextColorBlockItem) as TextColorBlockItem; + Assert.IsNotNull(textColorBlockItem); + Assert.AreEqual(new Color { A = 255, R = 240, G = 200, B = 150 }, textColorBlockItem.Color); + + var backgroundColorBlockItem = testInputBlockItems.First(b => b is BackgroundColorBlockItem) as BackgroundColorBlockItem; + Assert.IsNotNull(backgroundColorBlockItem); + Assert.AreEqual(new Color { A = 255, R = 0, G = 0, B = 0 }, backgroundColorBlockItem.Color); + + var borderColorBlockItem = testInputBlockItems.First(b => b is BorderColorBlockItem) as BorderColorBlockItem; + Assert.IsNotNull(borderColorBlockItem); + Assert.AreEqual(new Color { A = 255, R = 255, G = 255, B = 255 }, borderColorBlockItem.Color); + } + private class ItemFilterBlockTranslatorTestUtility { public ItemFilterBlockTranslatorTestUtility() diff --git a/Filtration.ThemeEditor/ViewModels/ThemeViewModel.cs b/Filtration.ThemeEditor/ViewModels/ThemeViewModel.cs index 6d9dc6e..eb4befa 100644 --- a/Filtration.ThemeEditor/ViewModels/ThemeViewModel.cs +++ b/Filtration.ThemeEditor/ViewModels/ThemeViewModel.cs @@ -36,7 +36,7 @@ namespace Filtration.ThemeEditor.ViewModels var icon = new BitmapImage(); icon.BeginInit(); - icon.UriSource = new Uri("pack://application:,,,/Filtration;component/Resources/Icons/theme_icon.png"); + icon.UriSource = new Uri("pack://application:,,,/Filtration;component/Resources/Icons/Theme.ico"); icon.EndInit(); IconSource = icon; } diff --git a/Filtration/App.xaml b/Filtration/App.xaml index ad4d7cf..2165bdd 100644 --- a/Filtration/App.xaml +++ b/Filtration/App.xaml @@ -5,14 +5,18 @@ - - - - - + + - \ No newline at end of file + + + + \ No newline at end of file diff --git a/Filtration/Converters/BooleanVisibilityConverter.cs b/Filtration/Converters/BooleanVisibilityConverter.cs index ba451d8..153b4c2 100644 --- a/Filtration/Converters/BooleanVisibilityConverter.cs +++ b/Filtration/Converters/BooleanVisibilityConverter.cs @@ -9,7 +9,30 @@ namespace Filtration.Converters { public object Convert(object value, Type targetType, object parameter, CultureInfo culture) { - return (bool)value ? Visibility.Visible : Visibility.Collapsed; + if (value is bool && targetType == typeof (Visibility)) + { + var val = (bool) value; + if (val) + { + return Visibility.Visible; + } + if (parameter is Visibility) + { + return parameter; + } + return Visibility.Collapsed; + } + if (value != null) + { + return Visibility.Visible; + } + + + if (parameter is Visibility) + { + return parameter; + } + return Visibility.Collapsed; } public object ConvertBack(object value, Type targetType, object parameter, CultureInfo culture) diff --git a/Filtration/Converters/BooleanVisibilityConverterCopy.cs b/Filtration/Converters/BooleanVisibilityConverterCopy.cs new file mode 100644 index 0000000..3be867a --- /dev/null +++ b/Filtration/Converters/BooleanVisibilityConverterCopy.cs @@ -0,0 +1,43 @@ +using System; +using System.Globalization; +using System.Windows; +using System.Windows.Data; + +namespace Filtration.Converters +{ + internal class BooleanVisibilityConverterCopy : IValueConverter + { + public object Convert(object value, Type targetType, object parameter, CultureInfo culture) + { + if (value is bool && targetType == typeof (Visibility)) + { + var val = (bool) value; + if (val) + { + return Visibility.Visible; + } + if (parameter is Visibility) + { + return parameter; + } + return Visibility.Collapsed; + } + if (value != null) + { + return Visibility.Visible; + } + + + if (parameter is Visibility) + { + return parameter; + } + return Visibility.Collapsed; + } + + public object ConvertBack(object value, Type targetType, object parameter, CultureInfo culture) + { + throw new NotImplementedException(); + } + } +} diff --git a/Filtration/Filtration.csproj b/Filtration/Filtration.csproj index a681a54..9408166 100644 --- a/Filtration/Filtration.csproj +++ b/Filtration/Filtration.csproj @@ -53,6 +53,12 @@ ..\packages\Castle.Windsor.3.3.0\lib\net45\Castle.Windsor.dll + + ..\packages\Fluent.Ribbon.3.4.0\lib\net45\Fluent.dll + + + ..\packages\FontAwesome.WPF.4.3.0.3\lib\FontAwesome.WPF.dll + False ..\packages\MvvmLightLibs.5.1.1.0\lib\net45\GalaSoft.MvvmLight.dll @@ -61,9 +67,6 @@ False ..\packages\MvvmLightLibs.5.1.1.0\lib\net45\GalaSoft.MvvmLight.Platform.dll - - ..\packages\MahApps.Metro.1.1.2.0\lib\net45\MahApps.Metro.dll - @@ -75,7 +78,9 @@ ..\packages\WPFToolkit.3.5.50211.1\lib\System.Windows.Controls.Layout.Toolkit.dll - + + ..\packages\Fluent.Ribbon.3.4.0\lib\net45\System.Windows.Interactivity.dll + @@ -124,6 +129,7 @@ + @@ -346,10 +352,8 @@ - - @@ -361,7 +365,6 @@ - @@ -369,8 +372,13 @@ - + + + + + + Always diff --git a/Filtration/Resources/Icons/Copy.ico b/Filtration/Resources/Icons/Copy.ico new file mode 100644 index 0000000..bcba93f Binary files /dev/null and b/Filtration/Resources/Icons/Copy.ico differ diff --git a/Filtration/Resources/Icons/Paste.ico b/Filtration/Resources/Icons/Paste.ico new file mode 100644 index 0000000..4487f98 Binary files /dev/null and b/Filtration/Resources/Icons/Paste.ico differ diff --git a/Filtration/Resources/Icons/PasteStyle.ico b/Filtration/Resources/Icons/PasteStyle.ico new file mode 100644 index 0000000..84052c0 Binary files /dev/null and b/Filtration/Resources/Icons/PasteStyle.ico differ diff --git a/Filtration/Resources/Icons/ReplaceColors.ico b/Filtration/Resources/Icons/ReplaceColors.ico new file mode 100644 index 0000000..100e18f Binary files /dev/null and b/Filtration/Resources/Icons/ReplaceColors.ico differ diff --git a/Filtration/Resources/Icons/Theme.ico b/Filtration/Resources/Icons/Theme.ico new file mode 100644 index 0000000..00ead80 Binary files /dev/null and b/Filtration/Resources/Icons/Theme.ico differ diff --git a/Filtration/Resources/Icons/copy_icon.png b/Filtration/Resources/Icons/copy_icon.png deleted file mode 100644 index 8ff40a0..0000000 Binary files a/Filtration/Resources/Icons/copy_icon.png and /dev/null differ diff --git a/Filtration/Resources/Icons/paste_icon.png b/Filtration/Resources/Icons/paste_icon.png deleted file mode 100644 index 36915a5..0000000 Binary files a/Filtration/Resources/Icons/paste_icon.png and /dev/null differ diff --git a/Filtration/Resources/Icons/replace_colors_icon.png b/Filtration/Resources/Icons/replace_colors_icon.png deleted file mode 100644 index 29a397d..0000000 Binary files a/Filtration/Resources/Icons/replace_colors_icon.png and /dev/null differ diff --git a/Filtration/Resources/Icons/settings_icon.png b/Filtration/Resources/Icons/settings_icon.png new file mode 100644 index 0000000..eb7b43c Binary files /dev/null and b/Filtration/Resources/Icons/settings_icon.png differ diff --git a/Filtration/Resources/Icons/theme_icon.png b/Filtration/Resources/Icons/theme_icon.png deleted file mode 100644 index 7b4c1d4..0000000 Binary files a/Filtration/Resources/Icons/theme_icon.png and /dev/null differ diff --git a/Filtration/Translators/ItemFilterBlockTranslator.cs b/Filtration/Translators/ItemFilterBlockTranslator.cs index aae6375..c4f2ecc 100644 --- a/Filtration/Translators/ItemFilterBlockTranslator.cs +++ b/Filtration/Translators/ItemFilterBlockTranslator.cs @@ -1,5 +1,6 @@ using System; using System.Collections.Generic; +using System.Collections.ObjectModel; using System.IO; using System.Linq; using System.Text.RegularExpressions; @@ -17,6 +18,7 @@ namespace Filtration.Translators { ItemFilterBlock TranslateStringToItemFilterBlock(string inputString); string TranslateItemFilterBlockToString(ItemFilterBlock block); + void ReplaceColorBlockItemsFromString(ObservableCollection blockItems, string inputString); } internal class ItemFilterBlockTranslator : IItemFilterBlockTranslator @@ -260,26 +262,30 @@ namespace Filtration.Translators } private void AddColorItemToBlockItems(ItemFilterBlock block, string inputString) where T : ColorBlockItem + { + block.BlockItems.Add(GetColorBlockItemFromString(inputString)); + } + + private T GetColorBlockItemFromString(string inputString) where T: ColorBlockItem { var blockItem = Activator.CreateInstance(); var result = Regex.Matches(inputString, @"([\w\s]*)[#]?(.*)"); - // When Theme support is added result[0].Groups[2].Value will contain the ColorGroup in the comment if it exists. blockItem.Color = GetColorFromString(result[0].Groups[1].Value); - + var componentName = result[0].Groups[2].Value.Trim(); if (!string.IsNullOrEmpty(componentName)) { ThemeComponentType componentType; - if (typeof (T) == typeof (TextColorBlockItem)) + if (typeof(T) == typeof(TextColorBlockItem)) { componentType = ThemeComponentType.TextColor; } - else if (typeof (T) == typeof (BackgroundColorBlockItem)) + else if (typeof(T) == typeof(BackgroundColorBlockItem)) { componentType = ThemeComponentType.BackgroundColor; } - else if (typeof (T) == typeof (BorderColorBlockItem)) + else if (typeof(T) == typeof(BorderColorBlockItem)) { componentType = ThemeComponentType.BorderColor; } @@ -291,7 +297,58 @@ namespace Filtration.Translators blockItem.ThemeComponent = _themeComponentListBuilder.AddComponent(componentType, componentName, blockItem.Color); } - block.BlockItems.Add(blockItem); + return blockItem; + } + + public void ReplaceColorBlockItemsFromString(ObservableCollection blockItems , string inputString) + { + foreach (var line in new LineReader(() => new StringReader(inputString))) + { + var matches = Regex.Match(line, @"(\w+)"); + + switch (matches.Value) + { + case "SetTextColor": + { + ReplaceColorBlockItem(blockItems, line); + break; + } + case "SetBackgroundColor": + { + ReplaceColorBlockItem(blockItems, line); + break; + } + case "SetBorderColor": + { + ReplaceColorBlockItem(blockItems, line); + break; + } + case "SetFontSize": + { + ReplaceFontSizeBlockItem(blockItems, line); + break; + } + } + } + } + + private void ReplaceColorBlockItem(ObservableCollection blockItems, string inputString) where T : ColorBlockItem + { + var newBlockItem = GetColorBlockItemFromString(inputString); + var existingBlockItem = blockItems.OfType().FirstOrDefault(); + blockItems.Remove(existingBlockItem); + blockItems.Add(newBlockItem); + } + + private void ReplaceFontSizeBlockItem(ObservableCollection blockItems, string inputString) + { + var match = Regex.Match(inputString, @"\s+(\d+)"); + if (!match.Success) return; + + var newBlockItem = new FontSizeBlockItem(Convert.ToInt16(match.Value)); + var existingBlockItem = blockItems.OfType().FirstOrDefault(); + blockItems.Remove(existingBlockItem); + blockItems.Add(newBlockItem); } private void AddBlockGroupToBlock(ItemFilterBlock block, string inputString) diff --git a/Filtration/UserControls/ItemPreviewControl.xaml b/Filtration/UserControls/ItemPreviewControl.xaml index a7d0822..94f4d14 100644 --- a/Filtration/UserControls/ItemPreviewControl.xaml +++ b/Filtration/UserControls/ItemPreviewControl.xaml @@ -10,17 +10,31 @@ - + + - - - - - - - - - - + + + + + + + + + + + + + + + + + + + + + + + diff --git a/Filtration/UserControls/ItemPreviewControl.xaml.cs b/Filtration/UserControls/ItemPreviewControl.xaml.cs index b39eb8f..2a753d4 100644 --- a/Filtration/UserControls/ItemPreviewControl.xaml.cs +++ b/Filtration/UserControls/ItemPreviewControl.xaml.cs @@ -33,6 +33,13 @@ namespace Filtration.UserControls new FrameworkPropertyMetadata() ); + public static readonly DependencyProperty BlockFontSizeProperty = DependencyProperty.Register( + "BlockFontSize", + typeof(int), + typeof(ItemPreviewControl), + new FrameworkPropertyMetadata() + ); + public Color TextColor { get { return (Color) GetValue(TextColorProperty); } @@ -50,25 +57,11 @@ namespace Filtration.UserControls get { return (Color)GetValue(BorderColorProperty); } set { SetValue(BorderColorProperty, value); } } - - //private static void OnItemPreviewControlPropertyChanged(DependencyObject source, - // DependencyPropertyChangedEventArgs e) - //{ - // var control = source as ItemPreviewControl; - // if (control == null) return; - // control.OnPropertyChanged("TextColor"); - // control.OnPropertyChanged("BackgroundColor"); - // control.OnPropertyChanged("BorderColor"); - //} - - //public event PropertyChangedEventHandler PropertyChanged; - - //[NotifyPropertyChangedInvocator] - //protected virtual void OnPropertyChanged([CallerMemberName] string propertyName = null) - //{ - // var handler = PropertyChanged; - // if (handler != null) handler(this, new PropertyChangedEventArgs(propertyName)); - //} + public int BlockFontSize + { + get { return (int)GetValue(BlockFontSizeProperty); } + set { SetValue(BlockFontSizeProperty, value); } + } } } diff --git a/Filtration/ViewModels/ItemFilterBlockViewModel.cs b/Filtration/ViewModels/ItemFilterBlockViewModel.cs index 35d8cd3..cf2d5a5 100644 --- a/Filtration/ViewModels/ItemFilterBlockViewModel.cs +++ b/Filtration/ViewModels/ItemFilterBlockViewModel.cs @@ -19,7 +19,9 @@ namespace Filtration.ViewModels { void Initialise(ItemFilterBlock itemFilterBlock, ItemFilterScriptViewModel parentScriptViewModel); bool IsDirty { get; set; } + bool IsExpanded { get; set; } ItemFilterBlock Block { get; } + void RefreshBlockPreview(); } internal class ItemFilterBlockViewModel : FiltrationViewModelBase, IItemFilterBlockViewModel @@ -38,6 +40,8 @@ namespace Filtration.ViewModels CopyBlockCommand = new RelayCommand(OnCopyBlockCommand); PasteBlockCommand = new RelayCommand(OnPasteBlockCommand); + CopyBlockStyleCommand = new RelayCommand(OnCopyBlockStyleCommand); + PasteBlockStyleCommand = new RelayCommand(OnPasteBlockStyleCommand); AddBlockCommand = new RelayCommand(OnAddBlockCommand); AddSectionCommand = new RelayCommand(OnAddSectionCommand); DeleteBlockCommand = new RelayCommand(OnDeleteBlockCommand); @@ -74,6 +78,8 @@ namespace Filtration.ViewModels public RelayCommand CopyBlockCommand { get; private set; } public RelayCommand PasteBlockCommand { get; private set; } + public RelayCommand CopyBlockStyleCommand { get; private set; } + public RelayCommand PasteBlockStyleCommand { get; private set; } public RelayCommand AddBlockCommand { get; private set; } public RelayCommand AddSectionCommand { get; private set; } public RelayCommand DeleteBlockCommand { get; private set; } @@ -90,7 +96,9 @@ namespace Filtration.ViewModels public RelayCommand PlaySoundCommand { get; private set; } public ItemFilterBlock Block { get; private set; } + public bool IsDirty { get; set; } + public bool IsExpanded { get; set; } public ObservableCollection BlockItems { @@ -228,7 +236,7 @@ namespace Filtration.ViewModels { return HasTextColor ? BlockItems.OfType().First().Color - : new Color { A = 255, R = 255, G = 255, B = 255 }; + : new Color { A = 255, R = 200, G = 200, B = 200 }; } } @@ -267,6 +275,12 @@ namespace Filtration.ViewModels get { return Block.HasBlockItemOfType(); } } + public int DisplayFontSize + { + // Dividing by 1.8 roughly scales in-game font sizes down to WPF sizes + get { return HasFontSize ? (int)(BlockItems.OfType().First().Value / 1.8) : 19; } + } + public bool HasSound { get { return Block.HasBlockItemOfType(); } @@ -325,6 +339,15 @@ namespace Filtration.ViewModels _parentScriptViewModel.PasteBlock(this); } + private void OnCopyBlockStyleCommand() + { + _parentScriptViewModel.CopyBlockStyle(this); + } + + private void OnPasteBlockStyleCommand() + { + _parentScriptViewModel.PasteBlockStyle(this); + } private void OnAddBlockCommand() { @@ -383,10 +406,16 @@ namespace Filtration.ViewModels } private void OnAudioVisualBlockItemChanged(object sender, EventArgs e) + { + RefreshBlockPreview(); + } + + public void RefreshBlockPreview() { RaisePropertyChanged("DisplayTextColor"); RaisePropertyChanged("DisplayBackgroundColor"); RaisePropertyChanged("DisplayBorderColor"); + RaisePropertyChanged("DisplayFontSize"); RaisePropertyChanged("HasSound"); } diff --git a/Filtration/ViewModels/ItemFilterScriptViewModel.cs b/Filtration/ViewModels/ItemFilterScriptViewModel.cs index d27f934..c764d14 100644 --- a/Filtration/ViewModels/ItemFilterScriptViewModel.cs +++ b/Filtration/ViewModels/ItemFilterScriptViewModel.cs @@ -37,10 +37,28 @@ namespace Filtration.ViewModels void RemoveDirtyFlag(); void SetDirtyFlag(); + RelayCommand AddBlockCommand { get; } + RelayCommand AddSectionCommand { get; } + RelayCommand DeleteBlockCommand { get; } + RelayCommand MoveBlockUpCommand { get; } + RelayCommand MoveBlockDownCommand { get; } + RelayCommand MoveBlockToTopCommand { get; } + RelayCommand MoveBlockToBottomCommand { get;} + RelayCommand CopyBlockCommand { get; } + RelayCommand PasteBlockCommand { get; } + RelayCommand CopyBlockStyleCommand { get; } + RelayCommand PasteBlockStyleCommand { get; } + RelayCommand ExpandAllBlocksCommand { get; } + RelayCommand CollapseAllBlocksCommand { get; } + RelayCommand ToggleShowAdvancedCommand { get; } + RelayCommand ClearFilterCommand { get; } + void AddSection(IItemFilterBlockViewModel targetBlockViewModel); void AddBlock(IItemFilterBlockViewModel targetBlockViewModel); void CopyBlock(IItemFilterBlockViewModel targetBlockViewModel); + void CopyBlockStyle(IItemFilterBlockViewModel targetBlockViewModel); void PasteBlock(IItemFilterBlockViewModel targetBlockViewModel); + void PasteBlockStyle(IItemFilterBlockViewModel targetBlockViewModel); } internal class ItemFilterScriptViewModel : PaneViewModel, IItemFilterScriptViewModel @@ -80,7 +98,11 @@ namespace Filtration.ViewModels AddBlockCommand = new RelayCommand(OnAddBlockCommand); AddSectionCommand = new RelayCommand(OnAddSectionCommand, () => SelectedBlockViewModel != null); CopyBlockCommand = new RelayCommand(OnCopyBlockCommand, () => SelectedBlockViewModel != null); + CopyBlockStyleCommand = new RelayCommand(OnCopyBlockStyleCommand, () => SelectedBlockViewModel != null); PasteBlockCommand = new RelayCommand(OnPasteBlockCommand, () => SelectedBlockViewModel != null); + PasteBlockStyleCommand = new RelayCommand(OnPasteBlockStyleCommand, () => SelectedBlockViewModel != null); + ExpandAllBlocksCommand = new RelayCommand(OnExpandAllBlocksCommand); + CollapseAllBlocksCommand = new RelayCommand(OnCollapseAllBlocksCommand); var icon = new BitmapImage(); icon.BeginInit(); @@ -100,7 +122,11 @@ namespace Filtration.ViewModels public RelayCommand AddBlockCommand { get; private set; } public RelayCommand AddSectionCommand { get; private set; } public RelayCommand CopyBlockCommand { get; private set; } + public RelayCommand CopyBlockStyleCommand { get; private set; } public RelayCommand PasteBlockCommand { get; private set; } + public RelayCommand PasteBlockStyleCommand { get; private set; } + public RelayCommand ExpandAllBlocksCommand { get; private set; } + public RelayCommand CollapseAllBlocksCommand { get; private set; } public ObservableCollection ItemFilterBlockViewModels { @@ -444,6 +470,44 @@ namespace Filtration.ViewModels Clipboard.SetText(_blockTranslator.TranslateItemFilterBlockToString(SelectedBlockViewModel.Block)); } + private void OnCopyBlockStyleCommand() + { + CopyBlockStyle(SelectedBlockViewModel); + } + + public void CopyBlockStyle(IItemFilterBlockViewModel targetBlockViewModel) + { + string outputText = string.Empty; + + foreach (var blockItem in targetBlockViewModel.Block.BlockItems.Where(b => b is IAudioVisualBlockItem)) + { + if (outputText != string.Empty) + { + outputText += Environment.NewLine; + } + outputText += blockItem.OutputText; + } + + Clipboard.SetText(outputText); + } + + private void OnPasteBlockStyleCommand() + { + PasteBlockStyle(SelectedBlockViewModel); + } + + public void PasteBlockStyle(IItemFilterBlockViewModel targetBlockViewModel) + { + var clipboardText = Clipboard.GetText(); + if (string.IsNullOrEmpty(clipboardText)) + { + return; + } + + _blockTranslator.ReplaceColorBlockItemsFromString(targetBlockViewModel.Block.BlockItems, clipboardText); + targetBlockViewModel.RefreshBlockPreview(); + } + private void OnPasteBlockCommand() { PasteBlock(SelectedBlockViewModel); @@ -479,7 +543,6 @@ namespace Filtration.ViewModels private void OnMoveBlockToTopCommand() { MoveBlockToTop(SelectedBlockViewModel); - } public void MoveBlockToTop(IItemFilterBlockViewModel targetBlockViewModel) @@ -589,20 +652,36 @@ namespace Filtration.ViewModels { AddSection(SelectedBlockViewModel); } - + public void AddSection(IItemFilterBlockViewModel targetBlockViewModel) { var vm = _itemFilterBlockViewModelFactory.Create(); var newSection = new ItemFilterSection { Description = "New Section" }; vm.Initialise(newSection, this); - Script.ItemFilterBlocks.Insert(Script.ItemFilterBlocks.IndexOf(targetBlockViewModel.Block) + 1, newSection); - ItemFilterBlockViewModels.Insert(ItemFilterBlockViewModels.IndexOf(targetBlockViewModel) + 1, vm); + Script.ItemFilterBlocks.Insert(Script.ItemFilterBlocks.IndexOf(targetBlockViewModel.Block), newSection); + ItemFilterBlockViewModels.Insert(ItemFilterBlockViewModels.IndexOf(targetBlockViewModel), vm); IsDirty = true; SelectedBlockViewModel = vm; RaisePropertyChanged("ItemFilterSectionViewModels"); } + private void OnExpandAllBlocksCommand() + { + foreach (var blockViewModel in ItemFilterBlockViewModels) + { + blockViewModel.IsExpanded = true; + } + } + + private void OnCollapseAllBlocksCommand() + { + foreach (var blockViewModel in ItemFilterBlockViewModels) + { + blockViewModel.IsExpanded = false; + } + } + private void OnDeleteBlockCommand() { DeleteBlock(SelectedBlockViewModel); diff --git a/Filtration/ViewModels/MainWindowViewModel.cs b/Filtration/ViewModels/MainWindowViewModel.cs index c68e14d..8f5992e 100644 --- a/Filtration/ViewModels/MainWindowViewModel.cs +++ b/Filtration/ViewModels/MainWindowViewModel.cs @@ -53,25 +53,39 @@ namespace Filtration.ViewModels _themeService = themeService; NewScriptCommand = new RelayCommand(OnNewScriptCommand); - CopyScriptCommand = new RelayCommand(OnCopyScriptCommand, ActiveDocumentIsScript); + CopyScriptCommand = new RelayCommand(OnCopyScriptCommand, () => ActiveDocumentIsScript); OpenScriptCommand = new RelayCommand(OnOpenScriptCommand); OpenThemeCommand = new RelayCommand(OnOpenThemeCommand); - SaveCommand = new RelayCommand(OnSaveDocumentCommand, ActiveDocumentIsEditable); SaveAsCommand = new RelayCommand(OnSaveAsCommand, ActiveDocumentIsEditable); CloseCommand = new RelayCommand(OnCloseDocumentCommand, () => AvalonDockWorkspaceViewModel.ActiveDocument != null); - CopyBlockCommand = new RelayCommand(OnCopyBlockCommand, () => ActiveDocumentIsScript() && (_avalonDockWorkspaceViewModel.ActiveScriptViewModel.SelectedBlockViewModel != null)); - PasteCommand = new RelayCommand(OnPasteCommand, () => ActiveDocumentIsScript() && (_avalonDockWorkspaceViewModel.ActiveScriptViewModel.SelectedBlockViewModel != null)); + CopyBlockCommand = new RelayCommand(OnCopyBlockCommand, () => ActiveDocumentIsScript && ActiveScriptHasSelectedBlock); + CopyBlockStyleCommand = new RelayCommand(OnCopyBlockStyleCommand, () => ActiveDocumentIsScript && ActiveScriptHasSelectedBlock); + PasteCommand = new RelayCommand(OnPasteCommand, () => ActiveDocumentIsScript && ActiveScriptHasSelectedBlock); + PasteBlockStyleCommand = new RelayCommand(OnPasteBlockStyleCommand, () => ActiveDocumentIsScript && ActiveScriptHasSelectedBlock); + + MoveBlockUpCommand = new RelayCommand(OnMoveBlockUpCommand, () => ActiveDocumentIsScript && ActiveScriptHasSelectedBlock); + MoveBlockDownCommand = new RelayCommand(OnMoveBlockDownCommand, () => ActiveDocumentIsScript && ActiveScriptHasSelectedBlock); + MoveBlockToTopCommand = new RelayCommand(OnMoveBlockToTopCommand, () => ActiveDocumentIsScript && ActiveScriptHasSelectedBlock); + MoveBlockToBottomCommand = new RelayCommand(OnMoveBlockToBottomCommand, () => ActiveDocumentIsScript && ActiveScriptHasSelectedBlock); + + AddBlockCommand = new RelayCommand(OnAddBlockCommand, () => ActiveDocumentIsScript); + AddSectionCommand = new RelayCommand(OnAddSectionCommand, () => ActiveDocumentIsScript); + DeleteBlockCommand = new RelayCommand(OnDeleteBlockCommand, () => ActiveDocumentIsScript && ActiveScriptHasSelectedBlock); OpenAboutWindowCommand = new RelayCommand(OnOpenAboutWindowCommand); OpenSettingsWindowCommand = new RelayCommand(OnOpenSettingsWindowCommand); - ReplaceColorsCommand = new RelayCommand(OnReplaceColorsCommand, ActiveDocumentIsScript); - CreateThemeCommand = new RelayCommand(OnCreateThemeCommand, ActiveDocumentIsScript); - ApplyThemeToScriptCommand = new RelayCommand(OnApplyThemeToScriptCommand, ActiveDocumentIsScript); + ReplaceColorsCommand = new RelayCommand(OnReplaceColorsCommand, () => ActiveDocumentIsScript); + CreateThemeCommand = new RelayCommand(OnCreateThemeCommand, () => ActiveDocumentIsScript); + ApplyThemeToScriptCommand = new RelayCommand(OnApplyThemeToScriptCommand, () => ActiveDocumentIsScript); - //LoadScriptFromFile("C:\\ThioleLootFilter.txt"); + ExpandAllBlocksCommand = new RelayCommand(OnExpandAllBlocksCommand, () => ActiveDocumentIsScript); + CollapseAllBlocksCommand = new RelayCommand(OnCollapseAllBlocksCommand, () => ActiveDocumentIsScript); + + ToggleShowAdvancedCommand = new RelayCommand(OnToggleShowAdvancedCommand, s => ActiveDocumentIsScript); + ClearFiltersCommand = new RelayCommand(OnClearFiltersCommand, () => ActiveDocumentIsScript); if (string.IsNullOrEmpty(_itemFilterScriptRepository.GetItemFilterScriptDirectory())) { @@ -95,6 +109,7 @@ namespace Filtration.ViewModels ReplaceColorsCommand.RaiseCanExecuteChanged(); ApplyThemeToScriptCommand.RaiseCanExecuteChanged(); CreateThemeCommand.RaiseCanExecuteChanged(); + RaisePropertyChanged("ShowAdvancedStatus"); break; } case "NewScript": @@ -116,7 +131,9 @@ namespace Filtration.ViewModels public RelayCommand SaveCommand { get; private set; } public RelayCommand SaveAsCommand { get; private set; } public RelayCommand CopyBlockCommand { get; private set; } + public RelayCommand CopyBlockStyleCommand { get; private set; } public RelayCommand PasteCommand { get; private set; } + public RelayCommand PasteBlockStyleCommand { get; private set; } public RelayCommand CopyScriptCommand { get; private set; } public RelayCommand NewScriptCommand { get; private set; } public RelayCommand CloseCommand { get; private set; } @@ -125,6 +142,21 @@ namespace Filtration.ViewModels public RelayCommand ReplaceColorsCommand { get; private set; } public RelayCommand CreateThemeCommand { get; private set; } public RelayCommand ApplyThemeToScriptCommand { get; private set; } + + public RelayCommand AddBlockCommand { get; private set; } + public RelayCommand AddSectionCommand { get; private set; } + public RelayCommand DeleteBlockCommand { get; private set; } + + public RelayCommand MoveBlockUpCommand { get; private set; } + public RelayCommand MoveBlockDownCommand { get; private set; } + public RelayCommand MoveBlockToTopCommand { get; private set; } + public RelayCommand MoveBlockToBottomCommand { get; private set; } + + public RelayCommand ExpandAllBlocksCommand { get; private set; } + public RelayCommand CollapseAllBlocksCommand { get; private set; } + + public RelayCommand ToggleShowAdvancedCommand { get; private set; } + public RelayCommand ClearFiltersCommand { get; private set; } public IAvalonDockWorkspaceViewModel AvalonDockWorkspaceViewModel { @@ -141,9 +173,25 @@ namespace Filtration.ViewModels } } - private bool ActiveDocumentIsScript() + public bool ActiveDocumentIsScript { - return _activeDocument is IItemFilterScriptViewModel; + get + { + { + var isScript = _activeDocument is ItemFilterScriptViewModel; + return isScript; + } + } + } + + public bool ActiveScriptHasSelectedBlock + { + get { return AvalonDockWorkspaceViewModel.ActiveScriptViewModel.SelectedBlockViewModel != null; } + } + + public bool ActiveDocumentIsTheme + { + get { { return _activeDocument is ThemeViewModel; } } } private bool ActiveDocumentIsEditable() @@ -151,6 +199,14 @@ namespace Filtration.ViewModels return _activeDocument is IEditableDocument; } + public bool ShowAdvancedStatus + { + get + { + return ActiveDocumentIsScript && _avalonDockWorkspaceViewModel.ActiveScriptViewModel.ShowAdvanced; + } + } + private void OnCreateThemeCommand() { var themeViewModel = _themeProvider.NewThemeForScript(AvalonDockWorkspaceViewModel.ActiveScriptViewModel.Script); @@ -321,12 +377,22 @@ namespace Filtration.ViewModels private void OnCopyBlockCommand() { - _avalonDockWorkspaceViewModel.ActiveScriptViewModel.CopyBlock(_avalonDockWorkspaceViewModel.ActiveScriptViewModel.SelectedBlockViewModel); + _avalonDockWorkspaceViewModel.ActiveScriptViewModel.CopyBlockCommand.Execute(null); + } + + private void OnCopyBlockStyleCommand() + { + _avalonDockWorkspaceViewModel.ActiveScriptViewModel.CopyBlockStyleCommand.Execute(null); } private void OnPasteCommand() { - _avalonDockWorkspaceViewModel.ActiveScriptViewModel.PasteBlock(_avalonDockWorkspaceViewModel.ActiveScriptViewModel.SelectedBlockViewModel); + _avalonDockWorkspaceViewModel.ActiveScriptViewModel.PasteBlockCommand.Execute(null); + } + + private void OnPasteBlockStyleCommand() + { + _avalonDockWorkspaceViewModel.ActiveScriptViewModel.PasteBlockStyleCommand.Execute(null); } private void OnNewScriptCommand() @@ -339,5 +405,60 @@ namespace Filtration.ViewModels { _avalonDockWorkspaceViewModel.ActiveDocument.Close(); } + + private void OnMoveBlockUpCommand() + { + _avalonDockWorkspaceViewModel.ActiveScriptViewModel.MoveBlockUpCommand.Execute(null); + } + + private void OnMoveBlockDownCommand() + { + _avalonDockWorkspaceViewModel.ActiveScriptViewModel.MoveBlockDownCommand.Execute(null); + } + + private void OnMoveBlockToTopCommand() + { + _avalonDockWorkspaceViewModel.ActiveScriptViewModel.MoveBlockToTopCommand.Execute(null); + } + + private void OnMoveBlockToBottomCommand() + { + _avalonDockWorkspaceViewModel.ActiveScriptViewModel.MoveBlockToBottomCommand.Execute(null); + } + + private void OnAddBlockCommand() + { + _avalonDockWorkspaceViewModel.ActiveScriptViewModel.AddBlockCommand.Execute(null); + } + + private void OnAddSectionCommand() + { + _avalonDockWorkspaceViewModel.ActiveScriptViewModel.AddSectionCommand.Execute(null); + } + + private void OnDeleteBlockCommand() + { + _avalonDockWorkspaceViewModel.ActiveScriptViewModel.DeleteBlockCommand.Execute(null); + } + + private void OnExpandAllBlocksCommand() + { + _avalonDockWorkspaceViewModel.ActiveScriptViewModel.ExpandAllBlocksCommand.Execute(null); + } + + private void OnCollapseAllBlocksCommand() + { + _avalonDockWorkspaceViewModel.ActiveScriptViewModel.CollapseAllBlocksCommand.Execute(null); + } + + private void OnToggleShowAdvancedCommand(bool showAdvanced) + { + _avalonDockWorkspaceViewModel.ActiveScriptViewModel.ToggleShowAdvancedCommand.Execute(showAdvanced); + } + + private void OnClearFiltersCommand() + { + _avalonDockWorkspaceViewModel.ActiveScriptViewModel.ClearFilterCommand.Execute(null); + } } } diff --git a/Filtration/Views/AboutWindow.xaml b/Filtration/Views/AboutWindow.xaml index d006756..3767236 100644 --- a/Filtration/Views/AboutWindow.xaml +++ b/Filtration/Views/AboutWindow.xaml @@ -1,16 +1,15 @@ - + BorderBrush="Black"> + @@ -71,4 +70,4 @@ - + diff --git a/Filtration/Views/IconsDictionary.xaml b/Filtration/Views/IconsDictionary.xaml index 3e66273..7b16b14 100644 --- a/Filtration/Views/IconsDictionary.xaml +++ b/Filtration/Views/IconsDictionary.xaml @@ -2,11 +2,9 @@ xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"> - - @@ -16,7 +14,7 @@ - + @@ -24,6 +22,10 @@ - + + + + + \ No newline at end of file diff --git a/Filtration/Views/ItemFilterBlockView.xaml b/Filtration/Views/ItemFilterBlockView.xaml index 05debd2..aa2748b 100644 --- a/Filtration/Views/ItemFilterBlockView.xaml +++ b/Filtration/Views/ItemFilterBlockView.xaml @@ -11,6 +11,7 @@ xmlns:blockItemBaseTypes="clr-namespace:Filtration.ObjectModel.BlockItemBaseTypes;assembly=Filtration.ObjectModel" xmlns:blockItemTypes="clr-namespace:Filtration.ObjectModel.BlockItemTypes;assembly=Filtration.ObjectModel" xmlns:enums="clr-namespace:Filtration.ObjectModel.Enums;assembly=Filtration.ObjectModel" + xmlns:componentModel="clr-namespace:System.ComponentModel;assembly=WindowsBase" mc:Ignorable="d" d:DataContext="{d:DesignInstance Type=viewModels:ItemFilterBlockViewModel}" d:DesignHeight="200" d:DesignWidth="800"> @@ -38,13 +39,23 @@ Advanced Block Group - + + + + + @@ -66,7 +77,6 @@ - @@ -94,15 +104,21 @@ - - + - + @@ -148,12 +164,39 @@ - + + + + + + + + + + + diff --git a/Filtration/Views/ItemFilterSectionView.xaml b/Filtration/Views/ItemFilterSectionView.xaml index a6928a8..6ff0543 100644 --- a/Filtration/Views/ItemFilterSectionView.xaml +++ b/Filtration/Views/ItemFilterSectionView.xaml @@ -22,7 +22,13 @@ - + + + + + + + diff --git a/Filtration/Views/MainWindow.xaml b/Filtration/Views/MainWindow.xaml index a582a5a..22df379 100644 --- a/Filtration/Views/MainWindow.xaml +++ b/Filtration/Views/MainWindow.xaml @@ -1,58 +1,83 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - + diff --git a/Filtration/Views/SettingsWindow.xaml b/Filtration/Views/SettingsWindow.xaml index 3a287ca..4832a3f 100644 --- a/Filtration/Views/SettingsWindow.xaml +++ b/Filtration/Views/SettingsWindow.xaml @@ -1,13 +1,13 @@ - + Title="Options" Height="150" Width="500"> + @@ -45,4 +45,4 @@ - + diff --git a/Filtration/Views/SharedResourcesDictionary.xaml b/Filtration/Views/SharedResourcesDictionary.xaml index 6ebc0ee..5287469 100644 --- a/Filtration/Views/SharedResourcesDictionary.xaml +++ b/Filtration/Views/SharedResourcesDictionary.xaml @@ -8,7 +8,7 @@