CheckBoxEditorControl.cs 1.5 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364
  1. using System.Windows;
  2. using System.Windows.Controls;
  3. using System.Windows.Media;
  4. using InABox.Core;
  5. namespace InABox.DynamicGrid
  6. {
  7. public class CheckBoxEditorControl : DynamicEditorControl<bool, CheckBoxEditor>
  8. {
  9. static CheckBoxEditorControl()
  10. {
  11. //DynamicEditorControlFactory.Register<CheckBoxEditorControl, CheckBoxEditor>();
  12. }
  13. private CheckBox Editor;
  14. public override void Configure()
  15. {
  16. }
  17. protected override FrameworkElement CreateEditor()
  18. {
  19. Editor = new CheckBox
  20. {
  21. VerticalAlignment = VerticalAlignment.Center,
  22. HorizontalAlignment = HorizontalAlignment.Stretch
  23. };
  24. Editor.Checked += (o, e) => CheckChanged();
  25. Editor.Unchecked += (o, e) => CheckChanged();
  26. return Editor;
  27. }
  28. public override int DesiredHeight()
  29. {
  30. return 25;
  31. }
  32. public override int DesiredWidth()
  33. {
  34. return 25;
  35. }
  36. protected override bool RetrieveValue()
  37. {
  38. return Editor.IsChecked == true;
  39. }
  40. protected override void UpdateValue(bool value)
  41. {
  42. Editor.IsChecked = value;
  43. }
  44. public override void SetFocus()
  45. {
  46. Editor.Focus();
  47. }
  48. public override void SetColor(Color color)
  49. {
  50. Editor.Background = new SolidColorBrush(color);
  51. }
  52. }
  53. }