Ejemplo n.º 1
0
 public void SaveTo(DroidContext c, bool p)
 {
     c.Font     = this.Font;
     c.LineDash = this.LineDash;
     c.Current  = this.Current;
     //c.Canvas = this.Canvas;
     c.Pattern = this.Pattern;
 }
        public override object CreateContext(object backend)
        {
            var b   = (DroidImage)backend;
            var ctx = new DroidContext {
                Canvas = new Android.Graphics.Canvas(b.Image)
            };

            return(ctx);
        }
        public virtual object CreateContext(Widget w)
        {
            var b = (IDroidCanvasBackend)w.GetBackend();

            var ctx = new DroidContext();

            if (b.Context != null)
            {
                ctx.Canvas = b.Context.Canvas;
            }
            return(ctx);
        }
Ejemplo n.º 4
0
        public static Context XwtContext(this AG.Canvas canvas, bool doscale)
        {
            var dc = new DroidContext {
                Canvas = canvas
            };
            var context = new Context(dc, Toolkit.CurrentEngine);

            if (doscale)
            {
                var scale = Desktop.PrimaryScreen.ScaleFactor;
                context.Scale(scale, scale);
            }
            return(context);
        }
Ejemplo n.º 5
0
        public object ConvertToBitmap(double width, double height, double scaleFactor, ImageFormat format)
        {
            if (_drawCallback != null)
            {
                var image = new DroidImage((int)width, (int)height, format);
                using (var canvas = new AG.Canvas(image.Image))
                    using (var dc = new DroidContext {
                        Canvas = canvas
                    }) {
                        canvas.Scale((float)scaleFactor, (float)scaleFactor);
                        _drawCallback(dc, new Xwt.Rectangle(0, 0, width, height));
                    }
                return(image);
            }

            throw new NotSupportedException();
        }
Ejemplo n.º 6
0
 public DroidContext(DroidContext c)
     : this()
 {
     c.SaveTo(this, false);
 }