-
Notifications
You must be signed in to change notification settings - Fork 0
/
DockLayoutManagerExt.vb
95 lines (76 loc) · 4.04 KB
/
DockLayoutManagerExt.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
Imports System.Windows
Imports DevExpress.Xpf.Layout.Core
Imports DevExpress.Xpf.Docking
Imports DevExpress.Xpf.Docking.Platform
Namespace DXDockingForLayoutPurposes
'S171364
Friend Class DockLayoutManagerExt
Inherits DockLayoutManager
Private layoutView As IView
Private customizationView As IView
Protected Overrides Function CreateLayoutView(ByVal element As IUIElement) As IView
layoutView = New CustomLayoutView(element)
Return layoutView
End Function
Protected Overrides Function CreateCustomizationView(ByVal element As IUIElement) As IView
customizationView = New MyCustomizationView(element)
Return customizationView
End Function
End Class
Public Class MyCustomizationView
Inherits CustomizationView
Public Sub New(ByVal viewUIElement As IUIElement)
MyBase.New(viewUIElement)
End Sub
Protected Overrides Sub RegisterListeners()
RegisterUIServiceListener(New LayoutViewSelectionListener())
RegisterUIServiceListener(New CustomizationViewUIInteractionListener())
RegisterUIServiceListener(New MyCustomizationDraggingListener()) 'my version
End Sub
End Class
Public Class CustomLayoutView
Inherits LayoutView
Public Sub New(ByVal viewUIElement As IUIElement)
MyBase.New(viewUIElement)
End Sub
Protected Overrides Sub RegisterListeners()
RegisterUIServiceListener(New LayoutViewRegularDragListener())
RegisterUIServiceListener(New LayoutViewFloatingDragListener())
RegisterUIServiceListener(New LayoutViewReorderingListener())
RegisterUIServiceListener(New MyDragListener()) ' my version
RegisterUIServiceListener(New LayoutViewNonClientDraggingListener())
RegisterUIServiceListener(New LayoutViewUIInteractionListener())
RegisterUIServiceListener(New LayoutViewSelectionListener())
RegisterUIServiceListener(New LayoutViewActionListener())
End Sub
End Class
Public Class MyDragListener
Inherits LayoutViewClientDraggingListener
Public Overrides Function CanDrop(ByVal point As Point, ByVal element As ILayoutElement) As Boolean
Dim dockLayoutElementDragInfo As DockLayoutElementDragInfo = New DockLayoutElementDragInfo(View, point, element)
Dim draggedItem As BaseLayoutItem = dockLayoutElementDragInfo.Item
Dim target As BaseLayoutItem = dockLayoutElementDragInfo.Target
If Not DragHelper.IsItemInGroup(draggedItem) AndAlso Not DragHelper.IsTargetInGroup(target) Then
Return MyBase.CanDrop(point, element)
End If
Dim result As Boolean = DragHelper.AllowMoving(draggedItem, target)
Return result
End Function
End Class
Public Class MyCustomizationDraggingListener
Inherits CustomizationViewClientDraggingListener
Public Overrides Function CanDrop(ByVal point As Point, ByVal element As ILayoutElement) As Boolean
Dim dockLayoutElementDragInfo As DockLayoutElementDragInfo = New DockLayoutElementDragInfo(View, point, element)
Dim draggedItem = dockLayoutElementDragInfo.Item
Dim target = dockLayoutElementDragInfo.Target
If(TypeOf dockLayoutElementDragInfo.DropTarget Is HiddenItemElement OrElse TypeOf dockLayoutElementDragInfo.DropTarget Is HiddenItemsListElement) AndAlso dockLayoutElementDragInfo.Item.AllowHide Then
Dim itemType As LayoutItemType = dockLayoutElementDragInfo.Item.ItemType
Return(LayoutItemsHelper.IsLayoutItem(dockLayoutElementDragInfo.Item) OrElse itemType = LayoutItemType.Group)
End If
If Not DragHelper.IsItemInGroup(draggedItem) AndAlso Not DragHelper.IsTargetInGroup(target) Then
Return MyBase.CanDrop(point, element)
End If
Return DragHelper.AllowMoving(draggedItem, target)
End Function
End Class
End Namespace