This repository has been archived by the owner on Oct 16, 2023. It is now read-only.
/
SelectFirstNavigationItemControllerBase.vb
56 lines (54 loc) · 2.19 KB
/
SelectFirstNavigationItemControllerBase.vb
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
Imports Microsoft.VisualBasic
Imports System
Imports DevExpress.ExpressApp
Imports DevExpress.ExpressApp.Actions
Imports DevExpress.ExpressApp.Templates
Imports DevExpress.ExpressApp.SystemModule
Namespace DXExample.Module
Public MustInherit Class SelectFirstNavigationItemControllerBase
Inherits WindowController
Private showNavigationItemController As ShowNavigationItemController
Protected navigationAction As SingleChoiceAction
Public Sub New()
TargetWindowType = WindowType.Main
End Sub
Protected Overrides Sub OnActivated()
MyBase.OnActivated()
showNavigationItemController= Frame.GetController(Of ShowNavigationItemController)()
navigationAction = showNavigationItemController.ShowNavigationItemAction
AddHandler Frame.TemplateChanged, AddressOf Frame_TemplateChanged
End Sub
Protected Overrides Sub OnDeactivated()
MyBase.OnDeactivated()
RemoveHandler Frame.TemplateChanged, AddressOf Frame_TemplateChanged
End Sub
Private Sub Frame_TemplateChanged(ByVal sender As Object, ByVal e As EventArgs)
Dim navigationControl As IActionContainer = FindNavigationActionContainer()
If navigationControl IsNot Nothing Then
SetupNavigationControl(navigationControl)
End If
End Sub
Protected MustOverride Function FindNavigationActionContainer() As IActionContainer
Protected MustOverride Sub SetupNavigationControl(ByVal container As IActionContainer)
'protected void SelectFirstItem(int navGroupIndex) {
' AutoSelectFirstItemInGroup(navigationAction.Items[navGroupIndex]);
'}
Protected Sub AutoSelectFirstItemInGroup(ByVal navGroupItem As ChoiceActionItem)
If (Not CanAutoSelectFirstItemInGroup()) Then
Return
End If
If navGroupItem.Items.Contains(navigationAction.SelectedItem)
Return
End If
For Each item As ChoiceActionItem In navGroupItem.Items
If item.Enabled.ResultValue AndAlso item.Active.ResultValue Then
navigationAction.DoExecute(item)
Return
End If
Next item
End Sub
Protected Function CanAutoSelectFirstItemInGroup() As Boolean
Return (CType((CType(Application.Model, IModelApplicationNavigationItems)).NavigationItems, IModelRootNavigationItemsEx)).AllowSelectFirstItem
End Function
End Class
End Namespace