private Rectangle GetTabRectangle(TabNG tab, bool transformed) { var dockState = tab.Content.DockHandler.DockState; var rectTabStrip = GetLogicalTabStripRectangle(dockState); if (rectTabStrip.IsEmpty) { return(Rectangle.Empty); } var x = tab.TabX; var y = rectTabStrip.Y + (dockState == DockState.DockTopAutoHide || dockState == DockState.DockRightAutoHide ? 0 : TabGapTop); var width = tab.TabWidth; var height = rectTabStrip.Height - TabGapTop; if (!transformed) { return(new Rectangle(x, y, width, height)); } else { return(GetTransformedRectangle(dockState, new Rectangle(x, y, width, height))); } }
private GraphicsPath GetTabOutline(TabNG tab, bool transformed, bool rtlTransform) { var dockState = tab.Content.DockHandler.DockState; var rectTab = GetTabRectangle(tab, transformed); if (rtlTransform) { rectTab = RtlTransform(rectTab, dockState); } var upTab = (dockState == DockState.DockLeftAutoHide || dockState == DockState.DockBottomAutoHide); DrawHelper.GetRoundedCornerTab(GraphicsPath, rectTab, upTab); return(GraphicsPath); }
private Rectangle GetTabRectangle(TabNG tab) { return(GetTabRectangle(tab, false)); }
private void DrawTab(Graphics g, TabNG tab) { var rectTabOrigin = GetTabRectangle(tab); if (rectTabOrigin.IsEmpty) { return; } var dockState = tab.Content.DockHandler.DockState; var content = tab.Content; var path = GetTabOutline(tab, false, true); var startColor = DockPanel.Theme.Skin.AutoHideStripSkin.TabGradient.StartColor; var endColor = DockPanel.Theme.Skin.AutoHideStripSkin.TabGradient.EndColor; var gradientMode = DockPanel.Theme.Skin.AutoHideStripSkin.TabGradient.LinearGradientMode; g.FillPath(new LinearGradientBrush(rectTabOrigin, startColor, endColor, gradientMode), path); g.DrawPath(PenTabBorder, path); // Set no rotate for drawing icon and text using (var matrixRotate = g.Transform) { g.Transform = MatrixIdentity; // Draw the icon var rectImage = rectTabOrigin; rectImage.X += ImageGapLeft; rectImage.Y += ImageGapTop; var imageHeight = rectTabOrigin.Height - ImageGapTop - ImageGapBottom; var 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. var 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 (var rotatedIcon = new Icon(((Form)content).Icon, 16, 16)) { g.DrawImage(rotatedIcon.ToBitmap(), rotationPoints); } } else { // Draw the icon normally without any rotation. g.DrawIcon(((Form)content).Icon, RtlTransform(rectImage, dockState)); } // Draw the text var rectText = rectTabOrigin; rectText.X += ImageGapLeft + imageWidth + ImageGapRight + TextGapLeft; rectText.Width -= ImageGapLeft + imageWidth + ImageGapRight + TextGapLeft; rectText = RtlTransform(GetTransformedRectangle(dockState, rectText), dockState); var textColor = DockPanel.Theme.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; } }