-
Notifications
You must be signed in to change notification settings - Fork 4
/
SunburstItemExtensionModule.cs
47 lines (46 loc) · 2.21 KB
/
SunburstItemExtensionModule.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
using DevExpress.DashboardCommon;
using DevExpress.DashboardWin;
using DevExpress.XtraBars;
using DevExpress.XtraBars.Ribbon;
namespace DevExpress.DashboardWin.CustomItemExtension {
public class SunburstItemExtensionModule : IExtensionModule {
IDashboardControl dashboardControl;
public void AttachViewer(DashboardViewer viewer) {
AttachDashboardControl(viewer);
}
public void DetachViewer() {
Detach();
}
public void AttachDesigner(DashboardDesigner designer) {
AttachDashboardControl(designer);
designer.CreateCustomItemBars(typeof(SunburstItemMetadata));
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) {
IDashboardControl dashboardControl = (IDashboardControl)sender;
if(e.MetadataType == typeof(SunburstItemMetadata))
e.CustomControlProvider = new SunburstItemControlProvider(
dashboardControl.Dashboard.Items[e.DashboardItemName] as CustomDashboardItem<SunburstItemMetadata>);
}
void RemoveDrillDownBarItem(DashboardDesigner designer) {
RibbonPage page = designer.Ribbon.GetDashboardRibbonPage(typeof(SunburstItemMetadata), DashboardRibbonPage.Data);
RibbonPageGroup interactivityGroup = page.Groups[1];
BarItem drillDownBarItem = interactivityGroup.ItemLinks[2].Item;
interactivityGroup.ItemLinks.Remove(drillDownBarItem);
}
}
}