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
/
CustomSizablePopupHelper.vb
103 lines (101 loc) · 4.19 KB
/
CustomSizablePopupHelper.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
Imports DevExpress.Utils
Imports DevExpress.Utils.Drawing
Imports DevExpress.XtraEditors.Popup
Imports System.Drawing
Imports System.Windows.Forms
Namespace DXApplication2
Friend Class CustomSizablePopupHelper
Inherits SizablePopupHelper
Protected pointOffset As Point
Protected cursor As Cursor = Cursors.Default
Protected ReadOnly Property popupListBoxForm() As CustomComboBoxPopupListBoxForm
Get
Return TryCast(Owner, CustomComboBoxPopupListBoxForm)
End Get
End Property
Public Sub New(ByVal owner As IPopupSizeableForm)
MyBase.New(owner)
End Sub
Public Overrides Function OnMouseMove(ByVal e As MouseEventArgs) As DXMouseEventArgs
Dim ee As DXMouseEventArgs = DXMouseEventArgs.GetMouseArgs(e)
Dim changeCursor As Boolean = False
If Not ee.Handled Then
If Sizing Then
DoSizing(New Point(e.X, e.Y))
changeCursor = True
ee.Handled = True
ElseIf e.Button = MouseButtons.None AndAlso popupListBoxForm.IsSizePoint(e.Location) Then
cursor = popupListBoxForm.GetGripCursor(e.Location)
changeCursor = True
ee.Handled = True
End If
UpdateCursor(changeCursor)
End If
Return ee
End Function
Public Overrides Function OnMouseDown(ByVal e As MouseEventArgs) As DXMouseEventArgs
Dim ee As DXMouseEventArgs = DXMouseEventArgs.GetMouseArgs(e)
If Not ee.Handled Then
If ee.Button = MouseButtons.Left AndAlso e.Clicks = 1 AndAlso popupListBoxForm.IsSizePoint(e.Location) Then
cursor = popupListBoxForm.GetGripCursor(e.Location)
ee.Handled = True
StartSizing()
End If
End If
Return ee
End Function
Protected Overrides Sub UpdateCursor(ByVal setSizing As Boolean)
If setSizing Then
If cursor = Cursors.Default Then
System.Windows.Forms.Cursor.Current = Owner.CalcGripCursor(Owner.GripPosition)
Else
System.Windows.Forms.Cursor.Current = cursor
End If
Else
System.Windows.Forms.Cursor.Current = Owner.Form.Cursor
End If
End Sub
Protected Overrides Sub StartSizing()
MyBase.StartSizing()
CalcPointOffset()
End Sub
Protected Shadows Sub CalcPointOffset()
Dim SizingCornerLocation As Point = GetSizingCornerLocation()
pointOffset = SizingCornerLocation
pointOffset.Offset(-Control.MousePosition.X, -Control.MousePosition.Y)
End Sub
Public Overrides Sub DoSizing(ByVal p As Point)
Dim gp As SizeGripPosition = Owner.GripPosition
If Owner.Form.RightToLeftLayout Then
gp = CustomComboBoxPopupListBoxForm.InvertGripPosition(gp)
End If
If cursor = Cursors.SizeNS Then
If gp = SizeGripPosition.LeftBottom OrElse gp = SizeGripPosition.LeftTop Then
p.X = SizingBounds.X
Else
p.X = SizingBounds.Right
End If
p.X = PointToClient(p).X
ElseIf cursor = Cursors.SizeWE Then
If gp = SizeGripPosition.LeftBottom OrElse gp = SizeGripPosition.RightBottom Then
p.Y = SizingBounds.Bottom
Else
p.Y = SizingBounds.Y
End If
p.Y = PointToClient(p).Y
End If
MyBase.DoSizing(p)
End Sub
Protected Function PointToClient(ByVal p As Point) As Point
If Not GetIsRightToLeftLayout() Then
p.Offset(-pointOffset.X, -pointOffset.Y)
p = Owner.Form.PointToClient(p)
Return p
End If
p.Y -= SizingBounds.Y
p.X -= SizingBounds.X
p.X = SizingBounds.Width - p.X
Return p
End Function
End Class
End Namespace