1using CommunityToolkit.Mvvm.ComponentModel;
3using System.Collections.ObjectModel;
4using System.Diagnostics.CodeAnalysis;
26 this.Ended = Args.
Ended;
40 await base.OnInitialize();
42 ServiceRef.XmppService.NeuroFeatureVariablesUpdated += this.Wallet_VariablesUpdated;
43 ServiceRef.XmppService.NeuroFeatureStateUpdated += this.Wallet_StateUpdated;
49 ServiceRef.XmppService.NeuroFeatureVariablesUpdated -= this.Wallet_VariablesUpdated;
50 ServiceRef.XmppService.NeuroFeatureStateUpdated -= this.Wallet_StateUpdated;
52 return base.OnDispose();
55 private Task Wallet_StateUpdated(
object? Sender,
NeuroFeatures.NewStateEventArgs e)
57 MainThread.BeginInvokeOnMainThread(() =>
59 this.CurrentState = e.NewState;
60 this.Ended =
string.IsNullOrEmpty(e.NewState);
61 this.Running = !
this.Ended;
64 return Task.CompletedTask;
67 private Task Wallet_VariablesUpdated(
object? Sender,
NeuroFeatures.VariablesUpdatedEventArgs e)
69 MainThread.BeginInvokeOnMainThread(() =>
73 if (this.TryGetVariableMode(Variable.Name, out VariableModel? Model))
74 Model.UpdateValue(Variable.ValueObject);
76 this.Variables.Add(new VariableModel(Variable.Name, Variable.ValueObject));
80 return Task.CompletedTask;
83 private bool TryGetVariableMode(
string Name, [NotNullWhen(
true)] out VariableModel? Result)
85 foreach (VariableModel Model
in this.
Variables)
87 if (Model.Name == Name)
103 public ObservableCollection<VariableModel>
Variables {
get; }
109 private bool running;
121 private string? currentState;
A base class for all view models, inheriting from the BindableObject. NOTE: using this class requir...
Holds navigation parameters specific to the current state of a state-machine.
Variables? Variables
Current variables
bool Running
If the State-machine is running
string? CurrentState
The Current State of the state-machine.
bool Ended
If the State-machine has ended
The view model to bind to for when displaying information about the current state of a state-machine.
MachineVariablesViewModel(MachineVariablesNavigationArgs? Args)
The view model to bind to for when displaying information about the current state of a state-machine.
override Task OnDispose()
Method called when the view is disposed, and will not be used more. Use this method to unregister eve...
override async Task OnInitialize()
Method called when view is initialized for the first time. Use this method to implement registration ...
Contains information about a variable.
object ValueObject
Object Value of variable.
string Name
Name of variable.
virtual Variable Add(string Name, object Value)
Adds a variable to the collection.