/// <summary>Internal method for rendering an individual <paramref name="tab" /> to the screen.</summary> /// <param name="graphicsContext">Graphics context to use when rendering the tab.</param> /// <param name="tab">Individual tab that we are to render.</param> /// <param name="area">Area of the screen that the tab should be rendered to.</param> /// <param name="cursor">Current position of the cursor.</param> protected virtual void Render(Graphics graphicsContext, TitleBarTab tab, Rectangle area, Point cursor) { if (_suspendRendering) { return; } // If we need to redraw the tab image if (tab.TabImage == null) { // We render the tab to an internal property so that we don't necessarily have to redraw it in every rendering pass, only if its width or // status have changed tab.TabImage = new Bitmap( area.Width, tab.Active ? _activeCenterImage.Height : _inactiveCenterImage.Height); using (Graphics tabGraphicsContext = Graphics.FromImage(tab.TabImage)) { // Draw the left, center, and right portions of the tab tabGraphicsContext.DrawImage( tab.Active ? _activeLeftSideImage : _inactiveLeftSideImage, new Rectangle( 0, 0, tab.Active ? _activeLeftSideImage .Width : _inactiveLeftSideImage .Width, tab.Active ? _activeLeftSideImage. Height : _inactiveLeftSideImage .Height), 0, 0, tab.Active ? _activeLeftSideImage.Width : _inactiveLeftSideImage.Width, tab.Active ? _activeLeftSideImage.Height : _inactiveLeftSideImage.Height, GraphicsUnit.Pixel); tabGraphicsContext.DrawImage( tab.Active ? _activeCenterImage : _inactiveCenterImage, new Rectangle( (tab.Active ? _activeLeftSideImage. Width : _inactiveLeftSideImage .Width), 0, _tabContentWidth, tab.Active ? _activeCenterImage . Height : _inactiveCenterImage . Height), 0, 0, _tabContentWidth, tab.Active ? _activeCenterImage.Height : _inactiveCenterImage.Height, GraphicsUnit.Pixel); tabGraphicsContext.DrawImage( tab.Active ? _activeRightSideImage : _inactiveRightSideImage, new Rectangle( (tab.Active ? _activeLeftSideImage .Width : _inactiveLeftSideImage .Width) + _tabContentWidth, 0, tab.Active ? _activeRightSideImage .Width : _inactiveRightSideImage .Width, tab.Active ? _activeRightSideImage .Height : _inactiveRightSideImage .Height), 0, 0, tab.Active ? _activeRightSideImage.Width : _inactiveRightSideImage.Width, tab.Active ? _activeRightSideImage.Height : _inactiveRightSideImage. Height, GraphicsUnit.Pixel); // Draw the close button if (tab.ShowCloseButton) { Image closeButtonImage = IsOverCloseButton(tab, cursor) ? _closeButtonHoverImage : _closeButtonImage; tab.CloseButtonArea = new Rectangle( area.Width - (tab.Active ? _activeRightSideImage.Width : _inactiveRightSideImage.Width) - CloseButtonMarginRight - closeButtonImage.Width, CloseButtonMarginTop, closeButtonImage.Width, closeButtonImage.Height); tabGraphicsContext.DrawImage( closeButtonImage, tab.CloseButtonArea, 0, 0, closeButtonImage.Width, closeButtonImage.Height, GraphicsUnit.Pixel); } } tab.Area = area; } // Render the tab's saved image to the screen graphicsContext.DrawImage( tab.TabImage, area, 0, 0, tab.TabImage.Width, tab.TabImage.Height, GraphicsUnit.Pixel); // Render the icon for the tab's content, if it exists and there's room for it in the tab's content area if (tab.Content.ShowIcon && _tabContentWidth > 16 + IconMarginLeft + (tab.ShowCloseButton ? CloseButtonMarginLeft + tab.CloseButtonArea.Width + CloseButtonMarginRight : 0)) { graphicsContext.DrawIcon( new Icon(tab.Content.Icon, 16, 16), new Rectangle(area.X + OverlapWidth + IconMarginLeft, IconMarginTop + area.Y, 16, 16)); } // Render the caption for the tab's content if there's room for it in the tab's content area if (_tabContentWidth > (tab.Content.ShowIcon ? 16 + IconMarginLeft + IconMarginRight : 0) + CaptionMarginLeft + CaptionMarginRight + (tab.ShowCloseButton ? CloseButtonMarginLeft + tab.CloseButtonArea.Width + CloseButtonMarginRight : 0)) { graphicsContext.DrawString( tab.Caption, SystemFonts.CaptionFont, Brushes.Black, new Rectangle( area.X + OverlapWidth + CaptionMarginLeft + (tab.Content.ShowIcon ? IconMarginLeft + 16 + IconMarginRight : 0), CaptionMarginTop + area.Y, _tabContentWidth - (tab.Content.ShowIcon ? IconMarginLeft + 16 + IconMarginRight : 0) - (tab.ShowCloseButton ? _closeButtonImage.Width + CloseButtonMarginRight + CloseButtonMarginLeft : 0), tab.TabImage.Height), new StringFormat(StringFormatFlags.NoWrap) { Trimming = StringTrimming.EllipsisCharacter }); } }
internal override void draw(Graphics g) { RectangleF rcNode = item.getRotatedBounds(); Rectangle rcDev = Utilities.docToDevice(g, getIconRect(rcNode)); if (rcDev.Width < 6 || rcDev.Height < 6) return; GraphicsState state = g.Save(); item.flowChart.unsetTransforms(g); if ((item as Node).Expanded) g.DrawIcon(imgExpanded, rcDev.X, rcDev.Y); else g.DrawIcon(imgCollapsed, rcDev.X, rcDev.Y); g.Restore(state); }
/// <summary> /// Draws the icon to the legend /// </summary> /// <param name="g"></param> /// <param name="box"></param> public override void LegendSymbol_Painted(Graphics g, Rectangle box) { if (_icon != null) { g.DrawIcon(_icon, box); } }
public static System.Drawing.Icon GetIcon(string text) { //Create bitmap, kind of canvas System.Drawing.Bitmap bitmap = new System.Drawing.Bitmap(32, 32); Icon icon = Resources.Status; System.Drawing.Font drawFont = new System.Drawing.Font("Calibri", 18, FontStyle.Regular); System.Drawing.SolidBrush drawBrush = new System.Drawing.SolidBrush(System.Drawing.Color.White); System.Drawing.Graphics graphics = System.Drawing.Graphics.FromImage(bitmap); graphics.TextRenderingHint = System.Drawing.Text.TextRenderingHint.SingleBitPerPixel; graphics.DrawIcon(icon, 0, 0); graphics.DrawString(text, drawFont, drawBrush, 0, 0); //To Save icon to disk bitmap.Save("icon.ico", System.Drawing.Imaging.ImageFormat.Icon); Icon createdIcon = Icon.FromHandle(bitmap.GetHicon()); drawFont.Dispose(); drawBrush.Dispose(); graphics.Dispose(); bitmap.Dispose(); return(createdIcon); }
public void Draw() { _size = new Size(_parent.Width, 25); _gradient_rect.Size = new Size(_size.Width / 2, 25); _gradient_rect.Location = new Point(_size.Width / 2, 0); _back_rect.Size = new Size(_size.Width / 2, 25); PointF text_loc = new PointF(_back_rect.Location.X + 5, _back_rect.Location.Y + 5); System.Drawing.Graphics g = Graphics.FromHwnd(_parent.Handle); LinearGradientBrush gradient_brush = new LinearGradientBrush(_gradient_rect, _leftcolor, _rightcolor, (float)0, false); LinearGradientBrush font_brush = new LinearGradientBrush(_back_rect, _textcolor, _textcolor, (float)0, false); g.FillRectangle(new SolidBrush(_leftcolor), _back_rect); g.FillRectangle(gradient_brush, _gradient_rect); g.DrawString(_text, _header_font, font_brush, text_loc); Icon icon; if (_parent.State == TaskBoxStates.Expanded || _parent.State == TaskBoxStates.Expanding) { if (_state == HeaderStates.Hovered) { icon = _chevron_up_hover; } else { icon = _chevron_up_nonhover; } } else { if (_state == HeaderStates.Hovered) { icon = _chevron_down_hover; } else { icon = _chevron_down_nonhover; } } if (icon != null) { g.DrawIcon(icon, _size.Width - icon.Width - 3, 3); } }
private void Detector_Paint(object sender, PaintEventArgs e) { this.SuspendLayout(); System.Drawing.Graphics formGraphics = this.CreateGraphics(); if ((int)animation.Tag < 0) { formGraphics.Clear(this.BackColor); } System.Drawing.SolidBrush myBrush = new System.Drawing.SolidBrush(System.Drawing.Color.FromArgb(255, 0, 0, 0)); formGraphics.FillEllipse(myBrush, new Rectangle(this.SizeValue / -2, this.SizeValue / -2, this.SizeValue, this.SizeValue)); myBrush.Dispose(); System.Drawing.Pen myBrushB = new System.Drawing.Pen(System.Drawing.Color.DarkSalmon, 3); formGraphics.DrawEllipse(myBrushB, new Rectangle(this.SizeValue / -2, this.SizeValue / -2, this.SizeValue, this.SizeValue)); myBrushB.Dispose(); if (SizeValue == SizeMax) { var iPos = new Rectangle(30, 130, 34, 34); var dCircle = Convert.ToInt32(Math.Round(Math.Sqrt(iPos.Width * iPos.Width + iPos.Height * iPos.Height), 0)); var iCircle = new Rectangle(iPos.X - (dCircle - iPos.Width) / 2, iPos.Y - (dCircle - iPos.Height) / 2, dCircle, dCircle); myBrush = new System.Drawing.SolidBrush(System.Drawing.Color.FromArgb(255, 0, 0, 0)); formGraphics.FillEllipse(myBrush, iCircle); myBrush.Dispose(); formGraphics.DrawIcon(System.Drawing.Icon.FromHandle(Properties.Resources.GCBA.GetHicon()), iPos); var pen = new System.Drawing.Pen(System.Drawing.Color.DarkSalmon, 2); formGraphics.DrawEllipse(pen, iCircle); pen.Dispose(); myBrush = new System.Drawing.SolidBrush(System.Drawing.Color.FromArgb(255, 0, 0, 0)); formGraphics.FillEllipse(myBrush, new Rectangle(75, 100, 32, 32)); myBrush.Dispose(); formGraphics.DrawIcon(System.Drawing.Icon.FromHandle(Properties.Resources.NACION.GetHicon()), new Rectangle(75, 100, 32, 32)); } formGraphics.Dispose(); this.Opacity = 10; this.ResumeLayout(); }
public override void Draw(Graphics graphics, RenderMode rm) { if (icon != null) { graphics.SmoothingMode = SmoothingMode.HighQuality; graphics.InterpolationMode = InterpolationMode.NearestNeighbor; graphics.CompositingQuality = CompositingQuality.Default; graphics.PixelOffsetMode = PixelOffsetMode.HighQuality; graphics.DrawIcon(icon, Bounds); } }
public void DrawIcon(Icon icon, Rectangle targetRect) { Bitmap currentBitmap = new Bitmap(icon.Width, icon.Height); System.Drawing.Graphics g = System.Drawing.Graphics.FromImage(currentBitmap); g.DrawIcon(icon, new Rectangle(0, 0, targetRect.Width, targetRect.Height)); this.DrawImage(currentBitmap, targetRect); currentBitmap.Dispose(); }
public static Icon GetIcon(string text) { string pat1 = string.Format(@"{0}\{1}.ico", AppDomain.CurrentDomain.BaseDirectory, "LogoBaoBao"); //Create bitmap, kind of canvas Bitmap bitmap = new Bitmap(32, 32); Icon icon = new Icon(pat1); System.Drawing.Font drawFont = new System.Drawing.Font("Calibri", 16, FontStyle.Bold); System.Drawing.SolidBrush drawBrush = new System.Drawing.SolidBrush(System.Drawing.Color.White); System.Drawing.Graphics graphics = System.Drawing.Graphics.FromImage(bitmap); graphics.TextRenderingHint = System.Drawing.Text.TextRenderingHint.SingleBitPerPixel; graphics.DrawIcon(icon, 0, 0); graphics.DrawString(text, drawFont, drawBrush, 1, 2); //To Save icon to disk bitmap.Save("icon.ico", System.Drawing.Imaging.ImageFormat.Icon); Icon createdIcon = Icon.FromHandle(bitmap.GetHicon()); drawFont.Dispose(); drawBrush.Dispose(); graphics.Dispose(); bitmap.Dispose(); return(createdIcon); }
public static Icon GetIcon(string text) { Bitmap bitmap = new Bitmap(32, 32); string iconPath = @"xicon.ico"; Icon icon = new Icon(iconPath); System.Drawing.Font drawFont = new System.Drawing.Font("Calibri", 16, FontStyle.Bold); System.Drawing.SolidBrush drawBrush = new System.Drawing.SolidBrush(System.Drawing.Color.White); System.Drawing.Graphics graphics = System.Drawing.Graphics.FromImage(bitmap); graphics.TextRenderingHint = System.Drawing.Text.TextRenderingHint.SingleBitPerPixel; graphics.DrawIcon(icon, 0, 0); graphics.DrawString(text, drawFont, drawBrush, 1, 2); Icon createdIcon = Icon.FromHandle(bitmap.GetHicon()); drawFont.Dispose(); drawBrush.Dispose(); graphics.Dispose(); bitmap.Dispose(); return(createdIcon); }
public static void DrawIcon(Graphics g,Icon icon,Rectangle drawRect,bool grayed,bool pushed) { // If Graphics or Icon isn't valid, // just skip this function. if(g == null || icon == null){ return; } // Icon pushed state, update icon location. if(pushed){ drawRect.Location = new Point(drawRect.X + 1,drawRect.Y + 1); } //----- Draw Icon --- if(grayed){ // Draw grayed icon Size s = new Size(drawRect.Size.Width-1,drawRect.Size.Height-1); ControlPaint.DrawImageDisabled(g,new Bitmap(icon.ToBitmap(),s),drawRect.X,drawRect.Y,Color.Transparent); } else{ // Draw normal icon g.DrawIcon(icon,drawRect); } }
protected virtual void DrawStatusBarPanel (Graphics dc, Rectangle area, int index, Brush br_forecolor, StatusBarPanel panel) { int border_size = 3; // this is actually const, even if the border style is none int icon_width = 16; area.Height -= border_size; DrawStatusBarPanelBackground (dc, area, panel); if (panel.Style == StatusBarPanelStyle.OwnerDraw) { StatusBarDrawItemEventArgs e = new StatusBarDrawItemEventArgs ( dc, panel.Parent.Font, area, index, DrawItemState.Default, panel, panel.Parent.ForeColor, panel.Parent.BackColor); panel.Parent.OnDrawItemInternal (e); return; } string text = panel.Text; StringFormat string_format = new StringFormat (); string_format.Trimming = StringTrimming.Character; string_format.FormatFlags = StringFormatFlags.NoWrap; if (text != null && text.Length > 0 && text [0] == '\t') { string_format.Alignment = StringAlignment.Center; text = text.Substring (1); if (text [0] == '\t') { string_format.Alignment = StringAlignment.Far; text = text.Substring (1); } } Rectangle string_rect = Rectangle.Empty; int x; int len; int icon_x = 0; int y = (area.Height / 2 - (int) panel.Parent.Font.Size / 2) - 1; switch (panel.Alignment) { case HorizontalAlignment.Right: len = (int) dc.MeasureString (text, panel.Parent.Font).Width; x = area.Right - len - 4; string_rect = new Rectangle (x, y, area.Right - x - border_size, area.Bottom - y - border_size); if (panel.Icon != null) { icon_x = x - icon_width - 2; } break; case HorizontalAlignment.Center: len = (int) dc.MeasureString (text, panel.Parent.Font).Width; x = area.Left + ((panel.Width - len) / 2); string_rect = new Rectangle (x, y, area.Right - x - border_size, area.Bottom - y - border_size); if (panel.Icon != null) { icon_x = x - icon_width - 2; } break; default: int left = area.Left + border_size;; if (panel.Icon != null) { icon_x = area.Left + 2; left = icon_x + icon_width + 2; } x = left; string_rect = new Rectangle (x, y, area.Right - x - border_size, area.Bottom - y - border_size); break; } RectangleF clip_bounds = dc.ClipBounds; dc.SetClip (area); dc.DrawString (text, panel.Parent.Font, br_forecolor, string_rect, string_format); dc.SetClip (clip_bounds); if (panel.Icon != null) { dc.DrawIcon (panel.Icon, new Rectangle (icon_x, y, icon_width, icon_width)); } }
private void DrawTab_Document( Graphics g, TabVS2003 tab, Rectangle rect ) { Rectangle rectText = rect; if( DockPane.DockPanel.ShowDocumentIcon ) { rectText.X += DocumentIconWidth + DocumentIconGapLeft; rectText.Width -= DocumentIconWidth + DocumentIconGapLeft; } if( DockPane.ActiveContent == tab.Content ) { g.FillRectangle( ActiveBackBrush, rect ); g.DrawLine( OutlineOuterPen, rect.X, rect.Y, rect.X, rect.Y + rect.Height ); g.DrawLine( OutlineOuterPen, rect.X, rect.Y, rect.X + rect.Width - 1, rect.Y ); g.DrawLine( OutlineInnerPen, rect.X + rect.Width - 1, rect.Y, rect.X + rect.Width - 1, rect.Y + rect.Height - 1 ); if( DockPane.DockPanel.ShowDocumentIcon ) { Icon icon = ( tab.Content as Form ).Icon; Rectangle rectIcon = new Rectangle( rect.X + DocumentIconGapLeft, rect.Y + ( rect.Height - DocumentIconHeight ) / 2, DocumentIconWidth, DocumentIconHeight ); g.DrawIcon( tab.ContentForm.Icon, rectIcon ); } if( DockPane.IsActiveDocumentPane ) { using( Font boldFont = new Font( this.Font, FontStyle.Bold ) ) { TextRenderer.DrawText( g, tab.Content.DockHandler.TabText, boldFont, rectText, ActiveTextColor, DocumentTextFormat ); } } else TextRenderer.DrawText( g, tab.Content.DockHandler.TabText, Font, rectText, InactiveTextColor, DocumentTextFormat ); } else { if( Tabs.IndexOf( DockPane.ActiveContent ) != Tabs.IndexOf( tab ) + 1 ) g.DrawLine( TabSeperatorPen, rect.X + rect.Width - 1, rect.Y, rect.X + rect.Width - 1, rect.Y + rect.Height - 1 - DocumentTabGapTop ); if( DockPane.DockPanel.ShowDocumentIcon ) { Icon icon = tab.ContentForm.Icon; Rectangle rectIcon = new Rectangle( rect.X + DocumentIconGapLeft, rect.Y + ( rect.Height - DocumentIconHeight ) / 2, DocumentIconWidth, DocumentIconHeight ); g.DrawIcon( tab.ContentForm.Icon, rectIcon ); } TextRenderer.DrawText( g, tab.Content.DockHandler.TabText, Font, rectText, InactiveTextColor, DocumentTextFormat ); } }
private void DrawTab_Document(Graphics g, TabVS2005 tab, Rectangle rect) { if (tab.TabWidth == 0) return; Rectangle rectIcon = new Rectangle( rect.X + DocumentIconGapLeft, rect.Y + rect.Height - 1 - DocumentIconGapBottom - DocumentIconHeight + 1, DocumentIconWidth, DocumentIconHeight); Rectangle 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; } Font fnt = TextFont; if (DockPane.IsActiveDocumentPane) fnt = BoldFont; rectText.Y = rect.Y + Convert.ToInt32((rect.Height - fnt.Height) / 2) - 1; rectText.Height = fnt.Height + 1; Rectangle rectTab = DrawHelper.RtlTransform(this, rect); rectText = DrawHelper.RtlTransform(this, rectText); rectIcon = DrawHelper.RtlTransform(this, rectIcon); GraphicsPath path = GetTabOutline(tab, true, false); if (DockPane.ActiveContent == tab.Content) { g.FillPath(BrushDocumentActiveBackground, path); g.DrawPath(PenDocumentTabActiveBorder, path); if (DockPane.IsActiveDocumentPane) TextRenderer.DrawText(g, tab.Content.DockHandler.TabText, BoldFont, rectText, ColorDocumentActiveText, DocumentTextFormat); else TextRenderer.DrawText(g, tab.Content.DockHandler.TabText, TextFont, rectText, ColorDocumentActiveText, DocumentTextFormat); } else { g.FillPath(BrushDocumentInactiveBackground, path); g.DrawPath(PenDocumentTabInactiveBorder, path); TextRenderer.DrawText(g, tab.Content.DockHandler.TabText, TextFont, rectText, ColorDocumentInactiveText, DocumentTextFormat); } if (rectTab.Contains(rectIcon) && DockPane.DockPanel.ShowDocumentIcon) g.DrawIcon(tab.Content.DockHandler.Icon, rectIcon); }
private void DrawTab_Document(Graphics g, TabVS2005 tab, Rectangle rect) { if (tab.TabWidth == 0) return; Rectangle rectIcon = new Rectangle( rect.X + DocumentIconGapLeft, rect.Y + rect.Height - 1 - DocumentIconGapBottom - DocumentIconHeight, DocumentIconWidth, DocumentIconHeight); Rectangle rectText = rectIcon; String tabStyle = PluginCore.PluginBase.MainForm.GetThemeValue("VS2005DockPaneStrip.TabStyle"); // Adjust text double scale = ScaleHelper.GetScale(); if (scale >= 1.5) { String tabSize = PluginCore.PluginBase.MainForm.GetThemeValue("VS2005DockPaneStrip.TabSize"); if (tabSize == "Default") rectText.Y += ScaleHelper.Scale(1); } else rectText.Y += ScaleHelper.Scale(2); if (Font.SizeInPoints <= 8F) rectText.Y -= ScaleHelper.Scale(1); 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; Rectangle rectTab = DrawHelper.RtlTransform(this, rect); rectText = DrawHelper.RtlTransform(this, rectText); rectIcon = DrawHelper.RtlTransform(this, rectIcon); GraphicsPath path = GetTabOutline(tab, true, false); Color stripColor = tab.Content.DockHandler.TabColor; if (stripColor != Color.Transparent) { Color temp = PluginCore.PluginBase.MainForm.GetThemeColor("VS2005DockPaneStrip.TabStripColor"); if (temp != Color.Empty) stripColor = temp; } if (DockPane.ActiveContent == tab.Content) { if (tabStyle == "Rect") g.FillRectangle(BrushDocumentActiveBackground, rectTab); else g.FillPath(BrushDocumentActiveBackground, path); // Change by Mika: add color strip to tabs SolidBrush stripBrush = new SolidBrush(stripColor); Rectangle stripRect = rectTab; stripRect.X = stripRect.X + stripRect.Width - 2; stripRect.Height -= 1; stripRect.Width = 2; stripRect.Y += 1; g.FillRectangle(stripBrush, stripRect); if (tabStyle == "Rect") g.DrawRectangle(PenDocumentTabActiveBorder, rectTab); else g.DrawPath(PenDocumentTabActiveBorder, path); Color sepColor = PluginCore.PluginBase.MainForm.GetThemeColor("VS2005DockPaneStrip.TabSeparatorColor"); // CHANGED to eliminate line between selected tab and content - NICK RectangleF r = path.GetBounds(); float right = stripColor == Color.Transparent ? r.Right - 1 : r.Right - 3; // Choose color if (sepColor == Color.Empty) { if (PluginCore.PluginBase.Settings.UseSystemColors) { sepColor = SystemColors.ControlLight; } else sepColor = Color.FromArgb(240, 239, 243); } // Draw separator using (Pen pen = new Pen(sepColor)) { if (tabStyle == "Rect") g.DrawLine(pen, rectTab.Left + 2, rectTab.Bottom - 1, right, rectTab.Bottom - 1); else g.DrawLine(pen, r.Left + 2, r.Bottom - 1, right, r.Bottom - 1); } if (DockPane.IsActiveDocumentPane) { TextRenderer.DrawText(g, tab.Content.DockHandler.TabText, BoldFont, rectText, ColorDocumentActiveText, DocumentTextFormat); } else TextRenderer.DrawText(g, tab.Content.DockHandler.TabText, Font, rectText, ColorDocumentInactiveText, DocumentTextFormat); } else { // CHANGE by NICK: emulate VS-style inactive tab gradient Brush tabBrush = new LinearGradientBrush(rectTab, SystemColors.ControlLightLight, SystemColors.ControlLight, LinearGradientMode.Vertical); // Choose color Color color = PluginCore.PluginBase.MainForm.GetThemeColor("VS2005DockPaneStrip.DocInactiveBackColor"); if (color != Color.Empty) { tabBrush = new SolidBrush(color); } //g.FillPath(BrushDocumentInactiveBackground, path); if (tabStyle == "Rect") g.FillRectangle(tabBrush, rectTab); else g.FillPath(tabBrush, path); // Change by Mika: add color strip to tabs SolidBrush stripBrush = new SolidBrush(stripColor); Rectangle stripRect = rectTab; stripRect.X = stripRect.X + stripRect.Width - 2; stripRect.Height -= 2; stripRect.Width = 2; stripRect.Y += 1; g.FillRectangle(stripBrush, stripRect); if (tabStyle == "Rect") g.DrawRectangle(PenDocumentTabInactiveBorder, rectTab); else g.DrawPath(PenDocumentTabInactiveBorder, path); TextRenderer.DrawText(g, tab.Content.DockHandler.TabText, Font, rectText, ColorDocumentInactiveText, DocumentTextFormat); } if (rectTab.Contains(rectIcon) && DockPane.DockPanel.ShowDocumentIcon) g.DrawIcon(tab.Content.DockHandler.Icon, rectIcon); }
public static Icon GetIcon(string text, string originalIcon) { Size bitmapSize = new Size(32, 32); float fontSize = 20; string fontFamily = "Arial"; FontStyle fontStyle = FontStyle.Bold; float offset = 0; Bitmap bitmap = new Bitmap(bitmapSize.Width, bitmapSize.Height); System.Drawing.Font drawFont = new System.Drawing.Font(fontFamily, fontSize, fontStyle); System.Drawing.SolidBrush drawEllipseBrush = new System.Drawing.SolidBrush(ColorTranslator.FromHtml("#ffba09")); System.Drawing.SolidBrush drawCountBrush = new System.Drawing.SolidBrush(System.Drawing.Color.Black); System.Drawing.Graphics graphics = System.Drawing.Graphics.FromImage(bitmap); graphics.TextRenderingHint = System.Drawing.Text.TextRenderingHint.ClearTypeGridFit; if (!string.IsNullOrEmpty(originalIcon)) { graphics.DrawIcon(new Icon(originalIcon), 0, 0); } float ratioOfEllipseToBitmap = 0.8f; SizeF ellipseSize = new SizeF(bitmap.Width * ratioOfEllipseToBitmap, bitmap.Width * ratioOfEllipseToBitmap); PointF ellipseLocation = new PointF(bitmap.Width - ellipseSize.Width, 0); RectangleF ellipseRectangle = new RectangleF(ellipseLocation, ellipseSize); graphics.FillEllipse(drawEllipseBrush, ellipseRectangle); int[,] pixelOne = PixelNumbers.pixelOne; int xOffset = (int)ellipseLocation.X + (int)(ellipseSize.Width / 2) - 2; int yOffset = (int)ellipseLocation.Y + (int)(ellipseSize.Height / 2) - 2; for (int i = 0; i < pixelOne.GetLength(0); i++) { bitmap.SetPixel(pixelOne[i, 0] + xOffset, pixelOne[i, 1] + yOffset, Color.Black); } float height = graphics.MeasureString(text, drawFont).Height; while (height >= ellipseSize.Height) { drawFont = new System.Drawing.Font(fontFamily, drawFont.Size - 0.01f, fontStyle); height = graphics.MeasureString(text, drawFont).Height; } double halfLength = Math.Sqrt(ellipseSize.Width * 0.5 * ellipseSize.Width * 0.5 - height * 0.5 * height * 0.5); while (halfLength * 2 < graphics.MeasureString(text, drawFont).Width) { drawFont = new System.Drawing.Font(fontFamily, drawFont.Size - 0.01f, fontStyle); height = graphics.MeasureString(text, drawFont).Height; halfLength = Math.Sqrt(ellipseSize.Width * 0.5 * ellipseSize.Width * 0.5 - height * height * 0.25); } StringFormat stringFormat = new StringFormat(); stringFormat.Alignment = StringAlignment.Center; stringFormat.LineAlignment = StringAlignment.Center; RectangleF textRectangle = new RectangleF((float)(bitmapSize.Width - ellipseSize.Width * 0.5 - halfLength), (float)(ellipseSize.Height * 0.5 - height * 0.5), (float)(2 * halfLength), height + offset); Icon createdIcon = Icon.FromHandle(bitmap.GetHicon()); drawFont.Dispose(); drawEllipseBrush.Dispose(); drawCountBrush.Dispose(); graphics.Dispose(); bitmap.Dispose(); return(createdIcon); }
private void DrawTab(Graphics g, AutoHideTabFromBase tab) { Rectangle rectTab = GetTabRectangle(tab); if (rectTab.IsEmpty) return; DockState dockState = tab.Content.DockHandler.DockState; IDockContent content = tab.Content; BeginDrawTab(); Pen penTabBorder = PenTabBorder; Brush brushTabText = new SolidBrush(ColorMixer.AutoHideTabTextColor); if (dockState == DockState.DockTopAutoHide || dockState == DockState.DockRightAutoHide) DrawUtil.DrawVSTab(g,rectTab,Color.WhiteSmoke,Color.DimGray,false); else DrawUtil.DrawVSTab(g,rectTab,Color.WhiteSmoke,Color.DimGray,false); // g.FillRectangle(new LinearGradientBrush(rectTab,ColorMixer.DarkColor,ColorMixer.LightColor,LinearGradientMode.Vertical) // , 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.DockHandler.Icon, rectImage); // Draw the text if (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(); }
/// <summary> /// Draws the layers icon to the legend /// </summary> /// <param name="g"></param> /// <param name="box"></param> public override void LegendSymbol_Painted(Graphics g, Rectangle box) { g.DrawIcon(SymbologyImages.Layers, box); }
private void DrawTab_Document(Graphics g, TabVS2012 tab, Rectangle rect) { if (tab.TabWidth == 0) return; var rectCloseButton = GetCloseButtonRect(rect); Rectangle rectIcon = new Rectangle( rect.X + DocumentIconGapLeft, rect.Y + rect.Height - DocumentIconGapBottom - DocumentIconHeight, DocumentIconWidth, DocumentIconHeight); Rectangle rectText = PatchController.EnableHighDpi == true ? new Rectangle( rect.X + DocumentIconGapLeft, rect.Y + rect.Height - DocumentIconGapBottom - TextFont.Height, DocumentIconWidth, TextFont.Height) : rectIcon; if (DockPane.DockPanel.ShowDocumentIcon) { rectText.X += rectIcon.Width + DocumentIconGapRight; rectText.Y = rect.Y; rectText.Width = rect.Width - rectIcon.Width - DocumentIconGapLeft - DocumentIconGapRight - DocumentTextGapRight - rectCloseButton.Width; rectText.Height = rect.Height; } else rectText.Width = rect.Width - DocumentIconGapLeft - DocumentTextGapRight - rectCloseButton.Width; Rectangle rectTab = DrawHelper.RtlTransform(this, rect); Rectangle rectBack = DrawHelper.RtlTransform(this, rect); rectBack.Width += DocumentIconGapLeft; rectBack.X -= DocumentIconGapLeft; rectText = DrawHelper.RtlTransform(this, rectText); rectIcon = DrawHelper.RtlTransform(this, rectIcon); Color activeColor = DockPane.DockPanel.Theme.ColorPalette.TabSelectedActive.Background; Color lostFocusColor = DockPane.DockPanel.Theme.ColorPalette.TabSelectedInactive.Background; Color inactiveColor = DockPane.DockPanel.Theme.ColorPalette.MainWindowActive.Background; Color mouseHoverColor = DockPane.DockPanel.Theme.ColorPalette.TabUnselectedHovered.Background; Color activeText = DockPane.DockPanel.Theme.ColorPalette.TabSelectedActive.Text; Color lostFocusText = DockPane.DockPanel.Theme.ColorPalette.TabSelectedInactive.Text; Color inactiveText = DockPane.DockPanel.Theme.ColorPalette.TabUnselected.Text; Color mouseHoverText = DockPane.DockPanel.Theme.ColorPalette.TabUnselectedHovered.Text; Color text; Image image = null; Color paint; var imageService = DockPane.DockPanel.Theme.ImageService; if (DockPane.ActiveContent == tab.Content) { if (DockPane.IsActiveDocumentPane) { paint = activeColor; text = activeText; image = IsMouseDown ? imageService.TabPressActive_Close : rectCloseButton == ActiveClose ? imageService.TabHoverActive_Close : imageService.TabActive_Close; } else { paint = lostFocusColor; text = lostFocusText; image = IsMouseDown ? imageService.TabPressLostFocus_Close : rectCloseButton == ActiveClose ? imageService.TabHoverLostFocus_Close : imageService.TabLostFocus_Close; } } else { if (tab.Content == DockPane.MouseOverTab) { paint = mouseHoverColor; text = mouseHoverText; image = IsMouseDown ? imageService.TabPressInactive_Close : rectCloseButton == ActiveClose ? imageService.TabHoverInactive_Close : imageService.TabInactive_Close; } else { paint = inactiveColor; text = inactiveText; } } g.FillRectangle(DockPane.DockPanel.Theme.PaintingService.GetBrush(paint), rect); TextRenderer.DrawText(g, tab.Content.DockHandler.TabText, TextFont, rectText, text, DocumentTextFormat); if (image != null) g.DrawImage(image, rectCloseButton); if (rectTab.Contains(rectIcon) && DockPane.DockPanel.ShowDocumentIcon) g.DrawIcon(tab.Content.DockHandler.Icon, rectIcon); }
private void DrawTab_ToolWindow(Graphics g, TabVS2012 tab, Rectangle rect, bool last) { rect.Y += 1; Rectangle rectIcon = new Rectangle( rect.X + ToolWindowImageGapLeft, rect.Y - 1 + rect.Height - ToolWindowImageGapBottom - ToolWindowImageHeight, ToolWindowImageWidth, ToolWindowImageHeight); Rectangle rectText = PatchController.EnableHighDpi == true ? new Rectangle( rect.X + ToolWindowImageGapLeft, rect.Y - 1 + rect.Height - ToolWindowImageGapBottom - TextFont.Height, ToolWindowImageWidth, TextFont.Height) : rectIcon; rectText.X += rectIcon.Width + ToolWindowImageGapRight; rectText.Width = rect.Width - rectIcon.Width - ToolWindowImageGapLeft - ToolWindowImageGapRight - ToolWindowTextGapRight; Rectangle rectTab = DrawHelper.RtlTransform(this, rect); rectText = DrawHelper.RtlTransform(this, rectText); rectIcon = DrawHelper.RtlTransform(this, rectIcon); Color separatorColor = DockPane.DockPanel.Theme.ColorPalette.ToolWindowSeparator; if (DockPane.ActiveContent == tab.Content) { Color textColor; Color backgroundColor; if (DockPane.IsActiveDocumentPane) { textColor = DockPane.DockPanel.Theme.ColorPalette.ToolWindowTabSelectedActive.Text; backgroundColor = DockPane.DockPanel.Theme.ColorPalette.ToolWindowTabSelectedActive.Background; } else { textColor = DockPane.DockPanel.Theme.ColorPalette.ToolWindowTabSelectedInactive.Text; backgroundColor = DockPane.DockPanel.Theme.ColorPalette.ToolWindowTabSelectedInactive.Background; } g.FillRectangle(DockPane.DockPanel.Theme.PaintingService.GetBrush(backgroundColor), rect); TextRenderer.DrawText(g, tab.Content.DockHandler.TabText, TextFont, rectText, textColor, ToolWindowTextFormat); // TODO: how to cache Pen? g.DrawLine(DockPane.DockPanel.Theme.PaintingService.GetPen(separatorColor), rect.X + rect.Width - 1, rect.Y, rect.X + rect.Width - 1, rect.Height); } else { Color textColor; Color backgroundColor; if (tab.Content == DockPane.MouseOverTab) { textColor = DockPane.DockPanel.Theme.ColorPalette.ToolWindowTabUnselectedHovered.Text; backgroundColor = DockPane.DockPanel.Theme.ColorPalette.ToolWindowTabUnselectedHovered.Background; } else { textColor = DockPane.DockPanel.Theme.ColorPalette.ToolWindowTabUnselected.Text; backgroundColor = DockPane.DockPanel.Theme.ColorPalette.MainWindowActive.Background; } g.FillRectangle(DockPane.DockPanel.Theme.PaintingService.GetBrush(backgroundColor), rect); TextRenderer.DrawText(g, tab.Content.DockHandler.TabText, TextFont, rectText, textColor, ToolWindowTextFormat); if (!last) { g.DrawLine(DockPane.DockPanel.Theme.PaintingService.GetPen(separatorColor), rect.X + rect.Width - 1, rect.Y, rect.X + rect.Width - 1, rect.Height); } } if (rectTab.Contains(rectIcon)) g.DrawIcon(tab.Content.DockHandler.Icon, rectIcon); }
private void DrawTab(Graphics g, TabVS2005 tab) { Rectangle rectTabOrigin = GetTabRectangle(tab); if (rectTabOrigin.IsEmpty) return; DockState dockState = tab.Content.DockHandler.DockState; IDockContent content = tab.Content; GraphicsPath path = GetTabOutline(tab, false, true); g.FillPath(BrushTabBackground, path); g.DrawPath(PenTabBorder, path); // 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); //g.DrawIcon(((Form)content).Icon, RtlTransform(rectImage, dockState)); 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 { // DockState is DockTopAutoHide or DockBottomAutoHide. g.DrawIcon(((Form)content).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); if (dockState == DockState.DockLeftAutoHide || dockState == DockState.DockRightAutoHide) g.DrawString(content.DockHandler.TabText, TextFont, BrushTabText, rectText, StringFormatTabVertical); else g.DrawString(content.DockHandler.TabText, TextFont, BrushTabText, rectText, StringFormatTabHorizontal); // Set rotate back g.Transform = matrixRotate; }
/// <summary> /// 绘制窗体图标和文本 /// </summary> private void DrawIconAndText(Graphics g) { Rectangle iconRect = Rectangle.Empty; Rectangle textRect = Rectangle.Empty; if (isDrawIcon && this.Icon != null) { iconRect = new Rectangle(new Point(8, 6), SystemInformation.SmallIconSize); if (this.Text.Length > 0) { textRect = new Rectangle(iconRect.Right + 2, iconRect.Top - (textFont.Height - iconRect.Height) / 2, Width - (8 + iconRect.Width + 2 + 27 * 2), textFont.Height); } } else { if (this.Text.Length > 0) { textRect = new Rectangle(8, 4, Width - 8, textFont.Height); } } if (isDrawIcon && this.Icon != null) { g.DrawIcon(this.Icon, iconRect); } if (this.Text.Length > 0) { TextRenderer.DrawText( g, this.Text, textFont, textRect, textForeColor, TextFormatFlags.SingleLine | TextFormatFlags.EndEllipsis); } }
public override void DrawToolTip(Graphics dc, Rectangle clip_rectangle, ToolTip.ToolTipWindow control) { ToolTipDrawBackground (dc, clip_rectangle, control); TextFormatFlags flags = TextFormatFlags.HidePrefix; Color foreground = control.ForeColor; if (control.title.Length > 0) { Font bold_font = new Font (control.Font, control.Font.Style | FontStyle.Bold); TextRenderer.DrawTextInternal (dc, control.title, bold_font, control.title_rect, foreground, flags, false); bold_font.Dispose (); } if (control.icon != null) dc.DrawIcon (control.icon, control.icon_rect); TextRenderer.DrawTextInternal (dc, control.Text, control.Font, control.text_rect, foreground, flags, false); }
public override void DrawManagedWindowDecorations (Graphics dc, Rectangle clip, InternalWindowManager wm) { #if debug Console.WriteLine (DateTime.Now.ToLongTimeString () + " DrawManagedWindowDecorations"); dc.FillRectangle (Brushes.Black, clip); #endif Rectangle tb = ManagedWindowDrawTitleBarAndBorders (dc, clip, wm); Form form = wm.Form; if (wm.ShowIcon) { Rectangle icon = ManagedWindowGetTitleBarIconArea (wm); if (icon.IntersectsWith (clip)) dc.DrawIcon (form.Icon, icon); const int SpacingBetweenIconAndCaption = 2; tb.Width -= icon.Right + SpacingBetweenIconAndCaption - tb.X ; tb.X = icon.Right + SpacingBetweenIconAndCaption; } foreach (TitleButton button in wm.TitleButtons.AllButtons) { tb.Width -= Math.Max (0, tb.Right - DrawTitleButton (dc, button, clip, form)); } const int SpacingBetweenCaptionAndLeftMostButton = 3; tb.Width -= SpacingBetweenCaptionAndLeftMostButton; string window_caption = form.Text; window_caption = window_caption.Replace (Environment.NewLine, string.Empty); if (window_caption != null && window_caption != string.Empty) { StringFormat format = new StringFormat (); format.FormatFlags = StringFormatFlags.NoWrap; format.Trimming = StringTrimming.EllipsisCharacter; format.LineAlignment = StringAlignment.Center; if (tb.IntersectsWith (clip)) dc.DrawString (window_caption, WindowBorderFont, ThemeEngine.Current.ResPool.GetSolidBrush (Color.White), tb, format); } }
private void DrawTab_ToolWindow(Graphics g, TabVS2005 tab, Rectangle rect) { 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; Rectangle rectTab = DrawHelper.RtlTransform(this, rect); rectText = DrawHelper.RtlTransform(this, rectText); rectIcon = DrawHelper.RtlTransform(this, rectIcon); GraphicsPath path = GetTabOutline(tab, true, false); if (DockPane.ActiveContent == tab.Content) { Color startColor = DockPane.DockPanel.Skin.DockPaneStripSkin.ToolWindowGradient.ActiveTabGradient.StartColor; Color endColor = DockPane.DockPanel.Skin.DockPaneStripSkin.ToolWindowGradient.ActiveTabGradient.EndColor; LinearGradientMode gradientMode = DockPane.DockPanel.Skin.DockPaneStripSkin.ToolWindowGradient.ActiveTabGradient.LinearGradientMode; g.FillPath(new LinearGradientBrush(rectTab, startColor, endColor, gradientMode), path); g.DrawPath(PenToolWindowTabBorder, path); Color textColor = DockPane.DockPanel.Skin.DockPaneStripSkin.ToolWindowGradient.ActiveTabGradient.TextColor; TextRenderer.DrawText(g, tab.Content.DockHandler.TabText, TextFont, rectText, textColor, ToolWindowTextFormat); } else { Color startColor = DockPane.DockPanel.Skin.DockPaneStripSkin.ToolWindowGradient.InactiveTabGradient.StartColor; Color endColor = DockPane.DockPanel.Skin.DockPaneStripSkin.ToolWindowGradient.InactiveTabGradient.EndColor; LinearGradientMode 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) { Point pt1 = new Point(rect.Right, rect.Top + ToolWindowTabSeperatorGapTop); Point pt2 = new Point(rect.Right, rect.Bottom - ToolWindowTabSeperatorGapBottom); g.DrawLine(PenToolWindowTabBorder, DrawHelper.RtlTransform(this, pt1), DrawHelper.RtlTransform(this, pt2)); } Color 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(new Icon(tab.Content.DockHandler.Icon, new Size(rectIcon.Width, rectIcon.Height)), rectIcon); }
protected override void OnPaint(PaintEventArgs e) { base.OnPaint(e); g = e.Graphics; Bmp = ResClass.GetImgRes("login_png_bkg"); g.DrawImage(Bmp, new Rectangle(0, 0, 5, 31), 0, 0, 5, 31, GraphicsUnit.Pixel); g.DrawImage(Bmp, new Rectangle(5, 0, this.Width - 10, 31), 5, 0, Bmp.Width - 10, 31, GraphicsUnit.Pixel); g.DrawImage(Bmp, new Rectangle(this.Width - 5, 0, 5, 31), Bmp.Width - 5, 0, 5, 31, GraphicsUnit.Pixel); g.DrawImage(Bmp, new Rectangle(0, 31, 2, 25), 0, 31, 2, 25, GraphicsUnit.Pixel); g.DrawImage(Bmp, new Rectangle(2, 31, this.Width - 4, 25), 2, 31, 5, 25, GraphicsUnit.Pixel); g.DrawImage(Bmp, new Rectangle(this.Width - 2, 31, 2, 25), Bmp.Width - 2, 31, 2, 25, GraphicsUnit.Pixel); g.DrawImage(Bmp, new Rectangle(0, this.Height - 34, 5, 34), 0, Bmp.Height - 34, 5, 34, GraphicsUnit.Pixel); g.DrawImage(Bmp, new Rectangle(5, this.Height - 34, this.Width - 10, 34), 5, Bmp.Height - 34, Bmp.Width - 10, 34, GraphicsUnit.Pixel); g.DrawImage(Bmp, new Rectangle(this.Width - 5, this.Height - 34, 5, 34), Bmp.Width - 5, Bmp.Height - 34, 5, 34, GraphicsUnit.Pixel); g.DrawImage(Bmp, new Rectangle(0, 56, 5, Height-90), 0, Bmp.Height - 230, 5, 130, GraphicsUnit.Pixel); g.DrawImage(Bmp, new Rectangle(5, 56, this.Width - 10, Height - 90), 5, Bmp.Height - 230, Bmp.Width - 10, 130, GraphicsUnit.Pixel); g.DrawImage(Bmp, new Rectangle(this.Width - 5, 56, 5, Height - 90), Bmp.Width - 5, Bmp.Height - 230, 5, 130, GraphicsUnit.Pixel); if (this.ShowIcon) { g.DrawIcon(icon, new Rectangle(8, 7, 16, 16)); } else { strX = 10; } //Bmp = ResClass.GetResObj("MainPanel_TitleBackgroundBluelight_background"); Font f = null; if (Environment.OSVersion.Version.Major >= 6) { f = new Font("微软雅黑", 11F, FontStyle.Regular); g.DrawString(this.Text, f, titleColor, strX, 4); //g.DrawImage(Bmp, new Rectangle(strX, 4, (int)SkinUtil.GetStrWidth(Text, f), 20), 0, 0, Bmp.Width, Bmp.Height, GraphicsUnit.Pixel); } else { f = new Font("宋体", 11F, FontStyle.Regular); g.DrawString(this.Text, f, titleColor, strX, 8); } f.Dispose(); Bmp.Dispose(); }
private void DrawTab_ToolWindow(Graphics g, DockContent content, Rectangle rect) { 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; if (DockPane.ActiveContent == content) { g.FillRectangle(ActiveBackBrush, rect); g.DrawLine(OutlineOuterPen, rect.X, rect.Y, rect.X, rect.Y + rect.Height - 1); g.DrawLine(OutlineInnerPen, rect.X, rect.Y + rect.Height - 1, rect.X + rect.Width - 1, rect.Y + rect.Height - 1); g.DrawLine(OutlineInnerPen, rect.X + rect.Width - 1, rect.Y, rect.X + rect.Width - 1, rect.Y + rect.Height - 1); g.DrawString(content.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.TabText, Font, InactiveTextBrush, rectText, ToolWindowTextStringFormat); } if (rect.Contains(rectIcon)) g.DrawIcon(content.Icon, rectIcon); }
private void DrawTab_ToolWindow(Graphics g, TabVS2005 tab, Rectangle rect) { 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; Rectangle rectTab = DrawHelper.RtlTransform(this, rect); rectText = DrawHelper.RtlTransform(this, rectText); rectIcon = DrawHelper.RtlTransform(this, rectIcon); GraphicsPath path = GetTabOutline(tab, true, false); if (DockPane.ActiveContent == tab.Content) { g.FillPath(BrushToolWindowActiveBackground, path); g.DrawPath(PenToolWindowTabActiveBorder, path); // NICK: eliminate line between tab and content RectangleF r = path.GetBounds(); Color color = PluginCore.PluginBase.MainForm.GetThemeColor("VS2005DockPaneStrip.ToolSeparatorColor"); if (color == Color.Empty) color = Color.FromArgb(240, 239, 243); using (Pen pen = new Pen(color)) g.DrawLine(pen, r.Left + 1, r.Top, r.Right - 1, r.Top); TextRenderer.DrawText(g, tab.Content.DockHandler.TabText, Font, rectText, ColorToolWindowActiveText, ToolWindowTextFormat); } else { // NICK: remove separators, too busy for FD /*if (Tabs.IndexOf(DockPane.ActiveContent) != Tabs.IndexOf(tab) + 1) { Point pt1 = new Point(rect.Right, rect.Top + ToolWindowTabSeperatorGapTop); Point pt2 = new Point(rect.Right, rect.Bottom - ToolWindowTabSeperatorGapBottom); g.DrawLine(PenToolWindowTabBorder, DrawHelper.RtlTransform(this, pt1), DrawHelper.RtlTransform(this, pt2)); }*/ TextRenderer.DrawText(g, tab.Content.DockHandler.TabText, Font, rectText, ColorToolWindowInactiveText, ToolWindowTextFormat); } if (rectTab.Contains(rectIcon)) g.DrawIcon(tab.Content.DockHandler.Icon, rectIcon); }
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 DrawTab_ToolWindow(Graphics g, TabVS2005 tab, Rectangle rect) { 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; if (TextFont.Height > rectIcon.Height) { rectText.Y -= TextFont.Height - rectIcon.Height; rectText.Height = TextFont.Height; } //rectText.Y = rect.Y + Convert.ToInt32((rect.Height - TextFont.Height) / 2) - 1; //rectText.Height = TextFont.Height; Rectangle rectTab = DrawHelper.RtlTransform(this, rect); rectText = DrawHelper.RtlTransform(this, rectText); rectIcon = DrawHelper.RtlTransform(this, rectIcon); GraphicsPath path = GetTabOutline(tab, true, false); if (DockPane.ActiveContent == tab.Content) { g.FillPath(BrushToolWindowActiveBackground, path); g.DrawPath(PenToolWindowTabBorder, path); TextRenderer.DrawText(g, tab.Content.DockHandler.TabText, TextFont, rectText, ColorToolWindowActiveText, ToolWindowTextFormat); } else { if (Tabs.IndexOf(DockPane.ActiveContent) != Tabs.IndexOf(tab) + 1) { Point pt1 = new Point(rect.Right, rect.Top + ToolWindowTabSeperatorGapTop); Point pt2 = new Point(rect.Right, rect.Bottom - ToolWindowTabSeperatorGapBottom); g.DrawLine(PenToolWindowTabBorder, DrawHelper.RtlTransform(this, pt1), DrawHelper.RtlTransform(this, pt2)); } TextRenderer.DrawText(g, tab.Content.DockHandler.TabText, TextFont, rectText, ColorToolWindowInactiveText, ToolWindowTextFormat); } if (rectTab.Contains(rectIcon)) g.DrawIcon(tab.Content.DockHandler.Icon, rectIcon); }
// Draw the checkbox for an item private void DrawCheckBoxes(Graphics g, ref PointF topLeft, LegendBox itemBox) { ILegendItem item = itemBox.Item; if (item == null) return; if (item.LegendSymbolMode != SymbolModes.Checkbox) return; if (item.Checked) { int top = (int)topLeft.Y + (ItemHeight - _icoChecked.Height) / 2; int left = (int)topLeft.X + 6; g.DrawIcon(_icoChecked, left, top); Rectangle box = new Rectangle(left, top, _icoChecked.Width, _icoChecked.Height); itemBox.CheckBox = box; } else { int top = (int)topLeft.Y + (ItemHeight - _icoUnchecked.Height) / 2; int left = (int)topLeft.X + 6; g.DrawIcon(_icoUnchecked, left, top); Rectangle box = new Rectangle(left, top, _icoChecked.Width, _icoChecked.Height); itemBox.CheckBox = box; } topLeft.X += 22; }
private void DrawTab_Document(Graphics g, TabVS2005 tab, Rectangle rect) { if (tab.TabWidth == 0) return; Rectangle rectIcon = new Rectangle( rect.X + DocumentIconGapLeft, rect.Y + rect.Height - 1 - DocumentIconGapBottom - DocumentIconHeight, DocumentIconWidth, DocumentIconHeight); Rectangle rectText = rectIcon; rectIcon.Y += 1; 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; Rectangle rectTab = DrawHelper.RtlTransform(this, rect); Rectangle rectBack = DrawHelper.RtlTransform(this, rect); rectBack.Width += rect.X; rectBack.X = 0; rectText = DrawHelper.RtlTransform(this, rectText); rectIcon = DrawHelper.RtlTransform(this, rectIcon); GraphicsPath path = GetTabOutline(tab, true, false); if (DockPane.ActiveContent == tab.Content) { Color startColor = DockPane.DockPanel.Skin.DockPaneStripSkin.DocumentGradient.ActiveTabGradient.StartColor; Color endColor = DockPane.DockPanel.Skin.DockPaneStripSkin.DocumentGradient.ActiveTabGradient.EndColor; LinearGradientMode gradientMode = DockPane.DockPanel.Skin.DockPaneStripSkin.DocumentGradient.ActiveTabGradient.LinearGradientMode; g.FillPath(new LinearGradientBrush(rectBack, startColor, endColor, gradientMode), path); g.DrawPath(PenDocumentTabActiveBorder, path); Color 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 { Color startColor = DockPane.DockPanel.Skin.DockPaneStripSkin.DocumentGradient.InactiveTabGradient.StartColor; Color endColor = DockPane.DockPanel.Skin.DockPaneStripSkin.DocumentGradient.InactiveTabGradient.EndColor; LinearGradientMode gradientMode = DockPane.DockPanel.Skin.DockPaneStripSkin.DocumentGradient.InactiveTabGradient.LinearGradientMode; g.FillPath(new LinearGradientBrush(rectBack, startColor, endColor, gradientMode), path); g.DrawPath(PenDocumentTabInactiveBorder, path); Color 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(new Icon(tab.Content.DockHandler.Icon, new Size(rectIcon.Width, rectIcon.Height)), rectIcon); }
/// <summary> /// Draws the icon. /// </summary> /// <param name="g">The g.</param> protected void DrawIcon( System.Drawing.Graphics g ) { if (this._icon == null) return; g.DrawIcon( this._icon, this.Width-this._icon.Width-BoundrySize , (this.Height-this._icon.Height)/2); }
private void DrawTab(Graphics g, TabVS2012Light tab) { Rectangle rectTabOrigin = GetTabRectangle(tab); if (rectTabOrigin.IsEmpty) return; DockState dockState = tab.Content.DockHandler.DockState; IDockContent content = tab.Content; Color textColor; if (tab.Content.DockHandler.IsActivated || tab.IsMouseOver) textColor = DockPanel.Skin.AutoHideStripSkin.DockStripGradient.StartColor; else textColor = DockPanel.Skin.AutoHideStripSkin.DockStripGradient.EndColor; Rectangle rectThickLine = rectTabOrigin; rectThickLine.X += _TabGapLeft + _TextGapLeft + _ImageGapLeft + _ImageWidth; rectThickLine.Width = TextRenderer.MeasureText(tab.Content.DockHandler.TabText, TextFont).Width - 8; rectThickLine.Height = Measures.AutoHideTabLineWidth; if (dockState == DockState.DockBottomAutoHide || dockState == DockState.DockLeftAutoHide) rectThickLine.Y += rectTabOrigin.Height - Measures.AutoHideTabLineWidth; else if (dockState == DockState.DockTopAutoHide || dockState == DockState.DockRightAutoHide) rectThickLine.Y += 0; g.FillRectangle(new SolidBrush(textColor), rectThickLine); //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. g.DrawIcon(((Form)content).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); if (DockPanel.ActiveContent == content || tab.IsMouseOver) textColor = DockPanel.Skin.DockPaneStripSkin.ToolWindowGradient.ActiveTabGradient.TextColor; else textColor = DockPanel.Skin.DockPaneStripSkin.ToolWindowGradient.InactiveTabGradient.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 DrawTab_Document(Graphics g, IDockContent content, Rectangle rect, int index) { Rectangle rectText = rect; //INSTANT C# NOTE: The VB integer division operator \ was replaced 1 time(s) by the regular division operator / rectText.X += (int)System.Math.Floor((double)DocumentTextExtraWidth / 2); rectText.Width -= DocumentTextExtraWidth; rectText.X += _DocumentTabOverlap; if (index == 0) { rect.Width += _DocumentTabOverlap; } else { rect.X += _DocumentTabOverlap; } g.SmoothingMode = SmoothingMode.AntiAlias; if (DockPane.ActiveContent == content) { if (index == 0) { if (DockPane.DockPanel.ShowDocumentIcon) { rectText.X += DocumentIconGapLeft; rectText.Width -= DocumentIconGapLeft; } } else { rect.X -= _DocumentTabOverlap; rect.Width += _DocumentTabOverlap; if (DockPane.DockPanel.ShowDocumentIcon) { rectText.X += DocumentIconGapLeft; rectText.Width -= DocumentIconGapLeft; } } // Draw Tab & Text DrawHelper.DrawDocumentTab(g, rect, Color.White, Color.White, Color.FromArgb(127, 157, 185), TabDrawType.Active, true); if (DockPane.IsActiveDocumentPane) { using (Font boldFont = new Font(this.Font, FontStyle.Bold)) { g.DrawString(content.DockHandler.TabText, boldFont, ActiveTextBrush, rectText, DocumentTextStringFormat); } } else { g.DrawString(content.DockHandler.TabText, Font, InactiveTextBrush, rectText, DocumentTextStringFormat); } // Draw Icon if (DockPane.DockPanel.ShowDocumentIcon) { Icon icon = content.DockHandler.Icon; Rectangle rectIcon = new Rectangle(); if (index == 0) { rectIcon = new Rectangle(rect.X + DocumentIconGapLeft + _DocumentTabOverlap, System.Convert.ToInt32(rectText.Y + (rect.Height - DocumentIconHeight) / 2), DocumentIconWidth, DocumentIconHeight); } else { rectIcon = new Rectangle(rect.X + DocumentIconGapLeft + _DocumentTabOverlap, System.Convert.ToInt32(rectText.Y + (rect.Height - DocumentIconHeight) / 2), DocumentIconWidth, DocumentIconHeight); } g.DrawIcon(content.DockHandler.Icon, rectIcon); } } else { if (index == 0) { DrawHelper.DrawDocumentTab(g, rect, Color.FromArgb(254, 253, 253), Color.FromArgb(241, 239, 226), Color.FromArgb(172, 168, 153), TabDrawType.First, true); } else { DrawHelper.DrawDocumentTab(g, rect, Color.FromArgb(254, 253, 253), Color.FromArgb(241, 239, 226), Color.FromArgb(172, 168, 153), TabDrawType.Inactive, true); } g.DrawLine(OutlineOuterPen, rect.X, ClientRectangle.Bottom - 1, rect.X + rect.Width, ClientRectangle.Bottom - 1); g.DrawString(content.DockHandler.TabText, Font, InactiveTextBrush, rectText, DocumentTextStringFormat); } }
private void DrawTab(Graphics g, TabVS2005 tab) { Rectangle rectTabOrigin = GetTabRectangle(tab); if (rectTabOrigin.IsEmpty) return; DockState dockState = tab.Content.DockHandler.DockState; IDockContent content = tab.Content; GraphicsPath path = GetTabOutline(tab, false, true); g.FillPath(BrushTabBackground, path); g.DrawPath(PenTabBorder, path); // Set no rotate for drawing icon and text Matrix matrixRotate = g.Transform; g.Transform = MatrixIdentity; // Draw the icon Rectangle rectImage = rectTabOrigin; // HACK - This makes the Silk icon set look better (although it is NOT VS 2005 behavior) if (dockState == DockState.DockLeftAutoHide || dockState == DockState.DockRightAutoHide) rectImage.Y -= 1; 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); g.DrawIcon(((Form)content).Icon, RtlTransform(rectImage, dockState)); // Draw the text Rectangle rectText = rectTabOrigin; // CHANGED - Mika if (Font.SizeInPoints > 8F) rectText.Y += 1; rectText.X += ImageGapLeft + imageWidth + ImageGapRight + TextGapLeft; rectText.Width -= ImageGapLeft + imageWidth + ImageGapRight + TextGapLeft; rectText = RtlTransform(GetTransformedRectangle(dockState, rectText), dockState); 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; }
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 (DockPane.ActiveContent == content) { DrawHelper.DrawTab(g, rect, Corners.Bottom, 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 DrawTab(Graphics g, TabVS2003 tab) { Rectangle rectTab = GetTabRectangle(tab); if (rectTab.IsEmpty) return; DockState dockState = tab.Content.DockHandler.DockState; IDockContent 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(((Form)content).Icon, rectImage); // Draw the text if (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; OnEndDrawTab(tab); }
private void DrawTabStrip_ToolWindow(Graphics g) { // TODO: Clean up and add properties for colors g.SmoothingMode = SmoothingMode.AntiAlias; //INSTANT C# NOTE: The ending condition of VB 'For' loops is tested only on entry to the loop. Instant C# has created a temporary variable in order to use the initial value of Tabs.Count for every iteration: int tempFor1 = Tabs.Count; for (int i = 0; i < tempFor1; 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 (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, Corners.Bottom, 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); } } }