This repository has been archived by the owner on Sep 11, 2023. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 0
/
MyNavBarControl.vb
105 lines (99 loc) · 2.65 KB
/
MyNavBarControl.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
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
97
98
99
100
101
102
103
104
105
Imports Microsoft.VisualBasic
Imports System
Imports System.Drawing
Imports System.Collections
Imports System.ComponentModel
Imports System.Windows.Forms
Imports System.Data
Imports DevExpress.XtraNavBar
Namespace WindowsApplication1
Public Class MyNavBarControl
Inherits NavBarControl
Private Function NextGroup(ByVal group As NavBarGroup, ByVal forward As Boolean) As NavBarGroup
If Groups.Count = 0 Then '|| (Groups.Count == 1 && group != null)
Return Nothing
End If
If group Is Nothing Then
If (forward) Then
Return Groups(0)
Else
Return Groups(Groups.Count - 1)
End If
End If
If forward Then
If Groups.IndexOf(group) < Groups.Count - 1 Then
Return Groups(Groups.IndexOf(group) + 1)
Else
Return Groups(0)
End If
ElseIf Groups.IndexOf(group) > 0 Then
Return Groups(Groups.IndexOf(group) - 1)
Else
Return Groups(Groups.Count - 1)
End If
End Function
Private Function FindNearItemLink(ByVal forward As Boolean) As NavBarItemLink
Dim link As NavBarItemLink = SelectedLink
Dim group As NavBarGroup
If link Is Nothing Then
group = NextGroup(Nothing, forward)
Else
group = link.Group
End If
If group Is Nothing Then
Return Nothing
End If
Dim startGroup As NavBarGroup = group
Dim i As Integer
If link IsNot Nothing Then
i = group.ItemLinks.IndexOf(link)
Else
If (forward) Then
i = -1
Else
i = group.ItemLinks.Count
End If
End If
Dim repeat As Boolean = False
Do
If forward Then
If i < group.ItemLinks.Count - 1 Then
Return group.ItemLinks(i + 1)
Else
group = NextGroup(group, forward)
repeat = i > 0
i = -1
End If
Else
If i > 0 AndAlso group.ItemLinks.Count > 0 Then
Return group.ItemLinks(i - 1)
Else
group = NextGroup(group, forward)
repeat = i < group.ItemLinks.Count - 1
i = group.ItemLinks.Count
End If
End If
Loop While group IsNot startGroup OrElse repeat
Return Nothing
End Function
Public Sub SelectNextLink(ByVal forward As Boolean)
SelectedLink = FindNearItemLink(forward)
If SelectedLink IsNot Nothing AndAlso (Not SelectedLink.Group.Expanded) Then
SelectedLink.Group.Expanded = True
End If
ViewInfo.MakeLinkVisible(SelectedLink)
End Sub
Protected Overrides Function ProcessDialogKey(ByVal keyData As Keys) As Boolean
Dim key As Keys = keyData And ((Not Keys.Modifiers))
Select Case key
Case Keys.Down
SelectNextLink(True)
Case Keys.Up
SelectNextLink(False)
Case Else
Return MyBase.ProcessDialogKey(keyData)
End Select
Return False
End Function
End Class
End Namespace