예제 #1
0
        /// <summary>
        /// Implement the display of the value's representation.</summary>
        /// <param name="g">The Graphics object</param>
        /// <param name="area">Rectangle delimiting area to paint</param>
        public override void PaintValue(Graphics g, Rectangle area)
        {
            int textOffset = 0;
            int left       = area.Left + Theme.Padding.Left;

            if (ShowSlider)
            {
                // draw track
                float slideY = area.Y + area.Height / 2;
                g.DrawLine(Theme.SliderTrackPen, left, slideY, left + SliderWidth, slideY);

                // draw thumb
                float t              = (Value - Min) / (Max - Min);
                float thumbX         = left + t * SliderWidth;
                var   thumbRectangle = new Rectangle((int)thumbX - 8, (int)area.Top, 18, 18);
                if (TrackBarRenderer.IsSupported)
                {
                    TrackBarRenderer.DrawBottomPointingThumb(g, thumbRectangle, TrackBarThumbState.Normal);
                }
                else // visual styles may be disabled by the user in the operating system, roll our own
                {
                    thumbRectangle = new Rectangle((int)thumbX - 4, (int)area.Top, 8, 16);
                    DrawThumb(g, thumbRectangle, TrackBarThumbState.Normal);
                }

                textOffset = SliderWidth + Theme.Padding.Left;
            }

            string valueString = ToString();

            g.DrawString(valueString, Theme.Font, Theme.TextBrush, left + textOffset, area.Top);
        }
        // Paint by MetroFramework Library
        protected override void OnPaint(PaintEventArgs e)
        {
            //e.Graphics.FillRectangle( Brushes.Silver, ClientRectangle);
            TrackBarRenderer.DrawHorizontalTrack(e.Graphics, ClientRectangle);
            TrackBarRenderer.DrawHorizontalThumb(e.Graphics, ClientRectangle, System.Windows.Forms.VisualStyles.TrackBarThumbState.Normal);
            //var g = e.Graphics;

            //base.OnPaint( e );

            //int trackX = (int) ( ( ( ( double ) this.Value ) / ( ( double ) this.Maximum ) ) * ( double ) this.Maximum );

            //using ( SolidBrush b = new SolidBrush( Color.Silver ) )
            //{
            //	Rectangle barRect = new Rectangle( trackX + 7, Height / 2 - 2, Width - trackX + 7, 4 );
            //	g.FillRectangle( b, barRect );
            //}

            //using ( SolidBrush b = new SolidBrush( Color.Blue ) )
            //{
            //	Rectangle barRect = new Rectangle( 0, Height / 2 - 2, trackX, 4 );
            //	g.FillRectangle( b, barRect );

            //	Rectangle thumbRect = new Rectangle( trackX, Height / 2 - 8, 6, 16 );
            //	g.FillRectangle( b, thumbRect );
            //}
        }
예제 #3
0
        private void DrawSlider(Graphics g, TrackBarThumbState state)
        {
            int sliderLocation;

            if (ZoomValue < DefaultValue)
            {
                int   regionWidth = Width / 2 - SliderWidth / 2;
                float scale       = (float)regionWidth / (DefaultValue - MinValue);
                sliderLocation = (int)Math.Round(scale * (ZoomValue - MinValue)) + SliderWidth / 2;
            }
            else
            {
                int   regionWidth = Width / 2 - SliderWidth / 2;
                float scale       = (float)regionWidth / (MaxValue - DefaultValue);
                sliderLocation = (int)Math.Round(scale * (ZoomValue - DefaultValue)) + Width / 2;
            }

            int       top    = Height / 2 - SliderHeight / 2;
            int       left   = sliderLocation - SliderWidth / 2;
            Rectangle bounds = new Rectangle(left, top, SliderWidth, SliderHeight);

            if (TrackBarRenderer.IsSupported && !MonoHelper.IsRunningOnMono)
            {
                TrackBarRenderer.DrawBottomPointingThumb(g, bounds, state);
            }
            else
            {
                bounds.X     += 1;
                bounds.Width -= 3;
                g.FillRectangle(SystemBrushes.ControlLightLight, bounds);
                g.DrawRectangle(linePen, bounds);
            }
        }
예제 #4
0
        protected override void OnPaint(PaintEventArgs e)
        {
            // If there is an image and it has a location,
            // paint it when the Form is repainted.
            base.OnPaint(e);

            if (!TrackBarRenderer.IsSupported)
            {
                this.Parent.Text = "CustomTrackBar Disabled";
                return;
            }

            this.Parent.Text = "CustomTrackBar Enabled";
            TrackBarRenderer.DrawHorizontalTrack(e.Graphics, trackRectangle);
            TrackBarRenderer.DrawTopPointingThumb(e.Graphics, thumbRectangle, thumbState);
            TrackBarRenderer.DrawHorizontalTicks(e.Graphics, ticksRectangle, numberTicks, EdgeStyle.Raised);

            //using ( var g = e.Graphics )
            //{
            //    g.SmoothingMode = SmoothingMode.AntiAlias;
            //    g.TextRenderingHint = TextRenderingHint.AntiAlias;

            //    Rectangle rect = e.ClipRectangle;
            //    float cY = rect.Height / 2.0f - rect.Top;
            //    Pen pen = new Pen(Color.AliceBlue, 6);
            //    Brush brush = new SolidBrush( Color.AliceBlue );
            //    g.DrawLine( pen, rect.Left, cY - 3, rect.Right, cY - 3 );
            //    g.DrawRectangle( Pens.AliceBlue, 0, cY - 3, rect.Width, 6 );
            //    g.FillRectangle( brush, rect );
            //}
            e.Graphics.FillRectangle(new SolidBrush(Color.AliceBlue), e.ClipRectangle);
            e.Graphics.DrawString(Text, Font, new SolidBrush(ForeColor), ClientRectangle);
        }
예제 #5
0
        /// <summary>
        /// Draws the ticks using the TrackBarRenderer.
        /// </summary>
        /// <param name="gfx">Graphics object.</param>
        private void DrawRenderTicks(Graphics gfx)
        {
            if (TickStyle != TickStyle.None)
            {
                if (IsHorizontal())
                {
                    if ((_tickStyle == TickStyle.Both) || (_tickStyle == TickStyle.BottomRight))
                    {
                        TrackBarRenderer.DrawHorizontalTicks(gfx, _ticksRectangleBottomRight, _numberTicks, _tickEdgeStyle);
                    }

                    if ((_tickStyle == TickStyle.Both) || (_tickStyle == TickStyle.TopLeft))
                    {
                        TrackBarRenderer.DrawHorizontalTicks(gfx, _ticksRectangleTopLeft, _numberTicks, _tickEdgeStyle);
                    }
                }
                else
                {
                    if ((_tickStyle == TickStyle.Both) || (_tickStyle == TickStyle.BottomRight))
                    {
                        TrackBarRenderer.DrawVerticalTicks(gfx, _ticksRectangleBottomRight, _numberTicks, _tickEdgeStyle);
                    }

                    if ((_tickStyle == TickStyle.Both) || (_tickStyle == TickStyle.TopLeft))
                    {
                        TrackBarRenderer.DrawVerticalTicks(gfx, _ticksRectangleTopLeft, _numberTicks, _tickEdgeStyle);
                    }
                }
            }
        }
예제 #6
0
파일: form1.cs 프로젝트: zhimaqiao51/docs
        //<Snippet2>
        //<Snippet6>
        // Calculate the sizes of the bar, thumb, and ticks rectangle.
        private void SetupTrackBar()
        {
            if (!TrackBarRenderer.IsSupported)
            {
                return;
            }

            using (Graphics g = this.CreateGraphics())
            {
                // Calculate the size of the track bar.
                trackRectangle.X      = ClientRectangle.X + 2;
                trackRectangle.Y      = ClientRectangle.Y + 28;
                trackRectangle.Width  = ClientRectangle.Width - 4;
                trackRectangle.Height = 4;

                // Calculate the size of the rectangle in which to
                // draw the ticks.
                ticksRectangle.X      = trackRectangle.X + 4;
                ticksRectangle.Y      = trackRectangle.Y - 8;
                ticksRectangle.Width  = trackRectangle.Width - 8;
                ticksRectangle.Height = 4;

                tickSpace = ((float)ticksRectangle.Width - 1) /
                            ((float)numberTicks - 1);

                // Calculate the size of the thumb.
                thumbRectangle.Size =
                    TrackBarRenderer.GetTopPointingThumbSize(g,
                                                             TrackBarThumbState.Normal);

                thumbRectangle.X = CurrentTickXCoordinate();
                thumbRectangle.Y = trackRectangle.Y - 8;
            }
        }
        protected override void OnPaint(PaintEventArgs e)
        {
            if (Application.RenderWithVisualStyles)
            {
                ButtonRenderer.DrawParentBackground(e.Graphics, e.ClipRectangle, this);
            }
            else
            {
                base.OnPaintBackground(e);
            }

            if (Application.RenderWithVisualStyles)
            {
                TrackBarRenderer.DrawHorizontalTrack(e.Graphics, new Rectangle(e.ClipRectangle.Left + 5, 5 + (e.ClipRectangle.Height - 10 - 4) / 2, e.ClipRectangle.Width - 12, 4));
                TrackBarRenderer.DrawHorizontalTicks(e.Graphics, new Rectangle(e.ClipRectangle.Left + 5, (e.ClipRectangle.Height - 5), e.ClipRectangle.Width - 12, 4), (Max + 1 - Min), EdgeStyle.Bump);
                TrackBarRenderer.DrawBottomPointingThumb(e.Graphics, GetThumbRectangle(), !Enabled ? TrackBarThumbState.Disabled : Pressed ? TrackBarThumbState.Pressed : Hot ? TrackBarThumbState.Hot : TrackBarThumbState.Normal);
            }
            else
            {
                e.Graphics.DrawRectangle(SystemPens.ControlDark, new Rectangle(e.ClipRectangle.Left + 5, 5 + (e.ClipRectangle.Height - 10 - 4) / 2, e.ClipRectangle.Width - 12, 3));
                e.Graphics.DrawLine(SystemPens.ButtonHighlight, e.ClipRectangle.Left + 5, 5 + (e.ClipRectangle.Height - 8) / 2, e.ClipRectangle.Left + 5 + e.ClipRectangle.Width - 12, 5 + (e.ClipRectangle.Height - 8) / 2);
                e.Graphics.DrawLine(SystemPens.ControlDarkDark, e.ClipRectangle.Left + 6, 5 + (e.ClipRectangle.Height - 12) / 2, e.ClipRectangle.Left + 5 + e.ClipRectangle.Width - 13, 5 + (e.ClipRectangle.Height - 12) / 2);
                e.Graphics.DrawLine(SystemPens.ButtonFace, e.ClipRectangle.Left + 6, 5 + (e.ClipRectangle.Height - 14) / 2, e.ClipRectangle.Left + 5 + e.ClipRectangle.Width - 13, 5 + (e.ClipRectangle.Height - 14) / 2);

                Rectangle tickRect = new Rectangle(e.ClipRectangle.Left + 5, (e.ClipRectangle.Height - 5), e.ClipRectangle.Width - 10, 4);
                int       tickLeft = tickRect.Left;
                int       add      = tickRect.Width / (Max - Min);

                using (Pen tickPen = new Pen(SystemColors.ControlText, 2.0f))
                {
                    for (int i = 0; i < (Max - Min) + 1; i++)
                    {
                        if (i < (Max - Min))
                        {
                            add = (tickRect.Right - tickLeft) / (Max - (Min + i));
                        }
                        e.Graphics.DrawLine(tickPen, tickLeft, tickRect.Bottom - 4, tickLeft, tickRect.Bottom);
                        tickLeft += add;
                    }
                }

                Rectangle thumbRect = GetThumbRectangle();
                if (Pressed)
                {
                    e.Graphics.FillPolygon(SystemBrushes.ControlDarkDark, new Point[] { new Point(thumbRect.Left, thumbRect.Top), new Point(thumbRect.Right, thumbRect.Top), new Point(thumbRect.Right, thumbRect.Bottom - 5), new Point(thumbRect.Left + thumbRect.Width / 2, thumbRect.Bottom), new Point(thumbRect.Left, thumbRect.Bottom - 5) });
                    e.Graphics.FillPolygon(SystemBrushes.ButtonHighlight, new Point[] { new Point(thumbRect.Left, thumbRect.Top), new Point(thumbRect.Right - 1, thumbRect.Top), new Point(thumbRect.Right - 1, thumbRect.Bottom - 5), new Point(thumbRect.Left + thumbRect.Width / 2, thumbRect.Bottom - 1), new Point(thumbRect.Left - 1 + thumbRect.Width / 2, thumbRect.Bottom - 1), new Point(thumbRect.Left, thumbRect.Bottom - 5) });
                    e.Graphics.FillPolygon(SystemBrushes.ButtonShadow, new Point[] { new Point(thumbRect.Left + 1, thumbRect.Top + 1), new Point(thumbRect.Right - 1, thumbRect.Top + 1), new Point(thumbRect.Right - 1, thumbRect.Bottom - 5), new Point(thumbRect.Left + thumbRect.Width / 2, thumbRect.Bottom - 1), new Point(thumbRect.Left + 1, thumbRect.Bottom - 5) });
                    e.Graphics.FillPolygon(SystemBrushes.ControlLightLight, new Point[] { new Point(thumbRect.Left + 1, thumbRect.Top + 1), new Point(thumbRect.Right - 2, thumbRect.Top + 1), new Point(thumbRect.Right - 2, thumbRect.Bottom - 5), new Point(thumbRect.Left + thumbRect.Width / 2, thumbRect.Bottom - 2), new Point(thumbRect.Left - 1 + thumbRect.Width / 2, thumbRect.Bottom - 2), new Point(thumbRect.Left + 1, thumbRect.Bottom - 5) });
                }
                else
                {
                    e.Graphics.FillPolygon(SystemBrushes.ControlDarkDark, new Point[] { new Point(thumbRect.Left, thumbRect.Top), new Point(thumbRect.Right, thumbRect.Top), new Point(thumbRect.Right, thumbRect.Bottom - 5), new Point(thumbRect.Left + thumbRect.Width / 2, thumbRect.Bottom), new Point(thumbRect.Left, thumbRect.Bottom - 5) });
                    e.Graphics.FillPolygon(SystemBrushes.ButtonHighlight, new Point[] { new Point(thumbRect.Left, thumbRect.Top), new Point(thumbRect.Right - 1, thumbRect.Top), new Point(thumbRect.Right - 1, thumbRect.Bottom - 5), new Point(thumbRect.Left + thumbRect.Width / 2, thumbRect.Bottom - 1), new Point(thumbRect.Left - 1 + thumbRect.Width / 2, thumbRect.Bottom - 1), new Point(thumbRect.Left, thumbRect.Bottom - 5) });
                    e.Graphics.FillPolygon(SystemBrushes.ButtonShadow, new Point[] { new Point(thumbRect.Left + 1, thumbRect.Top + 1), new Point(thumbRect.Right - 1, thumbRect.Top + 1), new Point(thumbRect.Right - 1, thumbRect.Bottom - 5), new Point(thumbRect.Left + thumbRect.Width / 2, thumbRect.Bottom - 1), new Point(thumbRect.Left + 1, thumbRect.Bottom - 5) });
                    e.Graphics.FillPolygon(SystemBrushes.ButtonFace, new Point[] { new Point(thumbRect.Left + 1, thumbRect.Top + 1), new Point(thumbRect.Right - 2, thumbRect.Top + 1), new Point(thumbRect.Right - 2, thumbRect.Bottom - 5), new Point(thumbRect.Left + thumbRect.Width / 2, thumbRect.Bottom - 2), new Point(thumbRect.Left - 1 + thumbRect.Width / 2, thumbRect.Bottom - 2), new Point(thumbRect.Left + 1, thumbRect.Bottom - 5) });
                }
            }
        }
