Exemplo n.º 1
0
        private void MenuItemSoundSelected(object sender, RoutedEventArgs e)
        {
            var cb = ((sender as MenuItem).Parent as ContextMenu).PlacementTarget as AlarmButton;

            SetAlarmSound(cb, ((MenuItem)sender).Header.ToString());
            currentCMPlacement = null;
        }
Exemplo n.º 2
0
        private bool SetAlarmSound(AlarmButton r, string soundFile)
        {
            r.ToolTip = Path.GetFileName(soundFile);
            r.SetOn();
            switch (r.Name)
            {
            case "SBell":
                sounds[HuntRank.S]     = new AudioFileReader(soundFile);
                Settings.Default.SBell = soundFile;
                return(true);

            case "ABell":
                sounds[HuntRank.A]     = new AudioFileReader(soundFile);
                Settings.Default.ABell = soundFile;
                return(true);

            case "BBell":
                sounds[HuntRank.B]     = new AudioFileReader(soundFile);
                Settings.Default.BBell = soundFile;
                return(true);

            case "FATEBell":
                sounds[HuntRank.FATE]     = new AudioFileReader(soundFile);
                Settings.Default.FATEBell = soundFile;
                return(true);

            default:
                return(false);
            }
        }
Exemplo n.º 3
0
 private void Cm_Closed(object sender, RoutedEventArgs e)
 {
     if (currentCMPlacement != null)
     {
         currentCMPlacement.SetOff();
     }
     currentCMPlacement = null;
 }
Exemplo n.º 4
0
        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();
            }
        }
Exemplo n.º 5
0
        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;
                }
            }
        }