示例#1
0
        protected override void OnPaint(PaintEventArgs e)
        {
            _logger.Trace($"executing {nameof(OnPaint)}...");
            base.OnPaint(e);

            if (this.TabPages.Count == 0)
            {
                if (Application.VisualStyleState == VisualStyleState.ClientAreaEnabled ||
                    Application.VisualStyleState == VisualStyleState.ClientAndNonClientAreasEnabled)
                {
                    var rect = new Rectangle(e.ClipRectangle.Location, e.ClipRectangle.Size);
                    rect.Inflate(-2, -2);
                    TabRenderer.DrawTabPage(e.Graphics, rect);
                }
                e.Graphics.DrawString(TerminalTexts.TabControlEx_NoPage, this.Font, Brushes.Cyan, 10, 8);
                e.Graphics.DrawString(TerminalTexts.TabControlEx_NoPage, this.Font, Brushes.Cyan, 11, 8);
                e.Graphics.DrawString(TerminalTexts.TabControlEx_NoPage, this.Font, Brushes.Cyan, 12, 8);
                e.Graphics.DrawString(TerminalTexts.TabControlEx_NoPage, this.Font, Brushes.Cyan, 10, 9);
                e.Graphics.DrawString(TerminalTexts.TabControlEx_NoPage, this.Font, Brushes.Cyan, 12, 9);
                e.Graphics.DrawString(TerminalTexts.TabControlEx_NoPage, this.Font, Brushes.Cyan, 10, 10);
                e.Graphics.DrawString(TerminalTexts.TabControlEx_NoPage, this.Font, Brushes.Cyan, 11, 10);
                e.Graphics.DrawString(TerminalTexts.TabControlEx_NoPage, this.Font, Brushes.Cyan, 12, 10);
                e.Graphics.DrawString(TerminalTexts.TabControlEx_NoPage, this.Font, Brushes.Black, 11, 9);
            }

            _logger.Trace($"completed {nameof(OnPaint)}");
        }
示例#2
0
        internal static void DrawSearchResultNodeText(object sender, DrawTreeNodeEventArgs e)
        {
            Font nodeFont = e.Node.NodeFont;

            if (nodeFont == null)
            {
                nodeFont = ((TreeView)sender).Font;
            }
            var clip = new Rectangle(0, e.Bounds.Y, e.Node.TreeView.Width, e.Bounds.Height);

            e.Graphics.SetClip(clip);
            var selectedStates = TreeNodeStates.Marked | TreeNodeStates.Selected | TreeNodeStates.Focused;

            if (e.Node.Tag == null)
            {
                nodeFont = new Font(nodeFont.FontFamily, nodeFont.Size - 2);
                // We use a TabRenderer to get the nice system gradient
                e.Graphics.Clear(Color.White);
                clip = new Rectangle(1, e.Bounds.Y + 1, e.Node.TreeView.ClientRectangle.Width - 3, e.Bounds.Height - 3);
                TabRenderer.DrawTabItem(e.Graphics, clip, e.Node.Text, nodeFont, System.Windows.Forms.VisualStyles.TabItemState.Normal);
                using (var pen = new Pen(Color.Black, 1.0f))
                    e.Graphics.DrawLine(pen, new Point(clip.Left, clip.Bottom), new Point(clip.Right - 1, clip.Bottom));
            }
            else
            {
                e.Graphics.Clear((e.State & selectedStates) != 0 ? SystemColors.Highlight : SystemColors.ControlLightLight);
                e.Graphics.DrawString(e.Node.Text, nodeFont, (e.State & selectedStates) != 0 ? SystemBrushes.HighlightText : SystemBrushes.ControlText, new PointF(e.Bounds.X, e.Bounds.Y + 2));
            }
        }
示例#3
0
        /// <summary>
        /// Draws certain tab.
        /// </summary>
        /// <param name="g">The <see cref="System.Drawing.Graphics"/> object used to draw tab control.</param>
        /// <param name="index">Index of the tab being drawn.</param>
        /// <param name="state">State of the tab item.</param>
        /// <param name="tabRect">The <see cref="System.Drawing.Rectangle"/> object specifying tab bounds.</param>
        /// <param name="textFmt">The <see cref="System.Drawing.StringFormat"/> object specifying text formatting
        /// in the tab.</param>
        private void DrawTabItem(Graphics g, int index, TabItemState state, Rectangle tabRect, StringFormat textFmt)
        {
            //if scroller is visible and the tab is fully placed under it we don't need to draw such tab
            if (fUpDown.X <= 0 || tabRect.X < fUpDown.X)
            {
                /* We will draw our tab on the bitmap and then will transfer image on the control
                 * graphic context.*/
                Bitmap    bmp      = new Bitmap(tabRect.Width, tabRect.Height);
                Rectangle drawRect = new Rectangle(0, 0, tabRect.Width, tabRect.Height);
                using (Graphics bitmapContext = Graphics.FromImage(bmp))
                {
                    TabRenderer.DrawTabItem(bitmapContext, drawRect, state);
                    if (state == TabItemState.Selected && tabRect.X == 0)
                    {
                        int corrY = bmp.Height - 1;
                        bmp.SetPixel(0, corrY, bmp.GetPixel(0, corrY - 1));
                    }

                    /* Important moment. If tab alignment is bottom we should flip image to display tab
                     * correctly.*/
                    if (this.Alignment == TabAlignment.Bottom)
                    {
                        bmp.RotateFlip(RotateFlipType.RotateNoneFlipY);
                    }

                    Rectangle focusRect = Rectangle.Inflate(drawRect, -3, -3); //focus rect
                    TabPage   pg        = this.TabPages[index];                //tab page whose tab we're drawing
                    //trying to get tab image if any
                    Image pagePict = this.GetImageByIndexOrKey(pg.ImageIndex, pg.ImageKey);
                    if (pagePict != null)
                    {
                        //If tab image is present we should draw it.
                        Point imgLoc = state == TabItemState.Selected ? new Point(8, 2) : new Point(6, 2);
                        if (this.Alignment == TabAlignment.Bottom)
                        {
                            imgLoc.Y = drawRect.Bottom - 2 - pagePict.Height;
                        }
                        bitmapContext.DrawImageUnscaled(pagePict, imgLoc);
                        //Correcting rectangle for drawing text.
                        drawRect.X += imgLoc.X + pagePict.Width; drawRect.Width -= imgLoc.X + pagePict.Width;
                    }
                    //drawing tab text
                    using (Brush b = new SolidBrush(SystemColors.ControlText))
                        bitmapContext.DrawString(pg.Text, this.Font, b, (RectangleF)drawRect, textFmt);
                    //and finally drawing focus rect(if needed)
                    if (this.Focused && state == TabItemState.Selected)
                    {
                        ControlPaint.DrawFocusRectangle(bitmapContext, focusRect);
                    }
                }
                //If the tab has part under scroller we shouldn't draw that part.
                int shift = state == TabItemState.Selected ? 2 : 0;
                if (fUpDown.X > 0 && fUpDown.X >= tabRect.X - shift && fUpDown.X < tabRect.Right + shift)
                {
                    tabRect.Width -= tabRect.Right - fUpDown.X + shift;
                }
                g.DrawImageUnscaledAndClipped(bmp, tabRect);
            }
        }
