-
Notifications
You must be signed in to change notification settings - Fork 7
/
HideProtectedContentController.cs
43 lines (42 loc) · 1.51 KB
/
HideProtectedContentController.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
using DevExpress.ExpressApp;
using DevExpress.ExpressApp.Editors;
using DevExpress.ExpressApp.ConditionalAppearance;
namespace MainDemo.Module.Controllers {
public class HideProtectedContentController : ViewController<ObjectView> {
private AppearanceController appearanceController;
protected override void OnActivated() {
base.OnActivated();
appearanceController = Frame.GetController<AppearanceController>();
if(appearanceController != null) {
appearanceController.CustomApplyAppearance += appearanceController_CustomApplyAppearance;
}
}
protected override void OnDeactivated() {
if(appearanceController != null) {
appearanceController.CustomApplyAppearance -= appearanceController_CustomApplyAppearance;
}
base.OnDeactivated();
}
void appearanceController_CustomApplyAppearance(object sender, ApplyAppearanceEventArgs e) {
if(View is ListView) {
if(e.Item is ColumnWrapper) {
if(!DataManipulationRight.CanRead(View.ObjectTypeInfo.Type,
((ColumnWrapper)e.Item).PropertyName, null,
((ListView)View).CollectionSource, View.ObjectSpace)) {
e.AppearanceObject.Visibility = ViewItemVisibility.Hide;
}
}
}
if(View is DetailView) {
if(e.Item is PropertyEditor) {
if(!DataManipulationRight.CanRead(View.ObjectTypeInfo.Type,
((PropertyEditor)e.Item).PropertyName,
e.ContextObjects.Length > 0 ? e.ContextObjects[0] : null, null,
View.ObjectSpace)) {
e.AppearanceObject.Visibility = ViewItemVisibility.Hide;
}
}
}
}
}
}