Пример #1
0
		private void PaintExpandButton(ItemPaintArgs pa, InternalMenuColors menuColors)
		{
			if(!m_ExpandButton.ShowExpandButton || m_ParentItem==null)
				return;

			Graphics g=pa.Graphics;

			ImageItem objParentImageItem=m_ParentItem as ImageItem;
			int iSideWidth=DEFAULT_SIDE_WIDTH;
			if(objParentImageItem!=null && objParentImageItem.SubItemsImageSize.Width>iSideWidth)
				iSideWidth=objParentImageItem.SubItemsImageSize.Width;
			iSideWidth+=7;

			objParentImageItem=null;

            if (IsGradientStyle)
			{
				if(m_ExpandButton.MouseOver)
				{
                    Rectangle r = m_ExpandButton.Rect;
                    DisplayHelp.FillRectangle(g, r, pa.Colors.MenuBackground, Color.Empty);
					r.Inflate(-1,0);
					if(Control.MouseButtons==MouseButtons.Left)
					{
                        DisplayHelp.FillRectangle(g, r, pa.Colors.ItemPressedBackground, pa.Colors.ItemPressedBackground2, pa.Colors.ItemPressedBackgroundGradientAngle);
					}
					else
					{
                        DisplayHelp.FillRectangle(g, r, pa.Colors.ItemHotBackground, pa.Colors.ItemHotBackground2, pa.Colors.ItemHotBackgroundGradientAngle);
					}
					NativeFunctions.DrawRectangle(g,SystemPens.Highlight,r);
				}
				else
				{
                    Rectangle r=new Rectangle(m_ExpandButton.Rect.Left+iSideWidth,m_ExpandButton.Rect.Top,m_ExpandButton.Rect.Width-iSideWidth,m_ExpandButton.Rect.Height);
                    DisplayHelp.FillRectangle(g, r, pa.Colors.MenuBackground, Color.Empty);

                    Rectangle sideRect = new Rectangle(m_ExpandButton.Rect.Left, m_ExpandButton.Rect.Top, iSideWidth, m_ExpandButton.Rect.Height);
                    DisplayHelp.FillRectangle(g, sideRect, pa.Colors.MenuSide, pa.Colors.MenuSide2, pa.Colors.MenuSideGradientAngle);
                    if (m_ParentItem != null && BarFunctions.IsOffice2007Style(m_ParentItem.EffectiveStyle))
                        PaintMenuItemSide(pa, sideRect, menuColors);
				}

                if (m_ParentItem.EffectiveStyle == eDotNetBarStyle.Office2003 || m_ParentItem.EffectiveStyle == eDotNetBarStyle.VS2005 || BarFunctions.IsOffice2007Style(m_ParentItem.EffectiveStyle))
				{
					System.Drawing.Drawing2D.GraphicsPath path=new System.Drawing.Drawing2D.GraphicsPath();
					Point pTopLeft=new Point(m_ExpandButton.Rect.X+(m_ExpandButton.Rect.Width-16)/2,m_ExpandButton.Rect.Y+(m_ExpandButton.Rect.Height-16)/2);
					path.AddEllipse(pTopLeft.X,pTopLeft.Y,16,16);
					System.Drawing.Drawing2D.PathGradientBrush gb=new System.Drawing.Drawing2D.PathGradientBrush(path);
					gb.CenterColor=pa.Colors.MenuSide;
					gb.SurroundColors=new Color[]{pa.Colors.MenuSide2};
					gb.CenterPoint=new Point(pTopLeft.X+3,pTopLeft.Y+3);
					System.Drawing.Drawing2D.SmoothingMode sm=g.SmoothingMode;
					g.SmoothingMode=System.Drawing.Drawing2D.SmoothingMode.AntiAlias;
					g.FillEllipse(gb,pTopLeft.X,pTopLeft.Y,16,16);
					g.SmoothingMode=sm;
				}

			}
            else if (m_ParentItem.EffectiveStyle == eDotNetBarStyle.Office2000)
			{
				if(m_ExpandButton.MouseOver)
				{	
					//g.FillRectangle(new SolidBrush(g.GetNearestColor(ControlPaint.Light(SystemColors.Control))),m_ExpandButton.Rect);
					g.FillRectangle(new SolidBrush(ColorFunctions.RecentlyUsedOfficeBackColor()),m_ExpandButton.Rect);
					if(Control.MouseButtons==MouseButtons.Left)
						ControlPaint.DrawBorder(g,m_ExpandButton.Rect,SystemColors.Control,ButtonBorderStyle.Inset);
					else
						ControlPaint.DrawBorder3D(g,m_ExpandButton.Rect,Border3DStyle.RaisedInner,(Border3DSide.Left | Border3DSide.Right | Border3DSide.Top | Border3DSide.Bottom));
					//NativeFunctions.DrawRectangle(g,SystemPens.Highlight,m_ExpandButton.Rect);
				}
				else
				{
					g.FillRectangle(SystemBrushes.Control,m_ExpandButton.Rect);
				}
			}

			Point[] p=new Point[3];
			p[0].X=m_ExpandButton.Rect.Left+(m_ExpandButton.Rect.Width-4)/2;
            if (m_ParentItem.EffectiveStyle == eDotNetBarStyle.Office2003 || m_ParentItem.EffectiveStyle == eDotNetBarStyle.VS2005 || BarFunctions.IsOffice2007Style(m_ParentItem.EffectiveStyle))
				p[0].Y=m_ExpandButton.Rect.Top+(m_ExpandButton.Rect.Height-7)/2;
			else
				p[0].Y=m_ExpandButton.Rect.Top+3;
			p[1].X=p[0].X+2;
			p[1].Y=p[0].Y+2;
			p[2].X=p[0].X+4;
			p[2].Y=p[0].Y;
			g.DrawLines(SystemPens.ControlText,p);
			p[0].Y+=1;
			p[1].Y+=1;
			p[2].Y+=1;
			g.DrawLines(SystemPens.ControlText,p);

			p[0].Y+=3;
			p[1].Y+=3;
			p[2].Y+=3;
			g.DrawLines(SystemPens.ControlText,p);
			p[0].Y+=1;
			p[1].Y+=1;
			p[2].Y+=1;
			g.DrawLines(SystemPens.ControlText,p);

		}
