MultipleSelectColumn.cs 1.7 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556
  1. using System;
  2. using System.Collections.Generic;
  3. using System.Linq;
  4. using System.Text;
  5. using System.Threading.Tasks;
  6. using System.Collections.ObjectModel;
  7. using RecipeEditorLib.RecipeModel.Params;
  8. namespace RecipeEditorLib.DGExtension.CustomColumn
  9. {
  10. public class MultipleSelectColumn : EditorDataGridTemplateColumnBase
  11. {
  12. public MultipleSelectColumn() : base()
  13. {
  14. this.Options = new ObservableCollection<Option>();
  15. }
  16. public class Option
  17. {
  18. public MultipleSelectParam parent { get; set; }
  19. public string ControlName { get; set; }
  20. public string DisplayName { get; set; }
  21. public string RelatedParameters { get; set; }
  22. public bool IsChecked
  23. {
  24. get { return this.isChecked; }
  25. set
  26. {
  27. this.isChecked = value;
  28. if (this.parent!=null)
  29. this.parent.IsSaved = false;
  30. }
  31. }
  32. private bool isChecked;
  33. }
  34. public ObservableCollection<Option> Options { get; set; }
  35. public List<Option> CloneOptions(MultipleSelectParam _parent = null)
  36. {
  37. List<Option> opts = new List<Option>();
  38. this.Options.ToList().ForEach(opt =>
  39. {
  40. opts.Add(new Option()
  41. {
  42. parent = _parent,
  43. ControlName = opt.ControlName,
  44. DisplayName = opt.DisplayName,
  45. RelatedParameters = opt.RelatedParameters
  46. });
  47. });
  48. return opts;
  49. }
  50. }
  51. }