/// <summary> /// Creates a TextLayout with the specified parameter</summary> /// <param name="text">The string to create a new D2dTextLayout object from</param> /// <param name="textFormat">The text format to apply to the string</param> /// <param name="layoutWidth">Text layout width</param> /// <param name="layoutHeight">Text layout height</param> /// <param name="transform">2D Matrix used to transform the text</param> /// <returns>A new instance of D2dTextLayout</returns> public static D2dTextLayout CreateTextLayout(string text, D2dTextFormat textFormat, float layoutWidth, float layoutHeight, Matrix3x2F transform) { var matrix = Matrix.Identity; matrix.M11 = transform.M11; matrix.M12 = transform.M12; matrix.M21 = transform.M21; matrix.M22 = transform.M22; matrix.M31 = transform.DX; matrix.M32 = transform.DY; var textlayout = new TextLayout(s_dwFactory, text, textFormat.NativeTextFormat, layoutWidth, layoutHeight, 1, matrix, true); if (textFormat.Underlined) { textlayout.SetUnderline(true, new SharpDX.DirectWrite.TextRange(0, text.Length)); } if (textFormat.Strikeout) { textlayout.SetStrikethrough(true, new SharpDX.DirectWrite.TextRange(0, text.Length)); } var d2dTextLayout = new D2dTextLayout(text, textlayout); d2dTextLayout.DrawTextOptions = textFormat.DrawTextOptions; return(d2dTextLayout); }
/// <summary> /// Creates a TextLayout with the specified parameter</summary> /// <param name="text">The string to create a new D2dTextLayout object from</param> /// <param name="textFormat">The text format to apply to the string</param> /// <param name="layoutWidth">Text layout width</param> /// <param name="layoutHeight">Text layout height</param> /// <returns>A new instance of D2dTextLayout</returns> public static D2dTextLayout CreateTextLayout(string text, D2dTextFormat textFormat, float layoutWidth, float layoutHeight) { var textlayout = new TextLayout(s_dwFactory, text, textFormat.NativeTextFormat, layoutWidth, layoutHeight); if (textFormat.Underlined) { textlayout.SetUnderline(true, new SharpDX.DirectWrite.TextRange(0, text.Length)); } if (textFormat.Strikeout) { textlayout.SetStrikethrough(true, new SharpDX.DirectWrite.TextRange(0, text.Length)); } var d2dTextLayout = new D2dTextLayout(text, textlayout); d2dTextLayout.DrawTextOptions = textFormat.DrawTextOptions; return(d2dTextLayout); }
/// <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="color">The color 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, Color color) { m_solidColorBrush.Color = color; DrawTextLayout(origin, textLayout, m_solidColorBrush); }
/// <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); }
/// <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( new DrawingPointF(origin.X, origin.Y), textLayout.NativeTextLayout, brush.NativeBrush, (DrawTextOptions)textLayout.DrawTextOptions); }