|
|
@@ -9,7 +9,7 @@ using System.Threading.Tasks;
|
|
|
|
|
|
namespace PRS.Avalonia.DigitalForms;
|
|
|
|
|
|
-class DFBooleanFieldControl : DigitalFormFieldControl<DFLayoutBooleanField, DFLayoutBooleanFieldProperties, bool, bool?>
|
|
|
+class DFBooleanFieldControl : DigitalFormFieldControl<DFLayoutBooleanField, DFLayoutBooleanFieldProperties, bool?, bool?>
|
|
|
{
|
|
|
private IOptionControl OptionControl = null!; // Late-initialised
|
|
|
|
|
|
@@ -33,18 +33,34 @@ class DFBooleanFieldControl : DigitalFormFieldControl<DFLayoutBooleanField, DFLa
|
|
|
|
|
|
public override void SetSerializedValue(bool? value)
|
|
|
{
|
|
|
- SetValue(value ?? false);
|
|
|
+ SetValue(value);
|
|
|
}
|
|
|
|
|
|
- public override bool GetValue() => OptionControl.GetValue() == Field.Properties.TrueValue;
|
|
|
-
|
|
|
- public override void SetValue(bool value) => OptionControl.SetValue(value ? Field.Properties.TrueValue : Field.Properties.FalseValue);
|
|
|
+ public override bool? GetValue()
|
|
|
+ {
|
|
|
+ var val = OptionControl.GetValue();
|
|
|
+ if(val == Field.Properties.TrueValue)
|
|
|
+ {
|
|
|
+ return true;
|
|
|
+ }
|
|
|
+ else if(val == Field.Properties.FalseValue)
|
|
|
+ {
|
|
|
+ return false;
|
|
|
+ }
|
|
|
+ else
|
|
|
+ {
|
|
|
+ return null;
|
|
|
+ }
|
|
|
+ }
|
|
|
|
|
|
- protected override bool IsEmpty() => Field.Properties.Type switch
|
|
|
+ public override void SetValue(bool? value) => OptionControl.SetValue(value switch
|
|
|
{
|
|
|
- DesignBooleanFieldType.Checkbox => GetValue() != true,
|
|
|
- _ => OptionControl.IsEmpty()
|
|
|
- };
|
|
|
+ true => Field.Properties.TrueValue,
|
|
|
+ false => Field.Properties.FalseValue,
|
|
|
+ null => null
|
|
|
+ });
|
|
|
+
|
|
|
+ protected override bool IsEmpty() => OptionControl.IsEmpty();
|
|
|
|
|
|
public override void SetBackground(IBrush brush, bool defaultColour)
|
|
|
{
|