public override void Paint(Graphics g, Rectangle position, Painter.State buttonState, string text, Image buttonImage, Font textFont, Rectangle?referencePosition)
 {
     foreach (Painter p in _painters)
     {
         p.Paint(g, position, buttonState, text, buttonImage, textFont, referencePosition);
     }
 }
Exemple #2
0
 private void ResetAllButtonState()
 {
     _moveThumbStart   = null;
     _thumbState       = Painter.State.Normal;
     _lowerButtonState = Painter.State.Normal;
     _upperButtonState = Painter.State.Normal;
     _beforeThumbState = Painter.State.Normal;
     _afterThumbState  = Painter.State.Normal;
 }
 private void ResetAllButtonState()
 {
     moveThumbStart   = null;
     thumbState       = Painter.State.Normal;
     lowerButtonState = Painter.State.Normal;
     upperButtonState = Painter.State.Normal;
     beforeThumbState = Painter.State.Normal;
     afterThumbState  = Painter.State.Normal;
 }
 protected override Color BorderColor(Painter.State state)
 {
     if (state == State.Pressed)
     {
         return(Color.FromArgb(0x8b, 0x76, 0x54));
     }
     else
     {
         return(Color.FromArgb(0x96, 0x9f, 0xa3));
     }
 }
        public override void Paint(Graphics g, Rectangle position, Painter.State state, string text, Image buttonImage, Font textFont, Rectangle?referencePosition)
        {
            if (position.Height < 10 || position.Width < 20)
            {
                return;
            }

            RecalcBrushes(position, state);
            g.FillRectangle(leftBrush, leftBounds);
            g.FillRectangle(middleBrush, middleBounds);
            g.FillRectangle(rightBrush, rightBounds);
            DrawBorder(g, position, state);
            g.FillPath(upperGradientBrush, upperGradientPath);
        }
