예제 #1
0
 public void Remove(FxMenuBarButton button)
 {
     List.Remove(button);
     Parent.ButtonlistChanged();
 }
예제 #2
0
 public FxMenuBarButton Add(string text, Image image)
 {
     FxMenuBarButton b = new FxMenuBarButton(this.parent);
     b.Text = text;
     b.Image = image;
     this.Add(b);
     return b;
 }
예제 #3
0
 public void Add(FxMenuBarButton item)
 {
     if (List.Count == 0) Parent.SelectedButton = item;
     List.Add(item);
     item.Parent = this.Parent;
     Parent.ButtonlistChanged();
 }
예제 #4
0
 public ButtonClickEventArgs(FxMenuBarButton button, MouseEventArgs evt)
     : base(evt.Button, evt.Clicks, evt.X, evt.Y, evt.Delta)
 {
     SelectedButton = button;
 }
예제 #5
0
        private void PaintSelectedButton(FxMenuBarButton prevButton, FxMenuBarButton newButton)
        {
            if (prevButton == newButton)
                return; // no change so return immediately

            int selIdx = -1;
            int valIdx = -1;

            // find the indexes of the previous and new button
            selIdx = buttons.IndexOf(prevButton);
            valIdx = buttons.IndexOf(newButton);

            // now reset selected button
            // mouse is leaving control, so unhighlight anythign that is highlighted
            Graphics g = Graphics.FromHwnd(this.Handle);
            if (selIdx >= 0)
                // un-highlight current hovering button
                buttons[selIdx].PaintButton(g, 1, selIdx * (buttonHeight + 1) + 1, false, false);

            if (valIdx >= 0)
                // highlight newly selected button
                buttons[valIdx].PaintButton(g, 1, valIdx * (buttonHeight + 1) + 1, true, false);
            g.Dispose();
        }
예제 #6
0
        private void FxMenuBar_MouseClick(object sender, MouseEventArgs e)
        {
            if (!(e is MouseEventArgs)) return;

            // case to MouseEventArgs so position and mousebutton clicked can be used
            MouseEventArgs mea = (MouseEventArgs)e;

            // only continue if left mouse button was clicked
            if (mea.Button != MouseButtons.Left) return;

            int index = (mea.Y - 1) / (buttonHeight + 1);

            if (index < 0 || index >= buttons.Count)
                return;

            FxMenuBarButton button = buttons[index];
            if (button == null) return;
            if (!button.Enabled) return;

            // ok, all checks passed so assign the new selected button
            // and raise the event
            SelectedButton = button;

            ButtonClickEventArgs bce = new ButtonClickEventArgs(selectedButton, mea);
            if (Click != null) // only invoke on left mouse click
                Click.Invoke(this, bce);
        }