The following example demonstrates how to implement custom saving and opening procedures in Dashboard Designer using the DashboardSaving and DashboardOpening events respectively.
In this example, the dashboard XML definition can be saved (opened) only to(from) the specified default location.
The DashboardSaving event is handled to implement a custom saving routine. Its DashboardSavingEventArgs.Command event parameter allows determining what user action raises the event. The Dashboard.SaveToXml method is used to save the dashboard to the specified XML file. Then, the DashboardSavingEventArgs.Handled event parameter is used to specify that the dashboard has been saved and no default actions are required.
Clicking the Save As button invokes a message box that allows saving the dashboard to the default location or cancel the saving procedure. The DashboardSavingEventArgs.Saved event parameter is used to notify whether the custom saving routine has succeeded.
The DashboardOpening event is handled to implement a custom opening procedure. The DashboardDesigner.LoadDashboard method is called to load the dashboard from the default location. The DashboardOpeningEventArgs.Handled event parameter allows specifying that no default actions are required to open the dashboard.