当前位置: 首页>>代码示例>>C#>>正文


C# VisualStyleRenderer.DrawText方法代码示例

本文整理汇总了C#中System.Windows.Forms.VisualStyles.VisualStyleRenderer.DrawText方法的典型用法代码示例。如果您正苦于以下问题:C# VisualStyleRenderer.DrawText方法的具体用法?C# VisualStyleRenderer.DrawText怎么用?C# VisualStyleRenderer.DrawText使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在System.Windows.Forms.VisualStyles.VisualStyleRenderer的用法示例。


在下文中一共展示了VisualStyleRenderer.DrawText方法的5个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。

示例1: Draw

 protected override void Draw(Graphics dc, string title, string text, Rectangle rect, Rectangle titleRect, Rectangle bodyRect, Image img, int iconWidth)
 {
     if (IsDefined(VisualStyleElement.ToolTip.BalloonTitle.Normal) && IsDefined(VisualStyleElement.ToolTip.Balloon.Normal))
     {
         VisualStyleRenderer titleRenderer = new VisualStyleRenderer(VisualStyleElement.ToolTip.BalloonTitle.Normal);
         VisualStyleRenderer balloonRenderer = new VisualStyleRenderer(VisualStyleElement.ToolTip.Balloon.Normal);
         balloonRenderer.DrawBackground(dc, rect);
         // drawing title
         titleRenderer.DrawText(dc,
             new Rectangle(Padding.Left + iconWidth, Padding.Top, rect.Width - iconWidth - (Padding.Left + Padding.Right), titleRect.Height),
             title, false, TextFormatFlags.Left | TextFormatFlags.WordEllipsis | TextFormatFlags.VerticalCenter);
         // drawing text
         Rectangle balloonTextBounds = new Rectangle(Padding.Left + iconWidth, Padding.Top + titleRect.Height, rect.Width - iconWidth - (Padding.Left + Padding.Right), rect.Height - (Padding.Top + titleRect.Height + Padding.Bottom));
         balloonRenderer.DrawText(dc, balloonTextBounds,
             text, false, TextFormatFlags.Left | TextFormatFlags.WordBreak | TextFormatFlags.VerticalCenter);
     }
     else
     {
         dc.FillRectangle(SystemBrushes.Info, rect);
         dc.DrawRectangle(Pens.Black, new Rectangle(0, 0, rect.Width - 1, rect.Height - 1));
         dc.DrawString(title, new Font(SystemFonts.DefaultFont, FontStyle.Bold), SystemBrushes.InfoText,
             new PointF(Padding.Left + iconWidth, Padding.Top), new StringFormat(StringFormatFlags.NoWrap));
         dc.DrawString(text, SystemFonts.DefaultFont, SystemBrushes.InfoText,
             new RectangleF(Padding.Left + iconWidth, Padding.Top + titleRect.Height, bodyRect.Width, bodyRect.Height),
             new StringFormat());
     }
 }
开发者ID:fiftin,项目名称:WinFormsPopupAlerts,代码行数:27,代码来源:SystemTooltipAlertRenderer.cs

示例2: Draw

        public static void Draw(IDeviceContext dc, Size minSize, Size maxSize, string title, string text, Rectangle titleRect, Rectangle rect, ToolTipIcon icon, Padding padding)
        {
            if (Application.RenderWithVisualStyles)
            {
                VisualStyleRenderer titleRenderer = new VisualStyleRenderer(VisualStyleElement.ToolTip.BalloonTitle.Normal);
                VisualStyleRenderer balloonRenderer = new VisualStyleRenderer(VisualStyleElement.ToolTip.Balloon.Normal);
                balloonRenderer.DrawBackground(dc, rect);

                if (icon == ToolTipIcon.None)
                {
                    titleRenderer.DrawText(dc, new Rectangle(padding.Left, padding.Top, rect.Width - (padding.Left + padding.Right), titleRect.Height),
                        title, false, TextFormatFlags.Left | TextFormatFlags.WordEllipsis | TextFormatFlags.VerticalCenter);

                    Rectangle balloonTextBounds = new Rectangle(padding.Left, padding.Top + titleRect.Height, rect.Width - (padding.Left + padding.Right), rect.Height - (padding.Top + titleRect.Height + padding.Bottom));

                    balloonRenderer.DrawText(dc, balloonTextBounds,
                        text, false, TextFormatFlags.Left | TextFormatFlags.WordBreak | TextFormatFlags.VerticalCenter);
                }
                else
                {
                    throw new NotImplementedException();
                }
            }
            else
            {
                throw new NotImplementedException();
            }
        }
开发者ID:fiftin,项目名称:WinFormsPopupAlerts,代码行数:28,代码来源:ToolTipBalloonDrawingHelper.cs

