IntegerEditorControl.cs 1.8 KB

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