Exemple #1
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);
                }
            }
        }
Exemple #2
0
 /// <summary>
 /// Draws a filled rectangle.
 /// </summary>
 /// <param name="brush">The brush.</param>
 /// <param name="rect">The rectangle bounds.</param>
 public void FillRectange(Perspex.Media.Brush brush, Rect rect)
 {
     using (var b = brush.ToDirect2D(this.renderTarget))
     {
         this.renderTarget.FillRectangle(
             new RectangleF(
                 (float)rect.X,
                 (float)rect.Y,
                 (float)rect.Width,
                 (float)rect.Height),
             b);
     }
 }
Exemple #3
0
        /// <summary>
        /// Draws a geometry.
        /// </summary>
        /// <param name="brush">The fill brush.</param>
        /// <param name="pen">The stroke pen.</param>
        /// <param name="geometry">The geometry.</param>
        public void DrawGeometry(Perspex.Media.Brush brush, Perspex.Media.Pen pen, Perspex.Media.Geometry geometry)
        {
            if (brush != null)
            {
                using (var d2dBrush = brush.ToDirect2D(this.renderTarget))
                {
                    GeometryImpl impl = (GeometryImpl)geometry.PlatformImpl;
                    this.renderTarget.FillGeometry(impl.Geometry, d2dBrush);
                }
            }

            if (pen != null)
            {
                using (var d2dBrush = pen.Brush.ToDirect2D(this.renderTarget))
                {
                    GeometryImpl impl = (GeometryImpl)geometry.PlatformImpl;
                    this.renderTarget.DrawGeometry(impl.Geometry, d2dBrush, (float)pen.Thickness);
                }
            }
        }