Exemple #6
0
        public override void Paint(Graphics g, Rectangle position, Painter.State buttonState, string text, Image buttonImage, Font textFont, Rectangle?referencePosition)
        {
            GraphicsPath path;

            Pen myPen = _pen;

            if (buttonState == State.Hover)
            {
                myPen = _hoverPen;
            }
            else if (buttonState == State.Pressed)
            {
                myPen = _clickPen;
            }

            if (_symbol == SymbolEnum.TriangleDown)
            {
                path = BuildTriangleDown(position);
            }
            else if (_symbol == SymbolEnum.TriangleUp)
            {
                path = BuildTriangleUp(position);
            }
            else if (_symbol == SymbolEnum.GripH)
            {
                path = BuildGripH(position);
            }
            else
            {
                throw new NotImplementedException("Symbol not implemented");
            }

            if (_fill && _noFill.Contains(_symbol) == false)
            {
                g.FillPath(_fillBrush, path);

                if (buttonState == State.Hover)
                {
                    g.DrawPath(myPen, path);
                }
                else if (buttonState == State.Pressed)
                {
                    g.DrawPath(myPen, path);
                }
            }
            else
            {
                g.DrawPath(myPen, path);
            }
        }
 protected virtual Brush CreateMiddleBrush(Rectangle bounds, Painter.State state)
 {
     if (state == State.Hover)
     {
         return(new SolidBrush(Color.FromArgb(247, 168, 247)));
     }
     else if (state == State.Pressed)
     {
         return(new SolidBrush(Color.FromArgb(241, 109, 241)));
     }
     else
     {
         return(new SolidBrush(Color.FromArgb(221, 217, 221)));
     }
 }
 protected virtual Brush CreateRightBrush(Rectangle bounds, Painter.State state)
 {
     if (state == State.Hover)
     {
         return(new LinearGradientBrush(bounds, Color.FromArgb(247, 168, 247), Color.FromArgb(228, 154, 228), LinearGradientMode.Horizontal));
     }
     else if (state == State.Pressed)
     {
         return(new LinearGradientBrush(bounds, Color.FromArgb(232, 109, 241), Color.FromArgb(220, 100, 223), LinearGradientMode.Horizontal));
     }
     else
     {
         return(new LinearGradientBrush(bounds, Color.FromArgb(214, 214, 214), Color.FromArgb(193, 193, 193), LinearGradientMode.Horizontal));
     }
 }
 protected override Brush LowerBrush(Painter.State state, Rectangle bounds)
 {
     if (state == State.Normal)
     {
         return(new LinearGradientBrush(bounds, Color.FromArgb(0xce, 0xd5, 0xd7), Color.FromArgb(0xdf, 0xe4, 0xe6), LinearGradientMode.Vertical));
     }
     else if (state == State.Hover)
     {
         return(new LinearGradientBrush(bounds, Color.FromArgb(0xfe, 0xd2, 0x53), Color.FromArgb(0xff, 0xe3, 0x97), LinearGradientMode.Vertical));
     }
     else
     {
         return(new LinearGradientBrush(bounds, Color.FromArgb(0xff, 0x9c, 0x26), Color.FromArgb(0xff, 0xc0, 0x4b), LinearGradientMode.Vertical));
     }
 }
 protected override Brush UpperBrush(Painter.State state, Rectangle bounds)
 {
     if (state == State.Normal)
     {
         return(new LinearGradientBrush(bounds, Color.FromArgb(0xd6, 0xde, 0xdf), Color.FromArgb(0xdb, 0xe2, 0xe4), LinearGradientMode.Vertical));
     }
     else if (state == State.Hover)
     {
         return(new LinearGradientBrush(bounds, Color.FromArgb(0xfe, 0xfa, 0xe5), Color.FromArgb(0xfb, 0xe0, 0x91), LinearGradientMode.Vertical));
     }
     else
     {
         return(new LinearGradientBrush(bounds, Color.FromArgb(0xcc, 0x96, 0x66), Color.FromArgb(0xff, 0xaa, 0x46), LinearGradientMode.Vertical));
     }
 }
Exemple #11
0
 protected virtual Brush CreateRightBrush(Rectangle bounds, Painter.State state)
 {
     if (state == State.Hover)
     {
         return(new LinearGradientBrush(bounds, Color.FromArgb(0xa9, 0xdb, 0xf6), Color.FromArgb(0x9c, 0xca, 0xe3), LinearGradientMode.Horizontal));
     }
     else if (state == State.Pressed)
     {
         return(new LinearGradientBrush(bounds, Color.FromArgb(0x6f, 0xca, 0xf0), Color.FromArgb(0x66, 0xba, 0xdd), LinearGradientMode.Horizontal));
     }
     else
     {
         return(new LinearGradientBrush(bounds, Color.FromArgb(0xd5, 0xd5, 0xd8), Color.FromArgb(0xc0, 0xc0, 0xc4), LinearGradientMode.Horizontal));
     }
 }
Exemple #12
0
 protected virtual Brush CreateLeftBrush(Rectangle bounds, Painter.State state)
 {
     if (state == State.Hover)
     {
         return(new LinearGradientBrush(bounds, Color.FromArgb(0xe3, 0xf4, 0xfc), Color.FromArgb(0xd6, 0xee, 0xfb), LinearGradientMode.Horizontal));
     }
     else if (state == State.Pressed)
     {
         return(new LinearGradientBrush(bounds, Color.FromArgb(0xce, 0xed, 0xfa), Color.FromArgb(0xb5, 0xe4, 0xf7), LinearGradientMode.Horizontal));
     }
     else
     {
         return(new LinearGradientBrush(bounds, Color.FromArgb(0xf5, 0xf5, 0xf5), Color.FromArgb(0xe9, 0xe9, 0xeb), LinearGradientMode.Horizontal));
     }
 }
