Exemplo n.º 1
0
        /// <summary>
        /// Draws a point on the target. The coordinates given are scene coordinates.
        /// </summary>
        /// <param name="target"></param>
        /// <param name="x">The x coordinate.</param>
        /// <param name="y">The y coordinate.</param>
        /// <param name="color">Color.</param>
        /// <param name="size">Size.</param>
        protected override void DrawPoint(Target2DWrapper <RenderContext> target, double x, double y, int color, double size)
        {
            size = ToPixels(size);
            var center = Tranform(x, y, -size / 2.0d, -size / 2.0d);

            target.Render().DrawPoint(center, size, size, color.ToColor());
        }
Exemplo n.º 2
0
        /// <summary>
        /// Draws text.
        /// </summary>
        /// <param name="target"></param>
        /// <param name="x"></param>
        /// <param name="y"></param>
        /// <param name="text"></param>
        /// <param name="color"></param>
        /// <param name="size"></param>
        /// <param name="haloColor"></param>
        /// <param name="haloRadius"></param>
        /// <param name="fontName"></param>
        protected override void DrawText(Target2DWrapper <RenderContext> target, double x, double y, string text, int color, double size,
                                         int?haloColor, int?haloRadius, string fontName)
        {
            size = ToPixels(size);
            var point = Tranform(x, y);

            target.Render().DrawText(text, point, new Typeface(fontName), size, color.ToColor(), haloColor.ToColor(), haloRadius);
        }
Exemplo n.º 3
0
        /// <summary>
        /// Draws a polygon on the target. The coordinates given are scene coordinates.
        /// </summary>
        /// <param name="target"></param>
        /// <param name="x">The x coordinate.</param>
        /// <param name="y">The y coordinate.</param>
        /// <param name="color">Color.</param>
        /// <param name="width">Width.</param>
        /// <param name="fill">If set to <c>true</c> fill.</param>
        protected override void DrawPolygon(Target2DWrapper <RenderContext> target, double[] x, double[] y, int color,
                                            double width, bool fill)
        {
            width = ToPixels(width);
            var points = new Point[x.Length];

            for (var idx = 0; idx < x.Length; idx++)
            {
                points[idx] = Tranform(x[idx], y[idx]);
            }
            target.Render().DrawPolygon(points, width, color.ToColor(), fill);
        }
Exemplo n.º 4
0
        /// <summary>
        /// Draws a line on the target. The coordinates given are scene coordinates.
        /// </summary>
        /// <param name="target"></param>
        /// <param name="x">The x coordinate.</param>
        /// <param name="y">The y coordinate.</param>
        /// <param name="color">Color.</param>
        /// <param name="width">Width.</param>
        /// <param name="lineJoin"></param>
        /// <param name="dashes"></param>
        protected override void DrawLine(Target2DWrapper <RenderContext> target, double[] x, double[] y, int color, double width,
                                         LineJoin lineJoin, int[] dashes)
        {
            width = ToPixels(width);
            var points = new Point[x.Length];

            for (var idx = 0; idx < x.Length; idx++)
            {
                points[idx] = Tranform(x[idx], y[idx]);
            }
            target.Render().DrawLine(points, width, color.ToColor(), PenLineCap.Round, PenLineCap.Round,
                                     lineJoin.ToPenLineJoin(), dashes.ToDashStyle(0));
        }
Exemplo n.º 5
0
 /// <summary>
 /// Draws text along a line.
 /// </summary>
 /// <param name="target"></param>
 /// <param name="x"></param>
 /// <param name="y"></param>
 /// <param name="text"></param>
 /// <param name="color"></param>
 /// <param name="size"></param>
 /// <param name="haloColor"></param>
 /// <param name="haloRadius"></param>
 /// <param name="fontName"></param>
 protected override void DrawLineText(Target2DWrapper <RenderContext> target, double[] x, double[] y, string text, int color,
                                      double size, int?haloColor, int?haloRadius, string fontName)
 {
     if (x.Length > 1)
     {
         size = ToPixels(size);
         var points = new Point[x.Length];
         for (var idx = 0; idx < x.Length; idx++)
         {
             points[idx] = Tranform(x[idx], y[idx]);
         }
         target.Render().DrawTextLine(text, points, new Typeface(fontName), size, color.ToColor(), haloColor.ToColor(), haloRadius);
     }
 }
Exemplo n.º 6
0
        /// <summary>
        /// Draws an icon unscaled but at the given scene coordinates.
        /// </summary>
        /// <param name="target"></param>
        /// <param name="x"></param>
        /// <param name="y"></param>
        /// <param name="imageData"></param>
        protected override void DrawIcon(Target2DWrapper <RenderContext> target, double x, double y, byte[] imageData)
        {
            using (var stream = new MemoryStream(imageData))
            {
                var imageSource = new BitmapImage();
                imageSource.BeginInit();
                imageSource.CacheOption  = BitmapCacheOption.OnLoad;
                imageSource.StreamSource = stream;
                imageSource.EndInit();

                var leftTop = Tranform(x, y);
                leftTop.Offset(-imageSource.Width / 2, -imageSource.Height / 2);
                target.Render().DrawImage(leftTop, imageSource);
            }
        }
Exemplo n.º 7
0
        /// <summary>
        /// Draws an image.
        /// </summary>
        /// <param name="target"></param>
        /// <param name="left"></param>
        /// <param name="top"></param>
        /// <param name="right"></param>
        /// <param name="bottom"></param>
        /// <param name="nativeImage"></param>
        protected override void DrawImage(Target2DWrapper <RenderContext> target, double left, double top, double right,
                                          double bottom, INativeImage nativeImage)
        {
            var wpfNativeImage = nativeImage as NativeImage;

            if (wpfNativeImage != null)
            {
                var leftTop     = Tranform(left, top);
                var rightBottom = Tranform(right, bottom);
                var width       = rightBottom.X - leftTop.X;
                var height      = rightBottom.Y - leftTop.Y;

                var destRect = new Rect(leftTop, new Size(width, height));
                target.Render().DrawImage(destRect, wpfNativeImage.Image);
            }
        }
Exemplo n.º 8
0
 /// <summary>
 /// Draws the backcolor.
 /// </summary>
 /// <param name="target"></param>
 /// <param name="backColor"></param>
 protected override void DrawBackColor(Target2DWrapper <RenderContext> target, int backColor)
 {
     target.Render().DrawRectangle(backColor.ToBrush(), null, target.Target.RenderRect);
 }