Пример #2
0
        private void PaintItems(ItemPaintArgs pa, InternalMenuColors menuColors)
		{
			Graphics g=pa.Graphics;
            bool rightToLeft = (this.RightToLeft == RightToLeft.Yes);

			// Draw all contained items
			if(m_ParentItem!=null && m_ParentItem!=null)
			{
				// Special case handling when menus exceed the size of window
				Point[] p;
				Rectangle clipRect=new Rectangle((int)g.ClipBounds.X,(int)g.ClipBounds.Y,(int)g.ClipBounds.Width,(int)g.ClipBounds.Height);
				if(m_Scroll)
				{
					if(m_TopScroll)
					{
						p=new Point[3];
						p[0].X=m_ClientRect.Left+(m_ClientRect.Width-8)/2;
						p[0].Y=m_ClientRect.Top+8;
						p[1].X=p[0].X+8;
						p[1].Y=p[0].Y;
						p[2].X=p[0].X+4;
						p[2].Y=p[0].Y-5;
						g.FillPolygon(SystemBrushes.ControlText,p);
					}
					BaseItem objTmp;
					ImageItem objParentImageItem=m_ParentItem as ImageItem;
					int iSideWidth=DEFAULT_SIDE_WIDTH;
					if(objParentImageItem!=null)
						iSideWidth=objParentImageItem.SubItemsImageSize.Width;
					objParentImageItem=null;
                    bool previousContainerItem = false;
					for(int i=m_ScrollTopPosition;i<m_ParentItem.SubItems.Count;i++)
					{
						objTmp=m_ParentItem.SubItems[i];
						if(!clipRect.IntersectsWith(objTmp.DisplayRectangle))
							continue;
						if(objTmp.Visible || m_IsCustomizeMenu)
						{
							if(objTmp.Displayed)
							{
                                SmoothingMode sm = g.SmoothingMode;
                                g.SmoothingMode = SmoothingMode.Default;
								if(objTmp.BeginGroup && objTmp.TopInternal>ClientMarginTop)  // Exclude first element
								{
                                    if (objTmp.EffectiveStyle == eDotNetBarStyle.Office2000)
									{
										if(m_IsCustomizeMenu)
											System.Windows.Forms.ControlPaint.DrawBorder3D(g,objTmp.HeightInternal+2+objTmp.LeftInternal+13,objTmp.TopInternal-5,objTmp.WidthInternal-26-objTmp.HeightInternal-2,2,System.Windows.Forms.Border3DStyle.Etched,System.Windows.Forms.Border3DSide.Top);
										else
											System.Windows.Forms.ControlPaint.DrawBorder3D(g,objTmp.LeftInternal+13,objTmp.TopInternal-5,objTmp.WidthInternal-26,2,System.Windows.Forms.Border3DStyle.Etched,System.Windows.Forms.Border3DSide.Top);
									}
									else
									{
										if(m_IsCustomizeMenu)
										{
                                            Rectangle sideRect = new Rectangle(objTmp.LeftInternal, objTmp.TopInternal - 3, objTmp.HeightInternal + 2 + iSideWidth + 7, 3);
                                            sideRect.Inflate(0, 1);
                                            DisplayHelp.FillRectangle(g, sideRect, menuColors.Side.Start, menuColors.Side.End, menuColors.Side.GradientAngle);

                                            if (BarFunctions.IsOffice2007Style(objTmp.EffectiveStyle))
                                                PaintMenuItemSide(pa, sideRect, menuColors);
                                            DisplayHelp.DrawLine(g, objTmp.LeftInternal + iSideWidth + 8 + 7 + objTmp.HeightInternal + 2, objTmp.TopInternal - 2, objTmp.DisplayRectangle.Right - 1, objTmp.TopInternal - 2,
                                                menuColors.SideBorder.Start, 1);
                                            if (BarFunctions.IsOffice2007Style(objTmp.EffectiveStyle))
											    DisplayHelp.DrawLine(g, objTmp.LeftInternal + iSideWidth + 8 + 7 + objTmp.HeightInternal + 2, objTmp.TopInternal - 1, objTmp.DisplayRectangle.Right - 1, objTmp.TopInternal - 1, menuColors.SideBorderLight.Start, 1);

										}
										else
										{
                                            bool paintSide = DoPaintSide(objTmp);
                                            bool itemOnlySeparator = paintSide;
                                            if(paintSide)
                                            {
                                                Rectangle sideRect = new Rectangle(objTmp.LeftInternal, objTmp.TopInternal - 3, iSideWidth + 7, 3);
                                                sideRect.Inflate(0, 1);
											    // Paint side bar
                                                if (objTmp is IPersonalizedMenuItem && ((IPersonalizedMenuItem)objTmp).MenuVisibility == eMenuVisibility.VisibleIfRecentlyUsed && !((IPersonalizedMenuItem)objTmp).RecentlyUsed)
                                                    DisplayHelp.FillRectangle(g, sideRect, menuColors.SideUnused);
                                                else
                                                    DisplayHelp.FillRectangle(g, sideRect, menuColors.Side);

                                                if (BarFunctions.IsOffice2007Style(objTmp.EffectiveStyle))
                                                    PaintMenuItemSide(pa, sideRect, menuColors);
                                            }
                                            if (itemOnlySeparator && previousContainerItem)
                                                itemOnlySeparator = false;
                                            DisplayHelp.DrawLine(g, objTmp.LeftInternal + (itemOnlySeparator ? (iSideWidth + 8 + 7) : 0), objTmp.TopInternal - 2, objTmp.DisplayRectangle.Right - 1, objTmp.TopInternal - 2, menuColors.SideBorder.Start, 1);
                                            if (BarFunctions.IsOffice2007Style(objTmp.EffectiveStyle))
                                                DisplayHelp.DrawLine(g, objTmp.LeftInternal + (itemOnlySeparator ? (iSideWidth + 8 + 7) : 0), objTmp.TopInternal - 1, objTmp.DisplayRectangle.Right - 1, objTmp.TopInternal - 1, menuColors.SideBorderLight.Start, 1);
										}
									}
								}
                                g.SmoothingMode = sm;
								objTmp.Paint(pa);
                                previousContainerItem = (objTmp.IsContainer);
							}
						}
					}
					if(m_BottomScroll)
					{
						// Draw down button
						p=new Point[3];
						p[0].X=m_ClientRect.Left+(m_ClientRect.Width-8)/2;
						p[0].Y=m_ClientRect.Bottom-8;
						p[1].X=p[0].X+8;
						p[1].Y=p[0].Y;
						p[2].X=p[0].X+4;
						p[2].Y=p[0].Y+4;
						g.FillPolygon(SystemBrushes.ControlText,p);
					}
				}
				else
				{
					// This is very simple...
					ImageItem objParentImageItem=m_ParentItem as ImageItem;
					int iSideBarWidth=DEFAULT_SIDE_WIDTH;
					if(objParentImageItem!=null)
						iSideBarWidth=objParentImageItem.SubItemsImageSize.Width;
					objParentImageItem=null;
					bool bFirst=true;
                    bool previousContainerItem = false;
					foreach(BaseItem objTmp in m_ParentItem.SubItems)
					{
						if(!clipRect.IntersectsWith(objTmp.DisplayRectangle))
							continue;

						if(objTmp.Visible && objTmp.Displayed || m_IsCustomizeMenu)
						{
                            SmoothingMode sm = g.SmoothingMode;
                            g.SmoothingMode = SmoothingMode.Default;
							if(objTmp.BeginGroup && !bFirst)
							{
                                if (objTmp.EffectiveStyle == eDotNetBarStyle.Office2000)
								{
									if(m_IsCustomizeMenu)
										System.Windows.Forms.ControlPaint.DrawBorder3D(g,objTmp.HeightInternal+2+objTmp.LeftInternal+13,objTmp.TopInternal-5,objTmp.WidthInternal-26-objTmp.HeightInternal-2,2,System.Windows.Forms.Border3DStyle.Etched,System.Windows.Forms.Border3DSide.Top);
									else
										System.Windows.Forms.ControlPaint.DrawBorder3D(g,objTmp.LeftInternal+13,objTmp.TopInternal-5,objTmp.WidthInternal-26,2,System.Windows.Forms.Border3DStyle.Etched,System.Windows.Forms.Border3DSide.Top);
								}
								else
								{
									if(m_IsCustomizeMenu)
									{
                                        Rectangle sideBar = new Rectangle(objTmp.LeftInternal, objTmp.TopInternal - 3, objTmp.HeightInternal + 2 + iSideBarWidth + 7, 3);
                                        sideBar.Inflate(0, 1);
                                        if (rightToLeft)
                                        {
                                            sideBar.Width = iSideBarWidth + 7;
                                            sideBar.X = objTmp.DisplayRectangle.Right - sideBar.Width;
                                        }
										// Paint side bar
                                        DisplayHelp.FillRectangle(g, sideBar, menuColors.Side);

                                        if (BarFunctions.IsOffice2007Style(objTmp.EffectiveStyle))
                                            PaintMenuItemSide(pa, sideBar, menuColors);

                                        if (rightToLeft)
                                        {
                                            DisplayHelp.DrawLine(g, objTmp.LeftInternal + 1, objTmp.TopInternal - 2, objTmp.DisplayRectangle.Right - (iSideBarWidth + 8 + 7 + objTmp.HeightInternal + 2 + 1), objTmp.TopInternal - 2, menuColors.SideBorder.Start, 1);
                                            if (BarFunctions.IsOffice2007Style(objTmp.EffectiveStyle))
                                                DisplayHelp.DrawLine(g, objTmp.LeftInternal + 1, objTmp.TopInternal - 1, objTmp.DisplayRectangle.Right - (iSideBarWidth + 8 + 7 + objTmp.HeightInternal + 2 + 1), objTmp.TopInternal - 1, menuColors.SideBorderLight.Start,1);
                                        }
                                        else
                                        {
                                            DisplayHelp.DrawLine(g, objTmp.LeftInternal + iSideBarWidth + 8 + 7 + objTmp.HeightInternal + 2, objTmp.TopInternal - 2, objTmp.DisplayRectangle.Right - 1, objTmp.TopInternal - 2, menuColors.SideBorder.Start, 1);
                                            if (BarFunctions.IsOffice2007Style(objTmp.EffectiveStyle))
                                                DisplayHelp.DrawLine(g, objTmp.LeftInternal + iSideBarWidth + 8 + 7 + objTmp.HeightInternal + 2, objTmp.TopInternal - 1, objTmp.DisplayRectangle.Right - 1, objTmp.TopInternal - 1, menuColors.SideBorderLight.Start, 1);
                                        }
									}
									else
									{
                                        Rectangle sideBar = new Rectangle(objTmp.LeftInternal, objTmp.TopInternal - 2, iSideBarWidth + 7, 3);
                                        sideBar.Inflate(0, 1);
                                        if (rightToLeft)
                                            sideBar.X = objTmp.DisplayRectangle.Right - sideBar.Width - 1;
                                        
                                        bool paintSide = DoPaintSide(objTmp);
                                        bool itemOnlySeparator = paintSide;
                                        if (itemOnlySeparator && previousContainerItem)
                                        {
                                            paintSide = false;
                                            itemOnlySeparator = false;
                                        }
                                        if (paintSide)
                                        {
                                            // Paint side bar
                                            if (objTmp is IPersonalizedMenuItem && ((IPersonalizedMenuItem)objTmp).MenuVisibility == eMenuVisibility.VisibleIfRecentlyUsed && !((IPersonalizedMenuItem)objTmp).RecentlyUsed)
                                            {
                                                DisplayHelp.FillRectangle(g, sideBar, menuColors.SideUnused);
                                            }
                                            else
                                            {
                                                DisplayHelp.FillRectangle(g, sideBar, menuColors.Side);
                                            }

                                            if (BarFunctions.IsOffice2007Style(objTmp.EffectiveStyle))
                                                PaintMenuItemSide(pa, sideBar, menuColors);
                                        }
                                        
                                        if (rightToLeft)
                                        {
                                            DisplayHelp.DrawLine(g, objTmp.LeftInternal + 1, objTmp.TopInternal - 2, objTmp.DisplayRectangle.Right - (itemOnlySeparator ? (iSideBarWidth + 8 + 7 + 1) : 0), objTmp.TopInternal - 2, menuColors.SideBorder.Start, 1);
                                            if (BarFunctions.IsOffice2007Style(objTmp.EffectiveStyle))
                                                DisplayHelp.DrawLine(g, objTmp.LeftInternal + 1, objTmp.TopInternal - 1, objTmp.DisplayRectangle.Right - (itemOnlySeparator ? (iSideBarWidth + 8 + 7 + 1) : 0), objTmp.TopInternal - 1, menuColors.SideBorderLight.Start, 1);
                                        }
                                        else
                                        {
                                            DisplayHelp.DrawLine(g, objTmp.LeftInternal + (itemOnlySeparator ? (iSideBarWidth + 8 + 7) : 0), objTmp.TopInternal - 2, objTmp.DisplayRectangle.Right - 1, objTmp.TopInternal - 2, pa.Colors.ItemSeparator, 1);
                                            if (BarFunctions.IsOffice2007Style(objTmp.EffectiveStyle) && !pa.Colors.ItemSeparatorShade.IsEmpty)
                                                DisplayHelp.DrawLine(g, objTmp.LeftInternal + (itemOnlySeparator ? (iSideBarWidth + 8 + 7) : 0), objTmp.TopInternal - 1, objTmp.DisplayRectangle.Right - 1, objTmp.TopInternal - 1, pa.Colors.ItemSeparatorShade, 1);
                                        }
									}
								}
							}
                            g.SmoothingMode = sm;
							bFirst=false;
							objTmp.Paint(pa);
							objTmp.Displayed=true;
                            previousContainerItem = objTmp.IsContainer;
						}
					}
				}
                PaintExpandButton(pa, menuColors);
			}
		}
