本文整理汇总了C#中System.Drawing.Graphics.DrawShadow方法的典型用法代码示例。如果您正苦于以下问题:C# Graphics.DrawShadow方法的具体用法?C# Graphics.DrawShadow怎么用?C# Graphics.DrawShadow使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类System.Drawing.Graphics
的用法示例。
在下文中一共展示了Graphics.DrawShadow方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: OnDraw
// Protected methods.
/// <summary>
/// An event handler called when drawing the annotation on the specified graphics object.
/// </summary>
/// <param name="graphics">The graphics object.</param>
protected override void OnDraw(Graphics graphics)
{
// If the message is not visible, do nothing.
if (!this.Visible) return;
// Use a normal smoothing mode.
graphics.SmoothingMode = SmoothingMode.HighQuality;
// Create the pen.
using (Pen pen = new Pen(this.BorderColor))
{
// Create the brush.
using (SolidBrush brush = new SolidBrush(this.BackgroundColor))
{
// Draw the shadow.
graphics.DrawShadow(this.Shadow, this.textRectangle);
// Draw the polygon.
graphics.FillPolygon(brush, this.polygon);
// Draw the border.
graphics.DrawPolygon(pen, this.polygon);
}
}
// Display a message.
TextRenderer.DrawText(graphics, this.Text, this.Font, this.textRectangle, this.TextColor, TextFormatFlags.HorizontalCenter | TextFormatFlags.VerticalCenter);
}
示例2: OnDraw
/// <summary>
/// An event handler called when drawing the annotation on the specified graphics object.
/// </summary>
/// <param name="graphics">The graphics object.</param>
protected override void OnDraw(Graphics graphics)
{
// Call the base class method.
base.OnDraw(graphics);
// If the message is not visible, do nothing.
if (!this.Visible) return;
// Use a normal smoothing mode.
graphics.SmoothingMode = SmoothingMode.Default;
// Create the pen.
using (Pen pen = new Pen(this.borderColor))
{
// Create the brush.
using (SolidBrush brush = new SolidBrush(this.backgroundColor))
{
// Draw the shadow.
graphics.DrawShadow(this.shadow, this.BorderRectangle);
// Draw the rectangle.
graphics.FillRectangle(brush, this.BorderRectangle);
// Draw the border.
graphics.DrawRectangle(pen, this.BorderRectangle);
}
}
// Display a message.
TextRenderer.DrawText(graphics, this.text, this.font, this.BorderRectangle, this.textColor, TextFormatFlags.HorizontalCenter | TextFormatFlags.VerticalCenter);
}
示例3: DrawText
protected static void DrawText(Graphics g, Rectangle rect, string text, ContentAlignmentEx alignment, bool multiline, Font font, Color color, Color shadow, ShadowMask mask)
{
if (multiline == false)
{
var rc = alignment.CalcTextRect(g.MeasureString(text, font), rect);
if (mask != ShadowMask.None)
{
g.DrawShadow(text, font, shadow, rc.X, rc.Y, mask);
}
using (var brush = new SolidBrush(color))
{
g.DrawString(text, font, brush, rc.X, rc.Y);
}
}
else
{
var texts = g.GetMultilineText(text, font, rect.Width);
var textSize = g.CalcMultilineTextSize(texts, font);
var rc = alignment.CalcTextRect(textSize, rect);
using (var brush = new SolidBrush(color))
{
var top = rc.Top;
foreach (var line in texts)
{
var size = g.MeasureString(String.IsNullOrEmpty(line) ? " " : line, font);
var rcLine = alignment.CalcTextRect(size, rc.Left, top, rc.Width, size.Height);
if (mask != ShadowMask.None)
{
g.DrawShadow(text, font, shadow, rcLine.X, rcLine.Y, mask);
}
g.DrawString(line, font, brush, rcLine.X, rcLine.Y);
top += rcLine.Height;
}
}
}
}