private void DrawTab_ToolWindow(Graphics g, IDockContent content, Rectangle rect, int index) { Rectangle rectIcon = new Rectangle(rect.X + ToolWindowImageGapLeft, rect.Y + rect.Height - 1 - ToolWindowImageGapBottom - ToolWindowImageHeight, ToolWindowImageWidth, ToolWindowImageHeight); Rectangle rectText = rectIcon; rectText.X += rectIcon.Width + ToolWindowImageGapRight; rectText.Width = rect.Width - rectIcon.Width - ToolWindowImageGapLeft - ToolWindowImageGapRight - ToolWindowTextGapRight; g.SmoothingMode = SmoothingMode.AntiAlias; if (object.ReferenceEquals(DockPane.ActiveContent, content)) { DrawHelper.DrawTab(g, rect, BaseControls.Docking.DrawHelper.Corners.Bottom, BaseControls.Docking.DrawHelper.GradientType.Flat, Color.LightBlue, Color.WhiteSmoke, Color.Gray, false); g.DrawString(content.DockHandler.TabText, Font, ActiveTextBrush, rectText, ToolWindowTextStringFormat); } else { if (Tabs.IndexOf(DockPane.ActiveContent) != Tabs.IndexOf(content) + 1) { g.DrawLine(TabSeperatorPen, rect.X + rect.Width - 1, rect.Y + ToolWindowTabSeperatorGapTop, rect.X + rect.Width - 1, rect.Y + rect.Height - 1 - ToolWindowTabSeperatorGapBottom); } g.DrawString(content.DockHandler.TabText, Font, InactiveTextBrush, rectText, ToolWindowTextStringFormat); } if (rect.Contains(rectIcon)) { g.DrawIcon(content.DockHandler.Icon, rectIcon); } }
private void DrawTabStrip_ToolWindow(Graphics g) { // TODO: Clean up and add properties for colors g.SmoothingMode = SmoothingMode.AntiAlias; for (int i = 0; i <= Tabs.Count - 1; i++) { Rectangle tabrect = GetTabRectangle(i); Rectangle rectIcon = new Rectangle(tabrect.X + ToolWindowImageGapLeft, tabrect.Y + tabrect.Height - 1 - ToolWindowImageGapBottom - ToolWindowImageHeight, ToolWindowImageWidth, ToolWindowImageHeight); Rectangle rectText = rectIcon; rectText.X += rectIcon.Width + ToolWindowImageGapRight; rectText.Width = tabrect.Width - rectIcon.Width - ToolWindowImageGapLeft - ToolWindowImageGapRight - ToolWindowTextGapRight; if (object.ReferenceEquals(DockPane.ActiveContent, Tabs[i].Content)) { // color area as the tab g.FillRectangle(new SolidBrush(Color.FromArgb(252, 252, 254)), ClientRectangle.X, ClientRectangle.Y - 1, ClientRectangle.Width - 1, tabrect.Y + 2); DrawHelper.DrawTab(g, tabrect, BaseControls.Docking.DrawHelper.Corners.Bottom, BaseControls.Docking.DrawHelper.GradientType.Flat, Color.FromArgb(252, 252, 254), Color.FromArgb(252, 252, 254), Color.FromArgb(172, 168, 153), false); // line to the left g.DrawLine(TabSeperatorPen, tabrect.X, tabrect.Y + 1, ClientRectangle.X, tabrect.Y + 1); // line to the right g.DrawLine(TabSeperatorPen, tabrect.X + tabrect.Width, tabrect.Y + 1, ClientRectangle.Width, tabrect.Y + 1); // text g.DrawString(Tabs[i].Content.DockHandler.TabText, Font, new SolidBrush(Color.Black), rectText, ToolWindowTextStringFormat); } else { if (Tabs.IndexOf(DockPane.ActiveContent) != Tabs.IndexOf(Tabs[i].Content) + 1 && Tabs.IndexOf(Tabs[i].Content) != Tabs.Count - 1) { g.DrawLine(TabSeperatorPen, tabrect.X + tabrect.Width - 1, tabrect.Y + ToolWindowTabSeperatorGapTop, tabrect.X + tabrect.Width - 1, tabrect.Y + tabrect.Height - 1 - ToolWindowTabSeperatorGapBottom); } g.DrawString(Tabs[i].Content.DockHandler.TabText, Font, InactiveTextBrush, rectText, ToolWindowTextStringFormat); } if (tabrect.Contains(rectIcon)) { g.DrawIcon(Tabs[i].Content.DockHandler.Icon, rectIcon); } } }
private void DrawTab(Graphics g, Tab tab) { Rectangle rectTab = GetTabRectangle(tab); if (rectTab.IsEmpty) { return; } DockState dockState = tab.Content.DockHandler.DockState; IDockContent content = tab.Content; BeginDrawTab(); Brush brushTabBackGround = this.BrushTabBackGround; Pen penTabBorder = this.PenTabBorder; Brush brushTabText = this.BrushTabText; g.SmoothingMode = SmoothingMode.AntiAlias; if (dockState == DockState.DockTopAutoHide || dockState == DockState.DockRightAutoHide) { DrawHelper.DrawTab(g, rectTab, BaseControls.Docking.DrawHelper.Corners.Bottom, BaseControls.Docking.DrawHelper.GradientType.Flat, Color.FromArgb(244, 242, 232), Color.FromArgb(244, 242, 232), Color.FromArgb(172, 168, 153), true); } else { DrawHelper.DrawTab(g, rectTab, BaseControls.Docking.DrawHelper.Corners.Top, BaseControls.Docking.DrawHelper.GradientType.Flat, Color.FromArgb(244, 242, 232), Color.FromArgb(244, 242, 232), Color.FromArgb(172, 168, 153), true); } // 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 = this.ImageWidth; if (imageHeight > this.ImageHeight) { imageWidth = this.ImageWidth * (imageHeight / this.ImageHeight); } rectImage.Height = imageHeight; rectImage.Width = imageWidth; rectImage = GetTransformedRectangle(dockState, rectImage); g.DrawIcon(content.DockHandler.Icon, rectImage); // Draw the text if (object.ReferenceEquals(content, content.DockHandler.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.DockHandler.TabText, Font, brushTabText, rectText, StringFormatTabVertical); } else { g.DrawString(content.DockHandler.TabText, Font, brushTabText, rectText, StringFormatTabHorizontal); } } // Set rotate back g.Transform = matrixRotate; EndDrawTab(); }