예제 #8
0
        private Rectangle GetThumbRectangle(double relativeValue, Graphics g)
        {
            Size size   = TrackBarRenderer.GetBottomPointingThumbSize(g, TrackBarThumbState.Normal);
            int  border = Convert.ToInt32(size.Width / 2);
            int  w      = GetTrackRectangle(border).Width;
            int  x      = Convert.ToInt32(0 / (Maximum - Minimum) * w + relativeValue * w);

            int y = Convert.ToInt32((Height - size.Height) / 2);

            return(new Rectangle(new Point(x, y), size));
        }
예제 #9
0
 /// <summary>
 /// Draws the TrackBar using TrackBarRenderer
 /// </summary>
 /// <param name="gfx">The Graphics object to draw on.</param>
 private void DrawRendererTrackBar(Graphics gfx)
 {
     if (IsHorizontal())
     {
         TrackBarRenderer.DrawHorizontalTrack(gfx, _trackRectangle);
     }
     else
     {
         TrackBarRenderer.DrawVerticalTrack(gfx, _trackRectangle);
     }
 }
예제 #10
0
 // Draw the track bar.
 protected override void OnPaint(PaintEventArgs e)
 {
     TrackBarRenderer.DrawHorizontalTrack(e.Graphics, trackRectangle);
     TrackBarRenderer.DrawTopPointingThumb(e.Graphics, thumbRectangleL, thumbStateL);
     TrackBarRenderer.DrawTopPointingThumb(e.Graphics, thumbRectangleR, thumbStateR);
     e.Graphics.FillRectangle(Brushes.OrangeRed, barRectangleC);
     if (numberTicksUser != 0)
     {
         TrackBarRenderer.DrawHorizontalTicks(e.Graphics, ticksRectangle, numberTicks, EdgeStyle.Raised);
     }
 }
예제 #11
0
        private Rectangle GetThumbRectangle(double relativeValue, Graphics g)
        {
            Size size   = TrackBarRenderer.GetBottomPointingThumbSize(g, System.Windows.Forms.VisualStyles.TrackBarThumbState.Normal);
            int  border = Convert.ToInt32(size.Width / 2);
            int  w      = this.GetTrackRectangle(border).Width;
            int  x      = Convert.ToInt32(Math.Abs(this.Minimum) / (this.Maximum - this.Minimum) * w + relativeValue * w);

            int y = Convert.ToInt32((this.Height - size.Height) / 2);

            return(new Rectangle(new Point(x, y), size));
        }
예제 #12
0
    private Rectangle GetThumbRectangle(double relativeValue, Graphics g)
    {
        var size   = TrackBarRenderer.GetBottomPointingThumbSize(g, TrackBarThumbState.Normal);
        var border = Convert.ToInt32(size.Width / 2.0);
        var w      = this.GetTrackRectangle(border).Width;
        var x      = Convert.ToInt32(Math.Abs(this.Minimum) / (this.Maximum - this.Minimum) * w + relativeValue * w);

        var y = Convert.ToInt32((this.Height - size.Height) / 2.0);

        return(new Rectangle(new Point(x, y), size));
    }
예제 #13
0
        /// <summary>
        /// Calculate the sizes of the bar and thumbs rectangles.
        /// </summary>
        private void SetupTrackBar()
        {
            using (Graphics g = this.CreateGraphics())
            {
                if (TrackBarRenderer.IsSupported)
                //return;
                {
                    // Calculate the size of the thumbs.
                    _leftThumbBounds.Size =
                        TrackBarRenderer.GetTopPointingThumbSize(g,
                                                                 TrackBarThumbState.Normal);

                    _rightThumbBounds.Size =
                        TrackBarRenderer.GetTopPointingThumbSize(g,
                                                                 TrackBarThumbState.Normal);

                    _caretThumbBounds.Size =
                        TrackBarRenderer.GetTopPointingThumbSize(g,
                                                                 TrackBarThumbState.Normal);
                }
                else
                {
                    // Calculate the size of the thumbs.
                    _leftThumbBounds.Size  = new Size(10, this.Height);
                    _rightThumbBounds.Size = new Size(10, this.Height);
                    _caretThumbBounds.Size = new Size(10, this.Height);
                }

                _timeTextSize = g.MeasureString("00:00:000", TimeFont);
            }
            _halfThumbWidth = _leftThumbBounds.Width / 2;
            // Calculate the size of the track bar.
            _trackBounds.X = ClientRectangle.X + _halfThumbWidth +
                             this.Padding.Left + (int)_timeTextSize.Width;
            _trackBounds.Y = ClientRectangle.Y + _leftThumbBounds.Height / 2 +
                             this.Padding.Top;// +(int)_timeTextSize.Height;
            _trackBounds.Width = ClientRectangle.Width - _rightThumbBounds.Width -
                                 this.Padding.Left - this.Padding.Right - 2 * (int)_timeTextSize.Width;
            _trackBounds.Height = 4;

            _leftThumbBounds.X = CurrentLeftThumbXCoordinate() - _halfThumbWidth +
                                 this.Padding.Left + (int)_timeTextSize.Width;
            _rightThumbBounds.X = CurrentRightThumbXCoordinate() - _halfThumbWidth + this.Padding.Left
                                  + (int)_timeTextSize.Width;
            _caretThumbBounds.X = CurrentCaretThumbXCoordinate() - _halfThumbWidth +
                                  this.Padding.Left + (int)_timeTextSize.Width;

            _leftThumbBounds.Y  = this.Padding.Top; // +(int)_timeTextSize.Height;
            _rightThumbBounds.Y = this.Padding.Top; // +(int)_timeTextSize.Height;
            _caretThumbBounds.Y = this.Padding.Top; // +(int)_timeTextSize.Height;
        }
예제 #14
0
        protected override void OnPaint(System.Windows.Forms.PaintEventArgs e)
        {
            base.OnPaint(e);

            Size      thumbSize = this.GetThumbRectangle(0, e.Graphics).Size;
            Rectangle trackRect = this.GetTrackRectangle(Convert.ToInt32(thumbSize.Width / 2));
            Rectangle ticksRect = trackRect;

            ticksRect.Offset(0, 15);

            TrackBarRenderer.DrawVerticalTrack(e.Graphics, trackRect);
            TrackBarRenderer.DrawHorizontalTicks(e.Graphics, ticksRect, this.Maximum - this.Minimum + 1, System.Windows.Forms.VisualStyles.EdgeStyle.Etched);
            TrackBarRenderer.DrawBottomPointingThumb(e.Graphics, this.GetLeftThumbRectangle(e.Graphics), leftThumbState);
            TrackBarRenderer.DrawBottomPointingThumb(e.Graphics, this.GetRightThumbRectangle(e.Graphics), rightThumbState);
        }
예제 #15
0
파일: form1.cs 프로젝트: zhimaqiao51/docs
        //<Snippet4>
        // Draw the track bar.
        protected override void OnPaint(PaintEventArgs e)
        {
            if (!TrackBarRenderer.IsSupported)
            {
                this.Parent.Text = "CustomTrackBar Disabled";
                return;
            }

            this.Parent.Text = "CustomTrackBar Enabled";
            TrackBarRenderer.DrawHorizontalTrack(e.Graphics,
                                                 trackRectangle);
            TrackBarRenderer.DrawTopPointingThumb(e.Graphics,
                                                  thumbRectangle, thumbState);
            TrackBarRenderer.DrawHorizontalTicks(e.Graphics,
                                                 ticksRectangle, numberTicks, EdgeStyle.Raised);
        }
