Skip to content

Support start/finish rendering events #5

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 2 commits into from
Nov 22, 2023
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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