コード例 #1
0
		protected virtual void PaintTab(Graphics g, TabItem tab, bool first, bool last)
		{
			if(!tab.Visible)
				return;

            if (tab.Parent!=null && tab.Parent.HasPreRenderTabItem)
            {
                RenderTabItemEventArgs re = new RenderTabItemEventArgs(tab, g);
                tab.Parent.InvokePreRenderTabItem(re);
                if (re.Cancel) return;
            }

            using (GraphicsPath path = GetTabItemPath(tab, first, last))
            {
                TabColors colors = tab.Parent.GetTabColors(tab);

                DrawTabItemBackground(tab, path, colors, g);

                DrawTabText(tab, colors, g);
            }

            if (tab.Parent != null && tab.Parent.HasPostRenderTabItem)
            {
                RenderTabItemEventArgs re = new RenderTabItemEventArgs(tab, g);
                tab.Parent.InvokePostRenderTabItem(re);
            }
		}
コード例 #2
0
		private void PaintFlat(Graphics g)
		{
			TabColorScheme colorScheme=m_ColorScheme;
//			if(m_Style==eTabStripStyle.Themed)
//				colorScheme=new TabColorScheme(eTabStripStyle.Flat);

			if(!colorScheme.TabBackground2.IsEmpty && this.Height>0 && this.Width>0)
			{
				using(LinearGradientBrush gradient=BarFunctions.CreateLinearGradientBrush(this.ClientRectangle,colorScheme.TabBackground,colorScheme.TabBackground2,colorScheme.TabBackgroundGradientAngle))
					g.FillRectangle(gradient,this.ClientRectangle);
				
			}
			else
			{
				using(SolidBrush brush=new SolidBrush(colorScheme.TabBackground))
					g.FillRectangle(brush,this.DisplayRectangle);
				//g.Clear(colorScheme.TabBackground);
			}

            if (m_Style != eTabStripStyle.Metro)
            {
                if (!colorScheme.TabBorder.IsEmpty)
                {
                    using (Pen pen = new Pen(colorScheme.TabBorder, 1))
                        g.DrawRectangle(pen, new Rectangle(ClientRectangle.X, ClientRectangle.Y, ClientRectangle.Width - 1, ClientRectangle.Height - 1));
                }
            }

			// Fill tab background color
			Rectangle r=this.DisplayRectangle;

			switch(m_Alignment)
			{
				case eTabStripAlignment.Bottom:
				{
					r.Height-=3;
					break;
				}
				case eTabStripAlignment.Top:
				{
					r.Y+=1;
					r.Height-=3;
					break;
				}
			}

			// See how we will draw items
			TabItem selected=this.SelectedTab;
            eTextFormat strFormat = eTextFormat.Default | eTextFormat.SingleLine | eTextFormat.EndEllipsis | eTextFormat.HorizontalCenter |
                eTextFormat.VerticalCenter;

			int outerBorderAdjustment=(colorScheme.TabBorder.IsEmpty?0:1);
			// Draw the upper back line
            if (m_Style != eTabStripStyle.Metro)
            {
                switch (m_Alignment)
                {
                    case eTabStripAlignment.Top:
                        {
                            if (!(this.Parent is TabControl))
                                g.FillRectangle(new SolidBrush((colorScheme.TabItemSelectedBackground2.IsEmpty ? colorScheme.TabItemSelectedBackground : colorScheme.TabItemSelectedBackground2)), r.X + outerBorderAdjustment, r.Bottom, r.Width - outerBorderAdjustment * 2, this.Height - r.Bottom);
                            else
                            {
                                using (Pen pen = new Pen(colorScheme.TabItemSelectedBorder, 1))
                                {
                                    g.DrawLine(pen, r.X, r.Bottom, r.X, ClientRectangle.Bottom);
                                    g.DrawLine(pen, r.Right - 1, r.Bottom, r.Right - 1, ClientRectangle.Bottom);
                                }
                            }
                            g.DrawLine(new Pen(colorScheme.TabItemSelectedBorderLight, 1), r.X + outerBorderAdjustment, r.Bottom, r.Right - 1 - outerBorderAdjustment, r.Bottom);
                            r.Inflate(-4, 0);
                            break;
                        }
                    case eTabStripAlignment.Left:
                        {
                            g.DrawLine(new Pen(colorScheme.TabItemSelectedBorderLight, 1), r.Right - 1, r.Y + outerBorderAdjustment, r.Right - 1, r.Bottom - outerBorderAdjustment);
                            r.Inflate(0, -4);
                            break;
                        }
                    case eTabStripAlignment.Right:
                        {
                            g.DrawLine(new Pen(colorScheme.TabItemSelectedBorderLight, 1), r.X, r.Y + outerBorderAdjustment, r.X, r.Bottom - outerBorderAdjustment);
                            r.Inflate(0, -4);
                            break;
                        }
                    default:
                        {
                            if (!(this.Parent is TabControl))
                                g.FillRectangle(new SolidBrush(colorScheme.TabItemSelectedBackground), r.X, 0, r.Width, r.Y);
                            else
                            {
                                using (Pen pen = new Pen(colorScheme.TabItemSelectedBorder, 1))
                                {
                                    g.DrawLine(pen, r.X, r.Y, r.X, 0);
                                    g.DrawLine(pen, r.Right - 1, r.Y, r.Right - 1, 0);
                                }
                            }
                            g.DrawLine(new Pen(colorScheme.TabItemSelectedBorderLight, 1), r.X, r.Y, r.Right, r.Y);
                            r.Inflate(-4, 0);
                            break;
                        }
                }
            }

            if (this.HasNavigationBox && m_TabSystemBox.Visible)
			{
				if(m_Alignment==eTabStripAlignment.Right || m_Alignment==eTabStripAlignment.Left)
				{
					if(m_TabSystemBox.DisplayRectangle.Height>0)
						r.Height-=m_TabSystemBox.DisplayRectangle.Height;
					else
                        r.Height-=m_TabSystemBox.DefaultWidth;
				}
				else
				{
					if(m_TabSystemBox.DisplayRectangle.Width>0)
						r.Width-=m_TabSystemBox.DisplayRectangle.Width;
					else
                        r.Width-=m_TabSystemBox.DefaultWidth;
                    if(this.IsRightToLeft)
                        r.X += m_TabSystemBox.DefaultWidth;
				}
			}
			if(m_NeedRecalcSize)
				RecalcSize(g,this.GetTabClientArea(this.DisplayRectangle,false,false));
			if(m_Alignment==eTabStripAlignment.Top)
				r.Height++;
			Rectangle rClip=r;
			g.SetClip(r);
            Rectangle selectedTabRect = Rectangle.Empty;
			foreach(TabItem tab in m_Tabs)
			{
				if(!tab.Visible || !r.IntersectsWith(tab.DisplayRectangle))
					continue;
                if (HasPreRenderTabItem)
                {
                    RenderTabItemEventArgs re = new RenderTabItemEventArgs(tab, g);
                    InvokePreRenderTabItem(re);
                    if (re.Cancel) continue;
                }

                Rectangle tabRect = tab.DisplayRectangle;
				TabColors tabColors=GetTabColors(tab);
				if(m_Alignment==eTabStripAlignment.Left || m_Alignment==eTabStripAlignment.Right)
				{
					if(tab==selected)
					{
                        selectedTabRect = tabRect;
						if(m_Alignment==eTabStripAlignment.Left)
						{
							if(tabColors.BackColor2.IsEmpty)
							{
								using(SolidBrush brush=new SolidBrush(g.GetNearestColor(tabColors.BackColor)))
									g.FillRectangle(brush,tabRect);
							}
							else
							{
								using(LinearGradientBrush gradient=BarFunctions.CreateLinearGradientBrush(tabRect,tabColors.BackColor,tabColors.BackColor2,tabColors.BackColorGradientAngle))
									g.FillRectangle(gradient,tabRect);
							}
                            if (m_Style == eTabStripStyle.Metro)
                            {
                                using (Pen p = new Pen(tabColors.BorderColor, 1))
                                {
                                    g.DrawLine(p, tabRect.X, tabRect.Y, tabRect.Right - 1, tabRect.Y);
                                    g.DrawLine(p, tabRect.X, tabRect.Bottom - 1, tabRect.Right - 1, tabRect.Bottom - 1);
                                }
                                using (SolidBrush brush = new SolidBrush(tabColors.TextColor))
                                    g.FillRectangle(brush, new Rectangle(tabRect.X, tabRect.Y, 2, tabRect.Height));
                            }
                            else
                            {
                                Pen p = new Pen(tabColors.LightBorderColor, 1);
                                g.DrawLine(p, tabRect.X, tabRect.Y, tabRect.Right, tabRect.Y);
                                g.DrawLine(p, tabRect.X, tabRect.Y, tabRect.X, tabRect.Bottom);
                                p.Dispose();
                                p = new Pen(tabColors.BorderColor, 1);
                                g.DrawLine(p, tabRect.X + 1, tabRect.Bottom, tabRect.Right - 2, tabRect.Bottom);
                                p.Dispose();
                            }
						}
						else
						{
							if(tabColors.BackColor2.IsEmpty)
							{
								using(SolidBrush brush=new SolidBrush(g.GetNearestColor(tabColors.BackColor)))
									g.FillRectangle(brush,tabRect.X,tabRect.Y,tabRect.Width,tabRect.Height+1);
							}
							else
							{
								using(LinearGradientBrush gradient=BarFunctions.CreateLinearGradientBrush(new Rectangle(tabRect.X,tabRect.Y,tabRect.Width,tabRect.Height+1),tabColors.BackColor,tabColors.BackColor2,tabColors.BackColorGradientAngle))
									g.FillRectangle(gradient,tabRect.X,tabRect.Y,tabRect.Width,tabRect.Height+1);
							}
                            if (m_Style == eTabStripStyle.Metro)
                            {
                                using (Pen p = new Pen(tabColors.BorderColor, 1))
                                {
                                    g.DrawLine(p, tabRect.X, tabRect.Y, tabRect.Right - 1, tabRect.Y);
                                    g.DrawLine(p, tabRect.X, tabRect.Bottom - 1, tabRect.Right - 1, tabRect.Bottom - 1);
                                }
                                using (SolidBrush brush = new SolidBrush(tabColors.TextColor))
                                    g.FillRectangle(brush, new Rectangle(tabRect.Right - 2, tabRect.Y, 2, tabRect.Height));
                            }
                            else
                            {
                                Pen p = new Pen(tabColors.LightBorderColor, 1);
                                g.DrawLine(p, tabRect.X, tabRect.Y, tabRect.Right, tabRect.Y);
                                g.DrawLine(p, tabRect.Right - 1, tabRect.Y, tabRect.Right - 1, tabRect.Bottom);
                                p.Dispose();
                                p = new Pen(tabColors.BorderColor, 1);
                                g.DrawLine(p, tabRect.X, tabRect.Bottom, tabRect.Right - 3, tabRect.Bottom);
                                p.Dispose();
                            }
						}
					}
					else
					{
						if(!tabColors.BackColor.IsEmpty)
						{
							if(!tabColors.BackColor2.IsEmpty)
							{
								using(LinearGradientBrush gradient=BarFunctions.CreateLinearGradientBrush(tabRect,tabColors.BackColor,tabColors.BackColor2,tabColors.BackColorGradientAngle))
									g.FillRectangle(gradient,tabRect);
							}
							else
							{
								using(SolidBrush brush=new SolidBrush(tabColors.BackColor))
									g.FillRectangle(brush,tabRect);
							}
						}

						if(!tabColors.LightBorderColor.IsEmpty)
						{
							if(m_Alignment==eTabStripAlignment.Left)
							{
								using(Pen p=new Pen(tabColors.LightBorderColor,1))
								{
									g.DrawLine(p,tabRect.X,tabRect.Y,tabRect.Right,tabRect.Y);
									g.DrawLine(p,tabRect.X,tabRect.Y,tabRect.X,tabRect.Bottom);
								}
							}
							else
							{
								using(Pen p=new Pen(tabColors.LightBorderColor,1))
								{
									g.DrawLine(p,tabRect.X,tabRect.Y,tabRect.Right,tabRect.Y);
									g.DrawLine(p,tabRect.Right-1,tabRect.Y,tabRect.Right-1,tabRect.Bottom);
								}
							}
						}

						if(!tabColors.BorderColor.IsEmpty)
						{
							if(m_Alignment==eTabStripAlignment.Left)
							{
								using(Pen p=new Pen(tabColors.BorderColor,1))
								{
									g.DrawLine(p,tabRect.X+1,tabRect.Bottom,tabRect.Right-2,tabRect.Bottom);
									g.DrawLine(p,tabRect.Right-1,tabRect.Bottom,tabRect.Right-1,tabRect.Y+1);
								}
							}
							else
							{
								using(Pen p=new Pen(tabColors.BorderColor,1))
								{
									g.DrawLine(p,tabRect.X,tabRect.Y+1,tabRect.X,tabRect.Bottom);
									g.DrawLine(p,tabRect.X+1,tabRect.Bottom,tabRect.Right-2,tabRect.Bottom);
								}
							}
						}						
					}

                    if (m_CloseButtonOnTabs && tab.CloseButtonVisible)
                        tab.CloseButtonBounds = PaintTabItemCloseButton(g, true, tab.CloseButtonMouseOver, tab == m_HotTab || tab == this.SelectedTab, ref tabRect);
                    else
                        tab.CloseButtonBounds = Rectangle.Empty;

					Image tabImage=tab.GetImage();
					Icon icon=tab.Icon;
					if(tabImage!=null && tabImage.Width+4<=tabRect.Width || icon!=null && tab.IconSize.Width+4<=tabRect.Width)
					{
						if(icon!=null)
						{
							Rectangle rIcon=new Rectangle(tabRect.X+(tabRect.Width-tab.IconSize.Width)/2,tabRect.Y+4,tab.IconSize.Width,tab.IconSize.Height);
							if(rClip.Contains(rIcon))
								g.DrawIcon(icon,rIcon);
							tabRect.Y+=(tab.IconSize.Height+2);
							tabRect.Height-=(tab.IconSize.Height+2);
						}
						else if(tabImage!=null)
						{
							g.DrawImage(tabImage,tabRect.X+(tabRect.Width-tabImage.Width)/2,tabRect.Y+4,tabImage.Width,tabImage.Height);
							tabRect.Y+=(tabImage.Height+2);
							tabRect.Height-=(tabImage.Height+2);
						}
						tabRect.Inflate(0,-1);
						tabRect.Height-=4;
						tabRect.Y+=3;
					}
					else
					{
						tabRect.Y+=2;
						tabRect.Height-=2;
					}

					g.RotateTransform(90);
					if(!m_DisplaySelectedTextOnly || tab==m_SelectedTab)
					{
						Font font=this.Font;
						if(tab==selected && m_SelectedTabFont!=null)
							font=m_SelectedTabFont;
						Rectangle rText=new Rectangle(tabRect.Top,-tabRect.Right,tabRect.Height,tabRect.Width);
						if(rText.Height>MIN_TEXT_WIDTH)
						{
							TextDrawing.DrawStringLegacy(g,tab.Text,font,tabColors.TextColor,rText,strFormat);
						}
						if(m_ShowFocusRectangle && this.Focused && tab==m_SelectedTab)
							ControlPaint.DrawFocusRectangle(g,GetFocusRectangle(rText));
								g.ResetTransform();
					}
					// Draw separator
					if(tab!=selected)
					{
						g.DrawLine(new Pen(colorScheme.TabItemSeparator,1),tab.DisplayRectangle.X+1,tab.DisplayRectangle.Bottom,tab.DisplayRectangle.Right-4,tab.DisplayRectangle.Bottom);
						if(!colorScheme.TabItemSeparatorShade.IsEmpty)
                            g.DrawLine(new Pen(colorScheme.TabItemSeparatorShade,1),tab.DisplayRectangle.X+1+1,tab.DisplayRectangle.Bottom+1,tab.DisplayRectangle.Right-4+1,tab.DisplayRectangle.Bottom+1);
					}
				}
				else
				{
					if(tab==selected)
					{
                        selectedTabRect = tabRect;
						if(m_Alignment==eTabStripAlignment.Bottom)
						{
							if(tabColors.BackColor2.IsEmpty)
							{
								using(SolidBrush brush=new SolidBrush(g.GetNearestColor(tabColors.BackColor)))
									g.FillRectangle(brush,tabRect);
							}
							else
							{
								using(LinearGradientBrush gradient=BarFunctions.CreateLinearGradientBrush(tabRect,tabColors.BackColor,tabColors.BackColor2,tabColors.BackColorGradientAngle))
									g.FillRectangle(gradient,tabRect);
							}

                            if (m_Style == eTabStripStyle.Metro)
                            {
                                using (Pen p = new Pen(tabColors.BorderColor, 1))
                                {
                                    g.DrawLine(p, tabRect.X, tabRect.Y, tabRect.X, tabRect.Bottom - 1);
                                    g.DrawLine(p, tabRect.Right - 1, tabRect.Y, tabRect.Right - 1, tabRect.Bottom - 1);
                                }
                                using (SolidBrush brush = new SolidBrush(tabColors.TextColor))
                                    g.FillRectangle(brush, new Rectangle(tabRect.X, tabRect.Bottom - 2, tabRect.Width, 2));
                            }
                            else
                            {
                                using (Pen p = new Pen(tabColors.LightBorderColor, 1))
                                    g.DrawLine(p, tabRect.X, tabRect.Y, tabRect.X, tabRect.Bottom);
                                using (Pen p = new Pen(tabColors.BorderColor, 1))
                                {
                                    g.DrawLine(p, tabRect.X + 1, tabRect.Bottom, tabRect.Right, tabRect.Bottom);
                                    g.DrawLine(p, tabRect.Right, tabRect.Y, tabRect.Right, tabRect.Bottom);
                                }
                            }
						}
						else
						{
							if(tabColors.BackColor2.IsEmpty)
							{
								using(SolidBrush brush=new SolidBrush(g.GetNearestColor(tabColors.BackColor)))
									g.FillRectangle(brush,tabRect.X,tabRect.Y,tabRect.Width,tabRect.Height+1);
							}
							else
							{
								using(LinearGradientBrush gradient=BarFunctions.CreateLinearGradientBrush(new Rectangle(tabRect.X,tabRect.Y,tabRect.Width,tabRect.Height+1),tabColors.BackColor,tabColors.BackColor2,tabColors.BackColorGradientAngle))
									g.FillRectangle(gradient,tabRect.X,tabRect.Y,tabRect.Width,tabRect.Height+1);
							}

                            if (m_Style == eTabStripStyle.Metro)
                            {
                                using (Pen p = new Pen(tabColors.BorderColor, 1))
                                {
                                    g.DrawLine(p, tabRect.X, tabRect.Y, tabRect.X, tabRect.Bottom);
                                    g.DrawLine(p, tabRect.Right - 1, tabRect.Y, tabRect.Right - 1, tabRect.Bottom);
                                }
                                using (SolidBrush brush = new SolidBrush(tabColors.TextColor))
                                    g.FillRectangle(brush, new Rectangle(tabRect.X, tabRect.Y, tabRect.Width, 2));
                            }
                            else
                            {
                                using (Pen p = new Pen(tabColors.LightBorderColor, 1))
                                {
                                    g.DrawLine(p, tabRect.X, tabRect.Y, tabRect.X, tabRect.Bottom);
                                    g.DrawLine(p, tabRect.X, tabRect.Y, tabRect.Right, tabRect.Y);
                                }
                                using (Pen p = new Pen(tabColors.BorderColor, 1))
                                    g.DrawLine(p, tabRect.Right, tabRect.Y, tabRect.Right, tabRect.Bottom);
                            }
						}
					}
					else
					{
						if(!tabColors.BackColor.IsEmpty)
						{
							Rectangle rBack=tabRect;
							rBack.Width--;
							rBack.X++;
							rBack.Height--;
							rBack.Y++;
							if(!tabColors.BackColor2.IsEmpty)
							{
								using(LinearGradientBrush gradient=BarFunctions.CreateLinearGradientBrush(tabRect,tabColors.BackColor,tabColors.BackColor2,tabColors.BackColorGradientAngle))
									g.FillRectangle(gradient,rBack);
							}
							else
							{
								using(SolidBrush brush=new SolidBrush(tabColors.BackColor))
									g.FillRectangle(brush,rBack);
							}
						}
						if(!tabColors.LightBorderColor.IsEmpty)
						{
							if(m_Alignment==eTabStripAlignment.Bottom)
							{
								using(Pen p=new Pen(tabColors.LightBorderColor,1))
								{
									g.DrawLine(p,tabRect.X,tabRect.Y,tabRect.Right,tabRect.Y);
									g.DrawLine(p,tabRect.X,tabRect.Y,tabRect.X,tabRect.Bottom);
								}
							}
							else
							{
								using(Pen p=new Pen(tabColors.LightBorderColor,1))
								{
									g.DrawLine(p,tabRect.X,tabRect.Y,tabRect.X,tabRect.Bottom);
									g.DrawLine(p,tabRect.X,tabRect.Y,tabRect.Right,tabRect.Y);
								}
							}
						}

						if(!tabColors.BorderColor.IsEmpty)
						{
							if(m_Alignment==eTabStripAlignment.Bottom)
							{
								using(Pen p=new Pen(tabColors.BorderColor,1))
								{
									g.DrawLine(p,tabRect.X+1,tabRect.Bottom,tabRect.Right,tabRect.Bottom);
									g.DrawLine(p,tabRect.Right,tabRect.Y,tabRect.Right,tabRect.Bottom);
								}
							}
							else
							{
								using(Pen p=new Pen(tabColors.BorderColor,1))
								{
									g.DrawLine(p,tabRect.Right-1,tabRect.Y,tabRect.Right-1,tabRect.Bottom);
									g.DrawLine(p,tabRect.X,tabRect.Bottom,tabRect.Right,tabRect.Bottom);
								}
							}
						}
					}

					if(m_Alignment==eTabStripAlignment.Top)
						tabRect.Offset(0,1);

                    if (m_CloseButtonOnTabs && tab.CloseButtonVisible)
                        tab.CloseButtonBounds = PaintTabItemCloseButton(g, false, tab.CloseButtonMouseOver, tab == m_HotTab || tab == this.SelectedTab, ref tabRect);
                    else
                        tab.CloseButtonBounds = Rectangle.Empty;

					Image tabImage=tab.GetImage();
					Icon icon=tab.Icon;
					if(tabImage!=null && tabImage.Width+4<tabRect.Width || icon!=null && tab.IconSize.Width+4<tabRect.Width)
					{
						if(icon!=null)
						{
							Rectangle rIcon=new Rectangle(tabRect.X+4,tabRect.Y+(tabRect.Height-tab.IconSize.Height)/2,tab.IconSize.Width,tab.IconSize.Height);
							if(rClip.Contains(rIcon))
								g.DrawIcon(icon,rIcon);
							tabRect.X+=(tab.IconSize.Width+2);
							tabRect.Width-=(tab.IconSize.Width+2);
						}
						else if(tabImage!=null)
						{
							g.DrawImage(tabImage,tabRect.X+4,tabRect.Y+(tabRect.Height-tabImage.Height)/2,tabImage.Width,tabImage.Height);
							tabRect.X+=(tabImage.Width+2);
							tabRect.Width-=(tabImage.Width+2);
						}
						tabRect.Inflate(0,-1);
						tabRect.Width-=4;
						tabRect.X+=3;
					}
					else
					{
						tabRect.X+=2;
						tabRect.Width-=2;
					}

					if(!m_DisplaySelectedTextOnly || tab==m_SelectedTab)
					{
						Font font=this.Font;
						if(tab==selected && m_SelectedTabFont!=null)
							font=m_SelectedTabFont;
						if(tabRect.Width>MIN_TEXT_WIDTH)
						{
							TextDrawing.DrawString(g,tab.Text,font,tabColors.TextColor,tabRect,strFormat);
						}
						if(m_ShowFocusRectangle && this.Focused && tab==m_SelectedTab)
							ControlPaint.DrawFocusRectangle(g,GetFocusRectangle(tabRect));
					}
	                    
					if(tab!=selected)
					{
                        Rectangle rect = tab.DisplayRectangle;
                        if (this.IsRightToLeft)
                            rect.Width -= 2;
						using(Pen p=new Pen(colorScheme.TabItemSeparator,1))
							g.DrawLine(p,rect.Right,rect.Y+2,rect.Right,rect.Bottom-4);
						if(!colorScheme.TabItemSeparatorShade.IsEmpty)
						{
							using(Pen p=new Pen(colorScheme.TabItemSeparatorShade,1))
								g.DrawLine(p,rect.Right+1,rect.Y+2+1,rect.Right+1,rect.Bottom-4+1);
						}
					}
				}

                if (HasPostRenderTabItem)
                {
                    RenderTabItemEventArgs re = new RenderTabItemEventArgs(tab, g);
                    InvokePostRenderTabItem(re);
                }
			}
			g.ResetClip();

            if (m_Style == eTabStripStyle.Metro && !selectedTabRect.IsEmpty && !colorScheme.TabBorder.IsEmpty)
            {
                if (m_Alignment == eTabStripAlignment.Top)
                {
                    using (Pen pen = new Pen(colorScheme.TabBorder, 1))
                    {
                        g.DrawLine(pen, ClientRectangle.X, ClientRectangle.Bottom - 1, selectedTabRect.X, ClientRectangle.Bottom - 1);
                        g.DrawLine(pen, selectedTabRect.Right - 1, ClientRectangle.Bottom - 1, ClientRectangle.Right - 1, ClientRectangle.Bottom - 1);
                    }
                }
                else if (m_Alignment == eTabStripAlignment.Bottom)
                {
                    using (Pen pen = new Pen(colorScheme.TabBorder, 1))
                    {
                        g.DrawLine(pen, ClientRectangle.X, ClientRectangle.Y, selectedTabRect.X, ClientRectangle.Y);
                        g.DrawLine(pen, selectedTabRect.Right - 1, ClientRectangle.Y, ClientRectangle.Right - 1, ClientRectangle.Y);
                    }
                }
                else if (m_Alignment == eTabStripAlignment.Left)
                {
                    using (Pen pen = new Pen(colorScheme.TabBorder, 1))
                    {
                        g.DrawLine(pen, ClientRectangle.Right - 1, ClientRectangle.Y, ClientRectangle.Right - 1, selectedTabRect.Y);
                        g.DrawLine(pen, ClientRectangle.Right - 1, selectedTabRect.Bottom - 1, ClientRectangle.Right - 1, ClientRectangle.Bottom - 1);
                    }
                }
                else if (m_Alignment == eTabStripAlignment.Right)
                {
                    using (Pen pen = new Pen(colorScheme.TabBorder, 1))
                    {
                        g.DrawLine(pen, ClientRectangle.X, ClientRectangle.Y, ClientRectangle.X, selectedTabRect.Y);
                        g.DrawLine(pen, ClientRectangle.X, selectedTabRect.Bottom - 1, ClientRectangle.X, ClientRectangle.Bottom - 1);
                    }
                }
            }

			if(this.HasNavigationBox && m_TabSystemBox.Visible)
			{
				g.SetClip(m_TabSystemBox.DisplayRectangle);
				m_TabSystemBox.Paint(g);
				g.ResetClip();
			}
		}
