Example #1
0
        protected override void DrawBackground(TabStrip tabStrip, Rectangle tabStripRect, Graphics g, TabColorScheme colors, Region tabsRegion, eTabStripAlignment tabAlignment, Rectangle selectedTabRect)
        {
            base.DrawBackground(tabStrip, tabStripRect, g, colors, tabsRegion, tabAlignment, selectedTabRect);

            SmoothingMode sm = g.SmoothingMode;
            g.SmoothingMode = SmoothingMode.Default;
            if (!colors.TabItemBorder.IsEmpty)
            {
                using (Pen pen = new Pen(colors.TabItemBorder, 1))
                {
                    if (tabAlignment == eTabStripAlignment.Top)
                    {
                        if (selectedTabRect.X > tabStripRect.Right)
                            selectedTabRect = Rectangle.Empty;
                        Rectangle r = new Rectangle(tabStripRect.X, tabStripRect.Bottom - 1, tabStripRect.Width, 2);
                        DisplayHelp.FillRectangle(g, r, colors.TabItemBackground, Color.Empty);
                        g.DrawLine(pen, r.X, r.Y, selectedTabRect.X - 1, r.Y);
                        g.DrawLine(pen, selectedTabRect.Right, r.Y, r.Right, r.Y);
                        g.DrawLine(pen, r.X, r.Y, r.X, r.Bottom);
                        g.DrawLine(pen, r.Right - 1, r.Y, r.Right - 1, r.Bottom);
                    }
                    else if (tabAlignment == eTabStripAlignment.Bottom)
                    {
                        if (selectedTabRect.X > tabStripRect.Right)
                            selectedTabRect = Rectangle.Empty;
                        Rectangle r = new Rectangle(tabStripRect.X, tabStripRect.Y, tabStripRect.Width, 1);
                        DisplayHelp.FillRectangle(g, r, colors.TabItemBackground, Color.Empty);
                        g.DrawLine(pen, r.X, r.Bottom - 1, selectedTabRect.X - 1, r.Bottom - 1);
                        g.DrawLine(pen, selectedTabRect.Right, r.Bottom - 1, r.Right, r.Bottom - 1);
                        g.DrawLine(pen, r.X, r.Y, r.X, r.Bottom - 1);
                        g.DrawLine(pen, r.Right - 1, r.Y, r.Right - 1, r.Bottom - 1);
                    }
                    else if (tabAlignment == eTabStripAlignment.Left)
                    {
                        if (selectedTabRect.Y > tabStripRect.Bottom)
                            selectedTabRect = Rectangle.Empty;
                        Rectangle r = new Rectangle(tabStripRect.Right - 1, tabStripRect.Y, 1, tabStripRect.Height);
                        DisplayHelp.FillRectangle(g, r, colors.TabItemBackground, Color.Empty);
                        g.DrawLine(pen, r.X, r.Y, r.X, selectedTabRect.Y - 1);
                        g.DrawLine(pen, r.X, selectedTabRect.Bottom, r.X, r.Bottom);
                        g.DrawLine(pen, r.X, r.Y, r.Right, r.Y);
                        g.DrawLine(pen, r.X, r.Bottom - 1, r.Right, r.Bottom - 1);
                    }
                    else if (tabAlignment == eTabStripAlignment.Right)
                    {
                        if (selectedTabRect.Y > tabStripRect.Bottom)
                            selectedTabRect = Rectangle.Empty;
                        Rectangle r = new Rectangle(tabStripRect.X, tabStripRect.Y, 1, tabStripRect.Height);
                        DisplayHelp.FillRectangle(g, r, colors.TabItemBackground, Color.Empty);
                        g.DrawLine(pen, r.Right - 1, r.Y, r.Right - 1, selectedTabRect.Y - 1);
                        g.DrawLine(pen, r.Right - 1, selectedTabRect.Bottom, r.Right - 1, r.Bottom);
                        g.DrawLine(pen, r.X, r.Y, r.Right - 1, r.Y);
                        g.DrawLine(pen, r.X, r.Bottom - 1, r.Right - 1, r.Bottom - 1);
                    }
                }
            }
            g.SmoothingMode = sm;
        }
