dashboard how-to.txt 2.5 KB

1234567891011121314151617181920212223242526272829303132333435
  1. Steps to creating a new dashboard:
  2. In PRSDesktop, create a new "User Control" XAML file under "Dashboards/". This is the control which is the dashboard itself. For the purposes of example, let this be "IncompleteTasksDashboard.xaml"
  3. The dashboard class associated with that XAML file (IncompleteTasksDashboard) must implement PRSDesktop.IDashboardWidget<TGroup, TProperties> in the following way:
  4. public partial class IncompleteTasksDashboard : UserControl, IDashboardWidget<Common, IncompleteTasksDashboardProperties>
  5. The "Common" type is a type that derives from PRSDesktop.DashboardWidgetGroup. When designing a dashboard, the context menu that allows to select which dashboard to add is grouped based on this type. So our example, IncompleteTasksDashboard, will appear under the "Common" sub-menu.
  6. The second type argument, IncompleteTasksDashboardProperties, is the class that defines the properties for the dashboard. This must be a class that implements PRSDesktop.IDashboardProperties, as below.
  7. public class IncompleteTasksDashboardProperties : IDashboardProperties { }
  8. Since IncompleteTasksDashboard derives from IDashboardWidget, there are several methods it must implement, which mirror the same methods for all panels:
  9. - void Setup()
  10. Called first, to initialise the dashboard. Put setup stuff in here rather than the constructor.
  11. - void Refresh()
  12. Called to refresh the dashboard's data.
  13. - void Shutdown()
  14. Called when closing the dashboard or navigating away.
  15. Also, you will need to define a property called "Properties", which is of type TProperties - in this case, IncompleteTasksDashboardProperties.
  16. This property is initialised automatically before Setup() is called from the saved dashboard properties. It is also automatically saved.
  17. In essence, don't worry about trying to save or load this manually. *Every* change you make to it should be saved.
  18. We need one final step to tell PRS where our dashboard is. You need to define a class that derives from PRSDesktop.DashboardElement<TDashboard, TGroup, TProperties>.
  19. UtilityDashboard.xaml.cs scans for all types that derive from this class, and this is how it marries up the saved dashboard properties and the dashboard classes.
  20. (Ultimately, it derives from DFLayoutElement). If you do not define this class, then you will not be able to create the dashboard; it will not appear in the menu.
  21. public class IncompleteTasksDashboardElement : DashboardElement<IncompleteTasksDashboard, Common, IncompleteTasksDashboardProperties> { }
  22. And that's basically it! Now you have a user control with properties that can be added to dashboards.