|
@@ -0,0 +1,56 @@
|
|
|
+using Avalonia.Controls;
|
|
|
+using Avalonia.Layout;
|
|
|
+using Avalonia.Media;
|
|
|
+using InABox.Avalonia.Components;
|
|
|
+using InABox.Core;
|
|
|
+using System;
|
|
|
+using System.Collections.Generic;
|
|
|
+using System.Globalization;
|
|
|
+using System.Linq;
|
|
|
+using System.Text;
|
|
|
+using System.Threading.Tasks;
|
|
|
+
|
|
|
+namespace PRS.Avalonia.DigitalForms;
|
|
|
+
|
|
|
+class DFDoubleFieldControl : DigitalFormFieldControl<DFLayoutDoubleField, DFLayoutDoubleFieldProperties, double, double?>
|
|
|
+{
|
|
|
+ private DoubleBox Double = null!; // late-initialising
|
|
|
+
|
|
|
+ protected override Control Create()
|
|
|
+ {
|
|
|
+ Double = new DoubleBox();
|
|
|
+ Double.Value = (decimal)Field.Properties.Default;
|
|
|
+ Double.HorizontalContentAlignment = HorizontalAlignment.Center;
|
|
|
+ Double.VerticalContentAlignment = VerticalAlignment.Center;
|
|
|
+ Double.VerticalAlignment = VerticalAlignment.Stretch;
|
|
|
+ Double.ValueChanged += (sender, e) => ChangeField();
|
|
|
+ Double.FormatString = Field.Properties.Format;
|
|
|
+ return Double;
|
|
|
+ }
|
|
|
+
|
|
|
+ public override void SetSerializedValue(double? value)
|
|
|
+ {
|
|
|
+ Double.Value = (decimal?)value;
|
|
|
+ }
|
|
|
+
|
|
|
+ public override double? GetSerializedValue()
|
|
|
+ {
|
|
|
+ return (double?)Double.Value;
|
|
|
+ }
|
|
|
+
|
|
|
+ public override double GetValue()
|
|
|
+ {
|
|
|
+ return (double?)Double.Value ?? 0.0;
|
|
|
+ }
|
|
|
+
|
|
|
+ public override void SetValue(double value)
|
|
|
+ {
|
|
|
+ Double.Value = (decimal?)value;
|
|
|
+ }
|
|
|
+ protected override bool IsEmpty() => Double.Value == null;
|
|
|
+
|
|
|
+ public override void SetBackground(IBrush brush, bool defaultColour)
|
|
|
+ {
|
|
|
+ Double.Background = brush;
|
|
|
+ }
|
|
|
+}
|