Neuron®
The Neuron® is the basis for the creation of open and secure federated networks for smart societies.
Loading...
Searching...
No Matches
AccountEventViewModel.cs
1using CommunityToolkit.Mvvm.ComponentModel;
2using CommunityToolkit.Mvvm.Input;
4
6{
10 public partial class AccountEventViewModel : XmppViewModel
11 {
17 : base()
18 {
19 if (Args is not null)
20 {
21 this.Remote = Args.Event?.Remote;
22 this.FriendlyName = Args.Event?.FriendlyName;
23 this.Timestamp = Args.Event?.Timestamp;
24 this.TimestampStr = Args.Event?.TimestampStr;
25 this.Change = Args.Event?.Change;
26 this.Balance = Args.Event?.Balance;
27 this.Reserved = Args.Event?.Reserved;
28 this.Message = Args.Event?.Message;
29 this.HasMessage = Args.Event?.HasMessage ?? false;
30 this.MessageIsUri = this.HasMessage && Uri.TryCreate(this.Message, UriKind.Absolute, out _);
31 this.Id = Args.Event?.TransactionId.ToString();
32 this.Currency = Args.Event?.Currency;
33
34 this.ChangeText = this.Change is null ? string.Empty : MoneyToString.ToString(this.Change.Value);
35 this.ChangeAndCurrency = this.ChangeText + " " + this.Currency;
36
37 this.BalanceText = this.Balance is null ? string.Empty : MoneyToString.ToString(this.Balance.Value);
38 this.BalanceAndCurrency = this.BalanceText + " " + this.Currency;
39
40 this.ReservedText = this.Reserved is null ? string.Empty : MoneyToString.ToString(this.Reserved.Value);
41 this.ReservedAndCurrency = this.ReservedText + " " + this.Currency;
42 }
43 }
44
45 #region Properties
46
50 [ObservableProperty]
51 private decimal? change;
52
56 [ObservableProperty]
57 private string? changeText;
58
62 [ObservableProperty]
63 private string? changeAndCurrency;
64
68 [ObservableProperty]
69 private decimal? balance;
70
74 [ObservableProperty]
75 private string? balanceText;
76
80 [ObservableProperty]
81 private string? balanceAndCurrency;
82
86 [ObservableProperty]
87 private decimal? reserved;
88
92 [ObservableProperty]
93 private string? reservedText;
94
98 [ObservableProperty]
99 private string? reservedAndCurrency;
100
104 [ObservableProperty]
105 private string? currency;
106
110 [ObservableProperty]
111 private DateTime? timestamp;
112
116 [ObservableProperty]
117 private string? timestampStr;
118
122 [ObservableProperty]
123 private string? id;
124
128 [ObservableProperty]
129 private string? remote;
130
134 [ObservableProperty]
135 private string? friendlyName;
136
140 [ObservableProperty]
141 private string? message;
142
146 [ObservableProperty]
147 private bool hasMessage;
148
152 [ObservableProperty]
153 private bool messageIsUri;
154
155 #endregion
156
157 #region Commands
158
162 [RelayCommand(CanExecute = nameof(MessageIsUri))]
163 private async Task OpenMessageLink()
164 {
165 if (!string.IsNullOrEmpty(this.Message))
166 await App.OpenUrlAsync(this.Message);
167 }
168
169 #endregion
170
171
172 }
173}
The Application class, representing an instance of the Neuro-Access app.
Definition: App.xaml.cs:69
static Task< bool > OpenUrlAsync(string Url)
Opens an URL in the application.
Definition: App.xaml.cs:919
static string ToString(decimal Money)
Converts a monetary value to a string, removing any round-off errors.
The view model to bind to for when displaying the contents of an account event.
AccountEventViewModel(AccountEventNavigationArgs? Args)
Creates an instance of the AccountEventViewModel class.
A view model that holds the XMPP state.