Beispiel #1
0
        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);
            }
        }
Beispiel #2
0
        protected override void Draw(Graphics g, DrawableButton btn, ButtonStatus status)
        {
            if (btn.Icon == null)
            {
                return;
            }

            g.DrawImage(btn.Icon.Image, btn.PixelPosition);
        }
Beispiel #3
0
        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);
            }
        }
Beispiel #4
0
        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);
        }
Beispiel #5
0
        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);
            }
        }
Beispiel #6
0
        /// <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;
            }
        }
Beispiel #7
0
        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);
            }
        }
Beispiel #8
0
 /// <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);
Beispiel #9
0
 public void DrawButton(Graphics g, DrawableButton btn)
 {
     DrawButton(g, btn, btn.Status);
 }
Beispiel #10
0
 public virtual void Reset(Size size)
 {
     mouseOverButton = null;
     CanvasSize      = size;
     ResizeGrid();
 }