示例3: DrawText

 public static void DrawText(IDeviceContext dc, string text, VisualStyleElement element, Font fallbackFont, ref Point location, bool measureOnly, int width)
 {
     // For Windows 2000, using Int32.MaxValue for the height doesn't seem to work, so we'll just pick another arbitrary large value
     // that does work.
     Rectangle textRect = new Rectangle(location.X, location.Y, width, NativeMethods.IsWindowsXPOrLater ? Int32.MaxValue : 100000);
     TextFormatFlags flags = TextFormatFlags.WordBreak;
     if( IsTaskDialogThemeSupported )
     {
         VisualStyleRenderer renderer = new VisualStyleRenderer(element);
         Rectangle textSize = renderer.GetTextExtent(dc, textRect, text, flags);
         location = location + new Size(0, textSize.Height);
         if( !measureOnly )
             renderer.DrawText(dc, textSize, text, false, flags);
     }
     else
     {
         if( !measureOnly )
             TextRenderer.DrawText(dc, text, fallbackFont, textRect, SystemColors.WindowText, flags);
         Size textSize = TextRenderer.MeasureText(dc, text, fallbackFont, new Size(textRect.Width, textRect.Height), flags);
         location = location + new Size(0, textSize.Height);
     }
 }
开发者ID:RogovaTatiana,项目名称:FilesSync,代码行数:22,代码来源:DialogHelper.cs

示例4: SimpleStyleRenderer_Paint

		private void SimpleStyleRenderer_Paint(object sender, PaintEventArgs e)
		{
			VisualStyleElement element = VisualStyleElement.Button.CheckBox.CheckedNormal;
			
			if (Application.RenderWithVisualStyles &&
				VisualStyleRenderer.IsElementDefined(element))
			{
				VisualStyleRenderer renderer = new VisualStyleRenderer(element);
				Rectangle rectCheck = new Rectangle(10, 10, 50, 50);
				Rectangle rectBox = new Rectangle(10, 10, 200, 50);
				Rectangle rectText = new Rectangle(50, 25, 150, 25);
				renderer.DrawBackground(e.Graphics, rectCheck);
				renderer.DrawEdge(e.Graphics, rectBox, 
					Edges.Bottom | Edges.Top | Edges.Left | Edges.Right,
					EdgeStyle.Etched, EdgeEffects.Flat);
				renderer.DrawText(e.Graphics, rectText, "Styled checkbox", false, TextFormatFlags.Top);
			}
			else
			{
				// (Perform ControlPaint drawing here.)
			}

		}
开发者ID:ehershey,项目名称:development,代码行数:23,代码来源:SimpleStyleRenderer.cs

示例5: OnPaint

			protected override void OnPaint(PaintEventArgs e)
			{
				var normal = VisualStyleElement.ToolTip.Standard.Normal;
				if (Application.RenderWithVisualStyles && VisualStyleRenderer.IsElementDefined(normal))
				{
					var renderer = new VisualStyleRenderer(normal);
					renderer.DrawBackground(e.Graphics, ClientRectangle);
					var textExtent = renderer.GetTextExtent(e.Graphics, ClientRectangle, Text, _tfFlags);
					textExtent.X = ClientRectangle.X + ClientRectangle.Width / 2 - textExtent.Width / 2;
					textExtent.Y = ClientRectangle.Y + ClientRectangle.Height / 2 - textExtent.Height / 2;
					renderer.DrawText(e.Graphics, textExtent, Text, false, _tfFlags);
					return;
				}
				e.Graphics.FillRectangle(SystemBrushes.Info, ClientRectangle);
				var pen = SystemInformation.HighContrast ? SystemPens.InfoText : SystemPens.Control;
				e.Graphics.DrawLine(pen, ClientRectangle.Left, ClientRectangle.Top, ClientRectangle.Right, ClientRectangle.Top);
				e.Graphics.DrawLine(pen, ClientRectangle.Left, ClientRectangle.Top, ClientRectangle.Left, ClientRectangle.Bottom);
				e.Graphics.DrawLine(SystemPens.InfoText, ClientRectangle.Left, ClientRectangle.Bottom - 1, ClientRectangle.Right, ClientRectangle.Bottom - 1);
				e.Graphics.DrawLine(SystemPens.InfoText, ClientRectangle.Right - 1, ClientRectangle.Top, ClientRectangle.Right - 1, ClientRectangle.Bottom);
				var crect = ClientRectangle;
				crect.Inflate(-2, -2);
				TextRenderer.DrawText(e.Graphics, Text, Font, crect, SystemColors.InfoText, _tfFlags);
			}
开发者ID:javagg,项目名称:DemoDock,代码行数:23,代码来源:ToolTips.cs


注:本文中的System.Windows.Forms.VisualStyles.VisualStyleRenderer.DrawText方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。