コード例 #3
0
 internal void InvokePostRenderTabItem(RenderTabItemEventArgs e)
 {
     if (PostRenderTabItem != null)
         PostRenderTabItem(this, e);
 }
コード例 #4
0
		private void PaintVS2005(Graphics g)
		{
			if(!m_ColorScheme.TabBackground2.IsEmpty && this.Width>0 && this.Height>0)
			{
				using(LinearGradientBrush gradient=BarFunctions.CreateLinearGradientBrush(this.ClientRectangle,m_ColorScheme.TabBackground,m_ColorScheme.TabBackground2,m_ColorScheme.TabBackgroundGradientAngle))
					g.FillRectangle(gradient,this.ClientRectangle);
			}
			else
			{
				using(SolidBrush brush=new SolidBrush(m_ColorScheme.TabBackground))
					g.FillRectangle(brush,this.DisplayRectangle);
			}

			Rectangle r=this.GetTabClientArea(this.DisplayRectangle,false,false);
			Rectangle client=this.DisplayRectangle;

			if(m_NeedRecalcSize)
				RecalcSize(g,r);

            // Text format
            TabItem selected = this.SelectedTab;
            Rectangle selectedRect = Rectangle.Empty;
            if (selected != null)
                selectedRect = selected.DisplayRectangle;
            eTextFormat strFormat = eTextFormat.Default | eTextFormat.SingleLine | eTextFormat.EndEllipsis |
                eTextFormat.VerticalCenter | eTextFormat.HorizontalCenter;

			switch(m_Alignment)
			{
				case eTabStripAlignment.Top:
				{
                    using (Pen pen = new Pen(m_ColorScheme.TabItemSelectedBorder, 1))
                    {
                        if (!selectedRect.IsEmpty)
                        {
                            g.DrawLine(pen, client.X, r.Bottom, selectedRect.X, r.Bottom);
                            g.DrawLine(pen, selectedRect.Right - 1, r.Bottom, client.Right, r.Bottom);
                        }
                        else
                            g.DrawLine(pen, client.X, client.Bottom - 1, client.Right, client.Bottom - 1);
                    }
                    //r.Height--;
					break;
				}
				case eTabStripAlignment.Bottom:
				{
                    using (Pen pen = new Pen(m_ColorScheme.TabItemSelectedBorder, 1))
                    {
                        if (!selectedRect.IsEmpty)
                        {
                            g.DrawLine(pen, client.X, client.Y, selectedRect.X, client.Y);
                            g.DrawLine(pen, selectedRect.Right - 1, client.Y, client.Right, client.Y);
                        }
                        else
                            g.DrawLine(pen, client.X, client.Y, client.Right, client.Y);
                    }
                    r.Y++;
                    r.Height--;
					break;
				}
				case eTabStripAlignment.Left:
				{
                    using (Pen pen = new Pen(m_ColorScheme.TabItemSelectedBorder, 1))
                    {
                        if (!selectedRect.IsEmpty)
                        {
                            g.DrawLine(pen, client.Right - 1, client.Y, client.Right - 1, selectedRect.Y);
                            g.DrawLine(pen, client.Right - 1, selectedRect.Bottom - 1, client.Right - 1, client.Bottom);
                        }
                        else
                            g.DrawLine(pen, client.Right - 1, client.Y, client.Right - 1, client.Bottom);
                    }
                    r.Width--;
					break;
				}
				case eTabStripAlignment.Right:
				{
                    using (Pen pen = new Pen(m_ColorScheme.TabItemSelectedBorder, 1))
                    {
                        if (!selectedRect.IsEmpty)
                        {
                            g.DrawLine(pen, client.X, client.Y, client.X, selectedRect.Y);
                            g.DrawLine(pen, client.X, selectedRect.Bottom - 1, client.X, client.Bottom);
                        }
                        else
                            g.DrawLine(pen, client.X, client.Y, client.X, client.Bottom);
                    }
                    r.Width--;
                    r.X++;
					break;
				}
			}

            if (this.HasNavigationBox && m_TabSystemBox.Visible)
			{
                if (m_Alignment == eTabStripAlignment.Right || m_Alignment == eTabStripAlignment.Left)
                    r.Height -= m_TabSystemBox.DisplayRectangle.Height;
                else
                {
                    r.Width -= m_TabSystemBox.DisplayRectangle.Width;
                    if (this.IsRightToLeft)
                        r.X += m_TabSystemBox.DisplayRectangle.Width;
                }
			}

			Rectangle rClip=r;
			if(m_Alignment==eTabStripAlignment.Right)
				rClip.Width++;
			
			g.SetClip(rClip);

			foreach(TabItem tab in m_Tabs)
			{
				if(!tab.Visible || !r.IntersectsWith(tab.DisplayRectangle))
					continue;

                if (HasPreRenderTabItem)
                {
                    RenderTabItemEventArgs re = new RenderTabItemEventArgs(tab, g);
                    InvokePreRenderTabItem(re);
                    if (re.Cancel) continue;
                }

				Rectangle tabRect=tab.DisplayRectangle;
				TabColors colors=GetTabColors(tab);
                
				GraphicsPath path=new GraphicsPath();
				switch(m_Alignment)
				{
					case eTabStripAlignment.Top:
					{
                        tabRect.Width--;
						path.AddLine(tabRect.X+2,tabRect.Y,tabRect.Right-2,tabRect.Y);
                        path.AddLine(tabRect.Right,tabRect.Y+2,tabRect.Right,tabRect.Bottom);
                        path.AddLine(tabRect.Right,tabRect.Bottom,tabRect.X,tabRect.Bottom);
						path.AddLine(tabRect.X,tabRect.Y+2,tabRect.X+2,tabRect.Y);
						path.CloseAllFigures();
						break;
					}
					case eTabStripAlignment.Bottom:
					{
                        tabRect.Width--;
						path.AddLine(tabRect.X,tabRect.Y,tabRect.Right,tabRect.Y);
						path.AddLine(tabRect.Right,tabRect.Y,tabRect.Right,tabRect.Bottom-2);
                        path.AddLine(tabRect.Right-2,tabRect.Bottom,tabRect.X+2,tabRect.Bottom);
						path.AddLine(tabRect.X,tabRect.Bottom-2,tabRect.X,tabRect.Y);
						path.CloseAllFigures();
						break;
					}
					case eTabStripAlignment.Left:
					{
                        tabRect.Height--;
						path.AddLine(tabRect.X+2,tabRect.Y,tabRect.Right,tabRect.Y);
						path.AddLine(tabRect.Right,tabRect.Bottom,tabRect.X+2,tabRect.Bottom);
						path.AddLine(tabRect.X,tabRect.Bottom-2,tabRect.X,tabRect.Y+2);
						path.CloseAllFigures();
						break;
					}
					case eTabStripAlignment.Right:
					{
                        tabRect.Height--;
						tabRect.Width-=2;
						path.AddLine(tabRect.X,tabRect.Y,tabRect.Right-2,tabRect.Y);
						path.AddLine(tabRect.Right,tabRect.Y+2,tabRect.Right,tabRect.Bottom-2);
						path.AddLine(tabRect.Right-2,tabRect.Bottom,tabRect.X,tabRect.Bottom);
						path.CloseAllFigures();
						break;
					}
				}

				// Draw Background
				//g.SetClip(rClip);
				if(colors.BackColor2.IsEmpty)
				{
					if(!colors.BackColor.IsEmpty)
					{
						using(SolidBrush brush=new SolidBrush(colors.BackColor))
							g.FillPath(brush,path);
					}
				}
				else
				{
					using(LinearGradientBrush brush=BarFunctions.CreateLinearGradientBrush(tabRect,colors.BackColor,colors.BackColor2,colors.BackColorGradientAngle))
						g.FillPath(brush,path);
				}
				//g.SetClip(rClip);

				// Draw border
				if(!colors.BorderColor.IsEmpty)
				{
					using(Pen pen=new Pen(colors.BorderColor,1))
						g.DrawPath(pen,path);
				}

                if (m_CloseButtonOnTabs && tab.CloseButtonVisible)
                    tab.CloseButtonBounds = PaintTabItemCloseButton(g, (m_Alignment == eTabStripAlignment.Left || m_Alignment == eTabStripAlignment.Right), tab.CloseButtonMouseOver, tab == m_HotTab || tab == this.SelectedTab, ref tabRect);
                else
                    tab.CloseButtonBounds = Rectangle.Empty;
				// Draw image
				CompositeImage image=this.GetTabImage(tab);
				if(image!=null && image.Width+4<=tabRect.Width)
				{
					if(m_Alignment==eTabStripAlignment.Top || m_Alignment==eTabStripAlignment.Bottom)
					{
						image.DrawImage(g,new Rectangle(tabRect.X+3,tabRect.Y+(tabRect.Height-image.Height)/2,image.Width,image.Height));
						int offset=image.Width+2;
						tabRect.X+=offset;
						tabRect.Width-=offset;
					}
					else
					{
						image.DrawImage(g,new Rectangle(tabRect.X+(tabRect.Width-image.Width)/2,tabRect.Y+3,image.Width,image.Height));
						int offset=image.Height+2;
						tabRect.Y+=offset;
						tabRect.Height-=offset;
					}
				}

				// Draw text
				if(!m_DisplaySelectedTextOnly || tab==m_SelectedTab)
				{
					Font font=this.Font;
					if(tab==selected && m_SelectedTabFont!=null)
						font=m_SelectedTabFont;

					Rectangle rText=tabRect;
					if(m_Alignment==eTabStripAlignment.Left || m_Alignment==eTabStripAlignment.Right)
					{
						g.RotateTransform(90);
						rText=new Rectangle(rText.Top,-rText.Right,rText.Height,rText.Width);
					}

					if(rText.Width>MIN_TEXT_WIDTH)
					{
                        if (m_Alignment == eTabStripAlignment.Left || m_Alignment == eTabStripAlignment.Right)
                            TextDrawing.DrawStringLegacy(g, tab.Text, font, colors.TextColor, rText, strFormat);
                        else
                            TextDrawing.DrawString(g,tab.Text,font,colors.TextColor,rText,strFormat);
					}

					if(m_Alignment==eTabStripAlignment.Left || m_Alignment==eTabStripAlignment.Right)
						g.ResetTransform();

					if(m_ShowFocusRectangle && this.Focused && tab==selected)
						ControlPaint.DrawFocusRectangle(g,GetFocusRectangle(tabRect));
				}

                // Draw tab separator line
                if (!tab.IsSelected && m_Tabs.IndexOf(tab) < m_Tabs.Count - 1 && m_Tabs.IndexOf(tab) + 1!=m_Tabs.IndexOf(m_SelectedTab))
                {
                    if (m_Alignment == eTabStripAlignment.Left || m_Alignment == eTabStripAlignment.Right)
                    {
                        DisplayHelp.DrawLine(g, tab.DisplayRectangle.X + 3, tab.DisplayRectangle.Bottom - 1, tab.DisplayRectangle.Right - 3, tab.DisplayRectangle.Bottom - 1, m_ColorScheme.TabItemSeparator, 1);
                        DisplayHelp.DrawLine(g, tab.DisplayRectangle.X + 3, tab.DisplayRectangle.Bottom, tab.DisplayRectangle.Right - 3, tab.DisplayRectangle.Bottom, m_ColorScheme.TabItemSeparatorShade, 1);
                    }
                    else
                    {
                        DisplayHelp.DrawLine(g, tab.DisplayRectangle.Right - 1, tab.DisplayRectangle.Y + 3, tab.DisplayRectangle.Right - 1, tab.DisplayRectangle.Bottom - 3, m_ColorScheme.TabItemSeparator, 1);
                        DisplayHelp.DrawLine(g, tab.DisplayRectangle.Right, tab.DisplayRectangle.Y + 3, tab.DisplayRectangle.Right, tab.DisplayRectangle.Bottom - 3, m_ColorScheme.TabItemSeparatorShade, 1);
                    }
                    
                }

                if (HasPostRenderTabItem)
                {
                    RenderTabItemEventArgs re = new RenderTabItemEventArgs(tab, g);
                    InvokePostRenderTabItem(re);
                }
			}

			g.ResetClip();
			if(this.HasNavigationBox && m_TabSystemBox.Visible)
			{
				g.SetClip(m_TabSystemBox.DisplayRectangle);
				using(SolidBrush brushSysBox=new SolidBrush(m_ColorScheme.TabBackground))
					g.FillRectangle(brushSysBox,m_TabSystemBox.DisplayRectangle);
				m_TabSystemBox.Paint(g);
				g.ResetClip();
			}
		}
