diff --git a/Filtration/App.xaml b/Filtration/App.xaml index f12e2dd..d5b0159 100644 --- a/Filtration/App.xaml +++ b/Filtration/App.xaml @@ -12,19 +12,6 @@ - - - - - - - - - - - - - diff --git a/Filtration/App.xaml.cs b/Filtration/App.xaml.cs index fcc31ba..ead2fca 100644 --- a/Filtration/App.xaml.cs +++ b/Filtration/App.xaml.cs @@ -1,4 +1,5 @@ -using System.Linq; +using System; +using System.Linq; using System.Windows; using Castle.MicroKernel.ModelBuilder.Inspectors; using Castle.Windsor; @@ -26,6 +27,14 @@ namespace Filtration var mainWindow = _container.Resolve(); mainWindow.Show(); + + //String[] arguments = Environment.GetCommandLineArgs(); + + //if (arguments.GetLength(0) <= 1) return; + //if (!arguments[1].EndsWith(".filter")) return; + + //var filePathFormMainArgs = arguments[1]; + //mainWindow.OpenScriptFromCommandLineArgument(filePathFormMainArgs); } protected override void OnExit(ExitEventArgs e) diff --git a/Filtration/Filtration.csproj b/Filtration/Filtration.csproj index 93d0910..e298fff 100644 --- a/Filtration/Filtration.csproj +++ b/Filtration/Filtration.csproj @@ -41,10 +41,6 @@ ..\packages\Castle.Windsor.3.3.0\lib\net45\Castle.Windsor.dll - - False - ..\packages\FontAwesome.WPF.4.3.0.2\lib\FontAwesome.WPF.dll - False ..\packages\MvvmLightLibs.5.1.1.0\lib\net45\GalaSoft.MvvmLight.dll @@ -254,9 +250,24 @@ - + PreserveNewest + + + + + + + + + + + + + + + Always @@ -265,42 +276,42 @@ - + PreserveNewest - + PreserveNewest - + PreserveNewest - + PreserveNewest - + PreserveNewest - + PreserveNewest - + PreserveNewest - + PreserveNewest diff --git a/Filtration/Properties/Resources.Designer.cs b/Filtration/Properties/Resources.Designer.cs index 63336cf..a5b8c53 100644 --- a/Filtration/Properties/Resources.Designer.cs +++ b/Filtration/Properties/Resources.Designer.cs @@ -60,6 +60,26 @@ namespace Filtration.Properties { } } + /// + /// Looks up a localized resource of type System.Drawing.Bitmap. + /// + internal static System.Drawing.Bitmap add_block_icon { + get { + object obj = ResourceManager.GetObject("add_block_icon", resourceCulture); + return ((System.Drawing.Bitmap)(obj)); + } + } + + /// + /// Looks up a localized resource of type System.Drawing.Bitmap. + /// + internal static System.Drawing.Bitmap add_section_icon { + get { + object obj = ResourceManager.GetObject("add_section_icon", resourceCulture); + return ((System.Drawing.Bitmap)(obj)); + } + } + /// /// Looks up a localized resource of type System.IO.UnmanagedMemoryStream similar to System.IO.MemoryStream. /// @@ -141,6 +161,26 @@ namespace Filtration.Properties { } } + /// + /// Looks up a localized resource of type System.Drawing.Bitmap. + /// + internal static System.Drawing.Bitmap copy_icon { + get { + object obj = ResourceManager.GetObject("copy_icon", resourceCulture); + return ((System.Drawing.Bitmap)(obj)); + } + } + + /// + /// Looks up a localized resource of type System.Drawing.Bitmap. + /// + internal static System.Drawing.Bitmap delete_icon { + get { + object obj = ResourceManager.GetObject("delete_icon", resourceCulture); + return ((System.Drawing.Bitmap)(obj)); + } + } + /// /// Looks up a localized resource of type System.Byte[]. /// @@ -160,5 +200,75 @@ namespace Filtration.Properties { return ((System.Drawing.Bitmap)(obj)); } } + + /// + /// Looks up a localized resource of type System.Drawing.Bitmap. + /// + internal static System.Drawing.Bitmap new_icon { + get { + object obj = ResourceManager.GetObject("new_icon", resourceCulture); + return ((System.Drawing.Bitmap)(obj)); + } + } + + /// + /// Looks up a localized resource of type System.Drawing.Bitmap. + /// + internal static System.Drawing.Bitmap open_icon { + get { + object obj = ResourceManager.GetObject("open_icon", resourceCulture); + return ((System.Drawing.Bitmap)(obj)); + } + } + + /// + /// Looks up a localized resource of type System.Drawing.Bitmap. + /// + internal static System.Drawing.Bitmap paste_icon { + get { + object obj = ResourceManager.GetObject("paste_icon", resourceCulture); + return ((System.Drawing.Bitmap)(obj)); + } + } + + /// + /// Looks up a localized resource of type System.Drawing.Bitmap. + /// + internal static System.Drawing.Bitmap play_icon { + get { + object obj = ResourceManager.GetObject("play_icon", resourceCulture); + return ((System.Drawing.Bitmap)(obj)); + } + } + + /// + /// Looks up a localized resource of type System.Drawing.Bitmap. + /// + internal static System.Drawing.Bitmap save_all_icon { + get { + object obj = ResourceManager.GetObject("save_all_icon", resourceCulture); + return ((System.Drawing.Bitmap)(obj)); + } + } + + /// + /// Looks up a localized resource of type System.Drawing.Bitmap. + /// + internal static System.Drawing.Bitmap save_icon { + get { + object obj = ResourceManager.GetObject("save_icon", resourceCulture); + return ((System.Drawing.Bitmap)(obj)); + } + } + + /// + /// Looks up a localized resource of type System.Drawing.Bitmap. + /// + internal static System.Drawing.Bitmap speaker_icon { + get { + object obj = ResourceManager.GetObject("speaker_icon", resourceCulture); + return ((System.Drawing.Bitmap)(obj)); + } + } } } diff --git a/Filtration/Properties/Resources.resx b/Filtration/Properties/Resources.resx index 9308e95..f36472f 100644 --- a/Filtration/Properties/Resources.resx +++ b/Filtration/Properties/Resources.resx @@ -118,32 +118,44 @@ System.Resources.ResXResourceWriter, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 + + ..\Resources\Icons\add_block_icon.png;System.Drawing.Bitmap, System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a + + + ..\Resources\Icons\add_section_icon.png;System.Drawing.Bitmap, System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a + - ..\Resources\AlertSound1.wav;System.IO.MemoryStream, mscorlib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 + ..\Resources\AlertSounds\AlertSound1.wav;System.IO.MemoryStream, mscorlib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 - ..\Resources\AlertSound2.wav;System.IO.MemoryStream, mscorlib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 + ..\Resources\AlertSounds\AlertSound2.wav;System.IO.MemoryStream, mscorlib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 - ..\Resources\AlertSound3.wav;System.IO.MemoryStream, mscorlib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 + ..\Resources\AlertSounds\AlertSound3.wav;System.IO.MemoryStream, mscorlib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 - ..\Resources\AlertSound4.wav;System.IO.MemoryStream, mscorlib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 + ..\Resources\AlertSounds\AlertSound4.wav;System.IO.MemoryStream, mscorlib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 - ..\Resources\AlertSound5.wav;System.IO.MemoryStream, mscorlib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 + ..\Resources\AlertSounds\AlertSound5.wav;System.IO.MemoryStream, mscorlib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 - ..\Resources\AlertSound6.wav;System.IO.MemoryStream, mscorlib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 + ..\Resources\AlertSounds\AlertSound6.wav;System.IO.MemoryStream, mscorlib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 - ..\Resources\AlertSound7.wav;System.IO.MemoryStream, mscorlib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 + ..\Resources\AlertSounds\AlertSound7.wav;System.IO.MemoryStream, mscorlib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 - ..\Resources\AlertSound8.wav;System.IO.MemoryStream, mscorlib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 + ..\Resources\AlertSounds\AlertSound8.wav;System.IO.MemoryStream, mscorlib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 - ..\Resources\AlertSound9.wav;System.IO.MemoryStream, mscorlib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 + ..\Resources\AlertSounds\AlertSound9.wav;System.IO.MemoryStream, mscorlib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 + + + ..\Resources\Icons\copy_icon.png;System.Drawing.Bitmap, System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a + + + ..\Resources\Icons\delete_icon.png;System.Drawing.Bitmap, System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a ..\Resources\Fontin-SmallCaps.ttf;System.Byte[], mscorlib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 @@ -151,4 +163,25 @@ ..\Resources\groundtile.png;System.Drawing.Bitmap, System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a + + ..\Resources\Icons\new_icon.png;System.Drawing.Bitmap, System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a + + + ..\Resources\Icons\open_icon.png;System.Drawing.Bitmap, System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a + + + ..\Resources\Icons\paste_icon.png;System.Drawing.Bitmap, System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a + + + ..\Resources\Icons\play_icon.png;System.Drawing.Bitmap, System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a + + + ..\Resources\Icons\save_all_icon.png;System.Drawing.Bitmap, System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a + + + ..\Resources\Icons\save_icon.png;System.Drawing.Bitmap, System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a + + + ..\Resources\Icons\speaker_icon.png;System.Drawing.Bitmap, System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a + \ No newline at end of file diff --git a/Filtration/Resources/AlertSound1.wav b/Filtration/Resources/AlertSounds/AlertSound1.wav similarity index 100% rename from Filtration/Resources/AlertSound1.wav rename to Filtration/Resources/AlertSounds/AlertSound1.wav diff --git a/Filtration/Resources/AlertSound2.wav b/Filtration/Resources/AlertSounds/AlertSound2.wav similarity index 100% rename from Filtration/Resources/AlertSound2.wav rename to Filtration/Resources/AlertSounds/AlertSound2.wav diff --git a/Filtration/Resources/AlertSound3.wav b/Filtration/Resources/AlertSounds/AlertSound3.wav similarity index 100% rename from Filtration/Resources/AlertSound3.wav rename to Filtration/Resources/AlertSounds/AlertSound3.wav diff --git a/Filtration/Resources/AlertSound4.wav b/Filtration/Resources/AlertSounds/AlertSound4.wav similarity index 100% rename from Filtration/Resources/AlertSound4.wav rename to Filtration/Resources/AlertSounds/AlertSound4.wav diff --git a/Filtration/Resources/AlertSound5.wav b/Filtration/Resources/AlertSounds/AlertSound5.wav similarity index 100% rename from Filtration/Resources/AlertSound5.wav rename to Filtration/Resources/AlertSounds/AlertSound5.wav diff --git a/Filtration/Resources/AlertSound6.wav b/Filtration/Resources/AlertSounds/AlertSound6.wav similarity index 100% rename from Filtration/Resources/AlertSound6.wav rename to Filtration/Resources/AlertSounds/AlertSound6.wav diff --git a/Filtration/Resources/AlertSound7.wav b/Filtration/Resources/AlertSounds/AlertSound7.wav similarity index 100% rename from Filtration/Resources/AlertSound7.wav rename to Filtration/Resources/AlertSounds/AlertSound7.wav diff --git a/Filtration/Resources/AlertSound8.wav b/Filtration/Resources/AlertSounds/AlertSound8.wav similarity index 100% rename from Filtration/Resources/AlertSound8.wav rename to Filtration/Resources/AlertSounds/AlertSound8.wav diff --git a/Filtration/Resources/AlertSound9.wav b/Filtration/Resources/AlertSounds/AlertSound9.wav similarity index 100% rename from Filtration/Resources/AlertSound9.wav rename to Filtration/Resources/AlertSounds/AlertSound9.wav diff --git a/Filtration/Resources/Icons/add_block_icon.png b/Filtration/Resources/Icons/add_block_icon.png new file mode 100644 index 0000000..1e6fdd8 Binary files /dev/null and b/Filtration/Resources/Icons/add_block_icon.png differ diff --git a/Filtration/Resources/Icons/add_section_icon.png b/Filtration/Resources/Icons/add_section_icon.png new file mode 100644 index 0000000..32a34f4 Binary files /dev/null and b/Filtration/Resources/Icons/add_section_icon.png differ diff --git a/Filtration/Resources/Icons/arrow_down_large_icon.png b/Filtration/Resources/Icons/arrow_down_large_icon.png new file mode 100644 index 0000000..efdaccd Binary files /dev/null and b/Filtration/Resources/Icons/arrow_down_large_icon.png differ diff --git a/Filtration/Resources/Icons/arrow_down_small_icon.png b/Filtration/Resources/Icons/arrow_down_small_icon.png new file mode 100644 index 0000000..1f221a1 Binary files /dev/null and b/Filtration/Resources/Icons/arrow_down_small_icon.png differ diff --git a/Filtration/Resources/Icons/arrow_up_large_icon.png b/Filtration/Resources/Icons/arrow_up_large_icon.png new file mode 100644 index 0000000..09b45f7 Binary files /dev/null and b/Filtration/Resources/Icons/arrow_up_large_icon.png differ diff --git a/Filtration/Resources/Icons/arrow_up_small_icon.png b/Filtration/Resources/Icons/arrow_up_small_icon.png new file mode 100644 index 0000000..7394bf0 Binary files /dev/null and b/Filtration/Resources/Icons/arrow_up_small_icon.png differ diff --git a/Filtration/Resources/Icons/copy_icon.png b/Filtration/Resources/Icons/copy_icon.png new file mode 100644 index 0000000..8ff40a0 Binary files /dev/null and b/Filtration/Resources/Icons/copy_icon.png differ diff --git a/Filtration/Resources/Icons/delete_icon.png b/Filtration/Resources/Icons/delete_icon.png new file mode 100644 index 0000000..4b6d6d4 Binary files /dev/null and b/Filtration/Resources/Icons/delete_icon.png differ diff --git a/Filtration/Resources/Icons/new_icon.png b/Filtration/Resources/Icons/new_icon.png new file mode 100644 index 0000000..12354ce Binary files /dev/null and b/Filtration/Resources/Icons/new_icon.png differ diff --git a/Filtration/Resources/Icons/open_icon.png b/Filtration/Resources/Icons/open_icon.png new file mode 100644 index 0000000..b9e1d55 Binary files /dev/null and b/Filtration/Resources/Icons/open_icon.png differ diff --git a/Filtration/Resources/Icons/paste_icon.png b/Filtration/Resources/Icons/paste_icon.png new file mode 100644 index 0000000..36915a5 Binary files /dev/null and b/Filtration/Resources/Icons/paste_icon.png differ diff --git a/Filtration/Resources/Icons/play_icon.png b/Filtration/Resources/Icons/play_icon.png new file mode 100644 index 0000000..72acefc Binary files /dev/null and b/Filtration/Resources/Icons/play_icon.png differ diff --git a/Filtration/Resources/Icons/save_all_icon.png b/Filtration/Resources/Icons/save_all_icon.png new file mode 100644 index 0000000..e429cd4 Binary files /dev/null and b/Filtration/Resources/Icons/save_all_icon.png differ diff --git a/Filtration/Resources/Icons/save_icon.png b/Filtration/Resources/Icons/save_icon.png new file mode 100644 index 0000000..f581e64 Binary files /dev/null and b/Filtration/Resources/Icons/save_icon.png differ diff --git a/Filtration/Resources/Icons/speaker_icon.png b/Filtration/Resources/Icons/speaker_icon.png new file mode 100644 index 0000000..b8c7c02 Binary files /dev/null and b/Filtration/Resources/Icons/speaker_icon.png differ diff --git a/Filtration/ViewModels/LootFilterBlockViewModel.cs b/Filtration/ViewModels/LootFilterBlockViewModel.cs index 260ef1b..f5c2fd1 100644 --- a/Filtration/ViewModels/LootFilterBlockViewModel.cs +++ b/Filtration/ViewModels/LootFilterBlockViewModel.cs @@ -33,7 +33,8 @@ namespace Filtration.ViewModels { _translator = translator; _staticDataService = staticDataService; - CopyBlockCommand = new RelayCommand(OnCopyConditionCommand); + CopyBlockCommand = new RelayCommand(OnCopyBlockCommand); + PasteBlockCommand = new RelayCommand(OnPasteBlockCommand); AddBlockCommand = new RelayCommand(OnAddBlockCommand); AddSectionCommand = new RelayCommand(OnAddSectionCommand); DeleteBlockCommand = new RelayCommand(OnDeleteBlockCommand); @@ -65,6 +66,7 @@ namespace Filtration.ViewModels } public RelayCommand CopyBlockCommand { get; private set; } + public RelayCommand PasteBlockCommand { get; private set; } public RelayCommand AddBlockCommand { get; private set; } public RelayCommand AddSectionCommand { get; private set; } public RelayCommand DeleteBlockCommand { get; private set; } @@ -237,11 +239,6 @@ namespace Filtration.ViewModels get { return FilterBlockItems.Count(b => b is SoundBlockItem) > 0; } } - private void OnCopyConditionCommand() - { - Clipboard.SetText(_translator.TranslateLootFilterBlockToString(Block)); - } - private void OnAddFilterBlockItemCommand(Type blockItemType) { if (!AddBlockItemAllowed(blockItemType)) return; @@ -276,6 +273,17 @@ namespace Filtration.ViewModels IsDirty = true; } + private void OnCopyBlockCommand() + { + _parentScriptViewModel.CopyBlock(this); + } + + private void OnPasteBlockCommand() + { + _parentScriptViewModel.PasteBlock(this); + } + + private void OnAddBlockCommand() { _parentScriptViewModel.AddBlock(this); @@ -310,7 +318,7 @@ namespace Filtration.ViewModels private void OnPlaySoundCommand() { - var soundUri = "Resources/AlertSound" + FilterBlockItems.OfType().First().Value + ".wav"; + var soundUri = "Resources/AlertSounds/AlertSound" + FilterBlockItems.OfType().First().Value + ".wav"; _mediaPlayer.Open(new Uri(soundUri, UriKind.Relative)); _mediaPlayer.Play(); } diff --git a/Filtration/ViewModels/LootFilterScriptViewModel.cs b/Filtration/ViewModels/LootFilterScriptViewModel.cs index c5a258b..e08f59b 100644 --- a/Filtration/ViewModels/LootFilterScriptViewModel.cs +++ b/Filtration/ViewModels/LootFilterScriptViewModel.cs @@ -3,7 +3,9 @@ using System.Collections.ObjectModel; using System.IO; using System.Linq; using System.Windows; +using Castle.Core.Internal; using Filtration.Models; +using Filtration.Translators; using GalaSoft.MvvmLight.CommandWpf; namespace Filtration.ViewModels @@ -14,28 +16,34 @@ namespace Filtration.ViewModels bool IsDirty { get; } string Description { get; set; } void Initialise(LootFilterScript lootFilterScript); + ILootFilterBlockViewModel SelectedBlockViewModel { get; set; } void RemoveDirtyFlag(); - void AddSection(ILootFilterBlockViewModel blockViewModel); - void AddBlock(ILootFilterBlockViewModel blockViewModel); + void AddSection(ILootFilterBlockViewModel targetBlockViewModel); + void AddBlock(ILootFilterBlockViewModel targetBlockViewModel); + void CopyBlock(ILootFilterBlockViewModel targetBlockViewModel); + void PasteBlock(ILootFilterBlockViewModel targetBlockViewModel); } internal class LootFilterScriptViewModel : FiltrationViewModelBase, ILootFilterScriptViewModel { private readonly ILootFilterBlockViewModelFactory _lootFilterBlockViewModelFactory; + private readonly ILootFilterBlockTranslator _blockTranslator; private bool _isDirty; private ILootFilterBlockViewModel _selectedBlockViewModel; - public LootFilterScriptViewModel(ILootFilterBlockViewModelFactory lootFilterBlockViewModelFactory ) + public LootFilterScriptViewModel(ILootFilterBlockViewModelFactory lootFilterBlockViewModelFactory, ILootFilterBlockTranslator blockTranslator) { DeleteBlockCommand = new RelayCommand(OnDeleteBlockCommand, () => SelectedBlockViewModel != null); MoveBlockToTopCommand = new RelayCommand(OnMoveBlockToTopCommand, () => SelectedBlockViewModel != null); MoveBlockUpCommand = new RelayCommand(OnMoveBlockUpCommand, () => SelectedBlockViewModel != null); MoveBlockDownCommand = new RelayCommand(OnMoveBlockDownCommand, () => SelectedBlockViewModel != null); MoveBlockToBottomCommand = new RelayCommand(OnMoveBlockToBottomCommand, () => SelectedBlockViewModel != null); - AddBlockCommand = new RelayCommand(OnAddBlockCommand, () => SelectedBlockViewModel != null); + AddBlockCommand = new RelayCommand(OnAddBlockCommand); AddSectionCommand = new RelayCommand(OnAddSectionCommand, () => SelectedBlockViewModel != null); - + CopyBlockCommand = new RelayCommand(OnCopyBlockCommand, () => SelectedBlockViewModel != null); + PasteBlockCommand = new RelayCommand(OnPasteBlockCommand); _lootFilterBlockViewModelFactory = lootFilterBlockViewModelFactory; + _blockTranslator = blockTranslator; LootFilterBlockViewModels = new ObservableCollection(); } @@ -47,6 +55,8 @@ namespace Filtration.ViewModels public RelayCommand MoveBlockToBottomCommand { get; private set; } public RelayCommand AddBlockCommand { get; private set; } public RelayCommand AddSectionCommand { get; private set; } + public RelayCommand CopyBlockCommand { get; private set; } + public RelayCommand PasteBlockCommand { get; private set; } public ObservableCollection LootFilterBlockViewModels { get; private set; } @@ -133,6 +143,48 @@ namespace Filtration.ViewModels } } + private void OnCopyBlockCommand() + { + CopyBlock(SelectedBlockViewModel); + } + + public void CopyBlock(ILootFilterBlockViewModel targetBlockViewModel) + { + Clipboard.SetText(_blockTranslator.TranslateLootFilterBlockToString(SelectedBlockViewModel.Block)); + } + + private void OnPasteBlockCommand() + { + PasteBlock(SelectedBlockViewModel); + } + + public void PasteBlock(ILootFilterBlockViewModel targetBlockViewModel) + { + var clipboardText = Clipboard.GetText(); + if (clipboardText.IsNullOrEmpty()) return; + + var translatedBlock = _blockTranslator.TranslateStringToLootFilterBlock(clipboardText); + if (translatedBlock == null) return; + + var vm = _lootFilterBlockViewModelFactory.Create(); + vm.Initialise(translatedBlock, this); + + if (LootFilterBlockViewModels.Count > 0) + { + Script.LootFilterBlocks.Insert(Script.LootFilterBlocks.IndexOf(targetBlockViewModel.Block) + 1, translatedBlock); + LootFilterBlockViewModels.Insert(LootFilterBlockViewModels.IndexOf(targetBlockViewModel) + 1, vm); + } + else + { + Script.LootFilterBlocks.Add(translatedBlock); + LootFilterBlockViewModels.Add(vm); + } + + SelectedBlockViewModel = vm; + _isDirty = true; + + } + private void OnMoveBlockToTopCommand() { var currentIndex = LootFilterBlockViewModels.IndexOf(SelectedBlockViewModel); @@ -153,13 +205,13 @@ namespace Filtration.ViewModels MoveBlockUp(SelectedBlockViewModel); } - public void MoveBlockUp(ILootFilterBlockViewModel blockViewModel) + public void MoveBlockUp(ILootFilterBlockViewModel targetBlockViewModel) { - var currentIndex = LootFilterBlockViewModels.IndexOf(blockViewModel); + var currentIndex = LootFilterBlockViewModels.IndexOf(targetBlockViewModel); if (currentIndex > 0) { - var block = blockViewModel.Block; + var block = targetBlockViewModel.Block; var blockPos = Script.LootFilterBlocks.IndexOf(block); Script.LootFilterBlocks.RemoveAt(blockPos); Script.LootFilterBlocks.Insert(blockPos - 1, block); @@ -174,13 +226,13 @@ namespace Filtration.ViewModels MoveBlockDown(SelectedBlockViewModel); } - public void MoveBlockDown(ILootFilterBlockViewModel blockViewModel) + public void MoveBlockDown(ILootFilterBlockViewModel targetBlockViewModel) { - var currentIndex = LootFilterBlockViewModels.IndexOf(blockViewModel); + var currentIndex = LootFilterBlockViewModels.IndexOf(targetBlockViewModel); if (currentIndex < LootFilterBlockViewModels.Count - 1) { - var block = blockViewModel.Block; + var block = targetBlockViewModel.Block; var blockPos = Script.LootFilterBlocks.IndexOf(block); Script.LootFilterBlocks.RemoveAt(blockPos); Script.LootFilterBlocks.Insert(blockPos + 1, block); @@ -210,7 +262,7 @@ namespace Filtration.ViewModels AddBlock(SelectedBlockViewModel); } - public void AddBlock(ILootFilterBlockViewModel blockViewModel) + public void AddBlock(ILootFilterBlockViewModel targetBlockViewModel) { var vm = _lootFilterBlockViewModelFactory.Create(); var newBlock = new LootFilterBlock(); @@ -218,8 +270,8 @@ namespace Filtration.ViewModels if (LootFilterBlockViewModels.Count > 0) { - Script.LootFilterBlocks.Insert(Script.LootFilterBlocks.IndexOf(blockViewModel.Block) + 1, newBlock); - LootFilterBlockViewModels.Insert(LootFilterBlockViewModels.IndexOf(blockViewModel) + 1, vm); + Script.LootFilterBlocks.Insert(Script.LootFilterBlocks.IndexOf(targetBlockViewModel.Block) + 1, newBlock); + LootFilterBlockViewModels.Insert(LootFilterBlockViewModels.IndexOf(targetBlockViewModel) + 1, vm); } else { @@ -236,14 +288,14 @@ namespace Filtration.ViewModels AddSection(SelectedBlockViewModel); } - public void AddSection(ILootFilterBlockViewModel blockViewModel) + public void AddSection(ILootFilterBlockViewModel targetBlockViewModel) { var vm = _lootFilterBlockViewModelFactory.Create(); var newSection = new LootFilterSection { Description = "New Section" }; vm.Initialise(newSection, this); - Script.LootFilterBlocks.Insert(Script.LootFilterBlocks.IndexOf(blockViewModel.Block) + 1, newSection); - LootFilterBlockViewModels.Insert(LootFilterBlockViewModels.IndexOf(blockViewModel) + 1, vm); + Script.LootFilterBlocks.Insert(Script.LootFilterBlocks.IndexOf(targetBlockViewModel.Block) + 1, newSection); + LootFilterBlockViewModels.Insert(LootFilterBlockViewModels.IndexOf(targetBlockViewModel) + 1, vm); _isDirty = true; SelectedBlockViewModel = vm; RaisePropertyChanged("LootFilterSectionViewModels"); @@ -254,15 +306,15 @@ namespace Filtration.ViewModels DeleteBlock(SelectedBlockViewModel); } - public void DeleteBlock(ILootFilterBlockViewModel blockViewModel) + public void DeleteBlock(ILootFilterBlockViewModel targetBlockViewModel) { var result = MessageBox.Show("Are you sure you wish to delete this block?", "Delete Confirmation", MessageBoxButton.YesNo, MessageBoxImage.Question); if (result == MessageBoxResult.Yes) { - Script.LootFilterBlocks.Remove(blockViewModel.Block); - LootFilterBlockViewModels.Remove(blockViewModel); + Script.LootFilterBlocks.Remove(targetBlockViewModel.Block); + LootFilterBlockViewModels.Remove(targetBlockViewModel); _isDirty = true; } SelectedBlockViewModel = null; diff --git a/Filtration/ViewModels/MainWindowViewModel.cs b/Filtration/ViewModels/MainWindowViewModel.cs index 6c6edaf..0ab2008 100644 --- a/Filtration/ViewModels/MainWindowViewModel.cs +++ b/Filtration/ViewModels/MainWindowViewModel.cs @@ -13,6 +13,7 @@ namespace Filtration.ViewModels { internal interface IMainWindowViewModel { + void LoadScriptFromFile(string path); } internal class MainWindowViewModel : FiltrationViewModelBase, IMainWindowViewModel @@ -38,6 +39,8 @@ namespace Filtration.ViewModels SaveScriptCommand = new RelayCommand(OnSaveScriptCommand, () => CurrentScriptViewModel != null); SaveScriptAsCommand = new RelayCommand(OnSaveScriptAsCommand, () => CurrentScriptViewModel != null); CopyScriptCommand = new RelayCommand(OnCopyScriptCommand, () => CurrentScriptViewModel != null); + CopyBlockCommand = new RelayCommand(OnCopyBlockCommand, () => CurrentScriptViewModel != null && CurrentScriptViewModel.SelectedBlockViewModel != null); + PasteCommand = new RelayCommand(OnPasteCommand, () => CurrentScriptViewModel != null); NewScriptCommand = new RelayCommand(OnNewScriptCommand); CloseScriptCommand = new RelayCommand(OnCloseScriptCommand, v => CurrentScriptViewModel != null); @@ -49,6 +52,8 @@ namespace Filtration.ViewModels public RelayCommand OpenScriptCommand { get; private set; } public RelayCommand SaveScriptCommand { get; private set; } public RelayCommand SaveScriptAsCommand { get; private set; } + public RelayCommand CopyBlockCommand { get; private set; } + public RelayCommand PasteCommand { get; private set; } public RelayCommand CopyScriptCommand { get; private set; } public RelayCommand NewScriptCommand { get; private set; } public RelayCommand CloseScriptCommand { get; private set; } @@ -84,7 +89,7 @@ namespace Filtration.ViewModels LoadScriptFromFile(openFileDialog.FileName); } - private void LoadScriptFromFile(string path) + public void LoadScriptFromFile(string path) { try { @@ -200,7 +205,17 @@ namespace Filtration.ViewModels private void OnCopyScriptCommand() { - Clipboard.SetText(_lootFilterScriptTranslator.TranslateLootFilterScriptToString(_loadedScript)); + Clipboard.SetText(_lootFilterScriptTranslator.TranslateLootFilterScriptToString(_currentScriptViewModel.Script)); + } + + private void OnCopyBlockCommand() + { + _currentScriptViewModel.CopyBlock(_currentScriptViewModel.SelectedBlockViewModel); + } + + private void OnPasteCommand() + { + _currentScriptViewModel.PasteBlock(_currentScriptViewModel.SelectedBlockViewModel); } private void OnNewScriptCommand() diff --git a/Filtration/Views/LootFilterBlockDisplaySettingsView.xaml b/Filtration/Views/LootFilterBlockDisplaySettingsView.xaml index d48be38..6a29ab0 100644 --- a/Filtration/Views/LootFilterBlockDisplaySettingsView.xaml +++ b/Filtration/Views/LootFilterBlockDisplaySettingsView.xaml @@ -4,7 +4,6 @@ xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006" xmlns:d="http://schemas.microsoft.com/expression/blend/2008" xmlns:xctk="http://schemas.xceed.com/wpf/xaml/toolkit" - xmlns:fa="http://schemas.fontawesome.io/icons/" xmlns:userControls="clr-namespace:Filtration.UserControls" xmlns:viewModels="clr-namespace:Filtration.ViewModels" xmlns:blockItemBaseTypes="clr-namespace:Filtration.Models.BlockItemBaseTypes" @@ -93,7 +92,7 @@ diff --git a/Filtration/Views/LootFilterBlockView.xaml b/Filtration/Views/LootFilterBlockView.xaml index 14f980c..1b60f66 100644 --- a/Filtration/Views/LootFilterBlockView.xaml +++ b/Filtration/Views/LootFilterBlockView.xaml @@ -8,7 +8,6 @@ xmlns:views="clr-namespace:Filtration.Views" xmlns:blockItemBaseTypes="clr-namespace:Filtration.Models.BlockItemBaseTypes" xmlns:blockItemTypes="clr-namespace:Filtration.Models.BlockItemTypes" - xmlns:fa="http://schemas.fontawesome.io/icons/" xmlns:enums="clr-namespace:Filtration.Enums" xmlns:extensions="clr-namespace:Filtration.Extensions" mc:Ignorable="d" @@ -39,29 +38,18 @@ - - - - - - - - - - - - - + + - - + + - + - - + + @@ -92,7 +80,7 @@ - + - + -