Beispiel #1
0
			protected GraphicsPath GetTabItemPath(DockItemTab tab)
			{
				Rectangle r=tab.DisplayRectangle;
				if(m_AutoHidePanel.Dock==DockStyle.Left)
					r=new Rectangle(r.X-(r.Height-r.Width),r.Y,r.Height,r.Width);
				else if(m_AutoHidePanel.Dock==DockStyle.Right)
					r=new Rectangle(r.X,r.Y,r.Height,r.Width);

				r.Offset(0,1);

				GraphicsPath path=new GraphicsPath();
                int cornerSize = 2;
				// Left line
				//path.AddPath(GetLeftLine(r),true);
                path.AddLine(r.X, r.Bottom, r.X, r.Y + cornerSize);

				// Top line
				path.AddLine(r.X+cornerSize,r.Y,r.Right-cornerSize,r.Y);

				// Right line
				//path.AddPath(GetRightLine(r),true);
                path.AddLine(r.Right, r.Y+cornerSize, r.Right, r.Bottom);

				// Bottom line
				//path.AddLine(r.Right+m_xTabOffset,r.Bottom,r.X-m_xTabOffset,r.Bottom);
                path.AddLine(r.Right , r.Bottom, r.X, r.Bottom);

				path.CloseAllFigures();

				if(m_AutoHidePanel.Dock==DockStyle.Top)
				{
					// Bottom
					Matrix m=new Matrix();
					m.RotateAt(180,new PointF(r.X+r.Width/2,r.Y+r.Height/2));
					path.Transform(m);
				}
				else if(m_AutoHidePanel.Dock==DockStyle.Right)
				{
					// Left
					Matrix m=new Matrix();
					m.RotateAt(-90,new PointF(r.X,r.Bottom));
					m.Translate(r.Height,r.Width-r.Height,MatrixOrder.Append);
					path.Transform(m);
				}
				else if(m_AutoHidePanel.Dock==DockStyle.Left)
				{
					// Right
					Matrix m=new Matrix();
					m.RotateAt(90,new PointF(r.Right,r.Bottom));
					m.Translate(-r.Height,r.Width-(r.Height-1),MatrixOrder.Append);
					path.Transform(m);
				}

				return path;
			}
Beispiel #2
0
			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();
				}
			}
Beispiel #3
0
			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);
				}
			}
Beispiel #4
0
			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;
			}
Beispiel #5
0
			protected virtual void PaintTab(Graphics g, DockItemTab tab, bool selected)
			{
				GraphicsPath path=GetTabItemPath(tab);
				TabColors colors=GetTabColors(tab,selected);

				DrawTabItemBackground(tab,path,colors,g);
				
				DrawTabText(tab,colors,g,selected);
			}
Beispiel #6
0
			public void ReloadDockItems()
			{
				foreach(DockItemTab tab in Tabs)
					tab.Dispose();
				Tabs.Clear();

                Graphics g = BarFunctions.CreateGraphics(BoundBar);
				try
				{
					if(BoundBar.LayoutType==eLayoutType.DockContainer)
					{
						foreach(BaseItem item in BoundBar.Items)
						{
							DockContainerItem dockItem=item as DockContainerItem;
							if(dockItem!=null && dockItem.Visible)
							{
								DockItemTab tab=new DockItemTab(this,dockItem);
								this.Tabs.Add(tab);
                                tab.TextSize = TextDrawing.MeasureStringLegacy(g, dockItem.Text, m_Parent.Font, Size.Empty, eTextFormat.Default);
                                tab.TextSize.Width += 4;
							}
						}
					}
					if(this.Tabs.Count==0)
					{
						DockItemTab tab=new DockItemTab(this,BoundBar.Text);
						this.Tabs.Add(tab);
                        tab.TextSize = TextDrawing.MeasureStringLegacy(g, BoundBar.Text, m_Parent.Font, Size.Empty, eTextFormat.Default);
                        tab.TextSize.Width += 4;
					}
				}
				finally
				{
					g.Dispose();
				}
				m_PanelSize=CalcPanelSize();
				if(BoundBar.SelectedDockTab>=0)
					this.ActiveTab=BoundBar.SelectedDockTab;
				else
					this.ActiveTab=0;
			}