BaseEditor.cs 2.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123
  1. using System;
  2. namespace InABox.Core
  3. {
  4. public interface IBaseEditor
  5. {
  6. Visible Visible { get; set; }
  7. Editable Editable { get; set; }
  8. string ToolTip { get; set; }
  9. Alignment Alignment { get; set; }
  10. int Width { get; set; }
  11. string Format { get; set; }
  12. int ColumnSequence { get; set; }
  13. int EditorSequence { get; set; }
  14. string Caption { get; set; }
  15. string? Page { get; set; }
  16. Summary Summary { get; set; }
  17. BaseEditor CloneEditor();
  18. public object Clone();
  19. }
  20. public abstract class BaseEditor : Attribute, IEnclosedEntity, ICloneable, IBaseEditor
  21. {
  22. private BaseObject _linkedParent;
  23. private string _linkedPath;
  24. public void SetLinkedParent(BaseObject parent)
  25. {
  26. _linkedParent = parent;
  27. }
  28. public void SetLinkedPath(string path)
  29. {
  30. _linkedPath = path;
  31. }
  32. public BaseObject GetLinkedParent() => _linkedParent;
  33. public string GetLinkedPath() => _linkedPath;
  34. protected BaseEditor()
  35. {
  36. Editable = Editable.Enabled;
  37. Visible = Visible.Optional;
  38. Alignment = Alignment.MiddleLeft;
  39. Width = 0;
  40. Format = "";
  41. ColumnSequence = 0;
  42. EditorSequence = 0;
  43. Caption = "";
  44. Summary = Summary.None;
  45. ToolTip = "";
  46. }
  47. [EnumLookupEditor(typeof(Visible))]
  48. public Visible Visible { get; set; }
  49. [EnumLookupEditor(typeof(Editable))]
  50. public Editable Editable { get; set; }
  51. [NullEditor]
  52. public string ToolTip { get; set; }
  53. [NullEditor]
  54. public Alignment Alignment { get; set; }
  55. [NullEditor]
  56. public int Width { get; set; }
  57. [NullEditor]
  58. public string Format { get; set; }
  59. [NullEditor]
  60. public int ColumnSequence { get; set; }
  61. [NullEditor]
  62. public int EditorSequence { get; set; }
  63. [NullEditor]
  64. public string Caption { get; set; }
  65. [NullEditor]
  66. public string? Page { get; set; }
  67. [NullEditor]
  68. public Summary Summary { get; set; }
  69. public BaseEditor CloneEditor()
  70. {
  71. var result = DoClone();
  72. result.Visible = Visible;
  73. result.Editable = Editable;
  74. result.Alignment = Alignment;
  75. result.Width = Width;
  76. result.Format = Format;
  77. result.ColumnSequence = ColumnSequence;
  78. result.EditorSequence = EditorSequence;
  79. result.Caption = Caption;
  80. result.Page = Page;
  81. result.Summary = Summary;
  82. result.ToolTip = ToolTip;
  83. return result;
  84. }
  85. public object Clone() => CloneEditor();
  86. protected abstract BaseEditor DoClone();
  87. }
  88. }