-
Notifications
You must be signed in to change notification settings - Fork 0
/
MyLayoutControl.vb
77 lines (66 loc) · 2.93 KB
/
MyLayoutControl.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
' Developer Express Code Central Example:
' How to place controls in a LayoutControl's tabbed group header
'
' By default, it is not possible to place any control within a tabbed group
' header, because the LayoutControl's layout can be widely customized (groups can
' be moved and hidden, their direction can be changed). However, you can emulate
' controls by custom drawing them. This example demonstrates how to draw a
' CheckBox and ProgressBar in headers.
'
' You can find sample updates and versions for different programming languages here:
' http://www.devexpress.com/example=E2811
Imports System.Collections.Generic
Imports System.ComponentModel
Imports System.Drawing
Imports System.Windows.Forms
Imports DevExpress.XtraLayout.Registrator
Imports DevExpress.XtraLayout
Imports DevExpress.XtraLayout.Painting
Imports DevExpress.XtraLayout.ViewInfo
Imports DevExpress.Utils.Drawing
Imports System.Runtime.InteropServices
Namespace WindowsApplication1
<System.ComponentModel.DesignerCategory("")>
Public Class MyLayoutControl
Inherits LayoutControl
Private _GroupItems As Dictionary(Of TabbedGroup, InplaceEditorInfo()) = New Dictionary(Of TabbedGroup, InplaceEditorInfo())()
Public Property TabGroupItems As Dictionary(Of TabbedGroup, InplaceEditorInfo())
Get
Return _GroupItems
End Get
Set(ByVal value As Dictionary(Of TabbedGroup, InplaceEditorInfo()))
_GroupItems = value
End Set
End Property
Protected Overrides Function CreateILayoutControlImplementorCore() As LayoutControlImplementor
Return New MyLayoutControlImplementor(Me)
End Function
Protected Overrides Sub OnMouseDown(ByVal e As MouseEventArgs)
MyBase.OnMouseDown(e)
CheckCustomEditorsClick(e)
End Sub
Private Function FindEditorInfo(ByVal location As Point, <Out> ByRef key As TabbedGroup, <Out> ByRef resultInfo As InplaceEditorInfo) As Boolean
key = Nothing
resultInfo = Nothing
For Each pair As KeyValuePair(Of TabbedGroup, InplaceEditorInfo()) In TabGroupItems
For Each info As InplaceEditorInfo In pair.Value
If info.Bounds.Contains(location) Then
key = pair.Key
resultInfo = info
Return True
End If
Next
Next
Return False
End Function
Private Sub CheckCustomEditorsClick(ByVal e As MouseEventArgs)
Dim key As TabbedGroup
Dim resultInfo As InplaceEditorInfo
If FindEditorInfo(e.Location, key, resultInfo) Then OnEditorClick(key, resultInfo)
End Sub
Private Sub OnEditorClick(ByVal group As TabbedGroup, ByVal info As InplaceEditorInfo)
info.RaiseMouseDown()
Refresh()
End Sub
End Class
End Namespace