DFDoubleControl.cs 1.2 KB

123456789101112131415161718192021222324252627282930313233343536373839
  1. using InABox.Core;
  2. using Syncfusion.Windows.Shared;
  3. using System;
  4. using System.Collections.Generic;
  5. using System.Linq;
  6. using System.Text;
  7. using System.Threading.Tasks;
  8. using System.Windows;
  9. namespace InABox.DynamicGrid
  10. {
  11. public class DFDoubleControl : DynamicFormFieldControl<DFLayoutDoubleField, DFLayoutDoubleFieldProperties, double>
  12. {
  13. private DoubleTextBox Double = null!; // late-initialising
  14. protected override FrameworkElement Create()
  15. {
  16. Double = new DoubleTextBox();
  17. Double.Value = Field.Properties.Default;
  18. Double.HorizontalContentAlignment = HorizontalAlignment.Center;
  19. Double.VerticalContentAlignment = VerticalAlignment.Center;
  20. Double.VerticalAlignment = VerticalAlignment.Stretch;
  21. Double.ValueChanged += (sender, e) => ChangeField();
  22. Double.IsScrollingOnCircle = false;
  23. return Double;
  24. }
  25. public override double GetValue()
  26. {
  27. return Double.Value ?? 0.0;
  28. }
  29. public override void SetValue(double value)
  30. {
  31. Double.Value = value;
  32. }
  33. protected override bool IsEmpty() => Double.Value == null;
  34. }
  35. }