Option Strict Off
Option Explicit On
'------------------------------------ 2023/11/09 ------------------------------------
Friend Class frmDlg僇乕僪僔儑乕暋悢儌乕僪慖戰
    Inherits System.Windows.Forms.Form

#Region "愰尵"
    Const cListMaxNum As Short = 9
    Private modes(cListMaxNum) As String
    Private mModeIdxStr As String
    Private mOldMode As Integer
    Private mLoopOrOne, mTestRuning As Boolean
    Private mTmcount As Integer
#End Region

#Region "僼僅乕儉僀儀儞僩"
    '仭仭仭仭仭仭仭仭仭仭仭仭仭仭仭仭仭仭仭仭仭仭仭仭仭仭仭仭仭仭仭仭仭仭仭仭仭仭仭仭
    Friend Function ffShowTestStop() As Boolean
        mTmcount = 0
        tim.Enabled = True
        Return True
    End Function
    '仭仭仭仭仭仭仭仭仭仭仭仭仭仭仭仭仭仭仭仭仭仭仭仭仭仭仭仭仭仭仭仭仭仭仭仭仭仭仭仭
    Friend Function DlgShow1(ByRef Ownerform As Form) As Boolean
        gm昞帵拞_Dlg僇乕僪僔儑乕暋悢儌乕僪慖戰 = True
        Me.Owner = Ownerform
        Me.ShowDialog()
        '----------------------------------------------
        gm昞帵拞_Dlg僇乕僪僔儑乕暋悢儌乕僪慖戰 = False
        Return True
    End Function
    '仭仭仭仭仭仭仭仭仭仭仭仭仭仭仭仭仭仭仭仭仭仭仭仭仭仭仭仭仭仭仭仭仭仭仭仭仭仭仭仭
    Private Sub frmDlgModeSet_Load(ByVal eventSender As System.Object, ByVal eventArgs As System.EventArgs) Handles MyBase.Load
        Dim a As Integer
        'gm僞僀儅乕掆巭偡傞 = True
        a = -1
        a = a + 1 : modes(a) = "0"
        a = a + 1 : modes(a) = "1 僘乕儉   儌乕僪"
        a = a + 1 : modes(a) = "2 僕儍儞僾 儌乕僪"
        a = a + 1 : modes(a) = "3 僗儔僀僪 儌乕僪"
        a = a + 1 : modes(a) = "4 僋儖僋儖 儌乕僪"
        a = a + 1 : modes(a) = "5 僗僩僢僾 儌乕僪"
        a = a + 1 : modes(a) = "6 傾僠僐僠 儌乕僪"
        a = a + 1 : modes(a) = "7 儁僞儁僞 儌乕僪"
        a = a + 1 : modes(a) = "8 僗僋僗僋 儌乕僪"
        a = a + 1 : modes(a) = "9 僼儔僼儔 儌乕僪"
        lst偡傋偰偺儌乕僪.Items.Clear()
        For a = 1 To cListMaxNum
            lst偡傋偰偺儌乕僪.Items.Add(modes(a))
        Next
        lst偡傋偰偺儌乕僪.SelectedIndex = 0
        a = gooClsCardShow.僇乕僪僔儑乕儌乕僪偺幚峴弴彉暥帤楍偐傜ListBox僙僢僩(lst幚峴儌乕僪弴彉, modes)
        lst幚峴儌乕僪弴彉.SelectedIndex = 0
        mTestRuning = False
        Call zzBtnEnabled()
        Me.Icon = frmMain.Icon
        gm昞帵拞_Dlg僇乕僪僔儑乕暋悢儌乕僪慖戰 = True
        gm僇乕僪儖乕僾掆巭尨場 = 0
    End Sub
    '仭仭仭仭仭仭仭仭仭仭仭仭仭仭仭仭仭仭仭仭仭仭仭仭仭仭仭仭仭仭仭仭仭仭仭仭仭仭仭仭
    Private Sub frmDlgModeSet_FormClosing(ByVal eventSender As System.Object, ByVal eventArgs As System.Windows.Forms.FormClosingEventArgs) Handles Me.FormClosing
        Dim Cancel As Boolean = eventArgs.Cancel
        Dim UnloadMode As System.Windows.Forms.CloseReason = eventArgs.CloseReason
        If pp僇乕僪僔儑乕幚峴拞 Then
            If mTestRuning Then Call zzTestOnOff() '2022/12/15  OK gm僇乕僪儖乕僾掆巭尨場 = 999
        End If
        eventArgs.Cancel = Cancel
        gm昞帵拞_Dlg僇乕僪僔儑乕暋悢儌乕僪慖戰 = False
    End Sub
    '仭仭仭仭仭仭仭仭仭仭仭仭仭仭仭仭仭仭仭仭仭仭仭仭仭仭仭仭仭仭仭仭仭仭仭仭仭仭仭仭
