Neuron®
The Neuron® is the basis for the creation of open and secure federated networks for smart societies.
Loading...
Searching...
No Matches
MachineReportViewModel.cs
1using CommunityToolkit.Mvvm.ComponentModel;
4
6{
10 public partial class MachineReportViewModel : BaseViewModel, IDisposable
11 {
12 private bool isDisposed;
13
14 [ObservableProperty]
15 private bool loaded = false;
16
22 : base()
23 {
24 this.TokenReport = Args?.Report;
25 this.Loaded = false;
26 }
27
29 public override async Task OnInitializeAsync()
30 {
31 await base.OnInitializeAsync();
32
33 if (this.TokenReport is null)
34 this.Title = string.Empty;
35 else
36 {
37 this.Title = await this.TokenReport.GetTitle();
38
39 await this.TokenReport.GenerateReportMaui(this);
40 //await this.TokenReport.GenerateReport(this);
41
42 MainThread.BeginInvokeOnMainThread(() =>
43 this.Loaded = true);
44 }
45
46 ServiceRef.XmppService.NeuroFeatureVariablesUpdated += this.Wallet_VariablesUpdated;
47 ServiceRef.XmppService.NeuroFeatureStateUpdated += this.Wallet_StateUpdated;
48 }
49
51 public override Task OnDisposeAsync()
52 {
53 ServiceRef.XmppService.NeuroFeatureVariablesUpdated -= this.Wallet_VariablesUpdated;
54 ServiceRef.XmppService.NeuroFeatureStateUpdated -= this.Wallet_StateUpdated;
55
56 this.DeleteTemporaryFiles();
57
58 return base.OnDisposeAsync();
59 }
60
61 private Task Wallet_StateUpdated(object? Sender, NeuroFeatures.EventArguments.NewStateEventArgs e)
62 {
63 return this.UpdateReport();
64 }
65
66 private Task Wallet_VariablesUpdated(object? Sender, NeuroFeatures.EventArguments.VariablesUpdatedEventArgs e)
67 {
68 return this.UpdateReport();
69 }
70
71 private Task UpdateReport()
72 {
73 return this.TokenReport?.GenerateReport(this) ?? Task.CompletedTask;
74 }
75
76 #region Properties
77
81 [ObservableProperty]
82 private string? title;
83
87 [ObservableProperty]
88 private object? report;
89
93 [ObservableProperty]
94 private TokenReport? tokenReport;
95
99 public void Dispose()
100 {
101 this.Dispose(true);
102 GC.SuppressFinalize(this);
103 }
104
108 protected virtual void Dispose(bool Disposing)
109 {
110 if (this.isDisposed)
111 return;
112
113 if (Disposing)
114 this.DeleteTemporaryFiles();
115
116 this.isDisposed = true;
117 }
118
119 private void DeleteTemporaryFiles()
120 {
121 this.TokenReport?.DeleteTemporaryFiles();
122 }
123
124 #endregion
125
126 }
127}
A base class for all view models, inheriting from the BindableObject. NOTE: using this class requir...
Holds navigation parameters specific to a report from a state-machine.
The view model to bind to for when displaying information about the current state of a state-machine.
override Task OnDisposeAsync()
Method called when the view is disposed, and will not be used more. Use this method to unregister eve...
MachineReportViewModel(MachineReportNavigationArgs? Args)
The view model to bind to for when displaying information about the current state of a state-machine.
override async Task OnInitializeAsync()
Method called when view is initialized for the first time. Use this method to implement registration ...
Event arguments events when the current state of a state-machine has changed.
Event arguments events when the variables of a state-machine has changed.