DynamicEditorPage.cs 1.6 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677
  1. using System;
  2. using System.Collections.Concurrent;
  3. using System.Collections.Generic;
  4. using System.Windows;
  5. using InABox.Core;
  6. namespace InABox.DynamicGrid;
  7. public enum PageType
  8. {
  9. Editor,
  10. Other
  11. }
  12. public interface IDynamicEditorPage
  13. {
  14. DynamicEditorGrid EditorGrid { get; set; }
  15. PageType PageType { get; }
  16. bool Ready { get; set; }
  17. bool ReadOnly { get; set; }
  18. void Load(object item, Func<Type, CoreTable?>? PageDataHandler);
  19. /// <summary>
  20. /// Called when the "OK" button is clicked on an editor, and before the item is saved.
  21. /// </summary>
  22. /// <param name="item"></param>
  23. void BeforeSave(object item);
  24. /// <summary>
  25. /// Called when the "OK" button is clicked on an editor, and after the item is saved.
  26. /// </summary>
  27. /// <remarks>
  28. /// Generally used to save any child entities that need to be saved, since now the parent has a valid <see cref="Entity.ID"/>.
  29. /// </remarks>
  30. /// <param name="item"></param>
  31. void AfterSave(object item);
  32. event EventHandler OnChanged;
  33. void DoChanged();
  34. Size MinimumSize();
  35. string Caption();
  36. int Order();
  37. }
  38. //public class DynamicEditorPage
  39. //{
  40. // public String Name { get; set; }
  41. // public Control Page { get; set; }
  42. // public DynamicEditorPage(String name, Control page) : base()
  43. // {
  44. // Name = name;
  45. // Page = page;
  46. // }
  47. //}
  48. public class DynamicEditorPages : List<IDynamicEditorPage>
  49. {
  50. public DynamicEditorPages() : base()
  51. {
  52. }
  53. public DynamicEditorPages(IEnumerable<IDynamicEditorPage> pages) : this()
  54. {
  55. foreach (var page in pages)
  56. Add(page);
  57. }
  58. }