-
Notifications
You must be signed in to change notification settings - Fork 3
/
SankeyItemExtensionModule.cs
45 lines (44 loc) · 2.1 KB
/
SankeyItemExtensionModule.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
using DevExpress.DashboardCommon;
using DevExpress.DashboardWin;
using DevExpress.XtraBars;
using DevExpress.XtraBars.Ribbon;
namespace DevExpress.DashboardWin.CustomItemExtension {
public class SankeyItemExtensionModule : IExtensionModule {
IDashboardControl dashboardControl;
public void AttachViewer(DashboardViewer viewer) {
AttachDashboardControl(viewer);
}
public void DetachViewer() {
Detach();
}
public void AttachDesigner(DashboardDesigner designer) {
AttachDashboardControl(designer);
designer.CreateCustomItemBars(typeof(SankeyItemMetadata));
RemoveDrillDownBarItem(designer);
}
public void DetachDesigner() {
Detach();
}
void Detach() {
if(dashboardControl != null)
dashboardControl.CustomDashboardItemControlCreating -= OnCustomDashboardItemControlCreating;
}
void AttachDashboardControl(IDashboardControl dashboardControl) {
if(dashboardControl != null) {
this.dashboardControl = dashboardControl;
dashboardControl.CalculateHiddenTotals = true;
dashboardControl.CustomDashboardItemControlCreating += OnCustomDashboardItemControlCreating;
}
}
void OnCustomDashboardItemControlCreating(object sender, CustomDashboardItemControlCreatingEventArgs e) {
if(e.MetadataType == typeof(SankeyItemMetadata))
e.CustomControlProvider = new SankeyItemControlProvider(dashboardControl.Dashboard.Items[e.DashboardItemName] as CustomDashboardItem<SankeyItemMetadata>);
}
void RemoveDrillDownBarItem(DashboardDesigner designer) {
RibbonPage page = designer.Ribbon.GetDashboardRibbonPage(typeof(SankeyItemMetadata), DashboardRibbonPage.Data);
RibbonPageGroup interactivityGroup = page.Groups[1];
BarItem drillDownBarItem = interactivityGroup.ItemLinks[2].Item;
interactivityGroup.ItemLinks.Remove(drillDownBarItem);
}
}
}