-
Notifications
You must be signed in to change notification settings - Fork 1
/
ChildWindow.xaml.cs
96 lines (91 loc) · 3.78 KB
/
ChildWindow.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
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
using DevExpress.DashboardCommon;
using DevExpress.DashboardCommon.ViewerData;
using DevExpress.DashboardWpf;
using System.Collections.Generic;
using System.Linq;
using System.Windows;
namespace WpfDashboard_LinkedInteractivity
{
/// <summary>
/// Interaction logic for ChildWindow.xaml
/// </summary>
public partial class ChildWindow : Window
{
private DashboardControl dControl;
public ChildWindow(DashboardControl dControl)
{
InitializeComponent();
this.dControl = dControl;
}
private void Window_Loaded(object sender, RoutedEventArgs e)
{
childDashboardControl.LoadDashboard("Data\\DashboardChild.xml");
DashboardControl dParentControl = this.dControl;
dParentControl.MasterFilterSet += DControl_MasterFilterSet;
dParentControl.MasterFilterCleared += DControl_MasterFilterCleared;
dParentControl.DrillDownPerformed += DControl_DrillDownPerformed;
dParentControl.DrillUpPerformed += DControl_DrillUpPerformed;
}
bool HasDashboardItem(string itemName)
{
return childDashboardControl.Dashboard.Items.
Select(i => i.ComponentName).Contains(itemName);
}
private void DControl_MasterFilterSet(object sender, MasterFilterSetEventArgs e)
{
if (HasDashboardItem(e.DashboardItemName))
{
string itemName = e.DashboardItemName;
if (e.SelectedValues != null)
childDashboardControl.SetMasterFilter(itemName, e.SelectedValues);
if (e.SelectedRange != null)
childDashboardControl.SetRange(itemName, e.SelectedRange);
}
}
private void DControl_MasterFilterCleared(object sender, MasterFilterClearedEventArgs e)
{
if (HasDashboardItem(e.DashboardItemName))
{
string itemName = e.DashboardItemName;
if (childDashboardControl.CanClearMasterFilter(itemName))
childDashboardControl.ClearMasterFilter(itemName);
}
}
private void DControl_DrillDownPerformed(object sender, DrillActionEventArgs e)
{
if (HasDashboardItem(e.DashboardItemName))
{
string itemName = e.DashboardItemName;
DashboardDataRow row = e.Values[0];
object value = row[row.Length - 1];
IList<AxisPointTuple> tuple = childDashboardControl.GetAvailableDrillDownValues(itemName);
IEnumerable<object> availableValues = tuple.Select(t => t.GetAxisPoint().UniqueValue);
if (availableValues.Contains(value))
{
childDashboardControl.PerformDrillDown(e.DashboardItemName, value);
}
}
}
private void DControl_DrillUpPerformed(object sender, DrillActionEventArgs e)
{
if (HasDashboardItem(e.DashboardItemName))
{
string itemName = e.DashboardItemName;
int level = e.DrillDownLevel;
AxisPointTuple tuple = childDashboardControl.GetCurrentDrillDownValues(itemName);
if (tuple != null)
{
AxisPoint point = childDashboardControl.GetCurrentDrillDownValues(itemName).GetAxisPoint();
int l = 0;
while (point.Parent != null)
{
l++;
point = point.Parent;
}
if ((level + 1) == l && childDashboardControl.CanPerformDrillUp(itemName))
childDashboardControl.PerformDrillUp(itemName);
}
}
}
}
}