diff --git a/.gitignore b/.gitignore index 7964536..fe27920 100644 --- a/.gitignore +++ b/.gitignore @@ -2,6 +2,7 @@ ## files generated by popular Visual Studio add-ons. # User-specific files +/.vs/ *.suo *.user *.sln.docstates diff --git a/Filtration.ObjectModel/BlockItemTypes/PositionalSoundBlockItem.cs b/Filtration.ObjectModel/BlockItemTypes/PositionalSoundBlockItem.cs index 6b4eb3a..c7d746e 100644 --- a/Filtration.ObjectModel/BlockItemTypes/PositionalSoundBlockItem.cs +++ b/Filtration.ObjectModel/BlockItemTypes/PositionalSoundBlockItem.cs @@ -2,21 +2,21 @@ namespace Filtration.ObjectModel.BlockItemTypes { - public class PositionalSoundBlockItem : DualIntegerBlockItem + public class PositionalSoundBlockItem : StrIntBlockItem { public PositionalSoundBlockItem() { - Value = 1; + Value = "1"; SecondValue = 79; } - public PositionalSoundBlockItem(int value, int secondValue) : base(value, secondValue) + public PositionalSoundBlockItem(string value, int secondValue) : base(value, secondValue) { } public override string PrefixText => "PlayAlertSoundPositional"; public override int MaximumAllowed => 1; public override string DisplayHeading => "Play Positional Alert Sound"; - public override int SortOrder => 18; + public override int SortOrder => 22; } -} +} \ No newline at end of file diff --git a/Filtration.Parser/Services/ItemFilterBlockTranslator.cs b/Filtration.Parser/Services/ItemFilterBlockTranslator.cs index 1b147cc..9fbdeb8 100644 --- a/Filtration.Parser/Services/ItemFilterBlockTranslator.cs +++ b/Filtration.Parser/Services/ItemFilterBlockTranslator.cs @@ -224,24 +224,42 @@ namespace Filtration.Parser.Services RemoveExistingBlockItemsOfType(block); var match = Regex.Match(trimmedLine, @"\S+\s+(\S+)\s+(\d+)?"); - + if (match.Success) { + string firstValue; + int secondValue; + if (match.Groups.Count == 2) + { + firstValue = match.Groups[1].Value; + secondValue = 79; + } + else if (match.Groups.Count == 3) + { + firstValue = match.Groups[1].Value; + secondValue = Convert.ToInt16(match.Groups[2].Value); + } + else + { + break; + } + + if (lineOption == "PlayAlertSound") { var blockItemValue = new SoundBlockItem { - Value = match.Groups[1].Value, - SecondValue = 79 + Value = firstValue, + SecondValue = secondValue }; block.BlockItems.Add(blockItemValue); } - else if(match.Groups.Count == 3) + else { - var blockItemValue = new SoundBlockItem + var blockItemValue = new PositionalSoundBlockItem { - Value = match.Groups[1].Value, - SecondValue = Int16.Parse(match.Groups[2].Value) + Value = firstValue, + SecondValue = secondValue }; block.BlockItems.Add(blockItemValue); } diff --git a/Filtration/UserControls/BlockItemControl.xaml b/Filtration/UserControls/BlockItemControl.xaml index a73bb14..c9dfba3 100644 --- a/Filtration/UserControls/BlockItemControl.xaml +++ b/Filtration/UserControls/BlockItemControl.xaml @@ -115,6 +115,17 @@ + + + + + + + + + diff --git a/Filtration/ViewModels/ItemFilterBlockViewModel.cs b/Filtration/ViewModels/ItemFilterBlockViewModel.cs index 2ddf404..39d3428 100644 --- a/Filtration/ViewModels/ItemFilterBlockViewModel.cs +++ b/Filtration/ViewModels/ItemFilterBlockViewModel.cs @@ -62,6 +62,7 @@ namespace Filtration.ViewModels RemoveFilterBlockItemCommand = new RelayCommand(OnRemoveFilterBlockItemCommand); SwitchBlockItemsViewCommand = new RelayCommand(OnSwitchBlockItemsViewCommand); PlaySoundCommand = new RelayCommand(OnPlaySoundCommand, () => HasSound); + PlayPositionalSoundCommand = new RelayCommand(OnPlayPositionalSoundCommand, () => HasPositionalSound); } public event EventHandler BlockBecameDirty; @@ -100,6 +101,7 @@ namespace Filtration.ViewModels public RelayCommand AddFilterBlockItemCommand { get; private set; } public RelayCommand RemoveFilterBlockItemCommand { get; private set; } public RelayCommand PlaySoundCommand { get; private set; } + public RelayCommand PlayPositionalSoundCommand { get; private set; } public RelayCommand SwitchBlockItemsViewCommand { get; private set; } public IItemFilterBlock Block { get; private set; } @@ -243,9 +245,9 @@ namespace Filtration.ViewModels public Color DisplayBorderColor => Block.DisplayBorderColor; public double DisplayFontSize => Block.DisplayFontSize/1.8; - public bool HasSound => Block.HasBlockItemOfType() || - Block.HasBlockItemOfType(); - + public bool HasSound => Block.HasBlockItemOfType(); + public bool HasPositionalSound => Block.HasBlockItemOfType(); + public bool HasAudioVisualBlockItems => AudioVisualBlockItems.Any(); private void OnSwitchBlockItemsViewCommand() @@ -430,7 +432,19 @@ namespace Filtration.ViewModels 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/Views/ItemFilterBlockView.xaml b/Filtration/Views/ItemFilterBlockView.xaml index db16670..98b941c 100644 --- a/Filtration/Views/ItemFilterBlockView.xaml +++ b/Filtration/Views/ItemFilterBlockView.xaml @@ -129,7 +129,7 @@ - +