Exemple #13
0
 protected virtual Brush CreateMiddleBrush(Rectangle bounds, Painter.State state)
 {
     if (state == State.Hover)
     {
         return(new SolidBrush(Color.FromArgb(0xa9, 0xdb, 0xf6)));
     }
     else if (state == State.Pressed)
     {
         return(new SolidBrush(Color.FromArgb(0x6f, 0xca, 0xf0)));
     }
     else
     {
         return(new SolidBrush(Color.FromArgb(0xd9, 0xda, 0xdc)));
     }
 }
 protected virtual Brush CreateLeftBrush(Rectangle bounds, Painter.State state)
 {
     if (state == State.Hover)
     {
         return(new LinearGradientBrush(bounds, Color.FromArgb(252, 226, 251), Color.FromArgb(252, 214, 251), LinearGradientMode.Horizontal));
     }
     else if (state == State.Pressed)
     {
         return(new LinearGradientBrush(bounds, Color.FromArgb(251, 206, 251), Color.FromArgb(248, 180, 245), LinearGradientMode.Horizontal));
     }
     else
     {
         return(new LinearGradientBrush(bounds, Color.FromArgb(245, 245, 245), Color.FromArgb(234, 234, 234), LinearGradientMode.Horizontal));
     };
 }
Exemple #15
0
        protected override void OnMouseDown(MouseEventArgs e)
        {
            base.OnMouseDown(e);

            if (RectUpperButton().Contains(e.Location) && _upperButtonState != Painter.State.Pressed)
            {
                ScrollAndActivateTimer(ScrollActionEnum.Up);
                ResetAllButtonState();
                _upperButtonState = Painter.State.Pressed;
                Invalidate();
            }
            else if (RectLowerButton().Contains(e.Location) && _lowerButtonState != Painter.State.Pressed)
            {
                ScrollAndActivateTimer(ScrollActionEnum.Down);
                ResetAllButtonState();
                _lowerButtonState = Painter.State.Pressed;
                Invalidate();
            }
            else if (_currentThumbPosition.Contains(e.Location) && _thumbState != Painter.State.Pressed)
            {
                ResetAllButtonState();
                _thumbState          = Painter.State.Pressed;
                _moveThumbStart      = e.Location;
                _moveThumbValueStart = _currentValue;
                _moveThumbRectStart  = _currentThumbPosition;
                Invalidate();
            }
            else if (_beforeThumb.Contains(e.Location) && _beforeThumbState != Painter.State.Pressed)
            {
                ScrollAndActivateTimer(ScrollActionEnum.PageUp);
                ResetAllButtonState();
                _beforeThumbState = Painter.State.Pressed;
                Invalidate();
            }
            else if (_afterThumb.Contains(e.Location) && _afterThumbState != Painter.State.Pressed)
            {
                ScrollAndActivateTimer(ScrollActionEnum.PageDown);
                ResetAllButtonState();
                _afterThumbState = Painter.State.Pressed;
                Invalidate();
            }
        }
        protected override void OnMouseDown(MouseEventArgs e)
        {
            base.OnMouseDown(e);

            if (RectUpperButton().Contains(e.Location) && upperButtonState != Painter.State.Pressed)
            {
                ScrollAndActivateTimer(EnumScrollAction.Up);
                ResetAllButtonState();
                upperButtonState = Painter.State.Pressed;
                Invalidate();
            }
            else if (RectLowerButton().Contains(e.Location) && lowerButtonState != Painter.State.Pressed)
            {
                ScrollAndActivateTimer(EnumScrollAction.Down);
                ResetAllButtonState();
                lowerButtonState = Painter.State.Pressed;
                Invalidate();
            }
            else if (currentThumbPosition.Contains(e.Location) && thumbState != Painter.State.Pressed)
            {
                ResetAllButtonState();
                thumbState          = Painter.State.Pressed;
                moveThumbStart      = e.Location;
                moveThumbValueStart = currentValue;
                moveThumbRectStart  = currentThumbPosition;
                Invalidate();
            }
            else if (beforeThumb.Contains(e.Location) && beforeThumbState != Painter.State.Pressed)
            {
                ScrollAndActivateTimer(EnumScrollAction.PageUp);
                ResetAllButtonState();
                beforeThumbState = Painter.State.Pressed;
                Invalidate();
            }
            else if (afterThumb.Contains(e.Location) && afterThumbState != Painter.State.Pressed)
            {
                ScrollAndActivateTimer(EnumScrollAction.PageDown);
                ResetAllButtonState();
                afterThumbState = Painter.State.Pressed;
                Invalidate();
            }
        }