示例#4
0
 public void DrawTabPage(Graphics g, Rectangle bounds)
 {
     if (TabRenderer.IsSupported == false)
     {
         (new VisualTabRenderer_VS2008()).DrawTabPage(g, bounds);
     }
     TabRenderer.DrawTabPage(g, bounds);
 }
示例#5
0
 public void DrawTabItem(Graphics g, Rectangle bounds, TabItemState state)
 {
     if (TabRenderer.IsSupported == false)
     {
         (new VisualTabRenderer_VS2008()).DrawTabItem(g, bounds, state);
     }
     bounds = GetModifiedBounds(bounds);
     TabRenderer.DrawTabItem(g, bounds, state);
 }
        protected override void OnPaintBackground(PaintEventArgs e)
        {
            TabControl parentInternal = this.Parent as TabControl;

            if ((Application.RenderWithVisualStyles && this.UseVisualStyleBackColor) && ((parentInternal != null) && (parentInternal.Appearance == TabAppearance.Normal)))
            {
                var backColor  = this.UseVisualStyleBackColor ? System.Drawing.Color.Transparent : this.BackColor;
                var bounds     = this.DisplayRectangle;
                var rectangle2 = new Rectangle(bounds.X - 4, bounds.Y - 2, bounds.Width + 8, bounds.Height + 6);
                TabRenderer.DrawTabPage(e.Graphics, rectangle2);
            }
            else
            {
                base.OnPaintBackground(e);
            }
        }
示例#7
0
        //<Snippet2>
        // Draw the tab page and the tab items.
        protected override void OnPaint(PaintEventArgs e)
        {
            base.OnPaint(e);

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

            TabRenderer.DrawTabPage(e.Graphics, tabPageRectangle);
            TabRenderer.DrawTabItem(e.Graphics, tabItemRectangle1,
                                    tab1Text, this.Font, tab1Focused, tab1State);
            TabRenderer.DrawTabItem(e.Graphics, tabItemRectangle2,
                                    tab2Text, this.Font, tab2Focused, tab2State);

            this.Parent.Text = "CustomTabControl Enabled";
        }
示例#8
0
        /*
         * DrawTabButtonBackgroundUsingVisualStyles
         */

        /// <summary>
        /// </summary>
        /// <exception cref="ArgumentNullException">
        /// <para>
        ///		<paramref name="g"/> is <see langword="null"/>.
        /// </para>
        /// </exception>
        /// <exception cref="InvalidOperationException">
        /// <para>
        ///		Visual styles are not currently available.
        /// </para>
        /// </exception>
        protected virtual void DrawTabButtonBackgroundUsingVisualStyles(
            Graphics g,
            Rectangle bounds,
            TabItemState state
            )
        {
            if (g == null)
            {
                throw new ArgumentNullException("g");
            }

            if (!VisualStyleInformation.IsEnabledByUser)
            {
                throw new InvalidOperationException(Resources.InvalidOperation_VisualStyles);
            }

            TabRenderer.DrawTabItem(g, bounds, state);
        }
示例#9
0
        protected override void OnDrawItem(DrawItemEventArgs e)
        {
            base.OnDrawItem(e);

            var dragIndex = _dragTab != null?TabPages.IndexOf(_dragTab) : -1;

            var bounds = e.Bounds;

            if (_dragging && e.Index == dragIndex)
            {
                var cursorPosition = PointToClient(Cursor.Position);
                bounds.X = Math.Min(Math.Max(0, cursorPosition.X + _dragOffset), Width - bounds.Width);
            }

            if (TabRenderer.IsSupported && Application.RenderWithVisualStyles)
            {
                TabRenderer.DrawTabItem(e.Graphics, bounds, e.State == DrawItemState.Selected ? TabItemState.Selected : TabItemState.Normal);
            }

            TabPages[e.Index].BorderStyle = BorderStyle.None;
            TabPages[e.Index].ForeColor   = SystemColors.ControlText;

            var textColor = SystemColors.ControlText;

            if (_hoverTab == e.Index || e.State == DrawItemState.Selected)
            {
                //textColor = Color.White;
            }
            //if (e.State == DrawItemState.Selected) e.Graphics.FillRectangle(new SolidBrush(Color.FromArgb(180, 180, 180)), rc);
            //else if (_hoverTab == e.Index) e.Graphics.FillRectangle(new SolidBrush(Color.FromArgb(200, 200, 200)), rc);

            e.Graphics.DrawString(TabPages[e.Index].Text, this.Font, new SolidBrush(textColor), bounds.Left + 5, bounds.Top + 5);

            // Draw X:
            if (_hoverButton == e.Index)
            {
                e.Graphics.FillRectangle(Brushes.LightGray, GetButtonBounds(bounds));
            }
            if (_hoverTab == e.Index || e.State == DrawItemState.Selected)
            {
                var xFont = new Font(FontFamily.GenericSansSerif, 7);
                e.Graphics.DrawString("X", xFont, new SolidBrush(textColor), bounds.Right - 17, bounds.Top + 6);
            }
        }
