Imports System.Drawing
Imports System.Drawing.Printing
Imports System.Math
Imports System.IO

Imports ThoughtWorks.QRCode.Codec '//QR코드
Imports ThoughtWorks.QRCode.Codec.Util
Imports ThoughtWorks.QRCode.Codec.Data
Public Class printformsy

    Dim DrStyle As PatternDS.TStyleRow = Nothing
    Dim DtPattern As PatternDS.TPatternDataTable = Nothing

    Dim AllLabels() As Str_Alllabels    '//전체갯수는 추가할대 셋팅한다.

    Dim S관리구전산번호 As MyControlOLEDBv2.MyLabel
    Dim S선로명(0) As MyControlOLEDBv2.MyLabel
    Dim S전주번호(1) As MyControlOLEDBv2.MyLabel
    Dim S비고1(0) As MyControlOLEDBv2.MyLabel
    Dim S비고2(0) As MyControlOLEDBv2.MyLabel
    Dim S비고3(0) As MyControlOLEDBv2.MyLabel
    Dim S비고4(0) As MyControlOLEDBv2.MyLabel
    'Dim S사용자1(0) As MyControlOLEDBv2.MyLabel 'U 마이너스
    'Dim S사용자2(0) As MyControlOLEDBv2.MyLabel 'A
    'Dim S사용자3(0) As MyControlOLEDBv2.MyLabel 'B
    'Dim S사용자4(0) As MyControlOLEDBv2.MyLabel 'D
    'Dim S사용자5(0) As MyControlOLEDBv2.MyLabel 'E
    Dim S일련번호 As MyControlOLEDBv2.MyLabel

    Dim S고장신고(0) As MyControlOLEDBv2.MyLabel


    Dim 관리구, 전산번호 As String
    Dim 관리전산번호 As String = vbNullString
    Dim 패턴명_관리전산번호 As String = "KWANLIJUNSAN"
    Dim 선로명 As String = vbNullString
    Dim 패턴명_선로 As String = "SUNLOPATTERN"
    Dim 번호 As String = vbNullString
    Dim 패턴명_번호 As String = "JJNUMPATTERN"
    Dim 비고 As String = vbNullString
    Dim 비고1 As String = vbNullString
    Dim 패턴명_비고1 As String = "BIGO1PATTERN"
    Dim 비고2 As String = vbNullString
    Dim 패턴명_비고2 As String = "BIGO2PATTERN"
    Dim 비고3 As String = vbNullString
    Dim 패턴명_비고3 As String = "BIGO3PATTERN"
    Dim 비고4 As String = vbNullString
    Dim 패턴명_비고4 As String = "BIGO4PATTERN"
    Dim 고장신고 As String = vbNullString
    Dim 패턴명_고장신고 As String = "GOJANGPATTERN"

    Dim BlineNum As Short = 0

    Dim NoView As Boolean = False   '//LOAD_STYLE 을 잠시 실행하지 않기위햇(중복실행방지)서 둔다.
    Dim 관리구전산번호조작됨 As Boolean = True
    Dim 선로명조작됨 As Boolean = True
    Dim 전주번호조작됨 As Boolean = True

    Dim SrcIdx As Integer = -1  '//원본 리뷰에서 클릭된 인덱스
    Dim Srcnum As Integer = -1  '//원본 리뷴에서 클릭된 번호값
    Dim Srcrow As DataRowView
    Dim FirstIdx As Integer = -1 '//새로 생성된 리뷰에서 적용될 인덱스

    'Public File As String = My.Application.Info.DirectoryPath & "\style.ini"   '//스타일 파일
    Dim StyleDir As New System.IO.DirectoryInfo(My.Application.Info.DirectoryPath & "\styleetc")
    Public FileC As String = My.Application.Info.DirectoryPath & "\styleetc.ini" '//사용자 스타일 파일

    '/qr코드변수
    Dim qr홈페이지1 As String = ""
    Dim qr홈페이지2 As String = ""
    Dim qr홈페이지3 As String = ""
    Dim qr홈페이지4 As String = ""



    Private WithEvents pDoc As New PrintDocument()
    Dim SelCon As New ArrayList '//선택된 레이블들이 저장된 배열이다.
    Dim onlyOne As MyControlOLEDBv2.MyLabel  '//포커스를 가진 레이블이다.

    Dim srcTable As ireaDataSet.EtcTableDataTable    '//데이터가 저장될 테이블
    Dim Dv As DataView   '//데이터뷰(실제로 이 뷰의 데이터를 가지고 출력을 행한다.)

    Dim printindex As Integer = 0   '//프린트되는 페이지 번호 이값이 -1 이면 현재페이지이므로 갱신하지 않고 출력한다.
    Dim PrintArray() As Integer '//프린트할 페이지의 배열번호

    Dim SettingFile As String = My.Application.Info.DirectoryPath & "\epole.ini"    '//환경설정 파일
    Dim PrintMode As Boolean = False

#Region "New"
    Public Sub New()
        InitializeComponent()
        WLog2(Auto_Log, "New()", "\순차로그.txt")
    End Sub

    Public Sub New(ByRef Src As ireaDataSet.EtcTableDataTable, Optional ByVal IRow As DataRowView = Nothing)
        InitializeComponent()
        WLog2(Auto_Log, "New(srctable,srcRow)", "\순차로그.txt")
        srcTable = Src  '//가져온 테이블을 임시테이블에 저장을 해두고 사용한다.
        Srcrow = IRow  '//이것은 클릭된 행번호이다. 이 행번호를 가지고 스타일을 판별한다
    End Sub
