void DrawCaption(Graphics g) { if (ClientRectangle.Width == 0 || ClientRectangle.Height == 0) { return; } Rectangle rect = ClientRectangle; using (var brush = new SolidBrush(DockPane.DockPanel.BackColor)) g.FillRectangle(brush, rect); ColorBlend captionBg; if (DockPane.IsActivated) { captionBg = ActiveBackColorGradientBlend; } else { captionBg = InactiveBackColorGradientBlend; } using (var captionBrush = new LinearGradientBrush(rect, Color.Empty, Color.Empty, LinearGradientMode.Vertical)) using (var captionPath = RoundedRectangle.Construct(rect, 4, RoundedCorner.TopLeft | RoundedCorner.TopRight)) { captionBrush.InterpolationColors = captionBg; g.FillPath(captionBrush, captionPath); } Rectangle rectCaption = rect; Rectangle rectCaptionText = rectCaption; rectCaptionText.X += TextGapLeft; rectCaptionText.Width -= TextGapLeft + TextGapRight; rectCaptionText.Width -= ButtonGapLeft + ButtonClose.Width + ButtonGapRight; if (ShouldShowAutoHideButton) { rectCaptionText.Width -= ButtonAutoHide.Width + ButtonGapBetween; } if (HasTabPageContextMenu) { rectCaptionText.Width -= ButtonOptions.Width + ButtonGapBetween; } rectCaptionText.Y += TextGapTop; rectCaptionText.Height -= TextGapTop + TextGapBottom; Color colorText; if (DockPane.IsActivated) { colorText = DockPane.DockPanel.Skin.DockPaneStripSkin.ToolWindowGradient.ActiveCaptionGradient.TextColor; } else { colorText = DockPane.DockPanel.Skin.DockPaneStripSkin.ToolWindowGradient.InactiveCaptionGradient.TextColor; } TextRenderer.DrawText(g, DockPane.CaptionText, TextFont, DrawHelper.RtlTransform(this, rectCaptionText), colorText, TextFormat); Rectangle rectDotsStrip = rectCaptionText; int textLength = (int)g.MeasureString(DockPane.CaptionText, TextFont).Width + TextGapLeft; rectDotsStrip.X += textLength; rectDotsStrip.Width -= textLength; rectDotsStrip.Height = ClientRectangle.Height; Color dotsColor; if (DockPane.IsActivated) { dotsColor = DockPane.DockPanel.Skin.DockPaneStripSkin.ToolWindowGradient.ActiveCaptionGradient.EndColor; } else { dotsColor = DockPane.DockPanel.Skin.DockPaneStripSkin.ToolWindowGradient.InactiveCaptionGradient.EndColor; } }
protected override void OnRenderMenuItemBackground(ToolStripItemRenderEventArgs e) { var item = (ToolStripMenuItem)e.Item; Graphics g = e.Graphics; e.Graphics.SmoothingMode = SmoothingMode.HighQuality; e.Graphics.PixelOffsetMode = PixelOffsetMode.None; if (item.IsOnDropDown) { item.AutoSize = false; item.Size = new Size(item.GetPreferredSize(Size.Empty).Width, 24); item.TextAlign = ContentAlignment.MiddleRight; } else { item.AutoSize = false; item.Size = new Size(item.GetPreferredSize(Size.Empty).Width + 4, 22); item.Padding = Padding.Empty; } Rectangle bounds = new Rectangle(Point.Empty, item.Size); if (bounds.Size.IsEmpty) { return; } Rectangle selectionRect; if (item.IsOnDropDown) { selectionRect = new Rectangle(bounds.X + 3, bounds.Y + 1, bounds.Width - 6, bounds.Height - 3); } else { selectionRect = new Rectangle(bounds.X + 1, bounds.Y + 2, bounds.Width - 2, bounds.Height - 5); } if (item.Pressed && !item.IsOnDropDown) { selectionRect.X--; selectionRect.Width++; selectionRect.Height += 4; using ( var rect = RoundedRectangle.Construct(selectionRect, 4, RoundedCorner.TopLeft | RoundedCorner.TopRight, RoundedEdge.Left | RoundedEdge.Top | RoundedEdge.Right)) { using (Brush brush = new SolidBrush(ColorTable.MenuItemPressedGradientMiddle)) e.Graphics.FillPath(brush, rect); using (Pen pen = new Pen(ColorTable.MenuBorder)) e.Graphics.DrawPath(pen, rect); } } else if (item.Selected) { using (var rect = RoundedRectangle.Construct(selectionRect, 4, RoundedCorner.All)) { using (Brush brush = new SolidBrush(ColorTable.MenuItemSelected)) e.Graphics.FillPath(brush, rect); var grad = new Rectangle(selectionRect.X, selectionRect.Y, selectionRect.Width, selectionRect.Height / 2 + 1); e.Graphics.SetClip(grad); using ( Brush brush = new LinearGradientBrush(grad, ColorTable.MenuItemSelectedGradientBegin, ColorTable.MenuItemSelectedGradientEnd, LinearGradientMode.Vertical)) e.Graphics.FillPath(brush, rect); e.Graphics.ResetClip(); using (Pen pen = new Pen(ColorTable.MenuItemBorder, 1f)) e.Graphics.DrawPath(pen, rect); } } }
void DrawTab(Graphics g, VS2010Tab tab) { Rectangle rectTabOrigin = GetTabRectangle(tab); if (rectTabOrigin.IsEmpty) { return; } rectTabOrigin.X++; rectTabOrigin.Width -= 2; DockState dockState = tab.Content.DockHandler.DockState; IDockContent content = tab.Content; var corner = RoundedCorner.TopLeft | RoundedCorner.TopRight; if (dockState == DockState.DockRightAutoHide || dockState == DockState.DockTopAutoHide) { corner = RoundedCorner.BottomLeft | RoundedCorner.BottomRight; } using (var brush = new LinearGradientBrush(rectTabOrigin, Color.Empty, Color.Empty, LinearGradientMode.Vertical)) using (var roundedRect = RoundedRectangle.Construct(rectTabOrigin, 6, corner)) { if (tab.IsMouseOver) { brush.InterpolationColors = HoverColorBlend; g.FillPath(brush, roundedRect); using (var pen = new Pen(new SolidBrush(VS2010Theme.ARGB(0xFF9BA7B7)))) g.DrawPath(pen, roundedRect); } else { brush.InterpolationColors = InactiveColorBlend; g.FillPath(brush, roundedRect); } } //Set no rotate for drawing icon and text Matrix matrixRotate = g.Transform; g.Transform = MatrixIdentity; // Draw the icon Rectangle rectImage = rectTabOrigin; rectImage.X += ImageGapLeft; rectImage.Y += ImageGapTop; int imageHeight = rectTabOrigin.Height - ImageGapTop - ImageGapBottom; int imageWidth = ImageWidth; if (imageHeight > ImageHeight) { imageWidth = ImageWidth * (imageHeight / ImageHeight); } rectImage.Height = imageHeight; rectImage.Width = imageWidth; rectImage = GetTransformedRectangle(dockState, rectImage); if (dockState == DockState.DockLeftAutoHide || dockState == DockState.DockRightAutoHide) { // The DockState is DockLeftAutoHide or DockRightAutoHide, so rotate the image 90 degrees to the right. Rectangle rectTransform = RtlTransform(rectImage, dockState); Point[] rotationPoints = { new Point(rectTransform.X + rectTransform.Width, rectTransform.Y), new Point(rectTransform.X + rectTransform.Width, rectTransform.Y + rectTransform.Height), new Point(rectTransform.X, rectTransform.Y) }; using (Icon rotatedIcon = new Icon(((Form)content).Icon, 16, 16)) { g.DrawImage(rotatedIcon.ToBitmap(), rotationPoints); } } else { // Draw the icon normally without any rotation. using (var icon = new Icon(((Form)content).Icon, rectImage.Size)) g.DrawIcon(icon, RtlTransform(rectImage, dockState)); } // Draw the text Rectangle rectText = rectTabOrigin; rectText.X += ImageGapLeft + imageWidth + ImageGapRight + TextGapLeft; rectText.Width -= ImageGapLeft + imageWidth + ImageGapRight + TextGapLeft; rectText = RtlTransform(GetTransformedRectangle(dockState, rectText), dockState); Color textColor = DockPanel.Skin.AutoHideStripSkin.TabGradient.TextColor; if (dockState == DockState.DockLeftAutoHide || dockState == DockState.DockRightAutoHide) { g.DrawString(content.DockHandler.TabText, TextFont, new SolidBrush(textColor), rectText, StringFormatTabVertical); } else { g.DrawString(content.DockHandler.TabText, TextFont, new SolidBrush(textColor), rectText, StringFormatTabHorizontal); } // Set rotate back g.Transform = matrixRotate; }