Пример #3
0
        private void PaintMenuItemSide(ItemPaintArgs pa, Rectangle sideRect, InternalMenuColors menuColors)
        {
            if (pa.Owner is DotNetBarManager) // Do not paint side lines for DotNetBarManager owned items...
                return;
            Graphics g = pa.Graphics;
            if (pa.RightToLeft)
            {
                Point p = new Point(sideRect.X, sideRect.Y);
                DisplayHelp.DrawLine(g, p.X, p.Y, p.X, p.Y + sideRect.Height, menuColors.SideBorderLight.Start, 1);
                
                p.X++;

                DisplayHelp.DrawLine(g, p.X, p.Y, p.X, p.Y + sideRect.Height, menuColors.SideBorder.Start, 1);
            }
            else
            {
                Point p = new Point(sideRect.Right - 2, sideRect.Y);

                DisplayHelp.DrawLine(g, p.X, p.Y, p.X, p.Y + sideRect.Height, menuColors.SideBorder.Start, 1);
                
                p.X++;

                DisplayHelp.DrawLine(g, p.X, p.Y, p.X, p.Y + sideRect.Height, menuColors.SideBorderLight.Start, 1);
            }
        }
Пример #4
0
        private InternalMenuColors GetMenuColors(ItemPaintArgs pa)
        {
            InternalMenuColors colors = new InternalMenuColors();
            if (m_ParentItem != null && BarFunctions.IsOffice2007Style(m_ParentItem.EffectiveStyle) && pa.Renderer is Rendering.Office2007Renderer)
            {
                Rendering.Office2007MenuColorTable ct = ((Rendering.Office2007Renderer)pa.Renderer).ColorTable.Menu;
                colors.Background = ct.Background;
                colors.Border = ct.Border;
                colors.Side = ct.Side;
                colors.SideBorder = ct.SideBorder;
                colors.SideBorderLight = ct.SideBorderLight;
                colors.SideUnused = ct.SideUnused;
            }
            else
            {
                colors.Background.Start = pa.Colors.MenuBackground;
                colors.Background.End = pa.Colors.MenuBackground2;
                colors.Background.GradientAngle = pa.Colors.MenuBackgroundGradientAngle;
                colors.Side.Start = pa.Colors.MenuSide;
                colors.Side.End = pa.Colors.MenuSide2;
                colors.Side.GradientAngle = pa.Colors.MenuSideGradientAngle;
                colors.SideUnused.Start = pa.Colors.MenuUnusedSide;
                colors.SideUnused.End = pa.Colors.MenuUnusedSide2;
                colors.SideUnused.GradientAngle = pa.Colors.MenuUnusedSideGradientAngle;
                colors.Border.Start = pa.Colors.MenuBorder;
                colors.SideBorder.Start = pa.Colors.ItemSeparator;
                colors.SideBorderLight.Start = pa.Colors.ItemSeparatorShade;
            }

            return colors;
        }