예제 #16
0
        private void RenderScene(Graphics graphics)
        {
            graphics.Clear(Color.CornflowerBlue);

            if (board == null)
            {
                return;
            }

            Rectangle rect, highlight;
            int       width, height, cx;

            foreach (var square in board)
            {
                if (square.Cleared)
                {
                    continue;
                }

                rect = Rectangle.Truncate(square.Bounds);
                if (highlightLeft == square || highlightRight == square)
                {
                    highlight = rect;
                    highlight.Inflate(3, 3);
                    graphics.FillRectangle(Brushes.Goldenrod, highlight);
                }

                string text = square.Value.ToString();
                ButtonRenderer.DrawButton(graphics, rect, text, buttonFont, square.Selected, square.State);

                if (square.Selected)
                {
                    width  = rect.Width / 2;
                    height = rect.Height / 2;
                    cx     = rect.X + (rect.Width / 2);

                    rect.X      = cx - (width / 2);
                    rect.Y     -= height;
                    rect.Width  = width;
                    rect.Height = height;

                    TrackBarRenderer.DrawBottomPointingThumb(graphics, rect, TrackBarThumbState.Hot);
                }
            }
        }
예제 #17
0
        public void DrawThumb(Graphics g)
        {
            if (TrackBarRenderer.IsSupported)
            {
                TrackBarRenderer.DrawHorizontalThumb(g, Slider.ThumbRect,
                                                     (Slider.MouseInThumbRegion)
                                                                                                                 ? (Control.MouseButtons & MouseButtons.Left) != 0
                                                                                                                           ? TrackBarThumbState.Pressed
                                                                                                                           : TrackBarThumbState.Hot
                                                                                                                 : TrackBarThumbState.Normal);
            }
            else
            {
                LinearGradientBrush brush;
                if (Slider.MouseInThumbRegion)
                {
                    if ((Control.MouseButtons & MouseButtons.Left) != 0)
                    {
                        brush = new LinearGradientBrush(new Point(0, Slider.ThumbRect.Y),
                                                        new Point(0, Slider.ThumbRect.Y + Slider.ThumbRect.Height), Color.White,
                                                        SystemColors.Highlight);
                    }
                    else
                    {
                        brush = new LinearGradientBrush(new Point(0, Slider.ThumbRect.Y),
                                                        new Point(0, Slider.ThumbRect.Y + Slider.ThumbRect.Height), SystemColors.Highlight,
                                                        Color.White);
                    }
                }
                else
                {
                    brush = new LinearGradientBrush(new Point(0, Slider.ThumbRect.Y),
                                                    new Point(0, Slider.ThumbRect.Y + Slider.ThumbRect.Height), Color.Gray, Color.White);
                }
                g.FillRectangle(brush, Slider.ThumbRect);

                g.DrawRectangle(Pens.Black, Slider.ThumbRect);
            }
        }
        protected override void OnPaint(PaintEventArgs e)
        {
            Graphics g     = e.Graphics;
            Brush    brush = new SolidBrush(this.ForeColor);
            Pen      pen   = new Pen(brush);

            //            DrawTrack(g, pen);

            int padding      = 2;
            int ticks        = _Maximum - _Minimum + 1;
            int sliderpixels = this.Width - 2 * (5 + padding);
            int tickheight   = 3;

//            _ThumbRect = new Rectangle(padding + (_Value - _Minimum) * (sliderpixels - 1) / (ticks - 1), tickheight, 11, 21);
            int xval = padding + ((sliderpixels - 1) * (_Value - _Minimum) + (ticks / 2)) / (ticks - 1);

            _ThumbRect = new Rectangle(xval, tickheight, 11, 21);

            if (!Enabled)
            {
                _ThumbState = TrackBarThumbState.Disabled;
            }

            TrackBarRenderer.DrawHorizontalTrack(g, new Rectangle(padding, 10, this.Width - 2 * padding, 4));
            TrackBarRenderer.DrawBottomPointingThumb(g, _ThumbRect, _ThumbState);
//            DrawHorizontalTrack(g, new Rectangle(padding, 10, this.Width - 2 * padding, 6));
//            DrawBottomPointingThumb(g, _ThumbRect, _ThumbState);
            EdgeStyle edge;

            edge = EdgeStyle.Bump;
            TrackBarRenderer.DrawHorizontalTicks(g, new Rectangle(5 + padding - 1, 26, sliderpixels + 1, tickheight), ticks, edge);
//            TrackBarRenderer.DrawHorizontalTicks(g, new Rectangle(5 + padding - 1, 26, sliderpixels + 1, 4), 2, edge);
//            DrawTicks(g, new Rectangle(5 + padding, 26, sliderpixels, tickheight), ticks);

            if (Focused && !(Parent is SlideSelector))
            {
                System.Windows.Forms.ControlPaint.DrawFocusRectangle(g, new Rectangle(0, 0, this.Width - 1, this.Height - 1));
            }
        }
예제 #19
0
        protected override void OnPaint(PaintEventArgs e)
        {
            base.OnPaint(e);

            Size      thumbSize = GetThumbRectangle(0, e.Graphics).Size;
            Rectangle trackRect = GetTrackRectangle(Convert.ToInt32(thumbSize.Width / 2));
            Rectangle ticksRect = trackRect;

            ticksRect.Offset(0, 15);

            Rectangle leftRectangle      = GetLeftThumbRectangle(e.Graphics);
            Rectangle rightRectangle     = GetRightThumbRectangle(e.Graphics);
            Rectangle highlightRectangle = new Rectangle((leftRectangle.X + leftRectangle.Width / 2), trackRect.Y, (rightRectangle.X + rightRectangle.Width / 2) - (leftRectangle.X + leftRectangle.Width / 2), trackRect.Height);

            TrackBarRenderer.DrawVerticalTrack(e.Graphics, trackRect);
            TrackBarRenderer.DrawHorizontalTicks(e.Graphics, ticksRect, (Maximum - Minimum) / TickNum + 1, EdgeStyle.Etched);

            e.Graphics.FillRectangle(new SolidBrush(Color.FromArgb(64, 141, 219)), highlightRectangle);

            TrackBarRenderer.DrawBottomPointingThumb(e.Graphics, GetLeftThumbRectangle(e.Graphics), leftThumbState);
            TrackBarRenderer.DrawBottomPointingThumb(e.Graphics, GetRightThumbRectangle(e.Graphics), rightThumbState);
        }
예제 #20
0
        /// <summary>
        /// Calculates the sizes of the bar, thumb, and ticks rectangle for a vertical track bar.
        /// </summary>
        private void SetupVerticalTrackBar()
        {
            using (Graphics g = this.CreateGraphics())
            {
                _trackRectangle.X      = ClientRectangle.Width / 2;
                _trackRectangle.Y      = ClientRectangle.Y + _trackBarMargin;
                _trackRectangle.Width  = _trackBarHeight;
                _trackRectangle.Height = ClientRectangle.Height - (_trackBarMargin * 2);

                // Calculate the size of the rectangle in which to
                // draw the ticks.
                _ticksRectangleBottomRight.Y      = _trackRectangle.Y;
                _ticksRectangleBottomRight.X      = _trackRectangle.X + 8; // ticks on the right
                _ticksRectangleBottomRight.Width  = 4;
                _ticksRectangleBottomRight.Height = _trackRectangle.Height;

                _ticksRectangleTopLeft   = _ticksRectangleBottomRight;
                _ticksRectangleTopLeft.X = _trackRectangle.X - 8; // ticks on the left

                _tickSpace = ((float)_ticksRectangleBottomRight.Height - 1) /
                             ((float)_numberTicks - 1);

                // Calculate the size of the thumb.
                // w = 21.0, h = 11.0
                if (TrackBarRenderer.IsSupported)
                {
                    _thumbRectangle.Size =
                        TrackBarRenderer.GetRightPointingThumbSize(g,
                                                                   TrackBarThumbState.Normal);
                }
                else
                {
                    _thumbRectangle.Size = new SizeF(21.0f, 11.0f);
                }

                UpdateThumbRectangle();
                _thumbRectangle.X = _trackRectangle.X - 8;
            }
        }
예제 #21
0
        protected override void OnPaint(PaintEventArgs e)
        {
            if (_oldValue != Value)
            {
                _oldValue = Value;
                if (ValueChanged != null)
                {
                    ValueChanged();
                }
            }

            base.OnPaint(e);

            var trackBarWidth = Width - 16;
            var thumbWidth    = 7;
            //TrackBarRenderer.DrawBottomPointingThumb(e.Graphics, e.ClipRectangle, TrackBarThumbState.Normal);
            //base.OnPaint(e);
            var position = Maximum == 0 ? 0 : (int)Math.Floor(((Value - Minimum) / (double)Maximum) * (double)(trackBarWidth - thumbWidth));

            TrackBarRenderer.DrawHorizontalTrack(e.Graphics, new Rectangle(8, 6, trackBarWidth, 3));
            TrackBarRenderer.DrawHorizontalThumb(e.Graphics, new Rectangle(8 + position, 2, thumbWidth, 12), TrackBarThumbState.Normal);
        }
예제 #22
0
        /// <summary>
        /// Implement the display of the value's representation.</summary>
        /// <param name="g">The Graphics object</param>
        /// <param name="area">Rectangle delimiting area to paint</param>
        public override void PaintValue(Graphics g, Rectangle area)
        {
            int textOffset = 0;
            int left       = area.Left + Theme.Padding.Left;

            if (ShowSlider)
            {
                // draw track
                float slideY = area.Y + area.Height / 2;
                g.DrawLine(Theme.SliderTrackPen, left, slideY, left + SliderWidth, slideY);

                // draw thumb
                float t              = (Value - Min) / (Max - Min);
                float thumbX         = left + t * SliderWidth;
                var   thumbRectangle = new Rectangle((int)thumbX - 8, (int)area.Top, 18, 18);
                TrackBarRenderer.DrawBottomPointingThumb(g, thumbRectangle, TrackBarThumbState.Normal);
                textOffset = SliderWidth + Theme.Padding.Left;
            }

            string valueString = ToString();

            g.DrawString(valueString, Theme.Font, Theme.TextBrush, left + textOffset, area.Top);
        }
예제 #23
0
        // Draw the track bar.
        protected override void OnPaint(PaintEventArgs e)
        {
            if (!TrackBarRenderer.IsSupported)
            {
                this.Parent.Text = "CustomTrackBar Disabled";
                return;
            }

            this.Parent.Text = "CustomTrackBar Enabled";
            TrackBarRenderer.DrawHorizontalTrack(e.Graphics,
                                                 trackRectangle);
            TrackBarRenderer.DrawTopPointingThumb(e.Graphics,
                                                  thumbRectangle, thumbState);

            /* TrackBarRenderer.DrawHorizontalTicks(e.Graphics,
             *   ticksRectangle, numberTicks, EdgeStyle.Raised);*/

            Color      myColor = Color.FromArgb(32, 32, 32);
            SolidBrush myBrush = new SolidBrush(myColor);

            e.Graphics.FillRectangle(myBrush, trackRectangle);
            e.Graphics.FillRectangle(myBrush, thumbRectangle);
        }
