本文整理汇总了C#中Media.GetType方法的典型用法代码示例。如果您正苦于以下问题:C# Media.GetType方法的具体用法?C# Media.GetType怎么用?C# Media.GetType使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Media
的用法示例。
在下文中一共展示了Media.GetType方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: DrawText
/// <summary>
/// Draws the specified text
/// </summary>
/// <param name="text">The text to draw</param>
/// <param name="position">The position at which to start drawing the text</param>
/// <param name="font">The <see cref="System.Drawing.Font"/> of the text to draw</param>
/// <param name="brush">The <see cref="Media.Brush"/> with which to draw the text</param>
public void DrawText(string text, Media.Point position, Font font, Media.Brush brush)
{
Color color;
Bitmap bitmap;
Graphics graphics;
PointF textLocation;
OpenTK.Graphics.TextExtents textExtents;
if (string.IsNullOrWhiteSpace(text))
{
return;
}
if (!typeof(Media.SolidColorBrush).IsAssignableFrom(brush.GetType()))
{
throw new NotSupportedException("Only the SolidColorBrush type is currently supported as brush argument of the DrawingContext's 'DrawText' method");
}
color = ((Media.SolidColorBrush)brush).Color;
bitmap = new Bitmap(10, 10);
graphics = Graphics.FromImage(bitmap);
textLocation = position.ToPointF();
textExtents = DrawingContext.MeasureTextExtents(text, font);
DrawingContext.TextPrinter.Begin();
DrawingContext.TextPrinter.Print(text, font, color, new RectangleF(position.ToPointF().X, position.ToPointF().Y, textExtents.BoundingBox.Width * 1.5f, textExtents.BoundingBox.Height * 1.5f), OpenTK.Graphics.TextPrinterOptions.Default, OpenTK.Graphics.TextAlignment.Near);
DrawingContext.TextPrinter.End();
}