| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687 |
- using System;
- using InABox.Core;
- using InABox.Mobile;
- using PRSClasses;
- namespace PRS.Mobile
- {
- public class DigitalFormAddTask : MobileButton, IDigitalFormField<DFLayoutAddTaskField, DFLayoutAddTaskFieldProperties, string?, string?>
- {
- private string? _value;
-
- private DFLayoutAddTaskField? _definition;
- public DFLayoutAddTaskField? Definition
- {
- get => _definition;
- set
- {
- _definition = value;
- Initialize(value ?? new DFLayoutAddTaskField());
- }
- }
-
- public string? Value
- {
- get => _value;
- set
- {
- _value = value;
- UpdateUI();
- }
- }
-
- public bool IsEmpty => String.IsNullOrWhiteSpace(Value);
-
- private bool _readOnly;
- public bool ReadOnly
- {
- get => _readOnly;
- set
- {
- _readOnly = value;
- UpdateStatus();
- }
- }
-
- public void Deserialize(DFLoadStorageEntry entry)
- => Value = Definition?.Properties.DeserializeValue(entry) ?? string.Empty;
-
- public void Serialize(DFSaveStorageEntry entry)
- => entry.SetValue(Value);
-
- public event DigitalFormViewChangedHandler? ValueChanged;
- public DigitalFormAddTask()
- {
- Clicked += (s, e) =>
- {
- // Create or Display the Task Here
- };
- }
-
- private void Initialize(DFLayoutAddTaskField definition)
- {
- }
-
- private void UpdateUI()
- {
- Text = String.IsNullOrWhiteSpace(_value)
- ? "Edit"
- : _value.Length > 25
- ? _value.Substring(0, 25) + "..."
- : _value;
- }
-
- private void UpdateStatus()
- {
- IsEnabled = !_readOnly && Definition?.Properties.Secure == false;
-
- var colors = DigitalFormUtils.GetColors(!IsEnabled, Definition?.Properties.Required ?? false, true);
- BackgroundColor = colors.Background;
- BorderColor = colors.Border;
- TextColor = colors.Foreground;
- }
- }
- }
|