예제 #24
0
        private void XTrackBar_Paint(object sender, PaintEventArgs e)
        {
            Graphics  g     = e.Graphics;
            Rectangle track = new Rectangle(padx, (int)(this.Height * 0.4), innerWidth - 1, (int)(this.Height * 0.2));
            Rectangle thumb = new Rectangle(thumbX, 3 + pady, thumbwidth, this.Height - 6);

            if (TrackBarRenderer.IsSupported)
            {
                TrackBarRenderer.DrawHorizontalTrack(g, track);
                if (Enabled)
                {
                    g.FillRectangle(new SolidBrush(Color.FromArgb(32, 0, 0, 128)), track.X, track.Y, thumb.X, track.Height);
                    TrackBarRenderer.DrawHorizontalThumb(g, thumb, thumbState);
                }
            }
            else
            {
                g.DrawLine(SystemPens.ButtonShadow, track.Left, track.Top, track.Right, track.Top);
                g.DrawLine(SystemPens.ButtonShadow, track.Left, track.Top, track.Left, track.Bottom);
                g.DrawLine(SystemPens.ButtonHighlight, track.Right, track.Bottom, track.Right, track.Top);
                g.DrawLine(SystemPens.ButtonHighlight, track.Right, track.Bottom, track.Left, track.Bottom);

                if (Enabled)
                {
                    g.FillRectangle(new SolidBrush(Color.FromArgb(32, 0, 0, 128)), track.X, track.Y, thumb.X, track.Height);
                    g.FillRectangle(thumbState == TrackBarThumbState.Normal ? SystemBrushes.ButtonFace : SystemBrushes.ButtonHighlight, thumb);
                    g.DrawLine(SystemPens.ButtonHighlight, thumb.Left, thumb.Top, thumb.Right, thumb.Top);
                    g.DrawLine(SystemPens.ButtonHighlight, thumb.Left, thumb.Top, thumb.Left, thumb.Bottom);
                    g.DrawLine(SystemPens.ButtonShadow, thumb.Right, thumb.Bottom, thumb.Right, thumb.Top);
                    g.DrawLine(SystemPens.ButtonShadow, thumb.Right, thumb.Bottom, thumb.Left, thumb.Bottom);
                }
            }
            if (Enabled && ThumbText != null)
            {
                TextRenderer.DrawText(g, ThumbText, this.Font, thumb, this.ForeColor, TextFormatFlags.NoClipping | TextFormatFlags.NoPrefix | TextFormatFlags.VerticalCenter | TextFormatFlags.HorizontalCenter | TextFormatFlags.NoPadding);
            }
        }
예제 #25
0
        // Calculate the sizes of the bar, thumb, and ticks rectangle.
        private void SetupTrackBar()
        {
            if (!TrackBarRenderer.IsSupported)
            {
                return;
            }

            using (Graphics g = this.CreateGraphics())
            {
                // Calculate the size of the track bar.
                trackRectangle.X      = ClientRectangle.X + 2;
                trackRectangle.Y      = ClientRectangle.Y + 8;
                trackRectangle.Width  = ClientRectangle.Width - 4;
                trackRectangle.Height = 4;

                // Calculate the size of the rectangle in which to
                // draw the ticks.
                ticksRectangle.X      = trackRectangle.X + 3;
                ticksRectangle.Y      = trackRectangle.Y - 8;
                ticksRectangle.Width  = trackRectangle.Width - 6;
                ticksRectangle.Height = 4;

                if (numberTicksUser == 0)
                {
                    currentTickPositionL = currentTickPositionL * (ticksRectangle.Width - 1) / (numberTicks - 1);
                    currentTickPositionR = currentTickPositionR * (ticksRectangle.Width - 1) / (numberTicks - 1);
                    numberTicks          = ticksRectangle.Width;
                }
                else
                {
                    currentTickPositionL = currentTickPositionL * (numberTicksUser - 1) / (numberTicks - 1);
                    currentTickPositionR = currentTickPositionR * (numberTicksUser - 1) / (numberTicks - 1);
                    numberTicks          = numberTicksUser;
                }

                tickSpace = ((float)ticksRectangle.Width - 1) /
                            ((float)numberTicks - 1);

                // Calculate the size of the thumb.
                thumbRectangleL.Size =
                    TrackBarRenderer.GetTopPointingThumbSize(g,
                                                             thumbStateL);

                thumbRectangleL.X = CurrentTickXCoordinate(currentTickPositionL);
                thumbRectangleL.Y = trackRectangle.Y - 8;



                // Calculate the size of the thumb.
                thumbRectangleR.Size =
                    TrackBarRenderer.GetTopPointingThumbSize(g,
                                                             thumbStateR);

                thumbRectangleR.X = CurrentTickXCoordinate(currentTickPositionR);
                thumbRectangleR.Y = trackRectangle.Y - 8;

                barRectangleC.X      = (thumbRectangleR.X + thumbRectangleL.X + thumbRectangleL.Width) / 2;
                barRectangleC.Y      = thumbRectangleR.Y;
                barRectangleC.Width  = 1;
                barRectangleC.Height = thumbRectangleR.Height;

                if (ValueChanged != null)
                {
                    ValueChanged(this, new EventArgs());
                }
            }
        }
예제 #26
0
        /// <summary>
        /// Overriden. Occurs when the control is redrawn.
        /// Draws the whole track bar and its thumbs, along with the timing.
        /// If section start and end thumbs are hot or pressed, show tooltip
        /// with timing information.
        /// </summary>
        /// <param name="e">A <see cref="PaintEventArgs"/> that contains the event data. </param>
        protected override void OnPaint(PaintEventArgs e)
        {
            //Visual Styles have to be enabled.
            if (!TrackBarRenderer.IsSupported)
            {
                _trackBounds.Y -= 2;
                e.Graphics.DrawRectangle(Pens.Black, _trackBounds);
                _trackBounds.Y += 2;
                //return;
            }
            else
            {
                //Draws the track line.
                TrackBarRenderer.DrawHorizontalTrack(e.Graphics, _trackBounds);
            }

            //Draws the interior of the trackline in green, if it is in the section between start and end thumb.
            Rectangle fillRectangle = _trackBounds;

            fillRectangle.Inflate(-1, -1);
            fillRectangle.X     = CurrentLeftThumbXCoordinate() + this.Padding.Left + (int)_timeTextSize.Width;
            fillRectangle.Width = CurrentRightThumbXCoordinate() - fillRectangle.X +
                                  this.Padding.Left + (int)_timeTextSize.Width;

            if (TrackBarRenderer.IsSupported)
            {
                e.Graphics.FillRectangle(Brushes.Green, fillRectangle);

                //Draw the thumbs.
                TrackBarRenderer.DrawHorizontalThumb(e.Graphics,
                                                     _leftThumbBounds, _leftThumbState);
                TrackBarRenderer.DrawHorizontalThumb(e.Graphics,
                                                     _rightThumbBounds, _rightThumbState);
                if (_showCaret)
                {
                    TrackBarRenderer.DrawTopPointingThumb(e.Graphics,
                                                          _caretThumbBounds, _caretThumbState);
                }
            }
            else
            {
                fillRectangle.Y      -= 2;
                fillRectangle.Height += 1;
                e.Graphics.FillRectangle(Brushes.Green, fillRectangle);

                e.Graphics.FillRectangle(Brushes.Green, _leftThumbBounds);
                e.Graphics.DrawRectangle(Pens.DarkGray, _leftThumbBounds);
                e.Graphics.FillRectangle(Brushes.Green, _rightThumbBounds);
                e.Graphics.DrawRectangle(Pens.DarkGray, _rightThumbBounds);
                if (_showCaret)
                {
                    e.Graphics.FillEllipse(Brushes.Red, _caretThumbBounds);
                    e.Graphics.DrawEllipse(Pens.DarkGray, _caretThumbBounds);
                }
            }
            //If track bar is in caret mode,
            //show tooltip with the section start time above the center of the left thumb
            //if the mouse is over it.
            if (_showCaret)
            {
                if (_leftThumbState == TrackBarThumbState.Hot || _leftThumbState == TrackBarThumbState.Pressed)
                {
                    _toolTipStartTime.Show(ConvertToSeconds(this.SectionStartTime), this,
                                           CurrentLeftThumbXCoordinate() + this.Padding.Left +
                                           (int)_timeTextSize.Width - (int)(_timeTextSize.Width / 2),
                                           (int)(_leftThumbBounds.Top - _timeTextSize.Height - 2));
                }
                else
                {
                    _toolTipStartTime.Hide(this);
                }
            }

            //If track bar is in caret mode,
            //show tooltips with the section end time above the center of the right thumb
            //if the mouse is over it.
            if (_showCaret)
            {
                if (_rightThumbState == TrackBarThumbState.Hot || _rightThumbState == TrackBarThumbState.Pressed)
                {
                    _toolTipEndTime.Show(ConvertToSeconds(this.SectionEndTime), this,
                                         CurrentRightThumbXCoordinate() + this.Padding.Left +
                                         (int)_timeTextSize.Width - (int)(_timeTextSize.Width / 2),
                                         (int)(_leftThumbBounds.Top - _timeTextSize.Height - 2));
                }
                else
                {
                    _toolTipEndTime.Hide(this);
                }
            }


            //Depending on caret drawing mode show either the track bars duration value
            //at the right of the control or the section end time value.
            int rightTime = 0;

            if (_showCaret)
            {
                //Use the Duration time string at the right of the control.
                rightTime = this.Duration;
            }
            else
            {
                //Use the section end time string at the right of the control.
                rightTime = this.SectionEndTime;
            }

            //Draw the string at the right of the control.
            e.Graphics.DrawString(ConvertToSeconds(rightTime), RangeTrackBar.TimeFont,
                                  RangeTrackBar.TimeFontBrush,
                                  this.Padding.Left + (int)_timeTextSize.Width + _trackBounds.Width + _leftThumbBounds.Width,
                                  this.Padding.Top + _leftThumbBounds.Height / 2 -
                                  _timeTextSize.Height / 2);//+ (int)_timeTextSize.Height);

            //Depending on caret drawing mode show either the carets time value
            //at the left of the control or the section start time value.
            int leftTime = 0;

            if (_showCaret)
            {
                //Use the current time string at the left of the control.
                leftTime = this.CurrentTime;
            }
            else
            {
                //Use the section start time string at the left of the control.
                leftTime = this.SectionStartTime;
            }

            //Draw the string at the left of the control.
            e.Graphics.DrawString(ConvertToSeconds(leftTime), RangeTrackBar.TimeFont,
                                  RangeTrackBar.TimeFontBrush,
                                  this.Padding.Left,
                                  this.Padding.Top + _leftThumbBounds.Height / 2 -
                                  _timeTextSize.Height / 2);// + (int)_timeTextSize.Height);
        }
예제 #27
0
 public override void Render(Graphics g)
 {
     TrackBarRenderer.DrawHorizontalTrack(g, new Rectangle(0, (Slider.Height / 2) - 2, Slider.Width, 4));
     TrackBarRenderer.DrawHorizontalThumb(g, Slider.ThumbRect, TrackBarThumbState.Normal);
 }
