本文整理汇总了C#中Styles.Convert方法的典型用法代码示例。如果您正苦于以下问题:C# Styles.Convert方法的具体用法?C# Styles.Convert怎么用?C# Styles.Convert使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Styles
的用法示例。
在下文中一共展示了Styles.Convert方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: DrawLabel
/// <summary>
/// Renders a label to the map.
/// </summary>
/// <param name="graphics">Graphics reference</param>
/// <param name="labelPoint">Label placement</param>
/// <param name="offset">Offset of label in screen coordinates</param>
/// <param name="font">Font used for rendering</param>
/// <param name="forecolor">Font forecolor</param>
/// <param name="backcolor">Background color</param>
/// <param name="halo">Color of halo</param>
/// <param name="rotation">Text rotation in degrees</param>
/// <param name="text">Text to render</param>
/// <param name="viewport"></param>
public static void DrawLabel(Graphics graphics, Point labelPoint, Styles.Offset offset, Styles.Font font, Styles.Color forecolor, Styles.Brush backcolor, Styles.Pen halo, double rotation, string text, IViewport viewport)
{
SizeF fontSize = graphics.MeasureString(text, font.Convert()); //Calculate the size of the text
labelPoint.X += offset.X; labelPoint.Y += offset.Y; //add label offset
if (rotation != 0 && !double.IsNaN(rotation))
{
graphics.TranslateTransform((float)labelPoint.X, (float)labelPoint.Y);
graphics.RotateTransform((float)rotation);
graphics.TranslateTransform(-fontSize.Width / 2, -fontSize.Height / 2);
if (backcolor != null && backcolor.Convert() != Brushes.Transparent)
graphics.FillRectangle(backcolor.Convert(), 0, 0, fontSize.Width * 0.74f + 1f, fontSize.Height * 0.74f);
var path = new GraphicsPath();
path.AddString(text, new FontFamily(font.FontFamily), (int)font.Convert().Style, font.Convert().Size, new System.Drawing.Point(0, 0), null);
if (halo != null)
graphics.DrawPath(halo.Convert(), path);
graphics.FillPath(new SolidBrush(forecolor.Convert()), path);
//g.DrawString(text, font, new System.Drawing.SolidBrush(forecolor), 0, 0);
}
else
{
if (backcolor != null && backcolor.Convert() != Brushes.Transparent)
graphics.FillRectangle(backcolor.Convert(), (float)labelPoint.X, (float)labelPoint.Y, fontSize.Width * 0.74f + 1, fontSize.Height * 0.74f);
var path = new GraphicsPath();
//Arial hack
path.AddString(text, new FontFamily("Arial"), (int)font.Convert().Style, (float)font.Size, new System.Drawing.Point((int)labelPoint.X, (int)labelPoint.Y), null);
if (halo != null)
graphics.DrawPath(halo.Convert(), path);
graphics.FillPath(new SolidBrush(forecolor.Convert()), path);
//g.DrawString(text, font, new System.Drawing.SolidBrush(forecolor), LabelPoint.X, LabelPoint.Y);
}
}