-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathMainWindow.xaml.cs
52 lines (45 loc) · 1.98 KB
/
MainWindow.xaml.cs
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
using DevExpress.DashboardCommon;
using System;
using System.Windows;
using System.Xml.Linq;
namespace WpfDashboard_DashboardState
{
/// <summary>
/// Interaction logic for MainWindow.xaml
/// </summary>
public partial class MainWindow : Window
{
public static readonly string PropertyName = "DashboardState";
public MainWindow()
{
InitializeComponent();
}
DashboardState GetDataFromString(string customPropertyValue) {
DashboardState dState = new DashboardState();
if(!string.IsNullOrEmpty(customPropertyValue)) {
var xmlStateEl = XDocument.Parse(customPropertyValue);
dState.LoadFromXml(xmlStateEl);
}
return dState;
}
private void dashboardControl_DashboardLoaded(object sender, DevExpress.DashboardWpf.DashboardLoadedEventArgs e) {
}
private void dashboardControl_SetInitialDashboardState(object sender, DevExpress.DashboardWpf.SetInitialDashboardStateWpfEventArgs e)
{
var state = GetDataFromString(dashboardControl.Dashboard.CustomProperties.GetValue(PropertyName));
e.InitialState = state;
}
private void Window_Closing(object sender, System.ComponentModel.CancelEventArgs e)
{
var dState = dashboardControl.GetDashboardState();
var stateValue = dState.SaveToXml().ToString(SaveOptions.DisableFormatting);
dashboardControl.Dashboard.CustomProperties.SetValue("DashboardState", stateValue);
dashboardControl.Dashboard.SaveToXml("SampleDashboardWithState.xml");
}
private void DashboardControl_ConfigureDataConnection(object sender, DashboardConfigureDataConnectionEventArgs e)
{
ExtractDataSourceConnectionParameters connParams = e.ConnectionParameters as ExtractDataSourceConnectionParameters;
connParams.FileName = "Data\\SalesPerson.dat";
}
}
}