Esempio n. 1
0
		/// <summary>
		/// Paints button on given canvas.
		/// </summary>
		/// <param name="info">Painting information.</param>
		public static void Paint(BubbleButtonDisplayInfo info)
		{
			if(!info.Button.Visible)
				return;

			CompositeImage image=null;
			Rectangle buttonRectangle=Rectangle.Empty;
			if(info.Magnified)
			{
				buttonRectangle=info.Button.MagnifiedDisplayRectangle;
				image=GetButtonImage(info.Button,buttonRectangle.Size);
			}
			else
			{
				buttonRectangle=info.Button.DisplayRectangle;
				image=GetButtonImage(info.Button,buttonRectangle.Size);
			}

            if (buttonRectangle.Width < 2 || buttonRectangle.Height < 2) return;

			if(image!=null)
			{
				if(!info.Button.Enabled)
					image.DrawImage(info.Graphics,buttonRectangle,0,0,image.RealWidth,image.RealHeight,GraphicsUnit.Pixel,GetDisabledAttributes());
				else if(info.Button.MouseDown)
					image.DrawImage(info.Graphics,buttonRectangle,0,0,image.RealWidth,image.RealHeight,GraphicsUnit.Pixel,GetDarkAttributes());
				else
					image.DrawImage(info.Graphics,buttonRectangle);
			}
			else
				info.Graphics.DrawRectangle(SystemPens.Highlight,buttonRectangle);
            
			if(info.Button.Focus)
			{
				buttonRectangle.Inflate(1,1);
				DesignTime.DrawDesignTimeSelection(info.Graphics,buttonRectangle,Color.Navy);
			}

			DrawTooltip(info);
		}
Esempio n. 2
0
		private static void DrawTooltip(BubbleButtonDisplayInfo info)
		{
			//float emMulti=1.3285f;

			if(info.Button.MouseOver && info.BubbleBar.ShowTooltips && info.Button.TooltipText!="")
			{
                Color textColor = info.BubbleBar.TooltipTextColor;
                Color outlineColor = info.BubbleBar.TooltipOutlineColor;

                StringFormat format = TextDrawing.GetStringFormat(eTextFormat.Default); // BarFunctions.CreateStringFormat();
				System.Drawing.Drawing2D.CompositingMode cs=info.Graphics.CompositingMode=System.Drawing.Drawing2D.CompositingMode.SourceOver;
				Font font=info.BubbleBar.TooltipFont;
				if(font==null)
					font=info.BubbleBar.Font;
				Rectangle rText=info.Button.DisplayRectangle;
                
                Size size = TextDrawing.MeasureString(info.Graphics, info.Button.TooltipText, font);

                if(info.Magnified)
					rText=info.Button.MagnifiedDisplayRectangle;
				if(info.Alignment==eBubbleButtonAlignment.Bottom)
					rText.Y-=(Math.Max(font.Height, size.Height)+BUTTON_TOOLTIP_SPACING);
				else
					rText.Y=rText.Bottom+BUTTON_TOOLTIP_SPACING;
				
				rText.Offset(-(size.Width-rText.Width)/2,0);

                Size tooltipSize = TextDrawing.MeasureString(info.Graphics, info.Button.TooltipText, font);
                Rectangle outline = rText;
                outline.Size = tooltipSize;
                outline.Inflate(2, 2);
                using (SolidBrush brush = new SolidBrush(Color.FromArgb(200, outlineColor)))
                    DisplayHelp.FillRoundedRectangle(info.Graphics, brush, outline, 3);
                //Point pOutline=rText.Location;
                //pOutline.Offset(-1,0);
                //GraphicsPath path=new GraphicsPath();
                //path.AddString(info.Button.TooltipText,font.FontFamily,(int)font.Style,font.SizeInPoints/*font.SizeInPoints*emMulti*/,new PointF((pOutline.X+1)*72/info.Graphics.DpiX,(pOutline.Y-1)*72/info.Graphics.DpiY),format);
                //using(Pen pen=new Pen(outlineColor,(font.SizeInPoints>=10?1:1)))
                //    path.Widen(pen);
                //using(SolidBrush brush=new SolidBrush(Color.FromArgb(200,outlineColor)))
                //{
                //    GraphicsUnit pageUnit=info.Graphics.PageUnit;
                //    info.Graphics.PageUnit=GraphicsUnit.Point;
                //    info.Graphics.FillPath(brush,path);
                //    info.Graphics.PageUnit=pageUnit;
                //}
				
                //path.Dispose();
                //path=new GraphicsPath();
                //path.AddString(info.Button.TooltipText,font.FontFamily,(int)font.Style,font.SizeInPoints/*font.SizeInPoints*emMulti*/,new PointF(pOutline.X*72/info.Graphics.DpiX,pOutline.Y*72/info.Graphics.DpiY),format);
                //path.Widen(SystemPens.ControlText);
                //using(SolidBrush brush=new SolidBrush(Color.FromArgb(200,outlineColor)))
                //{
                //    GraphicsUnit pageUnit=info.Graphics.PageUnit;
                //    info.Graphics.PageUnit=GraphicsUnit.Point;
                //    info.Graphics.FillPath(brush,path);
                //    info.Graphics.PageUnit=pageUnit;
                //}
                //path.Dispose();

				TextDrawing.DrawString(info.Graphics,info.Button.TooltipText,font,textColor,rText.X,rText.Y,eTextFormat.Default);

				info.Graphics.CompositingMode=cs;
				format.Dispose();
			}
		}