IDynamicDashboardDataPresenter.cs 2.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657
  1. using Newtonsoft.Json;
  2. using System;
  3. using System.Collections.Generic;
  4. using System.ComponentModel;
  5. using System.Linq;
  6. using System.Text;
  7. using System.Threading.Tasks;
  8. using System.Windows;
  9. namespace InABox.Wpf.Dashboard;
  10. public interface IDynamicDashboardDataPresenter
  11. {
  12. /// <summary>
  13. /// The desired height for this presenter while previewing in design mode.
  14. /// </summary>
  15. int PreviewHeight { get; }
  16. object Properties { get; set; }
  17. /// <summary>
  18. /// Component for the data of this presenter; can be safely assumed to be non-<see langword="null"/> when <see cref="Setup"/> is called.
  19. /// This may be set later, if the user changes the data they've selected, so the setter should be used to manage data refreshes.
  20. /// </summary>
  21. DynamicDashboardDataComponent DataComponent { get; set; }
  22. /// <summary>
  23. /// Sets up the data presenter; returns the UI element to be rendered to the user.
  24. /// </summary>
  25. /// <returns>
  26. /// <see langword="null"/> if some error occurred and the data cannot be presented; otherwise, returns the control.
  27. /// </returns>
  28. FrameworkElement? Setup();
  29. /// <summary>
  30. /// Update the dashboard with <paramref name="data"/>.
  31. /// </summary>
  32. /// <param name="data">The data to be rendered.</param>
  33. void Refresh(DynamicDashboardData data);
  34. void Shutdown(CancelEventArgs? cancel);
  35. }
  36. public interface IDynamicDashboardDataPresenter<TProperties> : IDynamicDashboardDataPresenter
  37. where TProperties: class, new()
  38. {
  39. /// <summary>
  40. /// The properties for the presenter; can be safely assumed to be non-<see langword="null"/> when <see cref="IDynamicDashboardDataPresenter.Setup"/>
  41. /// is called. This may be modified by the presenter, and any changes made will be persisted.
  42. /// </summary>
  43. new TProperties Properties { get; set; }
  44. object IDynamicDashboardDataPresenter.Properties
  45. {
  46. get => Properties;
  47. set => Properties = (value as TProperties)!;
  48. }
  49. }