Skip to content

Commit c6e86a3

Browse files
committed
Added AppTrayService OnAfterRender event
1 parent fd680bb commit c6e86a3

2 files changed

Lines changed: 20 additions & 7 deletions

File tree

SpawnDev.MatrixLEDDisplay.Demo/Layout/AppTray/AppTrayArea.razor.cs

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -5,16 +5,15 @@ namespace SpawnDev.MatrixLEDDisplay.Demo.Layout.AppTray
55
public partial class AppTrayArea : IDisposable
66
{
77
[Inject]
8-
AppTrayService TrayIconService { get; set; }
8+
AppTrayService TrayIconService { get; set; } = default!;
99

1010
protected override void OnInitialized()
1111
{
1212
TrayIconService.OnStateHasChanged += TrayIconService_OnStateHasChanged;
13-
1413
}
1514
protected override void OnAfterRender(bool firstRender)
1615
{
17-
16+
TrayIconService.AfterRender(firstRender);
1817
}
1918
public void Dispose()
2019
{

SpawnDev.MatrixLEDDisplay.Demo/Layout/AppTray/AppTrayService.cs

Lines changed: 18 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,16 +1,23 @@
1-
using System.Collections.ObjectModel;
1+
using SpawnDev.BlazorJS;
22

33
namespace SpawnDev.MatrixLEDDisplay.Demo.Layout.AppTray
44
{
5+
/// <summary>
6+
/// App tray icon service. Usedwith AppTrayArea.razor component
7+
/// </summary>
58
public class AppTrayService
69
{
710
List<AppTrayIcon> _TrayIcons { get; } = new List<AppTrayIcon>();
811
public IEnumerable<AppTrayIcon> TrayIcons => ReverseOrder ? _TrayIcons.AsReadOnly().Reverse() : _TrayIcons.AsReadOnly();
9-
public event Action OnStateHasChanged;
12+
public event Action OnStateHasChanged = default!;
1013
public bool ReverseOrder { get; set; } = true;
11-
public AppTrayService()
14+
public bool IsWindow { get; }
15+
/// <summary>
16+
/// New instance
17+
/// </summary>
18+
public AppTrayService(BlazorJSRuntime js)
1219
{
13-
20+
IsWindow = js.IsWindow;
1421
}
1522
public void Add(AppTrayIcon trayIcon)
1623
{
@@ -26,5 +33,12 @@ public void StateHasChanged()
2633
{
2734
OnStateHasChanged?.Invoke();
2835
}
36+
public bool FirstRenderFired { get; private set; } = false;
37+
public delegate void AfterRenderDelegate(bool firstRender);
38+
public event AfterRenderDelegate OnAfterRender = default!;
39+
public void AfterRender(bool firstRender)
40+
{
41+
OnAfterRender?.Invoke(firstRender);
42+
}
2943
}
3044
}

0 commit comments

Comments
 (0)