Exemplo n.º 1
0
        protected override void OnPaint(PaintEventArgs pevent)
        {
            base.OnPaint(pevent);
            Graphics gr            = pevent.Graphics;
            bool     mouseInButton = this.Capture &&
                                     this.ClientRectangle.Contains(this.PointToClient(MousePosition));

            System.Windows.Forms.ButtonState buttonState = !this.Enabled ? ButtonState.Inactive
              : (mouseInButton ? ButtonState.Pushed
              : ButtonState.Normal);
            ControlPaint.DrawScrollButton(gr, this.ClientRectangle,
                                          scrollButton,
                                          buttonState);
        }
Exemplo n.º 2
0
        /// <summary>
        /// Paint content of cell body.
        /// </summary>
        /// <param name="dc">Platform independency graphics context.</param>
        protected override void OnContentPaint(CellDrawingContext dc)
        {
            System.Windows.Forms.ButtonState bs = ButtonState.Normal;
            if (IsPressed)
            {
                bs |= ButtonState.Pushed;
            }
            if (IsChecked)
            {
                bs |= ButtonState.Checked;
            }

            ControlPaint.DrawCheckBox(dc.Graphics.PlatformGraphics, (System.Drawing.Rectangle)ContentBounds, bs);
        }
Exemplo n.º 3
0
        protected override void OnPaint(PaintEventArgs pevent)
        {
            base.OnPaint(pevent);   // Отправляем к базовому методу
            Graphics gr            = pevent.Graphics;
            bool     mouseInButton = this.Capture &&
                                     this.ClientRectangle.Contains(this.PointToClient(MousePosition));

            System.Windows.Forms.ButtonState buttonState =
                !this.Enabled ? ButtonState.Inactive
                : (mouseInButton ? ButtonState.Pushed
                : ButtonState.Normal);
            ControlPaint.DrawScrollButton(gr, this.ClientRectangle,
                                          scrollButton, // В какую сторону рисовать стрелку
                                          buttonState); // Каким стилем рисовать
        }
Exemplo n.º 4
0
        /// <summary>
        /// Paint content of cell body.
        /// </summary>
        /// <param name="dc">Platform independency graphics context.</param>
        protected override void OnContentPaint(CellDrawingContext dc)
        {
            System.Windows.Forms.ButtonState state = ButtonState.Normal;

            if (this.IsPressed)
            {
                state |= ButtonState.Pushed;
            }
            if (this.IsChecked)
            {
                state |= ButtonState.Checked;
            }

            ControlPaint.DrawRadioButton(dc.Graphics.PlatformGraphics,
                                         (System.Drawing.Rectangle) this.ContentBounds, state);
        }
Exemplo n.º 5
0
        /// <summary>
        /// Paint content of cell body.
        /// </summary>
        /// <param name="dc">Platform independency graphics context.</param>
        protected override void OnContentPaint(CellDrawingContext dc)
        {
#if WINFORM
            System.Windows.Forms.ButtonState bs = ButtonState.Normal;
            if (IsPressed)
            {
                bs |= ButtonState.Pushed;
            }
            if (IsChecked)
            {
                bs |= ButtonState.Checked;
            }

            ControlPaint.DrawCheckBox(dc.Graphics.PlatformGraphics, (System.Drawing.Rectangle)ContentBounds, bs);
#elif WPF
            var g = dc.Graphics;

            if (this.IsPressed)
            {
                g.FillRectangle(this.ContentBounds, StaticResources.SystemColor_Control);
            }

            g.DrawRectangle(this.ContentBounds, StaticResources.SystemColor_ControlDark);

            if (this.isChecked)
            {
                var x = this.ContentBounds.X;
                var y = this.ContentBounds.Y;
                var w = this.ContentBounds.Width;
                var h = this.ContentBounds.Height;

                var path   = new System.Windows.Media.PathGeometry();
                var figure = new System.Windows.Media.PathFigure(new System.Windows.Point(x + w * 0.167, y + h * 0.546),
                                                                 new System.Windows.Media.LineSegment[] {
                    new System.Windows.Media.LineSegment(new System.Windows.Point(x + w * 0.444, y + h * 0.712), false),
                    new System.Windows.Media.LineSegment(new System.Windows.Point(x + w * 0.833, y + h * 0.157), false),
                    new System.Windows.Media.LineSegment(new System.Windows.Point(x + w * 0.944, y + h * 0.323), false),
                    new System.Windows.Media.LineSegment(new System.Windows.Point(x + w * 0.500, y + h * 0.934), false),
                    new System.Windows.Media.LineSegment(new System.Windows.Point(x + w * 0.080, y + h * 0.712), false),
                }, true);

                path.Figures.Add(figure);

                g.FillPath(StaticResources.SystemColor_WindowText, path);
            }
#endif // WPF
        }
Exemplo n.º 6
0
        // Отрисовка кнопки в стиле со стрелкой
        protected override void OnPaint(PaintEventArgs pevent)
        {
            base.OnPaint(pevent);          // Отправляем к базовому методу или вообще убираем!!!
            Graphics gr = pevent.Graphics; // Извлекаем контекст устройства
                                           // Кнопка в контакте с мышью и курсор находится в области чувствительности
            bool mouseInButton = this.Capture && this.ClientRectangle.Contains(this.PointToClient(MousePosition));

            // Флаг состояния кнопки для управления ее стилем отрисовки
            System.Windows.Forms.ButtonState buttonState =
                !this.Enabled ? ButtonState.Inactive    // Если кнопка недоступна
                : (mouseInButton ? ButtonState.Pushed   // Если доступна и нажата
                : ButtonState.Normal);                  // Если доступна и отпущена
                                                        // Рисуем кнопку как кнопку со стрелкой
            ControlPaint.DrawScrollButton(gr, this.ClientRectangle,
                                          scrollButton, // В какую сторону рисовать стрелку
                                          buttonState); // Каким стилем рисовать
        }
