protected override void OnPaint(PaintEventArgs e)
        {
            e.Graphics.SmoothingMode = SmoothingMode.AntiAlias;

            PaintBack(e);

            Rectangle upperButton = RectUpperButton();
            Rectangle lowerButton = RectLowerButton();

            upperButtonPainter.Paint(e.Graphics, upperButton, upperButtonState, "", null, Font, null);
            lowerButtonPainter.Paint(e.Graphics, lowerButton, lowerButtonState, "", null, Font, null);

            if (currentThumbPosition.Height > 0)
            {
                GetThumbPainter().Paint(e.Graphics, currentThumbPosition, thumbState, "", null, Font, null);
            }
        }
 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);
 }
        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);
            }
            else
            {
                //maximize height
                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);
        }