private void UnsetAlarmSound(AlarmButton r) { r.ToolTip = Properties.Resources.NoSoundAlert; r.SetOff(); AudioFileReader s; switch (r.Name) { case "SBell": if (sounds.TryGetValue(HuntRank.S, out s)) { sounds.Remove(HuntRank.S); } Settings.Default.SBell = Properties.Resources.NoSoundAlert; break; case "ABell": if (sounds.TryGetValue(HuntRank.A, out s)) { sounds.Remove(HuntRank.A); } Settings.Default.ABell = Properties.Resources.NoSoundAlert; break; case "BBell": if (sounds.TryGetValue(HuntRank.B, out s)) { sounds.Remove(HuntRank.B); } Settings.Default.BBell = Properties.Resources.NoSoundAlert; break; case "FATEBell": if (sounds.TryGetValue(HuntRank.FATE, out s)) { sounds.Remove(HuntRank.FATE); } Settings.Default.FATEBell = Properties.Resources.NoSoundAlert; break; default: return; } if (s != null) { s.Position = s.Length; s.Dispose(); } }
private void SBell_Click(object sender, RoutedEventArgs e) { if (currentCMPlacement != null) { currentCMPlacement.SetOff(); currentCMPlacement = null; } if (((AlarmButton)sender).IsOn()) { UnsetAlarmSound((AlarmButton)sender); } else if (((AlarmButton)sender).IsEnabled) { ContextMenu cm = new ContextMenu(); var mi1 = new MenuItem { Header = Properties.Resources.FormSFCMNewAlert }; mi1.Click += MenuItemClickCallCheckBox; cm.Items.Add(mi1); if (Settings.Default.SBell != Properties.Resources.NoSoundAlert) { var miS = new MenuItem { Header = Settings.Default.SBell }; miS.Click += MenuItemSoundSelected; cm.Items.Add(miS); } if (Settings.Default.ABell != Properties.Resources.NoSoundAlert) { var miA = new MenuItem { Header = Settings.Default.ABell }; miA.Click += MenuItemSoundSelected; cm.Items.Add(miA); } if (Settings.Default.BBell != Properties.Resources.NoSoundAlert) { var miB = new MenuItem { Header = Settings.Default.BBell }; miB.Click += MenuItemSoundSelected; cm.Items.Add(miB); } if (Settings.Default.FATEBell != Properties.Resources.NoSoundAlert) { var miFATE = new MenuItem { Header = Settings.Default.FATEBell }; miFATE.Click += MenuItemSoundSelected; cm.Items.Add(miFATE); } //Remove duplicates for (int i = 0; i < cm.Items.Count; i++) { for (int j = 0; j < cm.Items.Count; j++) { if (i != j && ((MenuItem)cm.Items[i]).Header.ToString() == ((MenuItem)cm.Items[j]).Header.ToString()) { cm.Items.RemoveAt(j); } } } if (cm.Items.Count < 2) { CheckBox_Checked(sender, e); } else { cm.PlacementTarget = currentCMPlacement = (AlarmButton)sender; cm.Closed += Cm_Closed; ((AlarmButton)sender).ContextMenu = cm; ((AlarmButton)sender).ContextMenu.IsOpen = true; } } }