示例#10
0
        protected override void OnPaint(PaintEventArgs e)
        {
            int      currentX = 2, y = Height - 23;
            bool     seled = false;
            Graphics g     = e.Graphics;

            TabRenderer.DrawTabPage(g, new Rectangle(0, Height - 1, Width, 2));
            for (int i = 0; i < allTabs.Count; i++)
            {
                seled = false;
                TabItem it = allTabs[i];

                if (it.Width == -1)
                {
                    it.Width = (int)g.MeasureString(it.Text, Font).Width + 7;
                }

                Rectangle rect = new Rectangle(currentX, y, it.Width, 22);
                if (it.TabPage == targetTab.SelectedTab)
                {
                    rect.X -= 1; rect.Height = 25; rect.Y = Height - 25; seled = true; rect.Width += 7;
                }
                if (e.ClipRectangle.IntersectsWith(rect))
                {
                    TabItemState state = TabItemState.Normal;
                    if (it.TabPage == targetTab.SelectedTab)
                    {
                        state = TabItemState.Selected;
                    }
                    else if (it.Hover)
                    {
                        state = TabItemState.Hot;
                    }

                    TabRenderer.DrawTabItem(g, rect, it.Text, Font, state);
                    //g.DrawString(it.Text, Font, Brushes.Black, rect, stringFormatCenter);
                }
                it.X      = currentX;
                currentX += seled ? it.Width + 6 : it.Width;
            }
            base.OnPaint(e);
        }
示例#11
0
        /*
         * DrawTabBodyUsingVisualStyles
         */

        /// <summary>
        /// </summary>
        /// <exception cref="ArgumentNullException">
        /// <para>
        ///		<paramref name="g"/> is <see langword="null"/>.
        /// </para>
        /// </exception>
        /// <exception cref="InvalidOperationException">
        /// <para>
        ///		Visual styles are not currently available.
        /// </para>
        /// </exception>
        protected virtual void DrawTabBodyUsingVisualStyles(Graphics g, Rectangle bounds)
        {
            if (g == null)
            {
                throw new ArgumentNullException("g");
            }

            if (!VisualStyleInformation.IsEnabledByUser)
            {
                throw new InvalidOperationException(Resources.InvalidOperation_VisualStyles);
            }

            if (
                bounds.Height > 0 &&
                bounds.Width > 0
                )
            {
                TabRenderer.DrawTabPage(g, bounds);
            }
        }
示例#12
0
        internal static void DrawSearchResultNodeText(object sender, DrawTreeNodeEventArgs e)
        {
            Font nodeFont = e.Node.NodeFont;

            if (nodeFont == null)
            {
                nodeFont = ((TreeView)sender).Font;
            }
            var clip = new Rectangle(0, e.Bounds.Y, e.Node.TreeView.Width, e.Bounds.Height);

            e.Graphics.SetClip(clip);
            var selectedStates = TreeNodeStates.Marked | TreeNodeStates.Selected | TreeNodeStates.Focused;

            if (e.Node.Tag == null)
            {
                nodeFont = new Font(nodeFont.FontFamily, nodeFont.Size - 2);
                // We use a TabRenderer to get the nice system gradient
                e.Graphics.Clear(Color.White);
                clip = new Rectangle(1, e.Bounds.Y + 1, e.Node.TreeView.ClientRectangle.Width - 3, e.Bounds.Height - 3);
                // If we're using the classic theme, then we can't use TabRender. Fall back to a simpler view.
                if (TabRenderer.IsSupported)
                {
                    TabRenderer.DrawTabItem(e.Graphics, clip, e.Node.Text, nodeFont, System.Windows.Forms.VisualStyles.TabItemState.Normal);
                }
                else
                {
                    e.Graphics.FillRectangle(SystemBrushes.ActiveCaption, clip);
                    // The fallback rendering has more empty space than the tab rendering. Take advantage of it.
                    var fallbackNodeFont = new Font(nodeFont.FontFamily, nodeFont.Size + 2);
                    e.Graphics.DrawString(e.Node.Text, fallbackNodeFont, SystemBrushes.ActiveCaptionText, clip.X, clip.Y);
                }
                using (var pen = new Pen(Color.Black, 1.0f))
                    e.Graphics.DrawLine(pen, new Point(clip.Left, clip.Bottom), new Point(clip.Right - 1, clip.Bottom));
            }
            else
            {
                e.Graphics.Clear((e.State & selectedStates) != 0 ? SystemColors.Highlight : SystemColors.ControlLightLight);
                e.Graphics.DrawString(e.Node.Text, nodeFont, (e.State & selectedStates) != 0 ? SystemBrushes.HighlightText : SystemBrushes.ControlText, new PointF(e.Bounds.X, e.Bounds.Y + 2));
            }
        }
        protected override void OnRenderButtonBackground(ToolStripItemRenderEventArgs e)
        {
            TabStrip        tabStrip = e.ToolStrip as TabStrip;
            ToolStripButton button   = e.Item as ToolStripButton;
            Rectangle       bounds   = new Rectangle(Point.Empty, e.Item.Size);

            if (tabStrip != null)
            {
                System.Windows.Forms.VisualStyles.TabItemState tabState = System.Windows.Forms.VisualStyles.TabItemState.Normal;
                if (button.Checked)
                {
                    tabState |= System.Windows.Forms.VisualStyles.TabItemState.Selected;
                }
                if (button.Selected)
                {
                    tabState |= System.Windows.Forms.VisualStyles.TabItemState.Hot;
                }


                TabRenderer.DrawTabItem(e.Graphics, bounds, tabState);

                if (button.Checked)
                {
                    VisualStyleRenderer vsr           = new VisualStyleRenderer(VisualStyleElement.Tab.TabItem.Hot);
                    Padding             borderPadding = button.Padding;
                    borderPadding.Top    += 4;
                    borderPadding.Bottom += 2;
                    borderPadding.Left   -= 2;
                    borderPadding.Right  -= 2;
                    Rectangle rect = LayoutUtils.DeflateRect(bounds, borderPadding);


                    ControlPaint.DrawFocusRectangle(e.Graphics, rect);
                }
            }
            else
            {
                base.OnRenderButtonBackground(e);
            }
        }
        protected override void OnRenderButtonBackground(ToolStripItemRenderEventArgs e)
        {
            TabStrip  tabStrip = e.ToolStrip as TabStrip;
            Tab       tab      = e.Item as Tab;
            Rectangle bounds   = new Rectangle(Point.Empty, e.Item.Size);

            if (tab != null && tabStrip != null)
            {
                System.Windows.Forms.VisualStyles.TabItemState tabState = System.Windows.Forms.VisualStyles.TabItemState.Normal;
                if (tab.Checked)
                {
                    tabState |= System.Windows.Forms.VisualStyles.TabItemState.Selected;
                }
                if (tab.Selected)
                {
                    tabState |= System.Windows.Forms.VisualStyles.TabItemState.Hot;
                }
                TabRenderer.DrawTabItem(e.Graphics, bounds, tabState);
            }
            else
            {
                base.OnRenderButtonBackground(e);
            }
        }
