diff --git a/Filtration.ObjectModel/Commands/ItemFilterScript/AddCommentBlockCommand.cs b/Filtration.ObjectModel/Commands/ItemFilterScript/AddCommentBlockCommand.cs index 1c627df..1d951a6 100644 --- a/Filtration.ObjectModel/Commands/ItemFilterScript/AddCommentBlockCommand.cs +++ b/Filtration.ObjectModel/Commands/ItemFilterScript/AddCommentBlockCommand.cs @@ -15,7 +15,10 @@ namespace Filtration.ObjectModel.Commands.ItemFilterScript } public void Execute() { - _newItemFilterBlock = new ItemFilterCommentBlock(_itemFilterScript); + _newItemFilterBlock = new ItemFilterCommentBlock(_itemFilterScript) + { + Comment = string.Empty + }; if (_addAfterItemFilterBlock != null) { _itemFilterScript.ItemFilterBlocks.Insert(_itemFilterScript.ItemFilterBlocks.IndexOf(_addAfterItemFilterBlock) + 1, _newItemFilterBlock); diff --git a/Filtration/ViewModels/ItemFilterBlockViewModel.cs b/Filtration/ViewModels/ItemFilterBlockViewModel.cs index 936d738..5cf0c0c 100644 --- a/Filtration/ViewModels/ItemFilterBlockViewModel.cs +++ b/Filtration/ViewModels/ItemFilterBlockViewModel.cs @@ -28,7 +28,6 @@ namespace Filtration.ViewModels private readonly IStaticDataService _staticDataService; private readonly IReplaceColorsViewModel _replaceColorsViewModel; private readonly MediaPlayer _mediaPlayer = new MediaPlayer(); - private IItemFilterScriptViewModel _parentScriptViewModel; private bool _displaySettingsPopupOpen; private bool _isExpanded; @@ -39,17 +38,8 @@ namespace Filtration.ViewModels _staticDataService = staticDataService; _replaceColorsViewModel = replaceColorsViewModel; - 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); - MoveBlockUpCommand = new RelayCommand(OnMoveBlockUpCommand); - MoveBlockDownCommand = new RelayCommand(OnMoveBlockDownCommand); - MoveBlockToTopCommand = new RelayCommand(OnMoveBlockToTopCommand); - MoveBlockToBottomCommand = new RelayCommand(OnMoveBlockToBottomCommand); ReplaceColorsCommand = new RelayCommand(OnReplaceColorsCommand); AddFilterBlockItemCommand = new RelayCommand(OnAddFilterBlockItemCommand); ToggleBlockActionCommand = new RelayCommand(OnToggleBlockActionCommand); @@ -82,17 +72,8 @@ namespace Filtration.ViewModels base.Initialise(itemFilterBlock, parentScriptViewModel); } - public RelayCommand CopyBlockCommand { get; } - public RelayCommand PasteBlockCommand { get; } public RelayCommand CopyBlockStyleCommand { get; } public RelayCommand PasteBlockStyleCommand { get; } - public RelayCommand AddBlockCommand { get; } - public RelayCommand AddSectionCommand { get; } - public RelayCommand DeleteBlockCommand { get; } - public RelayCommand MoveBlockUpCommand { get; } - public RelayCommand MoveBlockDownCommand { get; } - public RelayCommand MoveBlockToTopCommand { get; } - public RelayCommand MoveBlockToBottomCommand { get; } public RelayCommand ToggleBlockActionCommand { get; } public RelayCommand ReplaceColorsCommand { get; } public RelayCommand AddFilterBlockItemCommand { get; } @@ -231,7 +212,7 @@ namespace Filtration.ViewModels public bool HasSound => Block.HasBlockItemOfType(); public bool HasPositionalSound => Block.HasBlockItemOfType(); - + public bool HasAudioVisualBlockItems => AudioVisualBlockItems.Any(); private void OnSwitchBlockItemsViewCommand() @@ -338,63 +319,63 @@ namespace Filtration.ViewModels return blockCount < blockItem.MaximumAllowed; } - private string ComputeFilePartFromNumber(string identifier) - { - if (Int32.TryParse(identifier, out int x)) - { - if (x <= 9) - { - return "AlertSound_0" + x + ".wav"; - } - else - { - return "AlertSound_" + x + ".wav"; - } - } - - return ""; + private string ComputeFilePartFromNumber(string identifier) + { + if (Int32.TryParse(identifier, out int x)) + { + if (x <= 9) + { + return "AlertSound_0" + x + ".wav"; + } + else + { + return "AlertSound_" + x + ".wav"; + } + } + + return ""; } - private string ComputeFilePartFromID(string identifier) - { - string filePart; - switch (identifier) { - case "ShGeneral": - filePart = "SH22General.wav"; - break; - case "ShBlessed": - filePart = "SH22Blessed.wav"; - break; - case "SH22Chaos": - filePart = "SH22Chaos.wav"; - break; - case "ShDivine": - filePart = "SH22Divine.wav"; - break; - case "ShExalted": - filePart = "SH22Exalted.wav"; - break; - case "ShMirror": - filePart = "SH22Mirror.wav"; - break; - case "ShAlchemy": - filePart = "SH22Alchemy.wav"; - break; - case "ShFusing": - filePart = "SH22Fusing.wav"; - break; - case "ShRegal": - filePart = "SH22Regal.wav"; - break; - case "ShVaal": - filePart = "SH22Vaal.wav"; - break; - default: - filePart = ComputeFilePartFromNumber(identifier); - break; - } - - return filePart; + private string ComputeFilePartFromID(string identifier) + { + string filePart; + switch (identifier) { + case "ShGeneral": + filePart = "SH22General.wav"; + break; + case "ShBlessed": + filePart = "SH22Blessed.wav"; + break; + case "ShChaos": + filePart = "SH22Chaos.wav"; + break; + case "ShDivine": + filePart = "SH22Divine.wav"; + break; + case "ShExalted": + filePart = "SH22Exalted.wav"; + break; + case "ShMirror": + filePart = "SH22Mirror.wav"; + break; + case "ShAlchemy": + filePart = "SH22Alchemy.wav"; + break; + case "ShFusing": + filePart = "SH22Fusing.wav"; + break; + case "ShRegal": + filePart = "SH22Regal.wav"; + break; + case "ShVaal": + filePart = "SH22Vaal.wav"; + break; + default: + filePart = ComputeFilePartFromNumber(identifier); + break; + } + + return filePart; } private void OnPlaySoundCommand() @@ -403,32 +384,32 @@ namespace Filtration.ViewModels var prefix = "Resources/AlertSounds/"; var filePart = ComputeFilePartFromID(identifier); - if (filePart == "") - { - return; + if (filePart == "") + { + return; } - else - { - _mediaPlayer.Open(new Uri(prefix + filePart, UriKind.Relative)); - _mediaPlayer.Play(); + else + { + _mediaPlayer.Open(new Uri(prefix + filePart, UriKind.Relative)); + _mediaPlayer.Play(); } } - private void OnPlayPositionalSoundCommand() - { - var identifier = BlockItems.OfType().First().Value; - var prefix = "Resources/AlertSounds/"; - var filePart = ComputeFilePartFromID(identifier); - - if (filePart == "") - { - return; - } - else - { - _mediaPlayer.Open(new Uri(prefix + filePart, UriKind.Relative)); - _mediaPlayer.Play(); - } + private void OnPlayPositionalSoundCommand() + { + var identifier = BlockItems.OfType().First().Value; + var prefix = "Resources/AlertSounds/"; + var filePart = ComputeFilePartFromID(identifier); + + if (filePart == "") + { + return; + } + else + { + _mediaPlayer.Open(new Uri(prefix + filePart, UriKind.Relative)); + _mediaPlayer.Play(); + } } private void OnBlockItemChanged(object sender, EventArgs e) diff --git a/Filtration/ViewModels/ItemFilterBlockViewModelBase.cs b/Filtration/ViewModels/ItemFilterBlockViewModelBase.cs index 347da48..86dcfcb 100644 --- a/Filtration/ViewModels/ItemFilterBlockViewModelBase.cs +++ b/Filtration/ViewModels/ItemFilterBlockViewModelBase.cs @@ -1,6 +1,7 @@ using System; using Filtration.ObjectModel; using GalaSoft.MvvmLight; +using GalaSoft.MvvmLight.CommandWpf; namespace Filtration.ViewModels { @@ -16,14 +17,40 @@ namespace Filtration.ViewModels { private bool _isDirty; + public ItemFilterBlockViewModelBase() + { + CopyBlockCommand = new RelayCommand(OnCopyBlockCommand); + PasteBlockCommand = new RelayCommand(OnPasteBlockCommand); + AddBlockCommand = new RelayCommand(OnAddBlockCommand); + AddSectionCommand = new RelayCommand(OnAddSectionCommand); + DeleteBlockCommand = new RelayCommand(OnDeleteBlockCommand); + MoveBlockUpCommand = new RelayCommand(OnMoveBlockUpCommand); + MoveBlockDownCommand = new RelayCommand(OnMoveBlockDownCommand); + MoveBlockToTopCommand = new RelayCommand(OnMoveBlockToTopCommand); + MoveBlockToBottomCommand = new RelayCommand(OnMoveBlockToBottomCommand); + } + + public virtual void Initialise(IItemFilterBlockBase itemfilterBlock, IItemFilterScriptViewModel itemFilterScriptViewModel) { BaseBlock = itemfilterBlock; + _parentScriptViewModel = itemFilterScriptViewModel; } public event EventHandler BlockBecameDirty; public IItemFilterBlockBase BaseBlock { get; protected set; } + public IItemFilterScriptViewModel _parentScriptViewModel; + + public RelayCommand CopyBlockCommand { get; } + public RelayCommand PasteBlockCommand { get; } + public RelayCommand AddBlockCommand { get; } + public RelayCommand AddSectionCommand { get; } + public RelayCommand DeleteBlockCommand { get; } + public RelayCommand MoveBlockUpCommand { get; } + public RelayCommand MoveBlockDownCommand { get; } + public RelayCommand MoveBlockToTopCommand { get; } + public RelayCommand MoveBlockToBottomCommand { get; } public bool IsDirty { @@ -38,5 +65,50 @@ namespace Filtration.ViewModels } } } + + private void OnCopyBlockCommand() + { + _parentScriptViewModel.CopyBlock(this); + } + + private void OnPasteBlockCommand() + { + _parentScriptViewModel.PasteBlock(this); + } + + private void OnAddBlockCommand() + { + _parentScriptViewModel.AddBlock(this); + } + + private void OnAddSectionCommand() + { + _parentScriptViewModel.AddCommentBlock(this); + } + + private void OnDeleteBlockCommand() + { + _parentScriptViewModel.DeleteBlock(this); + } + + private void OnMoveBlockUpCommand() + { + _parentScriptViewModel.MoveBlockUp(this); + } + + private void OnMoveBlockDownCommand() + { + _parentScriptViewModel.MoveBlockDown(this); + } + + private void OnMoveBlockToTopCommand() + { + _parentScriptViewModel.MoveBlockToTop(this); + } + + private void OnMoveBlockToBottomCommand() + { + _parentScriptViewModel.MoveBlockToBottom(this); + } } } \ No newline at end of file diff --git a/Filtration/ViewModels/ItemFilterCommentBlockViewModel.cs b/Filtration/ViewModels/ItemFilterCommentBlockViewModel.cs index 84b292c..08f5f23 100644 --- a/Filtration/ViewModels/ItemFilterCommentBlockViewModel.cs +++ b/Filtration/ViewModels/ItemFilterCommentBlockViewModel.cs @@ -10,12 +10,9 @@ namespace Filtration.ViewModels internal class ItemFilterCommentBlockViewModel : ItemFilterBlockViewModelBase, IItemFilterCommentBlockViewModel { - public ItemFilterCommentBlockViewModel() - { - } - public override void Initialise(IItemFilterBlockBase itemfilterBlock, IItemFilterScriptViewModel itemFilterScriptViewModel) { + _parentScriptViewModel = itemFilterScriptViewModel; ItemFilterCommentBlock = itemfilterBlock as IItemFilterCommentBlock; BaseBlock = ItemFilterCommentBlock; @@ -24,6 +21,21 @@ namespace Filtration.ViewModels public IItemFilterCommentBlock ItemFilterCommentBlock { get; private set; } - public string Comment => ItemFilterCommentBlock.Comment; + public string Comment + { + get + { + return ItemFilterCommentBlock.Comment; + } + set + { + if (ItemFilterCommentBlock.Comment != value) + { + ItemFilterCommentBlock.Comment = value; + IsDirty = true; + RaisePropertyChanged(); + } + } + } } } \ No newline at end of file diff --git a/Filtration/Views/ItemFilterCommentBlockView.xaml b/Filtration/Views/ItemFilterCommentBlockView.xaml index 6531030..8846a50 100644 --- a/Filtration/Views/ItemFilterCommentBlockView.xaml +++ b/Filtration/Views/ItemFilterCommentBlockView.xaml @@ -4,16 +4,47 @@ xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006" xmlns:d="http://schemas.microsoft.com/expression/blend/2008" xmlns:viewModels="clr-namespace:Filtration.ViewModels" + xmlns:views="clr-namespace:Filtration.Views" + xmlns:converters="clr-namespace:Filtration.Converters" d:DataContext="{d:DesignInstance Type=viewModels:ItemFilterCommentBlockViewModel}" mc:Ignorable="d" d:DesignHeight="50" d:DesignWidth="300"> - + + + + + + + + + + + + + @@ -45,7 +76,7 @@ - +