Ejemplo n.º 1
0
 /// <summary>
 /// Draws a line.
 /// </summary>
 /// <param name="pen">The stroke pen.</param>
 /// <param name="p1">The first point of the line.</param>
 /// <param name="p1">The second point of the line.</param>
 public void DrawLine(Pen pen, Perspex.Point p1, Perspex.Point p2)
 {
     this.SetBrush(pen.Brush);
     this.context.LineWidth = pen.Thickness;
     this.context.MoveTo(p1.ToCairo());
     this.context.LineTo(p2.ToCairo());
     this.context.Stroke();
 }
Ejemplo n.º 2
0
 /// <summary>
 /// Draws a line.
 /// </summary>
 /// <param name="pen">The stroke pen.</param>
 /// <param name="p1">The first point of the line.</param>
 /// <param name="p1">The second point of the line.</param>
 public void DrawLine(Pen pen, Perspex.Point p1, Perspex.Point p2)
 {
     if (pen != null)
     {
         using (var d2dBrush = pen.Brush.ToDirect2D(this.renderTarget))
         {
             this.renderTarget.DrawLine(p1.ToSharpDX(), p2.ToSharpDX(), d2dBrush);
         }
     }
 }
Ejemplo n.º 3
0
 /// <summary>
 /// Draws a line.
 /// </summary>
 /// <param name="pen">The stroke pen.</param>
 /// <param name="p1">The first point of the line.</param>
 /// <param name="p1">The second point of the line.</param>
 public void DrawLine(Pen pen, Perspex.Point p1, Perspex.Point p2)
 {
     if (pen != null)
     {
         using (SharpDX.Direct2D1.SolidColorBrush d2dBrush = this.Convert(pen.Brush))
         {
             this.renderTarget.DrawLine(p1.ToSharpDX(), p2.ToSharpDX(), d2dBrush);
         }
     }
 }
Ejemplo n.º 4
0
        /// <summary>
        /// Draws text.
        /// </summary>
        /// <param name="foreground">The foreground brush.</param>
        /// <param name="origin">The upper-left corner of the text.</param>
        /// <param name="text">The text.</param>
        public void DrawText(Perspex.Media.Brush foreground, Perspex.Point origin, FormattedText text)
        {
            if (!string.IsNullOrEmpty(text.Text))
            {
                var impl = (FormattedTextImpl)text.PlatformImpl;

                using (var renderer = new PerspexTextRenderer(this.renderTarget, foreground.ToDirect2D(this.renderTarget)))
                {
                    impl.TextLayout.Draw(renderer, (float)origin.X, (float)origin.Y);
                }
            }
        }
Ejemplo n.º 5
0
 public static Vector2 ToSharpDX(this Perspex.Point p)
 {
     return(new Vector2((float)p.X, (float)p.Y));
 }