IDynamicDashboardDataPresenter.cs 1.8 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152
  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. object Properties { get; set; }
  13. /// <summary>
  14. /// Component for the data of this presenter; can be safely assumed to be non-<see langword="null"/> when <see cref="Setup"/> is called.
  15. /// This may be set later, if the user changes the data they've selected, so the setter should be used to manage data refreshes.
  16. /// </summary>
  17. DynamicDashboardDataComponent DataComponent { get; set; }
  18. /// <summary>
  19. /// Sets up the data presenter; returns the UI element to be rendered to the user.
  20. /// </summary>
  21. /// <returns>
  22. /// <see langword="null"/> if some error occurred and the data cannot be presented; otherwise, returns the control.
  23. /// </returns>
  24. FrameworkElement? Setup();
  25. /// <summary>
  26. /// Update the dashboard with <paramref name="data"/>.
  27. /// </summary>
  28. /// <param name="data">The data to be rendered.</param>
  29. void Refresh(DynamicDashboardData data);
  30. void Shutdown(CancelEventArgs? cancel);
  31. }
  32. public interface IDynamicDashboardDataPresenter<TProperties> : IDynamicDashboardDataPresenter
  33. where TProperties: class, new()
  34. {
  35. /// <summary>
  36. /// The properties for the presenter; can be safely assumed to be non-<see langword="null"/> when <see cref="IDynamicDashboardDataPresenter.Setup"/>
  37. /// is called. This may be modified by the presenter, and any changes made will be persisted.
  38. /// </summary>
  39. new TProperties Properties { get; set; }
  40. object IDynamicDashboardDataPresenter.Properties
  41. {
  42. get => Properties;
  43. set => Properties = (value as TProperties)!;
  44. }
  45. }