Example #2
0
        protected virtual void DrawBackground(TabStrip tabStrip, Rectangle tabStripRect, Graphics g, TabColorScheme colors, Region tabsRegion, eTabStripAlignment tabAlignment, Rectangle selectedTabRect)
		{
			if(colors.TabBackground2.IsEmpty)
			{
                if (!colors.TabBackground.IsEmpty)
                {
                    using (SolidBrush brush = new SolidBrush(colors.TabBackground))
                        g.FillRegion(brush, tabsRegion);
                }
			}
			else
			{
				using(LinearGradientBrush brush=BarFunctions.CreateLinearGradientBrush(tabsRegion.GetBounds(g),colors.TabBackground,colors.TabBackground2,colors.TabBackgroundGradientAngle))
					g.FillRegion(brush, tabsRegion);
			}

		}
Example #3
0
        protected override void DrawBackground(TabStrip tabStrip, Rectangle tabStripRect, Graphics g, TabColorScheme colors, Region tabsRegion, eTabStripAlignment tabAlignment, Rectangle selectedTabRect)
        {
            base.DrawBackground(tabStrip, tabStripRect, g, colors, tabsRegion, tabAlignment, selectedTabRect);

            SmoothingMode sm = g.SmoothingMode;
            g.SmoothingMode = SmoothingMode.Default;
            using (Pen pen = new Pen(colors.TabItemBorder, 1))
            {
                int tabExtension = 9;
                if (selectedTabRect.IsEmpty)
                    tabExtension = 0;
                Color tabItemSelectedColor2 = colors.TabItemSelectedBackground2;
                if (tabStrip.SelectedTab != null)
                {
                    TabColors tc = tabStrip.GetTabColors(tabStrip.SelectedTab);
                    tabItemSelectedColor2 = tc.BackColor2;
                }
                if (tabAlignment == eTabStripAlignment.Top)
                {
                    if (selectedTabRect.X > tabStripRect.Right || selectedTabRect.Bottom < tabStripRect.Bottom - 4)
                    {
                        selectedTabRect = Rectangle.Empty;
                        tabExtension = 0;
                    }
                    Rectangle r = new Rectangle(tabStripRect.X, tabStripRect.Bottom - 1, tabStripRect.Width, 1);
                    DisplayHelp.FillRectangle(g, r, tabItemSelectedColor2, Color.Empty);
                    g.DrawLine(pen, r.X, r.Y, selectedTabRect.X, r.Y);
                    g.DrawLine(pen, selectedTabRect.Right + tabExtension, r.Y, r.Right, r.Y);
                    g.DrawLine(pen, r.X, r.Y, r.X, r.Bottom);
                    g.DrawLine(pen, r.Right - 1, r.Y, r.Right - 1, r.Bottom);
                }
                else if (tabAlignment == eTabStripAlignment.Bottom)
                {
                    if (selectedTabRect.X > tabStripRect.Right || selectedTabRect.Y>4)
                    {
                        selectedTabRect = Rectangle.Empty;
                        tabExtension = 0;
                    }
                    Rectangle r = new Rectangle(tabStripRect.X, tabStripRect.Y, tabStripRect.Width, 1);
                    DisplayHelp.FillRectangle(g, r, tabItemSelectedColor2, Color.Empty);
                    g.DrawLine(pen, r.X, r.Bottom -1, selectedTabRect.X, r.Bottom - 1);
                    g.DrawLine(pen, selectedTabRect.Right + tabExtension, r.Bottom - 1, r.Right, r.Bottom - 1);
                    g.DrawLine(pen, r.X, r.Y, r.X, r.Bottom -1);
                    g.DrawLine(pen, r.Right - 1, r.Y, r.Right - 1, r.Bottom - 1);
                }
                else if (tabAlignment == eTabStripAlignment.Left)
                {
                    if (selectedTabRect.Y > tabStripRect.Bottom || selectedTabRect.Right < tabStripRect.Right - 4)
                    {
                        selectedTabRect = Rectangle.Empty;
                        tabExtension = 0;
                    }
                    Rectangle r = new Rectangle(tabStripRect.Right -1, tabStripRect.Y, 1, tabStripRect.Height);
                    DisplayHelp.FillRectangle(g, r, tabItemSelectedColor2, Color.Empty);
                    g.DrawLine(pen, r.X, r.Y, r.X, selectedTabRect.Y);
                    g.DrawLine(pen, r.X, selectedTabRect.Bottom + tabExtension, r.X, r.Bottom);
                    g.DrawLine(pen, r.X, r.Y, r.Right, r.Y);
                    g.DrawLine(pen, r.X, r.Bottom - 1, r.Right, r.Bottom - 1);
                }
                else if (tabAlignment == eTabStripAlignment.Right)
                {
                    if (selectedTabRect.Y > tabStripRect.Bottom || selectedTabRect.X>4)
                    {
                        selectedTabRect = Rectangle.Empty;
                        tabExtension = 0;
                    }
                    Rectangle r = new Rectangle(tabStripRect.X, tabStripRect.Y, 1, tabStripRect.Height);
                    DisplayHelp.FillRectangle(g, r, tabItemSelectedColor2, Color.Empty);
                    g.DrawLine(pen, r.Right - 1, r.Y, r.Right - 1, selectedTabRect.Y);
                    g.DrawLine(pen, r.Right - 1, selectedTabRect.Bottom + tabExtension, r.Right - 1, r.Bottom);
                    g.DrawLine(pen, r.X, r.Y, r.Right, r.Y);
                    g.DrawLine(pen, r.X, r.Bottom - 1, r.Right, r.Bottom - 1);
                }
            }
            g.SmoothingMode = sm;
        }