예제 #28
0
파일: ResizeBar.cs 프로젝트: nxzzkj/lazyiot
            public void Draw(Graphics g, Rectangle bounds, Rectangle grip, TrackBarThumbState state)
            {
                ResizeBarVisualStyle style = Owner.VisualStyle;

                if (!renderWithVisualStyles)
                {
                    if (style == ResizeBarVisualStyle.ModernStrong)
                    {
                        style = ResizeBarVisualStyle.ClassicStrong;
                    }
                    else if (style == ResizeBarVisualStyle.ModernSubtle)
                    {
                        style = ResizeBarVisualStyle.ClassicSubtle;
                    }
                    else if (style == ResizeBarVisualStyle.ModernNone)
                    {
                        style = ResizeBarVisualStyle.ClassicNone;
                    }
                }

                if (style == ResizeBarVisualStyle.ModernStrong || style == ResizeBarVisualStyle.ModernNone)
                {
                    if (state == TrackBarThumbState.Disabled)
                    {
                        rBarDisabled.DrawBackground(g, bounds);
                    }
                    else
                    {
                        if (style == ResizeBarVisualStyle.ModernNone)
                        {
                            rBar1.DrawBackground(g, bounds);
                        }
                        else
                        {
                            TrackBarRenderer.DrawHorizontalThumb(g, bounds, state);
                        }
                    }

                    if (Owner.ShowGrip)
                    {
                        DrawGrip(g, grip);
                    }
                }
                else if (style == ResizeBarVisualStyle.ModernSubtle)
                {
                    if (state == TrackBarThumbState.Disabled)
                    {
                        rBarDisabled.DrawBackground(g, bounds);
                        if (Owner.ShowGrip)
                        {
                            rBarDisabled.DrawBackground(g, grip);
                            DrawGrip(g, grip, -5);
                        }
                    }
                    else
                    {
                        rBar1.DrawBackground(g, bounds);
                        if (Owner.ShowGrip)
                        {
                            TrackBarRenderer.DrawHorizontalThumb(g, grip, state);
                            DrawGrip(g, grip, -5);
                        }
                    }
                }
                else if (style == ResizeBarVisualStyle.ClassicStrong || style == ResizeBarVisualStyle.ClassicSubtle)
                {
                    Brush bg = brushNormal;
                    if (state == TrackBarThumbState.Disabled)
                    {
                        bg = brushDisabled;
                    }
                    else
                    {
                        if (style == ResizeBarVisualStyle.ClassicStrong)
                        {
                            if (state == TrackBarThumbState.Hot)
                            {
                                bg = SystemBrushes.GradientInactiveCaption;
                            }
                            else if (state == TrackBarThumbState.Pressed)
                            {
                                bg = SystemBrushes.GradientActiveCaption;
                            }
                        }
                    }

                    g.FillRectangle(bg, bounds);
                    ControlPaint.DrawBorder(g, bounds, SystemColors.ActiveBorder, ButtonBorderStyle.Solid);

                    if (Owner.ShowGrip)
                    {
                        var r = grip;
                        if (style == ResizeBarVisualStyle.ClassicSubtle)
                        {
                            bg = (state == TrackBarThumbState.Disabled ? brushDisabled : brushNormal);
                            if (state == TrackBarThumbState.Hot)
                            {
                                bg = SystemBrushes.GradientInactiveCaption;
                            }
                            else if (state == TrackBarThumbState.Pressed)
                            {
                                bg = SystemBrushes.GradientActiveCaption;
                            }

                            g.FillRectangle(bg, grip);
                            ControlPaint.DrawBorder(g, grip, SystemColors.ActiveBorder, ButtonBorderStyle.Solid);

                            r.Width -= r.Height;
                            r.X     += r.Height / 2;
                        }

                        int numLines = Math.Max(2, bounds.Height / 10);
                        int h        = 3 * numLines + (numLines - 1);
                        int dy       = (bounds.Height - h) / 2;

                        for (int i = 0; i < numLines; i++)
                        {
                            g.DrawLine(SystemPens.ControlLight, r.X, r.Y + dy, r.X + r.Width, r.Y + dy);
                            g.DrawLine(SystemPens.ControlDark, r.X, r.Y + dy + 2, r.X + r.Width, r.Y + dy + 2);
                            dy += 4;
                        }
                    }
                }
                else if (style == ResizeBarVisualStyle.ClassicNone)
                {
                    int x1 = bounds.X;
                    int y1 = bounds.Y;
                    int x2 = bounds.X + bounds.Width;
                    int y2 = bounds.Y + bounds.Height;

                    g.FillRectangle(SystemBrushes.Control, bounds);

                    g.DrawLine(SystemPens.ControlLight, x1 - 1, y1, x1 - 1, y2);
                    g.DrawLine(SystemPens.ControlLightLight, x1, y1, x1, y2);

                    g.DrawLine(SystemPens.ScrollBar, x1, y2 - 2, x2, y2 - 2);
                    g.DrawLine(SystemPens.ControlDark, x1, y2 - 1, x2, y2 - 1);

                    g.DrawLine(SystemPens.ControlLight, x1, y1, x2, y1);
                    g.DrawLine(SystemPens.ControlLightLight, x1, y1 + 1, x2, y1 + 1);

                    g.DrawLine(SystemPens.ScrollBar, x2 - 2, y1, x2 - 2, y2 - 2);
                    g.DrawLine(SystemPens.ControlDark, x2 - 1, y1, x2 - 1, y2);
                }
            }
