Преглед на файлове

avalonia: Added code to use the "Secure" property of a digital form field.

Kenric Nugteren преди 2 месеца
родител
ревизия
518c902dbc

+ 2 - 2
PRS.Avalonia/PRS.Avalonia/Components/FormsEditor/DigitalFormViewer.axaml.cs

@@ -257,9 +257,9 @@ public partial class DigitalFormViewer : UserControl, IDFRenderer
 
         if (element != null)
         {
-            if(item is DFLayoutField)
+            if(item is DFLayoutField field && element is IDigitalFormField fieldControl)
             {
-                element.IsEnabled = element.IsEnabled && !ReadOnly;
+                fieldControl.SetEnabled(!ReadOnly && !field.GetProperties().Secure);
             }
             _elementMap[item] = element;
 

+ 5 - 0
PRS.Avalonia/PRS.Avalonia/Components/FormsEditor/Fields/DFBooleanFieldControl.cs

@@ -53,4 +53,9 @@ class DFBooleanFieldControl : DigitalFormFieldControl<DFLayoutBooleanField, DFLa
             Background = brush;
         }
     }
+
+    public override void SetEnabled(bool enabled)
+    {
+        IsEnabled = enabled;
+    }
 }

+ 5 - 0
PRS.Avalonia/PRS.Avalonia/Components/FormsEditor/Fields/DFDateFieldControl.cs

@@ -39,4 +39,9 @@ class DFDateFieldControl : DigitalFormFieldControl<DFLayoutDateField, DFLayoutDa
     {
         Date.Background = brush;
     }
+
+    public override void SetEnabled(bool enabled)
+    {
+        IsEnabled = enabled;
+    }
 }

+ 5 - 0
PRS.Avalonia/PRS.Avalonia/Components/FormsEditor/Fields/DFDoubleFieldControl.cs

@@ -53,4 +53,9 @@ class DFDoubleFieldControl : DigitalFormFieldControl<DFLayoutDoubleField, DFLayo
     {
         Double.Background = brush;
     }
+
+    public override void SetEnabled(bool enabled)
+    {
+        IsEnabled = enabled;
+    }
 }

+ 5 - 0
PRS.Avalonia/PRS.Avalonia/Components/FormsEditor/Fields/DFIntegerFieldControl.cs

@@ -61,4 +61,9 @@ class DFIntegerFieldControl : DigitalFormFieldControl<DFLayoutIntegerField, DFLa
     {
         Integer.Background = brush;
     }
+
+    public override void SetEnabled(bool enabled)
+    {
+        IsEnabled = enabled;
+    }
 }

+ 5 - 0
PRS.Avalonia/PRS.Avalonia/Components/FormsEditor/Fields/DFLookupFieldControl.cs

@@ -209,4 +209,9 @@ partial class DFLookupFieldControl : DigitalFormFieldControl<DFLayoutLookupField
     {
         Button.Background = brush;
     }
+
+    public override void SetEnabled(bool enabled)
+    {
+        IsEnabled = enabled;
+    }
 }

+ 5 - 0
PRS.Avalonia/PRS.Avalonia/Components/FormsEditor/Fields/DFOptionFieldControl.cs

@@ -243,4 +243,9 @@ class DFOptionControl : DigitalFormFieldControl<DFLayoutOptionField, DFLayoutOpt
             OptionControl.Background = brush;
         }
     }
+
+    public override void SetEnabled(bool enabled)
+    {
+        IsEnabled = enabled;
+    }
 }

+ 5 - 0
PRS.Avalonia/PRS.Avalonia/Components/FormsEditor/Fields/DFStringFieldControl.cs

@@ -119,4 +119,9 @@ partial class DFStringFieldControl : DigitalFormFieldControl<DFLayoutStringField
     public override void SetValue(string? value) => Text = value;
 
     protected override bool IsEmpty() => string.IsNullOrWhiteSpace(Text);
+
+    public override void SetEnabled(bool enabled)
+    {
+        IsEnabled = enabled;
+    }
 }

+ 5 - 0
PRS.Avalonia/PRS.Avalonia/Components/FormsEditor/Fields/DFTimeFieldControl.cs

@@ -39,4 +39,9 @@ class DFTimeFieldControl : DigitalFormFieldControl<DFLayoutTimeField, DFLayoutTi
     {
         Time.Background = brush;
     }
+
+    public override void SetEnabled(bool enabled)
+    {
+        IsEnabled = enabled;
+    }
 }

+ 5 - 1
PRS.Avalonia/PRS.Avalonia/Components/FormsEditor/Fields/IDigitalFormField.cs

@@ -50,6 +50,8 @@ internal interface IDigitalFormField
     /// <param name="brush"></param>
     /// <param name="defaultColour"></param>
     public void SetBackground(IBrush brush, bool defaultColour);
+
+    public void SetEnabled(bool enabled);
 }
 
 internal abstract class DigitalFormFieldControl<TField, TProperties, TValue, TSerialized> : DigitalFormControl<TField>, IDigitalFormField
@@ -60,7 +62,7 @@ internal abstract class DigitalFormFieldControl<TField, TProperties, TValue, TSe
 
     public TField Field { get => Control; set => Control = value; }
 
-    public void Serialize(DFSaveStorageEntry storage)
+    public virtual void Serialize(DFSaveStorageEntry storage)
     {
         Field.Properties.SerializeValue(storage, GetSerializedValue());
     }
@@ -115,4 +117,6 @@ internal abstract class DigitalFormFieldControl<TField, TProperties, TValue, TSe
     void IDigitalFormField.SetValue(object? value) => SetValue(value != null ? (TValue)value : default);
 
     public abstract void SetBackground(IBrush brush, bool defaultColour);
+
+    public abstract void SetEnabled(bool enabled);
 }