private void OutlookBar_Click(object sender, EventArgs 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; } OutlookBarButton 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); } }
public void Remove(OutlookBarButton button) { List.Remove(button); Parent.ButtonlistChanged(); }
public ButtonClickEventArgs(OutlookBarButton button, MouseEventArgs evt) : base(evt.Button, evt.Clicks, evt.X, evt.Y, evt.Delta) { SelectedButton = button; }