protected override void OnPaint(PaintEventArgs e)
        {
            const int inset = 2; // A single inset value to control teh sizing of the inner rect.

            using (Image offscreenImage = new Bitmap(this.Width, this.Height))
            {
                using (Graphics offscreen = Graphics.FromImage(offscreenImage))
                {
                    Color     color1 = this.BackColor;
                    Color     color2 = this.ForeColor;
                    Rectangle rect   = new Rectangle(0, 0, this.Width, this.Height);

                    if (ProgressBarRenderer.IsSupported)
                    {
                        ProgressBarRenderer.DrawVerticalBar(offscreen, rect);
                    }

                    rect.Inflate(new Size(-inset, -inset)); // Deflate inner rect.
                    rect.Height = (int)(rect.Height * ((double)this.Value / this.Maximum));

                    if (rect.Height == 0) // Can't draw rec with width of 0.
                    {
                        rect.Height = 1;
                        color1      = Color.WhiteSmoke;
                        color2      = Color.WhiteSmoke;
                    }

                    LinearGradientBrush brush = new LinearGradientBrush(rect, color1, color2, LinearGradientMode.Vertical);
                    offscreen.FillRectangle(brush, inset, inset, rect.Width, rect.Height);

                    e.Graphics.DrawImage(offscreenImage, 0, 0);
                    offscreenImage.Dispose();
                }
            }
        }
Beispiel #2
0
        protected override void OnPaint(System.Windows.Forms.PaintEventArgs e)
        {
            if (ProgressBarRenderer.IsSupported)
            {
                ProgressBarRenderer.DrawVerticalBar(e.Graphics, ClientRectangle);

                const int HORIZ_OFFSET = 0;
                const int VERT_OFFSET  = 0;



                if (this.Minimum == this.Maximum || (this.Value - Minimum) == 0 ||
                    this.Height < 2 * VERT_OFFSET || this.Width < 2 * VERT_OFFSET)
                {
                    return;
                }

                int barHeight = (this.Value - this.Minimum) * this.Height / (this.Maximum - this.Minimum);
                barHeight = Math.Min(barHeight, this.Height - 2 * VERT_OFFSET);
                int barWidth = this.Width - 2 * HORIZ_OFFSET;

                if (this.RightToLeftLayout && this.RightToLeft == System.Windows.Forms.RightToLeft.No)
                {
                    SolidBrush brush = new SolidBrush(BackColor);
                    e.Graphics.FillRectangle(brush, HORIZ_OFFSET, VERT_OFFSET, barWidth, barHeight);
                }
                else
                {
                    int        blockHeight    = 1;
                    int        wholeBarHeight = Convert.ToInt32(barHeight / blockHeight) * blockHeight;
                    int        wholeBarY      = this.Height - wholeBarHeight - VERT_OFFSET;
                    int        restBarHeight  = barHeight % blockHeight;
                    int        restBarY       = this.Height - barHeight - VERT_OFFSET;
                    SolidBrush brush          = new SolidBrush(BackColor);
                    e.Graphics.FillRectangle(brush, HORIZ_OFFSET, wholeBarY, barWidth, wholeBarHeight);
                    e.Graphics.FillRectangle(brush, HORIZ_OFFSET, restBarY, barWidth, restBarHeight);
                    //ProgressBarRenderer.DrawVerticalChunks(e.Graphics,
                    //  new Rectangle(HORIZ_OFFSET, wholeBarY, barWidth, wholeBarHeight));
                }
            }

            string text = Text;

            using (Font f = new Font(FontFamily.GenericSansSerif, 10))
            {
                StringFormat stringFormat = new StringFormat();
                stringFormat.FormatFlags = StringFormatFlags.DirectionVertical;
                SizeF len = e.Graphics.MeasureString(text, f);
                // Calculate the location of the text (the middle of progress bar)
                // Point location = new Point(Convert.ToInt32((rect.Width / 2) - (len.Width / 2)), Convert.ToInt32((rect.Height / 2) - (len.Height / 2)));
                Point location = new Point(Convert.ToInt32((Width / 2) - len.Height / 2), Convert.ToInt32((Height / 2) - len.Width / 2));
                // The commented-out code will centre the text into the highlighted area only. This will centre the text regardless of the highlighted area.
                // Draw the custom text
                e.Graphics.DrawString(text, f, new SolidBrush(ForeColor), location, stringFormat);
            }

            base.OnPaint(e);
        }
