void DrawTab(System.Drawing.Graphics g, TabVS2005 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.Skin.AutoHideStripSkin.TabGradient.StartColor; var endColor = DockPanel.Skin.AutoHideStripSkin.TabGradient.EndColor; var gradientMode = DockPanel.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 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); 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.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; }
private void Draw(System.Drawing.Graphics g) { System.Drawing.Rectangle clientRectangle = base.ClientRectangle; string content = this.Content; if (content.get_Length() != 0) { System.Drawing.RectangleF ef = new System.Drawing.RectangleF(0f, (float) (this.headerSize.get_Height() + BalloonWindow.TIPMARGIN), (float) clientRectangle.get_Width(), (float) ((clientRectangle.get_Height() - this.headerSize.get_Height()) - BalloonWindow.TIPMARGIN)); System.Drawing.Brush brush = new System.Drawing.SolidBrush(this.ForeColor); g.DrawString(content, this.Font, brush, ef); brush.Dispose(); } if (base.Icon != null) { g.DrawIcon(base.Icon, 0, 0); clientRectangle.set_X((int) (clientRectangle.get_X() + base.Icon.get_Width())); clientRectangle.set_Width((int) (clientRectangle.get_Width() - base.Icon.get_Width())); } if (this.ShowCloseButton) { clientRectangle.set_Width((int) (clientRectangle.get_Width() - 14)); } string caption = this.Caption; if (caption.get_Length() != 0) { clientRectangle.set_X((int) (clientRectangle.get_X() + BalloonWindow.TIPMARGIN)); clientRectangle.set_Width((int) (clientRectangle.get_Width() - BalloonWindow.TIPMARGIN)); System.Drawing.Brush brush2 = new System.Drawing.SolidBrush(this.ForeColor); g.DrawString(caption, this.CaptionFont, brush2, clientRectangle); brush2.Dispose(); } }
void DrawTab_ToolWindow(System.Drawing.Graphics g, TabVS2005 tab, Rectangle rect) { var rectIcon = new Rectangle(rect.X + ToolWindowImageGapLeft, rect.Y + rect.Height - 1 - ToolWindowImageGapBottom - ToolWindowImageHeight, ToolWindowImageWidth, ToolWindowImageHeight); var rectText = rectIcon; rectText.X += rectIcon.Width + ToolWindowImageGapRight; rectText.Width = rect.Width - rectIcon.Width - ToolWindowImageGapLeft - ToolWindowImageGapRight - ToolWindowTextGapRight; var rectTab = DrawHelper.RtlTransform(this, rect); rectText = DrawHelper.RtlTransform(this, rectText); rectIcon = DrawHelper.RtlTransform(this, rectIcon); var path = GetTabOutline(tab, true, false); if (DockPane.ActiveContent == tab.Content) { var startColor = DockPane.DockPanel.Skin.DockPaneStripSkin.ToolWindowGradient.ActiveTabGradient.StartColor; var endColor = DockPane.DockPanel.Skin.DockPaneStripSkin.ToolWindowGradient.ActiveTabGradient.EndColor; var gradientMode = DockPane.DockPanel.Skin.DockPaneStripSkin.ToolWindowGradient.ActiveTabGradient.LinearGradientMode; g.FillPath(new LinearGradientBrush(rectTab, startColor, endColor, gradientMode), path); g.DrawPath(PenToolWindowTabBorder, path); var textColor = DockPane.DockPanel.Skin.DockPaneStripSkin.ToolWindowGradient.ActiveTabGradient.TextColor; TextRenderer.DrawText(g, tab.Content.DockHandler.TabText, TextFont, rectText, textColor, ToolWindowTextFormat); } else { var startColor = DockPane.DockPanel.Skin.DockPaneStripSkin.ToolWindowGradient.InactiveTabGradient.StartColor; var endColor = DockPane.DockPanel.Skin.DockPaneStripSkin.ToolWindowGradient.InactiveTabGradient.EndColor; var gradientMode = DockPane.DockPanel.Skin.DockPaneStripSkin.ToolWindowGradient.InactiveTabGradient.LinearGradientMode; g.FillPath(new LinearGradientBrush(rectTab, startColor, endColor, gradientMode), path); if (Tabs.IndexOf(DockPane.ActiveContent) != Tabs.IndexOf(tab) + 1) { var pt1 = new Point(rect.Right, rect.Top + ToolWindowTabSeperatorGapTop); var pt2 = new Point(rect.Right, rect.Bottom - ToolWindowTabSeperatorGapBottom); g.DrawLine(PenToolWindowTabBorder, DrawHelper.RtlTransform(this, pt1), DrawHelper.RtlTransform(this, pt2)); } var textColor = DockPane.DockPanel.Skin.DockPaneStripSkin.ToolWindowGradient.InactiveTabGradient.TextColor; TextRenderer.DrawText(g, tab.Content.DockHandler.TabText, TextFont, rectText, textColor, ToolWindowTextFormat); } if (rectTab.Contains(rectIcon)) g.DrawIcon(tab.Content.DockHandler.Icon, rectIcon); }
private void DrawImage( System.Drawing.Graphics g, ListViewItem item, bool selected) { ImageList imageList = item.ImageList; Size imageSize = imageList.ImageSize; Rectangle imageRect = item.GetBounds(ItemBoundsPortion.Icon); if (imageRect.Width > imageSize.Width) { imageRect.X += (imageRect.Width - imageSize.Width) / 2; imageRect.Width = imageSize.Width; } if (imageRect.Height > imageSize.Height) { imageRect.Y += (imageRect.Height - imageSize.Height) / 2; imageRect.Height = imageSize.Height; } int imageIndex = item.ImageIndex != -1 ? item.ImageIndex : imageList.Images.IndexOfKey(item.ImageKey); if (selected) { IntPtr hIcon = NativeMethods.ImageList_GetIcon( imageList.Handle, imageIndex, (int)NativeMethods.ImageListDrawFlags.ILD_SELECTED); g.DrawIcon(Icon.FromHandle(hIcon), imageRect); NativeMethods.DestroyIcon(hIcon); } else { Image image = imageList.Images[imageIndex]; g.DrawImage( image, imageRect, 0, 0, image.Width, image.Height, GraphicsUnit.Pixel); } }
void DrawTab_Document(System.Drawing.Graphics g, TabVS2005 tab, Rectangle rect) { if (tab.TabWidth == 0) return; var rectIcon = new Rectangle(rect.X + DocumentIconGapLeft, rect.Y + rect.Height - 1 - DocumentIconGapBottom - DocumentIconHeight, DocumentIconWidth, DocumentIconHeight); var rectText = rectIcon; if (DockPane.DockPanel.ShowDocumentIcon) { rectText.X += rectIcon.Width + DocumentIconGapRight; rectText.Y = rect.Y; rectText.Width = rect.Width - rectIcon.Width - DocumentIconGapLeft - DocumentIconGapRight - DocumentTextGapRight; rectText.Height = rect.Height; } else rectText.Width = rect.Width - DocumentIconGapLeft - DocumentTextGapRight; var rectTab = DrawHelper.RtlTransform(this, rect); var rectBack = DrawHelper.RtlTransform(this, rect); rectBack.Width += rect.X; rectBack.X = 0; rectText = DrawHelper.RtlTransform(this, rectText); rectIcon = DrawHelper.RtlTransform(this, rectIcon); var path = GetTabOutline(tab, true, false); if (DockPane.ActiveContent == tab.Content) { var startColor = DockPane.DockPanel.Skin.DockPaneStripSkin.DocumentGradient.ActiveTabGradient.StartColor; var endColor = DockPane.DockPanel.Skin.DockPaneStripSkin.DocumentGradient.ActiveTabGradient.EndColor; var gradientMode = DockPane.DockPanel.Skin.DockPaneStripSkin.DocumentGradient.ActiveTabGradient.LinearGradientMode; g.FillPath(new LinearGradientBrush(rectBack, startColor, endColor, gradientMode), path); g.DrawPath(PenDocumentTabActiveBorder, path); var textColor = DockPane.DockPanel.Skin.DockPaneStripSkin.DocumentGradient.ActiveTabGradient.TextColor; if (DockPane.IsActiveDocumentPane) TextRenderer.DrawText(g, tab.Content.DockHandler.TabText, BoldFont, rectText, textColor, DocumentTextFormat); else TextRenderer.DrawText(g, tab.Content.DockHandler.TabText, TextFont, rectText, textColor, DocumentTextFormat); } else { var startColor = DockPane.DockPanel.Skin.DockPaneStripSkin.DocumentGradient.InactiveTabGradient.StartColor; var endColor = DockPane.DockPanel.Skin.DockPaneStripSkin.DocumentGradient.InactiveTabGradient.EndColor; var gradientMode = DockPane.DockPanel.Skin.DockPaneStripSkin.DocumentGradient.InactiveTabGradient.LinearGradientMode; g.FillPath(new LinearGradientBrush(rectBack, startColor, endColor, gradientMode), path); g.DrawPath(PenDocumentTabInactiveBorder, path); var textColor = DockPane.DockPanel.Skin.DockPaneStripSkin.DocumentGradient.InactiveTabGradient.TextColor; TextRenderer.DrawText(g, tab.Content.DockHandler.TabText, TextFont, rectText, textColor, DocumentTextFormat); } if (rectTab.Contains(rectIcon) && DockPane.DockPanel.ShowDocumentIcon) g.DrawIcon(tab.Content.DockHandler.Icon, rectIcon); }