Example #4
0
        protected override void DrawBackground(TabStrip tabStrip, Rectangle tabStripRect, Graphics g, TabColorScheme colors, Region tabsRegion, eTabStripAlignment tabAlignment, Rectangle selectedTabRect)
		{
			base.DrawBackground(tabStrip, tabStripRect,g,colors,tabsRegion,tabAlignment, selectedTabRect);

			if(!colors.TabItemBorder.IsEmpty)
			{
				using(Pen pen=new Pen(colors.TabItemBorder,1))
				{
					if(tabAlignment==eTabStripAlignment.Bottom)
					{
						g.DrawLine(pen,tabStripRect.X,tabStripRect.Y+1,tabStripRect.Right,tabStripRect.Y+1);
					}
					else if(tabAlignment==eTabStripAlignment.Left)
					{
						g.DrawLine(pen,tabStripRect.Right-1,tabStripRect.Y,tabStripRect.Right-1,tabStripRect.Bottom);
					}
					else if(tabAlignment==eTabStripAlignment.Right)
					{
						g.DrawLine(pen,tabStripRect.X,tabStripRect.Y,tabStripRect.X,tabStripRect.Bottom);
					}
					else if(tabAlignment==eTabStripAlignment.Top)
					{
						g.DrawLine(pen,tabStripRect.X,tabStripRect.Bottom-1,tabStripRect.Right,tabStripRect.Bottom-1);
					}
				}
			}
		}
