Add support for PlayAlertSoundPositional.

This commit is contained in:
GlenCFL 2017-12-07 08:20:18 -05:00
parent 010e0dda31
commit 8bf3527b69
6 changed files with 73 additions and 17 deletions

1
.gitignore vendored
View File

@ -2,6 +2,7 @@
## files generated by popular Visual Studio add-ons.
# User-specific files
/.vs/
*.suo
*.user
*.sln.docstates

View File

@ -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;
}
}

View File

@ -227,21 +227,39 @@ namespace Filtration.Parser.Services
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);
}

View File

@ -115,6 +115,17 @@
<xctk:ShortUpDown Value="{Binding Path=SecondValue}" Minimum="1" Maximum="300" HorizontalAlignment="Right" ToolTip="Volume"/>
</WrapPanel>
</DataTemplate>
<!-- Positional Sound Template -->
<DataTemplate DataType="{x:Type blockItemTypes:PositionalSoundBlockItem}">
<WrapPanel HorizontalAlignment="Left">
<Button Command="{Binding Path=DataContext.PlayPositionalSoundCommand, RelativeSource={RelativeSource AncestorType={x:Type views:ItemFilterBlockView}}}" Width="20" Height="20" Background="Transparent" BorderBrush="Transparent">
<Image Source="/Filtration;component/Resources/Icons/speaker_icon.png" VerticalAlignment="Center" HorizontalAlignment="Center" />
</Button>
<ComboBox ItemsSource="{Binding ElementName=BlockItemContentControl, Path=DataContext.SoundsAvailable}" SelectedValue="{Binding Value}" Style="{StaticResource MetroComboBox}" />
<xctk:ShortUpDown Value="{Binding Path=SecondValue}" Minimum="1" Maximum="300" HorizontalAlignment="Right" ToolTip="Volume"/>
</WrapPanel>
</DataTemplate>
</ContentControl.Resources>
</ContentControl>
</Grid>

View File

@ -62,6 +62,7 @@ namespace Filtration.ViewModels
RemoveFilterBlockItemCommand = new RelayCommand<IItemFilterBlockItem>(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<Type> AddFilterBlockItemCommand { get; private set; }
public RelayCommand<IItemFilterBlockItem> 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,8 +245,8 @@ namespace Filtration.ViewModels
public Color DisplayBorderColor => Block.DisplayBorderColor;
public double DisplayFontSize => Block.DisplayFontSize/1.8;
public bool HasSound => Block.HasBlockItemOfType<SoundBlockItem>() ||
Block.HasBlockItemOfType<PositionalSoundBlockItem>();
public bool HasSound => Block.HasBlockItemOfType<SoundBlockItem>();
public bool HasPositionalSound => Block.HasBlockItemOfType<PositionalSoundBlockItem>();
public bool HasAudioVisualBlockItems => AudioVisualBlockItems.Any();
@ -430,7 +432,19 @@ namespace Filtration.ViewModels
private void OnPlayPositionalSoundCommand()
{
var identifier = BlockItems.OfType<PositionalSoundBlockItem>().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)

View File

@ -141,6 +141,18 @@
ToolTip="Click to preview drop sound">
<Image Source="/Filtration;component/Resources/Icons/speaker_icon.png" VerticalAlignment="Center" HorizontalAlignment="Center" />
</Button>
<Button Command="{Binding PlayPositionalSoundCommand}"
Width="25"
Height="25"
VerticalAlignment="Center"
HorizontalAlignment="Center"
Margin="0,0,3,0"
Visibility="{Binding HasPositionalSound, Converter={StaticResource BooleanVisibilityConverter}}"
Background="Transparent"
BorderBrush="Transparent"
ToolTip="Click to preview drop sound">
<Image Source="/Filtration;component/Resources/Icons/speaker_icon.png" VerticalAlignment="Center" HorizontalAlignment="Center" />
</Button>
<ToggleButton Margin="0,2,2,2"
Style="{StaticResource ChromelessToggleButton}"
x:Name="ItemPreviewButton"