public void OnMouseMove(Point location) { DrawableButton mouseOutButton = null; if (mouseOverButton != null) { if (mouseOverButton.PixelPosition.Contains(location)) { return; // nothing new happened } else { mouseOutButton = mouseOverButton; mouseOverButton = null; } } foreach (var btn in grid) { if (btn.PixelPosition.Contains(location)) { mouseOverButton = btn; } } if (mouseOverButton != null || mouseOutButton != null) { MouseChangeEventArgs args = new MouseChangeEventArgsImpl(mouseOverButton, mouseOutButton); RaiseMouseChangeEvent(args); } }
protected override void Draw(Graphics g, DrawableButton btn, ButtonStatus status) { if (btn.Icon == null) { return; } g.DrawImage(btn.Icon.Image, btn.PixelPosition); }
public void DrawButton(Graphics g, DrawableButton btn, ButtonStatus status) { // first let decorated drawer draw if (drawer != null) { drawer.DrawButton(g, btn, status); } try { Draw(g, btn, status); } catch (Exception e) { logger.Error("Exception occurred while drawing button '{0}'!\n{1}", btn.Id, e); } }
protected override void Draw(Graphics g, DrawableButton btn, ButtonStatus status) { Pen p = (status.Selected ? selectedPen : normalPen); Rectangle rect = btn.PixelPosition; // allowed cause of value type int width = (status.Selected ? selectedWidth : normalWidth); width--; rect.X += width; rect.Width -= 2 * width; rect.Y += width; rect.Height -= 2 * width; g.DrawRectangle(p, rect); }
protected override void Draw(Graphics g, DrawableButton btn, ButtonStatus status) { if (btn.Text == null || String.IsNullOrWhiteSpace(btn.Text.Content)) { return; } if (status.Selected) { g.DrawString(btn.Text.Content, fontSelected, Brushes.Red, btn.PixelPosition, format); } else { g.DrawString(btn.Text.Content, font, Brushes.Black, btn.PixelPosition, format); } }
/// <remarks> /// As only one mouse pointer is supported by <see cref="System.Windows.Forms"/>, we only provide constructor for one button. /// </remarks> public MouseChangeEventArgsImpl(DrawableButton mouseOver, DrawableButton mouseOut) { if (mouseOver != null) { MouseOver = new ButtonGroup(mouseOver.Id); } else { MouseOver = ButtonGroup.Empty; } if (mouseOut != null) { MouseOut = new ButtonGroup(mouseOut.Id); } else { MouseOut = ButtonGroup.Empty; } }
protected override void Draw(Graphics g, DrawableButton btn, ButtonStatus status) { g.FillRectangle(btn.BackBrush, btn.PixelPosition); if (btn.Icon != null) { if (btn.Text != null) { Rectangle alignRect = GetAlignedIconRect(btn.Text.Alignment, btn.PixelPosition); DrawIcon(g, btn.Icon, alignRect); } else { DrawIcon(g, btn.Icon, btn.PixelPosition); } } if (btn.Text != null) { DrawText(g, btn.Text, btn.FontBrush, btn.PixelPosition); } }
/// <remarks> /// <see cref="DrawableButton"/> has a status property, but grid drawer should be able to override this, /// so therefore the <paramref name="status"/> parameter. /// </remarks> protected abstract void Draw(Graphics g, DrawableButton btn, ButtonStatus status);
public void DrawButton(Graphics g, DrawableButton btn) { DrawButton(g, btn, btn.Status); }
public virtual void Reset(Size size) { mouseOverButton = null; CanvasSize = size; ResizeGrid(); }