Module FormSetting

    Public Enum ModeList
        DUALSONIC   '카트리지 분리형 모델
        MAXIMUM     '카트리지 일체형, HIFU + RF + EP + MC 기능 제공 모델
        ALTO        '카트리지 일체형, RF + EP 기능 제공 모델
        EFFECT      '카트리지 일체형, HIFU 기능 제공 모델
        LOW_PROD    '카트리지 일체형, 저가형 모델
        LDM         '카트리지 일체형, LDM 기능 제공 모델
        MAX_Mode
    End Enum
    Public SelectModeType As Int16

    Public Sub StartTop()

        With MainForm

            '' 상단 컴포넌트
            With .pnTop
                .Location = New Point(0, 0)
                .Size = New Size(1210, 90)
            End With

            With .gbModelSelect
                .Location = New Point(10, 5)
                .Size = New Size(400, 80)
            End With

            With .gbComport
                .Location = New Point(415, 5)
                .Size = New Size(350, 80)
            End With

            With .lbComport
                .Location = New Point(20, 35)
            End With

            With .cboComport
                .Location = New Point(105, 32)
                .Size = New Size(140, 32)
            End With

            With .btnComport
                .Location = New Point(250, 30)
                .Size = New Size(75, 37)
            End With

            With .gbEtcOp
                .Location = New Point(770, 5)
                .Size = New Size(125, 80)
            End With

            With .ckbDBUse
                .Location = New Point(20, 35)
            End With

            With .gbOpOut
                .Location = New Point(900, 5)
                .Size = New Size(310, 80)
            End With

            With .rdbUseTime
                .Location = New Point(40, 35)
                .Size = New Size(106, 28)
            End With

            With .rdbDev
                .Location = New Point(165, 35)
                .Size = New Size(106, 28)
            End With

            With .pnBottom
                .Location = New Point(0, 90)
                .Enabled = False
            End With

        End With

    End Sub

    Public Sub DUALForm_Setting()
        AuthSetting("인증코드설정", "카트리지")
        DefaultSetting()
        ModeSetting(SelectModeType)
        DUALSetting()
    End Sub

    Private Sub DUALSetting()
        MainForm.gbTD.Enabled = False
        MainForm.rdbDev.Enabled = True
        MainForm.rdbDev.Checked = True
        MainForm.rdbUseTime.Checked = False
    End Sub

    Public Sub MAXForm_Setting()
        AuthSetting("플래쉬 설정값 초기화", "초기화")
        DefaultSetting()
        ModeSetting(SelectModeType)
        MAXSetting()
    End Sub

    Public Sub ALTOForm_Setting()
        AuthSetting("플래쉬 설정값 초기화", "초기화")
        DefaultSetting()
        ModeSetting(SelectModeType)
        MAXSetting()
    End Sub

    Public Sub EFFECTForm_Setting()
        AuthSetting("플래쉬 설정값 초기화", "초기화")
        DefaultSetting()
        ModeSetting(SelectModeType)
        MAXSetting()
    End Sub

    Public Sub LOW_PRODForm_Setting()
        AuthSetting("플래쉬 설정값 초기화", "초기화")
        DefaultSetting()
        ModeSetting(SelectModeType)
        MAXSetting()
        MainForm.gbMotor.Visible = False
    End Sub

    Public Sub LDMForm_Setting()
        AuthSetting("플래쉬 설정값 초기화", "초기화")
        DefaultSetting()
        ModeSetting(SelectModeType)
        MAXSetting()
        MainForm.gbMotor.Visible = False
        LDMFreqPwrSetting()
    End Sub

    Private Sub MAXSetting()
        With MainForm

            With .rdbDev
                .Enabled = False
                .Checked = False
            End With

            With .rdbUseTime
                .Checked = True
            End With

            With .txbTDSerial
                .Text = "DITI"
            End With

            With .txbShot
                .Text = "0"
            End With

            With .txbMaxShot
                .Text = "0"
            End With

            With .gbTD
                .Enabled = True
                .Visible = True
            End With

        End With
    End Sub

    Private Sub LDMFreqPwrSetting()
        ' LDM: 전체 패널에 세 개 주파수/파워 패널을 넣고, 전체 패널에만 읽기/쓰기 한 세트
        With MainForm
            .pnlLDMFreqPwrContainer.Visible = True
            .pnlLDMFreqPwrContainer.Location = New Point(400, 170)
            .pnlLDMFreqPwrContainer.Size = New Size(380, 580)
            .pnlLDMFreqPwrContainer.BringToFront()

            .gbFreqPwr.Parent = .pnlLDMFreqPwrContainer
            .gbFreqPwr.Location = New Point(0, 0)
            .gbFreqPwr.Size = New Size(380, 170)
            .gbFreqPwr.Visible = True
            .pnFPResult.Visible = False

            .gbFreqPwr2.Parent = .pnlLDMFreqPwrContainer
            .gbFreqPwr2.Location = New Point(0, 175)
            .gbFreqPwr2.Size = New Size(380, 170)
            .gbFreqPwr2.Visible = True
            .pnFPResult2.Visible = False

            .gbFreqPwr3.Parent = .pnlLDMFreqPwrContainer
            .gbFreqPwr3.Location = New Point(0, 350)
            .gbFreqPwr3.Size = New Size(380, 170)
            .gbFreqPwr3.Visible = True
            .pnFPResult3.Visible = False

            .pnLDMFPResult.Visible = True
            .pnLDMFPResult.BringToFront()
        End With
    End Sub

    Private Sub ModeSetting(ModelNum As Int16)
        ShotCountSetting(ModelNum)
        MotorOpSetting(ModelNum)
        FreqOpSetting(ModelNum)
        FwVersionVisibleSetting(ModelNum)
    End Sub

    ''' <summary>LDM일 때는 pnlLDMFreqPwrContainer 아래에, 그 외에는 gbShot 아래에 펌웨어 버전 설정 UI 표시</summary>
    Private Sub FwVersionVisibleSetting(ModelNum As Int16)
        With MainForm
            .gbFwVersion.Visible = True
            .gbFwVersion.Parent = .gbSetting
            If ModelNum = ModeList.LDM Then
                ' pnlLDMFreqPwrContainer: Location (400, 170), Size (380, 580) → 아래쪽 170+580 = 750
                .gbFwVersion.Location = New Point(400, 755)
                .gbSetting.Height = 860 + 130
                .pnBottom.Height = 872 + 130
            Else
                .gbFwVersion.Location = New Point(400, 650)
                .gbSetting.Height = 860
                .pnBottom.Height = 872
            End If
        End With
    End Sub

    Private Sub DefaultSetting()
        MainForm.pnlLDMFreqPwrContainer.Visible = False
        MainForm.gbFreqPwr.Parent = MainForm.gbSetting
        MainForm.gbFreqPwr2.Parent = MainForm.gbSetting
        MainForm.gbFreqPwr3.Parent = MainForm.gbSetting
        MainForm.pnFPResult.Visible = True
        MainForm.gbFreqPwr2.Visible = False
        MainForm.gbFreqPwr3.Visible = False
        MainForm.gbMotor.Visible = True
        InfoSetting()
        TDSetting()
        FreqPowerSetting()
        ShotSetting()
        MotorSetting()
    End Sub

    Private Sub AuthSetting(btnStr As String, btnStr2 As String)

        ' 인증 항목
        With MainForm
            With .gbAuth
                .Location = New Point(10, 26)
                .Size = New Size(380, 70)
                .Text = btnStr
            End With

            With .txbAuthBox
                .Location = New Point(20, 30)
                .Size = New Size(130, 29)
                .Text = String.Empty
                .BackColor = Color.FromArgb(0, 192, 0)
                .Visible = False
            End With

            With .btnAuth
                .Location = New Point(160, 27)
                .Size = New Size(210, 35)
                .Text = btnStr2
            End With

        End With
    End Sub

    Private Sub InfoSetting()
        If MainForm.SelectedModelInfo.Code.Length = 2 Then
            With MainForm

                With .lbType
                    .Text = "카트리지 구분"
                End With

                With .comboBoxColor
                    .Enabled = True
                End With

                With .comboBoxClass
                    .Enabled = True
                End With

                With .pnlIfVersion
                    .Visible = True
                End With

            End With
        Else
            With MainForm

                With .lbType
                    .Text = "타입종류/버전"
                End With

                With .comboBoxColor
                    .Enabled = False
                End With

                With .comboBoxClass
                    .Enabled = False
                End With

                With .pnlIfVersion
                    .Visible = False
                End With

            End With
        End If
    End Sub

    Private Sub TDSetting()
        With MainForm
            With .gbTD
                .Location = New Point(400, 35)
                .Size = New Size(380, 130)
            End With

            With .pnTDSerial
                .Location = New Point(10, 30)
                .Size = New Size(360, 40)
            End With

            With .lbTDSerial
                .Location = New Point(5, 7)
                .Size = New Size(100, 24)
            End With

            With .txbTDSerial
                .Location = New Point(145, 5)
                .Size = New Size(205, 32)
                .Text = "DITI"
                .TextAlign = HorizontalAlignment.Center
                .CharacterCasing = CharacterCasing.Upper
                .MaxLength = 10
                .ImeMode = ImeMode.Disable
            End With

            With .pnTdResult
                .Location = New Point(10, 70)
                .Size = New Size(360, 50)
            End With

            With .txbTDBox
                .Location = New Point(10, 12)
                .Size = New Size(130, 29)
                .BackColor = Color.FromArgb(0, 192, 0)
                .Text = String.Empty
                .Visible = False
            End With

            With .btnTdRead
                .Location = New Point(145, 5)
                .Size = New Size(105, 40)
            End With

            With .btnTdWrite
                .Location = New Point(250, 5)
                .Size = New Size(105, 40)
            End With
        End With
    End Sub

    Private Sub FreqPowerSetting()
        With MainForm
            With .gbFreqPwr
                .Location = New Point(400, 170)
                .Size = New Size(380, 170)
            End With

            With .pnFreq
                .Location = New Point(10, 30)
                .Size = New Size(360, 40)
            End With

            With .lbFreq
                .Location = New Point(41, 7)
                .Size = New Size(64, 24)
            End With

            With .txbFreq
                .Location = New Point(145, 5)
                .Size = New Size(205, 32)
                .Text = "7000"
                .TextAlign = HorizontalAlignment.Center
            End With


            With .pnPower
                .Location = New Point(10, 70)
                .Size = New Size(360, 40)
            End With

            With .lbPower
                .Location = New Point(59, 7)
                .Size = New Size(46, 24)
            End With

            With .txbPower
                .Location = New Point(145, 5)
                .Size = New Size(205, 32)
                .Text = "0"
                .TextAlign = HorizontalAlignment.Center
            End With
        End With
    End Sub

    Private Sub ShotSetting()
        With MainForm
            With .gbShot
                .Location = New Point(400, 475)
                .Size = New Size(380, 170)
            End With

            With .pnShot
                .Location = New Point(10, 30)
                .Size = New Size(360, 40)
            End With

            With .lbShot
                .Location = New Point(23, 7)
                .Size = New Size(82, 24)
            End With

            With .txbShot
                .Location = New Point(145, 5)
                .Size = New Size(205, 32)
                .Text = "0"
                .TextAlign = HorizontalAlignment.Center
            End With


            With .pnMaxShot
                .Location = New Point(10, 70)
                .Size = New Size(360, 40)
            End With

            With .lbMaxShot
                .Location = New Point(23, 7)
                .Size = New Size(82, 24)
            End With

            With .txbMaxShot
                .Location = New Point(145, 5)
                .Size = New Size(205, 32)
                .Text = "0"
                .TextAlign = HorizontalAlignment.Center
            End With


            With .pnShResult
                .Location = New Point(10, 70)
                .Size = New Size(360, 50)
            End With

            With .txbShotBox
                .Location = New Point(10, 12)
                .Size = New Size(130, 29)
                .BackColor = Color.FromArgb(0, 192, 0)
                .Text = String.Empty
                .Visible = False
            End With

            With .btnShRead
                .Location = New Point(145, 5)
                .Size = New Size(105, 40)
            End With

            With .btnShWrite
                .Location = New Point(250, 5)
                .Size = New Size(105, 40)
            End With
        End With
    End Sub

    Private Sub ShotCountSetting(ModelNum As Int16)
        Select Case ModelNum
            Case ModeList.DUALSONIC

                With MainForm
                    With .pnMaxShot
                        .Visible = True
                    End With

                    With .pnShResult
                        .Location = New Point(10, 110)
                    End With

                    With .gbShot
                        .Enabled = True
                    End With

                End With

            Case ModeList.MAXIMUM

                With MainForm
                    With .pnMaxShot
                        .Visible = False
                    End With

                    With .pnShResult
                        .Location = New Point(10, 70)
                    End With

                    With .gbShot
                        .Enabled = True
                    End With

                End With
            Case ModeList.ALTO

                With MainForm
                    With .gbShot
                        .Enabled = False
                    End With
                End With
            Case ModeList.EFFECT
                With MainForm
                    With .pnMaxShot
                        .Visible = False
                    End With

                    With .pnShResult
                        .Location = New Point(10, 70)
                    End With

                    With .gbShot
                        .Enabled = True
                    End With

                End With
            Case ModeList.LOW_PROD
                With MainForm
                    With .pnMaxShot
                        .Visible = False
                    End With
                    With .pnShResult
                        .Location = New Point(10, 70)
                    End With
                    With .gbShot
                        .Enabled = True
                    End With
                End With
            Case ModeList.LDM
                With MainForm
                    With .pnMaxShot
                        .Visible = False
                    End With
                    With .pnShResult
                        .Location = New Point(10, 70)
                    End With
                    With .gbShot
                        .Location = New Point(9, 658)
                        .Enabled = True
                    End With
                End With
            Case Else
                MsgBox("잘못된 경로입니다.", vbCritical)
        End Select
    End Sub

    Private Sub MotorSetting()
        With MainForm
            With .gbMotor
                .Location = New Point(400, 340)
                .Size = New Size(380, 130)
            End With

            With .pnMotor
                .Location = New Point(10, 30)
                .Size = New Size(360, 40)
            End With

            With .lbMotor
                .Location = New Point(5, 7)
                .Size = New Size(100, 24)
            End With

            With .txbMotor
                .Location = New Point(145, 5)
                .Size = New Size(205, 32)
                .Text = "0"
                .TextAlign = HorizontalAlignment.Center
            End With
        End With
    End Sub

    Private Sub MotorOpSetting(ModelNum As Int16)
        Select Case ModelNum
            Case ModeList.DUALSONIC
                With MainForm
                    With .lbMotor
                        .Location = New Point(41, 7)
                        .Text = "백러쉬"
                    End With

                    With .gbMotor
                        .Enabled = True
                    End With
                End With

            Case ModeList.MAXIMUM
                With MainForm
                    With .lbMotor
                        .Location = New Point(23, 7)
                        .Text = "모터이동"
                    End With

                    With .gbMotor
                        .Enabled = True
                    End With
                End With

            Case ModeList.ALTO

                With MainForm
                    With .gbMotor
                        .Enabled = False
                    End With

                    With .lbMotor
                        .Location = New Point(23, 7)
                        .Text = "모터이동"
                    End With
                End With
            Case ModeList.EFFECT
                With MainForm
                    With .lbMotor
                        .Location = New Point(23, 7)
                        .Text = "모터이동"
                    End With

                    With .gbMotor
                        .Enabled = True
                    End With
                End With
            Case ModeList.LOW_PROD, ModeList.LDM
                With MainForm
                    With .lbMotor
                        .Location = New Point(23, 7)
                        .Text = "모터이동"
                    End With
                    With .gbMotor
                        .Enabled = False
                    End With
                End With
            Case Else
                MsgBox("잘못된 경로입니다.", vbCritical)
        End Select
    End Sub

    Private Sub FreqOpSetting(ModelNum As Int16)
        Select Case ModelNum
            Case ModeList.DUALSONIC

                With MainForm
                    With .gbFreqPwr
                        .Enabled = True
                    End With
                End With

            Case ModeList.MAXIMUM
                With MainForm

                    With .gbFreqPwr
                        .Enabled = True
                    End With

                End With

            Case ModeList.ALTO

                With MainForm
                    With .gbFreqPwr
                        .Enabled = False
                    End With
                End With

            Case ModeList.EFFECT
                With MainForm

                    With .gbFreqPwr
                        .Enabled = True
                    End With

                End With
            Case ModeList.LOW_PROD, ModeList.LDM
                With MainForm
                    With .gbFreqPwr
                        .Enabled = True
                    End With
                End With
            Case Else
                MsgBox("잘못된 경로입니다.", vbCritical)
        End Select
    End Sub

    Private Sub DeviceOpSetting()
        With MainForm
            With .gbDevice
                .Location = New Point(810, 5)
                .Size = New Size(400, 505)
            End With


            With .gbDvAuth
                .Location = New Point(10, 35)
                .Size = New Size(380, 70)
            End With


            With .txbDvAuthBox
                .Location = New Point(20, 30)
                .Size = New Size(130, 29)
                .Text = String.Empty
                .TextAlign = HorizontalAlignment.Center
                .BackColor = Color.FromArgb(0, 192, 0)
            End With

            With .btnDvAuth
                .Location = New Point(160, 27)
                .Size = New Size(210, 35)
                .Text = "본체"
            End With


            With .gbDvInfo
                .Location = New Point(10, 125)
                .Size = New Size(380, 365)
            End With

            With .pnDvNumber
                .Location = New Point(10, 30)
                .Size = New Size(360, 40)
            End With

            With .lbDvNumber
                .Location = New Point(5, 7)
                .Size = New Size(100, 24)
                .Text = "바코드넘버"
            End With

            With .txbDvNumber
                .Location = New Point(145, 5)
                .Size = New Size(205, 32)
                .Text = String.Empty
                .TextAlign = HorizontalAlignment.Center
                .ReadOnly = True
            End With

            With .pnDvCode
                .Location = New Point(10, 70)
                .Size = New Size(360, 40)
            End With

            With .lbDvCode
                .Location = New Point(5, 7)
                .Size = New Size(100, 24)
            End With

            With .txbDvCode
                .Location = New Point(145, 5)
                .Size = New Size(205, 32)
                .Text = "JOMT"
                .TextAlign = HorizontalAlignment.Center
            End With

            With .pnDvDate
                .Location = New Point(10, 110)
                .Size = New Size(360, 40)
            End With

            With .lbDvDate
                .Location = New Point(23, 7)
                .Size = New Size(82, 24)
            End With

            With .lbDvYear
                .Location = New Point(140, 8)
                .Size = New Size(28, 24)
            End With

            With .nudDvYear
                .Location = New Point(175, 5)
                .Size = New Size(65, 32)
                .TextAlign = HorizontalAlignment.Center
                .Text = Format(Now, "yy")
                .Maximum = 99
                .Minimum = 10
            End With

            With .lbDvMonth
                .Location = New Point(250, 8)
                .Size = New Size(28, 24)
            End With

            With .nudDvMonth
                .Location = New Point(285, 5)
                .Size = New Size(65, 32)
                .TextAlign = HorizontalAlignment.Center
                .Text = Format(Now, "MM")
                .Maximum = 12
                .Minimum = 1
            End With

            With .pnDvSerial
                .Location = New Point(10, 190)
                .Size = New Size(360, 40)
            End With

            With .lbDvSerial
                .Location = New Point(5, 7)
                .Size = New Size(100, 24)
            End With

            With .nudDvSerial
                .Location = New Point(145, 5)
                .Size = New Size(205, 32)
                .TextAlign = HorizontalAlignment.Center
                .Text = 0
                .Maximum = 999999
                .Minimum = 0
            End With

            With .pnDvAbroad
                .Location = New Point(10, 230)
                .Size = New Size(360, 40)
            End With

            With .lbDvAbroad
                .Location = New Point(23, 7)
                .Size = New Size(82, 24)
            End With

            With .txbDvAbroad
                .Location = New Point(145, 5)
                .Size = New Size(205, 32)
                .Text = "0"
                .TextAlign = HorizontalAlignment.Center
            End With

            With .pnDvAgency
                .Location = New Point(10, 270)
                .Size = New Size(360, 40)
            End With

            With .lbDvAgency
                .Location = New Point(5, 7)
                .Size = New Size(5, 7)
            End With

            With .txbDvAgency
                .Location = New Point(145, 5)
                .Size = New Size(205, 32)
                .Text = "0"
                .TextAlign = HorizontalAlignment.Center
            End With

            With .pnDvResult
                .Location = New Point(10, 310)
                .Size = New Size(360, 50)
            End With

            With .txbDvInfoBox
                .Location = New Point(10, 12)
                .Size = New Size(130, 29)
                .BackColor = Color.FromArgb(0, 192, 0)
                .Text = String.Empty
                .TextAlign = HorizontalAlignment.Center
            End With

            With .btnDvRead
                .Location = New Point(145, 5)
                .Size = New Size(105, 40)
            End With

            With .btnDvWrite
                .Location = New Point(250, 5)
                .Size = New Size(105, 40)
            End With

        End With
    End Sub

    Public Sub ResetClear()
        With MainForm
            .txbIfNumber.Text = String.Empty
            .txbIfCode.Text = String.Empty
            .nudIfYear.Text = Format(Now, "yy")
            .nudIfMonth.Text = Format(Now, "MM")
            .nudIfSerial.Text = String.Empty
            .txbAbroad.Text = String.Empty
            .txbAgency.Text = String.Empty
            .txbTDSerial.Text = String.Empty
            .txbFreq.Text = String.Empty
            .txbPower.Text = String.Empty
            .txbMotor.Text = String.Empty
            .txbShot.Text = String.Empty
            .txbMaxShot.Text = String.Empty
            .txbFwVersion.Text = String.Empty

            .txbALFtDay.Text = "0000"
            .txbALFtHour.Text = "00"
            .txbALFtMin.Text = "00"
            .txbALFtSec.Text = "00"
            .txbALEtDay.Text = "0000"
            .txbALEtHour.Text = "00"
            .txbALEtMin.Text = "00"
            .txbALEtSec.Text = "00"
            .txbALCsDay.Text = "0000"
            .txbALCsHour.Text = "00"
            .txbALCsMin.Text = "00"
            .txbALCsSec.Text = "00"

            .txbALLtDay.Text = "0000"
            .txbALLtHour.Text = "00"
            .txbALLtMin.Text = "00"
            .txbALLtSec.Text = "00"
            .txbALBtDay.Text = "0000"
            .txbALBtHour.Text = "00"
            .txbALBtMin.Text = "00"
            .txbALBtSec.Text = "00"

            .txbALAllDay.Text = "0000"
            .txbALAllHour.Text = "00"
            .txbALAllMin.Text = "00"
            .txbALAllSec.Text = "00"

            .txbALAllErr.Text = String.Empty

        End With
    End Sub


End Module
