コード例 #1
0
        void button_Click(object sender, EventArgs e)
        {
            McButton button = (McButton)sender;

            if (button.aeMenu != null)
            {
                List <MenuUtilities.MenuItem> mil = MenuUtilities.GetMenuItems(button.aeMenu, true);
                if (mil.Count > 0)
                {
                    AddButtons(mil);
                }
                else
                {
                    HighlightLastClicked(button);
                    MenuUtilities.ClickMenuItem(button.aeMenu);
                }
            }
            else
            {
                string[] tag = ((McButton)sender).Tag.ToString().Split(';');
                IntPtr   ips = WindowsAPI.GetSubMenu((IntPtr)Convert.ToInt32(tag[0]), Convert.ToInt32(tag[1]));
                if (WindowsAPI.GetMenuItemCount(ips) > 0)
                {
                    AddButtons(MenuUtilities.GetMenuItems(ips));
                }
                else
                {
                    HighlightLastClicked(button);
                    IntPtr hMenu = new IntPtr(Convert.ToInt32(tag[0]));
                    MenuUtilities.ClickMenuItem(hMenu, Convert.ToInt32(tag[1]), _currentWnd);
                }
            }
        }
コード例 #2
0
 private void HighlightLastClicked(McButton button)
 {
     button.BackColor = System.Drawing.SystemColors.ControlDarkDark;
     if (_lastClickedButton != null)
     {
         _lastClickedButton.BackColor = System.Drawing.SystemColors.Control;
     }
     _lastClickedButton = button;
 }
コード例 #3
0
        private void AddButtons(List <MenuUtilities.MenuItem> mil)
        {
            pbContainer.Controls.Clear();
            int j = 0;

            for (int i = 0; i < mil.Count; i++)
            {
                if (mil[i].text.Trim() != "")
                {
                    McButton b = new McButton();
                    b.Text = mil[i].text;
                    ToolTip tt = new ToolTip();
                    tt.SetToolTip(b, mil[i].text);
                    if (mil[i].aeMenu != null)
                    {
                        b.aeMenu = mil[i].aeMenu;
                    }
                    else
                    {
                        b.Tag = mil[i].hMenu + ";" + i;
                    }
                    b.Enabled = !mil[i].isDisabled;
                    b.Width   = ButtonDim;
                    b.Height  = ButtonDim;

                    if (this.Orientation == OrientationTypes.VerticalLeft || this.Orientation == OrientationTypes.VerticalRight)
                    {
                        b.Top = j * ButtonIncrement;
                    }
                    else
                    {
                        b.Left = j * ButtonIncrement;
                    }

                    b.Click += new EventHandler(button_Click);
                    b.Font   = new System.Drawing.Font("Arial", 18);
                    pbContainer.Controls.Add(b);
                    j++;
                }
            }

            if (this.Orientation == OrientationTypes.VerticalLeft || this.Orientation == OrientationTypes.VerticalRight)
            {
                pbContainer.Width  = ButtonDim;
                pbContainer.Height = mil.Count * ButtonIncrement - ButtonSpacing;
            }
            else
            {
                pbContainer.Width  = mil.Count * ButtonIncrement - ButtonSpacing;
                pbContainer.Height = ButtonDim;
            }
        }