1using System.ComponentModel;
2using System.Globalization;
3using CommunityToolkit.Mvvm.ComponentModel;
4using CommunityToolkit.Mvvm.Input;
26 this.Parameter = parameter;
30 #region Initialization
34 private async Task InitializeAsync(
Contract contract)
39 this.Description = UntrimmedDescription.Trim();
71 await ParameterInfo.InitializeAsync(contract);
75 if(RP.Value is not
null && RP.Value is
string RoleValue &&
string.IsNullOrEmpty(RoleValue))
82 if (
string.IsNullOrEmpty(CP.StringValue))
115 if (
string.IsNullOrEmpty(this.Guide))
130 get => this.description;
133 if (this.SetProperty(ref this.description, value))
134 this.OnPropertyChanged(nameof(this.
Label));
137 private string description =
string.Empty;
145 set => this.SetProperty(ref this.isValid, value);
147 private bool isValid =
true;
154 get => this.validationText;
157 this.SetProperty(ref this.validationText, value);
158 this.OnPropertyChanged(nameof(this.CanShowError));
159 this.ShowErrorCommand.NotifyCanExecuteChanged();
162 private string validationText =
string.Empty;
167 private object? value;
184 this.OnPropertyChanged(nameof(this.Value));
211 public bool CanShowError => !
string.IsNullOrEmpty(this.
ValidationText);
215 [RelayCommand(CanExecute = nameof(CanShowError), AllowConcurrentExecutions =
false)]
216 private async Task ShowError()
225 #region Property Change Handling
226 protected override void OnPropertyChanged(PropertyChangedEventArgs e)
228 base.OnPropertyChanged(e);
233 #region ObservableParameter Subclasses
238 this.Value = parameter.ObjectValue is
true;
241 public bool BooleanValue
243 get => this.Value as
bool? ??
false;
244 set => this.Value = value;
248 private void ToggleBooleanValue()
250 MainThread.BeginInvokeOnMainThread(() =>
252 this.BooleanValue = !this.BooleanValue;
253 this.OnPropertyChanged(nameof(this.BooleanValue));
262 this.Value = parameter.ObjectValue as DateTime?;
265 public DateTime? DateValue
267 get => this.Value as DateTime?;
268 set => this.Value = value;
276 this.Value = parameter.ObjectValue is decimal DecimalValue ? DecimalValue :
null;
279 public decimal? DecimalValue
281 get => this.Value as decimal?;
282 set => this.Value = value;
290 this.Value = parameter.ObjectValue as
string ??
string.Empty;
293 public string StringValue
295 get => this.Value as
string ??
string.Empty;
296 set => this.Value = value;
304 this.Value = parameter.ObjectValue is TimeSpan TimeSpan ? TimeSpan : TimeSpan.Zero;
307 public TimeSpan TimeSpanValue
309 get => this.Value as TimeSpan? ?? TimeSpan.Zero;
310 set => this.Value = value;
321 public string StringValue
323 get => this.Value?.ToString() ??
string.Empty;
327 this.Value = DurationValue;
339 this.Value = DurationValue;
351 this.Value = parameter.ObjectValue as
string ??
string.Empty;
354 public string RoleValue
356 get => this.Value as
string ??
string.Empty;
357 set => this.Value = value;
368 public object? CalcValue
371 set => this.Value = value;
374 public string CalcString
378 if (this.Value is
null)
381 CultureInfo Culture = CultureInfo.CurrentCulture;
383 Console.WriteLine(this.Value.GetType().Name);
385 return this.Value
switch
387 decimal DecimalValue => DecimalValue.ToString(
"N", Culture),
388 DateTime DateTimeValue => DateTimeValue.ToString(
"G", Culture),
389 TimeSpan TimeSpanValue => TimeSpanValue.ToString(
@"hh\:mm\:ss", Culture),
390 string StringValue =>
string.IsNullOrEmpty(StringValue) ?
"-" : StringValue,
391 _ => this.Value.ToString() ?? string.Empty
405 this.Value = parameter.
Min;
414 get => this.Value as DateTime?;
415 set => this.Value = value;
428 DateTime Current = this.DateTimeValue ?? DateTime.MinValue;
429 this.DateTimeValue =
new DateTime(value.Value.Year, value.Value.Month, value.Value.Day, Current.Hour, Current.Minute, Current.Second);
433 this.DateTimeValue =
null;
446 DateTime Current = this.DateTimeValue ?? DateTime.MinValue;
447 this.DateTimeValue = Current.Date + value;
461 public string ContractReferenceValue
463 get => this.Value?.ToString() ??
string.Empty;
464 set => this.Value = value;
467 [RelayCommand(AllowConcurrentExecutions =
false)]
468 private async Task OpenContract()
470 if (
string.IsNullOrEmpty(this.ContractReferenceValue))
484 [RelayCommand(AllowConcurrentExecutions =
false)]
485 private async Task PickContractReferenceAsync()
489 TaskCompletionSource<Contract?> TaskCompletionSource =
new();
494 MainThread.BeginInvokeOnMainThread(() =>
499 this.OnPropertyChanged(nameof(this.ContractReferenceValue));
520 set => this.Value = value;
523 public string GeoString
525 get => this.GeoValue?.ToString() ??
string.Empty;
529 this.Value = GeoValue;
536 bool isCheckinglocation;
538 [RelayCommand(AllowConcurrentExecutions =
false)]
539 private async Task SetCurrentLocationAsync()
543 MainThread.BeginInvokeOnMainThread(() => this.IsCheckinglocation =
true);
545 GeolocationRequest Request =
new GeolocationRequest(GeolocationAccuracy.Best, TimeSpan.FromSeconds(10));
546 Location? Location = await Geolocation.Default.GetLocationAsync(Request);
548 if (Location is not
null)
550 MainThread.BeginInvokeOnMainThread(() =>
552 this.GeoValue =
new GeoPosition(Location.Latitude, Location.Longitude);
553 this.OnPropertyChanged(nameof(this.GeoString));
569 MainThread.BeginInvokeOnMainThread(() => this.IsCheckinglocation =
false);
A strongly-typed resource class, for looking up localized strings, etc.
static string RequestToAccessContract
Looks up a localized string similar to Request to access contract.
static string Ok
Looks up a localized string similar to OK.
static string LocationError
Looks up a localized string similar to There was an error getting your location. Make sure location p...
static string Error
Looks up a localized string similar to Error.
Base class that references services in the app.
static ILogService LogService
Log service.
static IUiService UiService
Service serializing and managing UI-related tasks.
static INavigationService NavigationService
The navigation service for navigating between pages.
static IPopupService PopupService
Popup service for presenting application popups.
static IContractOrchestratorService ContractOrchestratorService
Contract orchestrator service.
static IReportingStringLocalizer Localizer
Localization service
Holds navigation parameters specific to views displaying a list of contacts.
A page that displays a list of the current user's contracts.
DateTime? DateTimeValue
The DateTime value of the parameter. When changed, updates the underlying parameter value.
TimeSpan SelectedTime
Helper to get or set just the Time portion.
DateTime? SelectedDate
Helper to get or set just the Date portion.
An observable object that wraps a Waher.Networking.XMPP.Contracts.Parameter object....
static async Task< ObservableParameter > CreateAsync(Parameter parameter, Contract contract)
Creates a new instance of ObservableParameter based on the type of the parameter.
bool IsProtected
If the parameter is protected, either encrypted or transient
bool IsEncrypted
If the parameter is encrypted
string Guide
The Guide of the parameter
string ValidationText
Validation error text
Parameter Parameter
The wrapped parameter object
string Description
The localized description of the parameter
bool IsTransient
If the parameter is transient
string Name
The name of the parameter
string Label
Label that determines the displayed text for the parameter.
bool CanReadValue
If the parameter can be read, for example encrypted parameters cannot be read if you don't have the k...
bool IsValid
If the parameter is avlid
Boolean contractual parameter
Calculation contractual parameter
override object ObjectValue
Parameter value.
Contains the definition of a contract
Task< string > ToPlainText(string Language)
Creates a human-readable Plain Trext document for the contract.
string ContractId
Contract identity
Contract-reference parameter
Date contractual parameter
Date and Time contractual parameter
Duration contractual parameter
Geo-spatial contractual parameter
override object ObjectValue
Parameter value.
HumanReadableText[] Descriptions
Discriptions of the object, in different languages.
Numerical contractual parameter
Abstract base class for contractual parameters
bool CanSerializeValue
If the value can be serialized in the clear.
abstract string StringValue
String representation of value.
abstract void SetValue(object Value)
Sets the parameter value.
string Name
Parameter name
abstract object ObjectValue
Parameter value.
string Guide
Parameter guide text
ParameterErrorReason? ErrorReason
After IsParameterValid(Variables) or IsParameterValid(Variables, ContractsClient) has been execited,...
T? Min
Optional minimum value.
override object ObjectValue
Parameter value.
Role-reference contractual parameter
String-valued contractual parameter
Time contractual parameter
Contains information about a position in a geo-spatial coordinate system.
static bool TryParse(string s, out GeoPosition Value)
Tries to parse a string representation of a GeoPosition. If first attempts the XML format....
ContractsListMode
What list of contracts to display
ProtectionLevel
Parameter protection levels
Represents a duration value, as defined by the xsd:duration data type: http://www....
static bool TryParse(string s, out Duration Result)
Tries to parse a duration value.
static readonly Duration Zero
Zero value