/// <summary> /// Draws the content of the control. /// </summary> /// <param name="canvas">The canvas to draw on.</param> protected override void OnDraw(Canvas canvas) { base.OnDraw(canvas); var actualModel = this.ActualModel; if (actualModel == null) { return; } if (actualModel.Background.IsVisible()) { canvas.DrawColor(actualModel.Background.ToColor()); } else { // do nothing } lock (this.invalidateLock) { if (this.isModelInvalidated) { ((IPlotModel)actualModel).Update(this.updateDataFlag); this.updateDataFlag = false; this.isModelInvalidated = false; } } lock (this.renderingLock) { if (this.rc == null) { var displayMetrics = this.Context.Resources.DisplayMetrics; // The factors for scaling to Android's DPI and SPI units. // The density independent pixel is equivalent to one physical pixel // on a 160 dpi screen (baseline density) this.Scale = displayMetrics.Density; this.rc = new CanvasRenderContext(Scale, displayMetrics.ScaledDensity); } this.rc.SetTarget(canvas); ((IPlotModel)actualModel) .Render ( this.rc , //2019-01-09 //new OxyRect(0, 0, 200, 200) new OxyRect(0, 0, Width / Scale, Height / Scale) //Width / Scale, Height / Scale ); } }
/// <summary> /// Draws the content of the control. /// </summary> /// <param name="canvas">The canvas to draw on.</param> protected override void OnDraw(Canvas canvas) { base.OnDraw(canvas); var actualModel = this.ActualModel; if (actualModel == null) { return; } if (!actualModel.Background.IsUndefined()) { canvas.DrawColor(actualModel.Background.ToColor()); } else { // Use white as default background color canvas.DrawColor(Color.White); } lock (this.invalidateLock) { if (this.isModelInvalidated) { ((IPlotModel)actualModel).Update(this.updateDataFlag); this.updateDataFlag = false; this.isModelInvalidated = false; } } lock (this.renderingLock) { if (this.rc == null) { this.rc = new CanvasRenderContext(Scale); } this.rc.SetTarget(canvas); using (var bounds = new Rect()) { canvas.GetClipBounds(bounds); var width = bounds.Right - bounds.Left; var height = bounds.Bottom - bounds.Top; ((IPlotModel)actualModel).Render(this.rc, width / Scale, height / Scale); } } }
/// <summary> /// Draws the content of the control. /// </summary> /// <param name="canvas">The canvas to draw on.</param> protected override void OnDraw(Canvas canvas) { base.OnDraw(canvas); var actualModel = this.ActualModel; if (actualModel == null) { return; } if (actualModel.Background.IsVisible()) { canvas.DrawColor(actualModel.Background.ToColor()); } else { // do nothing } lock (this.invalidateLock) { if (this.isModelInvalidated) { ((IPlotModel)actualModel).Update(this.updateDataFlag); this.updateDataFlag = false; this.isModelInvalidated = false; } } lock (this.renderingLock) { if (this.rc == null) { this.rc = new CanvasRenderContext(Scale); } this.rc.SetTarget(canvas); ((IPlotModel)actualModel).Render(this.rc, Width / Scale, Height / Scale); } }