| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108 |
- Public Class MyMsgText
- Private ReadOnly MyConverter As MyMsgBoxConverter
- Private ReadOnly Uuid As Integer = GetUuid()
- Public Sub New(Converter As MyMsgBoxConverter)
- Try
- InitializeComponent()
- Btn1.Name = Btn1.Name & GetUuid()
- Btn2.Name = Btn2.Name & GetUuid()
- Btn3.Name = Btn3.Name & GetUuid()
- MyConverter = Converter
- LabTitle.Text = Converter.Title
- LabCaption.Text = Converter.Text
- Btn1.Text = Converter.Button1
- If Converter.IsWarn Then
- Btn1.ColorType = MyButton.ColorState.Red
- LabTitle.SetResourceReference(TextBlock.ForegroundProperty, "ColorBrushRedLight")
- End If
- Btn2.Text = Converter.Button2
- Btn3.Text = Converter.Button3
- Btn2.Visibility = If(Converter.Button2 = "", Visibility.Collapsed, Visibility.Visible)
- Btn3.Visibility = If(Converter.Button3 = "", Visibility.Collapsed, Visibility.Visible)
- ShapeLine.StrokeThickness = GetWPFSize(1)
- Catch ex As Exception
- Logger.Error(ex, "普通弹窗初始化失败", LogBehavior.Toast)
- End Try
- End Sub
- Private Sub Load(sender As Object, e As EventArgs) Handles MyBase.Loaded
- Try
- 'UI 初始化
- If Btn2.IsVisible AndAlso Not Btn1.ColorType = MyButton.ColorState.Red Then Btn1.ColorType = MyButton.ColorState.Highlight
- Btn1.Focus()
- '动画
- Opacity = 0
- 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")
- AniStart({
- AaOpacity(Me, 1, 120, 60),
- AaDouble(Sub(i) TransformPos.Y += i, -TransformPos.Y, 300, 60, New AniEaseOutBack(AniEasePower.Weak)),
- AaDouble(Sub(i) TransformRotate.Angle += i, -TransformRotate.Angle, 300, 60, New AniEaseOutFluent(AniEasePower.Weak))
- }, "MyMsgBox " & Uuid)
- '记录日志
- Logger.Info($"普通弹窗:{LabTitle.Text}{vbCrLf}{LabCaption.Text}")
- Catch ex As Exception
- Logger.Error(ex, "普通弹窗加载失败", LogBehavior.Toast)
- End Try
- End Sub
- Private Sub Close()
- '结束线程阻塞
- If MyConverter.ForceWait OrElse Not MyConverter.Button2 = "" Then MyConverter.WaitFrame.Continue = False
- Interop.ComponentDispatcher.PopModal()
- '动画
- AniStart({
- AaCode(
- Sub()
- If Not WaitingMyMsgBox.Any() Then
- AniStart(AaColor(FrmMain.PanMsg, Grid.BackgroundProperty, New MyColor(0, 0, 0, 0) - FrmMain.PanMsg.Background, 200, Ease:=New AniEaseOutFluent(AniEasePower.Weak)))
- End If
- End Sub, 30),
- AaOpacity(Me, -Opacity, 80, 20),
- AaDouble(Sub(i) TransformPos.Y += i, 20 - TransformPos.Y, 150, 0, New AniEaseOutFluent),
- AaDouble(Sub(i) TransformRotate.Angle += i, 6 - TransformRotate.Angle, 150, 0, New AniEaseInFluent(AniEasePower.Weak)),
- AaCode(Sub() CType(Parent, Grid).Children.Remove(Me), , True)
- }, "MyMsgBox " & Uuid)
- End Sub
- Public Sub Btn1_Click() Handles Btn1.Click
- If MyConverter.IsExited Then Return
- If MyConverter.Button1Action IsNot Nothing Then
- MyConverter.Button1Action()
- Else
- MyConverter.IsExited = True
- MyConverter.Result = 1
- Close()
- End If
- End Sub
- Public Sub Btn2_Click() Handles Btn2.Click
- If MyConverter.IsExited Then Return
- If MyConverter.Button2Action IsNot Nothing Then
- MyConverter.Button2Action()
- Else
- MyConverter.IsExited = True
- MyConverter.Result = 2
- Close()
- End If
- End Sub
- Public Sub Btn3_Click() Handles Btn3.Click
- If MyConverter.IsExited Then Return
- If MyConverter.Button3Action IsNot Nothing Then
- MyConverter.Button3Action()
- Else
- MyConverter.IsExited = True
- MyConverter.Result = 3
- Close()
- End If
- End Sub
- Private Sub Drag(sender As Object, e As MouseButtonEventArgs) Handles PanBorder.MouseLeftButtonDown, LabTitle.MouseLeftButtonDown
- On Error Resume Next
- If e.GetPosition(ShapeLine).Y <= 2 Then FrmMain.DragMove()
- End Sub
- End Class
|