示例#15
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;
            }
        }
示例#16
0
        protected override void OnPaint(PaintEventArgs e)
        {
            _logger.Trace($"executing {nameof(OnPaint)}...");
            this.SuspendLayout();
            base.OnPaint(e);

            // 参考: https://dobon.net/vb/dotnet/control/tabsidebug.html#paint

            // 背景描画
            e.Graphics.Clear(this.BackColor);
            if (this.TabPages.Count == 0)
            {
                goto end;
            }

            // タブページの枠描画
            if (this.SelectedIndex < 0)
            {
                goto skip;
            }
            var page = this.TabPages[this.SelectedIndex];

            if (Application.VisualStyleState == VisualStyleState.ClientAreaEnabled ||
                Application.VisualStyleState == VisualStyleState.ClientAndNonClientAreasEnabled)
            {
                var pageRect = new Rectangle(
                    page.Bounds.X - 2,
                    page.Bounds.Y - 2,
                    page.Bounds.Width + 5,
                    page.Bounds.Height + 5);
                TabRenderer.DrawTabPage(e.Graphics, pageRect);
            }
skip:

            //タブの描画
            for (int i = 0; i < this.TabPages.Count; ++i)
            {
                var tabRect = this.GetTabRect(i);
                page = this.TabPages[i];

                // タブの状態取得
                TabItemState state;
                if (!this.Enabled)
                {
                    state = TabItemState.Disabled;
                }
                else if (this.SelectedIndex == i)
                {
                    state = TabItemState.Selected;
                }
                else if (_mouse_over == i)
                {
                    state = TabItemState.Hot;
                }
                else
                {
                    state = TabItemState.Normal;
                }

                if (this.SelectedIndex == i)
                {
                    // 選択中のタブを強調表示
                    tabRect.Y      -= 2;
                    tabRect.Height += 4;
                }

                // タブ描画
                if (Application.VisualStyleState == VisualStyleState.ClientAreaEnabled ||
                    Application.VisualStyleState == VisualStyleState.ClientAndNonClientAreasEnabled)
                {
                    TabRenderer.DrawTabItem(e.Graphics,
                                            new Rectangle(tabRect.X, tabRect.Y, tabRect.Width, tabRect.Height + 1),
                                            page.Text,
                                            page.Font,
                                            TextFormatFlags.EndEllipsis,
                                            state == TabItemState.Hot,
                                            state);
                }
                else
                {
                    var rect = new Rectangle(tabRect.X, tabRect.Y, tabRect.Width, tabRect.Height + 1);
                    switch (state)
                    {
                    case TabItemState.Selected:
                        e.Graphics.FillRectangle(SystemBrushes.ControlLightLight, rect);
                        e.Graphics.DrawRectangle(SystemPens.ControlDarkDark, rect);
                        break;

                    case TabItemState.Disabled:
                        e.Graphics.FillRectangle(SystemBrushes.ControlDark, rect);
                        e.Graphics.DrawRectangle(SystemPens.ControlDarkDark, rect);
                        break;

                    case TabItemState.Hot:
                        e.Graphics.FillRectangle(SystemBrushes.ControlLight, rect);
                        e.Graphics.DrawRectangle(SystemPens.ControlDarkDark, rect);
                        break;

                    default:                             //case TabItemState.Normal:
                        e.Graphics.FillRectangle(SystemBrushes.Control, rect);
                        e.Graphics.DrawRectangle(SystemPens.ControlDarkDark, rect);
                        break;
                    }
                    e.Graphics.DrawString(
                        page.Text,
                        page.Font,
                        Brushes.Black,
                        new RectangleF(tabRect.X + 2, tabRect.Y + 2, tabRect.Width - 2, tabRect.Height - 1));
                }

                // 閉じるボタン描画
                this.DrawCloseButton(e.Graphics, tabRect, i);
            }

end:
            this.ResumeLayout();
            _logger.Trace($"completed {nameof(OnPaint)}");
        }
