MyMsgInput.xaml.vb 4.1 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495
  1. Public Class MyMsgInput
  2. Private ReadOnly MyConverter As MyMsgBoxConverter
  3. Private ReadOnly Uuid As Integer = GetUuid()
  4. Public Sub New(Converter As MyMsgBoxConverter)
  5. Try
  6. InitializeComponent()
  7. Btn1.Name = Btn1.Name & GetUuid()
  8. Btn2.Name = Btn2.Name & GetUuid()
  9. MyConverter = Converter
  10. LabTitle.Text = Converter.Title
  11. LabText.Text = Converter.Text
  12. PanText.Visibility = If(Converter.Text = "", Visibility.Collapsed, Visibility.Visible)
  13. TextArea.Text = Converter.Content
  14. TextArea.HintText = Converter.HintText
  15. TextArea.ValidateRules = Converter.ValidateRules
  16. Btn1.Text = Converter.Button1
  17. If Converter.IsWarn Then
  18. Btn1.ColorType = MyButton.ColorState.Red
  19. LabTitle.SetResourceReference(TextBlock.ForegroundProperty, "ColorBrushRedLight")
  20. End If
  21. Btn2.Text = Converter.Button2
  22. Btn2.Visibility = If(Converter.Button2 = "", Visibility.Collapsed, Visibility.Visible)
  23. ShapeLine.StrokeThickness = GetWPFSize(1)
  24. Catch ex As Exception
  25. Log(ex, "输入弹窗初始化失败", LogLevel.Hint)
  26. End Try
  27. End Sub
  28. Private Sub Load(sender As Object, e As EventArgs) Handles MyBase.Loaded
  29. Try
  30. 'UI 初始化
  31. If Btn2.IsVisible AndAlso Not Btn1.ColorType = MyButton.ColorState.Red Then Btn1.ColorType = MyButton.ColorState.Highlight
  32. TextArea.Focus()
  33. TextArea.SelectionStart = TextArea.Text.Length
  34. '动画
  35. Opacity = 0
  36. AniStart(AaColor(FrmMain.PanMsg, Grid.BackgroundProperty, If(MyConverter.IsWarn, New MyColor(140, 80, 0, 0), New MyColor(90, 0, 0, 0)) - FrmMain.PanMsg.Background, 200), "PanMsg Background")
  37. AniStart({
  38. AaOpacity(Me, 1, 120, 60),
  39. AaDouble(Sub(i) TransformPos.Y += i, -TransformPos.Y, 300, 60, New AniEaseOutBack(AniEasePower.Weak)),
  40. AaDouble(Sub(i) TransformRotate.Angle += i, -TransformRotate.Angle, 300, 60, New AniEaseOutFluent(AniEasePower.Weak))
  41. }, "MyMsgBox " & Uuid)
  42. '记录日志
  43. Log("[Control] 输入弹窗:" & LabTitle.Text)
  44. Catch ex As Exception
  45. Log(ex, "输入弹窗加载失败", LogLevel.Hint)
  46. End Try
  47. End Sub
  48. Private Sub Close()
  49. '结束线程阻塞
  50. MyConverter.WaitFrame.Continue = False
  51. Interop.ComponentDispatcher.PopModal()
  52. '动画
  53. AniStart({
  54. AaCode(Sub()
  55. If WaitingMyMsgBox.Count = 0 Then
  56. AniStart(AaColor(FrmMain.PanMsg, Grid.BackgroundProperty, New MyColor(0, 0, 0, 0) - FrmMain.PanMsg.Background, 200, Ease:=New AniEaseOutFluent(AniEasePower.Weak)))
  57. End If
  58. End Sub, 30),
  59. AaOpacity(Me, -Opacity, 80, 20),
  60. AaDouble(Sub(i) TransformPos.Y += i, 20 - TransformPos.Y, 150, 0, New AniEaseOutFluent),
  61. AaDouble(Sub(i) TransformRotate.Angle += i, 6 - TransformRotate.Angle, 150, 0, New AniEaseInFluent(AniEasePower.Weak)),
  62. AaCode(Sub() CType(Parent, Grid).Children.Remove(Me), , True)
  63. }, "MyMsgBox " & Uuid)
  64. End Sub
  65. Public Sub Btn1_Click() Handles Btn1.Click
  66. If MyConverter.IsExited OrElse Not TextArea.ValidateResult = "" Then Exit Sub
  67. MyConverter.IsExited = True
  68. MyConverter.Result = TextArea.Text
  69. Close()
  70. End Sub
  71. Public Sub Btn2_Click() Handles Btn2.Click
  72. If MyConverter.IsExited Then Exit Sub
  73. MyConverter.IsExited = True
  74. MyConverter.Result = Nothing
  75. Close()
  76. End Sub
  77. Private Sub TextCaption_ValidateChanged(sender As Object, e As EventArgs) Handles TextArea.ValidateChanged
  78. Btn1.IsEnabled = TextArea.ValidateResult = ""
  79. End Sub
  80. Private Sub Drag(sender As Object, e As MouseButtonEventArgs) Handles PanBorder.MouseLeftButtonDown, LabTitle.MouseLeftButtonDown
  81. On Error Resume Next
  82. If e.GetPosition(ShapeLine).Y <= 2 Then FrmMain.DragMove()
  83. End Sub
  84. End Class