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 Log(ex, "普通弹窗初始化失败", LogLevel.Hint) 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) '记录日志 Log("[Control] 普通弹窗:" & LabTitle.Text & vbCrLf & LabCaption.Text) Catch ex As Exception Log(ex, "普通弹窗加载失败", LogLevel.Hint) 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