Beispiel #3
0
        // Draw the progress bar in its normal state.
        protected override void OnPaint(PaintEventArgs e)
        {
            base.OnPaint(e);

            if (ProgressBarRenderer.IsSupported)
            {
                ProgressBarRenderer.DrawVerticalBar(e.Graphics,
                                                    ClientRectangle);
                this.Parent.Text = "VerticalProgressBar Enabled";
            }
            else
            {
                this.Parent.Text = "VerticalProgressBar Disabled";
            }
        }
Beispiel #4
0
        protected override void OnPaint(PaintEventArgs e)
        {
            SolidBrush brush       = null;
            Rectangle  rec         = new Rectangle(0, 0, this.Width, this.Height);
            double     scaleFactor = (((double)Value - (double)Minimum) / ((double)Maximum - (double)Minimum));

            if (ProgressBarRenderer.IsSupported)
            {
                ProgressBarRenderer.DrawVerticalBar(e.Graphics, rec);
            }

            rec.Width -= 0;
            rec.Height = (int)((rec.Width * scaleFactor));
            brush      = new SolidBrush(this.ForeColor);
            e.Graphics.FillRectangle(brush, 0, 0, rec.Width, rec.Height);
        }
        protected override void OnPaint(PaintEventArgs e)
        {
            if (brush == null || brush.Color != this.ForeColor)
            {
                brush = new SolidBrush(this.ForeColor);
            }

            Rectangle rec = new Rectangle(0, 0, this.Width, this.Height);

            if (ProgressBarRenderer.IsSupported)
            {
                ProgressBarRenderer.DrawVerticalBar(e.Graphics, rec);
            }
            rec.Height = (int)(rec.Height * ((double)Value / Maximum)) - 4;
            rec.Width  = rec.Width - 4;
            e.Graphics.FillRectangle(brush, 2, rec.Height, rec.Width, this.Height - 2);
        }
        private void DrawSolidBar(Graphics gfx, int x, int y, int width, int height)
        {
            Rectangle rect = new Rectangle(0, 0, Width, Height);

            if (ProgressBarRenderer.IsSupported)
            {
                ProgressBarRenderer.DrawVerticalBar(gfx, rect);
            }

            LinearGradientBrush topBrush = new LinearGradientBrush(new Point(0, 0), new Point(1, 1), Color.FromArgb(255, 240, 250, 255), Color.FromArgb(255, 80, 215, 245));
            LinearGradientBrush botBrush = new LinearGradientBrush(new Point(1, 1), new Point(2, 2), Color.FromArgb(150, 80, 200, 210), Color.FromArgb(255, 210, 240, 255));

            //gfx.FillRectangle(topBrush, x, y - height, width, height);
            //gfx.FillRectangle(botBrush, x, y - height, width, height);

            gfx.FillRectangle(new SolidBrush(m_Color), x, y - height, width, height);
        }
        protected override void OnPaintBackground(PaintEventArgs eventArgs)
        {
            Rectangle rect = SkinExceptRectangleForProgressBar;

            if (ProgressBarRenderer.IsSupported && (SkinImage == null))
            {
                ProgressBarRenderer.DrawVerticalBar(eventArgs.Graphics, rect);
            }
            else
            {
                if (SkinImage == null)
                {
                    eventArgs.Graphics.FillRectangle(new SolidBrush(Parent.BackColor), rect);
                    eventArgs.Graphics.DrawRectangle(new Pen(Color.Black, 2), rect);
                }
                else
                {
                    eventArgs.Graphics.Clear(Parent.BackColor);
                }
            }
        }
    protected override void OnPaint(System.Windows.Forms.PaintEventArgs e)
    {
        if (ProgressBarRenderer.IsSupported)
        {
            ProgressBarRenderer.DrawVerticalBar(e.Graphics, ClientRectangle);

            const int HORIZ_OFFSET = 3;
            const int VERT_OFFSET  = 2;

            if (this.Minimum == this.Maximum || (this.Value - Minimum) == 0 ||
                this.Height < 2 * VERT_OFFSET || this.Width < 2 * VERT_OFFSET)
            {
                return;
            }

            int barHeight = (this.Value - this.Minimum) * this.Height / (this.Maximum - this.Minimum);
            barHeight = Math.Min(barHeight, this.Height - 2 * VERT_OFFSET);
            int barWidth = this.Width - 2 * HORIZ_OFFSET;

            if (this.RightToLeftLayout && this.RightToLeft == System.Windows.Forms.RightToLeft.No)
            {
                ProgressBarRenderer.DrawVerticalChunks(e.Graphics,
                                                       new Rectangle(HORIZ_OFFSET, VERT_OFFSET, barWidth, barHeight));
            }
            else
            {
                int blockHeight    = 10;
                int wholeBarHeight = Convert.ToInt32(barHeight / blockHeight) * blockHeight;
                int wholeBarY      = this.Height - wholeBarHeight - VERT_OFFSET;
                int restBarHeight  = barHeight % blockHeight;
                int restBarY       = this.Height - barHeight - VERT_OFFSET;
                ProgressBarRenderer.DrawVerticalChunks(e.Graphics,
                                                       new Rectangle(HORIZ_OFFSET, wholeBarY, barWidth, wholeBarHeight));
                ProgressBarRenderer.DrawVerticalChunks(e.Graphics,
                                                       new Rectangle(HORIZ_OFFSET, restBarY, barWidth, restBarHeight));
            }
        }

        base.OnPaint(e);
    }
