Example #1
0
        void DrawButton(PaintEventArgs e, ButtonInfo button, int iconX, int textX)
        {
            Color backColor = ButtonBackColor;
            Color foreColor = ButtonForeColor;

            if (button == PressedObject || button == HoverObject)
            {
                backColor = ButtonHoverBackColor;
                foreColor = ButtonHoverForeColor;
            }

            var rect = button.Bounds;
            var font = Font;

            e.Graphics.FillRectangle(new SolidBrush(backColor), rect);

            if (button.Image != null)
            {
                var rectIcon = new Rectangle(iconX, rect.Y, IconSize.Width, rect.Height);
                PaintHelper.DrawImageInRange(e.Graphics, button.Image, rectIcon);
            }

            if (!string.IsNullOrEmpty(button.Text))
            {
                var rectText = new Rectangle(textX, rect.Y, rect.Right - textX, rect.Height);

                var sf = PaintHelper.SFLeft;
                sf.FormatFlags |= StringFormatFlags.NoWrap;
                sf.Trimming     = StringTrimming.EllipsisCharacter;

                e.Graphics.DrawString(button.Text, Font, new SolidBrush(foreColor), rectText, sf);
            }
        }
Example #2
0
 void InvalidateButton(ButtonInfo button)
 {
     if (button != null)
     {
         Invalidate(button.Bounds);
     }
 }
Example #3
0
        void OnPressedObjectChanged(ButtonInfo old)
        {
            if (old != null)
            {
                InvalidateButton(old);
            }

            if (PressedObject != null)
            {
                InvalidateButton(PressedObject);
            }
        }
Example #4
0
        void OnHoverObjectChanged(ButtonInfo old)
        {
            if (old != null)
            {
                InvalidateButton(old);
            }

            if (HoverObject != null)
            {
                InvalidateButton(HoverObject);
            }
        }
Example #5
0
        void OnButtonClick(ButtonInfo button)
        {
            if (button == null)
            {
                throw new ArgumentNullException();
            }

            button.NotifyClick();

            if (ButtonClick != null)
            {
                ButtonClick(this, new ButtonEventArgs(button));
            }
        }
Example #6
0
 public ButtonEventArgs(ButtonInfo button)
 {
     Button = button;
 }