feat(ModEvent): 支持一个按钮执行多个事件
没给 HelpEntry 加这个功能,其他控件都加了
This commit is contained in:
@@ -150,7 +150,7 @@ Public Class MyButton
|
||||
Hint("主页自定义按钮语法已更新,且不再兼容老版本语法,请查看新的自定义示例!")
|
||||
End If
|
||||
End If
|
||||
ModEvent.TryStartEvent(EventType, EventData)
|
||||
ModEvent.ProcessCustomEvents(EventType, EventData, _CustomEvents)
|
||||
End Sub
|
||||
Public Property EventType As String
|
||||
Get
|
||||
@@ -170,6 +170,18 @@ Public Class MyButton
|
||||
End Set
|
||||
End Property
|
||||
Public Shared ReadOnly EventDataProperty As DependencyProperty = DependencyProperty.Register("EventData", GetType(String), GetType(MyButton), New PropertyMetadata(Nothing))
|
||||
Public Property CustomEvents As CustomEventCollection
|
||||
Get
|
||||
If _CustomEvents Is Nothing Then
|
||||
_CustomEvents = New CustomEventCollection
|
||||
End If
|
||||
Return _CustomEvents
|
||||
End Get
|
||||
Set(value As CustomEventCollection)
|
||||
_CustomEvents = value
|
||||
End Set
|
||||
End Property
|
||||
Private _CustomEvents As CustomEventCollection = Nothing
|
||||
|
||||
'鼠标点击判定(务必放在点击事件之后,以使得 Button_MouseUp 先于 Button_MouseLeave 执行)
|
||||
Private IsMouseDown As Boolean = False
|
||||
|
||||
@@ -79,7 +79,7 @@ Public Class MyHint
|
||||
IsMouseDown = False
|
||||
Log("[Control] 按下提示条" & If(String.IsNullOrEmpty(Name), "", ":" & Name))
|
||||
e.Handled = True
|
||||
ModEvent.TryStartEvent(EventType, EventData)
|
||||
ModEvent.ProcessCustomEvents(EventType, EventData, _CustomEvents)
|
||||
End Sub
|
||||
Private Sub MyHint_MouseDown(sender As Object, e As MouseButtonEventArgs) Handles Me.MouseLeftButtonDown
|
||||
IsMouseDown = True
|
||||
@@ -105,6 +105,18 @@ Public Class MyHint
|
||||
End Set
|
||||
End Property
|
||||
Public Shared ReadOnly EventDataProperty As DependencyProperty = DependencyProperty.Register("EventData", GetType(String), GetType(MyHint), New PropertyMetadata(Nothing))
|
||||
Public Property CustomEvents As CustomEventCollection
|
||||
Get
|
||||
If _CustomEvents Is Nothing Then
|
||||
_CustomEvents = New CustomEventCollection
|
||||
End If
|
||||
Return _CustomEvents
|
||||
End Get
|
||||
Set(value As CustomEventCollection)
|
||||
_CustomEvents = value
|
||||
End Set
|
||||
End Property
|
||||
Private _CustomEvents As CustomEventCollection = Nothing
|
||||
|
||||
End Class
|
||||
Partial Public Module ModAnimation
|
||||
|
||||
@@ -55,7 +55,7 @@
|
||||
RaiseEvent Click(sender, e)
|
||||
e.Handled = True
|
||||
Button_MouseUp()
|
||||
ModEvent.TryStartEvent(EventType, EventData)
|
||||
ModEvent.ProcessCustomEvents(EventType, EventData, _CustomEvents)
|
||||
End Sub
|
||||
Public Property EventType As String
|
||||
Get
|
||||
@@ -75,6 +75,18 @@
|
||||
End Set
|
||||
End Property
|
||||
Public Shared ReadOnly EventDataProperty As DependencyProperty = DependencyProperty.Register("EventData", GetType(String), GetType(MyIconButton), New PropertyMetadata(Nothing))
|
||||
Public Property CustomEvents As CustomEventCollection
|
||||
Get
|
||||
If _CustomEvents Is Nothing Then
|
||||
_CustomEvents = New CustomEventCollection
|
||||
End If
|
||||
Return _CustomEvents
|
||||
End Get
|
||||
Set(value As CustomEventCollection)
|
||||
_CustomEvents = value
|
||||
End Set
|
||||
End Property
|
||||
Private _CustomEvents As CustomEventCollection = Nothing
|
||||
|
||||
'鼠标点击判定(务必放在点击事件之后,以使得 Button_MouseUp 先于 Button_MouseLeave 执行)
|
||||
Private IsMouseDown As Boolean = False
|
||||
|
||||
@@ -76,7 +76,7 @@ Public Class MyIconTextButton
|
||||
Log("[Control] 按下带图标按钮:" & Text)
|
||||
IsMouseDown = False
|
||||
RaiseEvent Click(Me, New RouteEventArgs(True))
|
||||
ModEvent.TryStartEvent(EventType, EventData)
|
||||
ModEvent.ProcessCustomEvents(EventType, EventData, _CustomEvents)
|
||||
RefreshColor()
|
||||
End Sub
|
||||
Private Sub MyIconTextButton_MouseDown() Handles Me.MouseLeftButtonDown
|
||||
@@ -105,6 +105,18 @@ Public Class MyIconTextButton
|
||||
End Set
|
||||
End Property
|
||||
Public Shared ReadOnly EventDataProperty As DependencyProperty = DependencyProperty.Register("EventData", GetType(String), GetType(MyIconTextButton), New PropertyMetadata(Nothing))
|
||||
Public Property CustomEvents As CustomEventCollection
|
||||
Get
|
||||
If _CustomEvents Is Nothing Then
|
||||
_CustomEvents = New CustomEventCollection
|
||||
End If
|
||||
Return _CustomEvents
|
||||
End Get
|
||||
Set(value As CustomEventCollection)
|
||||
_CustomEvents = value
|
||||
End Set
|
||||
End Property
|
||||
Private _CustomEvents As CustomEventCollection = Nothing
|
||||
|
||||
'动画
|
||||
|
||||
|
||||
@@ -507,7 +507,7 @@ Public Class MyListItem
|
||||
If e.Handled Then Exit Sub
|
||||
'触发自定义事件
|
||||
If Not String.IsNullOrEmpty(EventType) Then
|
||||
ModEvent.TryStartEvent(EventType, EventData)
|
||||
ModEvent.ProcessCustomEvents(EventType, EventData, _CustomEvents)
|
||||
e.Handled = True
|
||||
End If
|
||||
If e.Handled Then Exit Sub
|
||||
@@ -556,6 +556,18 @@ Public Class MyListItem
|
||||
End Set
|
||||
End Property
|
||||
Public Shared ReadOnly EventDataProperty As DependencyProperty = DependencyProperty.Register("EventData", GetType(String), GetType(MyListItem), New PropertyMetadata(Nothing))
|
||||
Public Property CustomEvents As CustomEventCollection
|
||||
Get
|
||||
If _CustomEvents Is Nothing Then
|
||||
_CustomEvents = New CustomEventCollection
|
||||
End If
|
||||
Return _CustomEvents
|
||||
End Get
|
||||
Set(value As CustomEventCollection)
|
||||
_CustomEvents = value
|
||||
End Set
|
||||
End Property
|
||||
Private _CustomEvents As CustomEventCollection = Nothing
|
||||
|
||||
#End Region
|
||||
|
||||
|
||||
@@ -47,7 +47,7 @@
|
||||
IsMouseDown = False
|
||||
Log("[Control] 按下文本按钮:" & Text)
|
||||
RaiseEvent Click(Me, Nothing)
|
||||
ModEvent.TryStartEvent(EventType, EventData)
|
||||
ModEvent.ProcessCustomEvents(EventType, EventData, _CustomEvents)
|
||||
e.Handled = True
|
||||
End If
|
||||
End Sub
|
||||
@@ -106,5 +106,17 @@
|
||||
End Property
|
||||
Public Shared ReadOnly EventDataProperty As DependencyProperty = DependencyProperty.Register(
|
||||
"EventData", GetType(String), GetType(MyTextButton), New PropertyMetadata(Nothing))
|
||||
Public Property CustomEvents As CustomEventCollection
|
||||
Get
|
||||
If _CustomEvents Is Nothing Then
|
||||
_CustomEvents = New CustomEventCollection
|
||||
End If
|
||||
Return _CustomEvents
|
||||
End Get
|
||||
Set(value As CustomEventCollection)
|
||||
_CustomEvents = value
|
||||
End Set
|
||||
End Property
|
||||
Private _CustomEvents As CustomEventCollection = Nothing
|
||||
|
||||
End Class
|
||||
|
||||
Reference in New Issue
Block a user