Esempio n. 1
0
            private void DrawUpDownButton()
            {
                bool mouseOver       = false;
                bool mousePress      = LeftKeyPressed();
                bool mouseInUpButton = false;

                RECT rect = new RECT();

                Win32.GetClientRect(base.Handle, ref rect);

                Rectangle clipRect = Rectangle.FromLTRB(
                    rect.top, rect.left, rect.right, rect.bottom);

                Point cursorPoint = new Point();

                Win32.GetCursorPos(ref cursorPoint);
                Win32.GetWindowRect(base.Handle, ref rect);

                mouseOver = Win32.PtInRect(ref rect, cursorPoint);

                cursorPoint.X -= rect.left;
                cursorPoint.Y -= rect.top;

                mouseInUpButton = cursorPoint.X < clipRect.Width / 2;

                using (Graphics g = Graphics.FromHwnd(base.Handle))
                {
                    UpDownButtonPaintEventArgs e =
                        new UpDownButtonPaintEventArgs(
                            g,
                            clipRect,
                            mouseOver,
                            mousePress,
                            mouseInUpButton);
                    _owner.OnPaintUpDownButton(e);
                }
            }
Esempio n. 2
0
        protected virtual void OnPaintUpDownButton(
            UpDownButtonPaintEventArgs e)
        {
            Graphics  g    = e.Graphics;
            Rectangle rect = e.ClipRectangle;

            Color upButtonBaseColor   = SkinManager.CurrentSkin.DefaultControlColor.First;
            Color upButtonBorderColor = this._BorderColor;
            Color upButtonArrowColor  = Color.Green;

            Color downButtonBaseColor   = SkinManager.CurrentSkin.DefaultControlColor.First;
            Color downButtonBorderColor = this._BorderColor;
            Color downButtonArrowColor  = Color.Green;

            Rectangle upButtonRect = rect;

            upButtonRect.X      += 2;
            upButtonRect.Y      += 2;
            upButtonRect.Width   = rect.Width / 2 - 4;
            upButtonRect.Height -= 4;

            Rectangle downButtonRect = rect;

            downButtonRect.X       = upButtonRect.Right;
            downButtonRect.Y      += 2;
            downButtonRect.Width   = rect.Width / 2 - 4;
            downButtonRect.Height -= 4;

            if (Enabled)
            {
                if (e.MouseOver)
                {
                    if (e.MousePress)
                    {
                        if (e.MouseInUpButton)
                        {
                            upButtonBaseColor = SkinManager.CurrentSkin.HeightLightControlColor.First;
                        }
                        else
                        {
                            downButtonBaseColor = SkinManager.CurrentSkin.HeightLightControlColor.First;
                        }
                    }
                    else
                    {
                        if (e.MouseInUpButton)
                        {
                            upButtonBaseColor = SkinManager.CurrentSkin.DefaultControlColor.First;
                        }
                        else
                        {
                            downButtonBaseColor = SkinManager.CurrentSkin.DefaultControlColor.First;
                        }
                    }
                }
            }
            else
            {
                upButtonBaseColor     = SystemColors.Control;
                upButtonBorderColor   = SystemColors.ControlDark;
                upButtonArrowColor    = SystemColors.ControlDark;
                downButtonBaseColor   = SystemColors.Control;
                downButtonBorderColor = SystemColors.ControlDark;
                downButtonArrowColor  = SystemColors.ControlDark;
            }

            GDIHelper.FillPath(g, new RoundRectangle(rect, new CornerRadius()), this._BackColor, this._BackColor);
            RenderButton(
                g,
                upButtonRect,
                upButtonBaseColor,
                upButtonBorderColor,
                upButtonArrowColor,
                ArrowDirection.Left);
            RenderButton(
                g,
                downButtonRect,
                downButtonBaseColor,
                downButtonBorderColor,
                downButtonArrowColor,
                ArrowDirection.Right);

            UpDownButtonPaintEventHandler handler =
                base.Events[EventPaintUpDownButton] as UpDownButtonPaintEventHandler;

            if (handler != null)
            {
                handler(this, e);
            }
        }