예제 #29
0
        protected override void OnPaint(PaintEventArgs e)
        {
            base.OnPaint(e);

            if (comboBox1.SelectedItem == null)
            {
                return;
            }

            Graphics g = e.Graphics;
            Image    i = Image.FromFile(@"accessories-character-map.png");
            Font     f = new Font("Microsoft Sans Serif", 8);

            switch (comboBox1.SelectedItem.ToString())
            {
            case "ButtonRenderer":
                ButtonRenderer.DrawButton(g, new Rectangle(0, 125, 75, 23), System.Windows.Forms.VisualStyles.PushButtonState.Pressed);
                ButtonRenderer.DrawButton(g, new Rectangle(0, 25, 75, 23), System.Windows.Forms.VisualStyles.PushButtonState.Default);
                ButtonRenderer.DrawButton(g, new Rectangle(0, 50, 75, 23), System.Windows.Forms.VisualStyles.PushButtonState.Disabled);
                ButtonRenderer.DrawButton(g, new Rectangle(0, 75, 75, 23), System.Windows.Forms.VisualStyles.PushButtonState.Hot);
                ButtonRenderer.DrawButton(g, new Rectangle(0, 100, 75, 23), System.Windows.Forms.VisualStyles.PushButtonState.Normal);

                ButtonRenderer.DrawButton(g, new Rectangle(100, 125, 75, 23), true, System.Windows.Forms.VisualStyles.PushButtonState.Pressed);
                ButtonRenderer.DrawButton(g, new Rectangle(100, 25, 75, 23), true, System.Windows.Forms.VisualStyles.PushButtonState.Default);
                ButtonRenderer.DrawButton(g, new Rectangle(100, 50, 75, 23), true, System.Windows.Forms.VisualStyles.PushButtonState.Disabled);
                ButtonRenderer.DrawButton(g, new Rectangle(100, 75, 75, 23), true, System.Windows.Forms.VisualStyles.PushButtonState.Hot);
                ButtonRenderer.DrawButton(g, new Rectangle(100, 100, 75, 23), true, System.Windows.Forms.VisualStyles.PushButtonState.Normal);


                ButtonRenderer.DrawButton(g, new Rectangle(200, 125, 75, 23), i, new Rectangle(200, 128, 16, 16), true, System.Windows.Forms.VisualStyles.PushButtonState.Pressed);
                ButtonRenderer.DrawButton(g, new Rectangle(200, 25, 75, 23), i, new Rectangle(203, 28, 16, 16), true, System.Windows.Forms.VisualStyles.PushButtonState.Default);
                ButtonRenderer.DrawButton(g, new Rectangle(200, 50, 75, 23), i, new Rectangle(203, 53, 16, 16), false, System.Windows.Forms.VisualStyles.PushButtonState.Disabled);
                ButtonRenderer.DrawButton(g, new Rectangle(200, 75, 75, 23), i, new Rectangle(203, 78, 16, 16), true, System.Windows.Forms.VisualStyles.PushButtonState.Hot);
                ButtonRenderer.DrawButton(g, new Rectangle(200, 100, 75, 23), i, new Rectangle(203, 103, 16, 16), false, System.Windows.Forms.VisualStyles.PushButtonState.Normal);


                ButtonRenderer.DrawButton(g, new Rectangle(300, 125, 75, 23), "Hi there button!", f, true, System.Windows.Forms.VisualStyles.PushButtonState.Pressed);
                ButtonRenderer.DrawButton(g, new Rectangle(300, 25, 75, 23), "Hi there button!", f, true, System.Windows.Forms.VisualStyles.PushButtonState.Default);
                ButtonRenderer.DrawButton(g, new Rectangle(300, 50, 75, 23), "Hi there button!", f, false, System.Windows.Forms.VisualStyles.PushButtonState.Disabled);
                ButtonRenderer.DrawButton(g, new Rectangle(300, 75, 75, 23), "Hi there button!", f, true, System.Windows.Forms.VisualStyles.PushButtonState.Hot);
                ButtonRenderer.DrawButton(g, new Rectangle(300, 100, 75, 23), "Hi there button!", f, false, System.Windows.Forms.VisualStyles.PushButtonState.Normal);

                ButtonRenderer.DrawButton(g, new Rectangle(400, 125, 75, 23), "Hi there button!", f, TextFormatFlags.Left & TextFormatFlags.WordEllipsis, true, System.Windows.Forms.VisualStyles.PushButtonState.Pressed);
                ButtonRenderer.DrawButton(g, new Rectangle(400, 25, 75, 23), "Hi there button!", f, TextFormatFlags.Left & TextFormatFlags.WordEllipsis, true, System.Windows.Forms.VisualStyles.PushButtonState.Default);
                ButtonRenderer.DrawButton(g, new Rectangle(400, 50, 75, 23), "Hi there button!", f, TextFormatFlags.Left & TextFormatFlags.WordEllipsis, false, System.Windows.Forms.VisualStyles.PushButtonState.Disabled);
                ButtonRenderer.DrawButton(g, new Rectangle(400, 75, 75, 23), "Hi there button!", f, TextFormatFlags.Left & TextFormatFlags.WordEllipsis, true, System.Windows.Forms.VisualStyles.PushButtonState.Hot);
                ButtonRenderer.DrawButton(g, new Rectangle(400, 100, 75, 23), "Hi there button!", f, TextFormatFlags.Left & TextFormatFlags.WordEllipsis, false, System.Windows.Forms.VisualStyles.PushButtonState.Normal);

                ButtonRenderer.DrawButton(g, new Rectangle(500, 125, 75, 23), "Hi there button!", f, i, new Rectangle(500, 128, 16, 16), true, System.Windows.Forms.VisualStyles.PushButtonState.Pressed);
                ButtonRenderer.DrawButton(g, new Rectangle(500, 25, 75, 23), "Hi there button!", f, i, new Rectangle(500, 28, 16, 16), true, System.Windows.Forms.VisualStyles.PushButtonState.Default);
                ButtonRenderer.DrawButton(g, new Rectangle(500, 50, 75, 23), "Hi there button!", f, i, new Rectangle(500, 53, 16, 16), false, System.Windows.Forms.VisualStyles.PushButtonState.Disabled);
                ButtonRenderer.DrawButton(g, new Rectangle(500, 75, 75, 23), "Hi there button!", f, i, new Rectangle(500, 78, 16, 16), true, System.Windows.Forms.VisualStyles.PushButtonState.Hot);
                ButtonRenderer.DrawButton(g, new Rectangle(500, 100, 75, 23), "Hi there button!", f, i, new Rectangle(500, 103, 16, 16), false, System.Windows.Forms.VisualStyles.PushButtonState.Normal);

                ButtonRenderer.DrawButton(g, new Rectangle(600, 125, 75, 23), "Hi there button!", f, TextFormatFlags.Left & TextFormatFlags.WordEllipsis, i, new Rectangle(600, 128, 16, 16), true, System.Windows.Forms.VisualStyles.PushButtonState.Pressed);
                ButtonRenderer.DrawButton(g, new Rectangle(600, 25, 75, 23), "Hi there button!", f, TextFormatFlags.Left & TextFormatFlags.WordEllipsis, i, new Rectangle(600, 28, 16, 16), true, System.Windows.Forms.VisualStyles.PushButtonState.Default);
                ButtonRenderer.DrawButton(g, new Rectangle(600, 50, 75, 23), "Hi there button!", f, TextFormatFlags.Left & TextFormatFlags.WordEllipsis, i, new Rectangle(600, 53, 16, 16), false, System.Windows.Forms.VisualStyles.PushButtonState.Disabled);
                ButtonRenderer.DrawButton(g, new Rectangle(600, 75, 75, 23), "Hi there button!", f, TextFormatFlags.Left & TextFormatFlags.WordEllipsis, i, new Rectangle(600, 78, 16, 16), true, System.Windows.Forms.VisualStyles.PushButtonState.Hot);
                ButtonRenderer.DrawButton(g, new Rectangle(600, 100, 75, 23), "Hi there button!", f, TextFormatFlags.Left & TextFormatFlags.WordEllipsis, i, new Rectangle(600, 103, 16, 16), false, System.Windows.Forms.VisualStyles.PushButtonState.Normal);
                break;

            case "CheckBoxRenderer":
                CheckBoxRenderer.DrawCheckBox(g, new Point(5, 5), new Rectangle(8 + CheckBoxRenderer.GetGlyphSize(g, System.Windows.Forms.VisualStyles.CheckBoxState.UncheckedNormal).Width, 5, 75, 14), "checkBox1", f, TextFormatFlags.Default, i, new Rectangle(90, 4, 16, 16), false, System.Windows.Forms.VisualStyles.CheckBoxState.CheckedDisabled);
                CheckBoxRenderer.DrawCheckBox(g, new Point(5, 25), new Rectangle(8 + CheckBoxRenderer.GetGlyphSize(g, System.Windows.Forms.VisualStyles.CheckBoxState.UncheckedNormal).Width, 25, 75, 14), "checkBox1", f, TextFormatFlags.Default, i, new Rectangle(90, 24, 16, 16), false, System.Windows.Forms.VisualStyles.CheckBoxState.CheckedHot);
                CheckBoxRenderer.DrawCheckBox(g, new Point(5, 45), new Rectangle(8 + CheckBoxRenderer.GetGlyphSize(g, System.Windows.Forms.VisualStyles.CheckBoxState.UncheckedNormal).Width, 45, 75, 14), "checkBox1", f, TextFormatFlags.Default, i, new Rectangle(90, 44, 16, 16), true, System.Windows.Forms.VisualStyles.CheckBoxState.CheckedNormal);
                CheckBoxRenderer.DrawCheckBox(g, new Point(5, 65), new Rectangle(8 + CheckBoxRenderer.GetGlyphSize(g, System.Windows.Forms.VisualStyles.CheckBoxState.UncheckedNormal).Width, 65, 75, 14), "checkBox1", f, TextFormatFlags.Default, false, System.Windows.Forms.VisualStyles.CheckBoxState.CheckedPressed);
                CheckBoxRenderer.DrawCheckBox(g, new Point(5, 85), new Rectangle(8 + CheckBoxRenderer.GetGlyphSize(g, System.Windows.Forms.VisualStyles.CheckBoxState.UncheckedNormal).Width, 85, 75, 14), "checkBox1", f, TextFormatFlags.Default, i, new Rectangle(90, 84, 16, 16), true, System.Windows.Forms.VisualStyles.CheckBoxState.MixedDisabled);
                CheckBoxRenderer.DrawCheckBox(g, new Point(5, 105), System.Windows.Forms.VisualStyles.CheckBoxState.MixedHot);
                CheckBoxRenderer.DrawCheckBox(g, new Point(5, 125), new Rectangle(8 + CheckBoxRenderer.GetGlyphSize(g, System.Windows.Forms.VisualStyles.CheckBoxState.UncheckedNormal).Width, 125, 75, 14), "checkBox1", f, TextFormatFlags.Default, i, new Rectangle(90, 124, 16, 16), false, System.Windows.Forms.VisualStyles.CheckBoxState.MixedNormal);
                CheckBoxRenderer.DrawCheckBox(g, new Point(5, 145), new Rectangle(8 + CheckBoxRenderer.GetGlyphSize(g, System.Windows.Forms.VisualStyles.CheckBoxState.UncheckedNormal).Width, 145, 75, 14), "checkBox1", f, i, new Rectangle(90, 144, 16, 16), true, System.Windows.Forms.VisualStyles.CheckBoxState.MixedPressed);
                CheckBoxRenderer.DrawCheckBox(g, new Point(5, 165), new Rectangle(8 + CheckBoxRenderer.GetGlyphSize(g, System.Windows.Forms.VisualStyles.CheckBoxState.UncheckedNormal).Width, 165, 75, 14), "checkBox1", f, TextFormatFlags.Default, i, new Rectangle(90, 164, 16, 16), false, System.Windows.Forms.VisualStyles.CheckBoxState.UncheckedDisabled);
                CheckBoxRenderer.DrawCheckBox(g, new Point(5, 185), new Rectangle(8 + CheckBoxRenderer.GetGlyphSize(g, System.Windows.Forms.VisualStyles.CheckBoxState.UncheckedNormal).Width, 185, 75, 14), "checkBox1", f, TextFormatFlags.Default, i, new Rectangle(90, 184, 16, 16), false, System.Windows.Forms.VisualStyles.CheckBoxState.UncheckedHot);
                CheckBoxRenderer.DrawCheckBox(g, new Point(5, 205), new Rectangle(8 + CheckBoxRenderer.GetGlyphSize(g, System.Windows.Forms.VisualStyles.CheckBoxState.UncheckedNormal).Width, 205, 75, 14), "checkBox1", f, true, System.Windows.Forms.VisualStyles.CheckBoxState.UncheckedNormal);
                CheckBoxRenderer.DrawCheckBox(g, new Point(5, 225), new Rectangle(8 + CheckBoxRenderer.GetGlyphSize(g, System.Windows.Forms.VisualStyles.CheckBoxState.UncheckedNormal).Width, 225, 75, 14), "checkBox1", f, TextFormatFlags.Default, i, new Rectangle(90, 224, 16, 16), false, System.Windows.Forms.VisualStyles.CheckBoxState.UncheckedPressed);
                break;

            case "ComboBoxRenderer":
                if (!ComboBoxRenderer.IsSupported)
                {
                    g.DrawString("Visual Styles not enabled", f, Brushes.Black, 0, 0);
                    break;
                }
                ComboBoxRenderer.DrawTextBox(e.Graphics, new Rectangle(5, 5, 121, 21), System.Windows.Forms.VisualStyles.ComboBoxState.Normal);
                ComboBoxRenderer.DrawDropDownButton(e.Graphics, new Rectangle(109, 6, 16, 19), System.Windows.Forms.VisualStyles.ComboBoxState.Normal);
                ComboBoxRenderer.DrawTextBox(e.Graphics, new Rectangle(5, 35, 121, 21), this.Text, this.Font, System.Windows.Forms.VisualStyles.ComboBoxState.Hot);
                ComboBoxRenderer.DrawDropDownButton(e.Graphics, new Rectangle(109, 36, 16, 19), System.Windows.Forms.VisualStyles.ComboBoxState.Hot);
                ComboBoxRenderer.DrawTextBox(e.Graphics, new Rectangle(5, 65, 121, 21), this.Text, this.Font, new Rectangle(8, 65, 57, 21), System.Windows.Forms.VisualStyles.ComboBoxState.Disabled);
                ComboBoxRenderer.DrawDropDownButton(e.Graphics, new Rectangle(109, 66, 16, 19), System.Windows.Forms.VisualStyles.ComboBoxState.Disabled);
                ComboBoxRenderer.DrawTextBox(e.Graphics, new Rectangle(5, 95, 121, 21), this.Text, this.Font, TextFormatFlags.WordEllipsis, System.Windows.Forms.VisualStyles.ComboBoxState.Pressed);
                ComboBoxRenderer.DrawDropDownButton(e.Graphics, new Rectangle(109, 96, 16, 19), System.Windows.Forms.VisualStyles.ComboBoxState.Pressed);
                break;

            case "GroupBoxRenderer":
                Font f2 = new Font("Microsoft Sans Serif", 12);
                Font f3 = new Font("Microsoft Sans Serif", 14);
                Font f4 = new Font("Microsoft Sans Serif", 8);
                GroupBoxRenderer.DrawGroupBox(g, new Rectangle(5, 5, 150, 75), "My Group!", f, Color.Black, TextFormatFlags.Default, System.Windows.Forms.VisualStyles.GroupBoxState.Normal);
                GroupBoxRenderer.DrawGroupBox(g, new Rectangle(5, 105, 150, 75), "My Group!", f2, Color.Red, System.Windows.Forms.VisualStyles.GroupBoxState.Disabled);
                GroupBoxRenderer.DrawGroupBox(g, new Rectangle(5, 205, 150, 75), "My Group!", f3, TextFormatFlags.Default, System.Windows.Forms.VisualStyles.GroupBoxState.Normal);
                GroupBoxRenderer.DrawGroupBox(g, new Rectangle(5, 305, 150, 75), "My Group!", f4, System.Windows.Forms.VisualStyles.GroupBoxState.Disabled);
                GroupBoxRenderer.DrawGroupBox(g, new Rectangle(5, 405, 150, 75), System.Windows.Forms.VisualStyles.GroupBoxState.Normal);
                break;

            case "ProgressBarRenderer":
                if (!ProgressBarRenderer.IsSupported)
                {
                    g.DrawString("Visual Styles not enabled", f, Brushes.Black, 0, 0);
                    break;
                }
                g.DrawString("ChunkSpaceThickness: " + ProgressBarRenderer.ChunkSpaceThickness.ToString(), this.Font, Brushes.Black, 0, 0);
                g.DrawString("ChunkThickness: " + ProgressBarRenderer.ChunkThickness.ToString(), this.Font, Brushes.Black, 0, 20);

                ProgressBarRenderer.DrawHorizontalBar(g, new Rectangle(5, 40, 100, 20));
                ProgressBarRenderer.DrawHorizontalChunks(g, new Rectangle(7, 42, 47, 16));
                ProgressBarRenderer.DrawVerticalBar(g, new Rectangle(110, 40, 20, 100));
                ProgressBarRenderer.DrawVerticalChunks(g, new Rectangle(112, 42, 16, 47));
                break;

            case "RadioButtonRenderer":
                RadioButtonRenderer.DrawRadioButton(g, new Point(5, 5), new Rectangle(8 + RadioButtonRenderer.GetGlyphSize(g, System.Windows.Forms.VisualStyles.RadioButtonState.UncheckedNormal).Width, 5, 75, 14), "checkBox1", f, TextFormatFlags.Default, i, new Rectangle(90, 4, 16, 16), false, System.Windows.Forms.VisualStyles.RadioButtonState.CheckedDisabled);
                RadioButtonRenderer.DrawRadioButton(g, new Point(5, 25), new Rectangle(8 + RadioButtonRenderer.GetGlyphSize(g, System.Windows.Forms.VisualStyles.RadioButtonState.UncheckedNormal).Width, 25, 75, 14), "checkBox1", f, TextFormatFlags.Default, i, new Rectangle(90, 24, 16, 16), false, System.Windows.Forms.VisualStyles.RadioButtonState.CheckedHot);
                RadioButtonRenderer.DrawRadioButton(g, new Point(5, 45), new Rectangle(8 + RadioButtonRenderer.GetGlyphSize(g, System.Windows.Forms.VisualStyles.RadioButtonState.UncheckedNormal).Width, 45, 75, 14), "checkBox1", f, TextFormatFlags.Default, i, new Rectangle(90, 44, 16, 16), true, System.Windows.Forms.VisualStyles.RadioButtonState.CheckedNormal);
                RadioButtonRenderer.DrawRadioButton(g, new Point(5, 65), new Rectangle(8 + RadioButtonRenderer.GetGlyphSize(g, System.Windows.Forms.VisualStyles.RadioButtonState.UncheckedNormal).Width, 65, 75, 14), "checkBox1", f, TextFormatFlags.Default, false, System.Windows.Forms.VisualStyles.RadioButtonState.CheckedPressed);
                RadioButtonRenderer.DrawRadioButton(g, new Point(5, 85), new Rectangle(8 + RadioButtonRenderer.GetGlyphSize(g, System.Windows.Forms.VisualStyles.RadioButtonState.UncheckedNormal).Width, 85, 75, 14), "checkBox1", f, TextFormatFlags.Default, i, new Rectangle(90, 84, 16, 16), true, System.Windows.Forms.VisualStyles.RadioButtonState.UncheckedDisabled);
                RadioButtonRenderer.DrawRadioButton(g, new Point(5, 105), System.Windows.Forms.VisualStyles.RadioButtonState.UncheckedHot);
                RadioButtonRenderer.DrawRadioButton(g, new Point(5, 125), new Rectangle(8 + RadioButtonRenderer.GetGlyphSize(g, System.Windows.Forms.VisualStyles.RadioButtonState.UncheckedNormal).Width, 125, 75, 14), "checkBox1", f, TextFormatFlags.Default, i, new Rectangle(90, 124, 16, 16), false, System.Windows.Forms.VisualStyles.RadioButtonState.UncheckedNormal);
                RadioButtonRenderer.DrawRadioButton(g, new Point(5, 145), new Rectangle(8 + RadioButtonRenderer.GetGlyphSize(g, System.Windows.Forms.VisualStyles.RadioButtonState.UncheckedNormal).Width, 145, 75, 14), "checkBox1", f, i, new Rectangle(90, 144, 16, 16), true, System.Windows.Forms.VisualStyles.RadioButtonState.UncheckedPressed);
                break;

            case "ScrollBarRenderer":
                if (!ScrollBarRenderer.IsSupported)
                {
                    g.DrawString("Visual Styles not enabled", f, Brushes.Black, 0, 0);
                    break;
                }
                ScrollBarRenderer.DrawArrowButton(g, new Rectangle(5, 5, 18, 18), System.Windows.Forms.VisualStyles.ScrollBarArrowButtonState.DownDisabled);
                ScrollBarRenderer.DrawArrowButton(g, new Rectangle(25, 5, 18, 18), System.Windows.Forms.VisualStyles.ScrollBarArrowButtonState.DownHot);
                ScrollBarRenderer.DrawArrowButton(g, new Rectangle(45, 5, 18, 18), System.Windows.Forms.VisualStyles.ScrollBarArrowButtonState.DownNormal);
                ScrollBarRenderer.DrawArrowButton(g, new Rectangle(65, 5, 18, 18), System.Windows.Forms.VisualStyles.ScrollBarArrowButtonState.DownPressed);
                ScrollBarRenderer.DrawArrowButton(g, new Rectangle(85, 5, 18, 18), System.Windows.Forms.VisualStyles.ScrollBarArrowButtonState.LeftDisabled);
                ScrollBarRenderer.DrawArrowButton(g, new Rectangle(105, 5, 18, 18), System.Windows.Forms.VisualStyles.ScrollBarArrowButtonState.LeftHot);
                ScrollBarRenderer.DrawArrowButton(g, new Rectangle(125, 5, 18, 18), System.Windows.Forms.VisualStyles.ScrollBarArrowButtonState.LeftNormal);
                ScrollBarRenderer.DrawArrowButton(g, new Rectangle(145, 5, 18, 18), System.Windows.Forms.VisualStyles.ScrollBarArrowButtonState.LeftPressed);
                ScrollBarRenderer.DrawArrowButton(g, new Rectangle(165, 5, 18, 18), System.Windows.Forms.VisualStyles.ScrollBarArrowButtonState.RightDisabled);
                ScrollBarRenderer.DrawArrowButton(g, new Rectangle(185, 5, 18, 18), System.Windows.Forms.VisualStyles.ScrollBarArrowButtonState.RightHot);
                ScrollBarRenderer.DrawArrowButton(g, new Rectangle(205, 5, 18, 18), System.Windows.Forms.VisualStyles.ScrollBarArrowButtonState.RightNormal);
                ScrollBarRenderer.DrawArrowButton(g, new Rectangle(225, 5, 18, 18), System.Windows.Forms.VisualStyles.ScrollBarArrowButtonState.RightPressed);
                ScrollBarRenderer.DrawArrowButton(g, new Rectangle(245, 5, 18, 18), System.Windows.Forms.VisualStyles.ScrollBarArrowButtonState.UpDisabled);
                ScrollBarRenderer.DrawArrowButton(g, new Rectangle(265, 5, 18, 18), System.Windows.Forms.VisualStyles.ScrollBarArrowButtonState.UpHot);
                ScrollBarRenderer.DrawArrowButton(g, new Rectangle(285, 5, 18, 18), System.Windows.Forms.VisualStyles.ScrollBarArrowButtonState.UpNormal);
                ScrollBarRenderer.DrawArrowButton(g, new Rectangle(305, 5, 18, 18), System.Windows.Forms.VisualStyles.ScrollBarArrowButtonState.UpPressed);

                ScrollBarRenderer.DrawHorizontalThumb(g, new Rectangle(5, 25, 38, 18), System.Windows.Forms.VisualStyles.ScrollBarState.Disabled);
                ScrollBarRenderer.DrawHorizontalThumb(g, new Rectangle(45, 25, 38, 18), System.Windows.Forms.VisualStyles.ScrollBarState.Hot);
                ScrollBarRenderer.DrawHorizontalThumb(g, new Rectangle(85, 25, 38, 18), System.Windows.Forms.VisualStyles.ScrollBarState.Normal);
                ScrollBarRenderer.DrawHorizontalThumb(g, new Rectangle(125, 25, 38, 18), System.Windows.Forms.VisualStyles.ScrollBarState.Pressed);

                ScrollBarRenderer.DrawHorizontalThumbGrip(g, new Rectangle(5, 25, 38, 18), System.Windows.Forms.VisualStyles.ScrollBarState.Disabled);
                ScrollBarRenderer.DrawHorizontalThumbGrip(g, new Rectangle(45, 25, 38, 18), System.Windows.Forms.VisualStyles.ScrollBarState.Hot);
                ScrollBarRenderer.DrawHorizontalThumbGrip(g, new Rectangle(85, 25, 38, 18), System.Windows.Forms.VisualStyles.ScrollBarState.Normal);
                ScrollBarRenderer.DrawHorizontalThumbGrip(g, new Rectangle(125, 25, 38, 18), System.Windows.Forms.VisualStyles.ScrollBarState.Pressed);

                ScrollBarRenderer.DrawLeftHorizontalTrack(g, new Rectangle(5, 45, 38, 18), System.Windows.Forms.VisualStyles.ScrollBarState.Disabled);
                ScrollBarRenderer.DrawLeftHorizontalTrack(g, new Rectangle(45, 45, 38, 18), System.Windows.Forms.VisualStyles.ScrollBarState.Hot);
                ScrollBarRenderer.DrawLeftHorizontalTrack(g, new Rectangle(85, 45, 38, 18), System.Windows.Forms.VisualStyles.ScrollBarState.Normal);
                ScrollBarRenderer.DrawLeftHorizontalTrack(g, new Rectangle(125, 45, 38, 18), System.Windows.Forms.VisualStyles.ScrollBarState.Pressed);

                ScrollBarRenderer.DrawLowerVerticalTrack(g, new Rectangle(5, 65, 18, 38), System.Windows.Forms.VisualStyles.ScrollBarState.Disabled);
                ScrollBarRenderer.DrawLowerVerticalTrack(g, new Rectangle(25, 65, 18, 38), System.Windows.Forms.VisualStyles.ScrollBarState.Hot);
                ScrollBarRenderer.DrawLowerVerticalTrack(g, new Rectangle(45, 65, 18, 38), System.Windows.Forms.VisualStyles.ScrollBarState.Normal);
                ScrollBarRenderer.DrawLowerVerticalTrack(g, new Rectangle(65, 65, 18, 38), System.Windows.Forms.VisualStyles.ScrollBarState.Pressed);

                ScrollBarRenderer.DrawRightHorizontalTrack(g, new Rectangle(165, 45, 38, 18), System.Windows.Forms.VisualStyles.ScrollBarState.Disabled);
                ScrollBarRenderer.DrawRightHorizontalTrack(g, new Rectangle(205, 45, 38, 18), System.Windows.Forms.VisualStyles.ScrollBarState.Hot);
                ScrollBarRenderer.DrawRightHorizontalTrack(g, new Rectangle(245, 45, 38, 18), System.Windows.Forms.VisualStyles.ScrollBarState.Normal);
                ScrollBarRenderer.DrawRightHorizontalTrack(g, new Rectangle(285, 45, 38, 18), System.Windows.Forms.VisualStyles.ScrollBarState.Pressed);

                ScrollBarRenderer.DrawSizeBox(g, new Rectangle(5, 105, 18, 18), System.Windows.Forms.VisualStyles.ScrollBarSizeBoxState.LeftAlign);
                ScrollBarRenderer.DrawSizeBox(g, new Rectangle(25, 105, 18, 18), System.Windows.Forms.VisualStyles.ScrollBarSizeBoxState.RightAlign);

                ScrollBarRenderer.DrawUpperVerticalTrack(g, new Rectangle(85, 65, 18, 38), System.Windows.Forms.VisualStyles.ScrollBarState.Disabled);
                ScrollBarRenderer.DrawUpperVerticalTrack(g, new Rectangle(105, 65, 18, 38), System.Windows.Forms.VisualStyles.ScrollBarState.Hot);
                ScrollBarRenderer.DrawUpperVerticalTrack(g, new Rectangle(125, 65, 18, 38), System.Windows.Forms.VisualStyles.ScrollBarState.Normal);
                ScrollBarRenderer.DrawUpperVerticalTrack(g, new Rectangle(145, 65, 18, 38), System.Windows.Forms.VisualStyles.ScrollBarState.Pressed);

                ScrollBarRenderer.DrawVerticalThumb(g, new Rectangle(5, 105, 18, 38), System.Windows.Forms.VisualStyles.ScrollBarState.Disabled);
                ScrollBarRenderer.DrawVerticalThumb(g, new Rectangle(25, 105, 18, 38), System.Windows.Forms.VisualStyles.ScrollBarState.Hot);
                ScrollBarRenderer.DrawVerticalThumb(g, new Rectangle(45, 105, 18, 38), System.Windows.Forms.VisualStyles.ScrollBarState.Normal);
                ScrollBarRenderer.DrawVerticalThumb(g, new Rectangle(65, 105, 18, 38), System.Windows.Forms.VisualStyles.ScrollBarState.Pressed);

                ScrollBarRenderer.DrawVerticalThumbGrip(g, new Rectangle(5, 105, 18, 38), System.Windows.Forms.VisualStyles.ScrollBarState.Disabled);
                ScrollBarRenderer.DrawVerticalThumbGrip(g, new Rectangle(25, 105, 18, 38), System.Windows.Forms.VisualStyles.ScrollBarState.Hot);
                ScrollBarRenderer.DrawVerticalThumbGrip(g, new Rectangle(45, 105, 18, 38), System.Windows.Forms.VisualStyles.ScrollBarState.Normal);
                ScrollBarRenderer.DrawVerticalThumbGrip(g, new Rectangle(65, 105, 18, 38), System.Windows.Forms.VisualStyles.ScrollBarState.Pressed);

                g.DrawString(ScrollBarRenderer.GetSizeBoxSize(g, System.Windows.Forms.VisualStyles.ScrollBarState.Normal).ToString(), f, Brushes.Black, new PointF(5, 145));
                g.DrawString(ScrollBarRenderer.GetThumbGripSize(g, System.Windows.Forms.VisualStyles.ScrollBarState.Normal).ToString(), f, Brushes.Black, new PointF(5, 165));
                break;

            case "TabRenderer":
                if (!TabRenderer.IsSupported)
                {
                    g.DrawString("Visual Styles not enabled", f, Brushes.Black, 0, 0);
                    break;
                }
                TabRenderer.DrawTabPage(g, new Rectangle(5, 95, 700, 50));

                TabRenderer.DrawTabItem(g, new Rectangle(5, 55, 70, 25), System.Windows.Forms.VisualStyles.TabItemState.Normal);
                TabRenderer.DrawTabItem(g, new Rectangle(95, 55, 70, 25), true, System.Windows.Forms.VisualStyles.TabItemState.Selected);
                TabRenderer.DrawTabItem(g, new Rectangle(185, 55, 70, 25), "Tab 1", f, System.Windows.Forms.VisualStyles.TabItemState.Normal);
                TabRenderer.DrawTabItem(g, new Rectangle(275, 55, 70, 25), i, new Rectangle(278, 58, 16, 16), false, System.Windows.Forms.VisualStyles.TabItemState.Hot);
                TabRenderer.DrawTabItem(g, new Rectangle(365, 55, 70, 25), "Tab 6 is too long", f, true, System.Windows.Forms.VisualStyles.TabItemState.Normal);
                TabRenderer.DrawTabItem(g, new Rectangle(455, 55, 70, 25), "My Tab Octopus", f, TextFormatFlags.WordEllipsis, false, System.Windows.Forms.VisualStyles.TabItemState.Disabled);
                TabRenderer.DrawTabItem(g, new Rectangle(545, 55, 70, 25), "Tab 7", f, i, new Rectangle(546, 56, 16, 16), true, System.Windows.Forms.VisualStyles.TabItemState.Normal);
                TabRenderer.DrawTabItem(g, new Rectangle(635, 55, 70, 25), "Tab 8", f, TextFormatFlags.WordEllipsis, i, new Rectangle(638, 58, 16, 16), false, System.Windows.Forms.VisualStyles.TabItemState.Disabled);
                break;

            case "TextBoxRenderer":
                if (!TextBoxRenderer.IsSupported)
                {
                    g.DrawString("Visual Styles not enabled", f, Brushes.Black, 0, 0);
                    break;
                }
                TextBoxRenderer.DrawTextBox(g, new Rectangle(5, 55, 95, 40), System.Windows.Forms.VisualStyles.TextBoxState.Assist);
                TextBoxRenderer.DrawTextBox(g, new Rectangle(105, 55, 95, 40), "This is my text box text!!!", f, System.Windows.Forms.VisualStyles.TextBoxState.Disabled);
                TextBoxRenderer.DrawTextBox(g, new Rectangle(205, 55, 95, 40), "This is my text box text!!!", f, new Rectangle(205, 55, 95, 40), System.Windows.Forms.VisualStyles.TextBoxState.Hot);
                TextBoxRenderer.DrawTextBox(g, new Rectangle(305, 55, 95, 40), "This is my text box text!!!", f, TextFormatFlags.WordEllipsis, System.Windows.Forms.VisualStyles.TextBoxState.Normal);
                TextBoxRenderer.DrawTextBox(g, new Rectangle(405, 55, 95, 40), "This is my text box text!!!", f, new Rectangle(405, 55, 95, 40), TextFormatFlags.WordEllipsis, System.Windows.Forms.VisualStyles.TextBoxState.Readonly);
                TextBoxRenderer.DrawTextBox(g, new Rectangle(505, 55, 95, 40), System.Windows.Forms.VisualStyles.TextBoxState.Selected);
                break;

            case "TrackBarRenderer":
                if (!TrackBarRenderer.IsSupported)
                {
                    g.DrawString("Visual Styles not enabled", f, Brushes.Black, 0, 0);
                    break;
                }
                TrackBarRenderer.DrawBottomPointingThumb(g, new Rectangle(5, 5, 12, 20), System.Windows.Forms.VisualStyles.TrackBarThumbState.Disabled);
                TrackBarRenderer.DrawBottomPointingThumb(g, new Rectangle(20, 5, 12, 20), System.Windows.Forms.VisualStyles.TrackBarThumbState.Hot);
                TrackBarRenderer.DrawBottomPointingThumb(g, new Rectangle(35, 5, 12, 20), System.Windows.Forms.VisualStyles.TrackBarThumbState.Normal);
                TrackBarRenderer.DrawBottomPointingThumb(g, new Rectangle(50, 5, 12, 20), System.Windows.Forms.VisualStyles.TrackBarThumbState.Pressed);

                TrackBarRenderer.DrawHorizontalThumb(g, new Rectangle(5, 45, 12, 20), System.Windows.Forms.VisualStyles.TrackBarThumbState.Disabled);
                TrackBarRenderer.DrawHorizontalThumb(g, new Rectangle(20, 45, 12, 20), System.Windows.Forms.VisualStyles.TrackBarThumbState.Hot);
                TrackBarRenderer.DrawHorizontalThumb(g, new Rectangle(35, 45, 12, 20), System.Windows.Forms.VisualStyles.TrackBarThumbState.Normal);
                TrackBarRenderer.DrawHorizontalThumb(g, new Rectangle(50, 45, 12, 20), System.Windows.Forms.VisualStyles.TrackBarThumbState.Pressed);

                TrackBarRenderer.DrawHorizontalTicks(g, new Rectangle(5, 75, 100, 20), 15, System.Windows.Forms.VisualStyles.EdgeStyle.Bump);
                TrackBarRenderer.DrawHorizontalTicks(g, new Rectangle(115, 75, 100, 20), 10, System.Windows.Forms.VisualStyles.EdgeStyle.Etched);
                TrackBarRenderer.DrawHorizontalTicks(g, new Rectangle(225, 75, 100, 20), 5, System.Windows.Forms.VisualStyles.EdgeStyle.Raised);
                TrackBarRenderer.DrawHorizontalTicks(g, new Rectangle(335, 75, 100, 20), 25, System.Windows.Forms.VisualStyles.EdgeStyle.Sunken);

                TrackBarRenderer.DrawHorizontalTrack(g, new Rectangle(5, 120, 100, 20));

                TrackBarRenderer.DrawLeftPointingThumb(g, new Rectangle(5, 145, 20, 12), System.Windows.Forms.VisualStyles.TrackBarThumbState.Disabled);
                TrackBarRenderer.DrawLeftPointingThumb(g, new Rectangle(25, 145, 20, 12), System.Windows.Forms.VisualStyles.TrackBarThumbState.Hot);
                TrackBarRenderer.DrawLeftPointingThumb(g, new Rectangle(45, 145, 20, 12), System.Windows.Forms.VisualStyles.TrackBarThumbState.Normal);
                TrackBarRenderer.DrawLeftPointingThumb(g, new Rectangle(65, 145, 20, 12), System.Windows.Forms.VisualStyles.TrackBarThumbState.Pressed);

                TrackBarRenderer.DrawRightPointingThumb(g, new Rectangle(5, 165, 20, 12), System.Windows.Forms.VisualStyles.TrackBarThumbState.Disabled);
                TrackBarRenderer.DrawRightPointingThumb(g, new Rectangle(25, 165, 20, 12), System.Windows.Forms.VisualStyles.TrackBarThumbState.Hot);
                TrackBarRenderer.DrawRightPointingThumb(g, new Rectangle(45, 165, 20, 12), System.Windows.Forms.VisualStyles.TrackBarThumbState.Normal);
                TrackBarRenderer.DrawRightPointingThumb(g, new Rectangle(65, 165, 20, 12), System.Windows.Forms.VisualStyles.TrackBarThumbState.Pressed);

                TrackBarRenderer.DrawTopPointingThumb(g, new Rectangle(5, 185, 12, 20), System.Windows.Forms.VisualStyles.TrackBarThumbState.Disabled);
                TrackBarRenderer.DrawTopPointingThumb(g, new Rectangle(20, 185, 12, 20), System.Windows.Forms.VisualStyles.TrackBarThumbState.Hot);
                TrackBarRenderer.DrawTopPointingThumb(g, new Rectangle(35, 185, 12, 20), System.Windows.Forms.VisualStyles.TrackBarThumbState.Normal);
                TrackBarRenderer.DrawTopPointingThumb(g, new Rectangle(50, 185, 12, 20), System.Windows.Forms.VisualStyles.TrackBarThumbState.Pressed);

                TrackBarRenderer.DrawVerticalThumb(g, new Rectangle(5, 215, 20, 12), System.Windows.Forms.VisualStyles.TrackBarThumbState.Disabled);
                TrackBarRenderer.DrawVerticalThumb(g, new Rectangle(25, 215, 20, 12), System.Windows.Forms.VisualStyles.TrackBarThumbState.Hot);
                TrackBarRenderer.DrawVerticalThumb(g, new Rectangle(45, 215, 20, 12), System.Windows.Forms.VisualStyles.TrackBarThumbState.Normal);
                TrackBarRenderer.DrawVerticalThumb(g, new Rectangle(65, 215, 20, 12), System.Windows.Forms.VisualStyles.TrackBarThumbState.Pressed);

                TrackBarRenderer.DrawVerticalTicks(g, new Rectangle(5, 230, 20, 100), 15, System.Windows.Forms.VisualStyles.EdgeStyle.Bump);
                TrackBarRenderer.DrawVerticalTicks(g, new Rectangle(50, 230, 20, 100), 10, System.Windows.Forms.VisualStyles.EdgeStyle.Etched);
                TrackBarRenderer.DrawVerticalTicks(g, new Rectangle(95, 230, 20, 100), 5, System.Windows.Forms.VisualStyles.EdgeStyle.Raised);
                TrackBarRenderer.DrawVerticalTicks(g, new Rectangle(140, 230, 20, 100), 25, System.Windows.Forms.VisualStyles.EdgeStyle.Sunken);

                TrackBarRenderer.DrawVerticalTrack(g, new Rectangle(185, 230, 20, 100));

                g.DrawString(TrackBarRenderer.GetBottomPointingThumbSize(g, System.Windows.Forms.VisualStyles.TrackBarThumbState.Normal).ToString(), f, Brushes.Black, new Point(5, 340));
                g.DrawString(TrackBarRenderer.GetLeftPointingThumbSize(g, System.Windows.Forms.VisualStyles.TrackBarThumbState.Hot).ToString(), f, Brushes.Black, new Point(5, 370));
                g.DrawString(TrackBarRenderer.GetRightPointingThumbSize(g, System.Windows.Forms.VisualStyles.TrackBarThumbState.Disabled).ToString(), f, Brushes.Black, new Point(5, 400));
                g.DrawString(TrackBarRenderer.GetTopPointingThumbSize(g, System.Windows.Forms.VisualStyles.TrackBarThumbState.Pressed).ToString(), f, Brushes.Black, new Point(5, 430));
                break;

            default:
                break;
            }
        }