Exemple #17
0
        protected virtual void RecalcBrushes(Rectangle position, Painter.State state)
        {
            if (_lastPosition == null || _lastPosition.Value != position || _lastState == null || _lastState.Value != state)
            {
                _lastState = state;
                if (state == State.Hover)
                {
                    _borderPen = new Pen(Color.FromArgb(0x3c, 0x7f, 0xb1), 1);
                }
                else if (state == State.Pressed)
                {
                    _borderPen = new Pen(Color.FromArgb(0x18, 0x59, 0x8a), 1);
                }
                else
                {
                    _borderPen = new Pen(Color.FromArgb(0x9a, 0x9a, 0x9a), 1);
                }

                _leftBounds = new Rectangle(position.X, position.Y, 8, position.Height);
                _leftBrush  = CreateLeftBrush(_leftBounds, state);

                _middleBounds = new Rectangle(_leftBounds.Right, _leftBounds.Y, (int)((float)position.Width - 16), position.Height);
                _middleBrush  = CreateMiddleBrush(_middleBounds, state);

                _rightBounds = new Rectangle(_middleBounds.Right, _leftBounds.Y, 8, position.Height);
                _rightBrush  = CreateRightBrush(_rightBounds, state);

                _upperGradientPath = new GraphicsPath();
                _upperGradientPath.AddLine(position.X + 8, position.Y + 1, position.X + 8, position.Y + 5);
                _upperGradientPath.AddLine(position.X + 8, position.Y + 5, _middleBounds.Right, position.Y + 5);
                _upperGradientPath.AddLine(_middleBounds.Right, position.Y + 5, _rightBounds.Right - 1, position.Y + 1);
                _upperGradientPath.CloseAllFigures();

                _upperGradientRect  = new Rectangle(position.X + 8, position.Y + 1, 10, 4);
                _upperGradientBrush = new LinearGradientBrush(_upperGradientRect, Color.FromArgb(0xed, 0xed, 0xed), Color.FromArgb(0xdd, 0xdd, 0xe0), LinearGradientMode.Vertical);

                _lastPosition = position;
            }
        }