示例#17
0
        private void DrawTab(PaintEventArgs e)
        {
            #region 背景描画

            e.Graphics.FillRectangle(new SolidBrush(backColor), this.ClientRectangle);
            if (TabPages.Count < 1)
            {
                return;
            }

            #endregion

            if (SelectedIndex >= 0)
            {
                #region ページ枠描画

                TabPage   tp = TabPages[SelectedIndex];
                Rectangle tr = new Rectangle();
                switch (this.Alignment)
                {
                case TabAlignment.Top:
                    tr = new Rectangle(tp.Bounds.X - 4, tp.Bounds.Y - 3, tp.Bounds.Width + 6, tp.Bounds.Height + 6);
                    break;

                case TabAlignment.Bottom:
                    tr = new Rectangle(tp.Bounds.X - 4, tp.Bounds.Y - 4, tp.Bounds.Width + 6, tp.Bounds.Height + 6);
                    break;

                case TabAlignment.Left:
                    tr = new Rectangle(tp.Bounds.X - 3, tp.Bounds.Y - 4, tp.Bounds.Width + 6, tp.Bounds.Height + 7);
                    break;

                case TabAlignment.Right:
                    tr = new Rectangle(tp.Bounds.X - 4, tp.Bounds.Y - 4, tp.Bounds.Width + 6, tp.Bounds.Height + 7);
                    break;
                }
                if (Appearance == TabAppearance.Normal)
                {
                    switch (this.Alignment)
                    {
                    case TabAlignment.Top:
                        tr.Width  += 3;
                        tr.Height += 1;
                        break;

                    case TabAlignment.Bottom:
                        tr.Width  += 3;
                        tr.Height += 2;
                        break;

                    case TabAlignment.Left:
                        tr.Width  += 2;
                        tr.Height += 1;
                        break;

                    case TabAlignment.Right:
                        tr.Width  += 3;
                        tr.Height += 1;
                        break;
                    }
                    TabRenderer.DrawTabPage(e.Graphics, tr);
                }
                else
                {
                    e.Graphics.FillRectangle(new SolidBrush(tp.BackColor), tr);
                    e.Graphics.DrawRectangle(new Pen(SystemColors.ControlDark), tr);
                }

                #endregion

                #region タブ描画

                System.Windows.Forms.VisualStyles.TabItemState    tstat;
                System.Windows.Forms.VisualStyles.PushButtonState bstat;
                for (int ii = 0; ii <= TabPages.Count; ii++)
                {
                    if (ii != SelectedIndex)
                    {
                        int i = ii;
                        if (ii == TabPages.Count)
                        {
                            i = SelectedIndex;
                        }

                        tp = TabPages[i];
                        tr = GetTabRect(i);

                        #region タブ表示状態を決定

                        if (!Enabled)
                        {
                            tstat = System.Windows.Forms.VisualStyles.TabItemState.Disabled;
                            bstat = System.Windows.Forms.VisualStyles.PushButtonState.Disabled;
                        }
                        else if (SelectedIndex == i)
                        {
                            tstat = System.Windows.Forms.VisualStyles.TabItemState.Selected;
                            bstat = System.Windows.Forms.VisualStyles.PushButtonState.Pressed;
                        }
                        else
                        {
                            tstat = System.Windows.Forms.VisualStyles.TabItemState.Normal;
                            bstat = System.Windows.Forms.VisualStyles.PushButtonState.Normal;
                        }

                        #endregion

                        #region タブの調整

                        switch (this.Alignment)
                        {
                        case TabAlignment.Top:
                            tr.Y      -= 2;
                            tr.Height += 1;
                            if (Appearance == TabAppearance.Normal)
                            {
                                if (SelectedIndex == i)
                                {
                                    tr.X      -= 2;
                                    tr.Width  += 4;
                                    tr.Height += 1;
                                }
                                else
                                {
                                    tr.Y      += 2;
                                    tr.Height -= 2;
                                }
                            }
                            break;

                        case TabAlignment.Bottom:
                            tr.Y      += 1;
                            tr.Height += 1;
                            if (Appearance == TabAppearance.Normal)
                            {
                                if (SelectedIndex == i)
                                {
                                    tr.X      -= 2;
                                    tr.Width  += 4;
                                    tr.Y      -= 1;
                                    tr.Height += 1;
                                }
                                else
                                {
                                    tr.Height -= 2;
                                }
                            }
                            break;

                        case TabAlignment.Left:
                            tr.X     -= 2;
                            tr.Width += 1;
                            if (Appearance == TabAppearance.Normal)
                            {
                                if (SelectedIndex == i)
                                {
                                    tr.Width  += 1;
                                    tr.Y      -= 2;
                                    tr.Height += 4;
                                }
                                else
                                {
                                    tr.X     += 2;
                                    tr.Width -= 2;
                                }
                            }
                            break;

                        case TabAlignment.Right:
                            tr.X     += 1;
                            tr.Width += 1;
                            if (Appearance == TabAppearance.Normal)
                            {
                                if (SelectedIndex == i)
                                {
                                    tr.X      -= 1;
                                    tr.Width  += 1;
                                    tr.Y      -= 2;
                                    tr.Height += 4;
                                }
                                else
                                {
                                    tr.Width -= 2;
                                }
                            }
                            break;
                        }

                        #endregion

                        #region タブの生成と描画

                        StringFormat sf = new StringFormat();
                        sf.Alignment     = StringAlignment.Center;
                        sf.LineAlignment = StringAlignment.Center;

                        #region ビットマップ生成

                        Size ims;
                        if (Alignment == TabAlignment.Left || Alignment == TabAlignment.Right)
                        {
                            ims = new Size(tr.Height, tr.Width);
                        }
                        else
                        {
                            ims = tr.Size;
                        }
                        String tabText = tp.Text;
                        if (Alignment == TabAlignment.Bottom)
                        {
                            tabText = "";
                        }
                        Bitmap bmp = new Bitmap(ims.Width, ims.Height);

                        #endregion

                        #region ビットマップ描画

                        Graphics g  = Graphics.FromImage(bmp);
                        Brush    tb = (Brush)SystemBrushes.ControlText.Clone();
                        switch (Appearance)
                        {
                        case TabAppearance.Normal:
                            TabRenderer.DrawTabItem(g, new Rectangle(0, 0, bmp.Width, bmp.Height + 1), tabText, tp.Font, this.Focused && tp.Equals(SelectedTab), tstat);
                            break;

                        case TabAppearance.Buttons:
                            ButtonRenderer.DrawButton(g, new Rectangle(0, 0, bmp.Width, bmp.Height), tabText, tp.Font, this.Focused && tp.Equals(SelectedTab), bstat);
                            break;

                        case TabAppearance.FlatButtons:
                            Brush fb, bb;
                            Pen   bp;
                            if (SelectedIndex == i)
                            {
                                fb = new SolidBrush(PushOnForeColor);
                                bb = new SolidBrush(PushOnBackColor);
                                bp = new Pen(PushOnBorderColor);
                            }
                            else
                            {
                                fb = new SolidBrush(PushOffForeColor);
                                bb = new SolidBrush(PushOffBackColor);
                                bp = new Pen(PushOffBorderColor);
                            }
                            g.FillRectangle(bb, new Rectangle(2, 2, bmp.Width - 4, bmp.Height - 4));
                            g.DrawRectangle(bp, new Rectangle(1, 1, bmp.Width - 3, bmp.Height - 3));
                            if (this.Focused && tp.Equals(SelectedTab))
                            {
                                Pen focusPen = new Pen(Color.DarkGoldenrod);
                                focusPen.DashStyle = System.Drawing.Drawing2D.DashStyle.Dot;
                                g.DrawRectangle(new Pen(Color.Black), new Rectangle(3, 3, bmp.Width - 7, bmp.Height - 7));
                                g.DrawRectangle(focusPen, new Rectangle(3, 3, bmp.Width - 7, bmp.Height - 7));
                            }
                            tb.Dispose();
                            tb = (Brush)fb.Clone();
                            g.DrawString(tabText, tp.Font, tb, new Rectangle(0, 0, bmp.Width, bmp.Height), sf);
                            fb.Dispose();
                            bb.Dispose();
                            break;
                        }
                        g.Dispose();

                        #endregion

                        #region ビットマップの回転

                        switch (this.Alignment)
                        {
                        case TabAlignment.Bottom:
                            bmp.RotateFlip(RotateFlipType.Rotate180FlipNone);
                            g = Graphics.FromImage(bmp);
                            g.DrawString(tp.Text, tp.Font, tb, new RectangleF(0, 0, bmp.Width, bmp.Height), sf);
                            g.Dispose();
                            break;

                        case TabAlignment.Left:
                            bmp.RotateFlip(RotateFlipType.Rotate270FlipNone);
                            break;

                        case TabAlignment.Right:
                            bmp.RotateFlip(RotateFlipType.Rotate90FlipNone);
                            break;
                        }
                        e.Graphics.DrawImage(bmp, tr);
                        bmp.Dispose();
                        tb.Dispose();
                        sf.Dispose();

                        #endregion

                        #endregion
                    }
                }

                #endregion
            }
        }