Example #5
0
		private void DrawBackgroundInternal(Rectangle tabStripRect, Graphics g, TabColorScheme colors, Region tabsRegion, eTabStripAlignment tabAlignment, Rectangle tabItemsBounds)
		{
			int cornerDiameter=3;
			Rectangle br;
			GraphicsPath path=new GraphicsPath();
			GraphicsPath backPath=null;

			if(!tabItemsBounds.IsEmpty)
			{
				if(tabAlignment==eTabStripAlignment.Top)
				{
					tabItemsBounds.Width+=3;
					br=new Rectangle(tabStripRect.X,tabItemsBounds.Y+1,(tabItemsBounds.Right>tabStripRect.Right?tabStripRect.Width:tabItemsBounds.Right),tabItemsBounds.Height-1);
					path.AddLine(br.X,br.Bottom,br.X,br.Top+cornerDiameter);
					ArcData ad=GetCornerArc(br,cornerDiameter,eCornerArc.TopLeft);
					path.AddArc(ad.X,ad.Y,ad.Width,ad.Height,ad.StartAngle,ad.SweepAngle);
					path.AddLine(br.X+cornerDiameter,br.Y,br.Right-cornerDiameter,br.Y);
					ad=GetCornerArc(br,cornerDiameter,eCornerArc.TopRight);
					path.AddArc(ad.X,ad.Y,ad.Width,ad.Height,ad.StartAngle,ad.SweepAngle);
					path.AddLine(br.Right,br.Y+cornerDiameter,br.Right,br.Bottom);
					
					backPath=path.Clone() as GraphicsPath;
					backPath.CloseAllFigures();

					if(tabItemsBounds.Right<tabStripRect.Right)
						path.AddLine(br.Right,br.Bottom,tabStripRect.Right,br.Bottom);
				}
				else if(tabAlignment==eTabStripAlignment.Bottom)
				{
					tabItemsBounds.Width+=3;
					br=new Rectangle(tabStripRect.X,tabStripRect.Y,(tabItemsBounds.Right>tabStripRect.Right?tabStripRect.Width:tabItemsBounds.Right),tabItemsBounds.Height-1);
					path.AddLine(br.Right,br.Y,br.Right,br.Bottom-cornerDiameter);
					ArcData ad=GetCornerArc(br,cornerDiameter,eCornerArc.BottomRight);
					path.AddArc(ad.X,ad.Y,ad.Width,ad.Height,ad.StartAngle,ad.SweepAngle);
					path.AddLine(br.Right-cornerDiameter,br.Bottom,br.X+cornerDiameter,br.Bottom);
					ad=GetCornerArc(br,cornerDiameter,eCornerArc.BottomLeft);
					path.AddArc(ad.X,ad.Y,ad.Width,ad.Height,ad.StartAngle,ad.SweepAngle);
					path.AddLine(br.X,br.Bottom-cornerDiameter,br.X,br.Y);

					backPath=path.Clone() as GraphicsPath;
					backPath.CloseAllFigures();

					if(tabItemsBounds.Right<tabStripRect.Right)
						path.AddLine(br.Right,br.Y,tabStripRect.Right,br.Y);
				}
				else if(tabAlignment==eTabStripAlignment.Left)
				{
					tabItemsBounds.Height+=3;
					br=new Rectangle(tabItemsBounds.X+1,tabStripRect.Y,tabItemsBounds.Width-1,(tabItemsBounds.Bottom>tabStripRect.Bottom?tabStripRect.Height:tabItemsBounds.Bottom));
                    
                    path.AddLine(br.Right-1,br.Bottom,br.X+cornerDiameter,br.Bottom);
                    ArcData ad=GetCornerArc(br,cornerDiameter,eCornerArc.BottomLeft);
					path.AddArc(ad.X,ad.Y,ad.Width,ad.Height,ad.StartAngle,ad.SweepAngle);
					path.AddLine(br.X,br.Bottom-cornerDiameter,br.X,br.Y+cornerDiameter);
					ad=GetCornerArc(br,cornerDiameter,eCornerArc.TopLeft);
					path.AddArc(ad.X,ad.Y,ad.Width,ad.Height,ad.StartAngle,ad.SweepAngle);
                    path.AddLine(br.X+cornerDiameter,br.Y,br.Right-1,br.Y);

					backPath=path.Clone() as GraphicsPath;
					backPath.CloseAllFigures();

					if(tabItemsBounds.Bottom<tabStripRect.Bottom)
						path.AddLine(br.Right-1,br.Bottom,br.Right-1,tabStripRect.Bottom);
				}
				else if(tabAlignment==eTabStripAlignment.Right)
				{
					tabItemsBounds.Height+=3;
					br=new Rectangle(tabStripRect.X,tabStripRect.Y,tabItemsBounds.Width-1,(tabItemsBounds.Bottom>tabStripRect.Bottom?tabStripRect.Height:tabItemsBounds.Bottom));
					path.AddLine(br.X,br.Y,br.Right-cornerDiameter,br.Y);
					ArcData ad=GetCornerArc(br,cornerDiameter,eCornerArc.TopRight);
					path.AddArc(ad.X,ad.Y,ad.Width,ad.Height,ad.StartAngle,ad.SweepAngle);
					path.AddLine(br.Right,br.Y+cornerDiameter,br.Right,br.Bottom-cornerDiameter);
					ad=GetCornerArc(br,cornerDiameter,eCornerArc.BottomRight);
					path.AddArc(ad.X,ad.Y,ad.Width,ad.Height,ad.StartAngle,ad.SweepAngle);
					path.AddLine(br.Right-cornerDiameter,br.Bottom,br.X,br.Bottom);

					backPath=path.Clone() as GraphicsPath;
					backPath.CloseAllFigures();

					if(tabItemsBounds.Bottom<tabStripRect.Bottom)
						path.AddLine(br.X,br.Bottom,br.X,tabStripRect.Bottom);
				}
			}
			else
			{
				path.AddRectangle(tabStripRect);
			}

			// Paint background of the tab control
			//g.SetClip(backPath,CombineMode.Replace);
			//g.SetClip(tabsRegion,CombineMode.Exclude);
			
			if(colors.TabPanelBackground2.IsEmpty)
			{
				if(!colors.TabPanelBackground.IsEmpty)
				{
					using(SolidBrush brush=new SolidBrush(colors.TabPanelBackground))
						g.FillPath(brush,path);
				}
			}
			else
			{
				using(SolidBrush brush=new SolidBrush(Color.White))
					g.FillPath(brush,path);
				using(LinearGradientBrush brush=CreateTabGradientBrush(tabStripRect,colors.TabPanelBackground,colors.TabPanelBackground2,colors.TabPanelBackgroundGradientAngle))
					g.FillPath(brush,path);
			}

			if(!colors.TabBorder.IsEmpty)
			{
				path.CloseAllFigures();
				using(Pen pen=new Pen(colors.TabBorder,1))
					g.DrawPath(pen,path);
			}

            if (backPath != null)
                backPath.Dispose();
            if (path != null)
                path.Dispose();
		}
