Skip to content

Commit

Permalink
Merge pull request #5 from dtatarnikov/lifecycle_events
Browse files Browse the repository at this point in the history
Support start/finish rendering events
  • Loading branch information
janusw authored Nov 22, 2023
2 parents 1709137 + 7d0c8d7 commit 789276c
Showing 1 changed file with 13 additions and 0 deletions.
13 changes: 13 additions & 0 deletions Source/OxyPlot.Maui.Skia/PlotViewBase.cs
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,11 @@ namespace OxyPlot.Maui.Skia;

public abstract partial class PlotViewBase : BaseTemplatedView<Grid>, IPlotView
{
public event Action UpdateStarted;
public event Action UpdateFinished;
public event Action RenderStarted;
public event Action RenderFinished;

private int mainThreadId = 1;

protected override void OnControlInitialized(Grid control)
Expand Down Expand Up @@ -142,11 +147,15 @@ public void InvalidatePlot(bool updateData = true)
{
return;
}

UpdateStarted?.Invoke();

lock (this.ActualModel.SyncRoot)
{
((IPlotModel)this.ActualModel).Update(updateData);
}

UpdateFinished?.Invoke();

this.BeginInvoke(this.Render);
}
Expand Down Expand Up @@ -355,6 +364,8 @@ protected void Render()
/// </summary>
protected virtual void RenderOverride()
{
RenderStarted?.Invoke();

var dpiScale = this.UpdateDpi();
this.ClearBackground();

Expand All @@ -371,6 +382,8 @@ protected virtual void RenderOverride()
((IPlotModel)this.ActualModel).Render(this.renderContext, new OxyRect(0, 0, width, height));
}
}

RenderFinished?.Invoke();
}

/// <summary>
Expand Down

0 comments on commit 789276c

Please sign in to comment.