|
36 | 36 |
|
37 | 37 | '属性
|
38 | 38 | Public Uuid As Integer = GetUuid()
|
| 39 | + Public ReadOnly Property Inlines As InlineCollection |
| 40 | + Get |
| 41 | + Return MainTextBlock.Inlines |
| 42 | + End Get |
| 43 | + End Property |
39 | 44 | Public Property Title As String
|
40 | 45 | Get
|
41 | 46 | Return GetValue(TitleProperty)
|
|
62 | 67 | If IsLoad Then Exit Sub
|
63 | 68 | IsLoad = True
|
64 | 69 | '初次加载限定
|
65 |
| - If Title <> "" AndAlso MainTextBlock Is Nothing Then |
| 70 | + If MainTextBlock Is Nothing Then |
66 | 71 | MainTextBlock = New TextBlock With {.HorizontalAlignment = HorizontalAlignment.Left, .VerticalAlignment = VerticalAlignment.Top, .Margin = New Thickness(15, 12, 0, 0), .FontWeight = FontWeights.Bold, .FontSize = 13, .IsHitTestVisible = False}
|
67 | 72 | MainTextBlock.SetResourceReference(TextBlock.ForegroundProperty, "ColorBrush1")
|
68 | 73 | MainTextBlock.SetBinding(TextBlock.TextProperty, New Binding("Title") With {.Source = Me, .Mode = BindingMode.OneWay})
|
|
222 | 227 | '高度增加较大,使用弹起动画
|
223 | 228 | Dim Delta As Double = MathClamp(Math.Abs(DeltaHeight) * 0.05, 3, 10) * Math.Sign(DeltaHeight)
|
224 | 229 | AnimList.AddRange({
|
225 |
| - AaHeight(Me, DeltaHeight + Delta, 300, If(IsLoadAnimation, 30, 0), If(DeltaHeight > FrmMain.Height, New AniEaseInFluent(AniEasePower.ExtraStrong), New AniEaseOutFluent(AniEasePower.ExtraStrong))), |
226 |
| - AaHeight(Me, -Delta, 150, 260, Ease:=New AniEaseOutFluent(AniEasePower.Strong)) |
227 |
| - }) |
| 230 | + AaHeight(Me, DeltaHeight + Delta, 300, If(IsLoadAnimation, 30, 0), If(DeltaHeight > FrmMain.Height, New AniEaseInFluent(AniEasePower.ExtraStrong), New AniEaseOutFluent(AniEasePower.ExtraStrong))), |
| 231 | + AaHeight(Me, -Delta, 150, 260, Ease:=New AniEaseOutFluent(AniEasePower.Strong)) |
| 232 | + }) |
228 | 233 | Else
|
229 | 234 | '普通的改变就行啦
|
230 | 235 | AnimList.AddRange({
|
231 |
| - AaHeight(Me, DeltaHeight, MathClamp(Math.Abs(DeltaHeight) * 4, 150, 250),, New AniEaseOutFluent) |
232 |
| - }) |
| 236 | + AaHeight(Me, DeltaHeight, MathClamp(Math.Abs(DeltaHeight) * 4, 150, 250),, New AniEaseOutFluent) |
| 237 | + }) |
233 | 238 | End If
|
234 |
| - AnimList.Add(AaCode(Sub() |
235 |
| - IsHeightAnimating = False |
236 |
| - Height = ActualUsedHeight |
237 |
| - If IsSwaped Then SwapControl.Visibility = Visibility.Collapsed |
238 |
| - End Sub,, True)) |
| 239 | + AnimList.Add(AaCode( |
| 240 | + Sub() |
| 241 | + IsHeightAnimating = False |
| 242 | + Height = ActualUsedHeight |
| 243 | + If IsSwaped Then SwapControl.Visibility = Visibility.Collapsed |
| 244 | + End Sub,, True)) |
239 | 245 | AniStart(AnimList, "MyCard Height " & Uuid)
|
240 | 246 |
|
241 | 247 | IsHeightAnimating = True
|
|
253 | 259 |
|
254 | 260 | #End Region
|
255 | 261 |
|
256 |
| - '折叠 |
| 262 | +#Region "折叠" |
| 263 | + |
257 | 264 | '若设置了 CanSwap,或 SwapControl 不为空,则判定为会进行折叠
|
258 | 265 | '这是因为不能直接在 XAML 中设置 SwapControl
|
259 | 266 | Public SwapControl As Object
|
|
294 | 301 | Private Sub MyCard_MouseLeftButtonDown(sender As Object, e As MouseButtonEventArgs) Handles Me.MouseLeftButtonDown
|
295 | 302 | Dim Pos As Double = Mouse.GetPosition(Me).Y
|
296 | 303 | If Not IsSwaped AndAlso
|
297 |
| - (SwapControl Is Nothing OrElse Pos > SwapedHeight OrElse (Pos = 0 AndAlso Not IsMouseDirectlyOver)) Then Exit Sub '检测点击位置;或已经不在可视树上的误判 |
| 304 | + (SwapControl Is Nothing OrElse Pos > If(IsSwaped, SwapedHeight, SwapedHeight - 6) OrElse (Pos = 0 AndAlso Not IsMouseDirectlyOver)) Then Exit Sub '检测点击位置;或已经不在可视树上的误判 |
298 | 305 | IsMouseDown = True
|
299 | 306 | End Sub
|
300 | 307 | Private Sub MyCard_MouseLeftButtonUp(sender As Object, e As MouseButtonEventArgs) Handles Me.MouseLeftButtonUp
|
|
303 | 310 |
|
304 | 311 | Dim Pos As Double = Mouse.GetPosition(Me).Y
|
305 | 312 | If Not IsSwaped AndAlso
|
306 |
| - (SwapControl Is Nothing OrElse Pos > SwapedHeight OrElse (Pos = 0 AndAlso Not IsMouseDirectlyOver)) Then Exit Sub '检测点击位置;或已经不在可视树上的误判 |
| 313 | + (SwapControl Is Nothing OrElse Pos > If(IsSwaped, SwapedHeight, SwapedHeight - 6) OrElse (Pos = 0 AndAlso Not IsMouseDirectlyOver)) Then Exit Sub '检测点击位置;或已经不在可视树上的误判 |
307 | 314 |
|
308 | 315 | Dim ee = New RouteEventArgs(True)
|
309 | 316 | RaiseEvent PreviewSwap(Me, ee)
|
|
320 | 327 | IsMouseDown = False
|
321 | 328 | End Sub
|
322 | 329 |
|
| 330 | +#End Region |
| 331 | + |
323 | 332 | End Class
|
324 | 333 | Partial Public Module ModAnimation
|
325 | 334 | Public Sub AniDispose(Control As MyCard, RemoveFromChildren As Boolean, Optional CallBack As ParameterizedThreadStart = Nothing)
|
|
0 commit comments