public virtual void Paint(Graphics g, ISimpleTab[] tabs) { int iSelected=-1; for(int i=tabs.Length-1;i>=0;i--) { if(tabs[i].IsSelected) { iSelected=i; continue; } PaintTab(g,tabs[i]); } if(iSelected!=-1) PaintTab(g,tabs[iSelected]); }
protected virtual void PaintTab(Graphics g, ISimpleTab tab) { TabColors c=GetTabColors(tab); Rectangle r=tab.DisplayRectangle; r.Width+=(m_SideWidth*2); r.X-=m_SideWidth; GraphicsPath path=this.GetTabPath(r,tab.TabAlignment); if(c.BackColor2.IsEmpty) { using(SolidBrush brush=new SolidBrush(c.BackColor)) g.FillPath(brush,path); } else { using(LinearGradientBrush brush=BarFunctions.CreateLinearGradientBrush(tab.DisplayRectangle,c.BackColor,c.BackColor2,c.BackColorGradientAngle)) g.FillPath(brush,path); } r.Width--; r.Height--; //Rectangle r=tab.DisplayRectangle; // r.Width--; // r.Height--; if(!c.BorderColor.IsEmpty) { using(Pen pen=new Pen(c.BorderColor,1)) { Line l=GetLeftLine(r,tab.TabAlignment); g.DrawLine(pen,l.X1,l.Y1,l.X2,l.Y2); l=GetRightLine(r,tab.TabAlignment); g.DrawLine(pen,l.X1,l.Y1,l.X2,l.Y2); if(tab.TabAlignment==eTabStripAlignment.Top) { l=GetTopLine(r,tab.TabAlignment); g.DrawLine(pen,l.X1,l.Y1,l.X2,l.Y2); } else if(tab.TabAlignment==eTabStripAlignment.Bottom) { l=GetBottomLine(r,tab.TabAlignment); g.DrawLine(pen,l.X1,l.Y1,l.X2,l.Y2); } } } if(!c.LightBorderColor.IsEmpty) { using(Pen pen=new Pen(c.LightBorderColor,1)) { Line l=GetLeftLine(r,tab.TabAlignment); g.DrawLine(pen,l.X1,l.Y1,l.X2,l.Y2); if(tab.TabAlignment==eTabStripAlignment.Top) { l=GetTopLine(r,tab.TabAlignment); g.DrawLine(pen,l.X1,l.Y1,l.X2,l.Y2); } else if(tab.TabAlignment==eTabStripAlignment.Bottom) { l=GetBottomLine(r,tab.TabAlignment); g.DrawLine(pen,l.X1,l.Y1,l.X2,l.Y2); } } } if(!c.DarkBorderColor.IsEmpty) { using(Pen pen=new Pen(c.DarkBorderColor,1)) { Line l=GetRightLine(r,tab.TabAlignment); g.DrawLine(pen,l.X1,l.Y1,l.X2,l.Y2); } } DrawTabText(g,tab,GetTextRectangle(tab),c); // if(tab is BubbleBarTab && ((BubbleBarTab)tab).Focus) // { // Region clip=g.Clip; // g.ResetClip(); // r=tab.DisplayRectangle; // r.Width+=(m_SideWidth*2); // r.X-=m_SideWidth; // r.Inflate(1,1); // DesignTime.DrawDesignTimeSelection(g,r,Color.Navy); // g.Clip=clip; // } }
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(); }
protected virtual Rectangle GetTextRectangle(ISimpleTab tab) { Rectangle rText=tab.DisplayRectangle; rText.Y+=m_TextTopOffset; rText.Height-=m_TextTopOffset; //rText.X+=m_SideWidth/2; //rText.Width-=m_SideWidth; return rText; }
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; }
/// <summary> /// Applies predefinied tab item color scheme to the tab. /// </summary> /// <param name="item">Tab item to apply color to.</param> /// <param name="c">Predefined color to apply</param> public static void ApplyPredefinedColor(ISimpleTab item, eTabItemColor c) { Color color1, color2; GetPredefinedColors(c, out color1, out color2); item.BackColor = color1; item.BackColor2 = color2; item.BackColorGradientAngle = 90; item.TextColor = Color.Black; item.BorderColor = Color.Empty; item.DarkBorderColor = Color.FromArgb(190, Color.DimGray); item.LightBorderColor = Color.FromArgb(128, Color.White); }
/// <summary> /// Copies contained items to the ISimpleTab array. /// </summary> /// <param name="array">Array to copy to.</param> internal void CopyTo(ISimpleTab[] array) { List.CopyTo(array,0); }
protected virtual void PaintControl(PaintEventArgs e) { ElementStyleDisplayInfo info = new ElementStyleDisplayInfo(); info.Bounds = this.DisplayRectangle; info.Graphics = e.Graphics; info.Style = m_BackgroundStyle; ElementStyleDisplay.Paint(info); if (!m_ButtonBounds.IsEmpty && this.Tabs.Count > 0) { Rectangle r = GetButtonsBackground(); info.Bounds = r; info.Graphics = e.Graphics; info.Style = m_ButtonBackAreaStyle; ElementStyleDisplay.Paint(info); } SmoothingMode sm = e.Graphics.SmoothingMode; TextRenderingHint th = e.Graphics.TextRenderingHint; if (m_AntiAlias) { e.Graphics.SmoothingMode = System.Drawing.Drawing2D.SmoothingMode.AntiAlias; e.Graphics.TextRenderingHint = DisplayHelp.AntiAliasTextRenderingHint; } if (!m_TabsBounds.IsEmpty) { Rectangle r = GetTabBounds(); e.Graphics.SetClip(r); ISimpleTab[] tabs = new ISimpleTab[m_Tabs.Count]; m_Tabs.CopyTo(tabs); m_TabDisplay.Paint(e.Graphics, tabs); e.Graphics.ResetClip(); } if (m_Overlay == null) { BubbleButtonDisplayInfo displayInfo = GetBubbleButtonDisplayInfo(); displayInfo.Graphics = e.Graphics; if (m_SelectedTab != null) { foreach (BubbleButton button in m_SelectedTab.Buttons) { displayInfo.Button = button; BubbleButtonDisplay.Paint(displayInfo); } } } if (this.DesignMode && this.Tabs.Count == 0) { Rectangle r = this.DisplayRectangle; eTextFormat format = eTextFormat.Default | eTextFormat.HorizontalCenter | eTextFormat.VerticalCenter | eTextFormat.EndEllipsis | eTextFormat.WordBreak; string INFO_TEXT = "Right-click and choose Create Tab or Button to add new items."; TextDrawing.DrawString(e.Graphics, INFO_TEXT, this.Font, SystemColors.ControlDarkDark, r, format); } e.Graphics.TextRenderingHint = th; e.Graphics.SmoothingMode = sm; }