Beispiel #9
0
        private void DrawProgressBar(Graphics g)
        {
            Rectangle rect = ClientRectangle;

            if (_ProgressKind == ProgressBarKind.Horizontal)
            {
                ProgressBarRenderer.DrawHorizontalBar(g, rect);
                //rect.Inflate(-1, -1);

                if (Value > 0)
                {
                    if (this._ProgressDashed <= 0)
                    {
                        float      width = ((float)Value / (float)Maximum) * (float)rect.Width;
                        RectangleF clip  = new RectangleF(rect.X, rect.Y, width, rect.Height);
                        g.FillRectangle(_progressColourBrush, clip);
                    }
                    else
                    {
                        float OneStepWidth = this.Maximum <= 0 ? 0 : (float)rect.Width / (float)this.Maximum;
                        float StepValue    = 0;
                        while (StepValue < Value)
                        {
                            float StepWith = 0;

                            if (StepValue + _ProgressDashed <= Value)
                            {
                                StepWith = OneStepWidth * (float)_ProgressDashed - 1;
                            }
                            else
                            {
                                StepWith = OneStepWidth * ((float)Value - StepValue) - 1;
                            }

                            if (StepWith <= 1)
                            {
                                StepWith = 1;
                            }

                            RectangleF clip = new RectangleF((float)rect.X + StepValue * OneStepWidth, rect.Y, StepWith, rect.Height);
                            g.FillRectangle(_progressColourBrush, clip);

                            StepValue += _ProgressDashed;
                        }
                    }
                }
            }
            else
            {
                ProgressBarRenderer.DrawVerticalBar(g, rect);
                //rect.Inflate(-1, -1);

                if (Value > 0)
                {
                    if (this._ProgressDashed <= 0)
                    {
                        float      height = (((float)Value / (float)Maximum) * (float)rect.Height);
                        RectangleF clip   = new RectangleF(rect.X, (float)rect.Height - height, rect.Width, height);
                        g.FillRectangle(_progressColourBrush, clip);
                    }
                    else
                    {
                        float OneStepHeight = this.Maximum <= 0 ? 0 : (float)rect.Height / (float)this.Maximum;
                        float StepValue     = 0;
                        while (StepValue < Value)
                        {
                            float StepHeight = 0;

                            if (StepValue + _ProgressDashed <= Value)
                            {
                                StepHeight = OneStepHeight * (float)_ProgressDashed - 1;
                            }
                            else
                            {
                                StepHeight = OneStepHeight * ((float)Value - StepValue) - 1;
                            }

                            if (StepHeight <= 1)
                            {
                                StepHeight = 1;
                            }

                            RectangleF clip = new RectangleF((float)rect.X, ((float)rect.Height - (StepValue * OneStepHeight) - StepHeight), (float)rect.Width, StepHeight);
                            g.FillRectangle(_progressColourBrush, clip);

                            StepValue += _ProgressDashed;
                        }
                    }
                }
            }
        }
        // See http://stackoverflow.com/questions/778678/how-to-change-the-color-of-progressbar-in-c-sharp-net-3-5
        protected override void OnPaint(PaintEventArgs e)
        {
            LinearGradientBrush brush = null;
            Rectangle           rec   = new Rectangle(0, 0, this.Width, this.Height);

            CalculateRangeMaxEnd(); // Need some better here!
            int BarLength = GetBarLengthForCurrentValue();

            if (IsHorizontal())
            {
                // First draw background
                if (ProgressBarRenderer.IsSupported)
                {
                    ProgressBarRenderer.DrawHorizontalBar(e.Graphics, rec);
                }

                int startX;

                if (BarLength > 0)
                {
                    rec.Width   = BarLength;
                    rec.Height -= 2 * m_Margin;
                    startX      = (Direction == BarDirectionEnum.LeftToRight ? m_Margin : this.Width - m_Margin - rec.Width);

                    brush = new LinearGradientBrush(rec, GetColor(), this.BackColor, LinearGradientMode.Vertical);
                    e.Graphics.FillRectangle(brush, startX, m_Margin, rec.Width, rec.Height);
                }

                if (DrawRangeEndMarkers)
                {
                    for (byte i = 0; ((i + 1 < NUMOFRANGES) && m_RangeEnabled[i + 1]); i++) // Not we do not draw range max line
                    {
                        Pen pen = new Pen(new SolidBrush(m_RangeMarkerColor[i]));
                        // Draw range lines
                        startX = (Direction == BarDirectionEnum.LeftToRight ? m_Margin + GetBarLength(m_RangeEnd[i]) : this.Width - m_Margin - GetBarLength(m_RangeEnd[i]));
                        e.Graphics.DrawLine(pen, new Point(startX, m_Margin),
                                            new Point(startX, this.Height - m_Margin));
                    }
                }
            }
            else
            {
                // First draw background
                if (ProgressBarRenderer.IsSupported)
                {
                    ProgressBarRenderer.DrawVerticalBar(e.Graphics, rec);
                }

                int startY;

                if (BarLength > 0)
                {
                    rec.Height = BarLength;
                    rec.Width -= 2 * m_Margin;
                    startY     = (Direction == BarDirectionEnum.DownToUp ? this.Height - m_Margin - rec.Height : m_Margin);

                    brush = new LinearGradientBrush(rec, GetColor(), this.BackColor, LinearGradientMode.Horizontal);
                    e.Graphics.FillRectangle(brush, m_Margin, startY, rec.Width, rec.Height);
                }

                if (DrawRangeEndMarkers)
                {
                    for (byte i = 0; ((i + 1 < NUMOFRANGES) && m_RangeEnabled[i + 1]); i++) // Not we do not draw range max line
                    {
                        Pen pen = new Pen(new SolidBrush(m_RangeMarkerColor[i]));
                        // Draw range lines
                        startY = (Direction == BarDirectionEnum.DownToUp ? this.Height - m_Margin - GetBarLength(m_RangeEnd[i]) : m_Margin + GetBarLength(m_RangeEnd[i]));
                        e.Graphics.DrawLine(pen, new Point(m_Margin, startY),
                                            new Point(this.Width - m_Margin, startY));
                    }
                }
            }
        }
