/// <Docs>The Canvas to which the View is rendered.</Docs> /// <summary> /// Draw the specified canvas. /// </summary> /// <param name="canvas">Canvas.</param> public override void Draw(Android.Graphics.Canvas canvas) { if (Element == null) { base.Draw(canvas); return; } // Draws the background and default android setup. Children will also be redrawn here // base.Draw(canvas); // Set up clipping if (Element.IsClippedToBounds) { canvas.ClipRect(new Android.Graphics.Rect(0, 0, Width, Height)); } // Perform custom drawing from the NGraphics subsystems var ncanvas = new CanvasCanvas(canvas); var rect = new NGraphics.Rect(0, 0, Width, Height); // Fill background ncanvas.FillRectangle(rect, new NGraphics.Color(Element.BackgroundColor.R, Element.BackgroundColor.G, Element.BackgroundColor.B, Element.BackgroundColor.A)); // Custom drawing Element.Draw(ncanvas, rect); // Redraw children - since we might have a composite control containing both children // and custom drawing code, we want children to be drawn last. The reason for this double- // drawing is that the base.Draw(canvas) call will handle background which is needed before // doing NGraphics drawing - but unfortunately it also draws children - which then will // be drawn below NGraphics drawings. base.Draw(canvas); }
/// <Docs>The Canvas to which the View is rendered.</Docs> /// <summary> /// Draw the specified canvas. /// </summary> /// <param name="canvas">Canvas.</param> public override void Draw(Android.Graphics.Canvas canvas) { if (Element == null) { base.Draw(canvas); return; } // Should we clip? if (Element.IsClippedToBounds) { canvas.ClipRect(new Android.Graphics.Rect(0, 0, Width, Height), Region.Op.Replace); } // Draws the background and default android setup. Children will also be redrawn here base.Draw(canvas); // Perform custom drawing from the NGraphics subsystems var ncanvas = new CanvasCanvas(canvas); var rect = new NGraphics.Rect(0, 0, Width, Height); Element.Draw(ncanvas, rect); // Redraw children - since we might have a composite control containing both children // and custom drawing code, we want children to be drawn last. The reason for this double- // drawing is that the base.Draw(canvas) call will handle background which is needed before // doing NGraphics drawing - but unfortunately it also draws children - which then will // be drawn below NGraphics drawings. for (var i = 0; i < ChildCount; i++) { GetChildAt(i).Draw(canvas); } }
protected override void OnDraw(Android.Graphics.Canvas canvasDroid) { base.OnDraw(canvasDroid); var canvas = new CanvasCanvas(canvasDroid); var rect = new NGraphics.Rect(GetX(), GetY(), Width, Height); this.Draw(canvas, rect); }
public override void Draw(global::Android.Graphics.Canvas canvas) { var c = new CanvasCanvas(canvas); if (GraphicView != null) { var r = new global::Android.Graphics.Rect(); canvas.GetClipBounds(r); GraphicView.Draw(c, new Rect(r.Left, r.Top, r.Width(), r.Height())); } }
/// <Docs>The Canvas to which the View is rendered.</Docs> /// <summary> /// Draw the specified canvas. /// </summary> /// <param name="canvas">Canvas.</param> public override void Draw(Android.Graphics.Canvas canvas) { // Should we clip? if (Element != null && Element.IsClippedToBounds) { canvas.ClipRect(new Android.Graphics.Rect(0, 0, Width, Height), Region.Op.Replace); } // Perform custom drawing var ncanvas = new CanvasCanvas(canvas); Element.Draw(ncanvas, new NGraphics.Rect(0, 0, Width, Height)); // Draw elements/children etc. base.Draw(canvas); }