Imports System.Windows.Forms

Namespace UTSModule.Test.Command.SystemCommand
    ''' <summary>
    ''' 显示提示图像执行器
    ''' 耦合了
    ''' </summary>
    Public Class ShowTipImageExecutor
        Inherits TestCommandExecutor

        Public Shared TipImageControl As PictureBox

        Private ReadOnly _imgPath As String

        Sub New(command As TestCommand)
            MyBase.New(command)

            _imgPath =TestCommandManger.ReplacePath(TestCommand.Parameter(0)) 

            CommandReturn.LowerLimit = "True"

            CommandReturn.UpperLimit = "True"

            CommandReturn.RecordValue = String.Empty

            CommandReturn.ExecuteResultTipString = String.Empty

            CommandReturn.ExecuteResult = True
        End Sub


        Public Overrides Function Execute() As TestCommandReturn
            If IO.File.Exists(_imgPath) Then
                Try
                    TipImageControl.Image = ImageProcessor.ImageProcessor.GetBitmapImage(_imgPath)
                    CommandReturn.ExecuteResult = True
                    CommandReturn.RecordValue = "True"
                    CommandReturn.ExecuteResultTipString = "提示图像设置成功"
                Catch ex As Exception
                    CommandReturn.ExecuteResult = False
                    CommandReturn.RecordValue = "False"
                    CommandReturn.ExecuteResultTipString = $"未知错误:{ex.Message}"
                End Try
            Else
                CommandReturn.ExecuteResult = False
                CommandReturn.RecordValue = "False"
                CommandReturn.ExecuteResultTipString = $"路径 {_imgPath} 不存在"
            End If

            Return CommandReturn
        End Function
    End Class
End Namespace