Beispiel #11
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;
            }
        }
        public void Draw(Graphics gfx, Rectangle bounds, RenderState state, object value, Color foreColor, Color backColor, Font font)
        {
            var BackgroundBrush = GetBrush(backColor);

            gfx.FillRectangle(BackgroundBrush, bounds);

            int    ActualChunkThickness      = (ChunkThickness > 0) ? ChunkThickness : ProgressBarRenderer.ChunkThickness;
            int    ActualChunkSpaceThickness = (ChunkSpaceThickness >= 0) ? ChunkSpaceThickness : ProgressBarRenderer.ChunkSpaceThickness;
            int    TotalChunkThickness       = ActualChunkThickness + ActualChunkSpaceThickness;
            int    Value            = Utils.Clamp((int)value, MinValue, MaxValue);
            double PercentageFactor = ((double)Value + Math.Abs(MinValue)) / (MaxValue - MinValue);

            int       BarThickness = 0;
            Rectangle BarBounds;
            Rectangle ChunkBounds;

            bounds.Inflate(-1, -1); // Leave a 1 pixel wide border around the progressbar.

            if (Horizontal)
            {
                BarThickness = (int)Math.Floor(PercentageFactor * (bounds.Width - 2));
                BarThickness = Utils.Clamp(BarThickness, 0, bounds.Width - 2);
                BarBounds    = new Rectangle(bounds.Left + 1, bounds.Top + 1, BarThickness, bounds.Height - 2);
                ChunkBounds  = new Rectangle(bounds.Left + 1, bounds.Top + 1, ActualChunkThickness, bounds.Height - 2);
                ProgressBarRenderer.DrawHorizontalBar(gfx, bounds);
            }
            else
            {
                BarThickness = (int)Math.Floor(PercentageFactor * (bounds.Height - 2));
                BarThickness = Utils.Clamp(BarThickness, 0, bounds.Height - 2);
                BarBounds    = new Rectangle(bounds.Left + 1, bounds.Top + 1 + (bounds.Height - 2 - BarThickness), bounds.Width - 2, BarThickness);
                ChunkBounds  = new Rectangle(bounds.Left + 1, bounds.Top + 1 + (bounds.Height - 2 - ActualChunkThickness), bounds.Width - 2, ActualChunkThickness);
                ProgressBarRenderer.DrawVerticalBar(gfx, bounds);
            }

            if (BarThickness == 0 && Value > MinValue)
            {
                // If value is greater than the minimal value at least show something. Even if it's only one pixel.
                BarThickness = 1;
            }

            int ChunkCount            = (int)Math.Floor((BarThickness + ActualChunkSpaceThickness) / (double)TotalChunkThickness);
            int RemainingBarThickness = BarThickness - ChunkCount * TotalChunkThickness;

            if (ActualChunkSpaceThickness <= 0)
            {
                // No chunks, so draw one big chunk which should be a solid bar.
                ProgressBarRenderer.DrawHorizontalChunks(gfx, BarBounds);
            }
            else
            {
                if (Horizontal)
                {
                    for (int i = 0; i < ChunkCount; i++)
                    {
                        ProgressBarRenderer.DrawHorizontalChunks(gfx, ChunkBounds);
                        ChunkBounds.X += TotalChunkThickness;
                    }

                    if (RemainingBarThickness > 0)
                    {
                        ChunkBounds.Width = RemainingBarThickness;
                        ProgressBarRenderer.DrawHorizontalChunks(gfx, ChunkBounds);
                    }
                }
                else
                {
                    for (int i = 0; i < ChunkCount; i++)
                    {
                        ProgressBarRenderer.DrawVerticalChunks(gfx, ChunkBounds);
                        ChunkBounds.Y -= TotalChunkThickness;
                    }

                    if (RemainingBarThickness > 0)
                    {
                        ChunkBounds.Height = RemainingBarThickness;
                        ChunkBounds.Y     += (TotalChunkThickness - RemainingBarThickness - 1);
                        ProgressBarRenderer.DrawVerticalChunks(gfx, ChunkBounds);
                    }
                }
            }
        }