示例#18
0
        /// <summary>
        /// Draws our tab control.
        /// </summary>
        /// <param name="g">The <see cref="T:System.Drawing.Graphics"/> object used to draw tab control.</param>
        /// <param name="clipRect">The <see cref="T:System.Drawing.Rectangle"/> that specifies clipping rectangle
        /// of the control.</param>
        private void DrawCustomTabControl(Graphics g, Rectangle clipRect)
        {
            /* In this method we draw only those parts of the control which intersects with the
             * clipping rectangle. It's some kind of optimization.*/
            if (!this.Visible)
            {
                return;
            }

            //selected tab index and rectangle
            int       iSel    = this.SelectedIndex;
            Rectangle selRect = iSel != -1 ? this.GetTabRect(iSel) : Rectangle.Empty;

            Rectangle rcPage = this.ClientRectangle;

            //correcting page rectangle
            switch (this.Alignment)
            {
            case TabAlignment.Top:
            {
                int trunc = selRect.Height * this.RowCount + 2;
                rcPage.Y += trunc; rcPage.Height -= trunc;
            } break;

            case TabAlignment.Bottom: rcPage.Height -= (selRect.Height + VSTabControl.sAdjHeight) * this.RowCount; break;
            }

            //draw page itself
            if (rcPage.IntersectsWith(clipRect))
            {
                TabRenderer.DrawTabPage(g, rcPage);
            }

            int tabCount = this.TabCount;

            if (tabCount == 0)
            {
                return;
            }

            using (StringFormat textFormat = new StringFormat())
            {
                textFormat.Alignment     = StringAlignment.Center;
                textFormat.LineAlignment = StringAlignment.Center;
                //drawing unselected tabs
                this.lastHotIndex = HitTest();                //hot tab
                for (int iTab = 0; iTab < tabCount; iTab++)
                {
                    if (iTab != iSel)
                    {
                        Rectangle tabRect = this.GetTabRect(iTab);
                        if (tabRect.Right >= 3 && tabRect.IntersectsWith(clipRect))
                        {
                            TabItemState state = iTab == this.lastHotIndex ? TabItemState.Hot : TabItemState.Normal;
                            DrawTabItem(g, iTab, state, tabRect, textFormat);
                        }
                    }
                }

                /* Drawing selected tab. We'll also increase selected tab's rectangle. It should be a little
                 * bigger than other tabs.*/
                selRect.Inflate(2, 2);
                if (iSel != -1 && selRect.IntersectsWith(clipRect))
                {
                    DrawTabItem(g, iSel, TabItemState.Selected, selRect, textFormat);
                }
            }
        }
示例#19
0
    private void ReDrawTabs(Graphics graphics, Rectangle cliprectangle)
    {
        if (!this.Visible)
        {
            return;
        }

        // Draw tab page
        TabRenderer.DrawTabPage(graphics, this.ClientRectangle);

        // If there is no tabs to draw, return
        if (this.TabCount == 0)
        {
            return;
        }

        // Check tab alignment
        switch (this.Alignment)
        {
        case TabAlignment.Bottom:
            graphics.RotateTransform(180);
            break;

        case TabAlignment.Left:
            graphics.RotateTransform(90);
            break;

        case TabAlignment.Right:
            graphics.RotateTransform(-90);
            break;

        case TabAlignment.Top:
        default:
            break;
        }

        // Draw tabs
        Rectangle           tabRectangle;
        VisualStyleRenderer renderer = new VisualStyleRenderer(VisualStyleElement.Tab.TabItem.Normal);

        //TabItemState state;
        for (int i = 0; i < this.TabCount; ++i)
        {
            tabRectangle = this.GetTabRect(i);

            if (i == this.SelectedIndex)
            {
                renderer.SetParameters(VisualStyleElement.Tab.TabItem.Hot);
                //state = TabItemState.Selected;
            }
            else
            {
                renderer.SetParameters(VisualStyleElement.Tab.TabItem.Normal);
                //if(this.TabPages[i].Focused)
                //	state = TabItemState.Hot;
                //else
                //	state = TabItemState.Normal;
            }
            renderer.DrawBackground(graphics, tabRectangle);
            renderer.DrawText(graphics, tabRectangle, this.TabPages[i].Text);

            //graphics.FillRectangle(Brushes.Red, tabRectangle);
            //TabRenderer.DrawTabItem(graphics, this.ClientRectangle, state);
        }
    }
