MyHint.xaml.vb 6.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128
  1. Imports System.Windows.Markup
  2. <ContentProperty("Inlines")>
  3. Public Class MyHint
  4. Public Uuid As Integer = GetUuid()
  5. Private _IsWarn As Boolean = True
  6. Public Property IsWarn As Boolean
  7. Get
  8. Return _IsWarn
  9. End Get
  10. Set(value As Boolean)
  11. If _IsWarn = value Then Exit Property
  12. _IsWarn = value
  13. If _IsWarn Then
  14. BorderBrush = New MyColor("#CCFF4444")
  15. Gradient1.Color = New MyColor("#BBFFBBBB")
  16. Gradient2.Color = New MyColor("#BBFF8888")
  17. Path.Fill = New MyColor("#BF0000")
  18. LabText.Foreground = New MyColor("#BF0000")
  19. BtnClose.Foreground = New MyColor("#BF0000")
  20. Path.Data = (New GeometryConverter).ConvertFromString("F1 M 58.5832,55.4172L 17.4169,55.4171C 15.5619,53.5621 15.5619,50.5546 17.4168,48.6996L 35.201,15.8402C 37.056,13.9852 40.0635,13.9852 41.9185,15.8402L 58.5832,48.6997C 60.4382,50.5546 60.4382,53.5622 58.5832,55.4172 Z M 34.0417,25.7292L 36.0208,41.9584L 39.9791,41.9583L 41.9583,25.7292L 34.0417,25.7292 Z M 38,44.3333C 36.2511,44.3333 34.8333,45.7511 34.8333,47.5C 34.8333,49.2489 36.2511,50.6667 38,50.6667C 39.7489,50.6667 41.1666,49.2489 41.1666,47.5C 41.1666,45.7511 39.7489,44.3333 38,44.3333 Z ")
  21. Else
  22. BorderBrush = New MyColor("#CC4D76FF")
  23. Gradient1.Color = New MyColor("#BBB0D0FF")
  24. Gradient2.Color = New MyColor("#BB9EBAFF")
  25. Path.Fill = New MyColor("#0062BF")
  26. LabText.Foreground = New MyColor("#0062BF")
  27. BtnClose.Foreground = New MyColor("#0062BF")
  28. Path.Data = (New GeometryConverter).ConvertFromString("F1M38,19C48.4934,19 57,27.5066 57,38 57,48.4934 48.4934,57 38,57 27.5066,57 19,48.4934 19,38 19,27.5066 27.5066,19 38,19z M33.25,33.25L33.25,36.4167 36.4166,36.4167 36.4166,47.5 33.25,47.5 33.25,50.6667 44.3333,50.6667 44.3333,47.5 41.1666,47.5 41.1666,36.4167 41.1666,33.25 33.25,33.25z M38.7917,25.3333C37.48,25.3333 36.4167,26.3967 36.4167,27.7083 36.4167,29.02 37.48,30.0833 38.7917,30.0833 40.1033,30.0833 41.1667,29.02 41.1667,27.7083 41.1667,26.3967 40.1033,25.3333 38.7917,25.3333z")
  29. End If
  30. End Set
  31. End Property
  32. Public ReadOnly Property Inlines As InlineCollection
  33. Get
  34. Return LabText.Inlines
  35. End Get
  36. End Property
  37. Public Property Text As String
  38. Get
  39. Return GetValue(TextProperty)
  40. End Get
  41. Set(value As String)
  42. SetValue(TextProperty, value)
  43. End Set
  44. End Property
  45. Public Shared ReadOnly TextProperty As DependencyProperty =
  46. DependencyProperty.Register("Text", GetType(String), GetType(MyHint), New PropertyMetadata("",
  47. Sub(d As MyHint, e As DependencyPropertyChangedEventArgs)
  48. d.LabText.Text = e.NewValue
  49. End Sub))
  50. Public Property CanClose As Boolean
  51. Get
  52. Return BtnClose.Visibility = Visibility.Visible
  53. End Get
  54. Set(value As Boolean)
  55. BtnClose.Visibility = If(value, Visibility.Visible, Visibility.Collapsed)
  56. End Set
  57. End Property
  58. Public Property RelativeSetup As String = ""
  59. Private Sub MyHint_Loaded(sender As Object, e As RoutedEventArgs) Handles Me.Loaded
  60. If CanClose AndAlso Setup.Get(RelativeSetup) Then
  61. Visibility = Visibility.Collapsed
  62. End If
  63. End Sub
  64. Private Sub BtnClose_Click(sender As Object, e As EventArgs) Handles BtnClose.Click
  65. Setup.Set(RelativeSetup, True)
  66. AniDispose(Me, False)
  67. End Sub
  68. '触发点击事件
  69. Private IsMouseDown As Boolean = False
  70. Private Sub MyHint_MouseUp(sender As Object, e As MouseButtonEventArgs) Handles Me.MouseLeftButtonUp
  71. If Not IsMouseDown Then Return
  72. IsMouseDown = False
  73. Log("[Control] 按下提示条" & If(String.IsNullOrEmpty(Name), "", ":" & Name))
  74. e.Handled = True
  75. ModEvent.TryStartEvent(EventType, EventData)
  76. End Sub
  77. Private Sub MyHint_MouseDown(sender As Object, e As MouseButtonEventArgs) Handles Me.MouseLeftButtonDown
  78. IsMouseDown = True
  79. End Sub
  80. Private Sub MyHint_MouseLeave() Handles Me.MouseLeave
  81. IsMouseDown = False
  82. End Sub
  83. Public Property EventType As String
  84. Get
  85. Return GetValue(EventTypeProperty)
  86. End Get
  87. Set(value As String)
  88. SetValue(EventTypeProperty, value)
  89. End Set
  90. End Property
  91. Public Shared ReadOnly EventTypeProperty As DependencyProperty = DependencyProperty.Register("EventType", GetType(String), GetType(MyHint), New PropertyMetadata(Nothing))
  92. Public Property EventData As String
  93. Get
  94. Return GetValue(EventDataProperty)
  95. End Get
  96. Set(value As String)
  97. SetValue(EventDataProperty, value)
  98. End Set
  99. End Property
  100. Public Shared ReadOnly EventDataProperty As DependencyProperty = DependencyProperty.Register("EventData", GetType(String), GetType(MyHint), New PropertyMetadata(Nothing))
  101. End Class
  102. Partial Public Module ModAnimation
  103. Public Sub AniDispose(Control As MyHint, RemoveFromChildren As Boolean, Optional CallBack As ParameterizedThreadStart = Nothing)
  104. If Not Control.IsHitTestVisible Then Exit Sub
  105. Control.IsHitTestVisible = False
  106. AniStart({
  107. AaScaleTransform(Control, -0.08, 200,, New AniEaseInFluent),
  108. AaOpacity(Control, -1, 200,, New AniEaseOutFluent),
  109. AaHeight(Control, -Control.ActualHeight, 150, 100, New AniEaseOutFluent),
  110. AaCode(Sub()
  111. If RemoveFromChildren Then
  112. CType(Control.Parent, Object).Children.Remove(Control)
  113. Else
  114. Control.Visibility = Visibility.Collapsed
  115. End If
  116. If CallBack IsNot Nothing Then CallBack(Control)
  117. End Sub,, True)
  118. }, "MyCard Dispose " & Control.Uuid)
  119. End Sub
  120. End Module