Exemple #18
0
        public override void Paint(Graphics g, Rectangle position, Painter.State buttonState, string text, Image buttonImage, Font textFont, Rectangle?referencePosition)
        {
            Rectangle layoutArea = Rectangle.FromLTRB(position.X + _paddingLeft,
                                                      position.Y + _paddingTop,
                                                      position.Right - _paddingRight,
                                                      position.Bottom - _paddingBottom);

            if (layoutArea.Width <= 0 || layoutArea.Height <= 0)
            {
                return;
            }

            double layoutRatio = (double)layoutArea.Width / (double)layoutArea.Height;

            Rectangle targetRect;

            //maximize width
            if (layoutRatio < _targetRatio)
            {
                int targetWidth = layoutArea.Width;

                if (_maxWidth > 0)
                {
                    targetWidth = Math.Min(layoutArea.Width, _maxWidth);
                }

                int targetHeight = (int)((double)targetWidth / _targetRatio);

                targetRect = new Rectangle(layoutArea.X, layoutArea.Y, targetWidth, targetHeight);
            }
            //maximize height
            else
            {
                int targetWidth  = (int)((double)layoutArea.Height * _targetRatio);
                int targetHeight = layoutArea.Height;

                if (_maxWidth > 0 && targetWidth > _maxWidth)
                {
                    targetWidth  = _maxWidth;
                    targetHeight = (int)((double)targetHeight / _targetRatio);
                }

                targetRect = new Rectangle(layoutArea.X, layoutArea.Y, targetWidth, targetHeight);
            }

            if (_vAlign == Alignment.Far)
            {
                targetRect = new Rectangle(targetRect.X, layoutArea.Bottom - targetRect.Height, targetRect.Width, targetRect.Height);
            }
            else if (_vAlign == Alignment.Center)
            {
                targetRect = new Rectangle(targetRect.X, layoutArea.Top + (int)((double)layoutArea.Height / 2.0d - (double)targetRect.Height / 2.0d),
                                           targetRect.Width, targetRect.Height);
            }

            if (_hAlign == Alignment.Far)
            {
                targetRect = new Rectangle(layoutArea.Right - targetRect.Width, targetRect.Y, targetRect.Width, targetRect.Height);
            }
            else if (_hAlign == Alignment.Center)
            {
                targetRect = new Rectangle(targetRect.X + (int)((double)layoutArea.Width / 2.0d - (double)targetRect.Width / 2.0d),
                                           targetRect.Y, targetRect.Width, targetRect.Height);
            }

            _subPainter.Paint(g, targetRect, buttonState, text, buttonImage, textFont, referencePosition);
        }
 protected abstract Color BorderColor(Painter.State state);
 protected abstract int BorderWidth(Painter.State state);
 protected abstract Brush LowerBrush(Painter.State state, Rectangle bounds);
