/// </summary>
        /// <param name="rect"></param>
        internal void flushGraphics(Rectangle rect)
        {
            using (System.Threading.AutoResetEvent are = new System.Threading.AutoResetEvent(false))
            {
                SilverlightImplementation.dispatcher.RunAsync(Windows.UI.Core.CoreDispatcherPriority.Normal, () =>
                {
                    IList<AsyncOp> tmp = renderingOperations;
                    renderingOperations = pendingRenderingOperations;
                    pendingRenderingOperations = tmp;

                    if (rect == null)
                    {
                        _screen.Invalidate();
                    }
                    else
                    {
                        _graphics.clip = rect;
                        _graphics.destination.setClip(rect);
                        _screen.Invalidate();
                    }
                    _graphics.destination.setAlpha(255);
                    _graphics.destination.setColor(0);
                    are.Set();
                }).AsTask().GetAwaiter().GetResult();
                are.WaitOne();
            }
        }
 public void setRawClip(ui.geom.Shape clip)
 {
     removeClip();
     if (clip == null)
     {
         return;
     }
     com.codename1.ui.geom.Rectangle bounds = clip.getBounds();
     if (bounds.getWidth() <= 0 || bounds.getHeight() <= 0)
     {
         layer = graphics.CreateLayer(1f, new Rect(
                                          bounds.getX(),
                                          bounds.getY(),
                                          1,
                                          1
                                          ));
         return;
     }
     if (clip.isRectangle())
     {
         layer = graphics.CreateLayer(1f, new Rect(
                                          bounds.getX(),
                                          bounds.getY(),
                                          bounds.getWidth(),
                                          bounds.getHeight()
                                          ));
         return;
     }
     layer = graphics.CreateLayer(1f, CanvasGeometry.CreatePath(SilverlightImplementation.instance.cn1ShapeToAndroidPath(clip)));
 }
 public DrawImagePainter(Rectangle clip, Microsoft.Graphics.Canvas.CanvasBitmap canvasBitmap, int x, int y, int alpha)
     : base(clip)
 {
     this.clip = clip;
     this.canvasBitmap = canvasBitmap;
     this.x = x;
     this.y = y;
     this.alpha = alpha;
 }
 public DrawRectPainter(Rectangle clip, int x, int y, int w, int h, int stroke, int color, int alpha) : base(clip)
 {
     this.clip = clip;
     this.x = x;
     this.y = y;
     this.w = w;
     this.h = h;
     this.stroke = stroke;
     this.color = color;
     this.alpha = alpha;
 }
 public DrawStringPainter(Rectangle clip, string str, int x, int y, Microsoft.Graphics.Canvas.Text.CanvasTextFormat font, int color, int alpha)
     : base(clip)
 {
     this.clip = clip;
     this.str = str;
     this.x = x;
     this.y = y;
     this.font = font;
     this.color = color;
     this.alpha = alpha;
 }
 public DrawLinePainter(Rectangle clip, int x1, int y1, int x2, int y2, int color, int alpha)
     : base(clip)
 {
     this.clip = clip;
     this.x1 = x1;
     this.y1 = y1;
     this.x2 = x2;
     this.y2 = y2;
     this.color = color;
     this.alpha = alpha;
 }
 public FillArcPainter(Rectangle clip, int x, int y, int w, int h, int color, int alpha, int startAngle, int arcAngle)
     : base(clip)
 {
     this.clip = clip;
     this.x = x;
     this.y = y;
     this.w = w;
     this.h = h;
     this.color = color;
     this.alpha = alpha;
     this.startAngle = startAngle;
     this.arcAngle = arcAngle;
 }
 public DrawRoundRectPainter(Rectangle clip, int x, int y, int w, int h, int color, int alpha, int arcW, int arcH)
     : base(clip)
 {
     this.clip = clip;
     this.x = x;
     this.y = y;
     this.w = w;
     this.h = h;
     this.color = color;
     this.alpha = alpha;
     this.arcW = arcW;
     this.arcH = arcH;
 }
        internal void flushGraphics(Rectangle rect)
        {
            //int counter = 0;
            //while (renderingOperations.Count() > 0)
            //{
            //    try
            //    {
            //        global::System.Threading.Tasks.Task.Run(() => global::System.Threading.Tasks.Task.Delay(global::System.TimeSpan.FromMilliseconds(5))).ConfigureAwait(false).GetAwaiter().GetResult();

            //        // don't let the EDT die here
            //        counter++;
            //        if (counter > 10)
            //        {
            //            Debug.WriteLine("Flush graphics timed out!!!");
            //            return;
            //        }
            //    }
            //    catch (System.Exception e)
            //    {
            //        global::System.Diagnostics.Debug.WriteLine(e);
            //    }
            //}

            using (System.Threading.AutoResetEvent are = new System.Threading.AutoResetEvent(false))
            {
                SilverlightImplementation.dispatcher.RunAsync(Windows.UI.Core.CoreDispatcherPriority.Normal, () =>
                {
                    IList<AsyncOp> tmp = renderingOperations;
                    renderingOperations = pendingRenderingOperations;
                    pendingRenderingOperations = tmp;

                    if (rect == null)
                    {
                        _screen.Invalidate();
                    }
                    else
                    {
                        _graphics.clip = rect;
                        _graphics.destination.setClip(rect);
                        _screen.Invalidate();
                    }
                    _graphics.destination.setAlpha(255);
                    _graphics.destination.setColor(0);
                    are.Set();
                }).AsTask().GetAwaiter().GetResult();
                are.WaitOne();
            }
        }
        internal virtual void setClipShape(ui.geom.Shape clip)
        {
            removeClip();
            if (clip == null)
            {
                return;
            }
            com.codename1.ui.geom.Rectangle bounds = clip.getBounds();
            if (bounds.getWidth() <= 0 || bounds.getHeight() <= 0)
            {
                setClip(bounds);
                return;
            }

            CanvasPathBuilder nativeShape = SilverlightImplementation.instance.cn1ShapeToAndroidPath(clip);

            layer = graphics.CreateLayer(1f, CanvasGeometry.CreatePath(nativeShape));
        }
 internal virtual void setClip(Rectangle clip)
 {
     if (clip == null)
     {
         return;
     }
     if (clip.getWidth() <= 0)
     {
         System.Diagnostics.Debug.WriteLine("aaaaaaaaaaaaaaaaaaaa width");
         clip.setWidth(1);
     }
     if (clip.getHeight() <= 0)
     {
         System.Diagnostics.Debug.WriteLine("aaaaaaaaaaaaaaaaaaaa height");
         clip.setHeight(1);
     }
     layer = graphics.CreateLayer(1, new Rect(
         clip.getX(),
         clip.getY(),
         clip.getWidth(),
         clip.getHeight()
     ));
 }
 public void resetClip()
 {
     Rectangle r = new Rectangle();
     r.@this(0, 0, Convert.ToInt32(SilverlightImplementation.screen.ActualWidth), Convert.ToInt32(SilverlightImplementation.screen.ActualHeight));
     clip = r;
 }
        public override void clipRect(java.lang.Object graphics, int x, int y, int w, int h) {

            NativeGraphics ng = (NativeGraphics)graphics;
            Rectangle clip = new Rectangle();
            clip.@this(x, y, w, h);
            if (ng.clip != null) {
                ng.clip = (Rectangle)clip.intersection(ng.clip);
            }
            else {
                Debug.WriteLine("clipRect nulo " + ng.destination);
                ng.clip = clip;
            }
            //Debug.WriteLine("clipRect " + x + " " + y + " " + w + " " + h);
        }
 public override void flushGraphics(int x, int y, int width, int height) {
     if (width <= 0 || height <= 0) return;
     Rectangle rect = new Rectangle();
     rect.@this(x, y, width, height);
     myView.flushGraphics(rect);
 }
 public override void clipRect(java.lang.Object n1, Rectangle n2) {
     base.clipRect(n1, n2);
 }
 internal override void setClip(Rectangle clip)
 {
     this.clip = clip;
 }
Exemple #17
0
 public AsyncOp(Rectangle clip)
 {
     this.clip = clip;
 }
 public ClearColorPainter(Rectangle clip, int color, int alpha) : base(clip)
 {
     this.clip = clip;
     this.color = color;
     this.alpha = alpha;
 }
 public override void setClip(java.lang.Object graphics, int clipX, int clipY, int clipW, int clipH) {
     NativeGraphics ng = (NativeGraphics)graphics;
     Rectangle clip = new Rectangle();
     clip.@this(clipX, clipY, clipW, clipH);
     ng.clip = clip;
     //Debug.WriteLine("setClip " + clipX + " " + clipY + " " + clipW + " " + clipH);
 }