コード例 #5
0
		private void PaintThemed(Graphics g)
		{
			if(m_ThemeTab==null)
				this.RefreshThemes();
			
			if(m_ColorScheme.TabBackground.IsEmpty)
				m_ThemeTab.DrawBackground(g,ThemeTabParts.Body,ThemeTabStates.BodyNormal,this.ClientRectangle);
			else if(!m_ColorScheme.TabBackground2.IsEmpty && this.Width>0 && this.Height>0)
			{
				using(LinearGradientBrush gradient=BarFunctions.CreateLinearGradientBrush(this.ClientRectangle,m_ColorScheme.TabBackground,m_ColorScheme.TabBackground2,m_ColorScheme.TabBackgroundGradientAngle))
					g.FillRectangle(gradient,this.ClientRectangle);
			}
			else
			{
				using(SolidBrush brush=new SolidBrush(m_ColorScheme.TabBackground))
					g.FillRectangle(brush,this.DisplayRectangle);
				//g.Clear(m_ColorScheme.TabBackground);
			}

			Rectangle r=this.GetTabClientArea(this.DisplayRectangle,false,false); //this.DisplayRectangle;

			// Text format
			TabItem selected=this.SelectedTab;
            eTextFormat strFormat = eTextFormat.Default | eTextFormat.SingleLine |
                eTextFormat.EndEllipsis | eTextFormat.VerticalCenter | eTextFormat.HorizontalCenter;

			if(m_NeedRecalcSize)
				RecalcSize(g,r);

			// Draw tab base line
			if(this.Parent is TabControl)
			{
				if(m_Alignment==eTabStripAlignment.Top)
					m_ThemeTab.DrawBackground(g,ThemeTabParts.Pane,ThemeTabStates.PaneNormal,new Rectangle(0,r.Bottom,ClientRectangle.Width,ClientRectangle.Height));
				else
				{
					Size sz=new Size(this.Width,5);
					if(m_Alignment==eTabStripAlignment.Left || m_Alignment==eTabStripAlignment.Right)
						sz=new Size(this.Height,5);
					Bitmap bmp=new Bitmap(sz.Width,sz.Height,g);
					try
					{
						Graphics gtmp=Graphics.FromImage(bmp);
						try
						{
							m_ThemeTab.DrawBackground(gtmp,ThemeTabParts.Pane,ThemeTabStates.PaneNormal,new Rectangle(0,0,sz.Width,sz.Height));
						}
						finally
						{
							gtmp.Dispose();
						}
						if(m_Alignment==eTabStripAlignment.Left)
						{
							bmp.RotateFlip(RotateFlipType.Rotate270FlipNone);
							g.DrawImageUnscaled(bmp,r.Right,0);
						}
						else if(m_Alignment==eTabStripAlignment.Right)
						{
							bmp.RotateFlip(RotateFlipType.Rotate90FlipNone);
							g.DrawImageUnscaled(bmp,r.X-bmp.Width,0);
						}
						else if(m_Alignment==eTabStripAlignment.Bottom)
						{
							bmp.RotateFlip(RotateFlipType.Rotate180FlipNone);
							g.DrawImageUnscaled(bmp,0,r.Y-bmp.Height);
						}
					}
					finally
					{
						bmp.Dispose();
					}
				}
			}

			if(m_Alignment==eTabStripAlignment.Top)
				r.Height++;
			Rectangle rClip=r;
			if(m_Alignment==eTabStripAlignment.Bottom)
			{
				rClip.Y--;
				rClip.Height++;
			}
			else if(m_Alignment==eTabStripAlignment.Left)
			{
				rClip.Width++;
			}
			else if(m_Alignment==eTabStripAlignment.Right)
			{
				rClip.X--;
				rClip.Width++;
			}
			if(this.HasNavigationBox)
			{
				if(m_Alignment==eTabStripAlignment.Right || m_Alignment==eTabStripAlignment.Left)
					rClip.Height-=m_TabSystemBox.DisplayRectangle.Height;
				else
					rClip.Width-=m_TabSystemBox.DisplayRectangle.Width;
			}
			g.SetClip(rClip);

			foreach(TabItem tab in m_Tabs)
			{
				if(!tab.Visible || !r.IntersectsWith(tab.DisplayRectangle))
					continue;

                if (HasPreRenderTabItem)
                {
                    RenderTabItemEventArgs re = new RenderTabItemEventArgs(tab, g);
                    InvokePreRenderTabItem(re);
                    if (re.Cancel) continue;
                }
				
				Rectangle tabRect=tab.DisplayRectangle;
				Rectangle rTemp=new Rectangle(0,0,tabRect.Width,tabRect.Height);
				if(m_Alignment==eTabStripAlignment.Left || m_Alignment==eTabStripAlignment.Right)
					rTemp=new Rectangle(0,0,tabRect.Height,tabRect.Width);
				if(tab==selected)
				{
					if(m_Alignment==eTabStripAlignment.Top)
						rTemp.Height+=2;
					else if(m_Alignment==eTabStripAlignment.Bottom)
					{
						rTemp.Height+=2;
						tabRect.Y--;
					}
					else if(m_Alignment==eTabStripAlignment.Left)
					{
						rTemp.Height+=2;
						tabRect.X--;
					}
					else if(m_Alignment==eTabStripAlignment.Right)
					{
						rTemp.Height+=2;
						tabRect.X--;
					}
				}

				Bitmap temp=new Bitmap(rTemp.Width,rTemp.Height,g);
				try
				{
					Graphics gtemp=Graphics.FromImage(temp);
					try
					{
						using(SolidBrush brush=new SolidBrush(Color.Transparent))
							gtemp.FillRectangle(brush,0,0,temp.Width,temp.Height);
						//gtemp.Clear(Color.Transparent);
						if(m_Alignment==eTabStripAlignment.Bottom)
						{
							DrawThemedTab(gtemp,rTemp,tab,strFormat,rTemp,true,false);
							temp.RotateFlip(RotateFlipType.Rotate180FlipNone);
							DrawThemedTab(gtemp,rTemp,tab,strFormat,rTemp,false,true);
						}
						else
							DrawThemedTab(gtemp,rTemp,tab,strFormat,rTemp,true,true);
					}
					finally
					{
						gtemp.Dispose();
					}
				}
				finally
				{
					if(m_Alignment==eTabStripAlignment.Left)
						temp.RotateFlip(RotateFlipType.Rotate270FlipNone);
					else if(m_Alignment==eTabStripAlignment.Right)
                        temp.RotateFlip(RotateFlipType.Rotate90FlipNone);

					g.DrawImageUnscaled(temp,tabRect);
					temp.Dispose();
				}

                if (HasPostRenderTabItem)
                {
                    RenderTabItemEventArgs re = new RenderTabItemEventArgs(tab, g);
                    InvokePostRenderTabItem(re);
                }
			}
			g.ResetClip();
			if(this.HasNavigationBox && m_TabSystemBox.Visible)
			{
				g.SetClip(m_TabSystemBox.DisplayRectangle);
				using(SolidBrush brushSysBox=new SolidBrush(m_ColorScheme.TabBackground))
					g.FillRectangle(brushSysBox,m_TabSystemBox.DisplayRectangle);
				m_TabSystemBox.Paint(g);
				g.ResetClip();
			}

		}
