コード例 #1
0
        // Creates the button for a sound.
        private void createSoundButton(String line)
        {
            SoundButton button = new SoundButton(line);

            button.ContextMenu = menu;
            if (!File.Exists(button.soundPath))
            {
                return;
            }
            button.Click += sbButton_Click;

            button.MouseEnter += sbButton_Enter;
            button.MouseLeave += sbButton_Leave;
            button.AutoSize    = false;
            button.TabStop     = false;
            sbButtons.Add(button);
            List <Keys> keyindex = new List <Keys>();
            string      number   = sbButtons.Count.ToString();

            if (!number.Equals("0"))
            {
                foreach (char s in number.ToCharArray())
                {
                    keyindex.Add((Keys)Enum.Parse(typeof(Keys), "D" + s));
                }
            }
            hotkeys.Add(new HotKeyGesture(keyindex, Keys.Control));
        }
コード例 #2
0
        private void setGHK(object sender, EventArgs e)
        {
            Keys key = (Keys)Enum.Parse(typeof(Keys), (sender as MenuItem).Text);

            selected_button       = (((sender as MenuItem).Parent as MenuItem).Parent as ContextMenu).SourceControl as SoundButton;
            globalButtonRltn[key] = sbButtons.IndexOf(selected_button);
            updateGlobalKeyFile();
        }
コード例 #3
0
 private void removeImg_Click(object sender, EventArgs e)
 {
     selected_button = ((sender as MenuItem).Parent as ContextMenu).SourceControl as SoundButton;
     if (selected_button == null)
     {
         return;
     }
     selected_button.imagePath = null;
     selected_button.setImage(null);
     updateDataFile();
 }
コード例 #4
0
 private String getGlobalKeyFromButton(SoundButton button)
 {
     foreach (Keys k in globalButtonRltn.Keys)
     {
         if (globalButtonRltn[k].Equals(sbButtons.IndexOf(button)))
         {
             return(k.ToString().Replace("D", ""));;
         }
     }
     return("Unknown");
 }
コード例 #5
0
 // Remove a sound from the soundboard.
 private void removeSound_Click(object sender, EventArgs e)
 {
     selected_button = ((sender as MenuItem).Parent as ContextMenu).SourceControl as SoundButton;
     if (selected_button == null)
     {
         return;
     }
     sbButtons.Remove(selected_button);
     soundPanel.Controls.Remove(selected_button);
     selected_button.Dispose();
     updateSoundGrid();
 }
コード例 #6
0
        private void viewButtonInfo(object sender, EventArgs e)
        {
            selected_button = ((sender as MenuItem).Parent as ContextMenu).SourceControl as SoundButton;
            String info = "Name: " + selected_button.Text + System.Environment.NewLine +
                          "Sound Src: " + selected_button.soundPath + System.Environment.NewLine +
                          "Image Src: " + (String.IsNullOrEmpty(selected_button.imagePath) ? "" : selected_button.imagePath)
                          + System.Environment.NewLine +
                          "HotKeys: { Local : " + "CTRL+" + (sbButtons.IndexOf(selected_button) + 1) +
                          (globalButtonRltn.ContainsValue(sbButtons.IndexOf(selected_button)) ? " , Global : ALT+"
                           + getGlobalKeyFromButton(selected_button) + "}": "}");

            MessageBox.Show(info);
        }
コード例 #7
0
        // Play a sound and select it to edit/remove.
        private void sbButton_Click(object sender, EventArgs e)
        {
            MouseEventArgs me     = (MouseEventArgs)e;
            SoundButton    button = sender as SoundButton;

            selected_button = button;
            if (me.Button == MouseButtons.Left)
            {
                playSound(button.soundPath);
                foreach (SoundButton b in sbButtons)
                {
                    b.Highlight = false;
                }
                button.Highlight = true;
            }
        }
コード例 #8
0
        // Edit the name of a sound.
        private void editSound_Click(object sender, EventArgs e)
        {
            selected_button = (((sender as MenuItem).Parent as MenuItem).Parent as ContextMenu).SourceControl as SoundButton;
            if (selected_button == null)
            {
                return;
            }

            string name;

            name = Microsoft.VisualBasic.Interaction.InputBox("Enter name for sound",
                                                              "Name", selected_button.name).Replace(" ", "_").Replace(",", "");
            if (String.IsNullOrEmpty(name))
            {
                name = "";                             // Allow manual change to empty
            }
            selected_button.name = name;
            selected_button.Text = name;
            updateDataFile();
        }
コード例 #9
0
        private void editImgBtn_Click(object sender, EventArgs e)
        {
            selected_button = (((sender as MenuItem).Parent as MenuItem).Parent as ContextMenu).SourceControl as SoundButton;
            if (selected_button == null)
            {
                return;
            }
            string         imagePath;
            OpenFileDialog fileDialog = new OpenFileDialog();

            fileDialog.Filter = "Image files(*.png;*.jpg;*.jpeg)|*.png;*.jpg;*.jpeg"; // Just common types ¯\_(ツ)_/¯
            if (fileDialog.ShowDialog() == DialogResult.OK)
            {
                imagePath = fileDialog.FileName;
            }
            else
            {
                imagePath = null; // I.E Click cancel to remove image
            }
            fileDialog.Dispose();
            selected_button.imagePath = imagePath;
            selected_button.setImage(imagePath);
            updateDataFile();
        }
コード例 #10
0
        // Edit the source of a sound.
        private void editSoundPath_Click(object sender, EventArgs e)
        {
            selected_button = (((sender as MenuItem).Parent as MenuItem).Parent as ContextMenu).SourceControl as SoundButton;
            if (selected_button == null)
            {
                return;
            }
            string         path;
            OpenFileDialog fileDialog = new OpenFileDialog();

            fileDialog.Filter = "Audio files(*.aiff;*.mp3;*.wav;*.ogg)|*.aiff;*.mp3;*.wav;*.ogg";

            if (fileDialog.ShowDialog() == DialogResult.OK)
            {
                path = fileDialog.FileName;
            }
            else
            {
                path = selected_button.soundPath;
            }
            fileDialog.Dispose();
            selected_button.soundPath = path;
            updateDataFile();
        }
コード例 #11
0
        private void sbButton_Enter(object sender, EventArgs e)
        {
            SoundButton button = sender as SoundButton;

            metroToolTip1.Show(button.Text, button);
        }