예제 #1
0
        private void editButtonToolStripMenuItem_Click(object sender, EventArgs e)
        {
            // Thanks StackOverflow
            // Try to cast the sender to a ToolStripItem
            ToolStripItem menuItem = sender as ToolStripItem;

            if (menuItem != null)
            {
                // Retrieve the ContextMenuStrip that owns this ToolStripItem
                ContextMenuStrip owner = menuItem.Owner as ContextMenuStrip;
                if (owner != null)
                {
                    // Get the control that is displaying this context menu
                    Control sourceControl = owner.SourceControl;

                    // My code
                    int             index        = flowLayoutPanel1.Controls.IndexOf(sourceControl);
                    MusicButtonInfo ButtonToEdit = CurrentButtons[index];
                    using (ButtonForm buttonWindow = new ButtonForm(ButtonToEdit.text, ButtonToEdit.textColor.ToArgb(), ButtonToEdit.file, ButtonToEdit.image, ButtonToEdit.background))
                    {
                        DialogResult result = buttonWindow.ShowDialog();
                        if (result == DialogResult.OK)
                        {
                            ButtonToEdit.text       = buttonWindow.text;
                            ButtonToEdit.textColor  = buttonWindow.textColor;
                            ButtonToEdit.file       = buttonWindow.file;
                            ButtonToEdit.image      = buttonWindow.image;
                            ButtonToEdit.background = buttonWindow.background;
                            ReloadButtons();
                        }
                    }
                }
            }
        }
예제 #2
0
 private void addButtonToolStripMenuItem_Click(object sender, EventArgs e)
 {
     using (ButtonForm buttonWindow = new ButtonForm())
     {
         DialogResult result = buttonWindow.ShowDialog();
         if (result == DialogResult.OK)
         {
             MusicButtonInfo buttonToAdd = new MusicButtonInfo(buttonWindow.text, buttonWindow.textColor, buttonWindow.file, buttonWindow.image, buttonWindow.background);
             CurrentButtons.Add(buttonToAdd);
             ReloadButtons();
         }
     }
 }