IDynamicDashboardDataPresenter.cs 2.1 KB

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