コード例 #1
0
        private void RemoveSoundButton_Click(object sender, EventArgs e)
        {
            Notifier.StopAllSound();
            int selectedIndex = SoundListView.SelectedIndex;

            SoundListView.Items.RemoveAt(selectedIndex);
            Notifier.RemoveSound(selectedIndex);
            if (SoundListView.Items.Count > 0)
            {
                SoundListView.SelectItem(Math.Max(0, selectedIndex - 1));
            }
            else
            {
                RemoveSoundButton.Enabled = false;
            }
        }
コード例 #2
0
 private void AddSoundButton_Click(object sender, EventArgs e)
 {
     Notifier.StopAllSound();
     using (var dialog = new OpenFileDialog())
     {
         dialog.Title            = Resources.Open;
         dialog.Filter           = Resources.WaveFileFilter;
         dialog.Multiselect      = true;
         dialog.RestoreDirectory = true;
         if (dialog.ShowDialog() != DialogResult.OK)
         {
             return;
         }
         foreach (string fileName in dialog.FileNames)
         {
             Notifier.AddSound(fileName);
             SoundListView.Items.Add(StringUtils.EllipsisBySeparator(fileName, "\\", 3));
         }
         SoundListView.SelectItem(SoundListView.Items.Count - 1);
     }
 }
コード例 #3
0
 public void Reset(Notifier notifier)
 {
     Notifier?.StopAllSound();
     Notifier = notifier;
     ConditionComboBox.SelectedIndexChanged -= ConditionComboBox_SelectedIndexChanged;
     ConditionComboBox.SelectedIndex         = (int)Notifier.Condition;
     ConditionComboBox.SelectedIndexChanged += ConditionComboBox_SelectedIndexChanged;
     SpecifiedValueUpDown.ValueChanged      -= SpecifiedValueUpDown_ValueChanged;
     SpecifiedValueUpDown.Value              = Notifier.SpecifiedValue;
     SpecifiedValueUpDown.ValueChanged      += SpecifiedValueUpDown_ValueChanged;
     PlaySoundButton.Enabled             = false;
     StopSoundButton.Enabled             = false;
     SoundListView.SelectedIndexChanged -= SoundListView_SelectedIndexChanged;
     SoundListView.Items.Clear();
     foreach (string soundPath in Notifier.SoundPaths)
     {
         SoundListView.Items.Add(StringUtils.EllipsisBySeparator(soundPath, "\\", 3));
     }
     SoundListView.SelectedIndexChanged += SoundListView_SelectedIndexChanged;
     if (Notifier.SoundPaths.Count > 0)
     {
         SoundListView.SelectItem(0);
     }
 }