Example #1
0
        private void DrawTab(Graphics g, AutoHideTabVS2003 tab)
        {
            Rectangle rectTab = GetTabRectangle(tab);

            if (rectTab.IsEmpty)
            {
                return;
            }

            DockState   dockState = tab.Content.DockState;
            DockContent content   = tab.Content;

            OnBeginDrawTab(tab);

            Brush brushTabBackGround = BrushTabBackground;
            Pen   penTabBorder       = PenTabBorder;
            Brush brushTabText       = BrushTabText;

            g.FillRectangle(brushTabBackGround, rectTab);

            g.DrawLine(penTabBorder, rectTab.Left, rectTab.Top, rectTab.Left, rectTab.Bottom);
            g.DrawLine(penTabBorder, rectTab.Right, rectTab.Top, rectTab.Right, rectTab.Bottom);
            if (dockState == DockState.DockTopAutoHide || dockState == DockState.DockRightAutoHide)
            {
                g.DrawLine(penTabBorder, rectTab.Left, rectTab.Bottom, rectTab.Right, rectTab.Bottom);
            }
            else
            {
                g.DrawLine(penTabBorder, rectTab.Left, rectTab.Top, rectTab.Right, rectTab.Top);
            }

            // Set no rotate for drawing icon and text
            Matrix matrixRotate = g.Transform;

            g.Transform = MatrixIdentity;

            // Draw the icon
            Rectangle rectImage = rectTab;

            rectImage.X += ImageGapLeft;
            rectImage.Y += ImageGapTop;
            int imageHeight = rectTab.Height - ImageGapTop - ImageGapBottom;
            int imageWidth  = ImageWidth;

            if (imageHeight > ImageHeight)
            {
                imageWidth = ImageWidth * (imageHeight / ImageHeight);
            }
            rectImage.Height = imageHeight;
            rectImage.Width  = imageWidth;
            rectImage        = GetTransformedRectangle(dockState, rectImage);
            g.DrawIcon(content.Icon, rectImage);

            // Draw the text
            if (content == content.Pane.ActiveContent)
            {
                Rectangle rectText = rectTab;
                rectText.X     += ImageGapLeft + imageWidth + ImageGapRight + TextGapLeft;
                rectText.Width -= ImageGapLeft + imageWidth + ImageGapRight + TextGapLeft;
                rectText        = GetTransformedRectangle(dockState, rectText);
                if (dockState == DockState.DockLeftAutoHide || dockState == DockState.DockRightAutoHide)
                {
                    g.DrawString(content.TabText, Font, brushTabText, rectText, StringFormatTabVertical);
                }
                else
                {
                    g.DrawString(content.TabText, Font, brushTabText, rectText, StringFormatTabHorizontal);
                }
            }

            // Set rotate back
            g.Transform = matrixRotate;

            OnEndDrawTab(tab);
        }