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 OutlookBarButton Add(string text, Image image) { OutlookBarButton b = new OutlookBarButton(this.parent); b.Text = text; b.Image = image; this.Add(b); return b; }
public void Add(OutlookBarButton item) { if (List.Count == 0) Parent.SelectedButton = item; List.Add(item); item.Parent = this.Parent; Parent.ButtonlistChanged(); }
public ButtonClickEventArgs(OutlookBarButton button, MouseEventArgs evt) : base(evt.Button, evt.Clicks, evt.X, evt.Y, evt.Delta) { SelectedButton = button; }
private void PaintSelectedButton(OutlookBarButton prevButton,OutlookBarButton 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(); }
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); }