Exemple #22
0
 public virtual void DrawBorder(Graphics g, Rectangle position, Painter.State state)
 {
     g.DrawRectangle(_borderPen, new Rectangle(position.X, position.Y, (int)(position.Width - _borderPen.Width), (int)(position.Height - _borderPen.Width)));
 }
 protected abstract Color FontColor(Painter.State state);
 public override void Paint(Graphics g, Rectangle position, Painter.State buttonState, string text, Image buttonImage, Font textFont, Rectangle?referencePosition)
 {
     _subPainter.Paint(g, position, buttonState, "", buttonImage, textFont, referencePosition);
 }
 protected override int BorderWidth(Painter.State state)
 {
     return(1);
 }
        public override void Paint(Graphics g, Rectangle position, Painter.State buttonState, string text, Image buttonImage, Font textFont, Rectangle?referencePosition)
        {
            Rectangle upperRect;
            Rectangle lowerRect;

            if (buttonState != State.Pressed)
            {
                upperRect = new Rectangle(position.Left, position.Top, position.Width, position.Height / 2 - position.Height / 8);
                lowerRect = new Rectangle(position.Left, position.Top + position.Height / 2 - position.Height / 8, position.Width, position.Height / 2 + position.Height / 8);
            }
            else
            {
                upperRect = new Rectangle(position.Left, position.Top, position.Width, Math.Max(1, position.Height / 2));
                lowerRect = new Rectangle(position.Left, position.Top + position.Height / 2, position.Width, Math.Max(1, position.Height / 2));
            }

            g.FillRectangle(UpperBrush(buttonState, upperRect), upperRect);
            g.FillRectangle(LowerBrush(buttonState, lowerRect), lowerRect);

            Rectangle borderRect = new Rectangle(position.X, position.Y, position.Width - BorderWidth(buttonState), position.Height - BorderWidth(buttonState));
            Pen       thePen     = new Pen(BorderColor(buttonState), BorderWidth(buttonState));

            g.DrawRectangle(thePen, borderRect);
            thePen.Dispose();

            Rectangle textBounds;

            if (buttonImage == null)
            {
                textBounds = new Rectangle(
                    position.X + 2,
                    position.Y + 2,
                    position.Width - 4,
                    position.Height - 4);
            }
            else
            {
                //There is an image, calculate the the width from the max height
                int imageHeight = position.Height - 10;

                double imageRatio = (double)buttonImage.Width / (double)buttonImage.Height;
                int    imageWidth = (int)(imageRatio * (double)imageHeight);

                Rectangle imagePosition = new Rectangle(position.X + 5, position.Y + 5, imageWidth, imageHeight);
                textBounds = new Rectangle(imagePosition.Right + 2, position.Y + 2, position.Width - imagePosition.Width - 10, position.Height - 4);

                g.DrawImage(buttonImage, imagePosition, new Rectangle(0, 0, buttonImage.Width, buttonImage.Height), GraphicsUnit.Pixel);
            }

            StringFormat format = new StringFormat();

            format.LineAlignment = StringAlignment.Center;
            format.Alignment     = StringAlignment.Center;
            format.FormatFlags   = StringFormatFlags.NoClip
                                   | StringFormatFlags.FitBlackBox | StringFormatFlags.NoWrap;

            if (referencePosition != null)
            {
                double xRatio = (double)position.Width / (double)referencePosition.Value.Width;
                double yRatio = (double)position.Height / (double)referencePosition.Value.Height;
                textFont = ScaledFont(textFont, xRatio, yRatio, text, textBounds, g, format);
            }

            using (Brush frontBrush = new SolidBrush(FontColor(buttonState)))
            {
                g.DrawString(text, textFont, frontBrush,
                             textBounds, format);
                frontBrush.Dispose();
                textFont.Dispose();
            }
        }
 private bool AnyStateHasStatus(Painter.State state)
 {
     return(thumbState == state || lowerButtonState == state ||
            upperButtonState == state || beforeThumbState == state ||
            afterThumbState == state);
 }
 private void ResetAllButtonState()
 {
     _moveThumbStart = null;
     _thumbState = Painter.State.Normal;
     _lowerButtonState = Painter.State.Normal;
     _upperButtonState = Painter.State.Normal;
     _beforeThumbState = Painter.State.Normal;
     _afterThumbState = Painter.State.Normal;
 }
        protected override void OnMouseMove(MouseEventArgs e)
        {
            base.OnMouseMove(e);

            //The thumb gets actively moved by the mouse
            if (moveThumbStart != null)
            {
                int offset = e.Y - moveThumbStart.Value.Y;
                //Find the nearest valid thumb position for Y + offset and translate it
                //to the corresponding value
                double barHeight         = ClientSize.Height - 4 - 2 * 30 - moveThumbRectStart.Height;
                double smallChangeHeight = barHeight / (double)(maximum - minimum);


                double lastOffset         = Math.Abs(offset);
                int    currentValIncrease = 0;
                while (true)
                {
                    if (offset > 0)
                    {
                        currentValIncrease++;
                    }
                    else
                    {
                        currentValIncrease--;
                    }

                    double currentOffset = Math.Abs((double)smallChangeHeight * (double)currentValIncrease - (double)offset);
                    if (currentOffset > lastOffset || (currentOffset == 0 && lastOffset == 0))
                    {
                        break;
                    }

                    lastOffset = currentOffset;
                }
                if (currentValIncrease > 1)
                {
                    SetValue(moveThumbValueStart + currentValIncrease - 1);
                }
                else if (currentValIncrease < -1)
                {
                    SetValue(moveThumbValueStart + currentValIncrease + 1);
                }
                return;
            }

            if (AnyStateHasStatus(Painter.State.Pressed))
            {
                return;
            }


            if (RectUpperButton().Contains(e.Location) && upperButtonState != Painter.State.Hover)
            {
                ResetAllButtonState();
                upperButtonState = Painter.State.Hover;
                Invalidate();
            }
            else if (RectLowerButton().Contains(e.Location) && lowerButtonState != Painter.State.Hover)
            {
                ResetAllButtonState();
                lowerButtonState = Painter.State.Hover;
                Invalidate();
            }
            else if (currentThumbPosition.Contains(e.Location) && thumbState != Painter.State.Hover)
            {
                ResetAllButtonState();
                thumbState = Painter.State.Hover;
                Invalidate();
            }
            else if (beforeThumb.Contains(e.Location) && beforeThumbState != Painter.State.Hover)
            {
                ResetAllButtonState();
                beforeThumbState = Painter.State.Hover;
                Invalidate();
            }
            else if (afterThumb.Contains(e.Location) && afterThumbState != Painter.State.Hover)
            {
                ResetAllButtonState();
                afterThumbState = Painter.State.Hover;
                Invalidate();
            }
        }
        protected virtual void RecalcBrushes(Rectangle position, Painter.State state)
        {
            if (lastPosition == null || lastPosition.Value != position || lastState == null || lastState.Value != state)
            {
                lastState = state;
                if (state == State.Hover)
                {
                    if (borderPen != null)
                    {
                        borderPen.Dispose();
                        borderPen = null;
                    }
                    borderPen = new Pen(Color.FromArgb(0x3c, 0x7f, 0xb1), 1);
                }
                else if (state == State.Pressed)
                {
                    if (borderPen != null)
                    {
                        borderPen.Dispose();
                        borderPen = null;
                    }
                    borderPen = new Pen(Color.FromArgb(0x18, 0x59, 0x8a), 1);
                }
                else
                {
                    if (borderPen != null)
                    {
                        borderPen.Dispose();
                        borderPen = null;
                    }
                    borderPen = new Pen(Color.FromArgb(0x9a, 0x9a, 0x9a), 1);
                }

                if (leftBrush != null)
                {
                    leftBrush.Dispose();
                    leftBrush = null;
                }
                leftBounds = new Rectangle(position.X, position.Y, 8, position.Height);
                leftBrush  = CreateLeftBrush(leftBounds, state);

                if (middleBrush != null)
                {
                    middleBrush.Dispose();
                    middleBrush = null;
                }
                middleBounds = new Rectangle(leftBounds.Right, leftBounds.Y, (int)((float)position.Width - 16), position.Height);
                middleBrush  = CreateMiddleBrush(middleBounds, state);

                if (rightBrush != null)
                {
                    rightBrush.Dispose();
                    rightBrush = null;
                }
                rightBounds = new Rectangle(middleBounds.Right, leftBounds.Y, 8, position.Height);
                rightBrush  = CreateRightBrush(rightBounds, state);

                upperGradientPath = new GraphicsPath();
                upperGradientPath.AddLine(position.X + 8, position.Y + 1, position.X + 8, position.Y + 5);
                upperGradientPath.AddLine(position.X + 8, position.Y + 5, middleBounds.Right, position.Y + 5);
                upperGradientPath.AddLine(middleBounds.Right, position.Y + 5, rightBounds.Right - 1, position.Y + 1);
                upperGradientPath.CloseAllFigures();

                upperGradientRect = new Rectangle(position.X + 8, position.Y + 1, 10, 4);
                if (upperGradientBrush != null)
                {
                    upperGradientBrush.Dispose();
                    upperGradientBrush = null;
                }

                upperGradientBrush = new LinearGradientBrush(upperGradientRect, Color.FromArgb(237, 237, 237), Color.FromArgb(221, 221, 224), LinearGradientMode.Vertical);

                lastPosition = position;
            }
        }
        protected override void OnMouseDown(MouseEventArgs e)
        {
            base.OnMouseDown(e);

            if (RectUpperButton().Contains(e.Location) && _upperButtonState != Painter.State.Pressed)
            {
                ScrollAndActivateTimer(ScrollActionEnum.Up);
                ResetAllButtonState();
                _upperButtonState = Painter.State.Pressed;
                Invalidate();
            }
            else if (RectLowerButton().Contains(e.Location) && _lowerButtonState != Painter.State.Pressed)
            {
                ScrollAndActivateTimer(ScrollActionEnum.Down);
                ResetAllButtonState();
                _lowerButtonState = Painter.State.Pressed;
                Invalidate();
            }
            else if (_currentThumbPosition.Contains(e.Location) && _thumbState != Painter.State.Pressed)
            {
                ResetAllButtonState();
                _thumbState = Painter.State.Pressed;
                _moveThumbStart = e.Location;
                _moveThumbValueStart = _currentValue;
                _moveThumbRectStart = _currentThumbPosition;
                Invalidate();
            }
            else if (_beforeThumb.Contains(e.Location) && _beforeThumbState != Painter.State.Pressed)
            {
                ScrollAndActivateTimer(ScrollActionEnum.PageUp);
                ResetAllButtonState();
                _beforeThumbState = Painter.State.Pressed;
                Invalidate();
            }
            else if (_afterThumb.Contains(e.Location) && _afterThumbState != Painter.State.Pressed)
            {
                ScrollAndActivateTimer(ScrollActionEnum.PageDown);
                ResetAllButtonState();
                _afterThumbState = Painter.State.Pressed;
                Invalidate();
            }
        }
        protected override void OnMouseMove(MouseEventArgs e)
        {
            base.OnMouseMove(e);

            //The thumb gets actively moved by the mouse
            if (_moveThumbStart != null)
            {
                int offset = e.Y - _moveThumbStart.Value.Y;
                //Find the nearest valid thumb position for Y + offset and translate it
                //to the corresponding value
                double barHeight = ClientSize.Height - 4 - 2 * 30 - _moveThumbRectStart.Height;
                double smallChangeHeight = barHeight / (double)(_maximum - _minimum);


                double lastOffset = Math.Abs(offset);
                int currentValIncrease = 0;
                while (true)
                {
                    if (offset > 0)
                        currentValIncrease++;
                    else
                        currentValIncrease--;

                    double currentOffset = Math.Abs( (double)smallChangeHeight * (double)currentValIncrease - (double)offset);
                    if (currentOffset > lastOffset || (currentOffset == 0 && lastOffset == 0))
                        break;

                    lastOffset = currentOffset;

                }
                if (currentValIncrease > 1)
                    SetValue(_moveThumbValueStart + currentValIncrease - 1);
                else if (currentValIncrease < -1)
                    SetValue(_moveThumbValueStart + currentValIncrease + 1);
                return;
            }

            if (AnyStateHasStatus(Painter.State.Pressed))
                return;


            if (RectUpperButton().Contains(e.Location) && _upperButtonState != Painter.State.Hover)
            {
                ResetAllButtonState();
                _upperButtonState = Painter.State.Hover;
                Invalidate();
            }
            else if (RectLowerButton().Contains(e.Location) && _lowerButtonState != Painter.State.Hover)
            {
                ResetAllButtonState();
                _lowerButtonState = Painter.State.Hover;
                Invalidate();
            }
            else if (_currentThumbPosition.Contains(e.Location) && _thumbState != Painter.State.Hover)
            {
                ResetAllButtonState();
                _thumbState = Painter.State.Hover;
                Invalidate();
            }
            else if (_beforeThumb.Contains(e.Location) && _beforeThumbState != Painter.State.Hover)
            {
                ResetAllButtonState();
                _beforeThumbState = Painter.State.Hover;
                Invalidate();
            }
            else if (_afterThumb.Contains(e.Location) && _afterThumbState != Painter.State.Hover)
            {
                ResetAllButtonState();
                _afterThumbState = Painter.State.Hover;
                Invalidate();
            }
        }
 protected override Color FontColor(Painter.State state)
 {
     return(Color.FromArgb(0x46, 0x46, 0x46));
 }