IntegerEditorControl.cs 1.6 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758
  1. using System;
  2. using System.Globalization;
  3. using System.Windows;
  4. using System.Windows.Media;
  5. using Syncfusion.Windows.Shared;
  6. namespace InABox.DynamicGrid
  7. {
  8. public class IntegerEditorControl : DynamicEditorControl<int>
  9. {
  10. private IntegerTextBox Editor;
  11. protected override FrameworkElement CreateEditor()
  12. {
  13. Editor = new IntegerTextBox
  14. {
  15. VerticalAlignment = VerticalAlignment.Stretch,
  16. VerticalContentAlignment = VerticalAlignment.Center,
  17. HorizontalAlignment = HorizontalAlignment.Stretch,
  18. HorizontalContentAlignment = HorizontalAlignment.Center
  19. };
  20. Editor.NumberFormat = new NumberFormatInfo { NumberGroupSeparator = "", CurrencyGroupSeparator = "", PercentGroupSeparator = "" };
  21. Editor.ValueChanged += (o, e) => CheckChanged();
  22. return Editor;
  23. }
  24. public override int DesiredHeight()
  25. {
  26. return 25;
  27. }
  28. public override int DesiredWidth()
  29. {
  30. return 150;
  31. }
  32. protected override int RetrieveValue()
  33. {
  34. return Convert.ToInt32(Editor.Value.HasValue ? Editor.Value.Value : default(int));
  35. }
  36. protected override void UpdateValue(int value)
  37. {
  38. Editor.Value = value;
  39. }
  40. public override void SetFocus()
  41. {
  42. Editor.Focus();
  43. }
  44. public override void SetColor(Color color)
  45. {
  46. Editor.Background = new SolidColorBrush(color);
  47. }
  48. }
  49. }