示例#20
0
        /// <summary>
        /// 绘制我们的选项卡控件。
        /// </summary>
        /// <param name="g">The <see cref="T:System.Drawing.Graphics"/> 用于绘制选项卡控制的对象.</param>
        /// <param name="clipRect">The <see cref="T:System.Drawing.Rectangle"/> the that specifies the clipping rectangle
        /// of the control.</param>
        private void DrawCustomTabControl(Graphics g, Rectangle clipRect)
        {
            /*在这个方法中,我们只绘制这些地区的控制相交的
             *              *剪辑矩形。这是某种形式的优化。*/
            if (!this.Visible)
            {
                return;
            }

            //所选的选项卡索引和矩形
            int       iSel    = this.SelectedIndex;
            Rectangle selRect = iSel != -1 ? this.GetTabRect(iSel) : Rectangle.Empty;

            Rectangle rcPage = this.ClientRectangle;

            //纠正页的矩形
            switch (this.Alignment)
            {
            case TabAlignment.Top:
            {
                int trunc = selRect.Height * this.RowCount + 2;
                rcPage.Y += trunc; rcPage.Height -= trunc;
            } break;

            case TabAlignment.Bottom: rcPage.Height -= selRect.Height * this.RowCount + 1;
                break;
            }

            //显示页面本身
            if (rcPage.IntersectsWith(clipRect))
            {
                TabRenderer.DrawTabPage(g, rcPage);
            }

            int tabCount = this.TabCount;

            if (tabCount == 0)
            {
                return;
            }

            //绘制未选中的标签
            this.lastHotIndex = HitTest();//hot tab
            VisualStyleRenderer tabRend = new VisualStyleRenderer(VisualStyleElement.Tab.TabItem.Normal);

            for (int iTab = 0; iTab < tabCount; iTab++)
            {
                if (iTab != iSel)
                {
                    Rectangle tabRect = this.GetTabRect(iTab);
                    if (tabRect.Right >= 3 && tabRect.IntersectsWith(clipRect))
                    {
                        TabItemState state = iTab == this.lastHotIndex ? TabItemState.Hot : TabItemState.Normal;
                        tabRend.SetParameters(tabRend.Class, tabRend.Part, (int)state);
                        DrawTabItem(g, iTab, tabRect, tabRend);
                    }
                }
            }

            /*绘制一个选择的选项卡。我们也将增加选定的选项卡的矩形。它应该是一个小
             *              *大于其他选项卡。*/
            selRect.Inflate(2, 2);
            if (iSel != -1 && selRect.IntersectsWith(clipRect))
            {
                tabRend.SetParameters(tabRend.Class, tabRend.Part, (int)TabItemState.Selected);
                DrawTabItem(g, iSel, selRect, tabRend);
            }
        }
示例#21
0
        protected override void OnPaint(PaintEventArgs e)
        {
            base.OnPaint(e);

            //TabControlの背景を塗る
            if (this.DesignMode)
            {
                e.Graphics.FillRectangle(SystemBrushes.Control, this.ClientRectangle);
                return;
            }
            else
            {
                Color backColor = OptionForm.Color_Control_BackColor();
                Brush backBrush = new System.Drawing.SolidBrush(backColor);
                e.Graphics.FillRectangle(backBrush, this.ClientRectangle);
                backBrush.Dispose();
            }


            if (this.TabCount == 0)
            {
                return;
            }
            if (this.SelectedIndex < 0 || this.SelectedIndex >= this.TabCount)
            {
                return;
            }

            //TabPageの枠を描画する
            TabPage   page     = this.TabPages[this.SelectedIndex];
            Rectangle pageRect = new Rectangle(
                page.Bounds.X - 2,
                page.Bounds.Y - 2,
                page.Bounds.Width + 5,
                page.Bounds.Height + 5);

            if (Application.RenderWithVisualStyles)
            {
                TabRenderer.DrawTabPage(e.Graphics, pageRect);
            }

            //タブを描画する
            for (int i = 0; i < this.TabCount; i++)
            {
                page = this.TabPages[i];
                Rectangle tabRect = this.GetTabRect(i);

                bool focused = false;
                //選択されたタブとページの間の境界線を消すために、
                //描画する範囲を大きくする
                if (this.SelectedIndex == i)
                {
                    tabRect.Height += 1;
                    focused         = true;
                }

                //画像のサイズを決定する
                Size imgSize = tabRect.Size;

                //タブの画像を作成する
                Bitmap   bmp = new Bitmap(imgSize.Width, imgSize.Height);
                Graphics g   = Graphics.FromImage(bmp);
                //高さに1足しているのは、下にできる空白部分を消すため
                Rectangle rect = new Rectangle(0, 0, bmp.Width, bmp.Height + 1);

                if (Application.RenderWithVisualStyles)
                {
                    //表示するタブの状態を決定する
                    System.Windows.Forms.VisualStyles.TabItemState state;
                    if (!this.Enabled)
                    {
                        state = System.Windows.Forms.VisualStyles.TabItemState.Disabled;
                    }
                    else if (focused)
                    {
                        state = System.Windows.Forms.VisualStyles.TabItemState.Selected;
                    }
                    else
                    {
                        state = System.Windows.Forms.VisualStyles.TabItemState.Normal;
                    }

                    TabRenderer.DrawTabItem(g,
                                            rect,
                                            false,
                                            state);
                }
                else
                {
                    if (focused)
                    {
                        g.FillRectangle(SystemBrushes.Control, rect);
                    }
                    else
                    {
                        g.FillRectangle(SystemBrushes.ControlDark, rect);
                        g.DrawRectangle(new Pen(SystemBrushes.ControlDarkDark), rect);
                    }
                }

                if (page.Text.Length > 10)
                {
                    g.DrawString(page.Text, page.Font, SystemBrushes.ControlText, new Rectangle(rect.Left + 6, rect.Top + 4, rect.Width - 20, rect.Height - 4));
                }
                else
                {
                    g.DrawString(page.Text, page.Font, SystemBrushes.ControlText, new Rectangle(rect.Left + 12, rect.Top + 4, rect.Width - 20, rect.Height - 4));
                }

                Rectangle closeButton = TabRectToCloseButtonRect(tabRect);
                if (closeButton.Contains(this.LastMouseCursor))
                {//マウスカーソルが当たっている、ボタンの背景の色を変える.
                    Brush     hoverBrush = new SolidBrush(OptionForm.Color_List_HoverColor());
                    Rectangle rc         = new Rectangle(closeButton.X - tabRect.X, closeButton.Y - tabRect.Y, closeButton.Width, closeButton.Height);
                    g.FillRectangle(hoverBrush, rc);
                    hoverBrush.Dispose();
                }
                g.DrawString("x", page.Font, SystemBrushes.ControlText, rect.Right - 15, rect.Top + 4);
                g.Dispose();

                //画像を描画する
                e.Graphics.DrawImage(bmp, tabRect.X, tabRect.Y, bmp.Width, bmp.Height);


                bmp.Dispose();
            }
        }
