Ejemplo n.º 1
0
 /// <summary>
 /// See base docs.
 /// </summary>
 /// <param name="brush"></param>
 /// <param name="x"></param>
 /// <param name="y"></param>
 /// <param name="width"></param>
 /// <param name="height"></param>
 public override void FillRectangle(VrsDrawing.IBrush brush, int x, int y, int width, int height)
 {
     GdiPlusLock.EnforceSingleThread(() => {
         if (brush is BrushWrapper brushWrapper)
         {
             NativeDrawingContext.FillRectangle(brushWrapper.NativeBrush, x, y, width, height);
         }
     });
 }
Ejemplo n.º 2
0
 /// <summary>
 /// See base docs.
 /// </summary>
 /// <param name="image"></param>
 /// <param name="x"></param>
 /// <param name="y"></param>
 public override void DrawImage(VrsDrawing.IImage image, int x, int y)
 {
     if (image is ImageWrapper imageWrapper)
     {
         GdiPlusLock.EnforceSingleThread(() => {
             NativeDrawingContext.DrawImage(
                 imageWrapper.NativeImage,
                 x, y
                 );
         });
     }
 }
Ejemplo n.º 3
0
 /// <summary>
 /// See base docs.
 /// </summary>
 /// <param name="pen"></param>
 /// <param name="fromX"></param>
 /// <param name="fromY"></param>
 /// <param name="toX"></param>
 /// <param name="toY"></param>
 public override void DrawLine(VrsDrawing.IPen pen, int fromX, int fromY, int toX, int toY)
 {
     if (pen is PenWrapper penWrapper)
     {
         GdiPlusLock.EnforceSingleThread(() => {
             NativeDrawingContext.DrawLine(
                 penWrapper.NativePen,
                 fromX, fromY,
                 toX, toY
                 );
         });
     }
 }
Ejemplo n.º 4
0
        /// <summary>
        /// See base docs.
        /// </summary>
        /// <param name="text"></param>
        /// <param name="font"></param>
        /// <param name="fillBrush"></param>
        /// <param name="outlinePen"></param>
        /// <param name="x"></param>
        /// <param name="y"></param>
        /// <param name="alignment"></param>
        /// <param name="preferSpeedOverQuality"></param>
        public override void DrawText(string text, VrsDrawing.IFont font, VrsDrawing.IBrush fillBrush, VrsDrawing.IPen outlinePen, float x, float y, VrsDrawing.HorizontalAlignment alignment, bool preferSpeedOverQuality = true)
        {
            if (font is FontWrapper fontWrapper)
            {
                GdiPlusLock.EnforceSingleThread(() => {
                    var location = new PointF(x, y);

                    // Mono ignores these flags...
                    var stringFormat = new StringFormat()
                    {
                        Alignment     = Convert.ToSystemDrawingStringAlignment(alignment),
                        LineAlignment = Convert.ToSystemDrawingStringAlignment(alignment),
                        FormatFlags   = StringFormatFlags.NoWrap,
                    };

                    using (var graphicsPath = new GraphicsPath()) {
                        graphicsPath.AddString(
                            text,
                            fontWrapper.NativeFont.FontFamily,
                            (int)fontWrapper.NativeFont.Style,
                            fontWrapper.NativeFont.Size,
                            location,
                            stringFormat
                            );

                        NativeDrawingContext.SmoothingMode     = SmoothingMode.AntiAlias;
                        NativeDrawingContext.InterpolationMode = InterpolationMode.HighQualityBicubic;

                        if (outlinePen is PenWrapper outlinePenWrapper)
                        {
                            NativeDrawingContext.DrawPath(outlinePenWrapper.NativePen, graphicsPath);
                        }
                        if (fillBrush is BrushWrapper fillBrushWrapper)
                        {
                            NativeDrawingContext.FillPath(fillBrushWrapper.NativeBrush, graphicsPath);
                        }
                    }
                });
            }
        }