Exemplo n.º 7
0
        /// <summary>
        /// Paint content of cell body.
        /// </summary>
        /// <param name="dc">Platform independency graphics context.</param>
        protected override void OnContentPaint(CellDrawingContext dc)
        {
#if WINFORM
            System.Windows.Forms.ButtonState state = ButtonState.Normal;

            if (this.IsPressed)
            {
                state |= ButtonState.Pushed;
            }
            if (this.IsChecked)
            {
                state |= ButtonState.Checked;
            }

            ControlPaint.DrawRadioButton(dc.Graphics.PlatformGraphics,
                                         (System.Drawing.Rectangle) this.ContentBounds, state);
#elif WPF
            var g = dc.Graphics;

            var ox = this.ContentBounds.OriginX;
            var oy = this.ContentBounds.OriginY;

            var hw = this.ContentBounds.Width / 2;
            var hh = this.ContentBounds.Height / 2;
            var r  = new Rectangle(ox - hw / 2, oy - hh / 2, hw, hh);
            g.DrawEllipse(StaticResources.SystemColor_ControlDark, r);

            if (this.IsPressed)
            {
                g.FillEllipse(StaticResources.SystemColor_Control, r);
            }

            if (this.isChecked)
            {
                var hhw = this.ContentBounds.Width / 4;
                var hhh = this.ContentBounds.Height / 4;
                r = new Rectangle(ox - hhw / 2, oy - hhh / 2, hhw, hhh);
                g.FillEllipse(StaticResources.SystemColor_WindowText, r);
            }
#endif // WINFORM
        }
Exemplo n.º 8
0
        public override void DrawButton(System.Drawing.Graphics g, System.Drawing.Rectangle rect, System.Windows.Forms.ButtonState buttonState, Syncfusion.Windows.Forms.Grid.GridStyleInfo style)
        {
            ControlPaint.DrawButton(g, rect, buttonState);

            // Icon
            rect.Inflate(-3, -3);
            Syncfusion.Drawing.BrushPaint.FillRectangle(g, rect, new Syncfusion.Drawing.BrushInfo(Syncfusion.Drawing.GradientStyle.PathEllipse, Color.Black, Color.Wheat));
        }
Exemplo n.º 9
0
        /// <summary>
        /// Primary function for painting the button. This method should be overridden instead of OnPaint.
        /// </summary>
        /// <param name="graphics">The graphics.</param>
        /// <param name="bounds">The bounds.</param>
        protected virtual void PaintButton(Graphics graphics, Rectangle bounds)
        {
            VisualStyleRenderer rnd = null;
            bool vsOk = Application.RenderWithVisualStyles;

            if (vsOk)
            {
                rnd = new VisualStyleRenderer(VisualStyleElement.Button.PushButton.Normal);
                rnd.DrawParentBackground(graphics, bounds, this);
            }
            else
            {
                graphics.Clear(this.Parent.BackColor);
            }
            if (this.Image != null || (this.ImageList != null && this.ImageList.Images.Count == 1))
            {
                Image img = (this.Image != null) ? this.Image : this.ImageList.Images[0];
                if (Enabled)
                {
                    if (vsOk)
                    {
                        rnd.DrawImage(graphics, bounds, img);
                    }
                    else
                    {
                        graphics.DrawImage(img, bounds);
                    }
                }
                else
                {
                    ControlPaint.DrawImageDisabled(graphics, img, 0, 0, this.BackColor);
                }
            }
            else if (this.ImageList != null && this.ImageList.Images.Count > 1)
            {
                int idx = (int)ButtonState - 1;
                if (this.ImageList.Images.Count == 2)
                {
                    idx = ButtonState == PushButtonState.Disabled ? 1 : 0;
                }
                if (this.ImageList.Images.Count == 3)
                {
                    idx = ButtonState == PushButtonState.Normal ? 0 : idx - 1;
                }
                if (vsOk)
                {
                    rnd.DrawImage(graphics, bounds, this.ImageList, idx);
                }
                else
                {
                    graphics.DrawImage(this.ImageList.Images[idx], bounds);
                }
            }
            else
            {
                if (vsOk)
                {
                    rnd.SetParameters(rnd.Class, rnd.Part, (int)ButtonState);
                    rnd.DrawBackground(graphics, bounds);
                }
                else
                {
                    System.Windows.Forms.ButtonState bs = System.Windows.Forms.ButtonState.Flat;
                    switch (this.ButtonState)
                    {
                    case PushButtonState.Disabled:
                        bs |= System.Windows.Forms.ButtonState.Inactive;
                        break;

                    case PushButtonState.Pressed:
                        bs |= System.Windows.Forms.ButtonState.Pushed;
                        break;

                    default:
                        break;
                    }
                    ControlPaint.DrawButton(graphics, bounds, bs);
                }
            }
        }