本文整理汇总了C#中System.Drawing.PointF.ToSharpDX方法的典型用法代码示例。如果您正苦于以下问题:C# System.Drawing.PointF.ToSharpDX方法的具体用法?C# System.Drawing.PointF.ToSharpDX怎么用?C# System.Drawing.PointF.ToSharpDX使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类System.Drawing.PointF
的用法示例。
在下文中一共展示了System.Drawing.PointF.ToSharpDX方法的5个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: FillRectangle
/// <summary>
/// Paints the interior of the specified rectangle with a smooth color gradient</summary>
/// <param name="rect">Rectangle to paint, in pixels</param>
/// <param name="pt1">The point, in pixels, that color1 gets mapped to</param>
/// <param name="pt2">The point, in pixels, that color2 gets mapped to</param>
/// <param name="color1">The color to use at the first point</param>
/// <param name="color2">The color to use at the second point</param>
/// <remarks>Note that each color combination is used to create a brush that
/// is cached, so you cannot use an unlimited number of color combinations.</remarks>
public void FillRectangle(RectangleF rect, PointF pt1, PointF pt2, Color color1, Color color2)
{
var brush = GetCachedLinearGradientBrush(color1, color2);
brush.StartPoint = pt1.ToSharpDX();
brush.EndPoint = pt2.ToSharpDX();
m_renderTarget.FillRectangle(rect.ToSharpDX(), brush);
}
示例2: DrawTextLayout
/// <summary>
/// Draws the formatted text described by the specified D2dTextLayout</summary>
/// <param name="origin">The point, described in pixels, at which the upper-left
/// corner of the text described by textLayout is drawn</param>
/// <param name="textLayout">The formatted text to draw</param>
/// <param name="brush">The brush used to paint any text in textLayout
/// that does not already have a brush associated with it as a drawing effect</param>
public void DrawTextLayout(PointF origin, D2dTextLayout textLayout, D2dBrush brush)
{
m_renderTarget.DrawTextLayout(
origin.ToSharpDX(),
textLayout.NativeTextLayout,
brush.NativeBrush,
(DrawTextOptions)textLayout.DrawTextOptions);
}
示例3: DrawLine
/// <summary>
/// Draws a line between the specified points</summary>
/// <param name="pt1">The start point of the line, in pixels</param>
/// <param name="pt2">The end point of the line, in pixels</param>
/// <param name="brush">The brush used to paint the line's stroke</param>
/// <param name="strokeWidth">A value greater than or equal to 0.0f that specifies the width of the stroke</param>
/// <param name="strokeStyle">The style of stroke to paint, or NULL to paint a solid line</param>
public void DrawLine(PointF pt1, PointF pt2, D2dBrush brush, float strokeWidth = 1.0f, D2dStrokeStyle strokeStyle = null)
{
m_renderTarget.DrawLine(pt1.ToSharpDX(), pt2.ToSharpDX(),
brush.NativeBrush, strokeWidth,
strokeStyle != null ? strokeStyle.NativeStrokeStyle : null);
}
示例4: DrawText
/// <summary>
/// Draws the specified text using the format information provided at the specified location</summary>
/// <param name="text">The text string to draw</param>
/// <param name="textFormat">The text format object to use</param>
/// <param name="upperLeft">Upper left corner of the text</param>
/// <param name="brush">The brush to use to draw the text</param>
public void DrawText(string text, D2dTextFormat textFormat, PointF upperLeft, D2dBrush brush)
{
var rtsize = Size;
using (var layout
= new SharpDX.DirectWrite.TextLayout(D2dFactory.NativeDwFactory,
text, textFormat.NativeTextFormat, rtsize.Width, rtsize.Height))
{
layout.TextAlignment = SharpDX.DirectWrite.TextAlignment.Leading;
layout.ParagraphAlignment = SharpDX.DirectWrite.ParagraphAlignment.Near;
if (textFormat.Underlined)
layout.SetUnderline(true,new SharpDX.DirectWrite.TextRange(0, text.Length));
if (textFormat.Strikeout)
layout.SetStrikethrough(true,new SharpDX.DirectWrite.TextRange(0, text.Length));
m_renderTarget.DrawTextLayout(upperLeft.ToSharpDX(),
layout,
brush.NativeBrush,
(DrawTextOptions)textFormat.DrawTextOptions);
}
}
示例5: DrawBezier
/// <summary>
/// Draws a Bézier spline defined by four System.Drawing.PointF structures</summary>
/// <param name="pt1">Represents the starting point of the curve</param>
/// <param name="pt2">Represents the first control point for the curve</param>
/// <param name="pt3">Represents the second control point for the curve</param>
/// <param name="pt4">Represents the ending point of the curve</param>
/// <param name="brush">The brush used to paint the curve's stroke</param>
/// <param name="strokeWidth">The thickness of the geometry's stroke. The stroke is centered on the geometry's outline.</param>
/// <param name="strokeStyle">The style of stroke to apply to the geometry's outline or null to draw a solid line</param>
public void DrawBezier(PointF pt1, PointF pt2, PointF pt3, PointF pt4, D2dBrush brush, float strokeWidth = 1.0f, D2dStrokeStyle strokeStyle = null)
{
using (var geom = new PathGeometry(D2dFactory.NativeFactory))
{
var sink = geom.Open();
sink.BeginFigure(pt1.ToSharpDX(), FigureBegin.Hollow);
var seg = new BezierSegment
{
Point1 = pt2.ToSharpDX(),
Point2 = pt3.ToSharpDX(),
Point3 = pt4.ToSharpDX()
};
sink.AddBezier(seg);
sink.EndFigure(FigureEnd.Open);
sink.Close();
sink.Dispose();
var stroke = strokeStyle == null ? null : strokeStyle.NativeStrokeStyle;
m_renderTarget.DrawGeometry(geom, brush.NativeBrush, strokeWidth, stroke);
}
}