-
Notifications
You must be signed in to change notification settings - Fork 0
/
CustomPopupForm.vb
129 lines (112 loc) · 3.71 KB
/
CustomPopupForm.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
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
Imports Microsoft.VisualBasic
Imports System
Imports System.Collections.Generic
Imports System.Windows.Forms
Imports DevExpress.Skins
Imports DevExpress.XtraEditors.Registrator
Imports DevExpress.XtraEditors.Repository
Imports System.Drawing
Imports DevExpress.XtraEditors
Imports System.ComponentModel
Imports DevExpress.XtraEditors.ViewInfo
Imports DevExpress.XtraEditors.Drawing
Imports DevExpress.XtraEditors.Popup
Imports DevExpress.Utils.Drawing
Imports DevExpress.Utils
Namespace DXSample
Public Class CustomPopupForm
Inherits PopupListBoxForm
Private closeBtn As CloseButton = Nothing
Private closeButtonSize, clearButtonSize As Size
Private clearButtonRectangle_Renamed As Rectangle = Rectangle.Empty
Private isHotTrackClearButton_Renamed As Boolean = False
Public Sub New(ByVal edit As ComboBoxEdit)
MyBase.New(edit)
If OwnerEdit.Properties.ShowCloseButton Then
closeBtn = New CloseButton()
closeBtn.Parent = Me
AddHandler closeBtn.Click, AddressOf OnCloseButtonClick
closeButtonSize = New Size(16, 16)
End If
If OwnerEdit.Properties.ShowClearButton Then
clearButtonSize = New Size(35, 16)
End If
End Sub
Friend ReadOnly Property ClearButtonRectangle() As Rectangle
Get
Return clearButtonRectangle_Renamed
End Get
End Property
Friend Property IsHotTrackClearButton() As Boolean
Get
Return isHotTrackClearButton_Renamed
End Get
Set(ByVal value As Boolean)
If isHotTrackClearButton_Renamed <> value Then
isHotTrackClearButton_Renamed = value
Invalidate()
End If
End Set
End Property
Public Shadows ReadOnly Property OwnerEdit() As CustomEdit
Get
Return TryCast(MyBase.OwnerEdit, CustomEdit)
End Get
End Property
Public Overrides Property AllowSizing() As Boolean
Get
Return True
End Get
Set(ByVal value As Boolean)
MyBase.AllowSizing = value
End Set
End Property
Private Sub OnCloseButtonClick(ByVal sender As Object, ByVal e As EventArgs)
ClosePopup(PopupCloseMode.Cancel)
End Sub
Protected Overrides Sub SetupListBoxOnShow()
MyBase.SetupListBoxOnShow()
UpdateClearButtonBounds()
UpdateCloseButtonBounds()
End Sub
Private Sub UpdateClearButtonBounds()
If OwnerEdit.Properties.ShowClearButton Then
clearButtonRectangle_Renamed = New Rectangle(ViewInfo.SizeBarRect.X + closeButtonSize.Width + 2, ViewInfo.SizeBarRect.Y + 4, clearButtonSize.Width, clearButtonSize.Height)
End If
End Sub
Private Sub UpdateCloseButtonBounds()
If closeBtn IsNot Nothing Then
closeBtn.SetBounds(ViewInfo.SizeBarRect.X, ViewInfo.SizeBarRect.Y + 2, closeButtonSize.Width, closeButtonSize.Height)
End If
End Sub
Protected Overrides Sub UpdateControlPositionsCore()
MyBase.UpdateControlPositionsCore()
UpdateCloseButtonBounds()
UpdateClearButtonBounds()
End Sub
Protected Overrides Sub OnMouseMove(ByVal e As MouseEventArgs)
MyBase.OnMouseMove(e)
IsHotTrackClearButton = ClearButtonRectangle.Contains(e.Location)
End Sub
Protected Overrides Sub OnMouseDown(ByVal e As MouseEventArgs)
MyBase.OnMouseDown(e)
If ClearButtonRectangle.Contains(e.Location) Then
ClosePopup(PopupCloseMode.Normal)
OwnerEdit.EditValue = Nothing
End If
End Sub
Protected Overrides Sub OnVisibleChanged(ByVal e As EventArgs)
MyBase.OnVisibleChanged(e)
IsHotTrackClearButton = False
End Sub
Protected Overrides Function CreatePainter() As PopupBaseFormPainter
Return New CustomPopupBaseSizeableFormPainter()
End Function
Protected Overrides Overloads Sub Dispose(ByVal disposing As Boolean)
If disposing AndAlso closeBtn IsNot Nothing Then
RemoveHandler closeBtn.Click, AddressOf OnCloseButtonClick
End If
MyBase.Dispose(disposing)
End Sub
End Class
End Namespace