#End Region

    Private Sub printformsy_KeyPress(ByVal sender As Object, ByVal e As System.Windows.Forms.KeyPressEventArgs) Handles Me.KeyPress

    End Sub

    Private Sub Form1_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
        Me.dataview.Setting_Load(False, "printjjung", "\viewConfig\suyoung_")
        Me.SetStyle(ControlStyles.AllPaintingInWmPaint Or ControlStyles.UserPaint Or ControlStyles.DoubleBuffer, True) '//더블버퍼링
        WLog2(Auto_Log, "Form_Load()", "\순차로그.txt")
        GetPrintersName()   '//프린터명을 가져옵니다.
        Load_Setting()
        SetControls()   '//컨트롤을 초기화하고 셋팅한다.

        If srcTable Is Nothing Then
            'MsgBox("소스가없어서 기본셋팅으로 전환함")
            WLog2(Auto_Log, "개발자 기본셋팅으로 전환()", "\순차로그.txt")
            Common.Auto_Log = True
            Me.NoView = True
            'Me.fryTableAdapter.Connection.ConnectionString = ConString
            'Me.fryTableAdapter.Fill(Me.IreaDataSet1.etctable, 1)
            'Me.srcTable = Me.IreaDataSet1.etctable
            ''MsgBox("데이터수=" & Me.IreaDataSet1.etctable.Rows.Count)
            Admin = True
        End If

        WLog2(Auto_Log, "개발자모드=" & Admin.ToString, "\순차로그.txt")
        If Admin Then '//개발자모드라면 상세조정내에 숨겨진 체크박스를오픈한다.
            For Each A As Control In Me.TabPage3.Controls
                If A.GetType.Name.ToUpper = "CHECKBOX" Then A.Visible = True
            Next
        End If

        Me.SETTOOLTIP()
        GetStyleList()  '//style.ini 에서 스타일목록명만 가져온다.

        If Srcrow Is Nothing Then '//가져온 행값이인덱스가 없으므로 1번째 스타일을 지정한다.
            WLog2(Auto_Log, "가져온 행값이 없습니다. firstidx=0 / 일반용으로 셋팅합니다()", "\순차로그.txt")
            FirstIdx = 0 '//또한 맨 처음 데이터를 표시하게된다.
            Me.cmb_style.SelectedIndex = 0
            Return
        End If

        '//여기서 행값을 분석해서 콤보밗를 셋팅해준다; '//전부 셋팅된후 해당 값을 또 찾아야 한다.
        Srcnum = Srcrow("번호") 'srcTable.Rows(SrcIdx).Item("번호")
        Me.cmb_style.SelectedIndex = 0
        WLog2(Auto_Log, "선택되서 넘오온데이터의 번호를 찾습니다=" & Srcnum, "\순차로그.txt")
        If Me.cmb_style.SelectedIndex < 0 AndAlso Me.cmb_style.Items.Count > 0 Then Me.cmb_style.SelectedIndex = 0
    End Sub

    Private Sub printform_FormClosing(ByVal sender As Object, ByVal e As System.Windows.Forms.FormClosingEventArgs) Handles Me.FormClosing
        Me.dataview.Setting_Save(False, "printjjung", "\viewConfig\suyoung_")
        WLog2(Auto_Log, "Form_Closk", "\순차로그.txt")
        Save_Setting()
    End Sub

    Private Sub printform_KeyDown(ByVal sender As Object, ByVal e As System.Windows.Forms.KeyEventArgs) Handles Me.KeyDown
        'If SelCon Is Nothing Then Return
        'Dim Tobj As MyControlOLEDBv2.MyLabel
        Select Case e.KeyCode
            Case Keys.Up
                If e.Shift Then '//글씨높이
                    Me.CtrSize(True, -1)
                Else
                    Me.CtrPos(True, -1)
                End If
                'Me.ViewProperty(SelCon(0))
                e.Handled = True
            Case Keys.Down
                If e.Shift Then
                    Me.CtrSize(True, 1)
                Else
                    Me.CtrPos(True, 1)
                End If
                'ViewProperty(Tobj)
                e.Handled = True
            Case Keys.Left
                If e.Shift Then
                    Me.CtrSize(False, -1)
                Else
                    Me.CtrPos(False, -1)
                End If
                'ViewProperty(Tobj)
                e.Handled = True
            Case Keys.Right
                If e.Shift Then
                    Me.CtrSize(False, 1)
                Else
                    Me.CtrPos(False, 1)
                End If
                'ViewProperty(Tobj)
                e.Handled = True

            Case Keys.F4 '//관리구5번저장
                Me.Button8.PerformClick()
            Case Keys.F7
                Me.bt_print.PerformButtonClick()
            Case Keys.F8
                Me.bt_prnpreview.PerformClick()
        End Select

    End Sub

    Private Sub SetControls()
        WLog2(Auto_Log, "Running : SetControls()", "\순차로그.txt")
        Dim CtlCnt As Short = 0

        For i As Integer = 0 To S전주번호.GetUpperBound(0)  '//모든문자를 할당한다.
            S전주번호(i) = New MyControlOLEDBv2.MyLabel
            S전주번호(i).설명 = "전주번호" & i + 1
            S전주번호(i).Name = "X" & i + 1
            S전주번호(i).Visible = False
            ReDim Preserve AllLabels(CtlCnt)
            Me.AllLabels(CtlCnt).ctl = S전주번호(i)
            Me.cmb_controls.Items.Add(S전주번호(i).설명)
            CtlCnt += 1
        Next

        S일련번호 = New MyControlOLEDBv2.MyLabel
        S일련번호.설명 = "일련번호"
        S일련번호.MyText = ""
        S일련번호.Name = "N1"
        S일련번호.Visible = False
        ReDim Preserve AllLabels(CtlCnt)
        Me.AllLabels(CtlCnt).ctl = S일련번호
        Me.cmb_controls.Items.Add(S일련번호.설명)
        CtlCnt += 1

        S비고4(0) = New MyControlOLEDBv2.MyLabel
        S비고4(0).설명 = "비고4"
        S비고4(0).MyText = ""
        S비고4(0).Name = "R"
        S비고4(0).Visible = False
        ReDim Preserve AllLabels(CtlCnt)
        Me.AllLabels(CtlCnt).ctl = S비고4(0)
        Me.cmb_controls.Items.Add(S비고4(0).설명)
        CtlCnt += 1

        S비고3(0) = New MyControlOLEDBv2.MyLabel
        S비고3(0).설명 = "비고3"
        S비고3(0).MyText = ""
        S비고3(0).Name = "Q"
        S비고3(0).Visible = False
        ReDim Preserve AllLabels(CtlCnt)
        Me.AllLabels(CtlCnt).ctl = S비고3(0)
        Me.cmb_controls.Items.Add(S비고3(0).설명)
        CtlCnt += 1

        S비고2(0) = New MyControlOLEDBv2.MyLabel
        S비고2(0).설명 = "비고2"
        S비고2(0).MyText = ""
        S비고2(0).Name = "P"
        S비고2(0).Visible = False
        ReDim Preserve AllLabels(CtlCnt)
        Me.AllLabels(CtlCnt).ctl = S비고2(0)
        Me.cmb_controls.Items.Add(S비고2(0).설명)
        CtlCnt += 1

        S비고1(0) = New MyControlOLEDBv2.MyLabel
        S비고1(0).설명 = "비고1"
        S비고1(0).MyText = ""
        S비고1(0).Name = "O"
        S비고1(0).Visible = False
        ReDim Preserve AllLabels(CtlCnt)
        Me.AllLabels(CtlCnt).ctl = S비고1(0)
        Me.cmb_controls.Items.Add(S비고1(0).설명)
        CtlCnt += 1

        S선로명(0) = New MyControlOLEDBv2.MyLabel
        S선로명(0).설명 = "선로명"
        S선로명(0).MyText = ""
        S선로명(0).Name = "L"
        S선로명(0).Visible = False
        ReDim Preserve AllLabels(CtlCnt)
        Me.AllLabels(CtlCnt).ctl = S선로명(0)
        Me.cmb_controls.Items.Add(S선로명(0).설명)
        CtlCnt += 1

        S관리구전산번호 = New MyControlOLEDBv2.MyLabel
        S관리구전산번호.설명 = "관리구전산번호"
        S관리구전산번호.MyText = ""
        S관리구전산번호.Name = "H"
        S관리구전산번호.Visible = False
        ReDim Preserve AllLabels(CtlCnt)
        Me.AllLabels(CtlCnt).ctl = S관리구전산번호
        Me.cmb_controls.Items.Add(S관리구전산번호.설명)
        CtlCnt += 1

        S고장신고(0) = New MyControlOLEDBv2.MyLabel
        S고장신고(0).설명 = "고장신고"
        S고장신고(0).MyText = ""
        S고장신고(0).Name = "Z"
        S고장신고(0).Visible = False
        ReDim Preserve AllLabels(CtlCnt)
        Me.AllLabels(CtlCnt).ctl = S고장신고(0)
        Me.cmb_controls.Items.Add(S고장신고(0).설명)
        CtlCnt += 1


    End Sub

    Private Sub SETTOOLTIP()
        WLog2(Auto_Log, "Settooltip()", "\순차로그.txt")
        Dim TMSG As New System.Text.StringBuilder()
        TMSG.AppendLine()
        TMSG.AppendLine("선택가능한 개체목록을 볼 수 잇습니다")
        TMSG.AppendLine()
        TMSG.AppendLine("화면에 보이지 않는 개체도 선택이 가능합니다")
        TMSG.AppendLine()
        Me.ToolTip1.SetToolTip(Me.cmb_controls, TMSG.ToString)

        TMSG = New System.Text.StringBuilder("")
        TMSG.AppendLine()
        TMSG.AppendLine("선택된 개체들의 화면표시여부를 결정정합니다")
        Me.ToolTip1.SetToolTip(Me.cb_visible, TMSG.ToString)


        TMSG = New System.Text.StringBuilder()
        TMSG.AppendLine()
        TMSG.AppendLine("▼ 연속된 페이지는 -(마이너스) 로 구분합니다")
        TMSG.AppendLine("   예) 2페이지에서 8페이지까지 :  2-8")
        TMSG.AppendLine()
        TMSG.AppendLine("▼ 불규칙 페이지는 ,(콤마) 로 구분합니다")
        TMSG.AppendLine("   예) 1,3,4,10 페이지 : 1,3,4,7")
        TMSG.AppendLine()
        TMSG.AppendLine("▼ 각조건의 구분은 /(슬래쉬) 로 구분합니다")
        TMSG.AppendLine("   예) 2~8페이지와 11,15번 페이지 : 2-8/11,15")
        TMSG.AppendLine()
        Me.ToolTip1.SetToolTip(Me.RadioButton3, TMSG.ToString)

        TMSG = New System.Text.StringBuilder()
        TMSG.AppendLine()
        TMSG.AppendLine("<개체들의 상태를 확인할 수 있습니다>")
        TMSG.AppendLine()
        TMSG.AppendLine("더블클릭시 임시적으로 해당 문자를 수정할 수 있습니다.")
        TMSG.AppendLine("왼쪽클릭시 해당개체만 선택됩니다.")
        TMSG.AppendLine("Ctrl + 왼쪽클릭시 해당개체가 속한 그룹이 선택됩니다.")
        TMSG.AppendLine("우클릭시 선택된 개체가 추가됩니다(다중선택기능)")
        TMSG.AppendLine()
        TMSG.AppendLine("[번호출력시 색상구분]")
        TMSG.AppendLine("흑색 :  문자패턴 적용")
        TMSG.AppendLine("녹색 :  길이패턴 적용")
        TMSG.AppendLine("적색 :  길이,문자패턴 미적용")
        TMSG.AppendLine()
        TMSG.AppendLine(">>환경설정에서 색상구분이 가능하도록 설정되어야 합니다")
        TMSG.AppendLine()
        Me.ToolTip1.SetToolTip(Me.PictureBox1, TMSG.ToString)


        TMSG = New System.Text.StringBuilder()
        TMSG.AppendLine()
        TMSG.AppendLine("<사용할 프린터를 선택하세요>")
        TMSG.AppendLine()
        TMSG.AppendLine("아무것도 입력되지 않았으면 기본프린터로 출력됩니다.")
        TMSG.AppendLine("현재 설치되어있는 프린터 목록이 표시됩니다.")
        TMSG.AppendLine()
        Me.combobox5.ToolTipText = TMSG.ToString
        'Me.ToolTip1.SetToolTip(Me.ComboBox5, TMSG.ToString)

        TMSG = New System.Text.StringBuilder()
        TMSG.AppendLine()
        TMSG.AppendLine("<2번째 장이 출력될 위치를 결정하세요.>")
        TMSG.AppendLine()
        TMSG.AppendLine("2번째 장이 출력될때 1번째장과의 왼쪽거리 값입니다. 0 으로할경우 동일한 X값이 됩니다.")
        TMSG.AppendLine("같은 줄 아래쪽에 표시를 하려면 X=0 으로두고 Y=값을 임의로 입력하세요")
        TMSG.AppendLine()
        Me.ToolTip1.SetToolTip(Me.tb_secX, TMSG.ToString)

        TMSG = New System.Text.StringBuilder()
        TMSG.AppendLine()
        TMSG.AppendLine("<2번째 장이 출력될 위치를 결정하세요.>")
        TMSG.AppendLine()
        TMSG.AppendLine("2번째 장이 출력될때 1번째장과의 위쪽거리 값입니다. 0 으로할경우 동일한 Y값이 됩니다.")
        TMSG.AppendLine("같은 줄 아래쪽에 표시를 하려면 X=0 으로두고 Y=값을 임의로 입력하세요")
        TMSG.AppendLine()
        Me.ToolTip1.SetToolTip(Me.tb_secY, TMSG.ToString)

        TMSG = New System.Text.StringBuilder()
        TMSG.AppendLine()
        TMSG.AppendLine("<2장 출력시 데이터의 출력방법을 선택하세요.>")
        TMSG.AppendLine()
        TMSG.AppendLine("[복사]는 현재데이터와 동일한 데이터가 표시됩니다.")
        TMSG.AppendLine("[다음]은 다음데이터가 표시됩니다.")
        TMSG.AppendLine()
        TMSG.AppendLine("동일한 데이터를 한번더 출력하려면 [복사]를 선택하세요.")
        TMSG.AppendLine("다음데이터까지 출력하려면 [다음]을 선택하세요")
        Me.ToolTip1.SetToolTip(Me.cmb_dummy, TMSG.ToString)
    End Sub

    Private Sub con_dclick(ByVal sender As Object, ByVal e As System.EventArgs)
        WLog2(Auto_Log, "개체를 더블클릭했습니다.(이것은 사용되지 않음)", "\순차로그.txt")
        Dim Msg As New System.Text.StringBuilder("변경할 값을 입력하세요")
        Msg.AppendLine("줄바꿈을하려면 \n 을 입력하세요")
        Msg.AppendLine("예) 세로로 12를 출력하려면 1\n2 을 입력하세요")
        Msg.AppendLine()
        Msg.AppendLine("변경한 값은 현재페이지에만 적용됩니다")
        Dim A As MyControlOLEDBv2.MyLabel = sender
        Dim Val As String = InputBox(Msg.ToString, "변경", A.MyText)
        If Val = "" Then Return
        Val = Val.Replace("\n", vbCrLf)
        A.MyText = Val
        '//preview 는 아마도 픽쳐박스 더블클릭에서 정의한듯 하다.
    End Sub

    Private Sub Save_Setting()
        WLog2(Auto_Log, "현재 설정(스타일)을 저장합니다.", "\순차로그.txt")
        Dim A As New MyINI2(SettingFile)
        A.Write("PRINTFORM", "printername", Me.combobox5.Text)   '//패턴검사조건 콤보박스      
    End Sub
    Private Sub Load_Setting()
        WLog2(Auto_Log, "현재설정(스타일)을 가져옵니다.()", "\순차로그.txt")
        WLog2(Auto_Log, "Load_Setting()", "\순차로그.txt")
        Dim a As New MyINI2(SettingFile)
        Me.combobox5.Text = a.Read("PRINTFORM", "printername", "")
    End Sub

    Public Sub GeTviewData(ByVal index As Integer, ByVal previewWindow As Boolean, Optional ByRef 번호패턴검사 As Integer = -1)
        ' Dim STARTTIME, ENDTIME As Date
        WLog2(Auto_Log, "Entering : GetviewData", "\순차로그.txt")
        If Dv.Count <= 0 OrElse index < 0 OrElse index > Dv.Count Then
            WLog2(Auto_Log, "GetViewData : Not index or has problem", "\순차로그.txt")
            'MsgBox("GETVIEWDATA : 데이터가 없거나 잘못된 인덱스 입니다", MsgBoxStyle.Information, "확인") & index & "/" & Me.CustFP1.ActiveSheet.RowCount & ")", MsgBoxStyle.Critical, "확인")
            Return '//잘못된 인덱스는 리턴
        End If
        WLog2(Auto_Log, "Running : GetviewData", "\순차로그.txt")

        관리구 = GetSpread(Me.Dv, index, "관리구")
        전산번호 = GetSpread(Me.Dv, index, "전주번호")
        If 관리구 <> "" OrElse 전산번호 <> "" Then Me.관리전산번호 = 관리구 & "-" & 전산번호

        선로명 = GetSpread(Me.Dv, index, "선로명")
        번호 = GetSpread(Me.Dv, index, "번호1") & GetSpread(Me.Dv, index, "번호2") & GetSpread(Me.Dv, index, "번호3") & GetSpread(Me.Dv, index, "번호4") & GetSpread(Me.Dv, index, "번호5")

        Me.비고1 = GetSpread(Me.Dv, index, "비고1") : Me.비고2 = GetSpread(Me.Dv, index, "비고2")
        Me.비고3 = GetSpread(Me.Dv, index, "비고3") : Me.비고4 = GetSpread(Me.Dv, index, "비고4")
        비고 = 비고1 & 비고2 & 비고3 & 비고4

        Me.고장신고 = Me.gojang.Text.ToString()
        Me.BlineNum = 0   '//줄번호수를 초기화한다. //'//전체 몇줄이 표시됬는지 확인한다. 이는 패턴을 찾을때 쓴다.
        If 비고1 <> "" Then BlineNum += 1 : If 비고2 <> "" Then BlineNum += 1 : If 비고3 <> "" Then BlineNum += 1 : If 비고4 <> "" Then BlineNum += 1

        WLog2(Auto_Log, "Complete : Load Data from Dataview's data", "\순차로그.txt")
        Me.Text = "수용번호찰 출력작업(" & 번호 & ")"

        WLog2(Auto_Log, "Entering : All Parse Function.", "\순차로그.txt")
        '============ 여기는 따로 해석이 없는곳이다 ==========================================================
        Me.PARSE_일련번호(index)
        '====================================================================================================
        WLog2(Auto_Log, "패턴이있는 PASE 구문을 실행합니다.()", "\순차로그.txt")
        If Me.PARSE_선로명(Me.선로명) Then Me.PARSE_선로명패턴(선로명)
        If Me.PARSE_번호(Me.번호) Then Me.PARSE_번호패턴(번호)
        If Me.PARSE_관리전산번호(Me.관리전산번호) Then Me.PARSE_관리전산번호패턴(Me.관리전산번호)
        If Me.PARSE_비고1(Me.비고1) Then Me.PARSE_비고1패턴(비고1)
        If Me.PARSE_비고2(Me.비고2) Then Me.PARSE_비고2패턴(비고2)
        If Me.PARSE_비고3(Me.비고3) Then Me.PARSE_비고3패턴(비고3)
        If Me.PARSE_비고4(Me.비고4) Then Me.PARSE_비고4패턴(비고4)
        If Me.PARSE_고장신고(Me.고장신고) Then Me.PARSE_고장신고(고장신고)

        WLog2(Auto_Log, "사용자문자의 표시여부를 결정합니다.()", "\순차로그.txt")
        '사용자문자의 표시여부 u a b d e
        'If Not Me.cb_사용자1.Checked Then Me.S사용자1(0).Visible = False
        'If Not Me.cb_사용자2.Checked Then Me.S사용자2(0).Visible = False
        'If Not Me.cb_사용자3.Checked Then Me.S사용자3(0).Visible = False
        'If Not Me.cb_사용자4.Checked Then Me.S사용자4(0).Visible = False
        'If Not Me.cb_사용자5.Checked Then Me.S사용자5(0).Visible = False

        WLog2(Auto_Log, "Pewview 윈도우를 실행합니다.()", "\순차로그.txt")
        Me.preview_window()
    End Sub

    Public Function ChkNumPattern(ByVal index As Integer) As Int16
        WLog2(Auto_Log, "번호패턴을 체크합니다. int16을 반환합니다.()", "\순차로그.txt")
        If Dv.Count <= 0 Or index < 0 OrElse index > Dv.Count Then
            'MsgBox("데이터가 없거나 잘못된 인덱스 입니다(" & index & "/" & Me.CustFP1.ActiveSheet.RowCount & ")", MsgBoxStyle.Critical, "확인")
            Return -1 '//잘못된 인덱스는 리턴
        End If

        Dim 검사번호패턴검사 As Integer = 0
        Dim 검사번호 As String
        검사번호 = GetSpread(Me.Dv, index, 7) & GetSpread(Me.Dv, index, 8) & GetSpread(Me.Dv, index, 9) & GetSpread(Me.Dv, index, 10) & GetSpread(Me.Dv, index, 11)
        If 검사번호.Trim = "" Then Return -1 '//검사번호자체에 문제가잇을시 에 리턴

        Dim Wlen As Short = 검사번호.Length : If Wlen <= 0 Then Return -1 '//없는 글귀가 왓을때 턴해버린다.
        Dim SRC() As Char = 검사번호.ToCharArray
        Dim Log As String = "\Parse_검사번호패턴.txt"
        Dim SepPos As Short = 검사번호.IndexOf(";")
        Dim retval As Integer = 0   ''0은 정상 1은 길이패턴없음 2는 3은 길이+문자없음

        '//검사번호는 길이패턴을 하지않고 문자패턴만 한다.
        Dim pname As String
        Dim Arinini As New MyINI2(DrStyle.FILE)
        Dim PATTERN As String = PATTERN_ENC(검사번호)

        '//먼저문자가있는지 확인한다.
        pname = "JJNUMPATTERNII" & PATTERN

        Dim Dr() As DataRow
        Dr = Me.DtPattern.Select("NAME = '" & pname & "DESC'")
        WLog2(Auto_Log, "길이패턴의 존재여부 = " & Dr.GetUpperBound(0) & ":" & pname, "\순차로그.txt")
        If Dr.GetUpperBound(0) <> -1 Then '//있다.
            retval += 2
            'WLog2(Auto_Log, "관리구5번 문자를 찾았습니다 (" & pname & "DESC" & ")", Log)
        End If

        'If Arinini.Read(pname, "DESC") = vbNullString Then retval += 2 '//패턴이 없으므로 바로 넘긴다.

        pname = "JJNUMPATTERN" & Wlen
        Dr = DtPattern.Select("NAME = '" & pname & "DESC'")
        WLog2(Auto_Log, "문자패턴의 존재여부 = " & Dr.GetUpperBound(0) & ";" & pname, "\순차로그.txt")
        If Dr.GetUpperBound(0) <> -1 Then '//있다.
            retval += 1
            'WLog2(Auto_Log, "관리구5번 문자를 찾았습니다 (" & pname & "DESC" & ")", Log)
        End If
        Return retval '// 0이 리턴될것이다. 패턴이 모두 정상이란 뜻이다
    End Function
    Public Sub CLEAR_ITEM(ByVal DIV As String)
        WLog2(Auto_Log, "Running : Clear_item() div=" & DIV, "\순차로그.txt")

        Select Case DIV.ToUpper
            Case "L"
                For i As Short = 0 To S선로명.GetUpperBound(0)
                    S선로명(i).MyText = ""
                    S선로명(i).Visible = False
                Next
            Case "H"
                S관리구전산번호.MyText = ""
                S관리구전산번호.Visible = False
            Case "X"
                For i As Short = 0 To S전주번호.GetUpperBound(0)
                    S전주번호(i).MyText = ""
                    S전주번호(i).Visible = False
                Next
            Case "N"
                S일련번호.MyText = ""
                S일련번호.Visible = False
            Case "O"
                Me.S비고1(0).MyText = ""
                Me.S비고1(0).Visible = False
            Case "P"
                Me.S비고2(0).MyText = ""
                Me.S비고2(0).Visible = False
            Case "Q"
                Me.S비고3(0).MyText = ""
                Me.S비고3(0).Visible = False
            Case "R"
                Me.S비고4(0).MyText = ""
                Me.S비고4(0).Visible = False
            Case "Z"
                Me.S고장신고(0).MyText = ""
                Me.S고장신고(0).Visible = False
            Case Else
                MsgBox("Clear_Item 에 알수없는 문자 ( " & DIV & ") 입니다")
        End Select

    End Sub
    Public Sub GetStyleList()
        AddLog(Auto_Log, "GetStyleList진입()", "\지중(케이블라벨)순차로그.txt")
        '//스타일명을 가져와서 콤보박스에 표시합니다.
        '//style 폴더아래의 ini 파일전체를 스타일 이라한다.
        '//파일을 읽어서 메모리에 저장한다.
        ' Dim Arinini As MyINI
        Dim CurIdx As Integer = 0
        If StyleDir.Exists = False Then StyleDir.Create()
        Dim StyleCnt As Short = StyleDir.GetFiles("*.ini").GetUpperBound(0)

        'ReDim StyleList(StyleCnt)
        ReDim Common.PDS(StyleCnt) '//패턴데이터셋의 갯수를 저장한다 

        Dim Section, Value As New ArrayList
        Dim SectionIdx As Integer = 0

        AddLog(Auto_Log, "GetStyleList(파일에서 스타일목을 가져온다)", "\지중(케이블라벨)순차로그.txt")

        '//스타일파일명을 테이블에 임시저장한다(일괄로 불러오기위함이다.)
        Dim Dt As New System.Data.DataTable : Dt.Columns.Add("파일명")

         For Each FI As IO.FileInfo In StyleDir.GetFiles("*.ini")
            Dt.Rows.Add(FI.FullName)
        Next
        For Each Dr As DataRow In Dt.Select("", "파일명 asc")
            Dim FileName As String = Dr("파일명")
            AddLog(Auto_Log, "파일명=(" & FileName & ") 의 스타일을 가져옵니다 메모리로", "\지중순차로그.txt")

            '//XML테이블을 새로생성
            Common.PDS(CurIdx) = New PatternDS

          GetAllsection(FileName, CurIdx)

            Me.cmb_style.Items.Add(Common.PDS(CurIdx).TStyle.Rows(0)("DESC").ToString)
            CurIdx += 1
        Next

    End Sub
    Private Sub 데이터테이블갱신()
        WLog2(Auto_Log, "데이터테이블 갱신()", "\순차로그.txt")
        GetAllsection(DrStyle.FILE, Me.cmb_style.SelectedIndex)

        '//기본변수설정 170219
        DrStyle = Common.PDS(Me.cmb_style.SelectedIndex).TStyle.Rows(0)
        DtPattern = Common.PDS(Me.cmb_style.SelectedIndex).TPattern

    End Sub


    Private Function Prepare_Print() As Boolean '//범위내의 페이지번호와 일치하는 번호를 찾아서 배열에 할당한다.
        WLog2(Auto_Log, "Func(PrePare_Print) 인쇄번호 할당 준비", "\Alllog.txt")

        Dim Number As Integer = 0
        Dim FindNum As Boolean = False
        Me.printindex = 0   '//배열의 첫번으로 출력을 준비한다.
        'Me.PrintArray = Nothing  '//출력번호 배열을 저장할 것이다.\
        ReDim PrintArray(0)
        PrintArray(0) = 1

        'log = False
        'AddLog("==============출력준비중==============", True)

        Me.pDoc.DefaultPageSettings.Margins.Left = 0 'Me.tb_marginx.Text  '//좌,우 여백 설정
        Me.pDoc.DefaultPageSettings.Margins.Top = 0 'Me.tb_marginy.Text
        Me.pDoc.DefaultPageSettings.Landscape = IIf(Me.cmb_landscape.SelectedIndex = 0, False, True) '//가로,세로 출력결정
        '//프린터명이 지정되어있다면 해당 프린터로설정,없으면 기본프린터
        If Me.combobox5.Text <> "" Then Me.pDoc.PrinterSettings.PrinterName = Me.combobox5.Text
        '//범위인데 값이 비어있으면 현재출력으로
        If Me.RadioButton3.Checked AndAlso Me.tb_printrange.Text.Trim = "" Then Me.RadioButton2.Checked = True


        If Me.rad_repeat.Checked Then
            If IsNumeric(Me.tb_printrange.Text) = False Then
                MsgBox("출력장수에 숫자만 입력하세요", MsgBoxStyle.Critical, "확인")
                Return False
            End If
            ReDim PrintArray(Val(Me.tb_printrange.Text) - 1)
            For i As Integer = 0 To Val(Me.tb_printrange.Text) - 1
                PrintArray(i) = Me.BindingNavigatorPositionItem.Text - 1
            Next
        End If


        If Me.RadioButton1.Checked Then '//전체출력이므로 배열에 모든것을 리턴한다 : 모든데이터의 레코드 인덱스를 저장한다.
            'MsgBox("rad1")
            ReDim Me.PrintArray(Me.Dv.Count - 1)
            For i As Integer = 0 To Dv.Count - 1
                Me.PrintArray(i) = i
            Next
        End If

        If Me.RadioButton2.Checked Then '//현재페이지 : 현재보고있다는 페에지의  레코드인덱스만 저장한다.
            'MsgBox("Rad2" & Me.BindingNavigatorPositionItem.Text - 1)
            ReDim Me.PrintArray(0)
            Me.PrintArray(0) = Me.BindingNavigatorPositionItem.Text - 1    '/현재카운트보다 1작다 배열은 0부터 시작하기떄문에
            'Me.printindex = -1
        End If


        '//2007-12-21일  변경시작
        If Me.RadioButton3.Checked Then '//범위지정 : 지정된범위내의 번호값을 가지고 해당 인덱스를 찾아서 배열에 할당한다.
            'Dim buff() As String = Me.tb_printrange.Text.Split("/")
            'Dim curpos As Integer = 0
            'MsgBox("rad3")


            Dim buff As String = Me.tb_printrange.Text
            ReDim Me.PrintArray(0) : Me.PrintArray(0) = -1

            '//먼저 -가 있나없나 판단해서 한페이지용인지 범위용인지 구분한다.
            If buff.IndexOf("-") >= 0 Then    '//범위이다.
                Dim SubBuff() As String = buff.Split("-")
                Dim Sttnum As Integer = CInt(SubBuff(0))  '//시작
                Dim endnum As Integer = CInt(SubBuff(1)) '//종료값

                For SI As Integer = 0 To endnum - Sttnum    '//범위갯수만큼 돈다
                    FindNum = False
                    Number = CInt(Sttnum + SI)   '//페이지만 적엇을 것이므로
                    For ni As Integer = 0 To Dv.Count - 1  '//현재뷰의 모든데이터를 가지고 검색한다 좌->우 순차검색
                        If Number = Dv(ni).Row("번호") Then
                            If PrintArray(0) = -1 Then '//처음데이터이므로
                                Me.PrintArray(0) = ni
                            Else   '//처음이아니므로 배열을 증가시키고 기입한다.
                                ReDim Preserve PrintArray(PrintArray.GetUpperBound(0) + 1)   '//배열1증가
                                Me.PrintArray(PrintArray.GetUpperBound(0)) = ni
                            End If
                            FindNum = True
                            Exit For
                        End If
                    Next
                Next

            Else   '//페이지번호만 적었을때다    
                If IsNumeric(buff) Then
                    Number = CInt(buff)   '//페이지만 적엇을 것이므로
                    For ni As Integer = 0 To Dv.Count - 1  '//현재뷰의 모든데이터를 가지고 검색한다 좌->우 순차검색
                        If Number = Dv(ni).Row("번호") Then
                            PrintArray(0) = ni
                            Exit For
                        End If
                    Next
                Else
                    MsgBox("범위(-)를 제외하고 숫자만 입력하세요", MsgBoxStyle.Critical, "입력오류")
                End If
            End If
        End If

        If PrintArray(0) = -1 Then '//배열에 아무것도 없다면
            Return False
        Else
            Return True
        End If
    End Function
    Private Sub Print_Preview()
        WLog2(Auto_Log, "print_preview 미리보기 버튼을 눌렀을때다.()", "\순차로그.txt")
        Me.PrintMode = True
        If Not Prepare_Print() Then
            MsgBox("인쇄할 목록이 없습니다", MsgBoxStyle.Critical, "확인")
            Return
        End If
        Dim Preview As New PrintPreviewDialog()
        Try
            Preview.Document = pDoc
            Preview.ShowDialog()

        Catch EX As Exception
            MsgBox(EX.Message)
        End Try
    End Sub
    Private Sub pDoc_PrintPage(ByVal sender As Object, ByVal e As System.Drawing.Printing.PrintPageEventArgs) Handles pDoc.PrintPage
        AddLog(Admin, "proc_printpage 프린트패이지를 작성한다 중요하다.()", "\Alllog.txt")

        Dim fmt As New StringFormat(StringFormatFlags.LineLimit)
        Dim MyFont As Font
        Dim NewFontSize As Int16 = 10
        Dim dummy As Boolean = False    '//이값이 true 이면 출력시 변위를 지정해서 출력한다.
        Dim C As MyControlOLEDBv2.MyLabel
        Dim NewLeft, NewTop As Integer

        '페이지 구분을 이해하고 몇개를 찍을지 결정한다.
        'Debug.Print("프린터인덱스=" & Me.printindex)
        'Debug.Print("프린터배열=" & Me.PrintArray.GetUpperBound(0))

        If Me.printindex <> -1 Then
            If Me.rad_repeat.Checked = False Then Me.GeTviewData(Me.PrintArray(Me.printindex), False) '//페이지를 갱신하고 출력을 시작한다.
        Else
            MsgBox("프린트 인덱스가 없습니다", MsgBoxStyle.Critical, "확인")

        End If
        e.Graphics.ScaleTransform(Me.tb_scalex.Text, Me.tb_scaley.Text)



        If Me.chk_draw.Checked Then
            '//라인을 그린다.
            For Each Rect As S_Line In Draw_Line
                Dim Pen As New Drawing.Pen(Rect.PenColor, Rect.PenWidth)
                If Me.PrintMode Then
                    e.Graphics.DrawLine(Pen, Rect.X + CInt(Me.tb_marginx.Text), Rect.Y + CInt(Me.tb_marginy.Text), Rect.X2 + CInt(Me.tb_marginx.Text), Rect.Y2 + CInt(Me.tb_marginy.Text))
                Else
                    e.Graphics.DrawLine(Pen, Rect.X, Rect.Y, Rect.X2, Rect.Y2)
                End If

            Next
            '//박스를 그린다.
            For Each Rect As S_Box In Draw_Box
                Dim Pen As New Drawing.Pen(Rect.PenColor, Rect.PenWidth)
                If Me.PrintMode Then
                    e.Graphics.DrawRectangle(Pen, Rect.X + CInt(Me.tb_marginx.Text), Rect.Y + CInt(Me.tb_marginy.Text), Rect.Width, Rect.Height)
                Else
                    e.Graphics.DrawRectangle(Pen, Rect.X, Rect.Y, Rect.Width, Rect.Height)
                End If

            Next
            '//원을 그린다.
            For Each Rect As S_Circle In Draw_Circle
                Dim Pen As New Drawing.Pen(Rect.PenColor, Rect.PenWidth)
                If Me.PrintMode Then
                    e.Graphics.DrawEllipse(Pen, Rect.X + CInt(Me.tb_marginx.Text), Rect.Y + CInt(Me.tb_marginy.Text), Rect.Width, Rect.Height)
                Else
                    e.Graphics.DrawEllipse(Pen, Rect.X, Rect.Y, Rect.Width, Rect.Height)
                End If

            Next
        End If

        If 관리구 <> "" Then
            Try
                '//QR코드를 그린다.
                For Each Rect As S_QRCode In Draw_QRcode
                    'Dim scale As Int16
                    Dim version As Int16
                    Dim image As Image
                    Dim data As String
                    Dim errorCorrect As String
                    Dim qrCodeEncoder1 As New QRCodeEncoder()
                    Dim encoding As String
                    encoding = cboEncoding.Text
                    If encoding = "3" Then
                        qrCodeEncoder1.QRCodeEncodeMode = ThoughtWorks.QRCode.Codec.QRCodeEncoder.ENCODE_MODE.BYTE
                    ElseIf encoding = "1" Then
                        qrCodeEncoder1.QRCodeEncodeMode = ThoughtWorks.QRCode.Codec.QRCodeEncoder.ENCODE_MODE.ALPHA_NUMERIC
                    ElseIf encoding = "2" Then
                        qrCodeEncoder1.QRCodeEncodeMode = ThoughtWorks.QRCode.Codec.QRCodeEncoder.ENCODE_MODE.NUMERIC
                        Try
                            version = Convert.ToInt16(cboVersion.Text)
                            qrCodeEncoder1.QRCodeVersion = version
                        Catch ex As Exception
                            MessageBox.Show("Invaild Version!")
                        End Try
                    End If

                    errorCorrect = cboCorrectionLevel.Text
                    If errorCorrect = "1" Then
                        qrCodeEncoder1.QRCodeErrorCorrect = ThoughtWorks.QRCode.Codec.QRCodeEncoder.ERROR_CORRECTION.L
                    ElseIf errorCorrect = "2" Then
                        qrCodeEncoder1.QRCodeErrorCorrect = ThoughtWorks.QRCode.Codec.QRCodeEncoder.ERROR_CORRECTION.M
                    ElseIf errorCorrect = "3" Then
                        qrCodeEncoder1.QRCodeErrorCorrect = ThoughtWorks.QRCode.Codec.QRCodeEncoder.ERROR_CORRECTION.Q
                    ElseIf errorCorrect = "4" Then
                        qrCodeEncoder1.QRCodeErrorCorrect = ThoughtWorks.QRCode.Codec.QRCodeEncoder.ERROR_CORRECTION.H
                    End If

                    qr홈페이지1 = home1.Text
                    qr홈페이지2 = home2.Text
                    qr홈페이지3 = home3.Text
                    qr홈페이지4 = home4.Text



                    data = qr홈페이지1 & "/" & qr홈페이지2 & "/" & qr홈페이지3 & "/" & qr홈페이지4 & "=" & 관리구 & "-" & 전산번호 & "&name=" & 선로명 & ":" & 번호

                    If lbQrBg.BackColor <> Drawing.Color.White Then qrCodeEncoder1.QRCodeBackgroundColor = lbQrBg.BackColor
                    If lbQrFG.BackColor <> Drawing.Color.Black Then qrCodeEncoder1.QRCodeForegroundColor = lbQrFG.BackColor
                    image = qrCodeEncoder1.Encode(data, e.Graphics.DpiX, e.Graphics.DpiY)
                    If Me.PrintMode Then
                        e.Graphics.DrawImage(image, Rect.X + CInt(Me.tb_marginx.Text), Rect.Y + CInt(Me.tb_marginy.Text), Rect.Width, Rect.Height)
                    Else
                        e.Graphics.DrawImage(image, Rect.X, Rect.Y, Rect.Width, Rect.Height)
                    End If

                    '   If Rect.Width = 0 OrElse Rect.Height = 0 Then
                    '        Ga.DrawImage(Image, Rect.X + MyProperty_Paper.출력여백X, Rect.Y + MyProperty_Paper.출력여백Y)
                    'e.Graphics.DrawImage(image, Rect.X + CInt(Me.tb_marginx.Text), Rect.Y + CInt(Me.tb_marginy.Text))
                    'Else
                    '        Ga.DrawImage(Image, Rect.X + MyProperty_Paper.출력여백X, Rect.Y + MyProperty_Paper.출력여백Y, Rect.Width, Rect.Height)
                    'e.Graphics.DrawImage(image, Rect.X, Rect.Y, Rect.Width, Rect.Height)
                    'End If
                Next
            Catch ex As Exception
                MessageBox.Show(ex.ToString())
            End Try
        End If