#End Region

#Region "僐儞僩儘乕儖僀儀儞僩"
    '仭仭仭仭仭仭仭仭仭仭仭仭仭仭仭仭仭仭仭仭仭仭仭仭仭仭仭仭仭仭仭仭仭仭仭仭仭仭仭仭
    Private Sub tim_Tick(ByVal eventSender As System.Object, ByVal eventArgs As System.EventArgs) Handles tim.Tick
        mTmcount = mTmcount + 1
        If mTmcount = 2 Then
            tim.Enabled = False
            If mTestRuning Then Call zzTestOnOff()
        End If
    End Sub
    '仭仭仭仭仭仭仭仭仭仭仭仭仭仭仭仭仭仭仭仭仭仭仭仭仭仭仭仭仭仭仭仭仭仭仭仭仭仭仭仭
    Private Function zzTestOnOff() As Boolean
        On Error GoTo errop
        Dim n As Integer
        If mTestRuning Then
            mTestRuning = False
            gm僇乕僪儖乕僾掆巭尨場 = 999
            gooClsCardShow.p僇乕僪僔儑乕儌乕僪 = mOldMode
            gooClsCardShow.p僇乕僪僔儑乕偼儖乕僾偱幚峴 = mLoopOrOne
            btn僥僗僩.Text = "亙僥僗僩亜"
            gggbol = zzBtnEnabled()
            frmMain.Refresh()
        Else
            mTestRuning = True
            mOldMode = gooClsCardShow.p僇乕僪僔儑乕儌乕僪
            mLoopOrOne = gooClsCardShow.p僇乕僪僔儑乕偼儖乕僾偱幚峴
            gooClsCardShow.p僇乕僪僔儑乕偼儖乕僾偱幚峴 = True
            btn僥僗僩.Text = "亙掆巭亜"
            gggbol = zzBtnEnabled()
            If lst偡傋偰偺儌乕僪.SelectedIndex = -1 Then lst偡傋偰偺儌乕僪.SelectedIndex = 0
            n = Val(lst偡傋偰偺儌乕僪.SelectedItem.ToString)
            Call frmMain.aa僇乕僪僔儑乕幚峴(n)
        End If
        Return True
