private void OnPlaySoundCommand() { var soundUri = "Resources/AlertSounds/AlertSound" + BlockItems.OfType <SoundBlockItem>().First().Value + ".wav"; _mediaPlayer.Open(new Uri(soundUri, UriKind.Relative)); _mediaPlayer.Play(); }
private bool AddBlockItemAllowed(Type type) { var blockItem = (IItemFilterBlockItem)Activator.CreateInstance(type); var blockCount = BlockItems.Count(b => b.GetType() == type); return(blockCount < blockItem.MaximumAllowed); }
private void OnAddFilterBlockItemCommand(Type blockItemType) { if (!AddBlockItemAllowed(blockItemType)) { return; } var newBlockItem = (IItemFilterBlockItem)Activator.CreateInstance(blockItemType); BlockItems.Add(newBlockItem); IsDirty = true; }
private void OnRemoveFilterBlockItemCommand(IItemFilterBlockItem blockItem) { BlockItems.Remove(blockItem); if (blockItem is IAudioVisualBlockItem) { blockItem.PropertyChanged -= OnAudioVisualBlockItemChanged; OnAudioVisualBlockItemChanged(this, EventArgs.Empty); } IsDirty = true; }
private void OnAddAudioVisualBlockItemCommand(Type blockItemType) { if (!AddBlockItemAllowed(blockItemType)) { return; } var newBlockItem = (IItemFilterBlockItem)Activator.CreateInstance(blockItemType); newBlockItem.PropertyChanged += OnAudioVisualBlockItemChanged; BlockItems.Add(newBlockItem); OnAudioVisualBlockItemChanged(this, EventArgs.Empty); IsDirty = true; }