Dummyflag:  '//--2장출력일경우 이부분에서 다시 시작한다.

        'MsgBox(dummy)

        For i As Integer = 0 To Me.AllLabels.GetUpperBound(0)
            C = Me.AllLabels(i).ctl
            If C.Visible = True AndAlso C.MyText <> "" Then
                '//myfont 는 글꼴의 일괄크기변경 옵션의의해서 생성됨
                NewFontSize = C.MyFont.Size + Me.tb_myfontsize.Text
                If NewFontSize < 0 Then NewFontSize = 0

                MyFont = New Font(C.MyFont.FontFamily, NewFontSize, C.MyFont.Style)

                If dummy Then  '//인쇄가 아닐대에는 margin 을 넣지않는다.
                    NewLeft = C.Left + IIf(Me.PrintMode, Me.tb_marginx.Text, 0) + Me.tb_secX.Text
                    NewTop = C.Top + IIf(Me.PrintMode, Me.tb_marginy.Text, 0) + Me.tb_secY.Text
                Else
                    NewLeft = C.Left + IIf(Me.PrintMode, Me.tb_marginx.Text, 0)
                    NewTop = C.Top + IIf(Me.PrintMode, Me.tb_marginy.Text, 0)
                End If

                If C.장평 = 100 AndAlso C.장높이 = 100 Then '//장평미사용 문자열 처리                 
                    e.Graphics.DrawString(C.최종문자, MyFont, Brushes.Black, New Point(NewLeft, NewTop))
                Else    '//장평사용 이미지 처리
                    Dim NewX, Newy As Integer
                    Dim SrcDpix, SrcDPiY As Single
                    'MsgBox(Tobj.장높이)
                    SrcDpix = C.CreateGraphics.DpiX
                    SrcDPiY = C.CreateGraphics.DpiY

                    NewX = C.GetSize(MyFont).Width * (C.장평 / 100) * (e.Graphics.DpiX / SrcDpix)
                    Newy = C.GetSize(MyFont).Height * (C.장높이 / 100) * (e.Graphics.DpiY / SrcDPiY)

                    Dim BMP As New Bitmap(NewX, Newy, e.Graphics)
                    Dim G As Graphics = Graphics.FromImage(BMP)

                    G.ScaleTransform((C.장평 / 100), (C.장높이 / 100))
                    G.DrawString(C.최종문자, MyFont, Brushes.Black, 0, 0)
                    G.Dispose()
                    e.Graphics.DrawImage(BMP, New Point(NewLeft, NewTop)) ', CInt(GetSize.Width * (v장평 / 100)), GetSize.Height)
                End If
            End If
        Next

        '//페이지가 있던없던 2장복사를 먼저 확인한다.
        '//다음페이지가 잇으면 다음기능을 확인하고 그렇지 않을경우에는 한장복사만 확인한다.
        If dummy = False AndAlso Me.cb_dummy.Checked Then   '//2장복사일경우에는  현재복사인지 다음복사인지 체크

            dummy = True
            If Me.cmb_dummy.SelectedIndex = 0 Then  '//현재복사는 궂이 다음장없어도 가능하다.
                'dummy = True
                ' MsgBox("잇던없던 현재복사")
                GoTo Dummyflag
            Else    '//다음복사이므로 다음장이잇는지 확인하고해야한다.
                'MsgBox("다음장복사")
                If Me.printindex >= 0 AndAlso Me.printindex < Me.PrintArray.GetUpperBound(0) Then   '//다음장이있다.
                    'MsgBox("다음장이잇다.. 데이터바꾸고 goto한다")
                    Me.printindex += 1  '/1장넘기고 
                    If Me.rad_repeat.Checked = False Then Me.GeTviewData(Me.PrintArray(Me.printindex), False) '//데이터 바꾸는데..화면은 갱신하지 않는다.
                    GoTo Dummyflag  '//바로 출력다시한다.
                Else
                    'MsgBox("다음장없어서 그냥넘어간다")
                    '다음장이없으므로 그냥 넘어간다.
                    e.HasMorePages = False
                End If
            End If
        Else    '//다음장으로넘깁니다.
            If Me.printindex >= 0 AndAlso Me.printindex < Me.PrintArray.GetUpperBound(0) Then   '//다음장이있다.
                dummy = False   '//장수를 넘어가면 더미를 해제한다.
                Me.printindex += 1
                e.HasMorePages = True
            Else
                e.HasMorePages = False
            End If
        End If
        e.Graphics.Dispose()
    End Sub
    Private Sub Print()
        If MsgBox("인쇄를 하시겠습니까?", MsgBoxStyle.Information + MsgBoxStyle.OkCancel, "확인") = MsgBoxResult.Ok Then
            WLog2(Auto_Log, "print 바로 출력을 하라는 명령이다()", "\Alllog.txt")
            Me.PrintMode = True
            If Me.Prepare_Print() Then
                pDoc.Print()
                GeTviewData(BindingSource1.Position, True) '   preview_window()
            Else
                MsgBox("인쇄가능한 목록이 없습니다", MsgBoxStyle.Critical, "확인")
            End If
        Else
            NOTICE("인쇄가 취소되었습니다", Drawing.Color.Tomato, Me.lb_msg)
        End If
    End Sub
    Private Sub con_Mmove(ByVal sender As Object, ByVal e As System.Windows.Forms.MouseEventArgs)
        WLog2(Auto_Log, "con _move 개체이동할 프로시져인데 현재 안쓴다.()", "\순차로그.txt")
        If My.Computer.Keyboard.CtrlKeyDown AndAlso e.Button = Windows.Forms.MouseButtons.Left Then
            ' Me.Text = CType(sender, Label).Left & "/" & e.X
            CType(sender, MyControlOLEDBv2.MyLabel).Left += e.X
            CType(sender, MyControlOLEDBv2.MyLabel).Top += e.Y
        End If
    End Sub
    Public Sub ViewProperty(ByVal sender As MyControlOLEDBv2.MyLabel)
        WLog2(Auto_Log, "view properfty  개체의 상태보기()", "\순차로그.txt")
        If Not Me.GroupBox2.Enabled Then Me.GroupBox2.Enabled = True

        Me.TB_FONTNAME.Text = sender.MyFont.Name.ToString
        Me.tb_left.Text = sender.Left
        Me.tb_top.Text = sender.Top

        Me.tb_foncol.BackColor = sender.MyForeColor
        Me.cb_visible.Checked = sender.Visible

        Me.cb_bold.Checked = sender.MyFont.Bold
        'Me.cb_italic.Checked = sender.MyFont.Italic
        ' Me.cb_uline.Checked = sender.MyFont.Underline

        Me.tb_fsize.Text = sender.MyFont.Size
        Me.tb_wordwidth.Text = sender.장평
        Me.tb_wordheight.Text = sender.장높이
        Me.tb_space.Text = sender.공백



        Me.GroupBox2.Text = "위치/크기/글꼴(" & sender.MyText & ") W=" & sender.GetSize.Width & ",H=" & sender.GetSize.Height

        If Not sender.Tag Is Nothing Then   '//여기서 개체의 패턴적용여부를 표시합니다.
            ' MsgBox(sender.Tag.ToString)
            Me.lb_countpattern.ForeColor = IIf(sender.Tag.ToString.IndexOf("L") >= 0, Drawing.Color.Green, Drawing.Color.Black)
            Me.lb_strpattern.ForeColor = IIf(sender.Tag.ToString.IndexOf("C") >= 0, Drawing.Color.Green, Drawing.Color.Black)
            'Me.CB_LPATTERN.Checked = IIf(sender.Tag.ToString.IndexOf("L") >= 0, True, False)
            'Me.CB_CHARPATTERN.Checked = IIf(sender.Tag.ToString.IndexOf("C") >= 0, True, False)
        Else
            Me.lb_countpattern.ForeColor = Drawing.Color.Black
            Me.lb_strpattern.ForeColor = Drawing.Color.Black
        End If
    End Sub
    Private Sub ViewBackImage()
        WLog2(Auto_Log, "viewBackImage 배경이미지를 표시합니다.()", "\정액등순차로그.txt")
        Dim Picimg As String
        If Me.tb_picfile.Text.IndexOf(":") > -1 Then  '//드라이브명이 있으면 그대로쓰고 아니면 붙여서쓴다.
            Picimg = Me.tb_picfile.Text
        Else
            Picimg = My.Application.Info.DirectoryPath & "\image\" & Me.tb_picfile.Text
        End If
        If Not System.IO.File.Exists(Picimg) Then
            Me.CheckBox4.Checked = False
        ElseIf Me.CheckBox4.Checked Then
            Me.PictureBox1.BackgroundImage = Image.FromFile(Picimg)
        End If
    End Sub
    Private Sub CheckBox4_CheckedChanged(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles CheckBox4.CheckedChanged
        WLog2(Auto_Log, "배경보기 체크박스를 클릭했다.)", "\순차로그.txt")
        'Me.PictureBox1.Visible = IIf(CType(sender, CheckBox).Checked, True, False)
        If CType(sender, Windows.Forms.CheckBox).Checked Then
            Me.ViewBackImage()
        Else
            Me.PictureBox1.BackgroundImage = Nothing
        End If
    End Sub
    Private Sub Label11_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Label11.Click
        Dim A As New OpenFileDialog
        WLog2(Auto_Log, "파일찾기 버튼이 클릭됨", "\순차로그.txt")

        If System.IO.File.Exists(Me.tb_picfile.Text) Then
            A.FileName = Me.tb_picfile.Text
        Else
            A.FileName = My.Application.Info.DirectoryPath & "\image\normal.jpg"
        End If
        If A.ShowDialog() <> Windows.Forms.DialogResult.OK Then Return
        Me.tb_picfile.Text = A.FileName
        Me.PictureBox1.BackgroundImage = Image.FromFile(Me.tb_picfile.Text)
        Me.CheckBox4.Checked = True
    End Sub
    Public Sub CtrPos(ByVal vertical As Boolean, ByVal offset As Short)
        WLog2(Auto_Log, "ctrpos (선택된 개체들의 위치값을 변경합니다)", "\순차로그.txt")
        If SelCon Is Nothing OrElse SelCon.Count < 1 Then Exit Sub

        For Each sender As Control In SelCon
            If vertical Then    '//좌우측
                If My.Computer.Keyboard.CtrlKeyDown Then
                    If offset < 0 Then
                        sender.Top -= 10
                    Else
                        sender.Top += 10
                    End If
                Else
                    sender.Top += offset
                End If
            Else    '//상하측
                If My.Computer.Keyboard.CtrlKeyDown Then
                    If offset < 0 Then
                        sender.Left -= 10
                    Else
                        sender.Left += 10
                    End If
                Else
                    sender.Left += offset
                End If
            End If

        Next

        WLog2(Auto_Log, "ctrpos =[ preview 호출합니다]", "\순차로그.txt")
        Me.preview_window()
        'Me.ViewProperty(sender)
    End Sub

    Public Sub SetFont()   '//체크박스 상태에따라서 폰트를 변경합니다.
        WLog2(Auto_Log, "set font 체크박스 상태에 따라서 폰트를 변경합니다.", "\순차로그.txt")
        Dim B As System.Drawing.FontStyle
        If Me.cb_bold.Checked = True Then B = FontStyle.Bold
        Dim Tobj As MyControlOLEDBv2.MyLabel
        For Each A As Control In SelCon
            Tobj = CType(A, MyControlOLEDBv2.MyLabel)
            Tobj.MyFont = New Font(Tobj.MyFont, B)
        Next
        WLog2(Auto_Log, "setfont = preview 호출합니다.", "\순차로그.txt")
        Me.preview_window()
    End Sub
    Private Sub cmb_style_KeyUp(ByVal sender As Object, ByVal e As System.Windows.Forms.KeyEventArgs) Handles cmb_style.KeyUp
        WLog2(Auto_Log, "스타일콤보박스에서 keyip 이 감지되었으나 핸들을 true 로 해버린다.", "\순차로그.txt")
        e.Handled = True
    End Sub
    Private Sub cmb_style_SelectedIndexChanged(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles cmb_style.SelectedIndexChanged
        '//여기서 데이터를 추려내고(필터를 가져온다.)
        '//해당 스타일을 불러온다.

        WLog2(Auto_Log, "스타일 인덱스가 변경되었다.", "\순차로그.txt")
        If Me.cmb_style.SelectedIndex < 0 Then Me.cmb_style.SelectedIndex = 0

        '//기본변수설정 170219
        DrStyle = Common.PDS(Me.cmb_style.SelectedIndex).TStyle.Rows(0)
        DtPattern = Common.PDS(Me.cmb_style.SelectedIndex).TPattern

        Dim DataFilter As String = drstyle.Filter
        If DataFilter.Trim = "" Then
            DataFilter = "출력 = true" '//인쇄필드는 지선주 구분용으로 재사용한다.
        Else
            DataFilter &= " AND 출력 = true" '//지선주는 인쇄가 True 값이기때문에 해당 값을 제외한다
        End If

        Me.BindingSource1.Sort = ""
        Me.BindingSource1.DataSource = Nothing

        Dv = New DataView(srcTable, DataFilter, "정렬번호,번호", DataViewRowState.CurrentRows)
        'Dv = New DataView(srcTable, "len(DL명) > 0", "", DataViewRowState.CurrentRows)
        Me.SaveReadLayOut(True)
        Me.SaveDrawData(True)
        If Dv.Count <= 0 Then '//데이터가없다면
            MsgBox(Me.cmb_style.Text & "에 해당하는 데이터가존재하지 않습니다" & vbCrLf & vbCrLf & "다른 스타일을 선택하세요", MsgBoxStyle.Information, "확인")
            Me.PictureBox1.Refresh()
        Else
            WLog2(Auto_Log, "선택된 스타일에 데이터가있다=" & Dv.Count, "\순차로그.txt")
            Me.textbox2.Text = Dv.Count - 1 '//패턴검사시 종료카운터이다...
            'Me.VScrollBar1.Minimum = 1 'Me.BindingNavigatorPositionItem.Text
            'Me.VScrollBar1.Maximum = Dv.Count   'Me.BindingNavigatorCountItem.Text  ' Dv.Count '- 1

            Me.VScrollBar1.Minimum = 0
            Me.VScrollBar1.Maximum = Dv.Count - 1
            'MsgBox("cmb style select change=" & Me.VScrollBar1.Maximum)

            Me.LOAD_STYLE()   '//스타일불러오기(여기서 모든컨트롤의 기본 위치와 글꼴이 결정된다)
            If Me.FirstIdx = -1 Then
                For i As Integer = 0 To Dv.Count - 1    '//맨첨보여줄놈을 찾는다. DV와 원래 인덱스값이 다르기때문에 찾아야한다.
                    If Dv(i)("번호") = Srcnum Then
                        FirstIdx = i
                        Exit For
                    End If
                Next
            End If


            '필터를 적용해서 뷰를 구성한다음에 해당 뷰를 데이터소스로 변경한다.
            Me.SaveReadLayOut(True)
            Me.SaveDrawData(True)

            If FirstIdx = -1 OrElse FirstIdx > Dv.Count - 1 Then FirstIdx = 0 '//찾지못하고 나왓을경우에는 1번쨰 레코드를 보여주도록 한다.


            NoView = True   '//For Validate Index =0


            If FirstIdx = 0 Then    '//Index is first
                WLog2(Auto_Log, "View : First Record // Set = 0", "\Alllog.txt")
            Else    '//index is not first
                WLog2(Auto_Log, "View : Index Count = " & FirstIdx, "\Alllog.txt")
            End If

            Me.BindingSource1.DataSource = Dv 'Dv   '//여기서셋팅되면서 바로 tview 가 작동된다.
            Me.BindingSource1.Sort = "정렬번호,번호" ',번호"            
            Me.VScrollBar1.Value = FirstIdx
            Me.BindingSource1.Position = FirstIdx
            Me.dataview.DataSource = Me.BindingSource1
            'MsgBox("ASDF" & Me.BindingNavigatorPositionItem.Text)
            If FirstIdx = 0 Then Me.GeTviewData(Me.BindingNavigatorPositionItem.Text - 1, True)

        End If

        'WLog2(Auto_Log, "cmb_style selectindexchanged 에서 preview 를 호출함", "\순차로그.txt")
        'Me.preview_window()
    End Sub
    Public Sub LOAD_STYLE(Optional ByVal Div As String = "Z")   '//저장된 스타일을 불러옵니다.
        '  MsgBox("LOADSTYLE" & "/" & Div)
        '  MsgBox("LOADSTYLE" & "/" & Div)
        WLog2(Auto_Log, "load_style : 스타일을 불러옵니다. div= " & Div, "\순차로그.txt")
        Dim Arinini As New MyINI2(drstyle.file)
        Dim pos(), font(), visible, mytext As String
        Dim Tobj As MyControlOLEDBv2.MyLabel
        Dim DR() As DataRow
        Dim idx As Integer = 0

        '//모든아이템을 돈다
        For i As Integer = 0 To Me.AllLabels.GetUpperBound(0)   '//모든아이템을 돈다.
            Tobj = Me.AllLabels(i).ctl
            Try
                If Div.ToUpper = "Z" Then '//모든아이템을 가져오고
                    '//메모리에서 찾는다.
                    Tobj.Tag = ""
                    DR = DtPattern.Select("NAME = 'STYLE" & Tobj.Name.ToUpper & "POS'")
                    If DR.GetUpperBound(0) = 0 Then
                        pos = DR(0)(1).ToString.Split(",")
                        Tobj.Location = New Point(pos(0), pos(1))
                        Tobj.Size = New Size(pos(2), pos(3))
                    End If

                    DR = DtPattern.Select("NAME = 'STYLE" & Tobj.Name.ToUpper & "FONT'")
                    If DR.GetUpperBound(0) = 0 Then
                        font = DR(0)(1).ToString.Split(",")
                        Tobj.장평 = font(5)
                        Tobj.장높이 = font(6)
                        Tobj.MyFont = New Font(font(0), font(1), IIf(font(3).ToUpper = "TRUE", FontStyle.Bold, FontStyle.Regular), GraphicsUnit.Point)
                    End If

                    DR = DtPattern.Select("NAME = 'STYLE" & Tobj.Name.ToUpper & "VISIBLE'")
                    If DR.GetUpperBound(0) = 0 Then
                        visible = DR(0)(1).ToString
                        Tobj.Visible = CType(visible, Boolean)
                    End If

                    DR = DtPattern.Select("NAME = 'STYLE" & Tobj.Name.ToUpper & "MYTEXT'")
                    If DR.GetUpperBound(0) = 0 Then
                        mytext = DR(0)(1).ToString
                        Select Case Tobj.Name.ToUpper.Substring(0, 1)
                            Case "U", "A", "B", "D", "E"    '//사용자문자일경우에는 문자열도 저장해야한다.
                                If mytext <> "" Then Tobj.MyText = TextDec(mytext) '//ini구조상 바로저장하면안되기때문에 변환해서 저장한다.
                        End Select
                    End If

                    DR = DtPattern.Select("NAME = 'STYLE" & Tobj.Name.ToUpper & "SPACE'")
                    If DR.GetUpperBound(0) = 0 Then Tobj.공백 = DR(0)(1).ToString
                Else    '//특정아이템구분일때 

                    If Tobj.Name.ToUpper.Substring(0, 1) = Div Then
                        If Div.ToUpper = "H" Then   '//H의경우는 따로 찾아본다.

                            '//메모리에서 찾는다.
                            Tobj.Tag = ""
                            DR = DtPattern.Select("NAME = 'STYLE" & Tobj.Name.ToUpper & "POS'")
                            If DR.GetUpperBound(0) = 0 Then
                                pos = DR(0)(1).ToString.Split(",")
                                Tobj.Location = New Point(pos(0), pos(1))
                                Tobj.Size = New Size(pos(2), pos(3))
                            End If

                            DR = DtPattern.Select("NAME = 'STYLE" & Tobj.Name.ToUpper & "FONT'")
                            If DR.GetUpperBound(0) = 0 Then
                                font = DR(0)(1).ToString.Split(",")
                                Tobj.장평 = font(5)
                                Tobj.장높이 = font(6)
                                Tobj.MyFont = New Font(font(0), font(1), IIf(font(3).ToUpper = "TRUE", FontStyle.Bold, FontStyle.Regular), GraphicsUnit.Point)
                            End If

                            DR = DtPattern.Select("NAME = 'STYLE" & Tobj.Name.ToUpper & "VISIBLE'")
                            If DR.GetUpperBound(0) = 0 Then
                                visible = DR(0)(1).ToString
                                Tobj.Visible = CType(visible, Boolean)
                            End If

                            DR = DtPattern.Select("NAME = 'STYLE" & Tobj.Name.ToUpper & "MYTEXT'")
                            If DR.GetUpperBound(0) = 0 Then
                                mytext = DR(0)(1).ToString
                                Select Case Tobj.Name.ToUpper.Substring(0, 1)
                                    Case "U", "A", "B", "D", "E"    '//사용자문자일경우에는 문자열도 저장해야한다.
                                        If mytext <> "" Then Tobj.MyText = TextDec(mytext) '//ini구조상 바로저장하면안되기때문에 변환해서 저장한다.
                                End Select
                            End If

                            DR = DtPattern.Select("NAME = 'STYLE" & Tobj.Name.ToUpper & "SPACE'")
                            If DR.GetUpperBound(0) = 0 Then Tobj.공백 = DR(0)(1).ToString

                        Else
                            '//메모리에서 찾는다.
                            Tobj.Tag = ""
                            DR = DtPattern.Select("NAME = 'STYLE" & Tobj.Name.ToUpper & "POS'")
                            If DR.GetUpperBound(0) = 0 Then
                                pos = DR(0)(1).ToString.Split(",")
                                Tobj.Location = New Point(pos(0), pos(1))
                                Tobj.Size = New Size(pos(2), pos(3))
                            End If

                            DR = DtPattern.Select("NAME = 'STYLE" & Tobj.Name.ToUpper & "FONT'")
                            If DR.GetUpperBound(0) = 0 Then
                                font = DR(0)(1).ToString.Split(",")
                                Tobj.장평 = font(5)
                                Tobj.장높이 = font(6)
                                Tobj.MyFont = New Font(font(0), font(1), IIf(font(3).ToUpper = "TRUE", FontStyle.Bold, FontStyle.Regular), GraphicsUnit.Point)
                            End If

                            DR = DtPattern.Select("NAME = 'STYLE" & Tobj.Name.ToUpper & "VISIBLE'")
                            If DR.GetUpperBound(0) = 0 Then
                                visible = DR(0)(1).ToString
                                Tobj.Visible = CType(visible, Boolean)
                            End If

                            DR = DtPattern.Select("NAME = 'STYLE" & Tobj.Name.ToUpper & "MYTEXT'")
                            If DR.GetUpperBound(0) = 0 Then
                                mytext = DR(0)(1).ToString
                                Select Case Tobj.Name.ToUpper.Substring(0, 1)
                                    Case "U", "A", "B", "D", "E"    '//사용자문자일경우에는 문자열도 저장해야한다.
                                        If mytext <> "" Then Tobj.MyText = TextDec(mytext) '//ini구조상 바로저장하면안되기때문에 변환해서 저장한다.
                                End Select
                            End If

                            DR = DtPattern.Select("NAME = 'STYLE" & Tobj.Name.ToUpper & "SPACE'")
                            If DR.GetUpperBound(0) = 0 Then Tobj.공백 = DR(0)(1).ToString
                        End If
                    End If
                End If
            Catch ex As Exception
                WLog2(Auto_Log, "LOAD_STYLE_CUSTOM 오류:" & ex.Message.ToString, "LOAD_STYLE")
                '     MsgBox(ex.Message.ToString)
            End Try

        Next

        '        If Div.ToUpper <> "Z" Then Return '//모든템이아니다                                                                    ------임시방편..
        '       WLog2(Auto_Log, "load_style 기본값 체크박스등의 값을 불러온다. 이것은 맨첨에만 불러오면 된다. ", "\순차로그.txt")       ------임시 방편..

        '''''''''''''''''''''우측 스타일 체크박스를 가져온다.
        For Each B As Control In Me.TabPage1.Controls
            If B.GetType.Name.ToUpper = "CHECKBOX" Then '//체크박스라면 태그를 저장한다.
                CType(B, Windows.Forms.CheckBox).Checked = Arinini.Read("STYLE", B.Name, False)  '//기본값 false
            End If
        Next
        For Each B As Control In Me.TabPage3.Controls
            If B.GetType.Name.ToUpper = "CHECKBOX" Then '//체크박스라면 태그를 저장한다.
                CType(B, Windows.Forms.CheckBox).Checked = Arinini.Read("STYLE", B.Name, False)  '//기본값 false
            End If
        Next

        ''''''''''''''''''''''''''''외'''''''''''''''''''''''''''''''''
        Me.tb_marginx.Text = drstyle.MarginX 'Arinini.Read("STYLE", "MarginX", 10)
        Me.tb_marginy.Text = drstyle.MarginY ' Arinini.Read("STYLE", "MarginY", 10)
        Me.tb_scalex.Text = drstyle.ScaleX ' Arinini.Read("STYLE", "ScaleX", "1.5")
        Me.tb_scaley.Text = drstyle.ScaleY ' Arinini.Read("STYLE", "ScaleY", "1.3")
        ''''''''''''2중
        Me.cb_dummy.Checked = drstyle.Dummy 'Arinini.Read("STYLE", "dummy", False)
        Me.cmb_dummy.SelectedIndex = drstyle.Dummytype ' Arinini.Read("STYLE", "dummytype", 0)
        Me.tb_secX.Text = drstyle.dummmyx ' Arinini.Read("STYLE", "dummmyx", "0")
        Me.tb_secY.Text = drstyle.dummmyy ' Arinini.Read("STYLE", "dummmyy", "300")

        If DrStyle.BACKIMG.IndexOf("\") = -1 Then
            Me.tb_picfile.Text = My.Application.Info.DirectoryPath & "\image\" & DrStyle.BACKIMG
        Else
            Me.tb_picfile.Text = DrStyle.BACKIMG ' Arinini.Read("STYLE", "backimg", My.Application.Info.DirectoryPath & "\image\wall.bmp").ToString.Trim(Chr(0))
        End If
        Me.ViewBackImage()  '//배경이미지를 표시한다.

        Me.pDoc.DefaultPageSettings.Landscape = DrStyle.LANDSCAPE ' Arinini.Read("STYLE", "LandScape", False)
        Me.cmb_landscape.SelectedIndex = IIf(Me.pDoc.DefaultPageSettings.Landscape, 1, 0)

        Me.CheckBox4.Checked = DrStyle.VIEWIMAGE ' Arinini.Read("STYLE", "ViewImage", True)
        Me.tb_myfontsize.Text = DrStyle.PRINTFONTOFFSET    ' Arinini.Read("STYLE", "PrintFontOffset", 0)


        '//QR코드
        Try
            Me.cboCorrectionLevel.Text = Arinini.Read("STYLE", "qrlevel", 1)
            Me.cboEncoding.Text = Arinini.Read("STYLE", "qrencoding", 2)
            Me.cboVersion.Text = Arinini.Read("STYLE", "qrvison", 1)
            Dim qrbgstr As String = Arinini.Read("STYLE", "qrbg", "")
            Dim qrfgstr As String = Arinini.Read("STYLE", "qrfg", "")
            If qrbgstr = "" Then
                lbQrBg.BackColor = Drawing.Color.White
            Else
                lbQrBg.BackColor = Drawing.Color.FromArgb(CInt(qrbgstr))
            End If
            If qrfgstr = "" Then
                lbQrFG.BackColor = Drawing.Color.Black
            Else
                lbQrFG.BackColor = Drawing.Color.FromArgb(CInt(qrfgstr))
            End If
        Catch ex As Exception
            MessageBox.Show(ex.ToString())
        End Try

        '//QR홈페이지
        '//Try
        Me.home1.Text = Arinini.Read("STYLE", "qrhome1", "http://cyber.kepco.co.kr")
        Me.home2.Text = Arinini.Read("STYLE", "qrhome2", "jeonbuk")
        Me.home3.Text = Arinini.Read("STYLE", "qrhome3", "mjeonbuk")
        Me.home4.Text = Arinini.Read("STYLE", "qrhome4", "report.jsp?location")
        '//Catch ex As Exception
        '//  MessageBox.Show(ex.ToString())
        '//End Try

        Me.gojang.Text = Arinini.Read("STYLE", "gojang", "고장신고도 스마트하게")


        'Me.PictureBox1.Width =drstyle.CanvasX 'Arinini.Read("STYLE", "CanvasX", 297) '520
        'Me.PictureBox1.Height =drstyle.CanvasY ' Arinini.Read("STYLE", "CanvasY", 520) '520

        NOTICE(Me.cmb_style.Text & "스타일을 불러왔습니다.", Me.lb_msg)

    End Sub
    Public Sub SAVE_STYLE()
        WLog2(Auto_Log, "[Saving] Current Style to INI File ", "\순차로그.txt")
        Dim Arinini As New MyINI2(drstyle.file)
        Dim Arininic As New MyINI2(CStr(drstyle.file).ToLower.Replace("ini", "cfg"))
        Dim Tobj As MyControlOLEDBv2.MyLabel
        'Dim Div As Char



        '//현재 선택된 스타일을 저장합니다.
        erp.SetError(Me.cmb_style, vbNullString)
        If Me.cmb_style.SelectedIndex < 0 Then
            erp.SetError(Me.cmb_style, "저장할 스타일이 선택되지 않았습니다.")
            NOTICE("스타일을 선택하세요", Me.lb_msg)
            Return
        End If

        Dim f As New fProgress()
        f.ProgressBar1.Minimum = 0
        f.ProgressBar1.Maximum = Me.AllLabels.Length
        f.ProgressBar1.Value = 0
        f.ProgressBar1.Style = ProgressBarStyle.Blocks
        f.Label1.Text = String.Format("스타일을 저장합니다" + vbCrLf + "Control")
        'f.TopMost = True
        f.Show()
        Application.DoEvents()

        For i As Integer = 0 To Me.AllLabels.GetUpperBound(0)
            f.ProgressBar1.Value += 1
            f.Refresh()

            Tobj = Me.AllLabels(i).ctl
            Arinini.Write("STYLE", Tobj.Name & "pos", Tobj.Left & "," & Tobj.Top & "," & Tobj.Width & "," & Tobj.Height)
            Arinini.Write("STYLE", Tobj.Name & "font", Tobj.MyFont.Name & "," & Tobj.MyFont.Size & "," & Tobj.MyFont.Underline & "," & Tobj.MyFont.Bold & "," & Tobj.MyFont.Italic & "," & Tobj.장평 & "," & Tobj.장높이)
            Arinini.Write("STYLE", Tobj.Name & "visible", "true") '기본값으로 표시로 정해놓고 체크박스 체크한다.
            Arinini.Write("STYLE", Tobj.Name & "space", Tobj.공백)
            Select Case Tobj.Name.ToUpper.Substring(0, 1)    '//사용자문자일 경우에는 해당 문자역시 저장을 한다.
                Case "U", "A", "B", "D", "E" '//사용자문자는 총 5개이다.
                    Arinini.Write("STYLE", Tobj.Name & "mytext", TextEnc(Tobj.MyText))
            End Select

            'Div = Tobj.Name.Substring(0, 1) '1자리만끊어서 체크박스 태그랑 연결한다. (모르겟다 이부분이 왜 있는지 일단해제한다. 1118일 19시 2분
            'For Each B As Control In Me.TabPage1.Controls
            '    If B.GetType.Name.ToUpper = "CHECKBOX" Then '//체크박스라면 태그를 저장한다.
            '        If B.Tag <> Nothing AndAlso B.Tag.ToString.ToUpper = Div.ToString.ToUpper Then '//해당 체크박스를 찾았으면 체크박스 상태로 저장을한다.
            '            Arinini.Write("STYLE", Tobj.Name & "visible", CType(B, Windows.Forms.CheckBox).Checked) 'A.Visible)
            '            Exit For
            '        End If
            '    End If
            'Next
        Next


        f.Label1.Text = String.Format("스타일을 저장합니다" + vbCrLf + "CheckBox")
        f.Show()
        Application.DoEvents()
        f.ProgressBar1.Style = ProgressBarStyle.Marquee

        For Each TC As TabPage In Me.TabControl1.TabPages  '//탭컨트롤1의 모든 페이지에서 체크박스의 상태를 저장한다.
            For Each B As Control In TC.Controls
                If B.GetType.Name.ToUpper = "CHECKBOX" Then '//체크박스라면 태그를 저장한다.
                    Arinini.Write("STYLE", B.Name, CType(B, Windows.Forms.CheckBox).Checked) 'A.Visible)
                End If
            Next
        Next

        'For Each B As Control In Me.TabPage1.Controls
        '    If B.GetType.Name.ToUpper = "CHECKBOX" Then '//체크박스라면 태그를 저장한다.
        '        Arinini.Write("STYLE", B.Name, CType(B, Windows.Forms.CheckBox).Checked) 'A.Visible)
        '    End If
        'Next
        'For Each B As Control In Me.TabPage3.Controls
        '    If B.GetType.Name.ToUpper = "CHECKBOX" Then '//체크박스라면 태그를 저장한다.
        '        Arinini.Write("STYLE", B.Name, CType(B, Windows.Forms.CheckBox).Checked) 'A.Visible)
        '    End If
        'Next

        'Arinini.Write("STYLE", "CanvasX", Me.PictureBox1.Width)  '//Save Canvas Size
        'Arinini.Write("STYLE", "CanvasY", Me.PictureBox1.Height)

        f.Label1.Text = String.Format("스타일을 저장합니다" + vbCrLf + "일반정보")
        f.Show()
        Application.DoEvents()

        Arinini.Write("STYLE", "ViewImage", Me.CheckBox4.Checked)

        If Not IsNumeric(tb_marginx.Text) Then
            MsgBox("인쇄여백(가로) 값을 숫자로 입력하세요." + vbCrLf + "현재입력값:" + tb_marginx.Text, MsgBoxStyle.Information, "확인")
        Else
            Arininic.Write("printer", "MarginX", Me.tb_marginx.Text)
        End If

        If Not IsNumeric(tb_marginy.Text) Then
            MsgBox("인쇄여백(세로) 값을 숫자로 입력하세요." + vbCrLf + "현재입력값:" + tb_marginy.Text, MsgBoxStyle.Information, "확인")
        Else
            Arininic.Write("printer", "MarginY", Me.tb_marginy.Text)
        End If

        If Not IsNumeric(tb_scalex.Text) Then
            MsgBox("확대비율(가로) 값을 숫자로 입력하세요." + vbCrLf + "현재입력값:" + tb_scalex.Text, MsgBoxStyle.Information, "확인")
        Else
            Arininic.Write("printer", "ScaleX", Me.tb_scalex.Text)
        End If

        If Not IsNumeric(tb_scaley.Text) Then
            MsgBox("확대비율(세로) 값을 숫자로 입력하세요." + vbCrLf + "현재입력값:" + tb_scaley.Text, MsgBoxStyle.Information, "확인")
        Else
            Arininic.Write("printer", "ScaleY", Me.tb_scaley.Text)
        End If

        If Me.tb_picfile.Text.Trim = "" Then
            Arinini.Write("STYLE", "backimg", "")
        Else
            Dim newpath As String = CStr(My.Application.Info.DirectoryPath & "\image\").ToUpper
            Dim NEwpathp As Short = (Me.tb_picfile.Text.ToUpper.IndexOf(newpath))
            If NEwpathp = -1 Then
                Arinini.Write("STYLE", "backimg", Me.tb_picfile.Text)
            Else
                Arinini.Write("STYLE", "backimg", Me.tb_picfile.Text.Substring(NEwpathp + newpath.Length))
            End If
        End If


        Arininic.Write("printer", "PrintFontOffset", Me.tb_myfontsize.Text)
        Arinini.Write("STYLE", "LandScape", Me.pDoc.DefaultPageSettings.Landscape)

        '//더미 체크박스랑 더미콤보박스 인덱스랑 변위 x,y
        Arinini.Write("STYLE", "dummy", Me.cb_dummy.Checked)
        Arinini.Write("STYLE", "dummytype", Me.cmb_dummy.SelectedIndex)
        Arinini.Write("STYLE", "dummmyx", Me.tb_secX.Text)
        Arinini.Write("STYLE", "dummmyy", Me.tb_secY.Text)
        ' Arinini.Write("STYLE", "picstyle", Me.ComboBox1.SelectedIndex)



        '//QR코드
        Arinini.Write("STYLE", "qrencoding", Me.cboEncoding.Text)
        Arinini.Write("STYLE", "qrlevel", Me.cboCorrectionLevel.Text)
        Arinini.Write("STYLE", "qrvison", Me.cboVersion.Text)
        Arinini.Write("STYLE", "qrfg", Me.lbQrFG.BackColor.ToArgb().ToString())
        Arinini.Write("STYLE", "qrbg", Me.lbQrBg.BackColor.ToArgb().ToString())

        '//QR홈페이지
        Arinini.Write("STYLE", "qrhome1", Me.home1.Text)
        Arinini.Write("STYLE", "qrhome2", Me.home2.Text)
        Arinini.Write("STYLE", "qrhome3", Me.home3.Text)
        Arinini.Write("STYLE", "qrhome4", Me.home4.Text)


        Arinini.Write("STYLE", "gojang", Me.gojang.Text)


        f.Label1.Text = String.Format("스타일을 저장합니다" + vbCrLf + "레이아웃")
        f.Show()
        Application.DoEvents()

        Me.SaveReadLayOut(False)

        f.Label1.Text = String.Format("스타일을 저장합니다" + vbCrLf + "그리기개체")
        f.Show()
        Application.DoEvents()

        Me.SaveDrawData(False)

        NOTICE("기본스타일을 저장했습니다", Me.lb_msg)
        WLog2(Auto_Log, "Request Update DataTable Infomation After Style Save ", "\순차로그.txt")

        f.Close()
        f.Dispose()
        Application.DoEvents()

        Me.데이터테이블갱신()
        Me.preview_window()
    End Sub

    Public Sub SAVE_PATTERNII(ByVal SRCSTR As String, ByVal MIDNAME As String, ByVal DIV As Char, Optional ByVal LOGFILENAME As String = "\패턴.TXT", Optional ByVal prompt As Boolean = True)   '패턴을 저장합니다. 패턴역시 위치/크기/장평등이 저장됩니다.
        Dim Arinini As New MyINI2(drstyle.file)
        Dim BUF() As Char = SRCSTR.ToCharArray
        Dim mb As String = PATTERN_ENC(SRCSTR)
        '선로명 패턴 저장
        Dim TOBJ As MyControlOLEDBv2.MyLabel
        Dim Pname As String = MIDNAME & mb.ToString

        If prompt Then
            If MsgBox("문자패턴을 저장하시겠습니까?", MsgBoxStyle.Information + MsgBoxStyle.OkCancel, "확인") <> MsgBoxResult.Ok Then
                NOTICE("문자패턴 저장이 취소되었습니다", Me.lb_msg)
                Return
            End If
        End If

        WLog2(Auto_Log, " save_pattern2 를 실행한다.", "\순차로그.txt")

        Select Case DIV.ToString.ToUpper
            Case "O"    '//선로명
                For i As Integer = 0 To Me.S비고1.GetUpperBound(0)
                    TOBJ = Me.S비고1(i)
                    WLog2(Auto_Log, MIDNAME & "패턴저장시 아이템=" & TOBJ.Name & "/" & TOBJ.Name.Substring(0, 1).ToUpper, LOGFILENAME)
                    Arinini.Write(Pname, "DESC", "저장된 문자패턴 " & MIDNAME)
                    WLog2(Auto_Log, "최종선택완료=" & Pname & "      " & TOBJ.Name & "/" & TOBJ.Name.Substring(0, 1).ToUpper, LOGFILENAME)
                    Arinini.Write(Pname, TOBJ.Name & "pos", TOBJ.Left & "," & TOBJ.Top & "," & TOBJ.Width & "," & TOBJ.Height)
                    Arinini.Write(Pname, TOBJ.Name & "font", TOBJ.MyFont.Name & "," & TOBJ.MyFont.Size & "," & TOBJ.MyFont.Underline & "," & TOBJ.MyFont.Bold & "," & TOBJ.MyFont.Italic & "," & TOBJ.장평 & "," & TOBJ.장높이)
                    Arinini.Write(Pname, TOBJ.Name & "visible", TOBJ.Visible)
                    Arinini.Write(Pname, TOBJ.Name & "space", TOBJ.공백)
                Next
            Case "P"    '//선로명
                For i As Integer = 0 To Me.S비고2.GetUpperBound(0)
                    TOBJ = Me.S비고2(i)
                    WLog2(Auto_Log, MIDNAME & "패턴저장시 아이템=" & TOBJ.Name & "/" & TOBJ.Name.Substring(0, 1).ToUpper, LOGFILENAME)
                    Arinini.Write(Pname, "DESC", "저장된 문자패턴 " & MIDNAME)
                    WLog2(Auto_Log, "최종선택완료=" & Pname & "      " & TOBJ.Name & "/" & TOBJ.Name.Substring(0, 1).ToUpper, LOGFILENAME)
                    Arinini.Write(Pname, TOBJ.Name & "pos", TOBJ.Left & "," & TOBJ.Top & "," & TOBJ.Width & "," & TOBJ.Height)
                    Arinini.Write(Pname, TOBJ.Name & "font", TOBJ.MyFont.Name & "," & TOBJ.MyFont.Size & "," & TOBJ.MyFont.Underline & "," & TOBJ.MyFont.Bold & "," & TOBJ.MyFont.Italic & "," & TOBJ.장평 & "," & TOBJ.장높이)
                    Arinini.Write(Pname, TOBJ.Name & "visible", TOBJ.Visible)
                    Arinini.Write(Pname, TOBJ.Name & "space", TOBJ.공백)
                Next
            Case "Q"    '//선로명
                For i As Integer = 0 To Me.S비고3.GetUpperBound(0)
                    TOBJ = Me.S비고3(i)
                    WLog2(Auto_Log, MIDNAME & "패턴저장시 아이템=" & TOBJ.Name & "/" & TOBJ.Name.Substring(0, 1).ToUpper, LOGFILENAME)
                    Arinini.Write(Pname, "DESC", "저장된 문자패턴 " & MIDNAME)
                    WLog2(Auto_Log, "최종선택완료=" & Pname & "      " & TOBJ.Name & "/" & TOBJ.Name.Substring(0, 1).ToUpper, LOGFILENAME)
                    Arinini.Write(Pname, TOBJ.Name & "pos", TOBJ.Left & "," & TOBJ.Top & "," & TOBJ.Width & "," & TOBJ.Height)
                    Arinini.Write(Pname, TOBJ.Name & "font", TOBJ.MyFont.Name & "," & TOBJ.MyFont.Size & "," & TOBJ.MyFont.Underline & "," & TOBJ.MyFont.Bold & "," & TOBJ.MyFont.Italic & "," & TOBJ.장평 & "," & TOBJ.장높이)
                    Arinini.Write(Pname, TOBJ.Name & "visible", TOBJ.Visible)
                    Arinini.Write(Pname, TOBJ.Name & "space", TOBJ.공백)
                Next
            Case "R"    '//선로명
                For i As Integer = 0 To Me.S비고4.GetUpperBound(0)
                    TOBJ = Me.S비고4(i)
                    WLog2(Auto_Log, MIDNAME & "패턴저장시 아이템=" & TOBJ.Name & "/" & TOBJ.Name.Substring(0, 1).ToUpper, LOGFILENAME)
                    Arinini.Write(Pname, "DESC", "저장된 문자패턴 " & MIDNAME)
                    WLog2(Auto_Log, "최종선택완료=" & Pname & "      " & TOBJ.Name & "/" & TOBJ.Name.Substring(0, 1).ToUpper, LOGFILENAME)
                    Arinini.Write(Pname, TOBJ.Name & "pos", TOBJ.Left & "," & TOBJ.Top & "," & TOBJ.Width & "," & TOBJ.Height)
                    Arinini.Write(Pname, TOBJ.Name & "font", TOBJ.MyFont.Name & "," & TOBJ.MyFont.Size & "," & TOBJ.MyFont.Underline & "," & TOBJ.MyFont.Bold & "," & TOBJ.MyFont.Italic & "," & TOBJ.장평 & "," & TOBJ.장높이)
                    Arinini.Write(Pname, TOBJ.Name & "visible", TOBJ.Visible)
                    Arinini.Write(Pname, TOBJ.Name & "space", TOBJ.공백)
                Next
            Case "L"    '//선로명
                For i As Integer = 0 To Me.S선로명.GetUpperBound(0)
                    TOBJ = Me.S선로명(i)
                    WLog2(Auto_Log, MIDNAME & "패턴저장시 아이템=" & TOBJ.Name & "/" & TOBJ.Name.Substring(0, 1).ToUpper, LOGFILENAME)
                    Arinini.Write(Pname, "DESC", "저장된 문자패턴 " & MIDNAME)
                    WLog2(Auto_Log, "최종선택완료=" & Pname & "      " & TOBJ.Name & "/" & TOBJ.Name.Substring(0, 1).ToUpper, LOGFILENAME)
                    Arinini.Write(Pname, TOBJ.Name & "pos", TOBJ.Left & "," & TOBJ.Top & "," & TOBJ.Width & "," & TOBJ.Height)
                    Arinini.Write(Pname, TOBJ.Name & "font", TOBJ.MyFont.Name & "," & TOBJ.MyFont.Size & "," & TOBJ.MyFont.Underline & "," & TOBJ.MyFont.Bold & "," & TOBJ.MyFont.Italic & "," & TOBJ.장평 & "," & TOBJ.장높이)
                    Arinini.Write(Pname, TOBJ.Name & "visible", TOBJ.Visible)
                    Arinini.Write(Pname, TOBJ.Name & "space", TOBJ.공백)
                Next
            Case "X"    '//전주번호
                For i As Integer = 0 To Me.S전주번호.GetUpperBound(0)
                    TOBJ = Me.S전주번호(i)
                    WLog2(Auto_Log, MIDNAME & "패턴저장시 아이템=" & TOBJ.Name & "/" & TOBJ.Name.Substring(0, 1).ToUpper, LOGFILENAME)
                    Arinini.Write(Pname, "DESC", "저장된 문자패턴 " & MIDNAME)
                    WLog2(Auto_Log, "최종선택완료=" & Pname & "      " & TOBJ.Name & "/" & TOBJ.Name.Substring(0, 1).ToUpper, LOGFILENAME)
                    Arinini.Write(Pname, TOBJ.Name & "pos", TOBJ.Left & "," & TOBJ.Top & "," & TOBJ.Width & "," & TOBJ.Height)
                    Arinini.Write(Pname, TOBJ.Name & "font", TOBJ.MyFont.Name & "," & TOBJ.MyFont.Size & "," & TOBJ.MyFont.Underline & "," & TOBJ.MyFont.Bold & "," & TOBJ.MyFont.Italic & "," & TOBJ.장평 & "," & TOBJ.장높이)
                    Arinini.Write(Pname, TOBJ.Name & "visible", TOBJ.Visible)
                    Arinini.Write(Pname, TOBJ.Name & "space", TOBJ.공백)
                Next
                Arinini.Write(Pname, "LineType", Me.tb_ntype.Text)
                Arinini.Write(Pname, "nseparate", Me.cmb_sep.SelectedIndex)
            Case Else
                MsgBox("Save_PatternII 에 정의되지않은 문자(" & DIV & ") 가 발생하였습니다", MsgBoxStyle.Critical, "확인")
        End Select

        WLog2(Auto_Log, "save_patter2 ㅔ서 데이터테이블 갱신을 ㅎ호출한다ㅣㅣ ", "\순차로그.txt")
        Me.데이터테이블갱신()
    End Sub
    Private Sub cmb_controls_SelectedIndexChanged(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles cmb_controls.SelectedIndexChanged
        '//개체가 선택되면 해당 개체의 내역을 보여준다.
        'Me.Timer1.Enabled = False
        WLog2(Auto_Log, "개체목록 콤보박스에서 특정 개체가 선택되었다 view property 호출", "\순차로그.txt")
        ViewProperty(AllLabels(Me.cmb_controls.SelectedIndex).ctl)
    End Sub
    Private Sub cb_visible_CheckedChanged(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles cb_visible.CheckedChanged
        WLog2(Auto_Log, "표시 체크박스 선택 ", "\순차로그.txt")
        For Each a As Control In SelCon
            a.Visible = Me.cb_visible.Checked
        Next
        WLog2(Auto_Log, "[표시] 체크박스 선택에서 pewview를 호출 ", "\순차로그.txt")
        Me.preview_window()
    End Sub
    Private Sub tb_foncol_DoubleClick(ByVal sender As Object, ByVal e As System.EventArgs) Handles tb_foncol.DoubleClick
        WLog2(Auto_Log, " 글씨색깔 변경 클릭됨", "\순차로그.txt")
        Dim A As New ColorDialog
        If A.ShowDialog() = Windows.Forms.DialogResult.OK Then
            For Each Onlyone As MyControlOLEDBv2.MyLabel In SelCon
                Onlyone.MyForeColor = A.Color
            Next
            Me.tb_foncol.BackColor = A.Color
        End If
        Me.preview_window()
    End Sub
    Private Sub cb_bold_CheckedChanged(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles cb_bold.CheckedChanged
        WLog2(Auto_Log, "글씨꿁게 선택됨 setfont 호출 ", "\순차로그.txt")
        SetFont()
    End Sub
    Private Sub UpdateFontSize(ByVal newsize As Integer, Optional ByVal Src As MyControlOLEDBv2.MyLabel = Nothing) '
        WLog2(Auto_Log, "updatefont :  ", "\순차로그.txt")
        Dim A As Font
        For Each Tobj As MyControlOLEDBv2.MyLabel In SelCon
            A = New Font(Tobj.MyFont.FontFamily, newsize, FontStyle.Regular, GraphicsUnit.Point)
            Tobj.MyFont = A
        Next
        Me.SetFont()
    End Sub
    Public Sub CtrSize(ByVal vertical As Boolean, ByVal offset As Short)
        If SelCon Is Nothing OrElse SelCon.Count < 1 Then Exit Sub

        For Each sender As MyControlOLEDBv2.MyLabel In SelCon
            If vertical Then    '//상하
                If My.Computer.Keyboard.CtrlKeyDown Then
                    If offset < 0 Then
                        sender.장높이 -= 10
                    Else
                        sender.장높이 += 10
                    End If
                Else
                    sender.장높이 += offset
                End If
            Else    '//좌우
                If My.Computer.Keyboard.CtrlKeyDown Then
                    If offset < 0 Then
                        sender.장평 -= 10
                    Else
                        sender.장평 += 10
                    End If
                Else
                    sender.장평 += offset
                End If
            End If
        Next

        Me.preview_window()
    End Sub
    Public Sub LOAD_STYLEC(ByVal StyleName As String, ByVal Div As String)
        '//기타스타일은 빈도가 적으니 파일에서 불러오기로한다.;;메모리는 싫타.
        Dim Arinini As New MyINI2(FileC)
        If Not IO.File.Exists(FileC) Then
            MsgBox("기타스타일설정 파일이 존재하지 않습니다\n\n관리자에 문의하세요", MsgBoxStyle.Critical, "오류")
            Return
        End If
        Dim pos(), font(), visible As String '//구전산번호를 구현해본다.
        Dim Tobj As MyControlOLEDBv2.MyLabel

        For i As Integer = 0 To Me.AllLabels.GetUpperBound(0)
            Tobj = Me.AllLabels(i).ctl
            Try
                If Div.ToUpper = "Z" Then '//모든아이템을 가져오고
                    pos = Arinini.Read(StyleName, Tobj.Name & "pos").Split(",")
                    font = Arinini.Read(StyleName, Tobj.Name & "font").Trim(Chr(0)).Split(",")
                    visible = Arinini.Read(StyleName, Tobj.Name & "visible")
                    '//상태를 읽어서 바로 적용한다.
                    Tobj.Location = New Point(pos(0), pos(1))
                    Tobj.Size = New Size(pos(2), pos(3))
                    Tobj.MyFont = New Font(font(0), font(1), IIf(font(3).ToUpper = "TRUE", FontStyle.Bold, FontStyle.Regular), GraphicsUnit.Point)
                    Tobj.장평 = font(5)
                    Tobj.장높이 = font(6)
                    Tobj.공백 = Arinini.Read(StyleName, Tobj.Name & "space", 0)
                    Tobj.Visible = CType(visible, Boolean)
                Else '이곳에 O가올것이다.
                    If Tobj.Name.ToUpper.Substring(0, 1) = Div Then
                        pos = Arinini.Read(StyleName, Tobj.Name & "pos").Split(",")
                        font = Arinini.Read(StyleName, Tobj.Name & "font").Trim(Chr(0)).Split(",")
                        visible = Arinini.Read(StyleName, Tobj.Name & "visible")
                        '//상태를 읽어서 바로 적용한다.
                        Tobj.Location = New Point(pos(0), pos(1))
                        Tobj.Size = New Size(pos(2), pos(3))
                        Tobj.MyFont = New Font(font(0), font(1), IIf(font(3).ToUpper = "TRUE", FontStyle.Bold, FontStyle.Regular), GraphicsUnit.Point)
                        Tobj.장평 = font(5)
                        Tobj.장높이 = font(6)
                        Tobj.공백 = Arinini.Read(StyleName, Tobj.Name & "space", 0)
                        Tobj.Visible = CType(visible, Boolean)
                    End If
                End If
            Catch ex As Exception
                WLog2(Auto_Log, "LOAD_STYLE_CUSTOM 오류:" & ex.Message.ToString, "LOAD_STYLEC")
            End Try
        Next
        NOTICE(StyleName & "기타스타일을 불러왔습니다.", Me.lb_msg)
        Me.preview_window()
    End Sub
    Public Sub SAVE_STYLEC(ByVal stylename As String, ByVal div As String) '//기타스타일 저장한다.
        Dim Arinini As New MyINI2(FileC)
        '//현재 선택된 스타일을 저장합니다.
        Arinini.Write(stylename, "DESC", stylename)
        Dim Tobj As MyControlOLEDBv2.MyLabel

        For i As Integer = 0 To Me.AllLabels.GetUpperBound(0)
            Tobj = Me.AllLabels(i).ctl
            Arinini.Write(stylename, Tobj.Name & "pos", Tobj.Left & "," & Tobj.Top & "," & Tobj.Width & "," & Tobj.Height)
            Arinini.Write(stylename, Tobj.Name & "font", Tobj.MyFont.Name & "," & Tobj.MyFont.Size & "," & Tobj.MyFont.Underline & "," & Tobj.MyFont.Bold & "," & Tobj.MyFont.Italic & "," & Tobj.장평 & "," & Tobj.장높이)
            Arinini.Write(stylename, Tobj.Name & "visible", Tobj.Visible)
            Arinini.Write(stylename, Tobj.Name & "space", Tobj.공백)
        Next
        NOTICE("기타스타일을 저장했습니다", Me.lb_msg)
    End Sub
    Private Sub Button30_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button30.Click
        Me.CtrSize(False, -5)
    End Sub
    Private Sub Button29_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button29.Click
        Me.CtrSize(False, 5)
    End Sub
    Private Sub Button32_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button32.Click
        Me.CtrSize(True, -5)
    End Sub
    Private Sub Button31_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button31.Click
        Me.CtrSize(True, 5)
    End Sub
    Private Sub Button7_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button7.Click
        Me.CtrPos(False, -5)
    End Sub
    Private Sub Button6_Click_1(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button6.Click
        Me.CtrPos(False, 5)
    End Sub
    Private Sub Button27_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button27.Click
        Me.CtrPos(True, -5)
    End Sub
    Private Sub Button26_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button26.Click
        Me.CtrPos(True, 5)
    End Sub
    Private Sub BindingNavigatorPositionItem_KeyUp(ByVal sender As Object, ByVal e As System.Windows.Forms.KeyEventArgs) Handles BindingNavigatorPositionItem.KeyUp
        '//현재위치에서 엔터켯을경우 데이터베이스 위치값을 변경한다.(position)
        If e.KeyCode = Keys.Enter Then
            If IsNumeric(Me.BindingNavigatorPositionItem.Text) Then Me.GeTviewData(Me.BindingNavigatorPositionItem.Text - 1, True)
        End If
    End Sub
    Private Sub showcnt(ByVal cnt1 As Integer, ByVal cnt2 As Integer, Optional ByVal tag As String = "")
        Me.lb_msg.Text = cnt1 & "/" & cnt2 & Space(1) & tag
        My.Application.DoEvents()
    End Sub
    Private Sub NPartternCheck()
        Dim 번호패턴검사 As Integer = 0

        '//패턴검사시작
        ' Me.PictureBox1.Image = Image.FromFile(My.Application.Info.DirectoryPath & "\image\start.png")


        For i As Integer = Me.textbox1.Text To Me.textbox2.Text
            '  If chkFlag Then Exit For
            Me.showcnt(i, Me.textbox2.Text)

            Me.textbox1.Text = i
            번호패턴검사 = ChkNumPattern(i)
            '  MsgBox(번호패턴검사)

            If 번호패턴검사 = 0 Then    '1은 길이패턴이 없고 3이나 2는 문자패턴이다
                NOTICE("일련번호=" & i + 1 & "번 문자,길이 패턴이 존재하지 않습니다", Me.lb_msg)
                My.Computer.Audio.Play(My.Application.Info.DirectoryPath & "\sound\ding.wav", AudioPlayMode.Background)
                'If MsgBox("Sdf", MsgBoxStyle.OkCancel) = MsgBoxResult.Ok Then
                Me.BindingSource1.Position = i
                Exit For
            End If
        Next
        If Me.textbox1.Text = Me.textbox2.Text Then  '//완료되었다면
            My.Computer.Audio.Play(My.Application.Info.DirectoryPath & "\sound\notify.wav", AudioPlayMode.Background)
            NOTICE("패턴검사가 완료되었습니다", Me.lb_msg)
        End If
        Me.bt_chkpattern.Text = "시작(&S)"
    End Sub
    Private Sub tb_printrange_TextChanged(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles tb_printrange.TextChanged
        If Me.rad_repeat.Checked = False Then Me.RadioButton3.Checked = True
    End Sub

    Private Sub 번호형식지정(Optional ByVal msg As String = "99,99")
        'MsgBox("번호형식지정 : " & 번호, MsgBoxStyle.Information, msg)
        '//지정된 번호형식으로 전부번호를 표시한다.
        '//20070826 번호는 분리/통합으로 구분해서 출력한다.
        Dim A() As Char = 번호.ToCharArray

        Dim P() As String
        If msg.IndexOf(",") = -1 Then '//구버젼 140702
            Dim pp As New List(Of String)
            For Each cc As Char In msg.ToCharArray
                pp.Add(cc)
            Next
            P = pp.ToArray()
        Else
            P = msg.Split(",")
        End If

        Me.CLEAR_ITEM("X")

        Me.cmb_sep.SelectedIndex = 2 '//모두 통합으로 변경

        Dim NextCtl As MyControlOLEDBv2.MyLabel = Me.S선로명(0)
        Dim CurPos As Short = 0    '//몇번째 컨트롤까지 썻다는 표시
        Dim CPos As Short = -1       '//전체문자중 몇번째까지 했다는 표시
        Select Case Me.cmb_sep.SelectedIndex
            Case 2  '//통합
                Me.tb_ntype.Enabled = True
                For i As Integer = 0 To A.GetUpperBound(0)    '//모든 문자열을 집어넣는다 길이가 모자라면 중간에 없어진다.
                    If i <= CInt(P(0).ToString) - 1 Then
                        Me.S전주번호(0).MyText &= IIf(A(i) <> ";", A(i), "")
                    ElseIf i <= (CInt(P(0).ToString) + CInt(P(1).ToString) - 1) Then
                        Me.S전주번호(1).MyText &= IIf(A(i) <> ";", A(i), "")
                    End If
                Next
        End Select

        For i As Integer = 0 To Me.S전주번호.GetUpperBound(0)
            Me.S전주번호(i).Visible = IIf(Me.S전주번호(i).MyText = "", False, True)
        Next
    End Sub

    Public Function PARSE_관리전산번호(ByVal srcstr As String) As Boolean
        '/선로명의 길이는 예측되지 않는다 동적 컨트롤 생성을 사용한다.
        Me.CLEAR_ITEM("H")
0:      Dim Log As String = "\Parse_관리구전산번호.txt"
        If srcstr = "" OrElse Not Me.cb_kwnaligu.Checked Then
            WLog2(Auto_Log, "Zero Length - Return", Log)
            Return False
        End If

        Dim Wlen As Short = srcstr.Length
        Dim SepPos As Short = srcstr.IndexOf(";")
        WLog2(Auto_Log, "Length=" & Wlen & "   Sep=" & SepPos, Log)
        Me.S관리구전산번호.MyText = srcstr
        Me.S관리구전산번호.Visible = True
        Return True
    End Function

    Private Sub PARSE_관리전산번호패턴(ByVal SRCSTR As String)
        '//관리구5번 알파벳 지정이되어있는지 확인한다.
        Dim Log As String = "\Parse_관리구전산번호(수용).txt"
        Dim PNAME As String = ""
        Dim DR() As DataRow
        Dim CTLPOS() As String
        Dim CTLFONT() As String
        Dim CTLVISIBLE As Boolean

        If 관리구.Length < 5 Then Return '//160830

        PNAME = "CNUMPATTERNI" & 관리구.Substring(4, 1) ' Me.h5.MyText '//5번이 W 일때는 cnumpatternIw 를 찾게된다.
        DR = DtPattern.Select("NAME = '" & PNAME & "DESC'")

        If DR.GetUpperBound(0) = 0 Then '//있다.
            WLog2(Auto_Log, "관리구5번 문자를 찾았습니다 (" & PNAME & "DESC" & ")", Log)
            DR = DtPattern.Select("NAME = '" & PNAME & S관리구전산번호.Name & "POS'")
            If DR.GetUpperBound(0) = 0 Then
                CTLPOS = DR(0)(1).ToString.Split(",")
                Me.S관리구전산번호.Location = New Point(CTLPOS(0), CTLPOS(1))
                Me.S관리구전산번호.Size = New Size(CTLPOS(2), CTLPOS(3))
            End If

            DR = DtPattern.Select("NAME = '" & PNAME & S관리구전산번호.Name & "FONT'")
            If DR.GetUpperBound(0) = 0 Then
                CTLFONT = DR(0)(1).ToString.Split(",")
                S관리구전산번호.MyFont = New Font(CTLFONT(0), CTLFONT(1), IIf(CTLFONT(3).ToUpper = "TRUE", FontStyle.Bold, FontStyle.Regular), GraphicsUnit.Point)
                S관리구전산번호.장평 = CTLFONT(5)
                S관리구전산번호.장높이 = CTLFONT(6)
            End If
            DR = DtPattern.Select("NAME = '" & PNAME & S관리구전산번호.Name & "VISIBLE'")
            If DR.GetUpperBound(0) = 0 Then
                CTLVISIBLE = DR(0)(1).ToString
                S관리구전산번호.Visible = CType(CTLVISIBLE, Boolean)
            End If
            DR = DtPattern.Select("NAME = '" & PNAME & S관리구전산번호.Name & "SPACE'")
            If DR.GetUpperBound(0) = 0 Then
                S관리구전산번호.공백 = DR(0)(1)
            End If
        Else
            WLog2(Auto_Log, "관리구5번 문자가 지정되어있지않습니다. (" & S관리구전산번호.MyText & ")", Log)
        End If
    End Sub

    Public Sub PARSE_선로명패턴(ByVal Srcstr As String)
        Dim Log As String = "\PATTERN_선로명.txt"
        Dim Wlen As Short = Srcstr.Length : If Wlen <= 0 Then Return

        '길이패턴여부를 확인했으므로 패턴을적용한다.[STYLE1LINEPATTERN9]
        'Me.길이패턴연습(Srcstr, CStr(Me.패턴명_선로 & Wlen), Log, "L", S선로명)
        Me.문자패턴연습(Srcstr, CStr(Me.패턴명_선로 & "II" & PATTERN_ENC(선로명)), Log, Me.S선로명)

    End Sub
    Public Function PARSE_선로명(ByVal srcstr As String) As Boolean
        Me.CLEAR_ITEM("L")
        '/선로명의 길이는 예측되지 않는다 동적 컨트롤 생성을 사용한다.
        Dim Log As String = "\Parse_선로명.txt"
        If srcstr = "" OrElse Not Me.cb_sunlo.Checked Then
            WLog2(Auto_Log, "Zero Length - Return", Log)
            Return False
        End If

        Dim Wlen As Short = srcstr.Length
        Dim SepPos As Short = srcstr.IndexOf(";")

        WLog2(Auto_Log, "Length=" & Wlen & "   Sep=" & SepPos, Log)

        S선로명(0).MyText = srcstr.Trim(";")
        S선로명(0).Visible = True
        Return True
    End Function
    Private Sub PARSE_일련번호(ByVal index As Short)
        If Me.cb_seq.Checked Then
            Me.S일련번호.MyText = GetSpread(Me.Dv, index, "번호") 'index + 1
            Me.S일련번호.Visible = True
        Else
            Me.S일련번호.Visible = False
        End If
    End Sub

    Public Function PARSE_번호(ByVal srcstr As String) As Boolean
        'Me.CLEAR_ITEM("X")
        Dim Log As String = "\Parse_번호.txt"
        If srcstr = "" OrElse Not Me.cb_jnum.Checked Then
            Me.CLEAR_ITEM("X")
            WLog2(Auto_Log, "Zero Length - Return", Log)
            Return False
        End If

        Dim Wlen As Short = srcstr.Length
        Dim SepPos As Short = srcstr.IndexOf(";")
        WLog2(Auto_Log, "Length=" & Wlen & "   Sep=" & SepPos, Log)
        Return True
    End Function
    Public Function PARSE_번호패턴(ByVal srcstr As String) As Integer
        Dim Wlen As Short = 번호.Length : If Wlen <= 0 Then Return False '//없는 글귀가 왓을때 턴해버린다.
        Dim SRC() As Char = 번호.ToCharArray
        Dim Log As String = "\번호패턴ETC.txt"
        Dim SepPos As Short = 번호.IndexOf(";")
        Dim retval As Integer = 0   ''0은 정상 1은 길이패턴없음 2는 3은 길이+문자없음


        '//번호는 길이패턴을 하지않고 문자패턴만 한다.
        Dim Arinini As New MyINI2(drstyle.file)
        Dim CTLPOS() As String  '//위치정보
        Dim CTLFONT() As String
        Dim CTLVISIBLE As Boolean
        Dim TOBJ As MyControlOLEDBv2.MyLabel
        Dim Dr() As DataRow
        Dim 분리인덱스 As Short = 0
        Dim 번호형식 As String = "99,99"

        Dim Pname As String = CStr(Me.패턴명_번호 & "II" & PATTERN_ENC(srcstr))
        Dr = DtPattern.Select("NAME = '" & Pname & "DESC'")
        If Dr.GetUpperBound(0) = 0 Then '//데이터가 존재하므로 모두 적용을 한다.
            WLog2(Auto_Log, "번호패턴감지(문자) :  길이=" & Wlen & " 문자열=" & srcstr & " 패턴=" & Pname, Log)
            '//데이터는 최종적으로 번호형식에서 보낸다.
            분리인덱스 = Arinini.Read(Pname, "nseparate", 0)
            번호형식 = Arinini.Read(Pname, "LineType", "999")

            For i As Integer = 0 To Me.S전주번호.GetUpperBound(0)
                TOBJ = Me.S전주번호(i)
                TOBJ.Tag = ""   '//기존태그를 삭제한다.
                Try
                    '//상태를 읽어서 바로 적용한다.
                    Dr = DtPattern.Select("NAME = '" & Pname & TOBJ.Name & "POS'")
                    If Dr.GetUpperBound(0) = 0 Then
                        CTLPOS = Dr(0)(1).ToString.Split(",")
                        TOBJ.Location = New Point(CTLPOS(0), CTLPOS(1))
                        TOBJ.Size = New Size(CTLPOS(2), CTLPOS(3))
                    End If

                    Dr = DtPattern.Select("NAME = '" & Pname & TOBJ.Name & "FONT'")
                    If Dr.GetUpperBound(0) = 0 Then
                        CTLFONT = Dr(0)(1).ToString.Split(",")
                        TOBJ.MyFont = New Font(CTLFONT(0), CTLFONT(1), IIf(CTLFONT(3).ToUpper = "TRUE", FontStyle.Bold, FontStyle.Regular), GraphicsUnit.Point)
                        TOBJ.장평 = CTLFONT(5)
                        TOBJ.장높이 = CTLFONT(6)
                    End If

                    Dr = DtPattern.Select("NAME = '" & Pname & TOBJ.Name & "VISIBLE'")
                    If Dr.GetUpperBound(0) = 0 Then
                        CTLVISIBLE = Dr(0)(1).ToString
                        TOBJ.Visible = CType(CTLVISIBLE, Boolean)
                    End If

                    Dr = DtPattern.Select("NAME = '" & Pname & TOBJ.Name & "SPACE'")
                    If Dr.GetUpperBound(0) = 0 Then
                        TOBJ.공백 = Dr(0)(1).ToString
                    End If
                    TOBJ.Tag = "C"
                Catch ex As Exception
                    WLog2(Auto_Log, "문자패턴오류=" & ex.Message.ToString, Log)
                End Try
            Next
        Else
            WLog2(Auto_Log, "문자패턴불일치 길이=" & Wlen & " 문자열=" & srcstr & " 패턴=" & Pname, Log)
            'MsgBox("문자없다=" & Pname)
            retval += 2 '//패턴이 없으므로 바로 넘긴다.
        End If


        If retval = 2 Then  '//문자패턴이 없을경우에만 길이패턴을 확인한다.
            '//길이패턴 확인
            Pname = CStr(Me.패턴명_번호 & Wlen)
            Dr = DtPattern.Select("NAME = '" & Pname & "DESC'")
            If Dr.GetUpperBound(0) = 0 Then '//데이터가 존재하므로 모두 적용을 한다.
                WLog2(Auto_Log, "번호패턴감지(길이) :  길이=" & Wlen & " 문자열=" & srcstr, Log)
                '//데이터는 최종적으로 번호형식에서 보낸다.
                분리인덱스 = Arinini.Read(Pname, "nseparate", 0)
                번호형식 = Arinini.Read(Pname, "LineType", "999")

                For i As Integer = 0 To Me.S전주번호.GetUpperBound(0)
                    TOBJ = Me.S전주번호(i)
                    TOBJ.Tag = ""   '//기존태그를 삭제한다.
                    Try
                        '//상태를 읽어서 바로 적용한다.
                        Dr = DtPattern.Select("NAME = '" & Pname & TOBJ.Name & "POS'")
                        If Dr.GetUpperBound(0) = 0 Then
                            CTLPOS = Dr(0)(1).ToString.Split(",")
                            TOBJ.Location = New Point(CTLPOS(0), CTLPOS(1))
                            TOBJ.Size = New Size(CTLPOS(2), CTLPOS(3))
                        End If

                        Dr = DtPattern.Select("NAME = '" & Pname & TOBJ.Name & "FONT'")
                        If Dr.GetUpperBound(0) = 0 Then
                            CTLFONT = Dr(0)(1).ToString.Split(",")
                            TOBJ.MyFont = New Font(CTLFONT(0), CTLFONT(1), IIf(CTLFONT(3).ToUpper = "TRUE", FontStyle.Bold, FontStyle.Regular), GraphicsUnit.Point)
                            TOBJ.장평 = CTLFONT(5)
                            TOBJ.장높이 = CTLFONT(6)
                        End If

                        Dr = DtPattern.Select("NAME = '" & Pname & TOBJ.Name & "VISIBLE'")
                        If Dr.GetUpperBound(0) = 0 Then
                            CTLVISIBLE = Dr(0)(1).ToString
                            TOBJ.Visible = CType(CTLVISIBLE, Boolean)
                        End If

                        Dr = DtPattern.Select("NAME = '" & Pname & TOBJ.Name & "SPACE'")
                        If Dr.GetUpperBound(0) = 0 Then
                            TOBJ.공백 = Dr(0)(1).ToString
                        End If
                        TOBJ.Tag &= "L"
                    Catch ex As Exception
                        WLog2(Auto_Log, "길이 패턴오류=" & ex.Message.ToString, Log)
                    End Try
                Next
            Else
                WLog2(Auto_Log, "길이패턴불일치 기본스타일 복원  길이=" & Wlen & " 문자열=" & srcstr, Log)
                retval += 1 '//없다
            End If
        End If

        Me.cmb_sep.SelectedIndex = 분리인덱스

        If 번호형식 = "99,99" Then    '//패턴이없었다는 말이다 번호형식을 어느정도 맞춰준다.
            'MsgBox("번호형식이 없어서 셋팅합니다(" & 번호 & "/" & 번호.Length)
            If 번호.Length <= 10 Then
                번호형식 = "10,0"
            Else    '//12자리이상이므로 어덯게 쪼개야할지 3으로나눠서 ..int 대입을 하자
                번호형식 = "10," & srcstr.Length - 10
            End If
        End If
        Me.tb_ntype.Text = 번호형식

        번호형식지정(Me.tb_ntype.Text)  '//번호형식을 갱신해준다.
        Return retval '// 0이 리턴될것이다. 패턴이 모두 정상이란 뜻이다
    End Function
    Public Function PARSE_고장신고(ByVal srcstr As String) As Boolean
        Me.CLEAR_ITEM("Z")
        Dim Log As String = "\Parse_고장신고.txt"
        If srcstr = "" OrElse Not Me.cb_gojang.Checked Then
            WLog2(Auto_Log, "Zero Length - Return", Log)
            Return False
        End If
        Dim Wlen As Short = srcstr.Length
        Dim SepPos As Short = srcstr.IndexOf(";")
        WLog2(Auto_Log, "Length=" & Wlen & "   Sep=" & SepPos, Log)

        Me.S고장신고(0).MyText = srcstr
        Me.S고장신고(0).Visible = True
        Return True
    End Function
    Public Sub PARSE_고장신고패턴(ByVal SRCSTR As String)   '//비고패턴은 1234 가 존재한다.
        ''//비고 패턴은 몇줄 에 각 비고별로 존재한다.
        Dim Wlen As Short = 고장신고.Length : If Wlen <= 0 Then Return '//없는 글귀가 왓을때 턴해버린다.
        Dim Log As String = "\PATTERN_고장신고.txt"
        Dim SepPos As Short = 고장신고.IndexOf(";")
        Dim retval As Integer = 0   ''0은 정상 1은 길이패턴없음 2는 3은 길이+문자없음

        'Me.길이패턴연습(SRCSTR, "LNUM" & BlineNum & CStr(Me.패턴명_비고1 & Wlen), Log, "O", S비고1)
        Me.문자패턴연습(SRCSTR, "LNUM" & BlineNum & CStr(Me.패턴명_고장신고 & "II" & PATTERN_ENC(SRCSTR)), Log, Me.S고장신고)
    End Sub

    Public Function PARSE_비고1(ByVal srcstr As String) As Boolean
        Me.CLEAR_ITEM("O")
        Dim Log As String = "\Parse_비고1.txt"
        If srcstr = "" OrElse Not Me.cb_bigo1.Checked Then
            WLog2(Auto_Log, "Zero Length - Return", Log)
            Return False
        End If
        Dim Wlen As Short = srcstr.Length
        Dim SepPos As Short = srcstr.IndexOf(";")
        WLog2(Auto_Log, "Length=" & Wlen & "   Sep=" & SepPos, Log)

        Me.S비고1(0).MyText = srcstr
        Me.S비고1(0).Visible = True
        Return True
    End Function
    Public Sub PARSE_비고1패턴(ByVal SRCSTR As String)   '//비고패턴은 1234 가 존재한다.
        ''//비고 패턴은 몇줄 에 각 비고별로 존재한다.
        Dim Wlen As Short = 비고1.Length : If Wlen <= 0 Then Return '//없는 글귀가 왓을때 턴해버린다.
        Dim Log As String = "\PATTERN_비고1.txt"
        Dim SepPos As Short = 비고1.IndexOf(";")
        Dim retval As Integer = 0   ''0은 정상 1은 길이패턴없음 2는 3은 길이+문자없음

        'Me.길이패턴연습(SRCSTR, "LNUM" & BlineNum & CStr(Me.패턴명_비고1 & Wlen), Log, "O", S비고1)
        Me.문자패턴연습(SRCSTR, "LNUM" & BlineNum & CStr(Me.패턴명_비고1 & "II" & PATTERN_ENC(SRCSTR)), Log, Me.S비고1)
    End Sub
    Public Function PARSE_비고2(ByVal srcstr As String) As Boolean
        Me.CLEAR_ITEM("P")
        Dim Log As String = "\Parse_비고2.txt"
        If srcstr = "" OrElse Not Me.cb_bigo1.Checked Then
            WLog2(Auto_Log, "Zero Length - Return", Log)
            Return False
        End If
        Dim Wlen As Short = srcstr.Length
        Dim SepPos As Short = srcstr.IndexOf(";")
        WLog2(Auto_Log, "Length=" & Wlen & "   Sep=" & SepPos, Log)

        Me.S비고2(0).MyText = srcstr
        Me.S비고2(0).Visible = True
        Return True
    End Function
    Public Sub PARSE_비고2패턴(ByVal SRCSTR As String)   '//비고패턴은 1234 가 존재한다.
        ''//비고 패턴은 몇줄 에 각 비고별로 존재한다.
        Dim Wlen As Short = 비고2.Length : If Wlen <= 0 Then Return '//없는 글귀가 왓을때 턴해버린다.
        Dim Log As String = "\PATTERN_비고2.txt"
        Dim SepPos As Short = 비고2.IndexOf(";")
        Dim retval As Integer = 0   ''0은 정상 1은 길이패턴없음 2는 3은 길이+문자없음

        'Me.길이패턴연습(SRCSTR, "LNUM" & BlineNum & CStr(Me.패턴명_비고2 & Wlen), Log, "P", S비고2)
        Me.문자패턴연습(SRCSTR, "LNUM" & BlineNum & CStr(Me.패턴명_비고2 & "II" & PATTERN_ENC(SRCSTR)), Log, Me.S비고2)
    End Sub
    Public Function PARSE_비고3(ByVal srcstr As String) As Boolean
        Me.CLEAR_ITEM("Q")
        Dim Log As String = "\Parse_비고3.txt"
        If srcstr = "" OrElse Not Me.cb_bigo1.Checked Then
            WLog2(Auto_Log, "Zero Length - Return", Log)
            Return False
        End If
        Dim Wlen As Short = srcstr.Length
        Dim SepPos As Short = srcstr.IndexOf(";")
        WLog2(Auto_Log, "Length=" & Wlen & "   Sep=" & SepPos, Log)
        Me.S비고3(0).MyText = srcstr
        Me.S비고3(0).Visible = True
        Return True
    End Function
    Public Sub PARSE_비고3패턴(ByVal SRCSTR As String)   '//비고패턴은 1234 가 존재한다.
        ''//비고 패턴은 몇줄 에 각 비고별로 존재한다.
        Dim Wlen As Short = 비고3.Length : If Wlen <= 0 Then Return '//없는 글귀가 왓을때 턴해버린다.
        Dim Log As String = "\PATTERN_비고3.txt"
        Dim SepPos As Short = 비고3.IndexOf(";")
        Dim retval As Integer = 0   ''0은 정상 1은 길이패턴없음 2는 3은 길이+문자없음

        'Me.길이패턴연습(SRCSTR, "LNUM" & BlineNum & CStr(Me.패턴명_비고3 & Wlen), Log, "Q", S비고3)
        Me.문자패턴연습(SRCSTR, "LNUM" & BlineNum & CStr(Me.패턴명_비고3 & "II" & PATTERN_ENC(SRCSTR)), Log, Me.S비고3)
    End Sub
    Public Function PARSE_비고4(ByVal srcstr As String) As Boolean
        Me.CLEAR_ITEM("R")
        Dim Log As String = "\Parse_비고1.txt"
        If srcstr = "" OrElse Not Me.cb_bigo1.Checked Then
            WLog2(Auto_Log, "Zero Length - Return", Log)
            Return False
        End If
        Dim Wlen As Short = srcstr.Length
        Dim SepPos As Short = srcstr.IndexOf(";")
        WLog2(Auto_Log, "Length=" & Wlen & "   Sep=" & SepPos, Log)
        Me.S비고4(0).MyText = srcstr
        Me.S비고4(0).Visible = True
        Return True
    End Function
    Public Sub PARSE_비고4패턴(ByVal SRCSTR As String)   '//비고패턴은 1234 가 존재한다.
        ''//비고 패턴은 몇줄 에 각 비고별로 존재한다.
        Dim Wlen As Short = 비고4.Length : If Wlen <= 0 Then Return '//없는 글귀가 왓을때 턴해버린다.
        Dim Log As String = "\PATTERN_비고4.txt"
        Dim SepPos As Short = 비고4.IndexOf(";")
        Dim retval As Integer = 0   ''0은 정상 1은 길이패턴없음 2는 3은 길이+문자없음

        'Me.길이패턴연습(SRCSTR, "LNUM" & BlineNum & CStr(Me.패턴명_비고4 & Wlen), Log, "R", S비고4)
        Me.문자패턴연습(SRCSTR, "LNUM" & BlineNum & CStr(Me.패턴명_비고4 & "II" & PATTERN_ENC(SRCSTR)), Log, Me.S비고4)
    End Sub
    Private Sub SaveReadLayOut(ByVal read As Boolean)   '//현재 화면구성을 가로/세로 결정합니다.
        '//ini파일에저장한다. 섹션명은 pagetype0 ,pagetyp1  0은 세로 1은 가로다
        Dim ini As New MyINI2(drstyle.file)
        Dim Secname As String = "pagetype" & Me.cmb_landscape.SelectedIndex

        If read = False Then
            ini.Write(Secname, "tablelayoutpanel1loc", Me.TableLayoutPanel1.Left & "," & Me.TableLayoutPanel1.Top)
            ini.Write(Secname, "tablelayoutpanel1size", Me.TableLayoutPanel1.Width & "," & Me.TableLayoutPanel1.Height)
            ini.Write(Secname, "PictureBox1loc", Me.PictureBox1.Left & "," & Me.PictureBox1.Top)
            ini.Write(Secname, "PictureBox1size", Me.PictureBox1.Width & "," & Me.PictureBox1.Height)
            ini.Write(Secname, "TabControl1loc", Me.TabControl1.Left & "," & Me.TabControl1.Top)
            ini.Write(Secname, "TabControl1size", Me.TabControl1.Width & "," & Me.TabControl1.Height)
            ini.Write(Secname, "GroupBox3loc", Me.GroupBox3.Left & "," & Me.GroupBox3.Top)
            ini.Write(Secname, "GroupBox3size", Me.GroupBox3.Width & "," & Me.GroupBox3.Height)
            ini.Write(Secname, "GroupBox2loc", Me.GroupBox2.Left & "," & Me.GroupBox2.Top)
            ini.Write(Secname, "GroupBox2size", Me.GroupBox2.Width & "," & Me.GroupBox2.Height)
            ini.Write(Secname, "cmb_styleloc", Me.cmb_style.Left & "," & Me.cmb_style.Top)
            ini.Write(Secname, "cmb_stylesize", Me.cmb_style.Width & "," & Me.cmb_style.Height)
            ini.Write(Secname, "ToolStrip2loc", Me.ToolStrip2.Left & "," & Me.ToolStrip2.Top)
            ini.Write(Secname, "mesize", Me.Width & "," & Me.Height)
        Else   '//여기는 읽는 부분
            If Me.cmb_landscape.SelectedIndex = 0 Then '//세로
                Me.pDoc.DefaultPageSettings.Landscape = False
                TableLayoutPanel1.Location = New Point(ini.Read(Secname, "tablelayoutpanel1loc", "0,31").Split(",")(0), ini.Read(Secname, "tablelayoutpanel1loc", "0,31").Split(",")(1))
                TableLayoutPanel1.Size = New Size(ini.Read(Secname, "tablelayoutpanel1size", "297,522").Split(",")(0), ini.Read(Secname, "tablelayoutpanel1size", "297,522").Split(",")(1))
                PictureBox1.Location = New Point(ini.Read(Secname, "PictureBox1loc", "3,3").Split(",")(0), ini.Read(Secname, "PictureBox1loc", "3,3").Split(",")(1))
                PictureBox1.Size = New Size(ini.Read(Secname, "PictureBox1size", "270,479").Split(",")(0), ini.Read(Secname, "PictureBox1size", "270,479").Split(",")(1))
                TabControl1.Location = New Point(ini.Read(Secname, "TabControl1loc", "303,34").Split(",")(0), ini.Read(Secname, "TabControl1loc", "303,34").Split(",")(1))
                TabControl1.Size = New Size(ini.Read(Secname, "TabControl1size", "279,519").Split(",")(0), ini.Read(Secname, "TabControl1size", "279,519").Split(",")(1))
                TabControl2.Location = New Point(ini.Read(Secname, "TabControl2loc", "16,246").Split(",")(0), ini.Read(Secname, "TabControl2loc", "16,246").Split(",")(1))
                GroupBox3.Location = New Point(ini.Read(Secname, "GroupBox3loc", "11,368").Split(",")(0), ini.Read(Secname, "GroupBox3loc", "11,368").Split(",")(1))
                GroupBox3.Size = New Size(ini.Read(Secname, "GroupBox3size", "246,78").Split(",")(0), ini.Read(Secname, "GroupBox3size", "246,78").Split(",")(1))
                GroupBox2.Location = New Point(ini.Read(Secname, "GroupBox2loc", "11,170").Split(",")(0), ini.Read(Secname, "GroupBox2loc", "11,170").Split(",")(1))
                GroupBox2.Size = New Size(ini.Read(Secname, "GroupBox2size", "245,192").Split(",")(0), ini.Read(Secname, "GroupBox2size", "245,192").Split(",")(1))
                cmb_style.Location = New Point(ini.Read(Secname, "cmb_styleloc", "11,18").Split(",")(0), ini.Read(Secname, "cmb_styleloc", "11,18").Split(",")(1))
                cmb_style.Size = New Size(ini.Read(Secname, "cmb_stylesize", "245,146").Split(",")(0), ini.Read(Secname, "cmb_stylesize", "245,146").Split(",")(1))
                ToolStrip2.Location = New Point(ini.Read(Secname, "ToolStrip2loc", "3,451").Split(",")(0), ini.Read(Secname, "ToolStrip2loc", "3,451").Split(",")(1))
                Me.Size = New Size(ini.Read(Secname, "mesize", "588,632").Split(",")(0), ini.Read(Secname, "mesize", "588,632").Split(",")(1))
            Else
                Me.pDoc.DefaultPageSettings.Landscape = True
                TableLayoutPanel1.Location = New Point(ini.Read(Secname, "tablelayoutpanel1loc", "0,31").Split(",")(0), ini.Read(Secname, "tablelayoutpanel1loc", "0,31").Split(",")(1))
                TableLayoutPanel1.Size = New Size(ini.Read(Secname, "tablelayoutpanel1size", "710,292").Split(",")(0), ini.Read(Secname, "tablelayoutpanel1size", "710,292").Split(",")(1))
                PictureBox1.Location = New Point(ini.Read(Secname, "PictureBox1loc", "325,3").Split(",")(0), ini.Read(Secname, "PictureBox1loc", "325,3").Split(",")(1))
                PictureBox1.Size = New Size(ini.Read(Secname, "PictureBox1size", "355,200").Split(",")(0), ini.Read(Secname, "PictureBox1size", "355,200").Split(",")(1))
                TabControl1.Location = New Point(ini.Read(Secname, "TabControl1loc", "3,326").Split(",")(0), ini.Read(Secname, "TabControl1loc", "3,326").Split(",")(1))
                TabControl1.Size = New Size(ini.Read(Secname, "TabControl1size", "711,228").Split(",")(0), ini.Read(Secname, "TabControl1size", "711,228").Split(",")(1))
                TabControl2.Location = New Point(ini.Read(Secname, "TabControl2loc", "265,1").Split(",")(0), ini.Read(Secname, "TabControl2loc", "265,1").Split(",")(1))
                GroupBox3.Location = New Point(ini.Read(Secname, "GroupBox3loc", "513,6").Split(",")(0), ini.Read(Secname, "GroupBox3loc", "513,6").Split(",")(1))
                GroupBox3.Size = New Size(ini.Read(Secname, "GroupBox3size", "184,78").Split(",")(0), ini.Read(Secname, "GroupBox3size", "184,78").Split(",")(1))
                GroupBox2.Location = New Point(ini.Read(Secname, "GroupBox2loc", "262,6").Split(",")(0), ini.Read(Secname, "GroupBox2loc", "262,6").Split(",")(1))
                GroupBox2.Size = New Size(ini.Read(Secname, "GroupBox2size", "245,192").Split(",")(0), ini.Read(Secname, "GroupBox2size", "245,192").Split(",")(1))
                cmb_style.Location = New Point(ini.Read(Secname, "cmb_styleloc", "11,18").Split(",")(0), ini.Read(Secname, "cmb_styleloc", "11,18").Split(",")(1))
                cmb_style.Size = New Size(ini.Read(Secname, "cmb_stylesize", "245,139").Split(",")(0), ini.Read(Secname, "cmb_stylesize", "245,139").Split(",")(1))
                ToolStrip2.Location = New Point(ini.Read(Secname, "ToolStrip2loc", "3,159").Split(",")(0), ini.Read(Secname, "ToolStrip2loc", "3,159").Split(",")(1))
                Me.Size = New Size(ini.Read(Secname, "mesize", "730,643").Split(",")(0), ini.Read(Secname, "mesize", "730,643").Split(",")(1))
            End If
        End If

    End Sub
    Private Sub bt_canvasD_MouseDown(ByVal sender As Object, ByVal e As System.Windows.Forms.MouseEventArgs) Handles bt_canvasD.MouseDown, bt_canvasL.MouseDown, bt_canvasR.MouseDown, bt_canvasU.MouseDown
        If e.Button = Windows.Forms.MouseButtons.Right Then
            Select Case sender.name.ToString.ToUpper
                Case "BT_CANVASD"
                    Me.PictureBox1.Top += 5
                Case "BT_CANVASU"
                    Me.PictureBox1.Top -= 5
                Case "BT_CANVASR"
                    Me.PictureBox1.Left += 5
                Case "BT_CANVASL"
                    Me.PictureBox1.Left -= 5
            End Select
        End If

    End Sub
    Private Sub cmb_landscape_SelectedIndexChanged(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles cmb_landscape.SelectedIndexChanged
        Me.SaveReadLayOut(True)
    End Sub

    Private Sub GetPrintersName()
        WLog2(Auto_Log, "GetPrinterName()", "\순차로그.txt")
        Dim value As PrinterSettings.StringCollection = System.Drawing.Printing.PrinterSettings.InstalledPrinters
        Me.combobox5.Items.Clear()
        For i As Integer = 0 To value.Count - 1
            Me.combobox5.Items.Add(value(i))
        Next
    End Sub

    Private Sub printform_MouseWheel(ByVal sender As Object, ByVal e As System.Windows.Forms.MouseEventArgs) Handles Me.MouseWheel
        If e.Delta < 0 Then
            'If Me.BindingNavigatorPositionItem.Text < Me.BindingNavigatorCountItem.Text Then
            Me.BindingNavigatorMoveNextItem.PerformClick()
            Me.BindingNavigatorPositionItem.Focus()
            'End If
        Else
            If Me.BindingNavigatorPositionItem.Text > 0 Then
                Me.BindingNavigatorMovePreviousItem.PerformClick()
                Me.BindingNavigatorPositionItem.Focus()
            End If
        End If
    End Sub
    Private Sub ToolStripButton4_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles bt_chkpattern.Click
        If Me.bt_chkpattern.Text = "중지(&S)" Then
            ' If BackWork.IsAlive Then BackWork.Abort()
            Me.bt_chkpattern.Text = "시작(&S)"
        Else
            Me.bt_chkpattern.Text = "중지(&S)"
            'BackWork = New Threading.Thread(AddressOf NPartternCheck)
            'BackWork.Start()
            NPartternCheck()
        End If
    End Sub

    Private Sub Button3_Click_1(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button3.Click
        'Me.SetFont()
        If Not IsNumeric(Me.tb_space.Text) Then
            MsgBox("숫자만 입력하세요", MsgBoxStyle.Critical, "확인")
            Return
        End If
        For Each A As Control In SelCon
            CType(A, MyControlOLEDBv2.MyLabel).공백 = CInt(Me.tb_space.Text)
            'Me.UpdateFontSize(Me.tb_space.Text, A)
        Next
        Me.preview_window()
    End Sub

    Private Sub tb_picfile_TextChanged(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles tb_picfile.TextChanged
        If Not IO.File.Exists(Me.tb_picfile.Text) Then
            Me.erp.SetError(Me.tb_picfile, "그림파일이 존재하지 않습니다")
        Else
            Me.erp.SetError(Me.tb_picfile, "")
        End If
    End Sub

    Private Sub bt_canvasL_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles bt_canvasL.Click
        Me.PictureBox1.Width -= 2
    End Sub

    Private Sub bt_canvasR_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles bt_canvasR.Click
        Me.PictureBox1.Width += 2
    End Sub

    Private Sub bt_canvasU_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles bt_canvasU.Click
        Me.PictureBox1.Height -= 2
    End Sub

    Private Sub bt_canvasD_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles bt_canvasD.Click
        Me.PictureBox1.Height += 2
    End Sub

    Private Sub tb_space_KeyUp(ByVal sender As Object, ByVal e As System.Windows.Forms.KeyEventArgs)
        If e.KeyCode = Keys.Enter Then Me.Button3.PerformClick()
    End Sub




    Private Sub preview_window()    '//미리보기화면을 생성합니다.

        'Dim fmt As New StringFormat(StringFormatFlags.LineLimit)
        Dim MyFont As Font
        Dim NewFontSize As Int16 = 10
        Dim dummy As Boolean = False    '//이값이 true 이면 출력시 변위를 지정해서 출력한다.
        Dim BackScr As New Bitmap(Me.PictureBox1.Width, Me.PictureBox1.Height, Me.PictureBox1.CreateGraphics)
        Dim Ga As Graphics = Graphics.FromImage(BackScr)
        Dim Brush As SolidBrush
        Dim obj As MyControlOLEDBv2.MyLabel


        '페이지 구분을 이해하고 몇개를 찍을지 결정한다.
        'Debug.Print("프린터인덱스=" & Me.printindex)
        'Debug.Print("프린터배열=" & Me.PrintArray.GetUpperBound(0))

        ' If Me.printindex <> -1 Then Me.GeTviewData(Me.PrintArray(Me.printindex)) '//페이지를 갱신하고 출력을 시작한다.
        'Dummyflag:  '//--2장출력일경우 이부분에서 다시 시작한다.

        'If Not Me.PictureBox1.BackgroundImage Is Nothing Then
        ' Ga.DrawImage(Me.PictureBox1.BackgroundImage, 0, 0, Me.PictureBox1.Width, Me.PictureBox1.Height)
        ' End If

        'MsgBox("orevuew")

        For i As Integer = 0 To Me.AllLabels.GetUpperBound(0)   '//모든 개체들에 대해서 인쇄를 설정한다.
            obj = Me.AllLabels(i).ctl
            If obj.Visible AndAlso obj.MyText <> "" Then   '//화면에 보이는것만 한다.                
                NewFontSize = obj.MyFont.Size + Me.tb_myfontsize.Text
                If NewFontSize < 0 Then NewFontSize = 0
                Brush = New SolidBrush(obj.MyForeColor) '//전경색으로 브러쉬를 만든다.

                MyFont = New Font(obj.MyFont.FontFamily, NewFontSize, obj.MyFont.Style)
                If obj.장평 = 100 AndAlso obj.장높이 = 100 Then '//장평미사용 문자열 처리
                    Ga.DrawString(obj.최종문자, MyFont, Brush, obj.Location)
                Else    '//장평사용 이미지 처리
                    Dim NewX, Newy As Integer
                    Dim SrcDpix, SrcDPiY As Single
                    'MsgBox(Tobj.장높이)
                    SrcDpix = obj.CreateGraphics.DpiX
                    SrcDPiY = obj.CreateGraphics.DpiY

                    NewX = obj.GetSize(MyFont).Width * (obj.장평 / 100) * (Ga.DpiX / SrcDpix)
                    Newy = obj.GetSize(MyFont).Height * (obj.장높이 / 100) * (Ga.DpiY / SrcDPiY)

                    Dim BMP As New Bitmap(NewX, Newy, Ga)
                    Dim G As Graphics = Graphics.FromImage(BMP)

                    G.ResetTransform()
                    G.ScaleTransform((obj.장평 / 100), (obj.장높이 / 100))
                    G.DrawString(obj.최종문자, MyFont, Brush, 0, 0)
                    G.Dispose()
                    Ga.DrawImage(BMP, New Point(obj.Left, obj.Top)) ', CInt(GetSize.Width * (v장평 / 100)), GetSize.Height)
                End If
            End If
        Next

        If Me.cb_dummy.Checked Then '//복사가 선택되어있으며 ㄴ한번더 출력한다.
            For i As Integer = 0 To Me.AllLabels.GetUpperBound(0)   '//모든 개체들에 대해서 인쇄를 설정한다.
                obj = Me.AllLabels(i).ctl
                If obj.Visible AndAlso obj.MyText <> "" Then   '//화면에 보이는것만 한다.                
                    NewFontSize = obj.MyFont.Size + Me.tb_myfontsize.Text
                    If NewFontSize < 0 Then NewFontSize = 0
                    Brush = New SolidBrush(obj.MyForeColor) '//전경색으로 브러쉬를 만든다.

                    MyFont = New Font(obj.MyFont.FontFamily, NewFontSize, obj.MyFont.Style)
                    If obj.장평 = 100 AndAlso obj.장높이 = 100 Then '//장평미사용 문자열 처리
                        Ga.DrawString(obj.최종문자, MyFont, Brushes.Gray, (obj.Left + Me.tb_secX.Text), (obj.Top + Me.tb_secY.Text))
                    Else    '//장평사용 이미지 처리
                        Dim NewX, Newy As Integer
                        Dim SrcDpix, SrcDPiY As Single
                        'MsgBox(Tobj.장높이)
                        SrcDpix = obj.CreateGraphics.DpiX
                        SrcDPiY = obj.CreateGraphics.DpiY

                        NewX = obj.GetSize(MyFont).Width * (obj.장평 / 100) * (Ga.DpiX / SrcDpix)
                        Newy = obj.GetSize(MyFont).Height * (obj.장높이 / 100) * (Ga.DpiY / SrcDPiY)
                        Dim BMP As New Bitmap(NewX, Newy, Ga)
                        Dim G As Graphics = Graphics.FromImage(BMP)

                        G.ResetTransform()
                        G.ScaleTransform((obj.장평 / 100), (obj.장높이 / 100))
                        G.DrawString(obj.최종문자, MyFont, Brushes.Gray, 0, 0)
                        G.Dispose()
                        Ga.DrawImage(BMP, CSng(obj.Left + Me.tb_secX.Text), CSng(obj.Top + Me.tb_secY.Text)) ', CInt(GetSize.Width * (v장평 / 100)), GetSize.Height)
                    End If
                End If
            Next
        End If




        '//쉐이프를 먼저 그린다.
        If Me.chk_draw.Checked Then
            '//라인을 그린다.
            For Each Rect As S_Line In Draw_Line
                Dim Pen As New Drawing.Pen(Rect.PenColor, Rect.PenWidth)
                Ga.DrawLine(Pen, Rect.X, Rect.Y, Rect.X2, Rect.Y2)
            Next
            '//박스를 그린다.
            For Each Rect As S_Box In Draw_Box
                Dim Pen As New Drawing.Pen(Rect.PenColor, Rect.PenWidth)
                Ga.DrawRectangle(Pen, Rect.X, Rect.Y, Rect.Width, Rect.Height)
            Next
            '//원을 그린다
            For Each Rect As S_Circle In Draw_Circle
                Dim Pen As New Drawing.Pen(Rect.PenColor, Rect.PenWidth)
                Ga.DrawEllipse(Pen, Rect.X, Rect.Y, Rect.Width, Rect.Height)
            Next

            If 관리구 <> "" Then
                Try
                    '// qr코드를 그린다
                    For Each Rect As S_QRCode In Draw_QRcode
                        'Dim scale As Int16
                        Dim version As Int16
                        Dim image As Image
                        Dim data As String
                        Dim errorCorrect As String
                        Dim qrCodeEncoder1 As New QRCodeEncoder()
                        Dim encoding As String
                        encoding = cboEncoding.Text
                        If encoding = "3" Then
                            qrCodeEncoder1.QRCodeEncodeMode = ThoughtWorks.QRCode.Codec.QRCodeEncoder.ENCODE_MODE.BYTE
                        ElseIf encoding = "1" Then
                            qrCodeEncoder1.QRCodeEncodeMode = ThoughtWorks.QRCode.Codec.QRCodeEncoder.ENCODE_MODE.ALPHA_NUMERIC
                        ElseIf encoding = "2" Then
                            qrCodeEncoder1.QRCodeEncodeMode = ThoughtWorks.QRCode.Codec.QRCodeEncoder.ENCODE_MODE.NUMERIC
                            '     Try
                            'scale = Convert.ToInt16(txtSize.Text)
                            'qrCodeEncoder.QRCodeScale = scale
                            'Catch ex As Exception
                            ' MessageBox.Show("Invalid size!")
                            ' End Try
                            Try
                                version = Convert.ToInt16(cboVersion.Text)
                                qrCodeEncoder1.QRCodeVersion = version
                            Catch ex As Exception
                                MessageBox.Show("Invaild Version!")
                            End Try
                        End If

                        errorCorrect = cboCorrectionLevel.Text
                        If errorCorrect = "1" Then
                            qrCodeEncoder1.QRCodeErrorCorrect = ThoughtWorks.QRCode.Codec.QRCodeEncoder.ERROR_CORRECTION.L
                        ElseIf errorCorrect = "2" Then
                            qrCodeEncoder1.QRCodeErrorCorrect = ThoughtWorks.QRCode.Codec.QRCodeEncoder.ERROR_CORRECTION.M
                        ElseIf errorCorrect = "3" Then
                            qrCodeEncoder1.QRCodeErrorCorrect = ThoughtWorks.QRCode.Codec.QRCodeEncoder.ERROR_CORRECTION.Q
                        ElseIf errorCorrect = "4" Then
                            qrCodeEncoder1.QRCodeErrorCorrect = ThoughtWorks.QRCode.Codec.QRCodeEncoder.ERROR_CORRECTION.H
                        End If

                        data = qr홈페이지1 & "/" & qr홈페이지2 & "/" & qr홈페이지3 & "/" & qr홈페이지4 & "=" & 관리구 & "-" & 전산번호 & "&name=" & 선로명 & ":" & 번호

                        If lbQrBg.BackColor <> Drawing.Color.White Then qrCodeEncoder1.QRCodeBackgroundColor = lbQrBg.BackColor
                        If lbQrFG.BackColor <> Drawing.Color.Black Then qrCodeEncoder1.QRCodeForegroundColor = lbQrFG.BackColor
                        image = qrCodeEncoder1.Encode(data, Ga.DpiX, Ga.DpiY)
                        If Rect.Width = 0 OrElse Rect.Height = 0 Then
                            'Ga.DrawImage(image, Rect.X + MyProperty_Paper.출력여백X, Rect.Y + MyProperty_Paper.출력여백Y)
                            Ga.DrawImage(image, Rect.X, Rect.Y)
                        Else
                            'Ga.DrawImage(image, Rect.X + MyProperty_Paper.출력여백X, Rect.Y + MyProperty_Paper.출력여백Y, Rect.Width, Rect.Height)
                            Ga.DrawImage(image, Rect.X, Rect.Y, Rect.Width, Rect.Height)
                        End If
                    Next
                Catch ex As Exception
                    MessageBox.Show(ex.ToString())
                End Try
            End If
        End If



        Ga.Dispose()
        Me.PictureBox1.Image = BackScr
    End Sub

    Private Sub cb_bold_CheckedChanged_1(ByVal sender As System.Object, ByVal e As System.EventArgs)
        SetFont()
    End Sub


    Private Sub Button1_Click_2(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
        If SelCon Is Nothing Then Return

        Dim B As New FontDialog
        B.Font = CType(SelCon(0), MyControlOLEDBv2.MyLabel).MyFont
        If B.ShowDialog() <> Windows.Forms.DialogResult.OK Then Return

        For Each a As MyControlOLEDBv2.MyLabel In SelCon
            a.MyFont = B.Font
        Next
        Me.ViewProperty(CType(SelCon(0), MyControlOLEDBv2.MyLabel))
        Me.preview_window()
    End Sub

    Private Sub TextBox3_KeyUp(ByVal sender As Object, ByVal e As System.Windows.Forms.KeyEventArgs) Handles tb_left.KeyUp
        If e.KeyCode = Keys.Enter Then Me.Button5.PerformClick()
    End Sub



    Private Sub TextBox4_KeyUp(ByVal sender As Object, ByVal e As System.Windows.Forms.KeyEventArgs) Handles tb_top.KeyUp
        If e.KeyCode = Keys.Enter Then Me.Button9.PerformClick()
    End Sub



    Private Sub Button9_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button9.Click

        For Each A As Control In SelCon
            A.Top = IIf(IsNumeric(Me.tb_top.Text), Val(Me.tb_top.Text), A.Top)
        Next
        Me.preview_window()
    End Sub

    Private Sub Button10_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button10.Click

        If Not IsNumeric(Me.tb_wordwidth.Text) Then Return
        For Each A As Control In SelCon
            'Me.UpdateFontWidth(CType(A, MyControlOLEDBv2.MyLabel).장평 - Val(Me.tb_pixelsize.Text))
            CType(A, MyControlOLEDBv2.MyLabel).장평 = CInt(Me.tb_wordwidth.Text)
            ViewProperty(A)
        Next
        Me.preview_window()

    End Sub

    Private Sub Button11_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button11.Click
        If Not IsNumeric(Me.tb_wordheight.Text) Then Return

        For Each A As Control In SelCon
            'Me.UpdateFontWidth(CType(A, MyControlOLEDBv2.MyLabel).장평 - Val(Me.tb_pixelsize.Text))
            CType(A, MyControlOLEDBv2.MyLabel).장높이 = CInt(Me.tb_wordheight.Text)
            ViewProperty(A)
        Next
        Me.preview_window()
    End Sub

    Private Sub Button12_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button12.Click
        If Not IsNumeric(Me.tb_fsize.Text) Then
            MsgBox("숫자만 입력하세요", MsgBoxStyle.Critical, "확인")
            Return
        End If
        For Each A As Control In SelCon
            Me.UpdateFontSize(Me.tb_fsize.Text, A)
        Next
        Me.preview_window()
    End Sub

    Private Sub Button5_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button5.Click
        For Each A As Control In SelCon
            A.Left = IIf(IsNumeric(Me.tb_left.Text), Val(Me.tb_left.Text), A.Left)
        Next
        Me.preview_window()
    End Sub

    Private Sub TextBox5_KeyUp(ByVal sender As Object, ByVal e As System.Windows.Forms.KeyEventArgs) Handles tb_wordwidth.KeyUp
        If e.KeyCode = Keys.Enter Then Me.Button10.PerformClick()
    End Sub


    Private Sub TextBox6_KeyUp(ByVal sender As Object, ByVal e As System.Windows.Forms.KeyEventArgs) Handles tb_wordheight.KeyUp
        If e.KeyCode = Keys.Enter Then Me.Button11.PerformClick()
    End Sub



    Private Sub TextBox7_KeyUp(ByVal sender As Object, ByVal e As System.Windows.Forms.KeyEventArgs) Handles tb_fsize.KeyUp
        If e.KeyCode = Keys.Enter Then Me.Button12.PerformClick()
    End Sub


    Private Sub TextBox8_KeyUp(ByVal sender As Object, ByVal e As System.Windows.Forms.KeyEventArgs) Handles tb_space.KeyUp
        If e.KeyCode = Keys.Enter Then Me.Button3.PerformClick()
    End Sub

    Private Sub Button4_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button4.Click
        If SelCon Is Nothing Then Return

        For Each a As MyControlOLEDBv2.MyLabel In SelCon
            a.MyFont = CType(SelCon(0), MyControlOLEDBv2.MyLabel).MyFont
            a.장평 = CType(SelCon(0), MyControlOLEDBv2.MyLabel).장평
            a.장높이 = CType(SelCon(0), MyControlOLEDBv2.MyLabel).장높이
        Next
        Me.ViewProperty(CType(SelCon(0), MyControlOLEDBv2.MyLabel))
        Me.preview_window()
    End Sub

    Private Sub BindingSource1_PositionChanged(ByVal sender As Object, ByVal e As System.EventArgs) Handles BindingSource1.PositionChanged
        'MsgBox("BindingSource1_PositionChanged=" & Now.ToString & "current=" & Me.BindingNavigatorPositionItem.Text & "mnoview=" & NoView)
        Debug.Print("BindingSource1_PositionChanged : " & Me.BindingSource1.Position)
        Debug.Print("스크롤바값 범위값 " & Me.VScrollBar1.Minimum & "/" & Me.VScrollBar1.Maximum)
        If Me.BindingSource1.Position >= 0 Then Me.VScrollBar1.Value = Me.BindingSource1.Position
        If Me.NoView Then
            Me.NoView = False
        Else
            Me.GeTviewData(Me.BindingNavigatorPositionItem.Text - 1, True)
        End If
    End Sub

    Private Sub CheckBox1_CheckedChanged(ByVal sender As System.Object, ByVal e As System.EventArgs)
        Me.GeTviewData(Me.BindingSource1.Position, True)
    End Sub

    Private Sub VScrollBar1_Scroll(ByVal sender As System.Object, ByVal e As System.Windows.Forms.ScrollEventArgs)
        'MsgBox(Me.VScrollBar1.Minimum & "/" & Me.VScrollBar1.Maximum & "=" & e.NewValue)
        Me.BindingSource1.Position = e.NewValue
    End Sub

    Private Sub PictureBox1_MouseClick(ByVal sender As Object, ByVal e As System.Windows.Forms.MouseEventArgs) Handles PictureBox1.MouseClick
        Dim Tobj As MyControlOLEDBv2.MyLabel
        Dim selitem As New ArrayList
        Tobj = Nothing

        For i As Integer = 0 To Me.AllLabels.GetUpperBound(0)
            If Me.AllLabels(i).ctl.Visible AndAlso Me.AllLabels(i).ctl.MyText <> "" AndAlso _
                ((e.X >= Me.AllLabels(i).ctl.Left) And e.X <= (Me.AllLabels(i).ctl.Left + Me.AllLabels(i).ctl.GetSize.Width)) _
                AndAlso ((e.Y >= Me.AllLabels(i).ctl.Top) AndAlso (e.Y <= (Me.AllLabels(i).ctl.Top + Me.AllLabels(i).ctl.GetSize.Height))) Then
                Tobj = Me.AllLabels(i).ctl
                selitem.Add(Me.AllLabels(i).ctl)
                'Exit For
            End If
        Next

        If Tobj Is Nothing Then Return '//선택된게 없으면 날린다

        'If Me.chk_multisel.Checked Then '//다중목록에서 선택시가 체크되어있으면 목록을 표시해준다.
        If selitem.Count > 1 Then
            Dim A As New selitem
            For si As Short = 1 To selitem.Count
                A.ListBox1.Items.Add(CType(selitem.Item(si - 1), MyControlOLEDBv2.MyLabel).설명)
            Next
            If A.ShowDialog() = Windows.Forms.DialogResult.OK Then
                Tobj = selitem.Item(A.ListBox1.SelectedIndex)
            Else   '//캔슬시에는 첫번째 아템으로 한다.
                Tobj = selitem.Item(0)
            End If
        End If
        'End If

        Dim Exist As Boolean = False   '//선택개체에 존재여부
        If SelCon Is Nothing Then
            SelCon.Add(Tobj)
        Else
            If e.Button = Windows.Forms.MouseButtons.Right Then
                For Each obj As MyControlOLEDBv2.MyLabel In SelCon
                    If obj.Name = Tobj.Name Then    '//삭제된다.
                        obj.MyForeColor = Drawing.Color.Black
                        SelCon.Remove(obj)
                        Exist = True
                        Exit For
                    End If
                Next
                If Exist = False Then
                    SelCon.Add(Tobj)
                    Tobj.MyForeColor = Drawing.Color.Tomato
                End If
            ElseIf e.Button = Windows.Forms.MouseButtons.Left Then '왼쪽클리이면 지우고 다시 셋팅
                For Each SC As MyControlOLEDBv2.MyLabel In SelCon
                    SC.MyForeColor = Drawing.Color.Black
                Next
                SelCon.Clear()
                SelCon.Add(Tobj)
                Tobj.MyForeColor = Drawing.Color.DodgerBlue

                If My.Computer.Keyboard.CtrlKeyDown Then   '//컨트롤이 눌러졋으면 해당 그룹을 전부 찾는다.
                    'MsgBox(Tobj.Name)
                    SelCon.Clear()
                    For z As Short = 0 To Me.AllLabels.GetUpperBound(0)
                        If Me.AllLabels(z).ctl.Name.Substring(0, 1) = Tobj.Name.Substring(0, 1) Then
                            Me.AllLabels(z).ctl.MyForeColor = Drawing.Color.Blue
                            SelCon.Add(Me.AllLabels(z).ctl)
                        End If
                    Next
                End If

            Else
                Me.Button1.PerformClick()
            End If
        End If
        'onlyOne = sender
        'CType(sender, MyControlOLEDBv2.MyLabel).
        Me.cmb_controls.Text = Tobj.설명
        ViewProperty(Tobj)

        'For Each A As MyControlOLEDBv2.MyLabel In SelCon
        ' A.MyForeColor = Color.DodgerBlue
        '  Next

        Me.tb_left.Focus()
        Me.preview_window()
    End Sub


    Private Sub PictureBox1_Click_1(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles PictureBox1.Click

    End Sub

    Private Sub Panel1_Paint(ByVal sender As System.Object, ByVal e As System.Windows.Forms.PaintEventArgs)

    End Sub

    Private Sub PictureBox1_MouseDoubleClick(ByVal sender As Object, ByVal e As System.Windows.Forms.MouseEventArgs) Handles PictureBox1.MouseDoubleClick
        Dim Tobj As MyControlOLEDBv2.MyLabel
        Tobj = Nothing

        For i As Integer = 0 To Me.AllLabels.GetUpperBound(0)
            If Me.AllLabels(i).ctl.Visible AndAlso Me.AllLabels(i).ctl.MyText <> "" AndAlso _
                ((e.X >= Me.AllLabels(i).ctl.Left) And e.X <= (Me.AllLabels(i).ctl.Left + Me.AllLabels(i).ctl.GetSize.Width)) _
                AndAlso ((e.Y >= Me.AllLabels(i).ctl.Top) AndAlso (e.Y <= (Me.AllLabels(i).ctl.Top + Me.AllLabels(i).ctl.GetSize.Height))) Then
                Tobj = Me.AllLabels(i).ctl
                Exit For
            End If
        Next

        If Tobj Is Nothing Then Return '//선택된게 없으면 날린다

        Dim Msg As New System.Text.StringBuilder("변경할 값을 입력하세요")
        Msg.AppendLine("줄바꿈을하려면 \n 을 입력하세요")
        Msg.AppendLine("예) 세로로 12를 출력하려면 1\n2 을 입력하세요")
        Msg.AppendLine()
        Msg.AppendLine("변경한 값은 현재페이지에만 적용됩니다")


        Dim Val As String = InputBox(Msg.ToString, "변경", Tobj.MyText)
        If Val = "" Then Return
        Val = Val.Replace("\n", vbCrLf)
        Tobj.MyText = Val

        Me.preview_window()
    End Sub

    Private Sub cmb_controls_SelectionChangeCommitted(ByVal sender As Object, ByVal e As System.EventArgs) Handles cmb_controls.SelectionChangeCommitted
        For Each A As MyControlOLEDBv2.MyLabel In Me.SelCon
            A.MyForeColor = Drawing.Color.Black
        Next
        SelCon.Clear()
        SelCon.Add(AllLabels(Me.cmb_controls.SelectedIndex).ctl)
        AllLabels(Me.cmb_controls.SelectedIndex).ctl.MyForeColor = Drawing.Color.DodgerBlue
        ViewProperty(AllLabels(Me.cmb_controls.SelectedIndex).ctl)
        Me.preview_window()
    End Sub

    Private Sub ToolStripButton5_Click(ByVal sender As System.Object, ByVal e As System.EventArgs)
        If MsgBox("현재 스타일(기본)을 저장하시겠습니까?", MsgBoxStyle.Information + MsgBoxStyle.YesNo, "스타일저장") = MsgBoxResult.Yes Then
            SAVE_STYLE()
        Else
            NOTICE("스타일(기존)저장이 취소되었습니다", Me.lb_msg)
        End If
    End Sub

    Private Sub ToolStripButton1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles ToolStripButton1.Click
        Me.Close()
    End Sub


    Private Sub 문자패턴연습(ByVal srcstr As String, ByVal pname As String, ByVal log As String, ByVal S라벨() As MyControlOLEDBv2.MyLabel)
        Dim Wlen As Short = srcstr.Length : If Wlen <= 0 Then Return '//없는 글귀가 왓을때 턴해버린다.
        Dim SepPos As Short = srcstr.IndexOf(";")
        Dim DR() As DataRow
        Dim CTLPOS() As String
        Dim CTLFONT() As String
        Dim CTLVISIBLE As Boolean

        DR = DtPattern.Select("NAME = '" & pname & "DESC'")
        If DR.GetUpperBound(0) = 0 Then '//길이패턴이 있으면
            WLog2(Auto_Log, "문자패턴 검색 길이=" & Wlen & " 구분자위치=" & SepPos & " 미들네임=" & pname, log)
            For Each C As MyControlOLEDBv2.MyLabel In S라벨
                Try
                    DR = DtPattern.Select("NAME = '" & pname & C.Name & "POS'")
                    If DR.GetUpperBound(0) = 0 Then
                        CTLPOS = DR(0)(1).ToString.Split(",")
                        C.Location = New Point(CTLPOS(0), CTLPOS(1))
                        C.Size = New Size(CTLPOS(2), CTLPOS(3))
                    End If

                    DR = DtPattern.Select("NAME = '" & pname & C.Name & "FONT'")
                    If DR.GetUpperBound(0) = 0 Then
                        CTLFONT = DR(0)(1).ToString.Split(",")
                        C.MyFont = New Font(CTLFONT(0), CTLFONT(1), IIf(CTLFONT(3).ToUpper = "TRUE", FontStyle.Bold, FontStyle.Regular), GraphicsUnit.Point)
                        C.장평 = CTLFONT(5)
                        C.장높이 = CTLFONT(6)
                    End If

                    DR = DtPattern.Select("NAME = '" & pname & C.Name & "VISIBLE'")
                    If DR.GetUpperBound(0) = 0 Then
                        CTLVISIBLE = DR(0)(1).ToString
                        C.Visible = CType(CTLVISIBLE, Boolean)
                    End If

                    DR = DtPattern.Select("NAME = '" & pname & C.Name & "SPACE'")
                    If DR.GetUpperBound(0) = 0 Then
                        C.공백 = DR(0)(1).ToString
                    End If

                    '//반복정보확인  Arinini.Write(Pname, TOBJ.Name & "repeat", TOBJ.Repeat & "," & TOBJ.RepeatX & "," & TOBJ.RepeatY)  '//반복출력정보저장
                    AddLog(Auto_Log, "반복문자셋트 : " & pname & C.Name & "REPEAT" & "  를 검색합니다")
                    DR = DtPattern.Select("NAME = '" & pname & C.Name & "REPEAT'")
                    If DR.GetUpperBound(0) = 0 Then
                        AddLog(Auto_Log, "해당반복문자를 찾았습니다")
                        CTLFONT = DR(0)(1).ToString.Split(",")
                        AddLog(Auto_Log, "해당반복문자를 콤마로 쪼개어서 CTLFONT 배열에 저장하였습니다.")
                        C.Repeat = CTLFONT(0)
                        AddLog(Auto_Log, "해당반복문자중 0번째위치값을 적용")
                        C.RepeatX = CTLFONT(1)
                        AddLog(Auto_Log, "해당반복문자중 1번째위치값을 적용")
                        C.RepeatY = CTLFONT(2)
                        AddLog(Auto_Log, "해당반복문자중 2번째위치값을 적용")
                        'C.MyFont = New Font(CTLFONT(0), CTLFONT(1), IIf(CTLFONT(3).ToUpper = "TRUE", FontStyle.Bold, FontStyle.Regular), GraphicsUnit.Point)
                        ' C.장평 = CTLFONT(5)
                        '  C.장높이 = CTLFONT(6)
                    Else
                        AddLog(Auto_Log, "해당반복문자를 찾지못했습니다.")
                    End If

                    C.Tag = "C"
                Catch ex As Exception
                    WLog2(Auto_Log, "문자패턴오류 길이=" & Wlen & " Message=" & ex.Message.ToString, log)
                End Try
            Next
        Else
            WLog2(Auto_Log, "문자패턴불일치 길이=" & Wlen & " 문자열=" & srcstr, log)
            Me.LOAD_STYLE(S라벨(0).DIV)
        End If
    End Sub

    Private Sub cmb_style_SelectionChangeCommitted(ByVal sender As Object, ByVal e As System.EventArgs) Handles cmb_style.SelectionChangeCommitted
        '//스타일을 직접 선택햇을때 기본idx값을 0 으로한다.
        'MsgBox("스타일직접선택")
        FirstIdx = 0
    End Sub


    Private Sub Button8_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button8.Click
        '//고관리구 5번 저장

        If 관리구.Trim = "" Then
            MsgBox("저장할 [관리구]가 없습니다", MsgBoxStyle.Critical, "확인")
            Return
        End If

        Dim msg As New System.Text.StringBuilder
        msg.AppendLine("관리구-전산번호  영문자(" & Me.관리구.Substring(4, 1) & " )에 대한 스타일을 저장합니다")
        msg.AppendLine()
        msg.AppendLine("저장후 관리구5번에 동일한 영문자가 올경우에 저장된 내용이 반영됩니다")
        msg.AppendLine("------------------")
        msg.AppendLine("글꼴 = " & Me.S관리구전산번호.MyFont.ToString)
        msg.AppendLine("너비 = " & Me.S관리구전산번호.장평)
        msg.AppendLine("높이 = " & Me.S관리구전산번호.장높이)
        msg.AppendLine("좌표 = " & Me.S관리구전산번호.Location.ToString)
        msg.AppendLine("------------------")
        msg.AppendLine(" 저장하시겠습니까?")

        If MsgBox(msg.ToString, MsgBoxStyle.Information + MsgBoxStyle.OkCancel, "저장확인") <> MsgBoxResult.Ok Then
            NOTICE("취소되었습니다", Me.lb_msg)
            Return
        End If

        '이건 길이패턴 저장하는 함수다.
        'MsgBox(drstyle.file)

        Dim Arinini As New MyINI2(drstyle.file)
        Dim TOBJ As MyControlOLEDBv2.MyLabel = Me.S관리구전산번호
        Dim Pname As String = "CNUMPATTERNI" & 관리구.Substring(4, 1) '//5번이 W 일때는 cnumpatternIw 를 찾게된다.

        Arinini.Write(Pname, "DESC", "영문자 특수저장(" & 관리구.Substring(4, 1) & ")")
        Arinini.Write(Pname, TOBJ.Name & "pos", TOBJ.Left & "," & TOBJ.Top & "," & TOBJ.Width & "," & TOBJ.Height)
        Arinini.Write(Pname, TOBJ.Name & "font", TOBJ.MyFont.Name & "," & TOBJ.MyFont.Size & "," & TOBJ.MyFont.Underline & "," & TOBJ.MyFont.Bold & "," & TOBJ.MyFont.Italic & "," & TOBJ.장평 & "," & TOBJ.장높이)
        Arinini.Write(Pname, TOBJ.Name & "visible", TOBJ.Visible)
        Arinini.Write(Pname, TOBJ.Name & "space", TOBJ.공백)

        NOTICE("관리구5번 의 영문자 (" & Me.관리구.Substring(4, 1) & ") 상태를 저장하였습니다", Me.lb_msg)
        데이터테이블갱신()
    End Sub



    Private Sub ToolStripTextBox1_KeyUp(ByVal sender As Object, ByVal e As System.Windows.Forms.KeyEventArgs) Handles tb_ntype.KeyUp
        If e.KeyCode = Keys.Enter Then
            If Me.cmb_sep.SelectedIndex = 1 Then
                NOTICE("분리상태에서는 번호지정이 불가능합니다", Drawing.Color.Red, Me.lb_msg)
            Else
                번호형식지정(Me.tb_ntype.Text)
            End If
            Me.preview_window()
        End If
    End Sub

    Private Sub ToolStripLabel2_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles ToolStripLabel2.Click
        If MsgBox("현재 스타일(기본)을 저장하시겠습니까?", MsgBoxStyle.Information + MsgBoxStyle.YesNo, "스타일저장") = MsgBoxResult.Yes Then
            SAVE_STYLE()
        Else
            NOTICE("스타일(기존)저장이 취소되었습니다", Me.lb_msg)
        End If
    End Sub

    Private Sub tb_ntype_MouseEnter(ByVal sender As Object, ByVal e As System.EventArgs) Handles tb_ntype.MouseEnter
        Me.tb_ntype.Focus()
        Me.tb_ntype.SelectAll()
    End Sub
    Private Sub BindingNavigatorPositionItem_MouseEnter(ByVal sender As Object, ByVal e As System.EventArgs) Handles BindingNavigatorPositionItem.MouseEnter
        Me.BindingNavigatorPositionItem.Focus()
        Me.BindingNavigatorPositionItem.SelectAll()

    End Sub

    Private Sub VScrollBar1_Scroll_1(ByVal sender As System.Object, ByVal e As System.Windows.Forms.ScrollEventArgs) Handles VScrollBar1.Scroll
        Debug.Print("Scroll Old:" & e.OldValue & "/ New :" & e.NewValue & "/ Current : " & Me.VScrollBar1.Value)
        Debug.Print("스크롤바값 범위값 " & Me.VScrollBar1.Minimum & "/" & Me.VScrollBar1.Maximum)
        If e.NewValue > 0 Then
            Me.BindingSource1.Position = e.NewValue
        Else
            Debug.Print("스크롤바value값이 0보다 작습니다. 소스의 위치를 0으로 설정합니다")
            Me.BindingSource1.Position = 0
        End If
    End Sub

    Private Sub sdfnuItem_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles bt_prnpreview.Click
        Me.Print_Preview()
    End Sub

    Private Sub bt_print_ButtonClick(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles bt_print.ButtonClick
        Me.Print()
    End Sub

    Private Sub cm_styleedit_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles cm_styleedit.Click
        StyleEdit.ListIndex = Me.cmb_style.SelectedIndex
        StyleEdit.Path = Me.StyleDir
        StyleEdit.Show()
    End Sub

    Private Sub PictureBox1_MouseMove(ByVal sender As Object, ByVal e As System.Windows.Forms.MouseEventArgs) Handles PictureBox1.MouseMove
        'Me.Text = e.X & "/" & e.Y

        If My.Computer.Keyboard.CtrlKeyDown = True AndAlso My.Computer.Keyboard.AltKeyDown = True Then
            '//선택된 컨트롤을 마우스위치로 이동한다.
            If SelCon Is Nothing OrElse SelCon.Count < 1 Then Exit Sub
            For Each sender1 As MyControlOLEDBv2.MyLabel In SelCon
                sender1.Left = e.X - (sender1.Width / 2)
                sender1.Top = e.Y + (sender1.Height / 2)
            Next
            Me.preview_window()
        End If
    End Sub

    Private Sub ContextMenuStrip1_Opening(ByVal sender As System.Object, ByVal e As System.ComponentModel.CancelEventArgs) Handles ContextMenuStrip1.Opening
        If Me.cmb_style.Items.Count < 1 Then
            Me.cm_styleedit.Enabled = False
        End If
    End Sub

    Private Sub tyuToolStripMenuItem_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles tyuToolStripMenuItem.Click
        SAVE_PATTERNII(Me.관리전산번호 & "II", 패턴명_관리전산번호, "H", "\관리구전산패턴2.TXT")    '//선로명의 패턴을 저장합니다.
    End Sub

    Private Sub xxxolStripMenuItem_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles xxxolStripMenuItem.Click
        If MsgBox("비고1,2,3,4 를 저장하시겠습니까?", MsgBoxStyle.OkCancel Or MsgBoxStyle.Information, "문자패턴저장") = MsgBoxResult.Ok Then
            If 비고1 <> "" Then SAVE_PATTERNII(Me.비고1, "LNUM" & BlineNum & 패턴명_비고1 & "II", "O", "\비고1패턴2.TXT", False) '//선로명의 패턴을 저장합니다.
            If 비고2 <> "" Then SAVE_PATTERNII(Me.비고2, "LNUM" & BlineNum & 패턴명_비고2 & "II", "P", "\비고2패턴2.TXT", False) '//선로명의 패턴을 저장합니다.
            If 비고3 <> "" Then SAVE_PATTERNII(Me.비고3, "LNUM" & BlineNum & 패턴명_비고3 & "II", "Q", "\비고3패턴2.TXT", False) '//선로명의 패턴을 저장합니다.
            If 비고4 <> "" Then SAVE_PATTERNII(Me.비고4, "LNUM" & BlineNum & 패턴명_비고4 & "II", "R", "\비고4패턴2.TXT", False) '//선로명의 패턴을 저장합니다.
        End If
    End Sub

    Private Sub olStripMenuItem_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles olStripMenuItem.Click
        SAVE_PATTERNII(Me.선로명, 패턴명_선로 & "II", "L", "\선로명패턴2.TXT")    '//선로명의 패턴을 저장합니다.
    End Sub

    Private Sub kiuStripMenuItem_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles kiuStripMenuItem.Click
        SAVE_PATTERNII(Me.번호, 패턴명_번호 & "II", "X", "\번호패턴2.TXT")    '//선로명의 패턴을 저장합니다.
    End Sub

    Private Sub Button16_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button16.Click
        '//선추가
        Dim NewLine As New S_Line
        NewLine.PenColor = Drawing.Color.Black
        NewLine.PenWidth = 3
        NewLine.X = Draw_Line.Count * 10
        NewLine.Y = 10
        NewLine.X2 = 100 + Draw_Line.Count * 10
        NewLine.Y2 = NewLine.X2

        Draw_Line.Add(NewLine)
        Refresh_Drawlist()
    End Sub

    Private Sub Button15_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button15.Click
        '//선추가
        Dim NewLine As New S_Box
        NewLine.PenColor = Drawing.Color.Black
        NewLine.PenWidth = 3
        NewLine.X = Draw_Box.Count * 10
        NewLine.Y = Draw_Box.Count * 10
        NewLine.Width = 100 + Draw_Box.Count * 10
        NewLine.Height = NewLine.Width
        Draw_Box.Add(NewLine)
        Refresh_Drawlist()
    End Sub

    Private Sub Button13_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button13.Click
        Dim NewLine As New S_Circle
        NewLine.PenColor = Drawing.Color.Black
        NewLine.PenWidth = 3
        NewLine.X = 100
        NewLine.Y = 100
        NewLine.Width = 200
        'NewLine.Height = 200
        Draw_Circle.Add(NewLine)
        Refresh_Drawlist()
    End Sub

    Private Sub Button14_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button14.Click
        Try
            '//삭제
            Select Case Me.ListBox1.Text.Substring(0, 1)
                Case "선"
                    Draw_Line.RemoveAt(Me.ListBox1.Text.Split(":")(1))
                Case "박"
                    Draw_Box.RemoveAt(Me.ListBox1.Text.Split(":")(1))
                Case "원"
                    Draw_Circle.RemoveAt(Me.ListBox1.Text.Split(":")(1))
                Case "Q"
                    Draw_QRcode.RemoveAt(Me.ListBox1.Text.Split(":")(1))
            End Select
            Me.Refresh_Drawlist()
        Catch ex As Exception
            MessageBox.Show("선택 후 삭제가 가능합니다.", "확인", MessageBoxButtons.OK, MessageBoxIcon.Error)
            ListBox1.Focus()
        End Try
    End Sub

    Private Sub Button2_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button2.Click
        Dim NewLine As New S_QRCode
        NewLine.X = 100
        NewLine.Y = 100
        NewLine.Width = 0
        NewLine.Height = 0
        Draw_QRcode.Add(NewLine)
        Refresh_Drawlist()
    End Sub

    Private Sub ListBox1_SelectedIndexChanged(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles ListBox1.SelectedIndexChanged
        If Me.ListBox1.SelectedIndex < 0 Then Return
        Select Case Me.ListBox1.Text.Substring(0, 1)
            Case "선"
                Dim Line As S_Line = Draw_Line(Me.ListBox1.Text.Split(":")(1))
                Me.bt_pencolor.BackColor = Line.PenColor
                Me.tb_pensize.Text = Line.PenWidth
                Me.tb_dx.Text = Line.X
                Me.tb_dy.Text = Line.Y
                Me.tb_dw.Text = Line.X2
                Me.tb_dh.Text = Line.Y2
            Case "박"
                Dim Line As S_Box = Draw_Box(Me.ListBox1.Text.Split(":")(1))
                Me.bt_pencolor.BackColor = Line.PenColor
                Me.tb_pensize.Text = Line.PenWidth
                Me.tb_dx.Text = Line.X
                Me.tb_dy.Text = Line.Y
                Me.tb_dw.Text = Line.Width
                Me.tb_dh.Text = Line.Height
            Case "원"
                Dim Line As S_Circle = Draw_Circle(Me.ListBox1.Text.Split(":")(1))
                Me.bt_pencolor.BackColor = Line.PenColor
                Me.tb_pensize.Text = Line.PenWidth
                Me.tb_dx.Text = Line.X
                Me.tb_dy.Text = Line.Y
                Me.tb_dw.Text = Line.Width
            Case "Q"
                Dim Line As S_QRCode = Draw_QRcode(Me.ListBox1.Text.Split(":")(1))
                Me.tb_dx.Text = Line.X
                Me.tb_dy.Text = Line.Y
                Me.tb_dw.Text = Line.Width
                Me.tb_dh.Text = Line.Height

        End Select
    End Sub

    Private Sub tb_pensize_KeyDown(ByVal sender As Object, ByVal e As System.Windows.Forms.KeyEventArgs) Handles tb_pensize.KeyDown, tb_dx.KeyDown, tb_dy.KeyDown, tb_dw.KeyDown, tb_dh.KeyDown
        If Me.ListBox1.SelectedIndex < 0 Then Return
        Dim SI As Short = Me.ListBox1.SelectedIndex
        If e.KeyCode = Keys.Enter Then
            '//새로만들어서 저장한다.
            Set_NewDraw()
            Me.Refresh_Drawlist()
            Me.ListBox1.SelectedIndex = SI
        End If

    End Sub

    Private Sub Set_NewDraw()
        Select Case Me.ListBox1.Text.Substring(0, 1)
            Case "선"
                Dim Line As New S_Line
                Line.PenColor = Me.bt_pencolor.BackColor
                Line.PenWidth = Me.tb_pensize.Text
                Line.X = Me.tb_dx.Text
                Line.Y = Me.tb_dy.Text
                Line.X2 = Me.tb_dw.Text
                Line.Y2 = Me.tb_dh.Text
                Draw_Line(Me.ListBox1.Text.Split(":")(1)) = Line
                'MsgBox("선재구성")
            Case "박"
                Dim Line As New S_Box
                Line.PenColor = Me.bt_pencolor.BackColor
                Line.PenWidth = Me.tb_pensize.Text
                Line.X = Me.tb_dx.Text
                Line.Y = Me.tb_dy.Text
                Line.Width = Me.tb_dw.Text
                Line.Height = Me.tb_dh.Text
                Draw_Box(Me.ListBox1.Text.Split(":")(1)) = Line
                'MsgBox("박스재구성")
            Case "원"
                Dim Line As New S_Circle
                Line.PenColor = Me.bt_pencolor.BackColor
                Line.PenWidth = Me.tb_pensize.Text
                Line.X = Me.tb_dx.Text
                Line.Y = Me.tb_dy.Text
                Line.Width = Me.tb_dw.Text
                Draw_Circle(Me.ListBox1.Text.Split(":")(1)) = Line
                'MsgBox("원재구성")
            Case "Q"
                Dim Line As New S_QRCode
                Line.X = Me.tb_dx.Text
                Line.Y = Me.tb_dy.Text
                Line.Width = Me.tb_dw.Text
                Line.Height = Me.tb_dh.Text
                Draw_QRcode(Me.ListBox1.Text.Split(":")(1)) = Line
        End Select
    End Sub
    Private Sub bt_pencolor_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles bt_pencolor.Click
        Dim CD As New ColorDialog
        CD.Color = Me.bt_pencolor.BackColor
        If CD.ShowDialog <> Windows.Forms.DialogResult.OK Then Return
        Me.bt_pencolor.BackColor = CD.Color
        Set_NewDraw()
    End Sub

    Private Sub SaveDrawData(ByVal read As Boolean)   '//현재 화면구성을 가로/세로 결정합니다.
        '//ini파일에저장한다. 섹션명은 pagetype0 ,pagetyp1  0은 세로 1은 가로다
        Dim ini As New MyINI2(drstyle.file)

        Dim bname As String = "DrawBox"
        Dim lname As String = "DrawLine"
        Dim cname As String = "DrawCircle"
        Dim qname As String = "DrawQRcode"

        Dim bcnt, lcnt, ccnt, qcnt As Short

        If read = False Then
            ini.Write(bname, "Count", Draw_Box.Count)
            For i As Short = 1 To Draw_Box.Count '//모두돌아서 저장한다.
                Dim L As S_Box = Draw_Box(i - 1)
                ini.Write(bname, "box" & i & "pencolor", L.PenColor.ToArgb)
                ini.Write(bname, "box" & i & "pensize", L.PenWidth)
                ini.Write(bname, "box" & i & "x", L.X)
                ini.Write(bname, "box" & i & "y", L.Y)
                ini.Write(bname, "box" & i & "x2", L.Width)
                ini.Write(bname, "box" & i & "y2", L.Height)
            Next
            ini.Write(lname, "Count", Draw_Line.Count)
            For i As Short = 1 To Draw_Line.Count '//모두돌아서 저장한다.
                Dim L As S_Line = Draw_Line(i - 1)
                ini.Write(lname, "line" & i & "pencolor", L.PenColor.ToArgb)
                ini.Write(lname, "line" & i & "pensize", L.PenWidth)
                ini.Write(lname, "line" & i & "x", L.X)
                ini.Write(lname, "line" & i & "y", L.Y)
                ini.Write(lname, "line" & i & "x2", L.X2)
                ini.Write(lname, "line" & i & "y2", L.Y2)
            Next
            ini.Write(cname, "Count", Draw_Circle.Count)
            For i As Short = 1 To Draw_Circle.Count '//모두돌아서 저장한다.
                Dim L As S_Circle = Draw_Circle(i - 1)
                ini.Write(cname, "circle" & i & "pencolor", L.PenColor.ToArgb)
                ini.Write(cname, "circle" & i & "pensize", L.PenWidth)
                ini.Write(cname, "circle" & i & "x", L.X)
                ini.Write(cname, "circle" & i & "y", L.Y)
                ini.Write(cname, "circle" & i & "x2", L.Width)
                ini.Write(cname, "box" & i & "y2", L.Height)
            Next
            ini.Write(qname, "Count", Draw_QRcode.Count)
            For i As Short = 1 To Draw_QRcode.Count '//모두돌아서 저장한다.
                Dim L As S_QRCode = Draw_QRcode(i - 1)
                'ini.Write(pname, "Image" & i & "pencolor", L.PenColor.ToArgb)
                'ini.Write(pname, "Image" & i & "pensize", L.PenWidth)
                ini.Write(qname, "qrcode" & i & "x", L.X)
                ini.Write(qname, "qrcode" & i & "y", L.Y)
                ini.Write(qname, "qrcode" & i & "x2", L.Width)
                ini.Write(qname, "qrcode" & i & "y2", L.Height)
            Next
        Else   '//여기는 읽는 부분
            Draw_Box.Clear()
            Draw_Line.Clear()
            Draw_Circle.Clear()
            Draw_QRcode.Clear()

            bcnt = ini.Read(bname, "Count", 0)
            For i As Short = 1 To bcnt '//모두돌아서 저장한다.
                Dim L As New S_Box
                L.PenColor = Drawing.Color.FromArgb(ini.Read(bname, "box" & i & "pencolor", 0))
                L.PenWidth = ini.Read(bname, "box" & i & "pensize", 3)
                L.X = ini.Read(bname, "box" & i & "x", 0)
                L.Y = ini.Read(bname, "box" & i & "y", 0)
                L.Width = ini.Read(bname, "box" & i & "x2", 10)
                L.Height = ini.Read(bname, "box" & i & "y2", 10)
                Draw_Box.Add(L)
            Next

            lcnt = ini.Read(lname, "Count", 0)
            For i As Short = 1 To lcnt '//모두돌아서 저장한다.
                Dim L As New S_Line
                L.PenColor = Drawing.Color.FromArgb(ini.Read(lname, "line" & i & "pencolor", 0))
                L.PenWidth = ini.Read(lname, "line" & i & "pensize", 3)
                L.X = ini.Read(lname, "line" & i & "x", 0)
                L.Y = ini.Read(lname, "line" & i & "y", 0)
                L.X2 = ini.Read(lname, "line" & i & "x2", 10)
                L.Y2 = ini.Read(lname, "line" & i & "y2", 10)
                Draw_Line.Add(L)
            Next

            ccnt = ini.Read(cname, "Count", 0)   '//원
            For i As Short = 1 To ccnt '//모두돌아서 저장한다.
                Dim L As New S_Circle
                L.PenColor = Drawing.Color.FromArgb(ini.Read(cname, "circle" & i & "pencolor", 0))
                L.PenWidth = ini.Read(cname, "circle" & i & "pensize", 3)
                L.X = ini.Read(cname, "circle" & i & "x", 0)
                L.Y = ini.Read(cname, "circle" & i & "y", 0)
                L.Width = ini.Read(cname, "circle" & i & "x2", 10)
                L.Height = ini.Read(cname, "circle" & i & "y2", 10)
                Draw_Circle.Add(L)
            Next

            qcnt = ini.Read(qname, "Count", 0)
            For i As Short = 1 To qcnt '//모두돌아서 저장한다.
                Dim L As New S_QRCode
                'L.PenColor = Color.FromArgb(ini.Read(pname, "Circle" & i & "pencolor", 0))
                'L.PenWidth = ini.Read(sname, "Circle" & i & "pensize", 3)
                L.X = ini.Read(qname, "qrcode" & i & "x", 0)
                L.Y = ini.Read(qname, "qrcode" & i & "y", 0)
                L.Width = ini.Read(qname, "qrcode" & i & "x2", 10)
                L.Height = ini.Read(qname, "qrcode" & i & "y2", 10)
                Draw_QRcode.Add(L)
            Next
            Me.Refresh_Drawlist()
        End If

    End Sub

    Private Sub Refresh_Drawlist()
        '//;라인하고 박스를 읽어서 리스트박스에
        Me.ListBox1.Items.Clear()
        Dim I As Short = 0
        For Each Rect As S_Line In Draw_Line
            Me.ListBox1.Items.Add("선(" & Rect.X & "," & Rect.Y & "," & Rect.X2 & "," & Rect.Y2 & "):" & I)
            I += 1
        Next
        I = 0
        For Each Rect As S_Box In Draw_Box
            Me.ListBox1.Items.Add("박스(" & Rect.X & "," & Rect.X & "," & Rect.Width & "," & Rect.Height & "):" & I)
            I += 1
        Next
        I = 0
        For Each Rect As S_Circle In Draw_Circle
            Me.ListBox1.Items.Add("원(" & Rect.X & "," & Rect.Y & "," & Rect.Width & "," & Rect.Height & "):" & I)
        Next
        I = 0
        For Each Rect As S_QRCode In Draw_QRcode
            Me.ListBox1.Items.Add("QR(" & Rect.X & "," & Rect.Y & "," & Rect.Width & "," & Rect.Height & "):" & I)
            I += 1
        Next
        I = 0

        preview_window()
    End Sub

    Private Sub LinkLabel1_LinkClicked(sender As Object, e As LinkLabelLinkClickedEventArgs) Handles LinkLabel1.LinkClicked
        Dim a As New ColorDialog
        a.Color = lbQrBg.BackColor
        If a.ShowDialog() = Windows.Forms.DialogResult.OK Then
            lbQrBg.BackColor = a.Color
        End If
    End Sub

    Private Sub LinkLabel2_LinkClicked(sender As Object, e As LinkLabelLinkClickedEventArgs) Handles LinkLabel2.LinkClicked
        Dim a As New ColorDialog
        a.Color = lbQrFG.BackColor
        If a.ShowDialog() = Windows.Forms.DialogResult.OK Then
            lbQrFG.BackColor = a.Color
        End If
    End Sub
End Class



