MasterDetailPanelPage.cs 1.1 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546
  1. using System.Collections.Generic;
  2. using InABox.Core;
  3. using InABox.DynamicGrid;
  4. namespace InABox.Wpf;
  5. public abstract class MasterDetailPanelPage<TMaster,TPanel> : MasterDetailPage<TMaster>
  6. where TPanel : class, IBasePanel, IMasterDetailControl<TMaster>, new()
  7. {
  8. public MasterDetailPanelPage(DynamicTabItem tab) : base(tab) { }
  9. public TPanel? Panel { get; set; }
  10. public override Dictionary<string, object[]>? Selected() => Panel?.Selected();
  11. protected abstract void DoRefresh(TPanel panel);
  12. public override IDataModelSource DataModelSource() => CheckPanel();
  13. protected override IDataModelSource Refresh()
  14. {
  15. CheckPanel();
  16. DoRefresh(Panel);
  17. return Panel;
  18. }
  19. private IDataModelSource CheckPanel()
  20. {
  21. if (Panel == null)
  22. {
  23. Panel = new TPanel
  24. {
  25. IsReady = false
  26. };
  27. Panel.Setup();
  28. Panel.IsReady = true;
  29. Tab.Content = Panel;
  30. }
  31. Panel.Master = Master;
  32. return Panel;
  33. }
  34. }