public CaptionButtonInfo AddButton(string text, Image image) { CaptionButtonInfo cbi = new CaptionButtonInfo(text, image); AddButton(cbi); return(cbi); }
protected virtual void OnButtonClick(CaptionButtonInfo button) { if (ButtonClick != null) { ButtonClick(button, EventArgs.Empty); } }
void InvalidateButton(CaptionButtonInfo button) { if (button == null) { return; } Invalidate(button.Bounds); }
void OnMouseDownButtonChanged(CaptionButtonInfo old) { if (old != null) { InvalidateButton(old); } if (MouseDownButton != null) { InvalidateButton(MouseDownButton); } }
protected override void OnMouseDown(MouseEventArgs e) { base.OnMouseDown(e); if (e.Button == System.Windows.Forms.MouseButtons.Left) { MouseDownButton = HitTest(e.X, e.Y); if (MouseDownButton != null) { Capture = true; } } }
protected override void OnMouseUp(MouseEventArgs e) { base.OnMouseUp(e); if (MouseDownButton != null && MouseDownButton == HitTest(e.X, e.Y)) { MouseDownButton.NotifyClick(); OnButtonClick(MouseDownButton); } MouseDownButton = null; Capture = false; }
protected virtual void DrawButton(PaintEventArgs e, CaptionButtonInfo button) { if (button == null) { throw new ArgumentNullException(); } if (button == MouseHoverButton || button == MouseDownButton) { VisualStyleElement vse = null; ButtonState bs = ButtonState.Normal; if (button == MouseDownButton) { vse = VisualStyleElement.Button.PushButton.Pressed; bs = ButtonState.Pushed; } else if (button == MouseHoverButton) { vse = VisualStyleElement.Button.PushButton.Normal; bs = ButtonState.Normal; } if (VisualStyleRenderer.IsSupported && VisualStyleRenderer.IsElementDefined(vse)) { var renderer = new VisualStyleRenderer(vse); renderer.DrawBackground(e.Graphics, button.Bounds); } else { ControlPaint.DrawButton(e.Graphics, button.Bounds, bs); } } if (button.Image != null) { var rectangle = button.Bounds; e.Graphics.DrawImage(button.Image, new Rectangle(rectangle.X + (rectangle.Width - button.Image.Width) / 2, rectangle.Y + (rectangle.Height - button.Image.Height) / 2, button.Image.Width, button.Image.Height), 0, 0, button.Image.Width, button.Image.Height, GraphicsUnit.Pixel); } }
public bool RemoveButton(CaptionButtonInfo button) { if (button == null) { throw new ArgumentNullException(); } if (Buttons.Contains(button)) { Buttons = Buttons.Where(b => b != button).ToArray(); ResetControlsBounds(); Invalidate(); return(true); } else { return(false); } }
void OnMouseHoverButtonChanged(CaptionButtonInfo old) { if (old != null) { InvalidateButton(old); } if (MouseHoverButton != null) { InvalidateButton(MouseHoverButton); } if (MouseHoverButton != null) { ShowToolTipText(Lang._(MouseHoverButton.Text)); } else { ShowToolTipText(null); } }
public CaptionButtonInfo AddButton(CaptionButtonInfo button) { if (button == null) { throw new ArgumentNullException(); } List <CaptionButtonInfo> list = new List <CaptionButtonInfo>(); if (!Buttons.IsNullOrEmpty()) { list.AddRange(Buttons); } list.Add(button); //list.Sort(); Buttons = list.ToArray(); ResetControlsBounds(); Invalidate(); return(button); }
public CaptionButtonClickEventArgs(CaptionButtonInfo button) { Button = button; }