IDynamicDashboardDataPresenter.cs 1.7 KB

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