private void Draw() { if (Holder.IsCreating || _destroyed) { return; } Canvas canvas = null; try { canvas = Holder.LockCanvas(); var density = Resources.DisplayMetrics.Density; var canvasSize = new UGSize(Width / density, Height / density); using (var ugContext = new UGContext(canvas, canvasSize, density)) { canvas.Scale(density, density); DrawOverride(ugContext); } } finally { if (canvas != null) { Holder.UnlockCanvasAndPost(canvas); } } }
protected sealed override void OnDraw(Canvas canvas) { base.OnDraw(canvas); var density = Resources.DisplayMetrics.Density; var canvasSize = new UGSize(Width / density, Height / density); using (var ugContext = new UGContext(canvas, canvasSize, density)) { canvas.Scale(density, density); DrawOverride(ugContext); } }