Example #6
0
		/// <summary>
		/// Default constructor.
		/// </summary>
		public TabStrip()
		{
			if(!ColorFunctions.ColorsLoaded)
			{
				NativeFunctions.RefreshSettings();
				NativeFunctions.OnDisplayChange();
				ColorFunctions.LoadColors();
			}
			m_Tabs=new TabsCollection(this);
			this.SetStyle(ControlStyles.Selectable,true);
			this.SetStyle(ControlStyles.UserPaint,true);
			this.SetStyle(ControlStyles.Opaque,true);
            this.SetStyle(ControlStyles.SupportsTransparentBackColor, true);
			this.SetStyle(DisplayHelp.DoubleBufferFlag,true);
            this.SetStyle(ControlStyles.AllPaintingInWmPaint,true);
			this.SetStyle(ControlStyles.ResizeRedraw,true);

			m_TabSystemBox=new TabSystemBox(this);
			m_TabSystemBox.Back+=new EventHandler(this.OnTabBack);
			m_TabSystemBox.Close+=new EventHandler(this.OnTabClose);
			m_TabSystemBox.Forward+=new EventHandler(this.OnTabForward);

			m_ColorScheme=new TabColorScheme(m_Style);
			m_ColorScheme.ColorChanged+=new EventHandler(this.ColorSchemeChanged);

            StyleManager.Register(this);
		}
