DFDoubleControl.cs 1.5 KB

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