Beispiel #13
0
        protected override void OnPaint(PaintEventArgs e)
        {
            if (Maximum - Minimum == 0)
            {
                base.OnPaint(e);
                return;
            }

            Rectangle innerRectangle = ClientRectangle;

            if (Vertical)
            {
                int height = (Value - Minimum) * (ClientRectangle.Height - 2) / (Maximum - Minimum);
                innerRectangle = new Rectangle(ClientRectangle.X + 1, ClientRectangle.Y + ClientRectangle.Height - 1 - height, ClientRectangle.Width - 2, height);
            }
            else
            {
                int width = (Value - Minimum) * (ClientRectangle.Width - 2) / (Maximum - Minimum);
                innerRectangle = new Rectangle(ClientRectangle.X + 1, ClientRectangle.Y + 1, width, ClientRectangle.Height - 2);
            }

            /*
             *  if (Vertical)
             *  {
             *      int height = (Value - Minimum) * ClientRectangle.Height / (Maximum - Minimum);
             *      innerRectangle = new Rectangle(ClientRectangle.X, ClientRectangle.Y + ClientRectangle.Height - height, ClientRectangle.Width, height);
             *  }
             *  else
             *  {
             *      int width = (Value - Minimum) * ClientRectangle.Width / (Maximum - Minimum);
             *      innerRectangle = new Rectangle(ClientRectangle.X, ClientRectangle.Y, width, ClientRectangle.Height);
             *  }
             */

            if (RenderMode == 0)        // System
            {
                if (Vertical)
                {
                    ProgressBarRenderer.DrawVerticalBar(e.Graphics, ClientRectangle);
                    ProgressBarRenderer.DrawVerticalChunks(e.Graphics, innerRectangle);
                }
                else
                {
                    ProgressBarRenderer.DrawHorizontalBar(e.Graphics, ClientRectangle);
                    ProgressBarRenderer.DrawHorizontalChunks(e.Graphics, innerRectangle);
                }
            }
            else
            {
                int i = -1;

                if (RenderMode == 1) // Auto colour at 20%/80%
                {
                    i = 1;           // Blue
                    if (Value <= Minimum + 30 * (Maximum - Minimum) / 100)
                    {
                        i = 2;
                    }                                                                   // Red
                    if (Value >= Minimum + 80 * (Maximum - Minimum) / 100)
                    {
                        i = 3;
                    }                      // Green
                }
                else if (RenderMode == -1) // Invert auto colour at 20%/80%
                {
                    i = 1;                 // Blue
                    if (Value <= Minimum + 30 * (Maximum - Minimum) / 100)
                    {
                        i = 3;
                    }                                                                   // Green
                    if (Value >= Minimum + 80 * (Maximum - Minimum) / 100)
                    {
                        i = 2;
                    }                                                                   // Red
                }
                else if (RenderMode == 2)
                {
                    i = 1;
                }                                       // Blue
                else if (RenderMode == 3)
                {
                    i = 2;
                }                                       // Red
                else if (RenderMode == 4)
                {
                    i = 3;
                }                                       // Green

                if (Image != null && i >= 0)
                {
                    int n = 4;
                    e.Graphics.DrawImage(Image, ClientRectangle, new Rectangle(0, 0, Image.Width / n, Image.Height), GraphicsUnit.Pixel);
                    e.Graphics.DrawImage(Image, innerRectangle, new Rectangle(i * Image.Width / n + 1, 1, Image.Width / n - 2, innerRectangle.Height - 2), GraphicsUnit.Pixel);
                }
                else
                {
                    e.Graphics.FillRectangle(new SolidBrush(BackColor), ClientRectangle);
                    e.Graphics.FillRectangle(new SolidBrush(ForeColor), innerRectangle);
                }
            }
        }