示例#22
0
        /// <summary>
        /// Draws our tab control.
        /// </summary>
        /// <param name="g">The <see cref="T:System.Drawing.Graphics"/> object used to draw the tab control.</param>
        /// <param name="clipRect">The <see cref="T:System.Drawing.Rectangle"/> that specifies the clipping rectangle
        /// of the control.</param>
        private void DrawCustomTabControl(Graphics g, Rectangle clipRect)
        {
            /* In this method we draw only those parts of the control which intersect with the
             * clipping rectangle. It's some kind of optimization.*/
            if (!this.Visible)
            {
                return;
            }

            //selected tab index and rectangle
            int       iSel    = this.SelectedIndex;
            Rectangle selRect = iSel != -1 ? this.GetTabRect(iSel) : Rectangle.Empty;

            Rectangle rcPage = this.ClientRectangle;

            //correcting page rectangle
            switch (this.Alignment)
            {
            case TabAlignment.Top:
                int trunc = selRect.Height * this.RowCount + 2;
                rcPage.Y += trunc; rcPage.Height -= trunc;
                break;

            case TabAlignment.Bottom:
                rcPage.Height -= selRect.Height * this.RowCount + 1;
                break;
            }

            //draw page itself
            if (rcPage.IntersectsWith(clipRect))
            {
                TabRenderer.DrawTabPage(g, rcPage);
            }

            int tabCount = this.TabCount;

            if (tabCount == 0)
            {
                return;
            }

            //drawing unselected tabs
            this.lastHotIndex = HitTest();//hot tab
            VisualStyleRenderer tabRend = new VisualStyleRenderer(VisualStyleElement.Tab.TabItem.Normal);

            for (int iTab = 0; iTab < tabCount; iTab++)
            {
                if (iTab != iSel)
                {
                    Rectangle tabRect = this.GetTabRect(iTab);
                    if (tabRect.Right >= 3 && tabRect.IntersectsWith(clipRect))
                    {
                        TabItemState state = iTab == this.lastHotIndex ? TabItemState.Hot : TabItemState.Normal;
                        tabRend.SetParameters(tabRend.Class, tabRend.Part, (int)state);
                        DrawTabItem(g, iTab, tabRect, tabRend);
                    }
                }
            }

            /* Drawing of a selected tab. We'll also increase the selected tab's rectangle. It should be a little
             * bigger than other tabs.*/
            selRect.Inflate(2, 2);
            if (iSel != -1 && selRect.IntersectsWith(clipRect))
            {
                tabRend.SetParameters(tabRend.Class, tabRend.Part, (int)TabItemState.Selected);
                DrawTabItem(g, iSel, selRect, tabRend);
            }
        }
示例#23
0
        protected override void OnDrawItem(DrawItemEventArgs e)
        {
            base.OnDrawItem(e);
            bool vert = (Alignment > TabAlignment.Bottom);
            int  off  = 1;

            if ((e.State & DrawItemState.Selected) != 0)
            {
                off = -1;
            }

            Rectangle bounds;

            if (vert)
            {
                // tabs are aligned left or right
                System.Drawing.Drawing2D.Matrix m = new System.Drawing.Drawing2D.Matrix();
                m.Translate(0, e.Bounds.Height - TabPages[0].Top);
                m.RotateAt(270, new PointF(e.Bounds.X, e.Bounds.Y));
                e.Graphics.Transform = m;
                bounds = new Rectangle(e.Bounds.Left - TabPages[0].Top, e.Bounds.Top + off,
                                       e.Bounds.Height, e.Bounds.Width);
            }
            else
            {
                // tabs are aligned top or bottom
                bounds = new Rectangle(e.Bounds.X, e.Bounds.Y + off, e.Bounds.Width, e.Bounds.Height);
            }

            if (Application.RenderWithVisualStyles)
            {
                TabItemState state = TabItemState.Normal;
                if ((e.State & DrawItemState.HotLight) != 0 ||
                    // state is never HotLight in OwnerDrawFixed mode, so use this workaround
                    (HotTrack && hotTabIndex == e.Index))
                {
                    state = TabItemState.Hot;
                }
                if ((e.State & DrawItemState.Selected) != 0)
                {
                    state = TabItemState.Selected;
                }
                if ((e.State & DrawItemState.Disabled) != 0)
                {
                    state = TabItemState.Disabled;
                }

                TextFormatFlags flags = TextFormatFlags.HorizontalCenter |
                                        TextFormatFlags.VerticalCenter | TextFormatFlags.SingleLine |
                                        TextFormatFlags.PreserveGraphicsTranslateTransform |
                                        TextFormatFlags.PreserveGraphicsClipping;
                if ((e.State & DrawItemState.NoAccelerator) != 0)
                {
                    flags |= TextFormatFlags.HidePrefix;
                }

                bool focused = (e.State & DrawItemState.Focus) != 0 &&
                               (e.State & DrawItemState.NoFocusRect) != DrawItemState.NoFocusRect;

                //bounds = GetTabRect(e.Index);

                TabRenderer.DrawTabItem(e.Graphics, bounds,
                                        TabPages[e.Index].Text, e.Font, flags, focused, state);
            }
            else
            {
                e.DrawBackground();

                using (StringFormat sf = new StringFormat(StringFormatFlags.NoClip
                                                          | StringFormatFlags.NoWrap))
                {
                    sf.HotkeyPrefix  = (e.State & DrawItemState.NoAccelerator) != 0 ? HotkeyPrefix.Hide : HotkeyPrefix.Show;
                    sf.Alignment     = StringAlignment.Center;
                    sf.LineAlignment = StringAlignment.Center;
                    Color textcol;

                    // state is never HotLight in OwnerDrawFixed mode, so use this workaround
                    if (HotTrack && hotTabIndex == e.Index)
                    {
                        textcol = SystemColors.HotTrack;
                    }
                    switch (e.State & ~(DrawItemState.Selected | DrawItemState.Focus | DrawItemState.Default))
                    {
                    case DrawItemState.Disabled:
                        textcol = SystemColors.GrayText;
                        break;

                    case DrawItemState.HotLight:
                        textcol = SystemColors.HotTrack;
                        break;

                    default:
                        textcol = ForeColor;
                        break;
                    }
                    using (Brush brush = new SolidBrush(textcol))
                    {
                        e.Graphics.DrawString(TabPages[e.Index].Text,
                                              e.Font, brush, bounds, sf);
                    }
                }

                if ((e.State & DrawItemState.Selected) != 0)
                {
                    e.DrawFocusRectangle();
                }
            }

            if (vert)
            {
                e.Graphics.ResetTransform();
            }
        }