protected virtual void DrawTabItemBackground(DockItemTab tab, GraphicsPath path, TabColors colors, Graphics g) { RectangleF rf=path.GetBounds(); Rectangle tabRect=new Rectangle((int)rf.X, (int)rf.Y, (int)rf.Width, (int)rf.Height); if(colors.BackColor2.IsEmpty) { if(!colors.BackColor.IsEmpty) { using(SolidBrush brush=new SolidBrush(colors.BackColor)) g.FillPath(brush,path); } } else { using(SolidBrush brush=new SolidBrush(Color.White)) g.FillPath(brush,path); using(LinearGradientBrush brush=CreateTabGradientBrush(tabRect,colors.BackColor,colors.BackColor2,colors.BackColorGradientAngle)) g.FillPath(brush,path); } if(!colors.BorderColor.IsEmpty) { using(Pen pen=new Pen(colors.BorderColor,1)) g.DrawPath(pen,path); } }
protected virtual void DrawTabText(DockItemTab tab, TabColors colors, Graphics g, bool selected) { int MIN_TEXT_WIDTH=12; eTextFormat strFormat = eTextFormat.Default | eTextFormat.HorizontalCenter | eTextFormat.VerticalCenter | eTextFormat.EndEllipsis | eTextFormat.SingleLine; Rectangle rText=tab.DisplayRectangle; // Draw image CompositeImage image=tab.Icon; if(image!=null && image.Width+4<=rText.Width) { if(m_AutoHidePanel.Dock==DockStyle.Top || m_AutoHidePanel.Dock==DockStyle.Bottom) { image.DrawImage(g,new Rectangle(rText.X+3,rText.Y+(rText.Height-image.Height)/2,image.Width,image.Height)); int offset=image.Width+2; rText.X+=offset; rText.Width-=offset; } else { image.DrawImage(g,new Rectangle(rText.X+(rText.Width-image.Width)/2,rText.Y+3,image.Width,image.Height)); int offset=image.Height+2; rText.Y+=offset; rText.Height-=offset; } } bool drawTextAlways = false; if (tab.Item != null && tab.Item.ContainerControl is Bar) drawTextAlways = ((Bar)tab.Item.ContainerControl).AutoHideTabTextAlwaysVisible; if (m_DisplayTextForActiveTabOnly && !drawTextAlways && !selected && image != null) return; // Draw text //if(selected) { Font font=m_AutoHidePanel.Font; rText.Inflate(-1, -1); if((m_AutoHidePanel.Dock==DockStyle.Left || m_AutoHidePanel.Dock==DockStyle.Right)) { rText.Y += 2; g.RotateTransform(90); rText=new Rectangle(rText.Top,-rText.Right,rText.Height,rText.Width); } if(rText.Width>MIN_TEXT_WIDTH) { TextDrawing.DrawStringLegacy(g, tab.Text, font, colors.TextColor, rText, strFormat); } if((m_AutoHidePanel.Dock==DockStyle.Left || m_AutoHidePanel.Dock==DockStyle.Right)) g.ResetTransform(); } }
protected virtual void DrawTabItemBackground(TabItem tab, GraphicsPath path, TabColors colors, Graphics g) { RectangleF rf=path.GetBounds(); Rectangle tabRect=new Rectangle((int)rf.X, (int)rf.Y, (int)rf.Width, (int)rf.Height); SmoothingMode sm = g.SmoothingMode; g.SmoothingMode = SmoothingMode.Default; eBackgroundColorBlendType blendType = colors.BackgroundColorBlend.GetBlendType(); int ga = colors.BackColorGradientAngle; if (tab.TabAlignment == eTabStripAlignment.Left || tab.TabAlignment == eTabStripAlignment.Right) ga -= 90; if (blendType != eBackgroundColorBlendType.Invalid) { if (blendType == eBackgroundColorBlendType.Relative) { if (!colors.BackColor.IsEmpty || !colors.BackColor2.IsEmpty) { try { Rectangle rb = Rectangle.Ceiling(rf); rb.Inflate(1, 1); using (LinearGradientBrush brush = DisplayHelp.CreateLinearGradientBrush(rb, colors.BackColor, colors.BackColor2, ga)) { brush.InterpolationColors = colors.BackgroundColorBlend.GetColorBlend(); g.FillPath(brush, path); } } catch { blendType = eBackgroundColorBlendType.Invalid; } } } else { Rectangle bounds = Rectangle.Ceiling(rf); BackgroundColorBlendCollection bc = colors.BackgroundColorBlend; Region oldClip = g.Clip; g.SetClip(path, CombineMode.Intersect); for (int i = 0; i < bc.Count; i += 2) { BackgroundColorBlend b1 = bc[i]; BackgroundColorBlend b2 = null; if (i < bc.Count) b2 = bc[i + 1]; if (b1 != null && b2 != null) { Rectangle rb = new Rectangle(bounds.X, bounds.Y + (int)b1.Position, bounds.Width, (b2.Position == 1f ? bounds.Height : (int)b2.Position) - (int)b1.Position); using (LinearGradientBrush brush = DisplayHelp.CreateLinearGradientBrush(rb, b1.Color, b2.Color, ga)) g.FillRectangle(brush, rb); } } g.Clip = oldClip; } } if (blendType == eBackgroundColorBlendType.Invalid) { if (colors.BackColor2.IsEmpty) { if (!colors.BackColor.IsEmpty) { using (SolidBrush brush = new SolidBrush(colors.BackColor)) g.FillPath(brush, path); } } else { using (SolidBrush brush = new SolidBrush(Color.White)) g.FillPath(brush, path); using (LinearGradientBrush brush = CreateTabGradientBrush(tabRect, colors.BackColor, colors.BackColor2, ga)) g.FillPath(brush, path); } } g.SmoothingMode = sm; DrawTabBorder(tab, path, colors, g); }
private TabColors GetTabColors(DockItemTab tab, bool selected) { TabColors c=new TabColors(); if (tab.Item != null && BarFunctions.IsOffice2007Style(tab.Item.EffectiveStyle)) { if (tab.Item.PredefinedTabColor == eTabItemColor.Default) { if (selected && !m_ColorScheme.AutoHideSelectedTabBackground.IsEmpty) { c.BackColor = m_ColorScheme.AutoHideSelectedTabBackground; c.BackColor2 = m_ColorScheme.AutoHideSelectedTabBackground2; c.BackColorGradientAngle = m_ColorScheme.AutoHideTabBackgroundGradientAngle; c.TextColor = m_ColorScheme.AutoHideSelectedTabText; c.BorderColor = m_ColorScheme.AutoHideSelectedTabBorder; } else if (!m_ColorScheme.AutoHideTabBackground.IsEmpty) { c.BackColor = m_ColorScheme.AutoHideTabBackground; c.BackColor2 = m_ColorScheme.AutoHideTabBackground2; c.BackColorGradientAngle = m_ColorScheme.AutoHideTabBackgroundGradientAngle; c.TextColor = m_ColorScheme.AutoHideTabText; c.BorderColor = m_ColorScheme.AutoHideTabBorder; } else { c.BackColor = m_ColorScheme.BarBackground; c.BackColor2 = m_ColorScheme.BarBackground2; c.BackColorGradientAngle = m_ColorScheme.BarBackgroundGradientAngle; c.TextColor = m_ColorScheme.ItemText; c.BorderColor = m_ColorScheme.BarDockedBorder; } } else { Color c1, c2; TabColorScheme.GetPredefinedColors(tab.Item.PredefinedTabColor, out c1, out c2); c.BackColor = c1; c.BackColor2 = c2; c.BackColorGradientAngle = 90; c.TextColor = m_ColorScheme.ItemText; } if (m_AutoHidePanel != null && (m_AutoHidePanel.Dock == DockStyle.Left || m_AutoHidePanel.Dock == DockStyle.Right)) { c.BackColorGradientAngle -= 90; } } else { c.BackColor = m_ColorScheme.DockSiteBackColor; c.BackColor2 = m_ColorScheme.DockSiteBackColor; c.TextColor = SystemColors.ControlText; c.BorderColor = SystemColors.ControlDarkDark; } return c; }
protected virtual void DrawTabBorder(TabItem tab, GraphicsPath path, TabColors colors, Graphics g) { if (!colors.BorderColor.IsEmpty) { using (Pen pen = new Pen(colors.BorderColor, 1)) g.DrawPath(pen, path); } }
protected virtual void DrawTabText(TabItem tab, TabColors colors, Graphics g) { int MIN_TEXT_WIDTH = 4; eTextFormat strFormat = eTextFormat.Default | eTextFormat.SingleLine | eTextFormat.EndEllipsis | eTextFormat.HorizontalCenter | eTextFormat.VerticalCenter; eTabStripAlignment align = tab.Parent.TabAlignment; Rectangle rText = tab.DisplayRectangle; bool isVertical = ((align == eTabStripAlignment.Left || align == eTabStripAlignment.Right) && !m_HorizontalText); if (m_CloseButtonOnTabs && tab.CloseButtonVisible) { if (isVertical) { rText.Y++; rText.Height--; } else { rText.X += 2; rText.Width -= 2; } bool renderCloseButton = tab.IsSelected || tab.IsMouseOver || tab.Parent.CloseButtonOnTabsAlwaysDisplayed; tab.CloseButtonBounds = DrawCloseButton(g, isVertical, tab.CloseButtonMouseOver, ref rText, tab.Parent, renderCloseButton); } // Draw image CompositeImage image = GetTabImage(tab); if (image != null && image.Width + 4 <= rText.Width) { if (align == eTabStripAlignment.Top || align == eTabStripAlignment.Bottom || m_HorizontalText) { image.DrawImage(g, new Rectangle(rText.X + 3, rText.Y + (rText.Height - image.Height) / 2, image.Width, image.Height)); int offset = image.Width + 2; rText.X += offset; rText.Width -= offset; } else { image.DrawImage(g, new Rectangle(rText.X + (rText.Width - image.Width) / 2, rText.Y + 3, image.Width, image.Height)); int offset = image.Height + 2; rText.Y += offset; rText.Height -= offset; } } if (image != null) image.Dispose(); // Draw text bool isSelected = tab == tab.Parent.SelectedTab; if (!tab.Parent.DisplaySelectedTextOnly || isSelected) { if (!tab.Parent.AntiAlias) g.TextRenderingHint = TextRenderingHint.SystemDefault; Font font = tab.Parent.Font; if (isSelected && tab.Parent.SelectedTabFont != null) font = tab.Parent.SelectedTabFont; AdjustTextRectangle(ref rText, align); if (isVertical) { g.RotateTransform(90); rText = new Rectangle(rText.Top, -rText.Right, rText.Height, rText.Width); } if (rText.Width > MIN_TEXT_WIDTH) { if ((align == eTabStripAlignment.Left || align == eTabStripAlignment.Right) && !m_HorizontalText) TextDrawing.DrawStringLegacy(g, tab.Text, font, colors.TextColor, rText, strFormat); else TextDrawing.DrawString(g, tab.Text, font, colors.TextColor, rText, strFormat); } //using (Pen pen = new Pen(Color.Red)) // g.DrawRectangle(pen, rText); if (isVertical) g.ResetTransform(); if (!tab.Parent.AntiAlias) g.TextRenderingHint = DisplayHelp.AntiAliasTextRenderingHint; if (tab.Parent.ShowFocusRectangle && tab.Parent.Focused && isSelected) ControlPaint.DrawFocusRectangle(g, GetFocusRectangle(tab.DisplayRectangle)); } }
protected override void DrawTabBorder(TabItem tab, GraphicsPath path, TabColors colors, Graphics g) { Rectangle r = tab.DisplayRectangle; eTabStripAlignment align = tab.TabAlignment; //Region oldClip = g.Clip; //Rectangle rClip = Rectangle.Ceiling(path.GetBounds()); //if (tab.TabAlignment == eTabStripAlignment.Right || tab.TabAlignment == eTabStripAlignment.Bottom) // rClip.Inflate(1, 1); //g.SetClip(rClip); if (!colors.BorderColor.IsEmpty) { using (GraphicsPath borderPath = GetTabItemPath(r, align, false)) { using (Pen pen = new Pen(colors.BorderColor)) g.DrawPath(pen, borderPath); } } if (align == eTabStripAlignment.Top) { r.Offset(1, 1); r.Width-=2; r.Height--; } else if (align == eTabStripAlignment.Bottom) { r.Offset(1, 0); r.Height--; r.Width-=2; } else if (align == eTabStripAlignment.Left) { r.Offset(1, 1); r.Height-=2; r.Width-=2; } else if (align == eTabStripAlignment.Right) { r.Offset(1, 1); r.Height -= 2; r.Width -= 2; } if (!colors.LightBorderColor.IsEmpty) { using (GraphicsPath borderPath = GetTabItemPath(r, align, false)) { //rClip = Rectangle.Ceiling(path.GetBounds()); //g.SetClip(rClip); using (Pen pen = new Pen(colors.LightBorderColor)) g.DrawPath(pen, borderPath); } } //g.Clip = oldClip; }
protected override void DrawTabItemBackground(TabItem tab, GraphicsPath path, TabColors colors, Graphics g) { RectangleF rf=path.GetBounds(); Rectangle tabRect=new Rectangle((int)rf.X, (int)rf.Y, (int)rf.Width, (int)rf.Height); if(colors.BackColor2.IsEmpty) { if(!colors.BackColor.IsEmpty) { using(SolidBrush brush=new SolidBrush(colors.BackColor)) g.FillPath(brush,path); } } else { using(SolidBrush brush=new SolidBrush(Color.White)) g.FillPath(brush,path); using(LinearGradientBrush brush=CreateTabGradientBrush(tabRect,colors.BackColor,colors.BackColor2,colors.BackColorGradientAngle)) g.FillPath(brush,path); } using(Pen pen=new Pen(colors.BorderColor,1)) { if(!colors.BorderColor.IsEmpty && (tab.IsSelected || tab.IsMouseOver)) { g.DrawPath(pen,path); } else { if(tab.TabAlignment==eTabStripAlignment.Top || tab.TabAlignment==eTabStripAlignment.Bottom) { if(!colors.LightBorderColor.IsEmpty) { using(Pen border=new Pen(colors.LightBorderColor,1)) g.DrawLine(border,tabRect.Right-1,tabRect.Y+4,tabRect.Right-1,tabRect.Bottom-4); } if(!colors.DarkBorderColor.IsEmpty) { using(Pen border=new Pen(colors.DarkBorderColor,1)) g.DrawLine(border,tabRect.Right,tabRect.Y+4,tabRect.Right,tabRect.Bottom-4); } g.DrawLine(pen,tabRect.X,tabRect.Y,tabRect.Right,tabRect.Y); g.DrawLine(pen,tabRect.X,tabRect.Bottom,tabRect.Right,tabRect.Bottom); } else if(tab.TabAlignment==eTabStripAlignment.Left || tab.TabAlignment==eTabStripAlignment.Right) { if(!colors.LightBorderColor.IsEmpty) { using(Pen border=new Pen(colors.LightBorderColor,1)) g.DrawLine(border,tabRect.X+4,tabRect.Bottom-1,tabRect.Right-4,tabRect.Bottom-1); } if(!colors.DarkBorderColor.IsEmpty) { using(Pen border=new Pen(colors.DarkBorderColor,1)) g.DrawLine(border,tabRect.X+4,tabRect.Bottom,tabRect.Right-4,tabRect.Bottom); } g.DrawLine(pen,tabRect.X,tabRect.Y,tabRect.X,tabRect.Bottom); if(tab.TabAlignment==eTabStripAlignment.Left) g.DrawLine(pen,tabRect.Right-1,tabRect.Y,tabRect.Right-1,tabRect.Bottom); else g.DrawLine(pen,tabRect.Right,tabRect.Y,tabRect.Right,tabRect.Bottom); } } } if(tab.IsSelected || tab.IsMouseOver) { GraphicsPath edge=GetTabEdge(tab); if(!colors.LightBorderColor.IsEmpty) { GraphicsPath edgeFill=edge.Clone() as GraphicsPath; edgeFill.CloseAllFigures(); using(SolidBrush brush=new SolidBrush(colors.LightBorderColor)) g.FillPath(brush,edgeFill); edgeFill.Dispose(); } if(!colors.DarkBorderColor.IsEmpty) { using(Pen pen=new Pen(colors.DarkBorderColor,1)) g.DrawPath(pen,edge); } edge.Dispose(); } }
protected virtual void DrawTabText(Graphics g, ISimpleTab tab, Rectangle rText, TabColors c) { eTextFormat strFormat=GetStringFormat(); Font font=tab.GetTabFont(); if(tab.TabAlignment==eTabStripAlignment.Left || tab.TabAlignment==eTabStripAlignment.Right) { g.RotateTransform(90); rText=new Rectangle(rText.Top,-rText.Right,rText.Height,rText.Width); } if (tab.TabAlignment == eTabStripAlignment.Left || tab.TabAlignment == eTabStripAlignment.Right) TextDrawing.DrawStringLegacy(g, tab.Text, font, c.TextColor, rText, strFormat); else TextDrawing.DrawString(g,tab.Text,font,c.TextColor,rText,strFormat); if(tab.TabAlignment==eTabStripAlignment.Left || tab.TabAlignment==eTabStripAlignment.Right) g.ResetTransform(); }
private TabColors GetTabColors(ISimpleTab tab) { TabColors c=new TabColors(); c.BackColor=tab.BackColor; c.BackColor2=tab.BackColor2; c.BackColorGradientAngle=tab.BackColorGradientAngle; c.BorderColor=tab.BorderColor; c.DarkBorderColor=tab.DarkBorderColor; c.LightBorderColor=tab.LightBorderColor; c.TextColor=tab.TextColor; if(tab.IsSelected) { if(tab is BubbleBarTab && ((BubbleBarTab)tab).Parent!=null) { TabColors sel=((BubbleBarTab)tab).Parent.SelectedTabColors; if(!sel.BackColor.IsEmpty) c.BackColor=sel.BackColor; if(!sel.BackColor2.IsEmpty) { c.BackColor2=sel.BackColor2; c.BackColorGradientAngle=sel.BackColorGradientAngle; } if(!sel.BorderColor.IsEmpty) c.BorderColor=sel.BorderColor; if(!sel.DarkBorderColor.IsEmpty) c.DarkBorderColor=sel.DarkBorderColor; if(!sel.LightBorderColor.IsEmpty) c.LightBorderColor=sel.LightBorderColor; if(!sel.TextColor.IsEmpty) c.TextColor=sel.TextColor; } } if(tab.IsMouseOver) { if(tab is BubbleBarTab && ((BubbleBarTab)tab).Parent!=null) { TabColors sel=((BubbleBarTab)tab).Parent.MouseOverTabColors; if(!sel.BackColor.IsEmpty) c.BackColor=sel.BackColor; if(!sel.BackColor2.IsEmpty) { c.BackColor2=sel.BackColor2; c.BackColorGradientAngle=sel.BackColorGradientAngle; } if(!sel.BorderColor.IsEmpty) c.BorderColor=sel.BorderColor; if(!sel.DarkBorderColor.IsEmpty) c.DarkBorderColor=sel.DarkBorderColor; if(!sel.LightBorderColor.IsEmpty) c.LightBorderColor=sel.LightBorderColor; if(!sel.TextColor.IsEmpty) c.TextColor=sel.TextColor; } } return c; }
internal TabColors GetTabColors(TabItem tab) { TabColors c=new TabColors(); if(tab==m_HotTab && !tab.IsSelected) { c.BackColor=m_ColorScheme.TabItemHotBackground; c.BackColor2=m_ColorScheme.TabItemHotBackground2; c.BackColorGradientAngle=m_ColorScheme.TabItemHotBackgroundGradientAngle; c.TextColor=m_ColorScheme.TabItemHotText; c.LightBorderColor=m_ColorScheme.TabItemHotBorderLight; c.DarkBorderColor=m_ColorScheme.TabItemHotBorderDark; c.BorderColor=m_ColorScheme.TabItemHotBorder; c.BackgroundColorBlend.CopyFrom(m_ColorScheme.TabItemHotBackgroundColorBlend); } if(this.SelectedTab==tab) { if (tab.PredefinedColor != eTabItemColor.Default) { c.BackColor=tab.BackColor; c.BackColor2=tab.BackColor2; c.BackColorGradientAngle=tab.BackColorGradientAngle; c.TextColor = tab.TextColor; } if(c.BackColor.IsEmpty) { c.BackColor=m_ColorScheme.TabItemSelectedBackground; c.BackColor2=m_ColorScheme.TabItemSelectedBackground2; c.BackColorGradientAngle=m_ColorScheme.TabItemSelectedBackgroundGradientAngle; c.BackgroundColorBlend.CopyFrom(m_ColorScheme.TabItemSelectedBackgroundColorBlend); } if(c.TextColor.IsEmpty) { if(m_ColorScheme.TabItemSelectedText.IsEmpty) c.TextColor=m_ColorScheme.TabItemText; else c.TextColor=m_ColorScheme.TabItemSelectedText; } if(c.BorderColor.IsEmpty) { c.LightBorderColor=m_ColorScheme.TabItemSelectedBorderLight; c.DarkBorderColor=m_ColorScheme.TabItemSelectedBorderDark; c.BorderColor=m_ColorScheme.TabItemSelectedBorder; } } if(c.BackColor.IsEmpty) { if(tab.BackColor.IsEmpty && tab.BackColor2.IsEmpty) { c.BackColor=m_ColorScheme.TabItemBackground; c.BackColor2=m_ColorScheme.TabItemBackground2; c.BackColorGradientAngle=m_ColorScheme.TabItemBackgroundGradientAngle; c.BackgroundColorBlend.CopyFrom(m_ColorScheme.TabItemBackgroundColorBlend); } else { c.BackColor=tab.BackColor; c.BackColor2=tab.BackColor2; c.BackColorGradientAngle=tab.BackColorGradientAngle; c.TextColor = tab.TextColor; } } if(c.TextColor.IsEmpty) { if(tab.TextColor.IsEmpty) c.TextColor=m_ColorScheme.TabItemText; else c.TextColor=tab.TextColor; } if(c.BorderColor.IsEmpty) { if(tab.BorderColor.IsEmpty && tab.LightBorderColor.IsEmpty && tab.DarkBorderColor.IsEmpty) { c.DarkBorderColor=m_ColorScheme.TabItemBorderDark; c.LightBorderColor=m_ColorScheme.TabItemBorderLight; c.BorderColor=m_ColorScheme.TabItemBorder; } else { c.LightBorderColor=tab.LightBorderColor; c.DarkBorderColor=tab.DarkBorderColor; c.BorderColor=tab.BorderColor; } } return c; }