errop:
        Return False
    End Function
    '仭仭仭仭仭仭仭仭仭仭仭仭仭仭仭仭仭仭仭仭仭仭仭仭仭仭仭仭仭仭仭仭仭仭仭仭仭仭仭仭
    Private Function zzListToIntAry(ByRef ary() As Integer, ByRef rlst As ListBox) As Boolean
        Dim n, a, d As Integer
        n = rlst.Items.Count - 1
        For a = 0 To cListMaxNum - 1
            If a > n Then d = 0 Else d = Val(rlst.Items(a).ToString)
            ary(a + 1) = d
        Next
        ary(0) = 0
        Return True
    End Function
    '仭仭仭仭仭仭仭仭仭仭仭仭仭仭仭仭仭仭仭仭仭仭仭仭仭仭仭仭仭仭仭仭仭仭仭仭仭仭仭仭
    Private Sub lst偡傋偰偺儌乕僪_SelectedIndexChanged(ByVal sender As Object, ByVal e As System.EventArgs) Handles lst偡傋偰偺儌乕僪.SelectedIndexChanged
        If mTestRuning Then Call zzTestOnOff()
    End Sub
    '仭仭仭仭仭仭仭仭仭仭仭仭仭仭仭仭仭仭仭仭仭仭仭仭仭仭仭仭仭仭仭仭仭仭仭仭仭仭仭仭
    Private Sub lst幚峴儌乕僪弴彉_SelectedIndexChanged(ByVal sender As Object, ByVal e As System.EventArgs) Handles lst幚峴儌乕僪弴彉.SelectedIndexChanged
        If mTestRuning Then Call zzTestOnOff()
    End Sub
    '仭仭仭仭仭仭仭仭仭仭仭仭仭仭仭仭仭仭仭仭仭仭仭仭仭仭仭仭仭仭仭仭仭仭仭仭仭仭仭仭
    Private Sub btn僥僗僩_Click(ByVal sender As Object, ByVal e As System.EventArgs) Handles btn僥僗僩.Click, btn捛壛.Click, btn嶍彍.Click, btn婛掕偵栠偡.Click, btn愝掕偟偰暵偠傞.Click, btn僉儍儞僙儖.Click
        Dim index As Integer = IIf(sender.Equals(btn僥僗僩), 0, IIf(sender.Equals(btn捛壛), 1, IIf(sender.Equals(btn嶍彍), 2, IIf(sender.Equals(btn婛掕偵栠偡), 3, IIf(sender.Equals(btn愝掕偟偰暵偠傞), 4, IIf(sender.Equals(btn僉儍儞僙儖), 5, -1))))))
        If index = -1 Then Return
        If index <> 0 Then
            If mTestRuning Then Call zzTestOnOff()
        End If
        Dim a, n As Integer : Dim s As String
        Select Case index
            Case 0 'btn僥僗僩_Click
                Call zzTestOnOff()
            Case 1 'btn捛壛_Click
                n = lst偡傋偰偺儌乕僪.SelectedIndex
                If n >= 0 Then
                    s = lst偡傋偰偺儌乕僪.SelectedItem
                    n = lst幚峴儌乕僪弴彉.SelectedIndex
                    lst幚峴儌乕僪弴彉.Items.Insert(n, s)
                    lst幚峴儌乕僪弴彉.SelectedIndex = n
                    Call zzBtnEnabled()
                End If
            Case 2 'btn嶍彍_Click
                n = lst幚峴儌乕僪弴彉.SelectedIndex
                If n >= 0 Then
                    lst幚峴儌乕僪弴彉.Items.RemoveAt(n)
                    lst幚峴儌乕僪弴彉.SelectedIndex = Math.Min(n, lst幚峴儌乕僪弴彉.Items.Count - 1)
                    Call zzBtnEnabled()
                End If
            Case 3 'btn婛掕偵栠偡_Click
                lst幚峴儌乕僪弴彉.Items.Clear()
                For a = 1 To cListMaxNum
                    lst幚峴儌乕僪弴彉.Items.Add(modes(a))
                Next
                lst幚峴儌乕僪弴彉.SelectedIndex = 0
                Call zzBtnEnabled()
                '----------------------------------------------
            Case 4, 5
                Dim ary(cListMaxNum) As Integer
                Select Case index
                    Case 4  'btn愝掕偟偰暵偠傞_Click
                        s = gooClsCardShow.僇乕僪僔儑乕儌乕僪偺幚峴弴彉暥帤楍傪ListBox偐傜嶌傝_if_SetNew僾儘僷_僙僢僩僾儘僷僥傿(lst幚峴儌乕僪弴彉, True)
                    Case 5 'btn僉儍儞僙儖_Click()
                        'non
                End Select
                Me.Close()
        End Select
    End Sub
    '仭仭仭仭仭仭仭仭仭仭仭仭仭仭仭仭仭仭仭仭仭仭仭仭仭仭仭仭仭仭仭仭仭仭仭仭仭仭仭仭
    Private Function zzBtnEnabled() As Boolean
        Dim n, a, m As Integer : Dim s As String : Dim NotTestOn As Boolean
        Dim ary(cListMaxNum) As Integer
        Dim mmm(cListMaxNum) As Integer
        Dim e As Boolean
        NotTestOn = Not mTestRuning
        n = lst幚峴儌乕僪弴彉.Items.Count
        btn捛壛.Enabled = NotTestOn And (n < cListMaxNum)
        btn嶍彍.Enabled = NotTestOn And (n > 1)
        '儕僗僩偑曄峏偝傟偰偄傞偐僠僃僢僋
        s = gooClsCardShow.僇乕僪僔儑乕儌乕僪偺幚峴弴彉暥帤楍傪ListBox偐傜嶌傝_if_SetNew僾儘僷_僙僢僩僾儘僷僥傿(lst幚峴儌乕僪弴彉, False)
        btn愝掕偟偰暵偠傞.Enabled = NotTestOn And (s <> gooClsCardShow.p僇乕僪僔儑乕儌乕僪偺幚峴弴彉暥帤楍)
        lst幚峴儌乕僪弴彉.Enabled = NotTestOn
        m = lst偡傋偰偺儌乕僪.Items.Count - 1
        n = lst幚峴儌乕僪弴彉.Items.Count - 1
        e = (n <> m)
        If Not e Then
            Call zzListToIntAry(mmm, lst偡傋偰偺儌乕僪)
            For a = 1 To n
                If ary(a) <> mmm(a) Then
                    e = True : Exit For
                End If
            Next
        End If
        btn婛掕偵栠偡.Enabled = e And NotTestOn '婛掕偵栠偡
        Return True
    End Function
    '仭仭仭仭仭仭仭仭仭仭仭仭仭仭仭仭仭仭仭仭仭仭仭仭仭仭仭仭仭仭仭仭仭仭仭仭仭仭仭仭
#End Region

End Class

