From 73d256d69ed69aacf813876582b467ec6f9feda8 Mon Sep 17 00:00:00 2001 From: dtatarnikov Date: Tue, 21 Nov 2023 16:03:36 +0700 Subject: [PATCH 1/2] Support start/finish rendering events --- Source/OxyPlot.Maui.Skia/PlotViewBase.cs | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/Source/OxyPlot.Maui.Skia/PlotViewBase.cs b/Source/OxyPlot.Maui.Skia/PlotViewBase.cs index 61ceb02..05f7d21 100644 --- a/Source/OxyPlot.Maui.Skia/PlotViewBase.cs +++ b/Source/OxyPlot.Maui.Skia/PlotViewBase.cs @@ -4,6 +4,9 @@ namespace OxyPlot.Maui.Skia; public abstract partial class PlotViewBase : BaseTemplatedView, IPlotView { + public event Action UpdateStarted; + public event Action UpdateFinished; + private int mainThreadId = 1; protected override void OnControlInitialized(Grid control) @@ -138,6 +141,8 @@ public void HideZoomRectangle() /// The update Data. public void InvalidatePlot(bool updateData = true) { + UpdateStarted?.Invoke(); + if (this.ActualModel == null) { return; @@ -371,6 +376,8 @@ protected virtual void RenderOverride() ((IPlotModel)this.ActualModel).Render(this.renderContext, new OxyRect(0, 0, width, height)); } } + + UpdateFinished?.Invoke(); } /// From 7d0c8d70cf35251582bb8b762a7a94ec4defbb78 Mon Sep 17 00:00:00 2001 From: dtatarnikov Date: Wed, 22 Nov 2023 17:00:01 +0700 Subject: [PATCH 2/2] Add RenderStarted/RenderFinished events --- Source/OxyPlot.Maui.Skia/PlotViewBase.cs | 12 +++++++++--- 1 file changed, 9 insertions(+), 3 deletions(-) diff --git a/Source/OxyPlot.Maui.Skia/PlotViewBase.cs b/Source/OxyPlot.Maui.Skia/PlotViewBase.cs index 05f7d21..f105f6b 100644 --- a/Source/OxyPlot.Maui.Skia/PlotViewBase.cs +++ b/Source/OxyPlot.Maui.Skia/PlotViewBase.cs @@ -6,6 +6,8 @@ public abstract partial class PlotViewBase : BaseTemplatedView, IPlotView { public event Action UpdateStarted; public event Action UpdateFinished; + public event Action RenderStarted; + public event Action RenderFinished; private int mainThreadId = 1; @@ -141,17 +143,19 @@ public void HideZoomRectangle() /// The update Data. public void InvalidatePlot(bool updateData = true) { - UpdateStarted?.Invoke(); - if (this.ActualModel == null) { return; } + + UpdateStarted?.Invoke(); lock (this.ActualModel.SyncRoot) { ((IPlotModel)this.ActualModel).Update(updateData); } + + UpdateFinished?.Invoke(); this.BeginInvoke(this.Render); } @@ -360,6 +364,8 @@ protected void Render() /// protected virtual void RenderOverride() { + RenderStarted?.Invoke(); + var dpiScale = this.UpdateDpi(); this.ClearBackground(); @@ -377,7 +383,7 @@ protected virtual void RenderOverride() } } - UpdateFinished?.Invoke(); + RenderFinished?.Invoke(); } ///