コード例 #6
0
		private void PaintOneNote(Graphics g)
		{
			// Fill tab background color
			Rectangle r=GetTabClientArea(this.DisplayRectangle,false,false);
			//Rectangle rSysBox=Rectangle.Empty;

			if(m_NeedRecalcSize)
			{
				RecalcSize(g,GetTabClientArea(this.DisplayRectangle,false,false));
			}

			if(!m_ColorScheme.TabBackground2.IsEmpty && this.Height>0 && this.Width>0)
			{
				int gradientAngle=m_ColorScheme.TabBackgroundGradientAngle;
				if(m_Alignment==eTabStripAlignment.Bottom)
					gradientAngle-=180;
				else if(m_Alignment==eTabStripAlignment.Left)
					gradientAngle-=90;
				else if(m_Alignment==eTabStripAlignment.Right)
					gradientAngle+=90;

				using(LinearGradientBrush gradient=BarFunctions.CreateLinearGradientBrush(this.DisplayRectangle,m_ColorScheme.TabBackground,m_ColorScheme.TabBackground2,gradientAngle))
					g.FillRectangle(gradient,this.DisplayRectangle);
			}
			else
			{
				using(SolidBrush brush=new SolidBrush(m_ColorScheme.TabBackground))
					g.FillRectangle(brush,this.DisplayRectangle);
				//g.Clear(m_ColorScheme.TabBackground);
			}

			if(!m_ColorScheme.TabBorder.IsEmpty)
			{
				using(Pen pen=new Pen(m_ColorScheme.TabBorder,1))
					g.DrawRectangle(pen,this.DisplayRectangle);
			}

			// Set text format
			TabItem selected=this.SelectedTab;
            eTextFormat strFormat = eTextFormat.Default | eTextFormat.EndEllipsis | eTextFormat.SingleLine |
                eTextFormat.HorizontalCenter | eTextFormat.VerticalCenter;

			// Draw the upper back line
			Rectangle backArea=this.GetBackgroundArea(this.DisplayRectangle);
			Color backAreaColor=(m_ColorScheme.TabItemSelectedBackground2.IsEmpty?m_ColorScheme.TabItemSelectedBackground:m_ColorScheme.TabItemSelectedBackground2);
			if(selected!=null && selected.PredefinedColor!=eTabItemColor.Default && !selected.BackColor2.IsEmpty)
				backAreaColor=selected.BackColor2;
			switch(m_Alignment)
			{
				case eTabStripAlignment.Top:
				{
					using(SolidBrush brush=new SolidBrush(backAreaColor))
						g.FillRectangle(brush,backArea.X,backArea.Bottom,backArea.Width,this.Height-r.Bottom);
					if(selected!=null)
					{
						using(Pen pen=new Pen(m_ColorScheme.TabItemSelectedBorder,1))
						{
							//RectangleF rs=this.GetTabPath(selected.DisplayRectangle,2,m_Alignment,false).GetBounds();
							Rectangle rs=selected.DisplayRectangle;
							rs.Width+=rs.Height;
							rs.X-=(rs.Height-1);
							if(this.HasNavigationBox && rs.Right>m_TabSystemBox.DisplayRectangle.X)
								rs.Width-=(rs.Right-m_TabSystemBox.DisplayRectangle.X+2);

							g.DrawLine(pen,backArea.X,backArea.Bottom,rs.X-1,backArea.Bottom);
							g.DrawLine(pen,rs.Right+1,backArea.Bottom,backArea.Right,backArea.Bottom);
							if(this.Parent is TabControl)
							{
								g.DrawLine(pen,backArea.X,backArea.Bottom,backArea.X,this.ClientRectangle.Bottom);
								g.DrawLine(pen,backArea.Right-1,backArea.Bottom,backArea.Right-1,this.ClientRectangle.Bottom);
							}
						}
					}
					break;
				}
				case eTabStripAlignment.Left:
				{
					using(SolidBrush brush=new SolidBrush(backAreaColor))
						g.FillRectangle(brush,backArea.Right,backArea.Y,this.Width-backArea.Width,this.Height);
					using(Pen pen=new Pen(m_ColorScheme.TabItemSelectedBorder,1))
					{
						g.DrawLine(pen,backArea.Right-1,backArea.Y,backArea.Right-1,backArea.Bottom);
						if(this.Parent is TabControl)
						{
							g.DrawLine(pen,backArea.Right-1,backArea.Y,this.ClientRectangle.Right,backArea.Y);
                            g.DrawLine(pen,backArea.Right-1,backArea.Bottom-1,this.ClientRectangle.Right,backArea.Bottom-1);
						}
					}
					break;
				}
				case eTabStripAlignment.Right:
				{
					using(SolidBrush brush=new SolidBrush(backAreaColor))
						g.FillRectangle(brush,0,0,this.Width-backArea.Width,this.Height);

					using(Pen pen=new Pen(m_ColorScheme.TabItemSelectedBorder,1))
					{
						g.DrawLine(pen,backArea.X,backArea.Y,backArea.X,backArea.Bottom);
						if(this.Parent is TabControl)
						{
							g.DrawLine(pen,backArea.X,backArea.Y,0,backArea.Y);
							g.DrawLine(pen,backArea.X,backArea.Bottom-1,0,backArea.Bottom-1);
						}
					}
					break;
				}
				default:
				{
					using(SolidBrush brush=new SolidBrush(backAreaColor))
						g.FillRectangle(brush,backArea.X,0,backArea.Width,backArea.Y);
					using(Pen pen=new Pen(m_ColorScheme.TabItemSelectedBorder,1))
					{
						g.DrawLine(pen,backArea.X,backArea.Y,backArea.Right,backArea.Y);
						if(this.Parent is TabControl)
						{
							g.DrawLine(pen,backArea.X,backArea.Y,backArea.X,0);
							g.DrawLine(pen,backArea.Right-1,backArea.Y,backArea.Right-1,0);
						}
					}
					break;
				}
			}

			r=GetTabClientArea(this.DisplayRectangle,m_TabSystemBox.Visible,true);
			Rectangle rClip=r;
			g.SetClip(r);

			bool bVirstVisible=true;
			bool bContinue=(m_Tabs.Count>0);

			// Bi-directional loop
			int iIndex=0;
            bool reverseLoop = false;
            if (m_Alignment == eTabStripAlignment.Left ||
                (this.IsRightToLeft && (m_Alignment == eTabStripAlignment.Top || m_Alignment == eTabStripAlignment.Bottom)))
            {
                iIndex = m_Tabs.Count - 1;
                reverseLoop = true;
            }
			int iMultiLineSwitch=-1;
			while(bContinue)
			{
				TabItem tab=m_Tabs[iIndex];
                if (reverseLoop)
				{
					iIndex--;
					if(iIndex<0) bContinue=false;
				}
				else
				{
					iIndex++;
					if(iIndex>=m_Tabs.Count) bContinue=false;
				}

				if(!tab.Visible || !r.IntersectsWith(tab.DisplayRectangle))
					continue;

                if (HasPreRenderTabItem)
                {
                    RenderTabItemEventArgs re = new RenderTabItemEventArgs(tab, g);
                    InvokePreRenderTabItem(re);
                    if (re.Cancel) continue;
                }

				TabColors tabColors=this.GetTabColors(tab);
				Rectangle tabRect=tab.DisplayRectangle;
				if(m_Alignment==eTabStripAlignment.Right)
					tabRect.Height--;
				if(m_Alignment==eTabStripAlignment.Left || m_Alignment==eTabStripAlignment.Right)
				{
					if(iMultiLineSwitch==-1)
						iMultiLineSwitch=tab.DisplayRectangle.X;
					if(iMultiLineSwitch!=tab.DisplayRectangle.X)
					{
						iMultiLineSwitch=tab.DisplayRectangle.X;
						bVirstVisible=true;
					}
					GraphicsPath path=this.GetTabPath(tabRect,2,m_Alignment,true);
					Region clip=g.Clip;
					
					if(bVirstVisible || tab==m_SelectedTab)
					{
						RectangleF pb=path.GetBounds();
						pb.Width++;
						if(m_Alignment==eTabStripAlignment.Left)
						{
							//pb.Width--;
							if(bVirstVisible && tab!=m_SelectedTab)
								pb.Width--;
						}
						else
						{
							pb.Height++;
							if(bVirstVisible && tab!=m_SelectedTab)	pb.X++;
						}
						g.SetClip(pb);
					}
					else
					{
						if(m_Alignment==eTabStripAlignment.Right)
							g.SetClip(new Rectangle(tabRect.X+1,tabRect.Y+1,tabRect.Width+1,tabRect.Height+1));
						else
							g.SetClip(new Rectangle(tabRect.X,tabRect.Y,tabRect.Width-1,tabRect.Height));
					}
					ClipExcludeSystemBox(g);

                    if (tabColors.BackColor2.IsEmpty)
                    {
                        using (SolidBrush brush = new SolidBrush(tabColors.BackColor))
                            g.FillPath(brush, path);
                    }
                    else
                    {
                        using (LinearGradientBrush brush = BarFunctions.CreateLinearGradientBrush(path.GetBounds(), tabColors.BackColor, tabColors.BackColor2, (m_Alignment == eTabStripAlignment.Left ? tabColors.BackColorGradientAngle - 90 : tabColors.BackColorGradientAngle + 90)))
                            g.FillPath(brush, path);
                    }

					path=this.GetTabPath(tabRect,2,m_Alignment,false);
					using(Pen pen=new Pen(tabColors.BorderColor,1))
						g.DrawPath(pen,path);

					if(m_TabSystemBox.Visible && this.HasNavigationBox && path.GetBounds().IntersectsWith(m_TabSystemBox.DisplayRectangle))
					{
						Region reg=new Region(path);
						reg.Intersect(m_TabSystemBox.DisplayRectangle);
						RectangleF rg=reg.GetBounds(g);
						reg.Dispose();
						using(Pen pen=new Pen(tabColors.BorderColor,1))
						{
							pen.DashPattern=new float[] {2,2}; 
							g.DrawLine(pen,rg.X,rg.Y-1,rg.Right,rg.Y-1);
							g.DrawLine(pen,rg.X+2,rg.Y-2,rg.Right,rg.Y-2);
						}
					}
					else if(path.GetBounds().Y<-1 && path.GetBounds().Bottom>0)
					{
						RectangleF rg=path.GetBounds();
						using(Pen pen=new Pen(tabColors.BorderColor,1))
						{
							pen.DashPattern=new float[] {2,2}; 
							g.DrawLine(pen,rg.X,0,rg.Right,0);
							g.DrawLine(pen,rg.X+2,1,rg.Right,1);
						}
					}

					Rectangle rh=tabRect;
					if(m_Alignment==eTabStripAlignment.Right)
					{
						rh.Offset(-1,0);
						rh.Height-=1;
					}
					else
					{
						rh.Offset(1,0);
						rh.Height-=1;
						rh.Y++;
					}
					path=GetTabPath(rh,1,m_Alignment,false);
					
					using(Pen pen=new Pen(tabColors.LightBorderColor,1))
						g.DrawPath(pen,path);
					if(!tabColors.DarkBorderColor.IsEmpty)
					{
						RectangleF darkBounds=path.GetBounds();
						if(m_Alignment==eTabStripAlignment.Right)
						{
							darkBounds.Y=darkBounds.Bottom-1;
							darkBounds.Height=2;
							//darkBounds.Width--;
						}
						else
						{
							darkBounds.Height=2;
							darkBounds.Width-=2;
						}
						g.SetClip(darkBounds);
						ClipExcludeSystemBox(g);
						using(Pen pen=new Pen(tabColors.DarkBorderColor,1))
							g.DrawPath(pen,path);
					}

					g.SetClip(clip,CombineMode.Replace);

                    if (m_CloseButtonOnTabs && tab.CloseButtonVisible)
                    {
                        tabRect.Y += 3;
                        tabRect.Height -= 3;
                        tab.CloseButtonBounds = PaintTabItemCloseButton(g, true, tab.CloseButtonMouseOver, tab == m_HotTab || tab == this.SelectedTab, ref tabRect);
                    }
                    else
                        tab.CloseButtonBounds = Rectangle.Empty;

					Image tabImage=tab.GetImage();
					Icon icon=tab.Icon;
					if(icon!=null)
					{
						Rectangle rIcon=new Rectangle(tabRect.X+(tabRect.Width-tab.IconSize.Width)/2,tabRect.Y+6,tab.IconSize.Width,tab.IconSize.Height);
						if(rClip.Contains(rIcon))
							g.DrawIcon(icon,rIcon);
						tabRect.Y+=(tab.IconSize.Height+2);
						tabRect.Height-=(tab.IconSize.Height+2);
					}
					else if(tabImage!=null)
					{
						g.DrawImage(tabImage,tabRect.X+(tabRect.Width-tabImage.Width)/2,tabRect.Y+6,tabImage.Width,tabImage.Height);
						tabRect.Y+=(tabImage.Height+2);
						tabRect.Height-=(tabImage.Height+2);
					}
					tabRect.Inflate(0,-1);
					tabRect.Height-=4;
					if(m_Style==eTabStripStyle.OneNote)
						tabRect.Y+=3;

					g.RotateTransform(90);
					if(!m_DisplaySelectedTextOnly || tab==m_SelectedTab)
					{
						Font font=this.Font;
						if(tab==selected)
						{
							if(m_SelectedTabFont!=null)
								font=m_SelectedTabFont;
						}
						if(tab!=selected)
						{
							Rectangle rText=new Rectangle(tabRect.Top,-tabRect.Right,tabRect.Height,tabRect.Width);
							if(rText.Height>MIN_TEXT_WIDTH)
                                TextDrawing.DrawStringLegacy(g, tab.Text, font, tabColors.TextColor, rText, strFormat);
							if(m_ShowFocusRectangle && this.Focused && tab==m_SelectedTab)
								ControlPaint.DrawFocusRectangle(g,GetFocusRectangle(rText));
						}
						else
						{
							Rectangle rText=new Rectangle(tabRect.Top,-tabRect.Right,tabRect.Height,tabRect.Width);
							if(rText.Height>MIN_TEXT_WIDTH)
                                TextDrawing.DrawStringLegacy(g, tab.Text, font, tabColors.TextColor, rText, strFormat);
							if(m_ShowFocusRectangle && this.Focused && tab==m_SelectedTab)
								ControlPaint.DrawFocusRectangle(g,GetFocusRectangle(rText));
						}
						g.ResetTransform();
					}
					// Draw separator
					if(tab!=selected)
					{
						g.DrawLine(new Pen(m_SeparatorColor,1),tab.DisplayRectangle.X+1,tab.DisplayRectangle.Bottom,tab.DisplayRectangle.Right-4,tab.DisplayRectangle.Bottom);
						if(!m_SeparatorShadeColor.IsEmpty)
							g.DrawLine(new Pen(m_SeparatorShadeColor,1),tab.DisplayRectangle.X+1+1,tab.DisplayRectangle.Bottom+1,tab.DisplayRectangle.Right-4+1,tab.DisplayRectangle.Bottom+1);
					}
				}
				else
				{
					if(iMultiLineSwitch==-1)
						iMultiLineSwitch=tab.DisplayRectangle.Y;
					if(iMultiLineSwitch!=tab.DisplayRectangle.Y)
					{
						iMultiLineSwitch=tab.DisplayRectangle.Y;
						bVirstVisible=true;
					}

					GraphicsPath path=this.GetTabPath(tabRect,2,m_Alignment,true);
					Region clip=g.Clip;
					
					if(bVirstVisible || tab==m_SelectedTab)
					{
						//RectangleF pb=path.GetBounds();
						Rectangle pb=tabRect;
						pb.Width+=pb.Height;
						//if(m_Alignment!=eTabStripAlignment.Bottom)
							pb.X-=pb.Height;
						
						pb.Width++;
                        pb.Height++;
                        if (m_Alignment == eTabStripAlignment.Bottom && bVirstVisible && tab != m_SelectedTab)
                            pb.Y++;
                        
						g.SetClip(pb,CombineMode.Replace);
					}
					else
					{
						if(m_Alignment==eTabStripAlignment.Top)
							g.SetClip(new Rectangle(tabRect.X+1,tabRect.Y,tabRect.Width+1,tabRect.Height),CombineMode.Replace);
						else
                            g.SetClip(new Rectangle(tabRect.X + 1, tabRect.Y+1, tabRect.Width + 1, tabRect.Height+1), CombineMode.Replace);
					}
					ClipExcludeSystemBox(g);

                    if (tabColors.BackColor2.IsEmpty)
                    {
                        using (SolidBrush brush = new SolidBrush(tabColors.BackColor))
                            g.FillPath(brush, path);
                    }
                    else
                    {
                        using (LinearGradientBrush brush = BarFunctions.CreateLinearGradientBrush(path.GetBounds(), tabColors.BackColor, tabColors.BackColor2, (m_Alignment == eTabStripAlignment.Top ? tabColors.BackColorGradientAngle : -tabColors.BackColorGradientAngle)))
                            g.FillPath(brush, path);
                    }

					path=this.GetTabPath(tabRect,2,m_Alignment,false);
					using(Pen pen=new Pen(tabColors.BorderColor,1))
						g.DrawPath(pen,path);

					if(m_TabSystemBox.Visible && this.HasNavigationBox && path.GetBounds().IntersectsWith(m_TabSystemBox.DisplayRectangle))
					{
						Region reg=new Region(path);
						reg.Intersect(m_TabSystemBox.DisplayRectangle);
						RectangleF rg=reg.GetBounds(g);
						reg.Dispose();
						using(Pen pen=new Pen(tabColors.BorderColor,1))
						{
							pen.DashPattern=new float[] {2,2}; 
							g.DrawLine(pen,rg.X-1,rg.Y,rg.X-1,rg.Bottom);
							g.DrawLine(pen,rg.X-2,rg.Y+2,rg.X-2,rg.Bottom);
						}
					}
					else if(path.GetBounds().X<-1 && path.GetBounds().Right>0)
					{
						RectangleF rg=path.GetBounds();
						using(Pen pen=new Pen(tabColors.BorderColor,1))
						{
							pen.DashPattern=new float[] {2,2}; 
							g.DrawLine(pen,0,rg.Y,0,rg.Bottom);
							g.DrawLine(pen,1,rg.Y+2,1,rg.Bottom);
						}
					}
                    
					Rectangle rh=tabRect;
					if(m_Alignment==eTabStripAlignment.Top)
					{
						rh.Offset(1,1);
						rh.X-=1;
						rh.Width-=1;
					}
                    else
                    {
                        rh.Offset(1, -1);
                        rh.X -= 1;
                        rh.Width -= 1;
                    }
					path=GetTabPath(rh,1,m_Alignment,false);

                    if (!tabColors.LightBorderColor.IsEmpty)
                    {
                        RectangleF lightBounds = path.GetBounds();
                        lightBounds.Height--;
                        Region oldClip = g.Clip.Clone() as Region;
                        g.SetClip(lightBounds, CombineMode.Intersect);

                        using (Pen pen = new Pen(tabColors.LightBorderColor, 1))
                            g.DrawPath(pen, path);

                        g.SetClip(oldClip, CombineMode.Replace);
                    }
					
					if(!tabColors.DarkBorderColor.IsEmpty)
					{
						RectangleF darkBounds=path.GetBounds();
						darkBounds.X=darkBounds.Right-1;
						darkBounds.Width=2;
						darkBounds.Height--;

                        g.SetClip(clip,CombineMode.Replace);
						g.SetClip(darkBounds,CombineMode.Intersect);
						using(Pen pen=new Pen(tabColors.DarkBorderColor,1))
							g.DrawPath(pen,path);
					}

					g.SetClip(clip,CombineMode.Replace);

					//if(m_Alignment==eTabStripAlignment.Top)
						tabRect.Offset(0,1);

                    if (m_CloseButtonOnTabs && tab.CloseButtonVisible)
                        tab.CloseButtonBounds = this.PaintTabItemCloseButton(g, false, tab.CloseButtonMouseOver, tab == m_HotTab || tab == this.SelectedTab, ref tabRect);
                    else
                        tab.CloseButtonBounds = Rectangle.Empty;

					Image tabImage=tab.GetImage();
					Icon icon=tab.Icon;
					if(icon!=null)
					{
						Rectangle rIcon=new Rectangle(tabRect.X+tabRect.Height/3+(m_Alignment==eTabStripAlignment.Top?-2:0),tabRect.Y+(tabRect.Height-tab.IconSize.Height)/2,tab.IconSize.Width,tab.IconSize.Height);
						if(rClip.Contains(rIcon))
							g.DrawIcon(icon,rIcon);
						tabRect.X+=(tab.IconSize.Width+2);
						tabRect.Width-=(tab.IconSize.Width+2);
					}
					else if(tabImage!=null)
					{
						g.DrawImage(tabImage,tabRect.X+tabRect.Height/3+(m_Alignment==eTabStripAlignment.Top?-2:0),tabRect.Y+(tabRect.Height-tabImage.Height)/2,tabImage.Width,tabImage.Height);
						tabRect.X+=(tabImage.Width+2);
						tabRect.Width-=(tabImage.Width+2);
					}
					tabRect.Inflate(0,-1);

					tabRect.Width-=4;
					if(m_Style==eTabStripStyle.OneNote)
						tabRect.X+=3;

					if(!m_DisplaySelectedTextOnly || tab==m_SelectedTab)
					{
						Font font=this.Font;
						if(tab==selected && m_SelectedTabFont!=null)
							font=m_SelectedTabFont;

						if(tab!=selected)
						{
							if(tabRect.Width>MIN_TEXT_WIDTH)
								TextDrawing.DrawString(g,tab.Text,font,tabColors.TextColor,tabRect,strFormat);
							if(m_ShowFocusRectangle && this.Focused && tab==m_SelectedTab)
								ControlPaint.DrawFocusRectangle(g,GetFocusRectangle(tabRect));
						}
						else
						{
							if(tabRect.Width>MIN_TEXT_WIDTH)
								TextDrawing.DrawString(g,tab.Text,font,tabColors.TextColor,tabRect,strFormat);
							if(m_ShowFocusRectangle && this.Focused && tab==m_SelectedTab)
								ControlPaint.DrawFocusRectangle(g,GetFocusRectangle(tabRect));
						}
					}	                    
				}
                if (HasPostRenderTabItem)
                {
                    RenderTabItemEventArgs re = new RenderTabItemEventArgs(tab, g);
                    InvokePostRenderTabItem(re);
                }
				bVirstVisible=false;
			}

			g.ResetClip();
			if(this.HasNavigationBox && m_TabSystemBox.Visible)
			{
				m_TabSystemBox.Paint(g);
			}
		}