Example #7
0
        protected override void DrawBackground(TabStrip tabStrip, Rectangle tabStripRect, Graphics g, TabColorScheme colors, Region tabsRegion, eTabStripAlignment tabAlignment, Rectangle selectedTabRect)
		{
			int cornerDiameter=5;
			Rectangle br;
			GraphicsPath path=new GraphicsPath();
			if(tabAlignment==eTabStripAlignment.Top)
			{
				br=new Rectangle(tabStripRect.X,tabStripRect.Y+tabStripRect.Height/2,tabStripRect.Width-1,tabStripRect.Height-tabStripRect.Height/2);
				path.AddLine(br.X,br.Bottom,br.X,br.Top+cornerDiameter);
				ArcData ad=GetCornerArc(br,cornerDiameter,eCornerArc.TopLeft);
				path.AddArc(ad.X,ad.Y,ad.Width,ad.Height,ad.StartAngle,ad.SweepAngle);
				path.AddLine(br.X+cornerDiameter,br.Y,br.Right-cornerDiameter,br.Y);
				ad=GetCornerArc(br,cornerDiameter,eCornerArc.TopRight);
				path.AddArc(ad.X,ad.Y,ad.Width,ad.Height,ad.StartAngle,ad.SweepAngle);
				path.AddLine(br.Right,br.Y+cornerDiameter,br.Right,br.Bottom);
			}
			else if(tabAlignment==eTabStripAlignment.Bottom)
			{
				br=new Rectangle(tabStripRect.X,tabStripRect.Y,tabStripRect.Width-1,tabStripRect.Height/2);
				path.AddLine(br.Right,br.Y,br.Right,br.Bottom-cornerDiameter);
				ArcData ad=GetCornerArc(br,cornerDiameter,eCornerArc.BottomRight);
				path.AddArc(ad.X,ad.Y,ad.Width,ad.Height,ad.StartAngle,ad.SweepAngle);
				path.AddLine(br.Right-cornerDiameter,br.Bottom,br.X+cornerDiameter,br.Bottom);
				ad=GetCornerArc(br,cornerDiameter,eCornerArc.BottomLeft);
				path.AddArc(ad.X,ad.Y,ad.Width,ad.Height,ad.StartAngle,ad.SweepAngle);
				path.AddLine(br.X,br.Bottom-cornerDiameter,br.X,br.Y);
			}
			else if(tabAlignment==eTabStripAlignment.Left)
			{
				br=new Rectangle(tabStripRect.X+tabStripRect.Width/2,tabStripRect.Y,tabStripRect.Width/2+1,tabStripRect.Height-1);
				path.AddLine(br.Right,br.Bottom,br.X+cornerDiameter,br.Bottom);
				ArcData ad=GetCornerArc(br,cornerDiameter,eCornerArc.BottomLeft);
				path.AddArc(ad.X,ad.Y,ad.Width,ad.Height,ad.StartAngle,ad.SweepAngle);
				path.AddLine(br.X,br.Bottom-cornerDiameter,br.X,br.Y+cornerDiameter);
				ad=GetCornerArc(br,cornerDiameter,eCornerArc.TopLeft);
				path.AddArc(ad.X,ad.Y,ad.Width,ad.Height,ad.StartAngle,ad.SweepAngle);
				path.AddLine(br.X+cornerDiameter,br.Y,br.Right,br.Y);
			}
			else if(tabAlignment==eTabStripAlignment.Right)
			{
				br=new Rectangle(tabStripRect.X,tabStripRect.Y,tabStripRect.Width/2,tabStripRect.Height-1);
				path.AddLine(br.X,br.Y,br.Right-cornerDiameter,br.Y);
				ArcData ad=GetCornerArc(br,cornerDiameter,eCornerArc.TopRight);
				path.AddArc(ad.X,ad.Y,ad.Width,ad.Height,ad.StartAngle,ad.SweepAngle);
				path.AddLine(br.Right,br.Y+cornerDiameter,br.Right,br.Bottom-cornerDiameter);
				ad=GetCornerArc(br,cornerDiameter,eCornerArc.BottomRight);
				path.AddArc(ad.X,ad.Y,ad.Width,ad.Height,ad.StartAngle,ad.SweepAngle);
				path.AddLine(br.Right-cornerDiameter,br.Bottom,br.X,br.Bottom);
			}

			// Paint background of the tab control
			GraphicsPath backPath=path.Clone() as GraphicsPath;
			backPath.CloseAllFigures();
			g.SetClip(backPath,CombineMode.Replace);
			g.SetClip(tabsRegion,CombineMode.Exclude);
			g.Clear(colors.TabPanelBackground);
			g.ResetClip();
			backPath.Dispose();

			g.SetClip(tabsRegion,CombineMode.Exclude);
			
			using(Pen pen=new Pen(colors.TabBorder,1))
				g.DrawPath(pen,path);
			path.Dispose();
			g.ResetClip();
		}