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

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

Public Class printform

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

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

    Dim S구관리전산(0) As MyControlOLEDBv2.MyLabel
    Dim S관리구(4) As MyControlOLEDBv2.MyLabel
    Dim S전산번호(2) As MyControlOLEDBv2.MyLabel
    Dim S선로명(10) As MyControlOLEDBv2.MyLabel
    Dim S전주번호(20) As MyControlOLEDBv2.MyLabel
    Dim S시공년월(3) As MyControlOLEDBv2.MyLabel
    Dim S관리구전주번호(0) As MyControlOLEDBv2.MyLabel
    Dim S장척(2) As MyControlOLEDBv2.MyLabel
    Dim S시공자(0) As MyControlOLEDBv2.MyLabel
    Dim S접지(1) As MyControlOLEDBv2.MyLabel
    Dim S감독자(9) As MyControlOLEDBv2.MyLabel
    Dim S점검일자(0) As MyControlOLEDBv2.MyLabel
    Dim S일련번호(0) As MyControlOLEDBv2.MyLabel
    '    Dim S비고명(3) As MyControlOLEDBv2.MyLabel          '2013/06/13 인수 3개에서 0으로
    Dim S비고명(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본주번호(0) As MyControlOLEDBv2.MyLabel
    Dim S본주전주번호(0) As MyControlOLEDBv2.MyLabel
    Dim S전주번호한줄(0) As MyControlOLEDBv2.MyLabel

    '//150201 추가
    Dim S휴즈용량(9) As MyControlOLEDBv2.MyLabel
    Dim S상표시찰1단(2) As MyControlOLEDBv2.MyLabel
    Dim S상표시찰2단(2) As MyControlOLEDBv2.MyLabel

    Dim S구선로전주번호(0) As MyControlOLEDBv2.MyLabel 'v
    Dim S신선로전주번호(0) As MyControlOLEDBv2.MyLabel 'w

    Dim S점검(0) As MyControlOLEDBv2.MyLabel 'HI
    'Dim S고정문자1 As MyControlOLEDBv2.MyLabel 'x
    'Dim S고정문자2 As MyControlOLEDBv2.MyLabel 'y
    Dim S점검필(0) As MyControlOLEDBv2.MyLabel
    Dim S점검자(0) As MyControlOLEDBv2.MyLabel
    Dim S한국전력(0) As MyControlOLEDBv2.MyLabel

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

    Dim 구관리구 As String = ""
    Dim 구전산번호 As String = ""
    Dim 구관리전산 As String = ""
    Dim 관리구 As String = ""
    Dim 전산번호 As String = ""
    Dim 선로명 As String = ""
    Dim 번호 As String = ""
    Dim 장척 As String = ""
    Dim 시공년월 As String = ""
    Dim 시공자 As String = ""
    Dim 감독자 As String = ""
    Dim 점검일자 As String = ""
    Dim 접지1 As String = ""
    Dim 접지2 As String = ""
    Dim 비고명 As String = ""
    Dim 본주번호 As String = ""
    Dim 본주전주번호 As String = ""
    Dim 전주번호한줄 As String = ""
    'Dim 점검 As String = ""

    '//150201
    Dim 휴즈용량 As String = ""
    Dim 상표시찰1단 As String = ""
    Dim 상표시찰2단 As String = ""

    Dim 구선로전주번호 As String = ""
    Dim 신선로전주번호 As String = ""
    Dim 구선로명 As String = ""
    Dim 구전주번호 As String = ""

    Dim 점검필 As String = ""
    Dim 점검자 As String = ""
    Dim 한국전력 As String = ""

    Dim 고장신고 As String = ""

    '//170711
    Dim 선로전방 As String = ""
    Dim 선로좌측 As String = ""
    Dim 선로우측 As String = ""


    ''QR변수 선언
    'Dim q시공자 As String = ""
    'Dim q홈페이지 As String = ""
    'Dim q관리 As String = ""
    'Dim q관리1 As String = ""
    'Dim q관리2 As String = ""

    Dim qr홈페이지1 As String = ""
    Dim qr홈페이지2 As String = ""
    Dim qr홈페이지3 As String = ""
    Dim qr홈페이지4 As String = ""

    Dim rqr기타1 As String = ""
    Dim rqr기타2 As String = ""
    Dim rqr기타3 As String = ""
    Dim rqr기타4 As String = ""


    Dim NoView As Boolean = False   '//LOAD_STYLE 을 잠시 실행하지 않기위햇(중복실행방지)서 둔다.
    Dim 관리구조작됨 As Boolean = True
    Dim 전산번호조작됨 As Boolean = True
    Dim 선로명조작됨 As Boolean = True
    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 & "\style")
    Public FileC As String = My.Application.Info.DirectoryPath & "\styleC.ini" '//사용자 스타일 파일

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

    Dim srcTable As ireaDataSet.jjutableDataTable    '//데이터가 저장될 테이블
    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  '//실제출력일때는 true 을 가진다.

    Dim LastStyleName As String '//마지막으로사용한스타일명

    Public MyProperty_Paper As PropertyGrid_Paper

    Public Sub New()
        InitializeComponent()
        AddLog(Admin, "New()", "\Alllog.txt")
    End Sub

    Public Sub New(ByRef Src As ireaDataSet.jjutableDataTable, Optional ByVal IRow As DataRowView = Nothing)
        InitializeComponent()

        'QR 추가

        'q시공자 = d1
        'q홈페이지 = d2
        'q관리 = d3
        'q관리1 = d4
        'q관리2 = d5

        AddLog(Admin, "New(srctable,srcRow)", "\Alllog.txt")
        srcTable = Src  '//가져온 테이블을 임시테이블에 저장을 해두고 사용한다.
        Srcrow = IRow  '//이것은 클릭된 행번호이다. 이 행번호를 가지고 스타일을 판별한다
    End Sub

    Private Sub printform_FormClosing(ByVal sender As Object, ByVal e As System.Windows.Forms.FormClosingEventArgs) Handles Me.FormClosing
        'If Not BackWork Is Nothing Then BackWork = Nothing
        'Me.CustFP1.ColSize_Save()
        Me.dataview.Setting_Save(False, "printjjung", "\viewConfig\main_")
        AddLog(Admin, "Form_Close", "\Alllog.txt")
        Save_Setting()
    End Sub

    Dim wat As New System.Diagnostics.Stopwatch
    Private Sub Form1_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load

      
        Me.dataview.Setting_Load(False, "printjjung", "\viewConfig\main_")
        Me.SetStyle(ControlStyles.AllPaintingInWmPaint Or ControlStyles.UserPaint Or ControlStyles.DoubleBuffer, True) '//더블버퍼링
        AddLog(Admin, "Form_Load()", "\Alllog.txt")
        GetPrintersName()   '//프린터명을 가져옵니다.
        Load_Setting()
        SetControls()   '//컨트롤을 초기화하고 셋팅한다.


     

        If srcTable Is Nothing Then
            MsgBox("원본데이터소스가 정의되지 않았습니다", MsgBoxStyle.Critical, "확인")
            AddLog(Admin, "개발자 기본셋팅으로 전환()", "\Alllog.txt")
            Common.Admin = True
            Me.NoView = True
            'Me.detTableAdapter1.Connection.ConnectionString = ConString
            'Me.detTableAdapter1.Fill(Me.IreaDataSet1.jjutable, 1)
            'Me.srcTable = Me.IreaDataSet1.jjutable
            Admin = True

        End If

        AddLog(Admin, "개발자모드=" & Admin.ToString, "\Alllog.txt")
        If Admin Then   '//개발자모드는 체크박스를 사용할수 있게한다.
            showlog()
            For Each A As Control In Me.TabPage3.Controls
                If A.GetType.Name.ToUpper = "CHECKBOX" Then
                    A.Visible = True
                End If
            Next
        End If

        Me.SETTOOLTIP()


        Console.WriteLine("Form_Load GetStyle List Start")
        wat.Restart()

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

        Console.WriteLine("Form_Load GetStyle List Time : " + wat.ElapsedMilliseconds.ToString() + "ms")
        wat.Stop()

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

        '//여기서 행값을 분석해서 콤보밗를 셋팅해준다; '//전부 셋팅된후 해당 값을 또 찾아야 한다.
        Srcnum = Srcrow("번호") 'srcTable.Rows(SrcIdx).Item("번호")
        AddLog(Admin, "선택되서 넘오온데이터의 번호를 찾습니다=" & Srcnum, "\Alllog.txt")

        Console.WriteLine("Form_Load Events Step 2-1 : " + wat.ElapsedMilliseconds.ToString() + "ms")
        wat.Restart()

        Dim 기입 As Boolean = Srcrow("기입")
        Dim 인입 As Boolean = Srcrow("인입")

       
        If Srcrow("dl명").ToString <> "" Then
            AddLog(Admin, "기기용으로 판별()", "\Alllog.txt")
            Me.cmb_style.Text = "기기용"  '//여기서 데이터가 걸러지게된다.
        ElseIf 기입 AndAlso Not 인입 Then
            AddLog(Admin, "기입용으로 판별()", "\Alllog.txt")
            Me.cmb_style.Text = "기입용"  '//여기서 데이터가 걸러지게된다.
        ElseIf 인입 Then
            AddLog(Admin, "인입용 =소주로 판별()", "\Alllog.txt")
            Me.cmb_style.Text = "인입용"  '//여기서 데이터가 걸러지게된다.
        End If

      
        If Me.cmb_style.SelectedIndex = -1 Then
            AddLog(Admin, "일반용으로셋팅한다.()", "\Alllog.txt")
            If Me.LastStyleName.Trim = "중규격" Then
                Me.cmb_style.Text = "중규격"  '//여기서 데이터가 걸러지게된다.
            Else
                Me.cmb_style.Text = "일반용"  '//여기서 데이터가 걸러지게된다.
            End If

        End If

        Me.cmb_jisun.SelectedIndex = 1


    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.S
                If e.Control Then
                    Me.bt_pattern_no.PerformClick()
                End If
            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 AddControl(ByRef CtlCnt As Short, ByVal 설명 As String, ByVal tag As String, ByRef Labels() As MyControlOLEDBv2.MyLabel, ByRef Cb As CheckBox, ByVal bPattern As String)
        '//채크박스 싱크
        Cb.Tag = tag
        Cb.Text = 설명
        For i As Integer = 0 To Labels.GetUpperBound(0)  '//모든문자를 할당한다.
            Labels(i) = New MyControlOLEDBv2.MyLabel
            Labels(i).설명 = 설명 & i + 1
            Labels(i).DIV = tag
            Labels(i).Name = tag & i + 1
            Labels(i).TextValue = ""
            Labels(i).Repeat = 0
            Labels(i).RepeatX = 0
            Labels(i).RepeatY = 0
            Labels(i).Pattern = bPattern
            ReDim Preserve AllLabels(CtlCnt)
            Me.AllLabels(CtlCnt).ctl = Labels(i)
            Me.cmb_controls.Items.Add(Labels(i).설명)
            CtlCnt += 1
        Next
        Labels(0).CheckBox = Cb
        Labels(0).Pattern = bPattern
    End Sub


    Private Sub SetControls()
        AddLog(Admin, "SetControls()", "\Alllog.txt")
        Dim CtlCnt As Short = 0

        '//체크박스 오류
        AddControl(CtlCnt, "관리구", "H", Me.S관리구, Me.cb_kwang, "HNUMBERPATTERN")
        AddControl(CtlCnt, "비고명", "K", Me.S비고명, Me.cb_dl, "DLPATTERN")
        AddControl(CtlCnt, "전산번호", "S", Me.S전산번호, Me.cb_sunsannum, "JNUMPATTERN")
        AddControl(CtlCnt, "선로명", "L", Me.S선로명, Me.cb_sunglo, "LINEPATTERN")
        AddControl(CtlCnt, "전주번호", "X", Me.S전주번호, Me.cb_jjnum, "NUMBERPATTERN")

        AddControl(CtlCnt, "시공년월", "Y", Me.S시공년월, Me.cb_yymm, "YYMMPATTERN")
        AddControl(CtlCnt, "관리구전주번호", "G", Me.S관리구전주번호, Me.cb_kwanjun, "NUMBERPATTERN")
        AddControl(CtlCnt, "장척", "J", Me.S장척, Me.cb_jangck, "CHOKPATTERN") '"NUMBERPATTERN")
        AddControl(CtlCnt, "시공자", "C", Me.S시공자, Me.cb_maker, "MAKERPATTERN")

        AddControl(CtlCnt, "접지", "Z", Me.S접지, Me.cb_jji, "NUMBERPATTERN")
        AddControl(CtlCnt, "감독자", "M", Me.S감독자, Me.cb_man, "NUMBERPATTERN")
        AddControl(CtlCnt, "점검일자", "O", Me.S점검일자, Me.cb_date, "LINEPATTERN")
        AddControl(CtlCnt, "점검", "HI", Me.S점검, Me.cb_date1, "LINEPATTERN")
        AddControl(CtlCnt, "일련번호", "N", Me.S일련번호, Me.cb_seq, "NUMBERPATTERN")

        AddControl(CtlCnt, "사용자문자1", "U", Me.S사용자1, Me.cb_u1, "NUMBERPATTERN")
        AddControl(CtlCnt, "사용자문자2", "A", Me.S사용자2, Me.cb_u2, "NUMBERPATTERN")
        AddControl(CtlCnt, "사용자문자3", "B", Me.S사용자3, Me.cb_u3, "NUMBERPATTERN")
        AddControl(CtlCnt, "사용자문자4", "D", Me.S사용자4, Me.cb_u4, "NUMBERPATTERN")
        AddControl(CtlCnt, "사용자문자5", "E", Me.S사용자5, Me.cb_u5, "NUMBERPATTERN")

        AddControl(CtlCnt, "구관리전산번호", "O1", Me.S구관리전산, Me.cb_oldjun, "NUMBERPATTERN")
        AddControl(CtlCnt, "본주줄번호", "P", Me.S본주번호, Me.cb_mainrow, "NUMBERPATTERN")
        AddControl(CtlCnt, "본주전주번호", "Q", Me.S본주전주번호, Me.cb_mainnum, "NUMBERPATTERN")

        AddControl(CtlCnt, "점검필", "Z1", Me.S점검필, Me.cb_jump, "NUMBERPATTERN")
        AddControl(CtlCnt, "점검자", "Z2", Me.S점검자, Me.cb_jumj, "NUMBERPATTERN")
        AddControl(CtlCnt, "한국전력", "Z3", Me.S한국전력, Me.cb_han, "NUMBERPATTERN")

        AddControl(CtlCnt, "고장신고", "Z4", Me.S고장신고, Me.cb_gojang, "NUMBERPATTERN")

        '//150201
        AddControl(CtlCnt, "COS휴즈용량", "F", Me.S휴즈용량, Me.cb_휴즈용량, "FUSEPATTERN")
        AddControl(CtlCnt, "상표시찰1단", "I", Me.S상표시찰1단, Me.cb_상1단, "SANG1PATTERN")
        AddControl(CtlCnt, "상표시찰2단", "T", Me.S상표시찰2단, Me.cb_상2단, "SANG2PATTERN")

        '//이건 지선주에거 쓴다.제어용으로 씀
        S전주번호한줄(0) = New MyControlOLEDBv2.MyLabel
        S전주번호한줄(0).설명 = "한줄전주번호"
        S전주번호한줄(0).Name = "R"
        S전주번호한줄(0).MyText = ""
        S전주번호한줄(0).Visible = False
        ReDim Preserve AllLabels(CtlCnt)
        Me.AllLabels(CtlCnt).ctl = S전주번호한줄(0)
        Me.cmb_controls.Items.Add(S전주번호한줄(0).설명)
        CtlCnt += 1

        AddControl(CtlCnt, "구선로전주번호", "V", Me.S구선로전주번호, Me.cb_numo, "NUMBERPATTERN")
        AddControl(CtlCnt, "신선로전주번호", "W", Me.S신선로전주번호, Me.cb_numn, "NUMBERPATTERN")


        Me.cmb_jisun.SelectedIndex = 0
    End Sub

    Private Sub SETTOOLTIP()
        AddLog(Admin, "Settooltip()", "\Alllog.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.rad_print_area, 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("<화명 중앙의 1/2 미리보기 창의 활성화 여부>")
        TMSG.AppendLine()
        TMSG.AppendLine("클릭해제시 중앙 미리보기 화면이 표시되지 않습니다")
        TMSG.AppendLine()
        'Me.ToolTip1.SetToolTip(Me.chb_preview, 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("<1장에 두번의 데이터가 표시됩니다.>")
        TMSG.AppendLine()
        TMSG.AppendLine("[복사]는 현재데이터와 동일한 데이터가 표시됩니다.")
        TMSG.AppendLine("[다음]은 다음데이터가 표시됩니다.")
        TMSG.AppendLine()
        TMSG.AppendLine("[다음] 출력시 미리보기상태에는 현재데이터가 표시되지만")
        TMSG.AppendLine("실제 출력시에는 다음데이터가 표시됩니다.")
        Me.ToolTip1.SetToolTip(Me.cmb_dummy, TMSG.ToString)

        'TMSG = New System.Text.StringBuilder()
        'TMSG.AppendLine()
        'TMSG.AppendLine("<선택시 [기타스타일-장척3자리사용] 이 적용됩니다>")
        'TMSG.AppendLine()
        'TMSG.AppendLine("장척 3자리상태일때 원하는 위치및 크기로 장척을 변경한 후")
        'TMSG.AppendLine("저장시에는 반드시 [기타스타일저장]을 클릭하세요.")
        'TMSG.AppendLine()
        'TMSG.AppendLine("일반스타일저장을 하면 저장위치가 잘못될 수 있습니다.")
        'Me.ToolTip1.SetToolTip(Me.cb_jc1, TMSG.ToString)


        TMSG = New System.Text.StringBuilder()
        TMSG.AppendLine("녹색은 길이패턴만 적용된 아이템이며")
        TMSG.AppendLine("적색은 길이,문자패턴이 존재하지 않는 아이템입니다")
        TMSG.AppendLine("흑색은 문자패턴이나 길이,문자패턴이 존재하는 경우입니다.")
        TMSG.AppendLine()
        'Me.ToolTip1.SetToolTip(Me.X1, X1.설명 & vbCrLf & TMSG.ToString)
        'Me.ToolTip1.SetToolTip(Me.X2, X2.설명 & vbCrLf & TMSG.ToString)
        'Me.ToolTip1.SetToolTip(Me.X3, X3.설명 & vbCrLf & TMSG.ToString)
    End Sub
    Private Sub con_dclick(ByVal sender As Object, ByVal e As System.EventArgs)
        AddLog(Admin, "개체를 더블클릭했습니다.(이것은 사용되지 않음)", "\Alllog.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()
        AddLog(Admin, "현재 설정(스타일)을 저장합니다.", "\Alllog.txt")
        Dim A As New MyINI2(SettingFile)
        A.Write("PRINTFORM", "printername", Me.combobox5.Text)   '//패턴검사조건 콤보박스      
        '//마지막으로닫앗을때의스타일명을기억한다.
        '     MsgBox("스타일저장한다 " & Me.cmb_style.Text)
        A.Write("lastStyle", "name", Me.cmb_style.Text)

    End Sub
    Private Sub Load_Setting()
        AddLog(Admin, "현재설정(스타일)을 가져옵니다.()", "\Alllog.txt")
        AddLog(Admin, "Load_Setting()", "\Alllog.txt")
        Dim a As New MyINI2(SettingFile)
        Me.combobox5.Text = a.Read("PRINTFORM", "printername", "")
        Me.LastStyleName = a.Read("lastStyle", "name")
    End Sub

    Public Sub GeTviewData(ByVal index As Integer, ByVal previewWindow As Boolean, Optional ByRef 번호패턴검사 As Integer = -1)
        ' Dim STARTTIME, ENDTIME As Date
        AddLog(Admin, "GetviewData 진입()", "\Alllog.txt")
        'MsgBox("getview = " & index)

        Console.WriteLine("GetTviewData")

        If Dv.Count <= 0 OrElse index < 0 OrElse index > Dv.Count Then
            AddLog(Admin, "GetViewData : 인덱스가 없거나 문제가 잇어서 리턴합니다.(" & index & ")", "\Alllog.txt")
            'MsgBox("GETVIEWDATA : 데이터가 없거나 잘못된 인덱스 입니다", MsgBoxStyle.Information, "확인") ' & index & "/" & Me.CustFP1.ActiveSheet.RowCount & ")", MsgBoxStyle.Critical, "확인")
            Return '//잘못된 인덱스는 리턴
        End If
        ' STARTTIME = Now
        '//현재 테이블에서 데이터를 표시한다. 현 테이블은 종류별로 구분지어진 테이블이다 DV
        '//모든데이터를 컨트롤에표시한후 출력물의 구분(일반용/기입등)을 짓는다.
        'Dim 선로명패턴검사 As Integer = 0
        'Dim 장척패턴검삭 As Integer = 0

        ' Me.DataGridView1.DataSource = Dv

        구관리구 = GetSpread(Me.Dv, index, "구관리구")
        구전산번호 = GetSpread(Me.Dv, index, "구전산번호")
        관리구 = GetSpread(Me.Dv, index, "관리구")
        전산번호 = GetSpread(Me.Dv, index, "전주번호")
        선로명 = 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")
        장척 = GetSpread(Me.Dv, index, "장척")
        시공년월 = GetSpread(Me.Dv, index, "시공년월")
        시공자 = GetSpread(Me.Dv, index, "시공자")
        감독자 = GetSpread(Me.Dv, index, "감독자")
        점검일자 = GetSpread(Me.Dv, index, "점검일자")

        '점검 = GetSpread(Me.Dv, index, "점검")
        '점검자 = GetSpread(Me.Dv, index, "점검자")
        '점검필 = GetSpread(Me.Dv, index, "점검필")
        '한국전력 = GetSpread(Me.Dv, index, "한국전력")
        '고장신고 = GetSpread(Me.Dv, index, "고장신고")

        접지1 = GetSpread(Me.Dv, index, "접지저항1")
        접지2 = GetSpread(Me.Dv, index, "접지저항2")
        비고명 = GetSpread(Me.Dv, index, "DL명")
        구선로명 = GetSpread(Me.Dv, index, "구선로명")
        구전주번호 = GetSpread(Me.Dv, index, "구전주번호")

        '//150201
        휴즈용량 = GetSpread(Me.Dv, index, "COS휴즈용량")
        상표시찰1단 = GetSpread(Me.Dv, index, "상표시찰1단")
        상표시찰2단 = GetSpread(Me.Dv, index, "상표시찰2단")

        '//170711
        선로전방 = GetSpread(Me.Dv, index, "선로전방")
        선로좌측 = GetSpread(Me.Dv, index, "선로좌측")
        선로우측 = GetSpread(Me.Dv, index, "선로우측")

        AddLog(Admin, "시공년월 " & Dv(index)("시공년월"), "\Alllog.txt")

        '//여기서 인쇄(지선주)의 본주번호와 본주번호를 출력한다면 찾아서 보여준다.
        'addlog(admin, "ENTERING : 지선주(본주확인)", "\Alllog.txt")
        If 번호.IndexOf("G") > -1 OrElse 번호.IndexOf("K") > -1 Then
            'addlog(admin, "지선주확인됨(" & 번호 & ")", "\Alllog.txt")
            If Me.cb_mainrow.Checked OrElse Me.cb_mainnum.Checked Then    '//본주를 보여줄일이 있을경우라면
                Dim MAINNUM As String = ""
                If 번호.IndexOf("K") > -1 Then MAINNUM = 번호.Substring(0, 번호.IndexOf("K"))
                If 번호.IndexOf("G") > -1 Then MAINNUM = 번호.Substring(0, 번호.IndexOf("G"))

                Dim MAINROW As Integer = -1
                For Z As Integer = index To 0 Step -1 '//현재부터 처음가지 확인한다.
                    If CStr(Dv(Z)("번호1") & Dv(Z)("번호2") & Dv(Z)("번호3") & Dv(Z)("번호4") & Dv(Z)("번호5")).Trim = MAINNUM Then  '//본주를 찾았다면
                        MAINROW = Dv(Z)("번호")
                        Exit For
                    End If
                Next
                For Z As Integer = index To Dv.Count - 1
                    If CStr(Dv(Z)("번호1") & Dv(Z)("번호2") & Dv(Z)("번호3") & Dv(Z)("번호4") & Dv(Z)("번호5")).Trim = MAINNUM Then  '//본주를 찾았다면
                        MAINROW = Dv(Z)("번호")
                        Exit For
                    End If
                Next
                'MsgBox("OK")
                If MAINROW <> -1 Then PARSE_본주(MAINROW, MAINNUM)
            Else
                AddLog(Admin, "지선주확인됨(" & 번호 & ") 허나 체크된게 없어서 표시를 하지 않는다.", "\Alllog.txt")
                Me.CLEAR_ITEM(Me.S본주번호)
                Me.CLEAR_ITEM(S본주전주번호)
            End If
        Else
            AddLog(Admin, "지선주아님(" & 번호 & ")", "\Alllog.txt")
            Me.CLEAR_ITEM(Me.S본주번호)
            Me.CLEAR_ITEM(S본주전주번호)
        End If
        'addlog(admin, "ENDING : 지선주(본주확인)", "\Alllog.txt")

        If 구관리구 <> "" AndAlso 구전산번호 <> "" Then
            구관리전산 = 구관리구 & "-" & 구전산번호
        Else
            구관리전산 = ""
        End If

        If 구선로명 <> "" Then
            구선로전주번호 = CStr(구선로명 & "-" & 구전주번호).Trim
        Else
            구선로전주번호 = CStr(구전주번호).Trim
        End If


        점검자 = CStr("점검자 :").Trim
        점검필 = CStr("점검필").Trim
        한국전력 = CStr("한국전력").Trim
        고장신고 = gojang.Text.ToString()


        If 선로명 <> "" Then
            신선로전주번호 = CStr(선로명 & "-" & 번호).Trim
        Else
            신선로전주번호 = CStr(번호).Trim
        End If

        구선로전주번호 = 구선로전주번호.Replace(";", "")
        신선로전주번호 = 신선로전주번호.Replace(";", "")

        AddLog(Admin, "Complete : Load Data From Dataview", "\Alllog.txt")
        Me.Text = "가공번호찰 출력작업(" & 번호 & ")"
        AddLog(Admin, "PASE구문을 실행합니다.()", "\Alllog.txt")
        '============ 여기는 따로 해석이 없는곳이다 ==========================================================


        Me.PARSE_접지1(접지1)
        Me.PARSE_접지2(접지2)
        '====================================================================================================

        AddLog(Admin, "패턴이있는 PASE 구문을 실행합니다.()", "\Alllog.txt")

        If PARSE_감독자(감독자) Then Me.PARSE_감독자패턴(감독자) '//선로명을 해석후 가져온후 패턴분석후 적용
        If PARSE_관리구(관리구) Then Me.PARSE_관리구패턴(관리구) '//선로명을 해석후 가져온후 패턴분석후 적용
        If PARSE_장척(장척) Then Me.PARSE_장척패턴(장척) '//선로명을 해석후 가져온후 패턴분석후 적용

        If Me.PARSE(선로명, Me.S선로명) Then Me.PARSE_PATTERN(선로명, Me.S선로명)
        If Me.PARSE(전산번호, Me.S전산번호) Then Me.PARSE_PATTERN(전산번호, Me.S전산번호)
        If Me.PARSE(시공년월, Me.S시공년월) Then Me.PARSE_PATTERN(시공년월, Me.S시공년월)
        If Me.PARSE(시공자, Me.S시공자) Then Me.PARSE_PATTERN(시공자, Me.S시공자)

        If Me.PARSE(점검일자, Me.S점검일자) Then Me.PARSE_PATTERN(점검일자, Me.S점검일자)

        'If Me.PARSE(점검, Me.S점검) Then Me.PARSE_PATTERN(점검, Me.S점검)

        If Me.PARSE(점검자, Me.S점검자) Then Me.PARSE_PATTERN(점검자, Me.S점검자)
        If Me.PARSE(점검필, Me.S점검필) Then Me.PARSE_PATTERN(점검필, Me.S점검필)
        If Me.PARSE(한국전력, Me.S한국전력) Then Me.PARSE_PATTERN(한국전력, Me.S한국전력)

        If Me.PARSE(고장신고, Me.S고장신고) Then Me.PARSE_PATTERN(고장신고, Me.S고장신고)

        '//1501201
        If Me.PARSE(휴즈용량, Me.S휴즈용량) Then Me.PARSE_PATTERN(휴즈용량, Me.S휴즈용량)
        If Me.PARSE(상표시찰1단, Me.S상표시찰1단) Then Me.PARSE_PATTERN(상표시찰1단, Me.S상표시찰1단)
        If Me.PARSE(상표시찰2단, Me.S상표시찰2단) Then Me.PARSE_PATTERN(상표시찰2단, Me.S상표시찰2단)

        'If PARSE_DL명(비고명) Then Me.PARSE_DL명패턴(비고명) '/비고명 추가했다.      2013/06/13 임시 막아놓음...

        If Me.PARSE(비고명, Me.S비고명) Then Me.PARSE_PATTERN(비고명, Me.S비고명)

        ' addlog(admin, "New()", "\Alllog.txt")
        If PARSE_번호(번호, GetSpread(Me.Dv, index, "인쇄")) Then    '//여기서 False 는 출력의의미가 없다
            번호패턴검사 = Me.PARSE_번호패턴(번호) '//선로명을 해석후 패턴분석 적용   
            AddLog(Admin, "번호패턴검사가 완료되었습니다.=" & 번호패턴검사, "\Alllog.txt")
            If NUMCOLOR Then    '//환경설정에서 색상보기가 선택되어있다면
                If 번호패턴검사 = 3 Then   '//둘다없다.
                    '//둘다없는 부분이라서 여기서는 디폴트를 잡아준다.
                    For i As Short = 0 To Me.S전주번호.GetUpperBound(0)
                        Me.S전주번호(i).MyForeColor = Drawing.Color.Red
                    Next
                ElseIf 번호패턴검사 = 2 Then    '//문자가없고 길이만 있다.
                    For i As Short = 0 To Me.S전주번호.GetUpperBound(0)
                        Me.S전주번호(i).MyForeColor = Drawing.Color.Green
                    Next
                Else '//문자만 있거나 둘다있다. '//0이면 이면 둘다있다 1이면 문자도 없고 길이도 없다 길이가 없다
                    For i As Short = 0 To Me.S전주번호.GetUpperBound(0)
                        Me.S전주번호(i).MyForeColor = Drawing.Color.Black
                    Next
                End If
            End If
        End If

        AddLog(Admin, "구관리전산,일련번호,관리전산표시여부를 pase 합니다.()", "\Alllog.txt")
        '========================= 기타 =================================================
        '//이러면 표시해야한다.
        'MsgBox(구관리전산)
        If 구관리전산 <> "" AndAlso Me.cb_oldjun.Checked Then
            'MsgBox("구관리전산=" & 구관리전산)
            Me.S구관리전산(0).MyText = 구관리전산
            Me.S구관리전산(0).Visible = True
        Else
            Me.S구관리전산(0).Visible = False
        End If

        If 구선로전주번호 <> "" AndAlso Me.cb_numo.Checked Then
            Me.S구선로전주번호(0).MyText = 구선로전주번호
            Me.S구선로전주번호(0).Visible = True
        Else
            Me.S구선로전주번호(0).Visible = False
        End If


        ' If chk_draw.Checked Then
        If cb_date1.Checked Then

            '//점검자
            ' If Me.cb_jumj.Checked Then
            Me.S점검자(0).MyText = 점검자
            Me.S점검자(0).Visible = True
            ' Else
            ' Me.S점검자(0).Visible = False
            ' End If
            '//점검필
            'If cb_jump.Checked Then
            Me.S점검필(0).MyText = 점검필
            Me.S점검필(0).Visible = True
            'Else
            'Me.S점검필(0).Visible = False
            'End If
            '//한국전력
            'If cb_han.Checked Then
            Me.S한국전력(0).MyText = 한국전력
            Me.S한국전력(0).Visible = True
            'Else
            ' Me.S한국전력(0).Visible = False
            'End If
            ' End If


        Else
            Me.S점검자(0).Visible = False
            Me.S점검필(0).Visible = False
            Me.S한국전력(0).Visible = False

        End If

        Me.S고장신고(0).Visible = cb_gojang.Checked

        '//150201
        Me.S휴즈용량(0).Visible = cb_휴즈용량.Checked

        If cb_상1단.Checked AndAlso 상표시찰1단 <> "" Then
            Me.S상표시찰1단(0).Visible = True
            Me.S상표시찰1단(1).Visible = True
            Me.S상표시찰1단(2).Visible = True
        Else
            Me.S상표시찰1단(0).Visible = False
            Me.S상표시찰1단(1).Visible = False
            Me.S상표시찰1단(2).Visible = False
        End If

        If cb_상2단.Checked AndAlso 상표시찰2단 <> "" Then
            Me.S상표시찰2단(0).Visible = True
            Me.S상표시찰2단(1).Visible = True
            Me.S상표시찰2단(2).Visible = True
        Else
            Me.S상표시찰2단(0).Visible = False
            Me.S상표시찰2단(1).Visible = False
            Me.S상표시찰2단(2).Visible = False
        End If

        If 신선로전주번호 <> "" AndAlso Me.cb_numn.Checked Then
            Me.S신선로전주번호(0).MyText = 신선로전주번호
            Me.S신선로전주번호(0).Visible = True
        Else
            Me.S신선로전주번호(0).Visible = False
        End If

        If Me.cb_seq.Checked Then
            Me.S일련번호(0).MyText = GetSpread(Me.Dv, index, "번호") 'index + 1
            Me.S일련번호(0).Visible = True
        Else
            Me.S일련번호(0).Visible = False
        End If
        If 관리구 <> "" AndAlso 전산번호 <> "" AndAlso Me.cb_kwanjun.Checked Then
            Me.S관리구전주번호(0).MyText = 관리구 & "-" & 전산번호
            Me.S관리구전주번호(0).Visible = True
        Else
            Me.S관리구전주번호(0).Visible = False
        End If


        'If 번호.Trim <> "" AndAlso Me.cb_jnumrow.Checked Then  '//한줄전주번호 표시여부
        '    Me.S전주번호한줄.MyText = 번호
        '    Me.S전주번호한줄.Visible = True
        'Else
        '    Me.S전주번호한줄.Visible = False
        'End If

        AddLog(Admin, "사용자문자의 표시여부를 결정합니다.()", "\Alllog.txt")
        '사용자문자의 표시여부 u a b d e
        If Not Me.cb_u1.Checked Then Me.S사용자1(0).Visible = False
        If Not Me.cb_u2.Checked Then Me.S사용자2(0).Visible = False
        If Not Me.cb_u3.Checked Then Me.S사용자3(0).Visible = False
        If Not Me.cb_u4.Checked Then Me.S사용자4(0).Visible = False
        If Not Me.cb_u5.Checked Then Me.S사용자5(0).Visible = False

        'ENDTIME = Now
        ' Me.Text = "걸린시간 = " & (ENDTIME - STARTTIME).ToString

        '휴 끝났다.......................................................
        AddLog(Admin, "Pewview 윈도우를 실행합니다.()", "\Alllog.txt")
        'Me.preview_window()
        If previewWindow Then Me.preview_window()
    End Sub

    Public Function ChkNumPattern(ByVal index As Integer) As Int16
        AddLog(Admin, "번호패턴을 체크합니다. int16을 반환합니다.()", "\Alllog.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, "번호1") & GetSpread(Me.Dv, index, "번호2") & _
        GetSpread(Me.Dv, index, "번호3") & GetSpread(Me.Dv, index, "번호4") & GetSpread(Me.Dv, index, "번호5")
        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(검사번호)

        '//먼저문자가있는지 확인한다.

        'MsgBox(검사번호 & "/" & PATTERN)


        pname = "JJNUMPATTERNII" & PATTERN

        Dim Dr() As DataRow
        Dr = dtpattern.Select("NAME = '" & pname & "DESC'")
        AddLog(Admin, "문자패턴의 존재여부 = " & Dr.GetUpperBound(0) & ":" & pname, "\Alllog.txt")
        If Dr.GetUpperBound(0) <> -1 Then '//있다.
            retval += 2
            'addlog(admin, "관리구5번 문자를 찾았습니다 (" & pname & "DESC" & ")", Log)
        End If

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

        pname = "JJNUMPATTERN" & Wlen
        Dr = dtpattern.Select("NAME = '" & pname & "DESC'")
        AddLog(Admin, "길이패턴의 존재여부 = " & Dr.GetUpperBound(0) & ";" & pname, "\Alllog.txt")
        If Dr.GetUpperBound(0) <> -1 Then '//있다.
            retval += 1
            'addlog(admin, "관리구5번 문자를 찾았습니다 (" & pname & "DESC" & ")", Log)
        End If
        Return retval '// 0이 리턴될것이다. 패턴이 모두 정상이란 뜻이다
    End Function
    Public Sub CLEAR_ITEM(ByVal labels() As MyControlOLEDBv2.MyLabel)
        WLog2(Auto_Log, "Clear_item div=", "\지중(케이블라벨)순차로그.txt")
        For i As Short = 0 To labels.GetUpperBound(0)
            labels(i).MyText = ""
            labels(i).Visible = False
        Next
    End Sub
    Public Sub GetStyleList()

        Dim wat As New System.Diagnostics.Stopwatch

        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 Common.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

        wat.Restart()
        For Each Dr As DataRow In Dt.Select("", "파일명 asc")
            Dim FileName As String = Dr("파일명")
            AddLog(Auto_Log, "파일명=(" & FileName & ") 의 스타일을 가져옵니다 메모리로", "\지중순차로그.txt")

            '//pattern table
            Common.PDS(CurIdx) = New PatternDS

            '//default setting
            Common.StyleList(CurIdx) = New SStyle()
            Common.StyleList(CurIdx).LoadOK = False
            Common.StyleList(CurIdx).Desc = String.Empty
            Common.StyleList(CurIdx).File = String.Empty


            Console.WriteLine("Getstyle List  : GetallSection File=" + FileName)
            wat.Restart()

            '//여기서는 자료를 읽지않고 목록만 처리한다.
            'GetAllsection(FileName, CurIdx)

            '//이파일의 정보를 읽는다.
            Common.StyleList(CurIdx).File = FileName

            Dim ini As New tinyIni(FileName)
            Common.StyleList(CurIdx).Desc = ini.Read("STYLE", "DESC")


            Console.WriteLine("Getstyle List  : GetallSection + " + wat.ElapsedMilliseconds.ToString() + "ms")
            wat.Restart()

            Me.cmb_style.Items.Add(Common.StyleList(CurIdx).Desc)
            CurIdx += 1
        Next
        wat.Stop()

    End Sub

    Private Sub 데이터테이블갱신()
        AddLog(Admin, "데이터테이블 갱신()", "\Alllog.txt")
        GetAllsection(DrStyle.FILE, Me.cmb_style.SelectedIndex)

        '//다시설정 170222
        DrStyle = Common.PDS(cmb_style.SelectedIndex).TStyle.Rows(0)
        DtPattern = Common.PDS(cmb_style.SelectedIndex).TPattern
    End Sub

    Private Function Prepare_Print() As Boolean '//범위내의 페이지번호와 일치하는 번호를 찾아서 배열에 할당한다.
        AddLog(Admin, "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.rad_print_area.Checked AndAlso Me.tb_printrange.Text.Trim = "" Then Me.rad_print_cur.Checked = True


        If Me.rad_print_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.rad_print_all.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.rad_print_cur.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.rad_print_area.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()
        AddLog(Admin, "print_preview 미리보기 버튼을 눌렀을때다.()", "\Alllog.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_print_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_BgImageprint.Checked AndAlso Me.chk_DisplayBG.Checked AndAlso Not Me.bakimg.BackgroundImage Is Nothing Then
            If Me.PrintMode = False Then    '//미리보기일때  인쇄마진을 넣지않는다.
                e.Graphics.DrawImage(Me.bakimg.BackgroundImage, CInt(Me.tb_bakx.Text), CInt(Me.tb_baky.Text), CInt(Me.tb_bakw.Text), CInt(Me.tb_bakh.Text))   '//배경그림
            Else
                e.Graphics.DrawImage(Me.bakimg.BackgroundImage, CInt(Me.tb_bakx.Text) + CInt(Me.tb_marginx.Text), CInt(Me.tb_baky.Text) + CInt(Me.tb_marginy.Text), CInt(Me.tb_bakw.Text), CInt(Me.tb_bakh.Text))   '//배경그림
            End If
        End If
        If Me.chk_draw.Checked Then
            '//라인을 그린다.
            For Each Rect As S_Line In Draw_Line

                If Rect.Field <> "" Then
                    Select Case Rect.Field
                        Case "COS휴즈용량"
                            If Me.휴즈용량 = "" OrElse Not cb_휴즈용량.Checked Then
                                Continue For
                            End If
                        Case "상표시찰1단"
                            If Me.상표시찰1단 = "" OrElse Not cb_상1단.Checked Then
                                Continue For
                            End If
                        Case "상표시찰2단"
                            If Me.상표시찰2단 = "" OrElse Not cb_상2단.Checked Then
                                Continue For
                            End If
                        Case "점검일자"
                            If Me.점검일자 = "" OrElse Not cb_date.Checked Then
                                Continue For
                            End If
                        Case "선로전방"
                            If Me.선로전방 = "" Then
                                Continue For
                            End If
                        Case "선로좌측"
                            If Me.선로좌측 = "" Then
                                Continue For
                            End If
                        Case "선로우측"
                            If Me.선로우측 = "" Then
                                Continue For
                            End If

                    End Select
                End If

                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

                If Rect.Field <> "" Then
                    Select Case Rect.Field
                        Case "COS휴즈용량"
                            If Me.휴즈용량 = "" OrElse Not cb_휴즈용량.Checked Then
                                Continue For
                            End If
                        Case "상표시찰1단"
                            If Me.상표시찰1단 = "" OrElse Not cb_상1단.Checked Then
                                Continue For
                            End If
                        Case "상표시찰2단"
                            If Me.상표시찰2단 = "" OrElse Not cb_상2단.Checked Then
                                Continue For
                            End If
                        Case "점검일자"
                            If Me.점검일자 = "" OrElse Not cb_date.Checked Then
                                Continue For
                            End If
                        Case "선로전방"
                            If Me.선로전방 = "" Then
                                Continue For
                            End If
                        Case "선로좌측"
                            If Me.선로좌측 = "" Then
                                Continue For
                            End If
                        Case "선로우측"
                            If Me.선로우측 = "" Then
                                Continue For
                            End If
                    End Select
                End If

                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

                If Rect.Field <> "" Then
                    Select Case Rect.Field
                        Case "COS휴즈용량"
                            If Me.휴즈용량 = "" OrElse Not cb_휴즈용량.Checked Then
                                Continue For
                            End If
                        Case "상표시찰1단"
                            If Me.상표시찰1단 = "" OrElse Not cb_상1단.Checked Then
                                Continue For
                            End If
                        Case "상표시찰2단"
                            If Me.상표시찰2단 = "" OrElse Not cb_상2단.Checked Then
                                Continue For
                            End If
                        Case "점검일자"
                            If Me.점검일자 = "" OrElse Not cb_date.Checked Then
                                Continue For
                            End If
                        Case "선로전방"
                            If Me.선로전방 = "" Then
                                Continue For
                            End If
                        Case "선로좌측"
                            If Me.선로좌측 = "" Then
                                Continue For
                            End If
                        Case "선로우측"
                            If Me.선로우측 = "" Then
                                Continue For
                            End If
                    End Select
                End If

                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
            '//그림을 그린다.
            For Each Rect As S_Image In Draw_Image

                If Rect.Field <> "" Then
                    Select Case Rect.Field
                        Case "COS휴즈용량"
                            If Me.휴즈용량 = "" OrElse Not cb_휴즈용량.Checked Then
                                Continue For
                            End If
                        Case "상표시찰1단"
                            If Me.상표시찰1단 = "" OrElse Not cb_상1단.Checked Then
                                Continue For
                            End If
                        Case "상표시찰2단"
                            If Me.상표시찰2단 = "" OrElse Not cb_상2단.Checked Then
                                Continue For
                            End If
                        Case "점검일자"
                            If Me.점검일자 = "" OrElse Not cb_date.Checked Then
                                Continue For
                            End If
                        Case "선로전방"
                            If Me.선로전방 = "" Then
                                Continue For
                            End If
                        Case "선로좌측"
                            If Me.선로좌측 = "" Then
                                Continue For
                            End If
                        Case "선로우측"
                            If Me.선로우측 = "" Then
                                Continue For
                            End If
                    End Select
                End If

                Dim F As String = Rect.FileName
                If F.Trim <> "" Then
                    F = F.Replace(".\", My.Application.Info.DirectoryPath & "\")

                    If System.IO.File.Exists(F) Then
                        Dim Image As Image = Image.FromFile(F)
                        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, Rect.Y)
                        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
                    End If
                End If
            Next


            '//화살표를 그린다. 170711
            For Each Rect As S_Arrow In Draw_Arrow

                Select Case Rect.Direction
                   
                    Case 0
                        If Me.선로전방 = "" Then
                            Continue For
                        End If
                    Case 1
                        If Me.선로좌측 = "" Then
                            Continue For
                        End If
                    Case 2
                        If Me.선로우측 = "" Then
                            Continue For
                        End If
                End Select

                '//각포인트를 생성한다.
                Dim pts As New List(Of Point)

                If Rect.Direction = 1 Then '//좌측
                    pts.Add(New Point(Rect.RectX - Rect.TriWidth, Rect.RectY + Rect.RectH / 2))
                    pts.Add(New Point(Rect.RectX, Rect.RectY - Rect.TriHeight))

                    pts.Add(New Point(Rect.RectX, Rect.RectY))
                    pts.Add(New Point(Rect.RectX + Rect.RectW, Rect.RectY))
                    pts.Add(New Point(Rect.RectX + Rect.RectW, Rect.RectY + Rect.RectH))
                    pts.Add(New Point(Rect.RectX, Rect.RectY + Rect.RectH))

                    pts.Add(New Point(Rect.RectX, Rect.RectY + Rect.RectH + Rect.TriHeight))
                    pts.Add(New Point(Rect.RectX - Rect.TriWidth, Rect.RectY + Rect.RectH / 2))

                ElseIf Rect.Direction = 2 Then '//우측

                    pts.Add(New Point(Rect.RectX, Rect.RectY))
                    pts.Add(New Point(Rect.RectX + Rect.RectW, Rect.RectY))

                    pts.Add(New Point(Rect.RectX + Rect.RectW, Rect.RectY - Rect.TriHeight))
                    pts.Add(New Point(Rect.RectX + Rect.RectW + Rect.TriWidth, Rect.RectY + Rect.RectH / 2))
                    pts.Add(New Point(Rect.RectX + Rect.RectW, Rect.RectY + Rect.RectH + Rect.TriHeight))

                    pts.Add(New Point(Rect.RectX + Rect.RectW, Rect.RectY + Rect.RectH))
                    pts.Add(New Point(Rect.RectX, Rect.RectY + Rect.RectH))

                    pts.Add(New Point(Rect.RectX, Rect.RectY))

                ElseIf Rect.Direction = 0 Then '//전방

                    pts.Add(New Point(Rect.RectX, Rect.RectY + Rect.RectH))
                    pts.Add(New Point(Rect.RectX, Rect.RectY))

                    pts.Add(New Point(Rect.RectX - Rect.TriWidth, Rect.RectY))

                    pts.Add(New Point(Rect.RectX + Rect.RectW / 2, Rect.RectY - Rect.TriHeight))

                    pts.Add(New Point(Rect.RectX + Rect.RectW + Rect.TriWidth, Rect.RectY))
                    pts.Add(New Point(Rect.RectX + Rect.RectW, Rect.RectY))

                    pts.Add(New Point(Rect.RectX + Rect.RectW, Rect.RectY + Rect.RectH))
                    pts.Add(New Point(Rect.RectX, Rect.RectY + Rect.RectH))

                End If

                If Me.PrintMode Then
                    For i As Integer = 0 To pts.Count - 1
                        Dim pt As Point = pts(i)
                        pt.X += CInt(Me.tb_marginx.Text)
                        pts(i) = pt
                    Next
                    '  e.Graphics.DrawEllipse(Pen, Rect.X + CInt(Me.tb_marginx.Text), Rect.Y + CInt(Me.tb_marginy.Text), Rect.Width, Rect.Height)

                End If

                Dim Pen As New Drawing.SolidBrush(Rect.PenColor)
                e.Graphics.FillPolygon(Pen, pts.ToArray())

            Next

            If 관리구 <> "" Then
                '//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

                    Try
                        'data = q시공자 & q홈페이지 & q관리 & q관리1 & q관리2
                        data = qr홈페이지1 & "/" & qr홈페이지2 & "/" & qr홈페이지3 & "/" & qr홈페이지4 & "=" & 관리구 & "-" & 전산번호 & "&name=" & 신선로전주번호 & ":" & 장척 & "M" ' 시공자: " & 시공자 & " 감독자 : " & 감독자
                        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)
                        'MessageBox.Show("구관리구 : " & 구관리구 & "구전산번호 : " & 구전산번호 & "관리구 : " & 관리구 & "전산번호 : " & 전산번호 & "선로명 : " & 선로명 & "번호 : " & 번호 & "장척 : " & 장척 & "시공년월 : " & 시공년월 & "시공장 : " & 시공자 & "감독자 : " & 감독자 & "점검일자 : " & 점검일자 & "접지1 : " & 접지1 & "접지2 : " & 접지2 & "DI명 : " & Dl명 & "본주번호 : " & 본주번호 & "본주전주번호 : " & 본주전주번호 & "전주번호한줄 : " & 전주번호한줄 & "구관선로전주번호 : " & 구선로전주번호 & "신서로전주번호 : " & 신선로전주번호 & "구선로명 : " & 구선로명 & "구전주번호 : " & 구전주번호)
                        '위의 MBOX는 어떤 항목인지를 확인하기 위함이다..


                        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
                    Catch ex As Exception
                        MessageBox.Show("QR코드를 그리는데 그리려는 DATA가 숫자인지 영숫자인지 모두인지 확인 후 선택하여 주세요")
                    End Try

                    '   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
            End If
        End If


        For Each Rect As S_QRCode1 In Draw_QRcode1
            '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

            rqr기타1 = gita1.Text
            rqr기타2 = gita2.Text
            rqr기타3 = gita3.Text
            rqr기타4 = gita4.Text

            Try
                'data = q시공자 & q홈페이지 & q관리 & q관리1 & q관리2
                If rqr기타1 <> "" And rqr기타2 <> "" And rqr기타3 <> "" And rqr기타4 <> "" Then
                    data = rqr기타1 & "/" & rqr기타2 & "/" & rqr기타3 & "/" & rqr기타4
                ElseIf rqr기타1 <> "" And rqr기타2 <> "" And rqr기타3 <> "" Then
                    data = rqr기타1 & "/" & rqr기타2 & "/" & rqr기타3
                ElseIf rqr기타1 <> "" And rqr기타2 <> "" Then
                    data = rqr기타1 & "/" & rqr기타2
                ElseIf rqr기타1 <> "" Then
                    data = rqr기타1
                Else
                    data = rqr기타1 & "/" & rqr기타2 & "/" & rqr기타3 & "/" & rqr기타4
                End If

                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)
                'MessageBox.Show("구관리구 : " & 구관리구 & "구전산번호 : " & 구전산번호 & "관리구 : " & 관리구 & "전산번호 : " & 전산번호 & "선로명 : " & 선로명 & "번호 : " & 번호 & "장척 : " & 장척 & "시공년월 : " & 시공년월 & "시공장 : " & 시공자 & "감독자 : " & 감독자 & "점검일자 : " & 점검일자 & "접지1 : " & 접지1 & "접지2 : " & 접지2 & "DI명 : " & Dl명 & "본주번호 : " & 본주번호 & "본주전주번호 : " & 본주전주번호 & "전주번호한줄 : " & 전주번호한줄 & "구관선로전주번호 : " & 구선로전주번호 & "신서로전주번호 : " & 신선로전주번호 & "구선로명 : " & 구선로명 & "구전주번호 : " & 구전주번호)
                '위의 MBOX는 어떤 항목인지를 확인하기 위함이다..


                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
            Catch ex As Exception
                MessageBox.Show("QR코드를 그리는데 그리려나는 DATA가 숫자인지 영숫자인지 모두인지 확인 후 선택하여 주세요")
            End Try

        Next




        '//연속페이지 오류정정
        If Me.tb_pagerepeat.Text = "" Or Me.tb_pagerepeat.Text < 1 Then Me.tb_pagerepeat.Text = "1"
        For pi As Short = 0 To Me.tb_pagerepeat.Text - 1  '//페이지당 연속출력할 횟수
            For i As Integer = 0 To Me.AllLabels.GetUpperBound(0)
                C = Me.AllLabels(i).ctl
                If C.Visible = True AndAlso C.MyText <> "" Then
                    For rcnt As Short = 0 To C.Repeat   '//반복기능추가
                        '//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)

                        NewLeft = C.Left + IIf(Me.PrintMode, Me.tb_marginx.Text, 0) + Me.tb_secX.Text * pi + rcnt * C.RepeatX
                        NewTop = C.Top + IIf(Me.PrintMode, Me.tb_marginy.Text, 0) + Me.tb_secY.Text * pi + rcnt * C.RepeatY

                        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
                    Next
                End If
            Next

            '//한데이터출력하고나서 반복페에지횟수가 있는지확인한다.
            If Me.tb_pagerepeat.Text > 1 Then
                ' If Me.cmb_dummy.SelectedIndex <> 0 Then '//다음데이터의 출력이면 여기서 데이터를 갱신해준다.
                If Me.cmb_dummy.SelectedIndex <> 0 Then   '//다음장이있다.
                    If Me.printindex >= 0 AndAlso Me.printindex < Me.PrintArray.GetUpperBound(0) Then

                        '//루프가 끝낫는지 추가체크한다.  170308
                        If pi < Me.tb_pagerepeat.Text - 1 Then
                            Me.printindex += 1 '/1장넘기고 
                            If Me.cmb_dummy.SelectedIndex <> 0 AndAlso Me.rad_print_repeat.Checked = False Then
                                '   MsgBox("다음데이터갱신")
                                Me.GeTviewData(Me.PrintArray(Me.printindex), False) '//데이터 바꾸는데..화면은 갱신하지 않는다.
                            End If
                        End If
                    Else   '//다음장의 출력인데 데이터가없다면 루프를 더이상 돌면안된다.
                        Exit For
                    End If
                End If
            End If
        Next   '//pi 반복할거를 모두 출력했을시에

        If Me.printindex >= 0 AndAlso Me.printindex < Me.PrintArray.GetUpperBound(0) Then   '//다음장이있다.
            If Me.tb_pagerepeat.Text < 2 Then
                Me.printindex += 1 '//페이지번호를 증가
            Else
                Me.printindex += 1
            End If
            e.HasMorePages = True
        Else
            e.HasMorePages = False
        End If
        e.Graphics.Dispose()
    End Sub
    Private Sub Print()
        If MsgBox("인쇄를 하시겠습니까?", MsgBoxStyle.Information + MsgBoxStyle.OkCancel, "확인") = MsgBoxResult.Ok Then
            AddLog(Admin, "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)
        AddLog(Admin, "con _move 개체이동할 프로시져인데 현재 안쓴다.()", "\Alllog.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)
        AddLog(Admin, "view properfty  개체의 상태보기()", "\Alllog.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.tb_rep.Text = sender.Repeat.ToString
        Me.tb_repx.Text = sender.RepeatX.ToString
        Me.tb_repy.Text = sender.RepeatY.ToString

        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.chk_DisplayBG.Checked = False
        ElseIf Me.chk_DisplayBG.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 chk_DisplayBG.CheckedChanged
        AddLog(Admin, "배경보기 체크박스를 클릭했다.)", "\Alllog.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
        AddLog(Admin, "파일찾기 버튼이 클릭됨", "\Alllog.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.chk_DisplayBG.Checked = True
        Me.ViewBackImage() '//배경이밎표시

    End Sub

    Public Sub CtrPos(ByVal vertical As Boolean, ByVal offset As Short)
        AddLog(Admin, "ctrpos (선택된 개체들의 위치값을 변경합니다)", "\Alllog.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

        AddLog(Admin, "ctrpos =[ preview 호출합니다]", "\Alllog.txt")
        Me.preview_window()
        'Me.ViewProperty(sender)
    End Sub

    Private Sub ShowMsg(ByVal Message As String)
        AddLog(Admin, "showmsg 메세지를 보여줍니다 =" & Message, "\Alllog.txt")
        Me.lb_msg.Text = "▷ " & Message & Space(1) & TimeOfDay.ToString
    End Sub

    Public Sub SetFont()   '//체크박스 상태에따라서 폰트를 변경합니다.
        AddLog(Admin, "set font 체크박스 상태에 따라서 폰트를 변경합니다.", "\Alllog.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
        AddLog(Admin, "setfont = preview 호출합니다.", "\Alllog.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
        AddLog(Admin, "스타일콤보박스에서 keyip 이 감지되었으나 핸들을 true 로 해버린다.", "\Alllog.txt")
        e.Handled = True
    End Sub

    Private Sub cmb_style_MouseUp(ByVal sender As Object, ByVal e As System.Windows.Forms.MouseEventArgs) Handles cmb_style.MouseUp

    End Sub


    Private Sub cmb_style_SelectedIndexChanged(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles cmb_style.SelectedIndexChanged

        Dim wat As New System.Diagnostics.Stopwatch
        wat.Restart()


        AddLog(Admin, "→ Change : Style Index...", "\Alllog.txt")
        If Me.cmb_style.SelectedIndex < 0 Then Me.cmb_style.SelectedIndex = 0

        Console.WriteLine("style index changed")

        '//스타일이 로딩되지 않았다면 로딩을 먼저한다.
        If Not Common.StyleList(cmb_style.SelectedIndex).LoadOK Then


            GetAllsection(Common.StyleList(cmb_style.SelectedIndex).File, cmb_style.SelectedIndex)
            Common.StyleList(cmb_style.SelectedIndex).LoadOK = True


        End If

        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

        Console.WriteLine("Style Index Changed :: filter=" + DataFilter)

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

        Dv = New DataView(srcTable, DataFilter, "정렬번호,번호", DataViewRowState.CurrentRows)

        Dim AlphaPos As Short = 0
        If Me.cmb_style.Text.IndexOf("중규격") >= 0 Then
            'MsgBox("중규격서렂ㅇ")
            Dim Fullnum As String
            Dim TDT As DataTable = Dv.ToTable
            For Each DR As DataRow In TDT.Rows  '//각행의 값을 가지고 판단한다.
                Fullnum = CStr(DR("번호1") & DR("번호2") & DR("번호3") & DR("번호4") & DR("번호5")).Trim
                If Fullnum.Length = 6 Then   '//즉 6자리일경우에 판단한다.
                    '//에를들어 34R213  이런경우이다 허나 34R1R2이런경우도있고 1R1231 그럼 뒤에서부터 발견된 알파벳다음으로 3자리가 잇으면안된다.
                    '//asc 가 57보다크면 알파벳이라한다.
                    For i As Integer = 0 To Fullnum.ToCharArray.GetUpperBound(0)
                        If Asc(Fullnum.ToCharArray()(i)) > 57 Then AlphaPos = i '//여기서 마지막 알파벳의 위치가 정해진다.
                    Next
                    DR("기입") = IIf(AlphaPos <= 2, True, False)
                Else
                    DR("기입") = True
                End If
            Next
            Dv = New DataView(TDT, "", "정렬번호,번호", DataViewRowState.CurrentRows)
        ElseIf Me.cmb_style.Text.IndexOf("활입주") >= 0 Then '//활입주는 H외의 알파벳이 있으면안되는 H가 들어간거다
            Dim Fullnum As String
            Dim TDT As DataTable = Dv.ToTable
            For Each DR As DataRow In TDT.Rows  '//각행의 값을 가지고 판단한다.
                Fullnum = CStr(DR("번호1") & DR("번호2") & DR("번호3") & DR("번호4") & DR("번호5")).ToUpper.Trim
                If Fullnum.IndexOf("H") >= 0 Then '//일단 H 가 있어야한다.
                    DR("기입") = True
                    For i As Integer = 0 To Fullnum.ToCharArray.GetUpperBound(0)
                        If Asc(Fullnum.ToCharArray()(i)) > 57 AndAlso Fullnum.ToCharArray()(i) <> "H" Then '//문자인데   H 가아니면 false
                            DR("기입") = False
                            Exit For
                        End If
                    Next
                Else
                    DR("기입") = False
                End If
            Next
            Dv = New DataView(TDT, "기입=true", "정렬번호,번호", DataViewRowState.CurrentRows)
        End If


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

        Console.WriteLine("Change Style 준비시간 : " + wat.ElapsedMilliseconds.ToString() + "ms")

        If Dv.Count <= 0 Then '//데이터가없다면
            MsgBox(Me.cmb_style.Text & "에 해당하는 데이터가존재하지 않습니다" & vbCrLf & vbCrLf & "다른 스타일을 선택하세요", MsgBoxStyle.Information, "확인")
            Me.PictureBox1.Refresh()
        Else
            AddLog(Admin, "FindData : Count = " & Dv.Count, "\Alllog.txt")
            Me.TB_Pattern_End.Text = Dv.Count - 1 '//패턴검사시 종료카운터이다...
            Me.VScrollBar1.Minimum = 0  '//스크롤바가 잘 안움직인다.(차후에 수정요망)
            Me.VScrollBar1.Maximum = Dv.Count - 1
            Me.LOAD_STYLE()   '//스타일불러오기(여기서 모든컨트롤의 기본 위치와 글꼴이 결정된다)

            Console.WriteLine("Change Style Loading 시간 : " + wat.ElapsedMilliseconds.ToString() + "ms")

            Debug.Print("스크롤바값 설정 " & Me.VScrollBar1.Minimum & "/" & Me.VScrollBar1.Maximum)
            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
            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
                AddLog(Admin, "View : First Record // Set = 0", "\Alllog.txt")
            Else    '//index is not first
                AddLog(Admin, "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

        Console.WriteLine("Change Style 전체 시간 : " + wat.ElapsedMilliseconds.ToString() + "ms")
        wat.Stop()


        'addlog(admin, "cmb_style selectindexchanged 에서 preview 를 호출함", "\Alllog.txt")
        'Me.preview_window()
    End Sub

    Public Sub LOAD_STYLE(Optional ByVal Div As String = "Z")   '//저장된 스타일을 불러옵니다.     



        If Div = "Z" Then
            Console.WriteLine("Load Style ** 모든 라벨을 불러옵니다 ** : Z")
        Else
            Console.WriteLine("Load Style : 개별항목 불러오기 DIV=" + Div)
        End If

        AddLog(Admin, "load_style : 스타일을 불러옵니다. div= " & Div, "\Alllog.txt")

        Dim pos(), font(), visible, mytext As String
        Dim Tobj As MyControlOLEDBv2.MyLabel
        Dim DR() As DataRow
        Dim idx As Integer = 0

        ''//기존템의 정보를 모두 클리어한다.
        '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)
            Tobj = Me.AllLabels(i).ctl
            '  f.ProgressBar1.Value += 1
            If Div.ToUpper = "Z" OrElse Tobj.Name.ToUpper.StartsWith(Div) Then '//모든아이템을 가져오고

                Tobj.Location = New Point(0, 0)
                Tobj.Size = New Size(10, 10)
                Tobj.장평 = 10
                Tobj.장높이 = 10
                Tobj.MyFont = Me.Font
                Tobj.Visible = False
                'Tobj.MyText = String.Empty '//글자는 parse 에서 할당된 상태이므로 제거하면안된다.
                Tobj.공백 = 0
                Tobj.Repeat = False
                Tobj.RepeatX = 0
                Tobj.RepeatY = 0
            End If
        Next

        'f.ProgressBar1.Value = 0
        'f.Label1.Text = "스타일을 불러옵니다"
        'f.Show()
        'Application.DoEvents()

        '//모든아이템을 돈다
        For i As Integer = 0 To Me.AllLabels.GetUpperBound(0)   '//모든아이템을 돈다.

            'f.ProgressBar1.Value = i + 1
            'f.ProgressBar1.Refresh()

            Tobj = Me.AllLabels(i).ctl
            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

                DR = DtPattern.Select("NAME = 'STYLE" & Tobj.Name.ToUpper & "REPEAT'")
                If DR.GetUpperBound(0) = 0 Then
                    Dim strdata() As String = DR(0)(1).ToString.Split(",")
                    Tobj.Repeat = CInt(strdata(0))
                    Tobj.RepeatX = CInt(strdata(1))
                    Tobj.RepeatY = CInt(strdata(2))
                Else
                    Tobj.Repeat = False
                    Tobj.RepeatX = 0
                    Tobj.RepeatY = 0
                End If


            Else    '//특정아이템구분일때 

                If Tobj.Name.ToUpper.StartsWith(Div) Then
                    If Div.ToUpper = "H" Then   '//H의경우는 따로 찾아본다.
                        If Me.관리구조작됨 = True 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

                            DR = DtPattern.Select("NAME = 'STYLE" & Tobj.Name.ToUpper & "REPEAT'")
                            If DR.GetUpperBound(0) = 0 Then
                                Dim strdata() As String = DR(0)(1).ToString.Split(",")
                                Tobj.Repeat = CInt(strdata(0))
                                Tobj.RepeatX = CInt(strdata(1))
                                Tobj.RepeatY = CInt(strdata(2))
                            Else
                                Tobj.Repeat = False
                                Tobj.RepeatX = 0
                                Tobj.RepeatY = 0
                            End If
                        End If

                    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

                        DR = DtPattern.Select("NAME = 'STYLE" & Tobj.Name.ToUpper & "REPEAT'")
                        If DR.GetUpperBound(0) = 0 Then
                            Dim strdata() As String = DR(0)(1).ToString.Split(",")
                            Tobj.Repeat = CInt(strdata(0))
                            Tobj.RepeatX = CInt(strdata(1))
                            Tobj.RepeatY = CInt(strdata(2))
                        Else
                            Tobj.Repeat = False
                            Tobj.RepeatX = 0
                            Tobj.RepeatY = 0
                        End If
                    End If
                End If
            End If

        Next

        'f.Label1.Text = "기타정보를 불러옵니다"
        'f.Refresh()

        If Div.ToUpper <> "Z" Then Return '//모든템이아니다
        AddLog(Admin, "load_style 기본값 체크박스등의 값을 불러온다. 이것은 맨첨에만 불러오면 된다. ", "\Alllog.txt")

        Dim Arinini As New MyINI2(DrStyle.FILE)
        '''''''''''''''''''''우측 스타일 체크박스를 가져온다.
        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.ToString, 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.ToString, False)  '//기본값 false
            End If
        Next
        For Each B As Control In Me.TabPage5.Controls
            If B.GetType.Name.ToUpper = "CHECKBOX" Then '//체크박스라면 태그를 저장한다.
                CType(B, Windows.Forms.CheckBox).Checked = Arinini.Read("STYLE", B.Name.ToString, 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중
        '//더미는 이제 사용하지않는다.20090729 변경
        'Dim UseDummy As Boolean = StyleList(Me.cmb_style.SelectedIndex).Dummy 'Arinini.Read("STYLE", "dummy", False)
        'Try
        Me.tb_pagerepeat.Text = DrStyle.DUMMYCNT
        If Me.tb_pagerepeat.Text.Trim = "" OrElse Me.tb_pagerepeat.Text < 1 Then Me.tb_pagerepeat.Text = "1"
        'Catch ex As Exception
        '    If UseDummy Then
        '        Me.tb_pagerepeat.Text = "2"
        '    Else
        '        Me.tb_pagerepeat.Text = "1"
        '    End If
        'End Try


        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")



        '//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


        '//QR기타 출력부분
        Me.gita1.Text = Arinini.Read("STYLE", "rqrgita1", "")
        Me.gita2.Text = Arinini.Read("STYLE", "rqrgita2", "")
        Me.gita3.Text = Arinini.Read("STYLE", "rqrgita3", "")
        Me.gita4.Text = Arinini.Read("STYLE", "rqrgita4", "")

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


        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.chk_DisplayBG.Checked = DrStyle.VIEWIMAGE ' Arinini.Read("STYLE", "ViewImage", True)
        Me.tb_myfontsize.Text = DrStyle.PRINTFONTOFFSET    ' Arinini.Read("STYLE", "PrintFontOffset", 0)
        NOTICE(Me.cmb_style.Text & "스타일을 불러왔습니다.", Me.lb_msg)


        Application.DoEvents()

    End Sub



    Public Sub SAVE_STYLE()
        AddLog(Admin, "ini파일에 스타일을 저장합니다. ", "\Alllog.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
        '//현재 선택된 스타일을 저장합니다.
        If Me.cmb_style.SelectedIndex < 0 Then
            erp.SetError(Me.cmb_style, "저장할 스타일이 선택되어있지 않습니다")
            NOTICE("스타일을 선택하세요", Me.lb_msg)
            Return
        End If
        erp.SetError(Me.cmb_style, vbNullString)

        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()



        Dim Div As Char

        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.공백)
            Arinini.Write("STYLE", Tobj.Name & "repeat", Tobj.Repeat.ToString() + "," + Tobj.RepeatX.ToString() + "," + Tobj.RepeatY.ToString()) '//170222
            Select Case Tobj.Name.ToUpper.Substring(0, 1)
                Case "U", "A", "B", "D", "E", "Z"
                    Arinini.Write("STYLE", Tobj.Name & "mytext", TextEnc(Tobj.MyText))
                Case "F", "I", "T"
                    ' Debug.WriteLine("new datarow")
            End Select

            Div = Tobj.Name.Substring(0, 1) '1자리만끊어서 체크박스 태그랑 연결한다.
            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.ToString, 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.ToString, CType(B, Windows.Forms.CheckBox).Checked) 'A.Visible)
        '    End If
        'Next

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

        Arinini.Write("STYLE", "CanvasX", Me.PictureBox1.Width)  '//캔버스사이즈저장한다.
        Arinini.Write("STYLE", "CanvasY", Me.PictureBox1.Height)

        Arinini.Write("STYLE", "ViewImage", Me.chk_DisplayBG.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", "dummycnt", Me.tb_pagerepeat.Text)
        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)


        '//QR기타
        Arinini.Write("STYLE", "rqrgita1", Me.gita1.Text)
        Arinini.Write("STYLE", "rqrgita2", Me.gita2.Text)
        Arinini.Write("STYLE", "rqrgita3", Me.gita3.Text)
        Arinini.Write("STYLE", "rqrgita4", Me.gita4.Text)

        Arinini.Write("STYLE", "gojang1", 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)
        AddLog(Admin, "save style 완료후 데이터테이블 갱신을 호춣 ", "\Alllog.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, IncludeH As Boolean, Optional ByVal LOGFILENAME As String = "\패턴.TXT")   '패턴을 저장합니다. 패턴역시 위치/크기/장평등이 저장됩니다.

        '//이곳은 문자패턴을 저장한다.
        Dim Arinini As New MyINI2(DrStyle.FILE)
        Dim BUF() As Char = SRCSTR.ToCharArray
        Dim mb As String = PATTERN_ENC(SRCSTR, IncludeH) '//h 여부에따라서 저장된 패턴명이 달라지게된다. 후에 찾을떄 h를 변환한걸 먼저 찾은후 처리하게한다
        Dim TOBJ As MyControlOLEDBv2.MyLabel
        Dim Pname As String = MIDNAME & mb.ToString

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


        Dim f As New fProgress()
        f.ProgressBar1.Minimum = 0
        f.ProgressBar1.Maximum = 0
        f.ProgressBar1.Style = ProgressBarStyle.Blocks
        f.Label1.Text = String.Format("패턴({0})을 저장합니다" + vbCrLf + MIDNAME, DIV)
        f.TopMost = True
        f.Show()
        Application.DoEvents()


        AddLog(Admin, " save_pattern2" + IIf(IncludeH, "(H)", "") + " 를 실행한다.", "\Alllog.txt")

        Select Case DIV.ToString.ToUpper
            Case "M"    '//감독자

                f.ProgressBar1.Maximum = S감독자.Length
                f.ProgressBar1.Value = 0
                f.Refresh()


                For i As Integer = 0 To Me.S감독자.GetUpperBound(0)
                    TOBJ = Me.S감독자(i)
                    ' AddLog(Admin, MIDNAME & "패턴저장시 아이템=" & TOBJ.Name & "/" & TOBJ.Name.Substring(0, 1).ToUpper, LOGFILENAME)
                    Arinini.Write(Pname, "DESC", "저장된 문자패턴 " & MIDNAME)
                    ' AddLog(Admin, "최종선택완료=" & 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.공백)
                    f.ProgressBar1.Value += 1
                Next
                Arinini.Write(Pname, "LineType1", Me.tb_ntype.Text)
                Arinini.Write(Pname, "nseparate1", Me.cmb_sep.SelectedIndex)
            Case "J"    '//장척 170215

                f.ProgressBar1.Maximum = S장척.Length
                f.ProgressBar1.Value = 0
                f.Refresh()

                For i As Integer = 0 To Me.S장척.GetUpperBound(0)
                    TOBJ = Me.S장척(i)
                    'AddLog(Admin, MIDNAME & "패턴저장시 아이템=" & TOBJ.Name & "/" & TOBJ.Name.Substring(0, 1).ToUpper, LOGFILENAME)
                    Arinini.Write(Pname, "DESC", "저장된 문자패턴 " & MIDNAME)
                    ' AddLog(Admin, "최종선택완료=" & 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.공백)
                    f.ProgressBar1.Value += 1
                Next
            Case "L"    '//선로명

                f.ProgressBar1.Maximum = S선로명.Length
                f.ProgressBar1.Value = 0
                f.Refresh()

                For i As Integer = 0 To Me.S선로명.GetUpperBound(0)
                    TOBJ = Me.S선로명(i)
                    'AddLog(Admin, MIDNAME & "패턴저장시 아이템=" & TOBJ.Name & "/" & TOBJ.Name.Substring(0, 1).ToUpper, LOGFILENAME)
                    Arinini.Write(Pname, "DESC", "저장된 문자패턴 " & MIDNAME)
                    'AddLog(Admin, "최종선택완료=" & 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.공백)
                    f.ProgressBar1.Value += 1
                Next
            Case "C"    '//선로명

                f.ProgressBar1.Maximum = S시공자.Length
                f.ProgressBar1.Value = 0
                f.Refresh()

                For i As Integer = 0 To Me.S시공자.GetUpperBound(0)
                    TOBJ = Me.S시공자(i)
                    'AddLog(Admin, MIDNAME & "패턴저장시 아이템=" & TOBJ.Name & "/" & TOBJ.Name.Substring(0, 1).ToUpper, LOGFILENAME)
                    Arinini.Write(Pname, "DESC", "저장된 문자패턴 " & MIDNAME)
                    'AddLog(Admin, "최종선택완료=" & 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.공백)
                    f.ProgressBar1.Value += 1
                Next
            Case "K"    '//dl명

                f.ProgressBar1.Maximum = S비고명.Length
                f.ProgressBar1.Value = 0
                f.Refresh()

                For i As Integer = 0 To Me.S비고명.GetUpperBound(0)
                    TOBJ = Me.S비고명(i)
                    ' AddLog(Admin, MIDNAME & "패턴저장시 아이템=" & TOBJ.Name & "/" & TOBJ.Name.Substring(0, 1).ToUpper, LOGFILENAME)
                    Arinini.Write(Pname, "DESC", "저장된 문자패턴 " & MIDNAME)
                    ' AddLog(Admin, "최종선택완료=" & 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.공백)
                    f.ProgressBar1.Value += 1
                Next
            Case "F"    '//휴즈용량

                f.ProgressBar1.Maximum = S휴즈용량.Length
                f.ProgressBar1.Value = 0
                f.Refresh()


                For i As Integer = 0 To Me.S휴즈용량.GetUpperBound(0)
                    TOBJ = Me.S휴즈용량(i)
                    ' AddLog(Admin, MIDNAME & "패턴저장시 아이템=" & TOBJ.Name & "/" & TOBJ.Name.Substring(0, 1).ToUpper, LOGFILENAME)
                    Arinini.Write(Pname, "DESC", "저장된 문자패턴 " & MIDNAME)
                    '  AddLog(Admin, "최종선택완료=" & 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.공백)
                    f.ProgressBar1.Value += 1
                Next
            Case "I"    '//상표시찰 1단 150201

                f.ProgressBar1.Maximum = S상표시찰1단.Length
                f.ProgressBar1.Value = 0
                f.Refresh()

                For i As Integer = 0 To Me.S상표시찰1단.GetUpperBound(0)
                    TOBJ = Me.S상표시찰1단(i)
                    ' AddLog(Admin, MIDNAME & "패턴저장시 아이템=" & TOBJ.Name & "/" & TOBJ.Name.Substring(0, 1).ToUpper, LOGFILENAME)
                    Arinini.Write(Pname, "DESC", "저장된 문자패턴 " & MIDNAME)
                    ' AddLog(Admin, "최종선택완료=" & 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.공백)
                    f.ProgressBar1.Value += 1
                Next
            Case "T"    '//상표시찰 2단  150201

                f.ProgressBar1.Maximum = S상표시찰2단.Length
                f.ProgressBar1.Value = 0
                f.Refresh()

                For i As Integer = 0 To Me.S상표시찰2단.GetUpperBound(0)
                    TOBJ = Me.S상표시찰2단(i)
                    ' AddLog(Admin, MIDNAME & "패턴저장시 아이템=" & TOBJ.Name & "/" & TOBJ.Name.Substring(0, 1).ToUpper, LOGFILENAME)
                    Arinini.Write(Pname, "DESC", "저장된 문자패턴 " & MIDNAME)
                    ' AddLog(Admin, "최종선택완료=" & 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.공백)
                    f.ProgressBar1.Value += 1
                Next
            Case "X"    '//전주번호

                f.ProgressBar1.Maximum = S전주번호.Length
                f.ProgressBar1.Value = 0
                f.Refresh()

                For i As Integer = 0 To Me.S전주번호.GetUpperBound(0)
                    TOBJ = Me.S전주번호(i)
                    'AddLog(Admin, MIDNAME & "패턴저장시 아이템=" & TOBJ.Name & "/" & TOBJ.Name.Substring(0, 1).ToUpper, LOGFILENAME)
                    Arinini.Write(Pname, "DESC", "저장된 문자패턴 " & MIDNAME)
                    ' AddLog(Admin, "최종선택완료=" & 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.공백)

                    f.ProgressBar1.Value += 1
                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

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


        AddLog(Admin, "save_patter2 에서 데이터테이블 갱신을 ㅎ호출한다ㅣㅣ ", "\Alllog.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
        AddLog(Admin, "개체목록 콤보박스에서 특정 개체가 선택되었다 view property 호출", "\Alllog.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
        AddLog(Admin, "표시 체크박스 선택 ", "\Alllog.txt")
        For Each a As Control In SelCon
            a.Visible = Me.cb_visible.Checked
        Next
        AddLog(Admin, "[표시] 체크박스 선택에서 pewview를 호출 ", "\Alllog.txt")
        Me.preview_window()
    End Sub

    Private Sub tb_foncol_DoubleClick(ByVal sender As Object, ByVal e As System.EventArgs) Handles tb_foncol.DoubleClick
        AddLog(Admin, " 글씨색깔 변경 클릭됨", "\Alllog.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
        AddLog(Admin, "글씨꿁게 선택됨 setfont 호출 ", "\Alllog.txt")
        SetFont()
    End Sub

    Private Sub UpdateFontSize(ByVal newsize As Integer, Optional ByVal Src As MyControlOLEDBv2.MyLabel = Nothing) '
        AddLog(Admin, "updatefont :  ", "\Alllog.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.StartsWith(Div.ToUpper()) 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
                AddLog(Admin, "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
            If Not Tobj.Name.ToUpper.StartsWith(div.ToUpper) Then Continue For

            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.TB_Pattern_Start.Text To Me.TB_Pattern_End.Text
            '  If chkFlag Then Exit For
            showcnt(i, Me.TB_Pattern_End.Text)

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

            If 번호패턴검사 = 0 Then    '0은 둘다 없다는 뜻이다 // 3은.. 문자와 길이가 동시에 존재한다는 뜻이다.
                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.TB_Pattern_Start.Text = Me.TB_Pattern_End.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_print_repeat.Checked = False Then Me.rad_print_area.Checked = True
    End Sub

    '---------------------------------
    Public Function PARSE_번호(ByVal srcsTR As String, ByVal jisun As Boolean) As Boolean
        'Me.CLEAR_ITEM("X")

        Dim Log As String = "\Parse_번호.txt"
        If srcsTR = "" OrElse Not Me.cb_jjnum.Checked Then
            Me.CLEAR_ITEM(S전주번호)
            Me.CLEAR_ITEM(S전주번호한줄)
            AddLog(Admin, "번호에대한 내용이 없거나 번호를 표시하지 않도록 체크되어있습니다", Log)
            Return False
        End If

        '//지선주의 경우를 판단한다. 지선주는 지선주(디비의인쇄컬럼)가 체크되어있고 cb.jisun 이 체크되어있으면 번호는 보이지 않게한다.
        If jisun AndAlso Me.cmb_jisun.SelectedIndex > 0 Then
            Me.CLEAR_ITEM(S전주번호)
            AddLog(Admin, "지선주가 적용되며 현재데이터는 지선주이므로 번호를 표시하지 않습니다", Log)
            If Me.cmb_jisun.SelectedIndex = 1 Then   '//한줄을 표시해야한다.
                Me.S전주번호한줄(0).MyText = srcsTR
                Me.S전주번호한줄(0).Visible = True
                ' ---------------------------------------------------          Else
                '        ----------------------------------------------       Me.S전주번호한줄(0).Visible = False
            End If
            Return False
        Else ''//한줄이 미미표시된 상태엿는데 아랫줄이없으면 게속 표시되어버린현상발생 20080220
            Me.S전주번호한줄(0).Visible = False
        End If

        Dim Wlen As Short = srcsTR.Length
        Dim SepPos As Short = srcsTR.IndexOf(";")
        Dim SRC() As Char = srcsTR.ToCharArray

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

        '//번호는 길이패턴을 하지않고 문자패턴만 한다.
        Dim pname As String
        Dim Arinini As New MyINI2(DrStyle.FILE)
        Dim CTLPOS() As String  '//위치정보
        Dim CTLFONT() As String
        Dim CTLVISIBLE As Boolean
        Dim PATTERN As String = PATTERN_ENC(SRCSTR)
        Dim PATTERN2 As String = PATTERN_ENC(SRCSTR, True)
        Dim TOBJ As MyControlOLEDBv2.MyLabel

        Dim 분리인덱스 As Short = 0
        Dim 번호형식 As String = "999"
        Dim Dr() As DataRow

        '//H패턴을 검사한다.
        pname = "JJNUMPATTERNII" & PATTERN2
        Dr = DtPattern.Select("NAME = '" & pname & "X1POS'")
        Dim FindHpattern As Boolean = False
        If Dr.GetUpperBound(0) = 0 Then '//데이터가 존재하므로 모두 적용을 한다.
            FindHpattern = True
            AddLog(Admin, "번호패턴H감지(문자) :  길이=" & Wlen & " 문자열=" & SRCSTR & " 패턴=" & PATTERN2, 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
                    AddLog(Admin, "문자패턴(H)오류=" & ex.Message.ToString, Log)
                End Try
            Next
        Else

            '//H문자가 없으므로 일반 문자패턴을 추출한다.
            pname = "JJNUMPATTERNII" & PATTERN

            Dr = DtPattern.Select("NAME = '" & pname & "X1POS'")
            If Dr.GetUpperBound(0) = 0 Then '//데이터가 존재하므로 모두 적용을 한다.
                AddLog(Admin, "번호패턴감지(문자) :  길이=" & Wlen & " 문자열=" & SRCSTR & " 패턴=" & PATTERN, 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
                        AddLog(Admin, "문자패턴오류=" & ex.Message.ToString, Log)
                    End Try
                Next
            Else
                AddLog(Admin, "문자패턴불일치 길이=" & Wlen & " 문자열=" & SRCSTR & " 패턴=" & PATTERN, Log)
                retval += 2 '//패턴이 없으므로 바로 넘긴다.
            End If
        End If

        If retval = 2 Then  '//문자패턴이 없을경우에만 길이패턴을 확인한다.
            '//길이패턴 확인
            pname = "JJNUMPATTERN" & Wlen

            Dr = DtPattern.Select("NAME = '" & pname & "X1POS'")
            If Dr.GetUpperBound(0) = 0 Then '//데이터가 존재하므로 모두 적용을 한다.
                AddLog(Admin, "번호패턴감지(길이) :  길이=" & 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
                        AddLog(Admin, "길이 패턴오류=" & ex.Message.ToString, Log)
                    End Try
                Next
            Else
                AddLog(Admin, "길이패턴불일치 기본스타일 복원  길이=" & Wlen & " 문자열=" & SRCSTR, Log)
                retval += 1 '//없다
            End If
        End If

        Me.cmb_sep.SelectedIndex = 분리인덱스

        If 번호형식 = "999" Then    '//패턴이없었다는 말이다 번호형식을 어느정도 맞춰준다.
            'MsgBox("번호형식이 없어서 셋팅합니다(" & 번호 & "/" & 번호.Length)
            If 번호.Length <= 12 Then
                If 번호.Length <= 4 Then
                    번호형식 = 번호.Length & "00"
                ElseIf 번호.Length <= 8 Then
                    번호형식 = "4" & CStr(번호.Length - 4) & "0"
                Else
                    번호형식 = "44" & CStr(번호.Length - 8)
                End If
            Else    '//12자리이상이므로 어덯게 쪼개야할지 3으로나눠서 ..int 대입을 하자
                번호형식 = CStr(Int(번호.Length / 3)) & CStr(Int(번호.Length / 3)) & CStr(번호.Length - Int(번호.Length / 3) * 2)
            End If
            'MsgBox("최종번호=" & 번호형식)
        End If

        Me.tb_ntype.Text = 번호형식

        번호형식지정(Me.tb_ntype.Text)  '//번호형식을 갱신해준다.
        Return retval '// 0이 리턴될것이다. 패턴이 모두 정상이란 뜻이다

    End Function

    Private Function SetXdata(ByVal idx As Short, ByRef Src() As Char) As MyControlOLEDBv2.MyLabel
        If idx > Src.GetUpperBound(0) Then Return Nothing
        Dim A As MyControlOLEDBv2.MyLabel = Me.S전주번호(0)

        For i As Integer = 0 To Me.S전주번호.GetUpperBound(0)
            If Me.S전주번호(i).MyText = "" Then
                Me.S전주번호(i).MyText = Src(idx)
                If i = 11 Then
                    A = Nothing
                Else
                    A = Me.S전주번호(i + 1)
                End If
                Exit For
            End If
        Next
        Return A
    End Function


    Private Function GetnextCtl(ByVal currCtl As MyControlOLEDBv2.MyLabel) As MyControlOLEDBv2.MyLabel
        Dim a As MyControlOLEDBv2.MyLabel = Nothing
        Select Case currCtl.Name.ToUpper
            Case "X1"
                a = Me.S전주번호(1) ' X2
            Case "X2"
                a = Me.S전주번호(2) 'X3
            Case "X3"
                a = Me.S전주번호(3) 'x4
            Case "X4"
                a = Me.S전주번호(4) 'x5
            Case "X5"
                a = Me.S전주번호(5) ' x6
            Case "X6"
                a = Me.S전주번호(6) 'x7
            Case "X7"
                a = Me.S전주번호(7) ' x8
            Case "X8"
                a = Me.S전주번호(8) 'x9
            Case "X9"
                a = Me.S전주번호(9) 'x10
            Case "X10"
                a = Me.S전주번호(10) ' x11
            Case "X11"
                a = Me.S전주번호(11) 'x12
            Case "X12"
                a = Me.S전주번호(12) 'X13
            Case "X13"
                a = Me.S전주번호(13) 'x14
            Case "X14"
                a = Me.S전주번호(14) 'x15
            Case "X15"
                a = Me.S전주번호(15) ' x16
            Case "X16"
                a = Me.S전주번호(16) 'x17
            Case "X17"
                a = Me.S전주번호(17) ' x18
            Case "X18"
                a = Me.S전주번호(18) 'x19
            Case "X19"
                a = Me.S전주번호(19) 'x20
            Case "X20"
                a = Me.S전주번호(20) ' x21
            Case Else
                a = Nothing
        End Select
        Return a
    End Function
    Private Sub 번호형식지정감독자(Optional ByVal msg As String = "999")
        'MsgBox("번호형식지정 : " & 번호, MsgBoxStyle.Information, msg)
        '//지정된 번호형식으로 전부번호를 표시한다.
        '//20070826 번호는 분리/통합으로 구분해서 출력한다.
        Dim A() As Char = 감독자.ToCharArray
        Dim P() As Char = msg.ToCharArray
        Me.CLEAR_ITEM(S감독자)
        '//12자이상은 개별이라고 한다면 해당번호를 통합으로 변경
        If Me.cmb_sep.SelectedIndex = -1 OrElse (Me.cmb_sep.SelectedIndex = 1 AndAlso 감독자.Length > 12) Then Me.cmb_sep.SelectedIndex = 2

        Dim NextCtl As MyControlOLEDBv2.MyLabel = Me.S감독자(0)
        Dim CurPos As Short = 0    '//몇번째 컨트롤까지 썻다는 표시
        Dim CPos As Short = 0       '//전체문자중 몇번째까지 했다는 표시
        Select Case Me.cmb_sep.SelectedIndex
            Case 0  '//혼합
                '//형식수가 4를 넘지않으면 개별 넘을경우 통합출력으로한다.
                '//연습데이터 342 : 345 R23L1 R9
                ' MsgBox("번호형식=" & msg & "/" & 번호 & "/p0=" & P(0))

                Me.tb_ntype.Enabled = True  '//분리엿을때 이것이 false 로 된다.
                If CInt(P(0).ToString) <> 0 AndAlso CInt(P(0).ToString) < 5 Then  '//첫줄에해당할 문자를 전부 개별로 넣는다.
                    ' MsgBox("1줄=" & msg & "/" & 번호 & "/p0=" & P(0))
                    For i As Int16 = 0 To (CInt(P(0).ToString) - 1) '//
                        If i <= A.GetUpperBound(0) Then '//정상적인 범위의 데이터일경우
                            Me.S감독자(i).MyText = IIf(A(i) <> ";", A(i), "")   '//0번째 (0,0)
                            'Me.S전주번호(i).Visible = True
                            'NextCtl = SetXdata(i, A)
                            CPos = i ' + 1
                            CurPos = i
                        End If
                    Next
                ElseIf CInt(P(0).ToString) > 4 Then   '//첫줄의 문자를 통합으로한다.
                    For i As Int16 = 0 To (CInt(P(0).ToString) - 1)
                        If i <= A.GetUpperBound(0) Then '//정상적인 범위의 데이터
                            Me.S감독자(CPos).MyText &= IIf(A(i) <> ";", A(i), "")    '//0번째 (0,0)
                            'Me.S전주번호(i).Visible = True
                            CurPos = i
                            'CurPos += 1
                            'NextCtl.MyText &= A(i)
                        End If
                    Next
                    'NextCtl = GetnextCtl(NextCtl)
                    'CurPos += 1 '//여기서 1이된다.
                End If


                'curpos 는 몇번째 번호까지 했다는것이다(그 다음번호를 가르킨다)
                'cpos 는 몇번째 컨트롤까지 썻다는 뜻이다.
                ' MsgBox("1번째출출력후 마지막위치값=" & CurPos)

                '//2번째줄을 테스트한다.

                If CPos = 0 AndAlso Me.S감독자(0).MyText = "" Then    '//컨트롤번호가 0일경우다. 만약 값이없으면 1번째줄에서 아무것도없엇따는뜻이다.
                    CPos = -1
                End If

                If CInt(P(1).ToString) > 0 AndAlso CInt(P(1).ToString) < 5 Then
                    ' MsgBox("2줄=" & msg & "/" & 번호 & "/p0=" & P(0))
                    For i As Int16 = CurPos + 1 To CInt(P(0).ToString) + CInt(P(1).ToString) - 1
                        If i <= A.GetUpperBound(0) Then
                            Me.S감독자(CPos + 1).MyText = IIf(A(i) <> ";", A(i), "")  '//0번째 (0,0)
                            CPos += 1
                            'Me.S전주번호(i).Visible = True
                            'NextCtl = SetXdata(i, A)

                            CurPos = i
                        End If
                    Next
                ElseIf CInt(P(1).ToString) > 0 Then '//통합출력
                    CPos += 1
                    For i As Int16 = CurPos + 1 To CInt(P(0).ToString) + CInt(P(1).ToString) - 1
                        If i <= A.GetUpperBound(0) Then
                            Me.S감독자(CPos).MyText &= IIf(A(i) <> ";", A(i), "")   '//0번째 (0,0)
                            'Me.S전주번호(CPos).Visible = True
                            'NextCtl.MyText &= A(i)
                            CurPos = i
                        End If
                    Next
                    'NextCtl = GetnextCtl(NextCtl)
                End If


                ' MsgBox("2번째출출력후 마지막위치값=" & CurPos)

                If CInt(P(2).ToString) > 0 AndAlso CInt(P(2).ToString) < 5 Then
                    ' MsgBox("3줄개별=" & msg & "/" & 번호 & "/p0=" & P(0))
                    For i As Int16 = CurPos + 1 To CInt(P(0).ToString) + CInt(P(1).ToString) + CInt(P(2).ToString) - 1
                        If i <= A.GetUpperBound(0) Then
                            '  MsgBox(i & "/" & A(i))
                            Me.S감독자(CPos + 1).MyText = IIf(A(i) <> ";", A(i), "")    '//0번째 (0,0)
                            CPos += 1
                            'Me.S전주번호(i).Visible = True
                            'NextCtl = SetXdata(i, A)
                            CurPos = i
                        End If

                    Next
                ElseIf CInt(P(2).ToString) > 0 Then '//통합출력
                    'MsgBox("3줄통합=" & msg & "/" & 번호 & "/p0=" & P(0))
                    CPos += 1
                    For i As Int16 = CurPos + 1 To CInt(P(0).ToString) + CInt(P(1).ToString) + CInt(P(2).ToString) - 1
                        If i <= A.GetUpperBound(0) Then
                            Me.S감독자(CPos).MyText &= IIf(A(i) <> ";", A(i), "")   '//0번째 (0,0)
                            'Me.S전주번호(CPos).Visible = True
                            'NextCtl.MyText &= A(i)
                            CurPos = i
                        End If
                    Next
                    'NextCtl = GetnextCtl(NextCtl)
                End If
                ' MsgBox("3번째출출력후 마지막위치값=" & CurPos)


            Case 1  '//분리 
                Me.tb_ntype.Enabled = False
                For i As Int16 = 0 To A.GetUpperBound(0) '//개별 12개의 열에 데이터를 출력한다.
                    Me.S감독자(i).MyText = IIf(A(i) <> ";", A(i), "")
                Next
            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), "")
                    Else
                        Me.S감독자(2).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
    Private Sub 번호형식지정(Optional ByVal msg As String = "999")
        '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(S전주번호)
        '//12자이상은 개별이라고 한다면 해당번호를 혼합으로 바꾼다.
        If Me.cmb_sep.SelectedIndex = -1 OrElse (Me.cmb_sep.SelectedIndex = 1 AndAlso 번호.Length > 30) Then Me.cmb_sep.SelectedIndex = 0

        Dim NextCtl As MyControlOLEDBv2.MyLabel = Me.S전주번호(0)
        Dim CurPos As Short = 0    '//몇번째 컨트롤까지 썻다는 표시
        Dim CPos As Short = 0       '//전체문자중 몇번째까지 했다는 표시

        Dim Limit(P.GetUpperBound(0)) As Short    '//각배열별 한계숫자
        For i As Short = 0 To P.GetUpperBound(0)
            If i = 0 Then
                Limit(i) = CInt(P(i).ToString)
            Else
                Limit(i) = Limit(i - 1) + CInt(P(i).ToString)
            End If
            'MsgBox("한게값 : " & i & " 값=" & Limit(i))
        Next

        Select Case Me.cmb_sep.SelectedIndex
            Case 0  '//혼합
                '//형식수가 4를 넘지않으면 개별 넘을경우 통합출력으로한다.
                '//연습데이터 3442 : 345 R23L1 R932
                'MsgBox("번호형식=" & msg & "/" & 번호 & "/p0=" & P(0))
                Me.tb_ntype.Enabled = True  '//분리엿을때 이것이 false 로 된다.
                Dim OK As Short = -1  '//완료 번호형식 배열값
                Dim 사용한컨트롤위치 As Short = -1
                Dim RES As Boolean = False

                For i As Integer = 0 To A.GetUpperBound(0)
                    If CInt(P(OK + 1).ToString) <= 4 Then    '//개별로넣는다
                        If i + 1 < Limit(OK + 1) Then
                            사용한컨트롤위치 += 1
                            Me.S전주번호(사용한컨트롤위치).MyText &= IIf(A(i) <> ";", A(i), "")
                        ElseIf i + 1 = Limit(OK + 1) Then
                            OK += 1 : If OK > Limit.GetUpperBound(0) Then Exit For
                            사용한컨트롤위치 += 1
                            Me.S전주번호(사용한컨트롤위치).MyText &= IIf(A(i) <> ";", A(i), "")
                        End If
                    Else   '//4보다크다면 해당 ok가 끈날때까지 한개의 컨트롤에 넣는다.
                        If RES = False Then
                            사용한컨트롤위치 += 1
                            RES = True
                        End If
                        If i + 1 < Limit(OK + 1) Then
                            Me.S전주번호(사용한컨트롤위치).MyText &= IIf(A(i) <> ";", A(i), "")
                        ElseIf i + 1 = Limit(OK + 1) Then
                            Me.S전주번호(사용한컨트롤위치).MyText &= IIf(A(i) <> ";", A(i), "")
                            OK += 1 : If OK + 1 > Limit.GetUpperBound(0) Then Exit For
                            RES = False
                        End If
                    End If
                Next
            Case 1  '//분리 
                Me.tb_ntype.Enabled = False
                For i As Int16 = 0 To A.GetUpperBound(0) '//개별 12개의 열에 데이터를 출력한다.(30개로 늘렷으니 충분할것이다)
                    Me.S전주번호(i).MyText = IIf(A(i) <> ";", A(i), "")
                Next
            Case 2  '//통합
                Me.tb_ntype.Enabled = True
                Dim OK As Short = -1  '//완료 번호형식 배열값
                For i As Integer = 0 To A.GetUpperBound(0)
                    If i < Limit(OK + 1) Then
                        Me.S전주번호(OK + 1).MyText &= IIf(A(i) <> ";", A(i), "")
                    ElseIf i = Limit(OK + 1) Then
                        OK += 1 : If OK + 1 > Limit.GetUpperBound(0) Then Exit For
                        Me.S전주번호(OK + 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 SRCNUM As Integer, ByVal srcstr As String) As Boolean
        '/선로명의 길이는 예측되지 않는다 동적 컨트롤 생성을 사용한다.
        ' MsgBox("PARSET_관리구")
        Me.CLEAR_ITEM(Me.S본주번호)
        Me.CLEAR_ITEM(Me.S본주전주번호)
        Dim Log As String = "\Parse_본주.txt"
        If Me.cb_mainrow.Checked Then
            Me.S본주번호(0).MyText = SRCNUM
            Me.S본주번호(0).Visible = True
        End If
        If Me.cb_mainnum.Checked Then
            Me.S본주전주번호(0).MyText = srcstr
            Me.S본주전주번호(0).Visible = True
        End If
        AddLog(Admin, "MAIN ROW NUM=" & SRCNUM & "   STRING=" & srcstr, Log)
        Return True
    End Function
    Public Function PARSE_관리구(ByVal srcstr As String) As Boolean
        '/선로명의 길이는 예측되지 않는다 동적 컨트롤 생성을 사용한다.
        ' MsgBox("PARSET_관리구")

        Console.WriteLine("PARSE_관리구 : " + srcstr)
        Me.CLEAR_ITEM(Me.S관리구)
        Dim Log As String = "\Parse_관리구.txt"
        If srcstr = "" OrElse Not Me.cb_kwang.Checked Then
            AddLog(Admin, "Zero Length - Return", Log)
            Return False
        End If

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

        AddLog(Admin, "Length=" & Wlen & "   Sep=" & SepPos, Log)

        For i As Integer = 0 To Wlen - 1   '//모든문자를 할당한다.
            Try
                S관리구(i).MyText = SRC(i).ToString
                S관리구(i).Visible = True
            Catch ex As Exception
                Exit For
            End Try
            'S관리구(i) = New MyControlOLEDBv2.MyLabel

            ' MsgBox(S관리구(i).MyText)

        Next
        Return True
    End Function

    Public Function PARSE_감독자(ByVal srcstr As String) As Boolean
        '/선로명의 길이는 예측되지 않는다 동적 컨트롤 생성을 사용한다.
        ' MsgBox("PARSET_관리구")
        Me.CLEAR_ITEM(Me.S감독자)
        Dim Log As String = "\Parse_감독자.txt"
        If srcstr = "" OrElse Not Me.cb_man.Checked Then
            AddLog(Admin, "Zero Length - Return", Log)
            Return False
        End If

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

        AddLog(Admin, "Length=" & Wlen & "   Sep=" & SepPos, Log)

        'For i As Integer = 0 To Wlen - 1   '//모든문자를 할당한다.
        '    Try
        '        S감독자(i).MyText = SRC(i).ToString
        '        S감독자(i).Visible = True
        '    Catch ex As Exception
        '        Exit For
        '    End Try
        'Next
        Return True

    End Function



    Public Sub PARSE_관리구패턴(ByVal srcstr As String)
        Dim Log As String = "\Parse_관리구패턴.txt"
        Dim Wlen As Short = srcstr.Length
        Dim SepPos As Short = srcstr.IndexOf(";")
        Dim SrC() As Char = srcstr.ToCharArray

        '길이패턴여부를 확인했으므로 패턴을적용한다.[STYLE1LINEPATTERN9]

        'Dim lpattern As Boolean = False
        Dim Pname As String = "CNUMPATTERN" & Wlen
        'Dim Sname As String
        Dim CTLPOS() As String
        Dim CTLFONT() As String
        Dim CTLVISIBLE As Boolean
        Dim Arinini As New MyINI2(DrStyle.FILE)
        'Dim tobj As MyControlOLEDBv2.MyLabel
        Dim Dr() As DataRow
        'Dim idx As Short = 0
        ' Me.길이패턴연습(srcstr, Pname, Log, "H", S관리구)

        Pname = "CNUMPATTERNII" & PATTERN_ENC(srcstr)
        Me.문자패턴연습(srcstr, Pname, Log, S관리구)

        '//관리구5번 알파벳 지정이되어있는지 확인한다.
        Pname = "CNUMPATTERNI" & S관리구(4).MyText ' Me.h5.MyText '//5번이 W 일때는 cnumpatternIw 를 찾게된다.
        Dr = DtPattern.Select("NAME = '" & Pname & "DESC'")

        If Dr.GetUpperBound(0) = 0 Then '//있다.
            AddLog(Admin, "관리구5번 문자를 찾았습니다 (" & Pname & "DESC" & ")", Log)
            Dr = DtPattern.Select("NAME = '" & Pname & S관리구(4).Name & "POS'")
            If Dr.GetUpperBound(0) = 0 Then
                CTLPOS = Dr(0)(1).ToString.Split(",")
                Me.S관리구(4).Location = New Point(CTLPOS(0), CTLPOS(1))
                Me.S관리구(4).Size = New Size(CTLPOS(2), CTLPOS(3))
            End If

            Dr = DtPattern.Select("NAME = '" & Pname & S관리구(4).Name & "FONT'")
            If Dr.GetUpperBound(0) = 0 Then
                CTLFONT = Dr(0)(1).ToString.Split(",")
                S관리구(4).MyFont = New Font(CTLFONT(0), CTLFONT(1), IIf(CTLFONT(3).ToUpper = "TRUE", FontStyle.Bold, FontStyle.Regular), GraphicsUnit.Point)
                S관리구(4).장평 = CTLFONT(5)
                S관리구(4).장높이 = CTLFONT(6)
            End If
            Dr = DtPattern.Select("NAME = '" & Pname & S관리구(4).Name & "VISIBLE'")
            If Dr.GetUpperBound(0) = 0 Then
                CTLVISIBLE = Dr(0)(1).ToString
                S관리구(4).Visible = CType(CTLVISIBLE, Boolean)
            End If
            Dr = DtPattern.Select("NAME = '" & Pname & S관리구(4).Name & "SPACE'")
            If Dr.GetUpperBound(0) = 0 Then
                S관리구(4).공백 = Dr(0)(1)
            End If
        Else
            AddLog(Admin, "관리구5번 문자가 지정되어있지않습니다. (" & S관리구(4).MyText & ")", Log)
        End If
    End Sub
    Public Function PARSE_감독자패턴(ByVal srcstr As String) As Integer

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

        '//번호는 길이패턴을 하지않고 문자패턴만 한다.
        Dim pname As String
        Dim Arinini As New MyINI2(DrStyle.FILE)
        Dim CTLPOS() As String  '//위치정보
        Dim CTLFONT() As String
        Dim CTLVISIBLE As Boolean
        Dim PATTERN As String = PATTERN_ENC(srcstr)
        Dim TOBJ As MyControlOLEDBv2.MyLabel

        Dim 분리인덱스 As Short = 0
        Dim 번호형식 As String = "999"
        Dim Dr() As DataRow

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

        Dr = DtPattern.Select("NAME = '" & pname & "M1POS'")
        If Dr.GetUpperBound(0) = 0 Then '//데이터가 존재하므로 모두 적용을 한다.
            AddLog(Admin, "감독자패턴감지(문자) :  길이=" & Wlen & " 문자열=" & srcstr & " 패턴=" & PATTERN, Log)
            '//데이터는 최종적으로 번호형식에서 보낸다.
            분리인덱스 = Arinini.Read(pname, "nseparate1", 2)
            번호형식 = Arinini.Read(pname, "LineType1", "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
                    AddLog(Admin, "문자패턴오류=" & ex.Message.ToString, Log)
                End Try
            Next
        Else
            AddLog(Admin, "문자패턴불일치 길이=" & Wlen & " 문자열=" & srcstr & " 패턴=" & PATTERN, Log)
            retval += 2 '//패턴이 없으므로 바로 넘긴다.
        End If




        If retval = 2 Then  '//문자패턴이 없을경우에만 길이패턴을 확인한다.
            '//길이패턴 확인
            pname = "MANGPATTERN" & Wlen

            Dr = DtPattern.Select("NAME = '" & pname & "X1POS'")
            If Dr.GetUpperBound(0) = 0 Then '//데이터가 존재하므로 모두 적용을 한다.
                AddLog(Admin, "감독자패턴감지(길이) :  길이=" & Wlen & " 문자열=" & srcstr, Log)
                '//데이터는 최종적으로 번호형식에서 보낸다.
                분리인덱스 = Arinini.Read(pname, "nseparate1", 2)
                번호형식 = Arinini.Read(pname, "LineType1", "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
                        AddLog(Admin, "길이 패턴오류=" & ex.Message.ToString, Log)
                    End Try
                Next
            Else
                AddLog(Admin, "길이패턴불일치 기본스타일 복원  길이=" & Wlen & " 문자열=" & srcstr, Log)
                retval += 1 '//없다
            End If
        End If

        Me.cmb_sep.SelectedIndex = 분리인덱스

        If 번호형식 = "999" Then    '//패턴이없었다는 말이다 번호형식을 어느정도 맞춰준다.
            'MsgBox("번호형식이 없어서 셋팅합니다(" & 번호 & "/" & 번호.Length)
            If 번호.Length <= 12 Then
                If 번호.Length <= 4 Then
                    번호형식 = 번호.Length & "00"
                ElseIf 번호.Length <= 8 Then
                    번호형식 = "4" & CStr(번호.Length - 4) & "0"
                Else
                    번호형식 = "44" & CStr(번호.Length - 8)
                End If
            Else    '//12자리이상이므로 어덯게 쪼개야할지 3으로나눠서 ..int 대입을 하자
                번호형식 = CStr(Int(번호.Length / 3)) & CStr(Int(번호.Length / 3)) & CStr(번호.Length - Int(번호.Length / 3) * 2)
            End If
            'MsgBox("최종번호=" & 번호형식)
        End If

        Me.tb_ntype.Text = 번호형식

        번호형식지정감독자()  '//번호형식을 갱신해준다.
        Return retval '// 0이 리턴될것이다. 패턴이 모두 정상이란 뜻이다

    End Function


    Public Function PARSE(ByVal srcstr As String, ByVal Mylabels() As MyControlOLEDBv2.MyLabel) As Boolean
        '/선로명의 길이는 예측되지 않는다 동적 컨트롤 생성을 사용한다.
        ' MsgBox("PARSET_관리구")
        Me.CLEAR_ITEM(Mylabels)
        Dim Log As String = "\Parse_" & Mylabels(0).Name & ".txt"
        If srcstr = "" OrElse Not Mylabels(0).CheckBox.Checked Then
            WLog2(Auto_Log, "Zero Length - Return", Log)
            Return False
        End If
        WLog2(Auto_Log, "pase 시작", Log)

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

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

        Console.WriteLine("Parse : " + srcstr + ",설명=" + Mylabels(0).설명)
        If Mylabels(0).설명.IndexOf("한줄") <> -1 Then
            Console.WriteLine("한줄")
        End If

        If Mylabels.GetUpperBound(0) = 0 Then
            Mylabels(0).MyText = srcstr
            Mylabels(0).Visible = True
        Else
            For i As Integer = 0 To Wlen - 1   '//모든문자를 할당한다.
                Try
                    Select Case SRC(i)
                        Case ";"
                            Mylabels(i).MyText = "---"
                            Mylabels(i).Visible = True
                        Case ":"
                            Mylabels(i).MyText = ""
                            Mylabels(i).Visible = True
                        Case Else
                            Mylabels(i).MyText = SRC(i)
                            Mylabels(i).Visible = True
                    End Select
                Catch ex As Exception
                    Exit For
                End Try
            Next
        End If
        Return True
    End Function
    Public Sub PARSE_PATTERN(ByVal Srcstr As String, ByVal labels() As MyControlOLEDBv2.MyLabel, Optional ByVal BlineNum As String = "")
        Dim Wlen As Short = Srcstr.Length : If Wlen <= 0 Then Return '//없는 글귀가 왓을때 턴해버린다.
        Dim Log As String = "\PATTERN_" & labels(0).Name & ".txt"
        '//먼저패턴이 존재하는지 확인해본다.
        '길이패턴여부를 확인했으므로 패턴을적용한다.[STYLE1LINEPATTERN9]
        Dim Pname As String = labels(0).Pattern & Wlen
        If BlineNum <> "" Then '//줄그룹
            '  Me.길이패턴연습(Srcstr, "LNUM" & BlineNum & Pname, Log, labels(0).Tag, labels)
            Pname = labels(0).Pattern & "II" & PATTERN_ENC(Srcstr)
            Me.문자패턴연습(Srcstr, "LNUM" & BlineNum & Pname, Log, labels)
        Else
            ' Me.길이패턴연습(Srcstr, Pname, Log, labels(0).Tag, labels)
            Pname = labels(0).Pattern & "II" & PATTERN_ENC(Srcstr)
            Me.문자패턴연습(Srcstr, Pname, Log, labels)
        End If
        '//패턴1이 끝났다 패턴2를 찾는다.
        '//패턴2는 style1LInepatternII문자숫자형식
    End Sub

    Public Sub PARSE_장척패턴(ByVal SrcStr As String)

        Dim Wlen As Short = SrcStr.Length : If Wlen <= 0 Then Return '//없는 글귀가 왓을때 턴해버린다.
        Dim Log As String = "\PATTERN_장척.txt"
        Dim SepPos As Short = SrcStr.IndexOf(";")
        Dim Pname As String = "CHOKPATTERN" & Wlen

        ' Me.길이패턴연습(SrcStr, Pname, Log, "J", S장척)
        Pname = "CHOKPATTERNII" & PATTERN_ENC(SrcStr)
        Me.문자패턴연습(SrcStr, Pname, Log, S장척)
    End Sub

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

        Dim Wlen As Short = srcStr.Length
        Dim SepPos As Short = srcStr.IndexOf(";")
        Dim SRC() As Char = srcStr.ToCharArray

        AddLog(Admin, "Length=" & Wlen & "   Sep=" & SepPos, Log)

        Select Case srcStr.Length
            Case 1
                Me.S장척(0).MyText = "0"
                Me.S장척(1).MyText = srcStr
                Me.S장척(0).Visible = True
                Me.S장척(1).Visible = True

                Me.S장척(2).Visible = False
            Case 2
                Me.S장척(0).MyText = srcStr.Substring(0, 1)
                Me.S장척(1).MyText = srcStr.Substring(1)
                Me.S장척(0).Visible = True
                Me.S장척(1).Visible = True

                Me.S장척(2).Visible = False
                'Case 3
                '    Me.S장척(0).MyText = srcStr.Substring(0, 1)
                '    Me.S장척(1).MyText = srcStr.Substring(1, 1)
                '    Me.S장척(2).MyText = srcStr.Substring(2)
                '    Me.S장척(0).Visible = True
                '    Me.S장척(1).Visible = True
                '    Me.S장척(2).Visible = True
            Case Else

                Me.S장척(0).MyText = srcStr.ToString
                Me.S장척(0).Visible = True

                Me.S장척(1).Visible = False
                Me.S장척(2).Visible = False

                'If Me.cb_jc1.Checked Then   '//장척3자리 사용일때
                '    Me.S장척(2).Visible = True
                '    Me.S장척(2).MyText = srcStr.ToString
                '    Me.S장척(2).Visible = True
                '    LOAD_STYLEC(Me.cmb_style.SelectedIndex & "STYLEJANGCHOK", "J")   '//장척3자리일때의 커스텀스타일을 불러옵니다
                '    Return False    '//뒤에 패턴검사를 하지않기위해서이다.. 어차피 필요없지 않은가...
                'Else    '//장척전체를 보여준다.
                '    Me.S장척(0).MyText = srcStr.Substring(1, 1)
                '    Me.S장척(1).MyText = srcStr.Substring(2, 1)
                '    Me.S장척(0).Visible = True
                'End If
        End Select
        Return True
    End Function




    Private Sub PARSE_접지1(ByVal srcstr As String)
        Me.CLEAR_ITEM(S접지)
        If srcstr <> "" AndAlso Me.cb_jji.Checked Then
            Me.S접지(0).MyText = srcstr & "Ω"
            Me.S접지(0).Visible = True
        End If
    End Sub
    Private Sub PARSE_접지2(ByVal srcstr As String)
        If srcstr <> "" AndAlso Me.cb_jji.Checked Then
            Me.S접지(1).MyText = srcstr & "Ω"
            Me.S접지(1).Visible = True
        End If
    End Sub

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

    Private Sub GetPrintersName()
        AddLog(Admin, "GetPrinterName()", "\Alllog.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
            'If Me.cb_dummy.Checked AndAlso Me.cmb_dummy.SelectedIndex = 1 And Me.BindingSource1.Position >= 0 AndAlso Me.BindingSource1.Position + 1 < Me.BindingSource1.Count Then   '//현재인덱스가 최고값보다 작으면
            'Me.BindingSource1.Position += 2
            'Else
            Me.BindingSource1.Position += 1
            'End If
            'Me.BindingNavigatorMoveNextItem.PerformClick()
            'Me.BindingNavigatorPositionItem.Focus()
            'End If
        Else

            If Me.BindingNavigatorPositionItem.Text > 0 Then
                'If Me.cb_dummy.Checked AndAlso Me.cmb_dummy.SelectedIndex = 1 And Me.BindingSource1.Position >= 0 AndAlso Me.BindingSource1.Position + 1 < Me.BindingSource1.Count Then   '//현재인덱스가 최고값보다 작으면
                ' Me.BindingSource1.Position -= 2
                'Else
                Me.BindingSource1.Position -= 1
                'End If
                'Me.BindingNavigatorMovePreviousItem.PerformClick()
                'Me.BindingNavigatorPositionItem.Focus()
            End If

        End If
    End Sub

    Private Sub Panel1_MouseMove(ByVal sender As Object, ByVal e As System.Windows.Forms.MouseEventArgs)
        Me.Text = e.X & "/" & e.Y
    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 ToolStripMenuItem5_Click(ByVal sender As System.Object, ByVal e As System.EventArgs)
    '    Dim A As New System.Text.StringBuilder
    '    A.AppendLine("[기타스타일] 장척3자리 사용이 선택되어있습니다")
    '    A.AppendLine()
    '    A.AppendLine("기타스타일 저장을 클릭하세요")
    '    If Me.cb_jc1.Checked Then
    '        MsgBox(A.ToString, MsgBoxStyle.Critical, "확인")
    '        Return
    '    End If
    '    SAVE_PATTERNII(Me.장척.ToCharArray, "CHOKPATTERNII", "J", "\장척패턴2.TXT")    '//선로명의 패턴을 저장합니다.
    'End Sub

    'Private Sub ToolStripMenuItem4_Click(ByVal sender As System.Object, ByVal e As System.EventArgs)
    '    SAVE_PATTERNII(Me.시공년월.ToCharArray, "YYMMPATTERNII", "Y", "\시공년월패턴2.TXT")    '//선로명의 패턴을 저장합니다.
    '    SAVE_PATTERNII(Me.점검일자.ToCharArray, "YYMMPATTERNII", "O", "\정검일자패턴2.TXT")    '//선로명의 패턴을 저장합니다.
    '    SAVE_PATTERNII(Me.점검.ToCharArray, "YYMMPATTERNII", "HI", "\정검일자패턴2.TXT")    '//선로명의 패턴을 저장합니다.
    'End Sub

    'Private Sub ToolStripMenuItem3_Click(ByVal sender As System.Object, ByVal e As System.EventArgs)
    '    SAVE_PATTERNII(Me.전산번호.ToCharArray, "JNUMPATTERNII", "S", "\선로번호패턴2.TXT")    '//선로명의 패턴을 저장합니다.
    'End Sub

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

    'Private Sub ToolStripMenuItem1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs)
    '    SAVE_PATTERNII(Me.선로명.ToCharArray, "LINEPATTERNII", "L", "\선로명패턴2.TXT")    '//선로명의 패턴을 저장합니다.
    'End Sub

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

        Dim msg As New System.Text.StringBuilder
        msg.AppendLine("관리구5번  영문자(" & Me.S관리구(4).MyText & " )문자에대한 스타일을 저장합니다")
        msg.AppendLine()
        msg.AppendLine("저장후 관리구5번에 동일한 영문자가 올경우에 저장된 내용이 반영됩니다")
        msg.AppendLine("------------------")
        msg.AppendLine("글꼴 = " & Me.S관리구(4).MyFont.ToString)
        msg.AppendLine("너비 = " & Me.S관리구(4).장평)
        msg.AppendLine("높이 = " & Me.S관리구(4).장높이)
        msg.AppendLine("좌표 = " & Me.S관리구(4).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(StyleList(Me.cmb_style.SelectedIndex).File)


        Dim Arinini As New MyINI2(DrStyle.FILE)
        Dim TOBJ As MyControlOLEDBv2.MyLabel = Me.S관리구(4)
        Dim Pname As String = "CNUMPATTERNI" & TOBJ.MyText '//5번이 W 일때는 cnumpatternIw 를 찾게된다.

        Arinini.Write(Pname, "DESC", "영문자 특수저장(" & TOBJ.MyText & ")")
        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번 의 영문자 (" & TOBJ.MyText & ") 상태를 저장하였습니다", Me.lb_msg)
        데이터테이블갱신()
    End Sub

    Private Sub ToolStripButton6_Click(ByVal sender As System.Object, ByVal e As System.EventArgs)
        If Not Me.cb_jc1.Checked Then
            MsgBox("기타스타일[장척3자리]를 사용하지 않기떄문에 저장이 되지 않습니다", MsgBoxStyle.Critical, "확인")
            Return
        End If

        If MsgBox("현재 스타일(기타-장척3자리)을 저장하시겠습니까?", MsgBoxStyle.Information + MsgBoxStyle.YesNo, "기타스타일저장") = MsgBoxResult.Yes Then
            If Me.cb_jc1.Checked Then Me.SAVE_STYLEC(Me.cmb_style.SelectedIndex & "STYLEJANGCHOK", "J")
            NOTICE("스타일(기타-장척3자리)을 저장했습니다", Me.lb_msg)
        Else
            NOTICE("스타일(기타-장척3자리)저장이 취소되었습니다", Me.lb_msg)
        End If
    End Sub

    Private Sub 기타장척3자리ToolStripMenuItem_Click(ByVal sender As System.Object, ByVal e As System.EventArgs)

        If Not Me.cb_jc1.Checked Then
            MsgBox("기타스타일[장척3자리]를 사용하지 않기떄문에 저장이 되지 않습니다", MsgBoxStyle.Critical, "확인")
            Return
        End If

        If MsgBox("현재 스타일(기타-장척3자리)을 저장하시겠습니까?", MsgBoxStyle.Information + MsgBoxStyle.YesNo, "기타스타일저장") = MsgBoxResult.Yes Then
            Me.SAVE_STYLEC(Me.cmb_style.SelectedIndex & "STYLEJANGCHOK", "J")
            NOTICE("스타일(기타-장척3자리)을 저장했습니다", Me.lb_msg)
        Else
            NOTICE("스타일(기타-장척3자리)저장이 취소되었습니다", Me.lb_msg)
        End If
    End Sub

#Region "Not Edit"


    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

    Public 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

        '//쉐이프를 먼저 그린다.
        If Me.chk_draw.Checked Then
            '//라인을 그린다.
            For Each Rect As S_Line In Draw_Line

                If Rect.Field <> "" Then
                    Select Case Rect.Field
                        Case "COS휴즈용량"
                            If Me.휴즈용량 = "" OrElse Not cb_휴즈용량.Checked Then
                                Continue For
                            End If
                        Case "상표시찰1단"
                            If Me.상표시찰1단 = "" OrElse Not cb_상1단.Checked Then
                                Continue For
                            End If
                        Case "상표시찰2단"
                            If Me.상표시찰2단 = "" OrElse Not cb_상2단.Checked Then
                                Continue For
                            End If
                        Case "점검일자"
                            If Me.점검일자 = "" OrElse Not cb_date.Checked Then
                                Continue For
                            End If

                        Case "선로전방"
                            If Me.선로전방 = "" Then
                                Continue For
                            End If
                        Case "선로좌측"
                            If Me.선로좌측 = "" Then
                                Continue For
                            End If
                        Case "선로우측"
                            If Me.선로우측 = "" Then
                                Continue For
                            End If
                    End Select
                End If

                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

                If Rect.Field <> "" Then
                    Select Case Rect.Field
                        Case "COS휴즈용량"
                            If Me.휴즈용량 = "" OrElse Not cb_휴즈용량.Checked Then
                                Continue For
                            End If
                        Case "상표시찰1단"
                            If Me.상표시찰1단 = "" OrElse Not cb_상1단.Checked Then
                                Continue For
                            End If
                        Case "상표시찰2단"
                            If Me.상표시찰2단 = "" OrElse Not cb_상2단.Checked Then
                                Continue For
                            End If
                        Case "점검일자"
                            If Me.점검일자 = "" OrElse Not cb_date.Checked Then
                                Continue For
                            End If
                        Case "선로전방"
                            If Me.선로전방 = "" Then
                                Continue For
                            End If
                        Case "선로좌측"
                            If Me.선로좌측 = "" Then
                                Continue For
                            End If
                        Case "선로우측"
                            If Me.선로우측 = "" Then
                                Continue For
                            End If
                    End Select
                End If

                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

                If Rect.Field <> "" Then
                    Select Case Rect.Field
                        Case "COS휴즈용량"
                            If Me.휴즈용량 = "" OrElse Not cb_휴즈용량.Checked Then
                                Continue For
                            End If
                        Case "상표시찰1단"
                            If Me.상표시찰1단 = "" OrElse Not cb_상1단.Checked Then
                                Continue For
                            End If
                        Case "상표시찰2단"
                            If Me.상표시찰2단 = "" OrElse Not cb_상2단.Checked Then
                                Continue For
                            End If
                        Case "점검일자"
                            If Me.점검일자 = "" OrElse Not cb_date.Checked Then
                                Continue For
                            End If
                        Case "선로전방"
                            If Me.선로전방 = "" Then
                                Continue For
                            End If
                        Case "선로좌측"
                            If Me.선로좌측 = "" Then
                                Continue For
                            End If
                        Case "선로우측"
                            If Me.선로우측 = "" Then
                                Continue For
                            End If
                    End Select
                End If

                Dim Pen As New Drawing.Pen(Rect.PenColor, Rect.PenWidth)
                Ga.DrawEllipse(Pen, Rect.X, Rect.Y, Rect.Width, Rect.Height)
            Next

            '//그림을 그린다.
            For Each Rect As S_Image In Draw_Image

                If Rect.Field <> "" Then
                    Select Case Rect.Field
                        Case "COS휴즈용량"
                            If Me.휴즈용량 = "" OrElse Not cb_휴즈용량.Checked Then
                                Continue For
                            End If
                        Case "상표시찰1단"
                            If Me.상표시찰1단 = "" OrElse Not cb_상1단.Checked Then
                                Continue For
                            End If
                        Case "상표시찰2단"
                            If Me.상표시찰2단 = "" OrElse Not cb_상2단.Checked Then
                                Continue For
                            End If
                        Case "점검일자"
                            If Me.점검일자 = "" OrElse Not cb_date.Checked Then
                                Continue For
                            End If
                        Case "선로전방"
                            If Me.선로전방 = "" Then
                                Continue For
                            End If
                        Case "선로좌측"
                            If Me.선로좌측 = "" Then
                                Continue For
                            End If
                        Case "선로우측"
                            If Me.선로우측 = "" Then
                                Continue For
                            End If
                    End Select
                End If

                Dim F As String = Rect.FileName
                If F.Trim <> "" Then
                    F = F.Replace(".\", My.Application.Info.DirectoryPath & "\")

                    If System.IO.File.Exists(F) Then
                        Dim Image As Image = Image.FromFile(F)
                        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
                    End If
                End If
            Next

            '//화살표를 그린다. 170711
            For Each Rect As S_Arrow In Draw_Arrow

                Select Case Rect.Direction
            
                    Case 0
                        If Me.선로전방 = "" Then
                            Continue For
                        End If
                    Case 1
                        If Me.선로좌측 = "" Then
                            Continue For
                        End If
                    Case 2
                        If Me.선로우측 = "" Then
                            Continue For
                        End If
                End Select

                '//각포인트를 생성한다.
                Dim pts As New List(Of Point)

                If Rect.Direction = 1 Then '//좌측
                    pts.Add(New Point(Rect.RectX - Rect.TriWidth, Rect.RectY + Rect.RectH / 2))
                    pts.Add(New Point(Rect.RectX, Rect.RectY - Rect.TriHeight))

                    pts.Add(New Point(Rect.RectX, Rect.RectY))
                    pts.Add(New Point(Rect.RectX + Rect.RectW, Rect.RectY))
                    pts.Add(New Point(Rect.RectX + Rect.RectW, Rect.RectY + Rect.RectH))
                    pts.Add(New Point(Rect.RectX, Rect.RectY + Rect.RectH))

                    pts.Add(New Point(Rect.RectX, Rect.RectY + Rect.RectH + Rect.TriHeight))
                    pts.Add(New Point(Rect.RectX - Rect.TriWidth, Rect.RectY + Rect.RectH / 2))

                ElseIf Rect.Direction = 2 Then '//우측

                    pts.Add(New Point(Rect.RectX, Rect.RectY))
                    pts.Add(New Point(Rect.RectX + Rect.RectW, Rect.RectY))

                    pts.Add(New Point(Rect.RectX + Rect.RectW, Rect.RectY - Rect.TriHeight))
                    pts.Add(New Point(Rect.RectX + Rect.RectW + Rect.TriWidth, Rect.RectY + Rect.RectH / 2))
                    pts.Add(New Point(Rect.RectX + Rect.RectW, Rect.RectY + Rect.RectH + Rect.TriHeight))

                    pts.Add(New Point(Rect.RectX + Rect.RectW, Rect.RectY + Rect.RectH))
                    pts.Add(New Point(Rect.RectX, Rect.RectY + Rect.RectH))

                    pts.Add(New Point(Rect.RectX, Rect.RectY))

                ElseIf Rect.Direction = 0 Then '//전방

                    pts.Add(New Point(Rect.RectX, Rect.RectY + Rect.RectH))
                    pts.Add(New Point(Rect.RectX, Rect.RectY))

                    pts.Add(New Point(Rect.RectX - Rect.TriWidth, Rect.RectY))

                    pts.Add(New Point(Rect.RectX + Rect.RectW / 2, Rect.RectY - Rect.TriHeight))

                    pts.Add(New Point(Rect.RectX + Rect.RectW + Rect.TriWidth, Rect.RectY))
                    pts.Add(New Point(Rect.RectX + Rect.RectW, Rect.RectY))

                    pts.Add(New Point(Rect.RectX + Rect.RectW, Rect.RectY + Rect.RectH))
                    pts.Add(New Point(Rect.RectX, Rect.RectY + Rect.RectH))

                End If
                

                

                Dim Pen As New Drawing.SolidBrush(Rect.PenColor)
                Ga.FillPolygon(Pen, pts.ToArray())

            Next

            If 관리구 <> "" Then
                '// 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


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

                    Try
                        'data = qr홈페이지1 & "/" & qr홈페이지2 & "/" & qr홈페이지3 & "/" & qr홈페이지4 & "=" & 관리구 & 전산번호 & "&name=" & 신선로전주번호 & ":" & 시공년월 & ":" & 장척 ' & " 시공자: " & 시공자 & " 감독자 : " & 감독자
                        data = qr홈페이지1 & "/" & qr홈페이지2 & "/" & qr홈페이지3 & "/" & qr홈페이지4 & "=" & 관리구 & "-" & 전산번호 & "&name=" & 신선로전주번호 & ":" & 장척 & "M" ' 시공자: " & 시공자 & " 감독자 : " & 감독자

                        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)   'data설정 임시


                            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
                    Catch ex As Exception
                        'MessageBox.Show("QR코드를 그리는데 DATA가 숫자인지 영숫자인지 모두인지 확인 후 선택하여 주세요")
                        MessageBox.Show(ex.ToString())
                    End Try

                Next


                '// qr코드를 그린다
                For Each Rect As S_QRCode1 In Draw_QRcode1
                    '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

                    rqr기타1 = gita1.Text
                    rqr기타2 = gita2.Text
                    rqr기타3 = gita3.Text
                    rqr기타4 = gita4.Text

                    Try
                        'data = q시공자 & q홈페이지 & q관리 & q관리1 & q관리2
                        If rqr기타1 <> "" And rqr기타2 <> "" And rqr기타3 <> "" And rqr기타4 <> "" Then
                            data = rqr기타1 & "/" & rqr기타2 & "/" & rqr기타3 & "/" & rqr기타4
                        ElseIf rqr기타1 <> "" And rqr기타2 <> "" And rqr기타3 <> "" Then
                            data = rqr기타1 & "/" & rqr기타2 & "/" & rqr기타3
                        ElseIf rqr기타1 <> "" And rqr기타2 <> "" Then
                            data = rqr기타1 & "/" & rqr기타2
                        ElseIf rqr기타1 <> "" Then
                            data = rqr기타1
                        Else
                            data = rqr기타1 & "/" & rqr기타2 & "/" & rqr기타3 & "/" & rqr기타4
                        End If

                        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
                    Catch ex As Exception
                        'MessageBox.Show("QR코드를 그리는데 DATA가 숫자인지 영숫자인지 모두인지 확인 후 선택하여 주세요")
                        MessageBox.Show(ex.ToString())
                    End Try

                Next

            End If

        End If


        If Me.tb_pagerepeat.Text = "" Or Me.tb_pagerepeat.Text < 1 Then Me.tb_pagerepeat.Text = "0"

        For pi As Short = 0 To Me.tb_pagerepeat.Text - 1  '//페이지당 연속출력할 횟수
            For i As Integer = 0 To Me.AllLabels.GetUpperBound(0)   '//모든 개체들에 대해서 인쇄를 설정한다.
                obj = Me.AllLabels(i).ctl

                If obj.설명.IndexOf("한줄") <> -1 Then
                    Console.WriteLine("한줄전주번호 표시 visible=" + obj.Visible.ToString())
                End If

                If obj.Visible AndAlso obj.MyText <> "" Then   '//화면에 보이는것만 한다.                

                    For rcnt As Short = 0 To obj.Repeat '//반복기능추가한다
                        NewFontSize = obj.MyFont.Size + Me.tb_myfontsize.Text
                        If NewFontSize < 0 Then NewFontSize = 0

                        If pi > 0 Then   '//연속출력에의한 샊깔변경
                            Brush = New SolidBrush(Drawing.Color.DarkKhaki) '//전경색으로 브러쉬를 만든다.
                        Else
                            If rcnt > 0 Then '//더미출력에의한 색깔변경
                                Brush = New SolidBrush(Drawing.Color.LightGray) '//전경색으로 브러쉬를 만든다.
                            Else
                                Brush = New SolidBrush(obj.MyForeColor) '//전경색으로 브러쉬를 만든다.
                            End If
                        End If

                        MyFont = New Font(obj.MyFont.FontFamily, NewFontSize, obj.MyFont.Style)
                        If obj.장평 = 100 AndAlso obj.장높이 = 100 Then '//장평미사용 문자열 처리
                            Ga.DrawString(obj.최종문자, MyFont, Brush, (obj.Left + Me.tb_secX.Text * pi + obj.RepeatX * rcnt), (obj.Top + Me.tb_secY.Text * pi + obj.RepeatY * rcnt))
                        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))
                            If rcnt > 0 Then
                                G.DrawString(obj.최종문자, MyFont, Brushes.LightGray, 0, 0)
                                G.Dispose()
                                Ga.DrawImage(BMP, New Point(obj.Left + Me.tb_secX.Text * pi + obj.RepeatX * rcnt, obj.Top + Me.tb_secY.Text * pi + obj.RepeatY * rcnt)) ', CInt(GetSize.Width * (v장평 / 100)), GetSize.Height)
                            Else
                                G.DrawString(obj.최종문자, MyFont, Brush, 0, 0)
                                G.Dispose()
                                Ga.DrawImage(BMP, New Point(obj.Left + Me.tb_secX.Text * pi, obj.Top + Me.tb_secY.Text * pi)) ', CInt(GetSize.Width * (v장평 / 100)), GetSize.Height)
                            End If
                        End If
                    Next
                End If
            Next
        Next
        Ga.Dispose()
        Me.PictureBox1.Image = BackScr
    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(BindingSource1.Position, True)
        End If
    End Sub

    Private Sub CheckBox1_CheckedChanged(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles cb_jc1.CheckedChanged
        Me.GeTviewData(Me.BindingSource1.Position, True)
    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
        If SelCon Is Nothing Then
            MsgBox("선택된 개체가 없습니다", MsgBoxStyle.Critical, "확인")
            Return
        End If
        For Each A As Control In SelCon
            CType(A, MyControlOLEDBv2.MyLabel).장평 = CInt(Me.tb_wordwidth.Text)
        Next
        ViewProperty(SelCon(0))
        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
        If SelCon Is Nothing Then
            MsgBox("선택된 개체가 없습니다", MsgBoxStyle.Critical, "확인")
            Return
        End If
        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)
        Next
        ViewProperty(SelCon(0))
        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).장높이
            a.공백 = CType(SelCon(0), MyControlOLEDBv2.MyLabel).공백
        Next
        Me.ViewProperty(CType(SelCon(0), MyControlOLEDBv2.MyLabel))
        Me.preview_window()
    End Sub
    Private Sub VScrollBar1_ValueChanged(ByVal sender As Object, ByVal e As System.EventArgs) Handles VScrollBar1.ValueChanged
        Debug.Print("ValueChange Current : " & Me.VScrollBar1.Value)

    End Sub
    Private Sub VScrollBar1_Scroll(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 If

    End Sub
    Private Sub PictureBox1_MouseClick(ByVal sender As Object, ByVal e As System.Windows.Forms.MouseEventArgs) Handles PictureBox1.MouseClick
        Dim SelItem As New ArrayList

        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
                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_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 '//길이패턴이 있으면
            AddLog(Admin, "문자패턴 검색 길이=" & 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
                    AddLog(Admin, "문자패턴오류 길이=" & Wlen & " Message=" & ex.Message.ToString, log)
                End Try
            Next
        Else
            AddLog(Admin, "문자패턴불일치 길이=" & Wlen & " 문자열=" & srcstr, log)
            Me.LOAD_STYLE(S라벨(0).DIV)
        End If
    End Sub
    Private Sub 기본ToolStripMenuItem_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 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 = 1
                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
        'MsgBox(Me.PictureBox1.Size.ToString)
    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 bt_prnpreview_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles bt_prnpreview.Click

        Me.Print_Preview()
    End Sub
    Private Sub ToolStripButton2_Click_1(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles ToolStripButton2.Click
        Process.Start(My.Application.Info.DirectoryPath & "\help\printform1.htm")
    End Sub
    Private Sub cm_styleeditoolStripMenuItem_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 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_jisun_SelectedIndexChanged(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles cmb_jisun.SelectedIndexChanged
        If Me.cmb_jisun.SelectedIndex > 0 Then
            Me.StatusStrip1.BackColor = Drawing.Color.Thistle
        Else
            Me.StatusStrip1.BackColor = Drawing.Color.White
        End If
    End Sub
    Private Sub ToolStripLabel2_ButtonClick(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles ToolStripLabel2.ButtonClick
        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 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 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
                If Me.cmb_controls.Text.IndexOf("감독자") > -1 Then
                    번호형식지정감독자(Me.tb_ntype.Text)
                Else
                    번호형식지정(Me.tb_ntype.Text)
                End If
            End If
            Me.preview_window()
        End If
    End Sub
#End Region

    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

    Public 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 & "," & Rect.Field & "):" & I)
            I += 1
        Next
        I = 0
        For Each Rect As S_Box In Draw_Box
            Me.ListBox1.Items.Add("박스(" & Rect.X & "," & Rect.Y & "," & Rect.Width & "," & Rect.Height & "," & Rect.Field & "):" & 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 & "," & Rect.Field & "):" & I)
            I += 1
        Next
        I = 0
        For Each Rect As S_Image In Draw_Image
            Me.ListBox1.Items.Add("그림(" & Rect.X & "," & Rect.Y & "," & Rect.Width & "," & Rect.Height & "," & Rect.Field & "):" & I)
            Me.ListBox1.Items.Add("그림위치(" & Rect.FileName & "):" & I)
            I += 1
        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 & "," & Rect.Field & "):" & I)
            I += 1
        Next
        I = 0
        For Each Rect As S_QRCode1 In Draw_QRcode1
            Me.ListBox1.Items.Add("RQR1(" & Rect.X & "," & Rect.Y & "," & Rect.Width & "," & Rect.Height & "," & Rect.Field & "):" & I)
            I += 1
        Next
        I = 0
        For Each Rect As S_Arrow In Draw_Arrow
            Dim sName As String = "ARR({0})({1},{2},{3},{4},{5},{6}):" & I
            sName = String.Format(sName, Rect.Direction, Rect.RectX, Rect.RectY, Rect.RectW, Rect.RectH, Rect.TriWidth, Rect.TriHeight)
            Me.ListBox1.Items.Add(sName)
            I += 1
        Next
        preview_window()
    End Sub

    Private Sub Button13_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button13.Click
        '//선추가
        Dim NewLine As 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
        NewLine.Field = ""

        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 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
        NewLine.Field = ""

        Draw_Box.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

        cmb_connfield.Enabled = True
        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
                Me.cmb_connfield.Text = Line.Field
            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
                Me.cmb_connfield.Text = Line.Field
            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
                Me.tb_dh.Text = Line.Height
                Me.cmb_connfield.Text = Line.Field
            Case "그"
                Dim Line As S_Image = Draw_Image(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
                Me.tb_image.Text = Line.FileName
                Me.cmb_connfield.Text = Line.Field
            Case "Q"
                Dim Line As S_QRCode = Draw_QRcode(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
                Me.cmb_connfield.Text = Line.Field
            Case "R"
                Dim Line As S_QRCode1 = Draw_QRcode1(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
                Me.cmb_connfield.Text = Line.Field

            Case "A" '//170711
                Dim Line As S_Arrow = Draw_Arrow(Me.ListBox1.Text.Split(":")(1))
                Me.bt_pencolor.BackColor = Line.PenColor
                Me.tb_pensize.Text = Line.PenWidth
                Me.tb_dx.Text = Line.RectX
                Me.tb_dy.Text = Line.RectY
                Me.tb_dw.Text = Line.RectW
                Me.tb_dh.Text = Line.RectH
                Me.tb_tx.Text = Line.TriWidth
                Me.tb_ty.Text = Line.TriHeight
                Me.tb_tx.Enabled = True
                Me.tb_ty.Enabled = True
                'Me.cmb_connfield.Text = Line.Field
                cmb_connfield.SelectedIndex = 5 + Line.Direction
        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, tb_image.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 "A"
                Dim Line As S_Arrow = Draw_Arrow(Me.ListBox1.Text.Split(":")(1))
                Line.PenColor = Me.bt_pencolor.BackColor
                Line.PenWidth = Me.tb_pensize.Text
                Line.RectX = Me.tb_dx.Text
                Line.RectY = Me.tb_dy.Text
                Line.RectW = Me.tb_dw.Text
                Line.RectH = Me.tb_dh.Text
                Line.Direction = Me.cmb_connfield.SelectedIndex - 5
                Line.TriHeight = Me.tb_ty.Text
                Line.TriWidth = Me.tb_tx.Text
                Draw_Arrow(Me.ListBox1.Text.Split(":")(1)) = Line

            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
                Line.Field = Me.cmb_connfield.Text
                Draw_Line(Me.ListBox1.Text.Split(":")(1)) = Line
            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
                Line.Field = Me.cmb_connfield.Text
                Draw_Box(Me.ListBox1.Text.Split(":")(1)) = Line
            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
                Line.Height = Me.tb_dh.Text
                Line.Field = Me.cmb_connfield.Text
                Draw_Circle(Me.ListBox1.Text.Split(":")(1)) = Line
            Case "그"
                Dim Line As New S_Image
                '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
                Line.FileName = Me.tb_image.Text
                Line.Field = Me.cmb_connfield.Text
                Draw_Image(Me.ListBox1.Text.Split(":")(1)) = Line
            Case "Q"
                Dim Line As New S_QRCode
                '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
                Line.Field = Me.cmb_connfield.Text
                Draw_QRcode(Me.ListBox1.Text.Split(":")(1)) = Line
            Case "R"
                Dim Line As New S_QRCode1
                '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
                Line.Field = Me.cmb_connfield.Text
                Draw_QRcode1(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 sname As String = "DrawCircle"
        Dim pname As String = "DrawImage"
        Dim qname As String = "DrawQRcode"
        Dim rname As String = "DrawQRcode1"
        Dim aname As String = "DrawArrow"
     
        Dim bcnt, lcnt, scnt, pcnt, qcnt, rcnt, acnt 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)
                ini.Write(bname, "box" & i & "field", L.Field)
            Next

            ini.Write(sname, "Count", Draw_Circle.Count)
            For i As Short = 1 To Draw_Circle.Count '//모두돌아서 저장한다.
                Dim L As S_Circle = Draw_Circle(i - 1)
                ini.Write(sname, "Circle" & i & "pencolor", L.PenColor.ToArgb)
                ini.Write(sname, "Circle" & i & "pensize", L.PenWidth)
                ini.Write(sname, "Circle" & i & "x", L.X)
                ini.Write(sname, "Circle" & i & "y", L.Y)
                ini.Write(sname, "Circle" & i & "x2", L.Width)
                ini.Write(sname, "Circle" & i & "y2", L.Height)
                ini.Write(sname, "Circle" & i & "field", L.Field)
            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)
                ini.Write(lname, "line" & i & "field", L.Field)
            Next

            ini.Write(pname, "Count", Draw_Image.Count)
            For i As Short = 1 To Draw_Image.Count '//모두돌아서 저장한다.
                Dim L As S_Image = Draw_Image(i - 1)
                'ini.Write(pname, "Image" & i & "pencolor", L.PenColor.ToArgb)
                'ini.Write(pname, "Image" & i & "pensize", L.PenWidth)
                ini.Write(pname, "Image" & i & "x", L.X)
                ini.Write(pname, "Image" & i & "y", L.Y)
                ini.Write(pname, "Image" & i & "x2", L.Width)
                ini.Write(pname, "Image" & i & "y2", L.Height)
                ini.Write(pname, "Image" & i & "location", L.FileName)
                ini.Write(pname, "Image" & i & "field", L.Field)
            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)
                ini.Write(qname, "qrcode" & i & "field", L.Field)
            Next

            ini.Write(rname, "Count", Draw_QRcode1.Count)
            For i As Short = 1 To Draw_QRcode1.Count '//모두돌아서 저장한다.
                Dim L As S_QRCode1 = Draw_QRcode1(i - 1)
                'ini.Write(pname, "Image" & i & "pencolor", L.PenColor.ToArgb)
                'ini.Write(pname, "Image" & i & "pensize", L.PenWidth)
                ini.Write(rname, "rqrcode1" & i & "x", L.X)
                ini.Write(rname, "rqrcode1" & i & "y", L.Y)
                ini.Write(rname, "rqrcode1" & i & "x2", L.Width)
                ini.Write(rname, "rqrcode1" & i & "y2", L.Height)
                ini.Write(rname, "rqrcode1" & i & "field", L.Field)
            Next

            ini.Write(aname, "Count", Draw_Arrow.Count)
            For i As Short = 1 To Draw_Arrow.Count '//모두돌아서 저장한다.
                Dim L As S_Arrow = Draw_Arrow(i - 1)
                ini.Write(aname, "arrow" & i & "direction", L.Direction.ToString())
                ini.Write(aname, "arrow" & i & "pencolor", L.PenColor.ToArgb)
                '//ini.Write(pname, "arrow" & i & "fillcolor", L.FillColor.ToArgb)
                ini.Write(aname, "arrow" & i & "pensize", L.PenWidth)
                ini.Write(aname, "arrow" & i & "tx", L.TriWidth)
                ini.Write(aname, "arrow" & i & "ty", L.TriHeight)
                ini.Write(aname, "arrow" & i & "x", L.RectX)
                ini.Write(aname, "arrow" & i & "y", L.RectY)
                ini.Write(aname, "arrow" & i & "x2", L.RectW)
                ini.Write(aname, "arrow" & i & "y2", L.RectH)
                ini.Write(aname, "arrow" & i & "field", L.Field)
            Next

        Else   '//여기는 읽는 부분

            Draw_Box.Clear()
            Draw_Line.Clear()
            Draw_Circle.Clear()
            Draw_Image.Clear()
            Draw_QRcode.Clear()
            Draw_QRcode1.Clear()
            Draw_Arrow.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)
                L.Field = ini.Read(bname, "box" & i & "field", "")
                Draw_Box.Add(L)
            Next

            scnt = ini.Read(sname, "Count", 0)
            For i As Short = 1 To scnt '//모두돌아서 저장한다.
                Dim L As New S_Circle
                L.PenColor = Drawing.Color.FromArgb(ini.Read(sname, "Circle" & i & "pencolor", 0))
                L.PenWidth = ini.Read(sname, "Circle" & i & "pensize", 3)
                L.X = ini.Read(sname, "Circle" & i & "x", 0)
                L.Y = ini.Read(sname, "Circle" & i & "y", 0)
                L.Width = ini.Read(sname, "Circle" & i & "x2", 10)
                L.Height = ini.Read(sname, "Circle" & i & "y2", 10)
                L.Field = ini.Read(sname, "Circle" & i & "field", "")
                Draw_Circle.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)
                L.Field = ini.Read(lname, "line" & i & "field", "")
                Draw_Line.Add(L)
            Next

            pcnt = ini.Read(pname, "Count", 0)
            For i As Short = 1 To pcnt '//모두돌아서 저장한다.
                Dim L As New S_Image
                'L.PenColor = Color.FromArgb(ini.Read(pname, "Circle" & i & "pencolor", 0))
                'L.PenWidth = ini.Read(sname, "Circle" & i & "pensize", 3)
                L.X = ini.Read(pname, "Image" & i & "x", 0)
                L.Y = ini.Read(pname, "Image" & i & "y", 0)
                L.Width = ini.Read(pname, "Image" & i & "x2", 10)
                L.Height = ini.Read(pname, "Image" & i & "y2", 10)
                L.FileName = ini.Read(pname, "Image" & i & "location", 10)
                L.Field = ini.Read(pname, "Image" & i & "field", "")
                Draw_Image.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)
                L.Field = ini.Read(qname, "qrcode" & i & "field", "")
                Draw_QRcode.Add(L)
            Next

            rcnt = ini.Read(rname, "Count", 0)
            For i As Short = 1 To rcnt '//모두돌아서 저장한다.
                Dim L As New S_QRCode1
                'L.PenColor = Color.FromArgb(ini.Read(pname, "Circle" & i & "pencolor", 0))
                'L.PenWidth = ini.Read(sname, "Circle" & i & "pensize", 3)
                L.X = ini.Read(rname, "rqrcode1" & i & "x", 0)
                L.Y = ini.Read(rname, "rqrcode1" & i & "y", 0)
                L.Width = ini.Read(rname, "rqrcode1" & i & "x2", 10)
                L.Height = ini.Read(rname, "rqrcode1" & i & "y2", 10)
                L.Field = ini.Read(rname, "rqrcode1" & i & "field", "")
                Draw_QRcode1.Add(L)
            Next

            acnt = ini.Read(aname, "Count", 0)
            For i As Short = 1 To acnt '//모두돌아서 저장한다.
                Dim L As New S_Arrow
                L.Direction = ini.Read(aname, "arrow" & i & "direction", 0)
                L.PenColor = System.Drawing.Color.FromArgb(ini.Read(aname, "arrow" & i & "pencolor", 0))
                L.PenWidth = ini.Read(aname, "arrow" & i & "pensize", 3)
                ' L.FillColor = System.Drawing.Color.FromArgb(ini.Read(aname, "arrow" & i & "fillcolor", 0))
                L.TriWidth = ini.Read(aname, "arrow" & i & "tx", 30)
                L.TriHeight = ini.Read(aname, "arrow" & i & "ty", 20)
                L.RectX = ini.Read(aname, "arrow" & i & "x", 0)
                L.RectY = ini.Read(aname, "arrow" & i & "y", 0)
                L.RectW = ini.Read(aname, "arrow" & i & "x2", 10)
                L.RectH = ini.Read(aname, "arrow" & i & "y2", 10)
                L.Field = ini.Read(aname, "arrow" & i & "field", "")
                Draw_Arrow.Add(L)
            Next


            Me.Refresh_Drawlist()
        End If

    End Sub

    Private Sub Button2_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button2.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 "그"
                    Draw_Image.RemoveAt(Me.ListBox1.Text.Split(":")(1))
                Case "Q"
                    Draw_QRcode.RemoveAt(Me.ListBox1.Text.Split(":")(1))
                Case "R"
                    Draw_QRcode1.RemoveAt(Me.ListBox1.Text.Split(":")(1))
                Case "A"
                    Draw_Arrow.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 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 tb_pagerepeat_KeyDown(ByVal sender As Object, ByVal e As System.Windows.Forms.KeyEventArgs) Handles tb_pagerepeat.KeyDown, tb_secX.KeyDown, tb_secY.KeyDown
        If e.KeyCode = Keys.Enter Then
            Me.preview_window()
        End If
    End Sub


    Private Sub tb_rep_KeyUp(ByVal sender As Object, ByVal e As System.Windows.Forms.KeyEventArgs) Handles tb_rep.KeyUp
        If e.KeyCode = Keys.Enter Then
            If Me.tb_rep.Text = "" OrElse Me.tb_rep Is vbNullString Then Me.tb_rep.Text = 0
            For Each A As Control In SelCon
                CType(A, MyLabel).Repeat = Me.tb_rep.Text
            Next
            Me.preview_window()
        End If
    End Sub

    Private Sub tb_repx_KeyUp(ByVal sender As Object, ByVal e As System.Windows.Forms.KeyEventArgs) Handles tb_repx.KeyUp
        If e.KeyCode = Keys.Enter Then
            If Me.tb_rep.Text = "" OrElse Me.tb_rep Is vbNullString Then Me.tb_rep.Text = 0
            For Each A As Control In SelCon
                CType(A, MyLabel).RepeatX = Me.tb_repx.Text
            Next
            Me.preview_window()
        End If
    End Sub

    Private Sub tb_repy_KeyUp(ByVal sender As Object, ByVal e As System.Windows.Forms.KeyEventArgs) Handles tb_repy.KeyUp
        If e.KeyCode = Keys.Enter Then
            If Me.tb_rep.Text = "" OrElse Me.tb_rep Is vbNullString Then Me.tb_rep.Text = 0
            For Each A As Control In SelCon
                CType(A, MyLabel).RepeatY = Me.tb_repy.Text
            Next
            Me.preview_window()
        End If
    End Sub

    Private Sub COS휴즈용량ToolStripMenuItem_Click(sender As System.Object, e As System.EventArgs) Handles COS휴즈용량ToolStripMenuItem.Click
        SAVE_PATTERNII(Me.휴즈용량, "FUSEPATTERNII", "F", False, "\휴즈용량.TXT")    '//선로명의 패턴을 저장합니다.
    End Sub

    Private Sub 상표시찰1단ToolStripMenuItem_Click(sender As System.Object, e As System.EventArgs) Handles 상표시찰1단ToolStripMenuItem.Click
        SAVE_PATTERNII(Me.상표시찰1단, "SANG1PATTERNII", "I", False, "\상표시찰1단.TXT")    '//선로명의 패턴을 저장합니다.
    End Sub

    Private Sub 상표시찰2단ToolStripMenuItem_Click(sender As System.Object, e As System.EventArgs) Handles 상표시찰2단ToolStripMenuItem.Click
        SAVE_PATTERNII(Me.상표시찰2단, "SANG2PATTERNII", "T", False, "\상표시찰2단.TXT")    '//선로명의 패턴을 저장합니다.
    End Sub

    Private Sub DoolStripMenuItem_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles DoolStripMenuItem.Click
        SAVE_PATTERNII(Me.비고명, "DLPATTERNII", "K", False, "\Dl명패턴2.TXT")    '//선로명의 패턴을 저장합니다.
    End Sub

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

    Private Sub gfdlStripMenuItem_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles bt_pattern_no.Click
        If Me.번호.IndexOf("H") <> -1 Then
            MsgBox("번호에 H가 있습니다. 이 패턴은 H가 없는 경우에 저장이 가능합니다.", MsgBoxStyle.Critical, "확인")
            Return
        End If
        SAVE_PATTERNII(Me.번호, "JJNUMPATTERNII", "X", False, "\번호패턴2.TXT")    '//H가 없는경우
    End Sub

    Private Sub bt_pattern_noH_Click(sender As System.Object, e As System.EventArgs) Handles bt_pattern_noH.Click
        If Me.번호.IndexOf("H") = -1 Then
            MsgBox("번호에 H가 없습니다. H가 있어야 이 패턴을 저장할 수 있습니다.", MsgBoxStyle.Critical, "확인")
            Return
        End If
        SAVE_PATTERNII(Me.번호, "JJNUMPATTERNII", "X", True, "\번호패턴2H.TXT")    '//H가 있는경우
    End Sub

    Private Sub bt_style_manager_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles bt_style_manager.Click
        SAVE_PATTERNII(Me.감독자, "MANGPATTERNII", "M", False, "\감독자패턴2.TXT")    '//선로명의 패턴을 저장합니다.
        'SAVE_PATTERNII(Me.감독자, "MANGPATTERN", "MM", "\감독자패턴2.TXT")    '//선로명의 패턴을 저장합니다.
    End Sub

    Private Sub bt_style_company_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles bt_style_company.Click
        SAVE_PATTERNII(Me.시공자, "MAKERPATTERNII", "C", False, "\시공자패턴2.TXT")    '//선로명의 패턴을 저장합니다.
    End Sub

    Private Sub Button14_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button14.Click


        '       Dim NewLine As S_Circle
        '      NewLine.PenColor = Color.Black
        '      NewLine.PenWidth = 3
        '      NewLine.X = 100
        '     NewLine.Y = 50
        '    NewLine.Width = 200
        '   NewLine.Height = 50
        '  Draw_Circle.Add(NewLine)
        '  Me.Refresh_Drawlist()

        Dim NewLine As S_Circle
        NewLine.PenColor = Drawing.Color.Black
        NewLine.PenWidth = 3
        NewLine.X = Draw_Circle.Count * 10
        NewLine.Y = Draw_Circle.Count * 10
        NewLine.Width = 100 + Draw_Circle.Count * 10
        'NewLine.Height = NewLine.Width
        NewLine.Field = ""

        Draw_Circle.Add(NewLine)
        Refresh_Drawlist()
    End Sub

    Private Sub Button16_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button16.Click
        Dim NewLine As S_Image
        NewLine.X = 100
        NewLine.Y = 100
        NewLine.Width = 0
        NewLine.Height = 0
        NewLine.FileName = ".\image\그림파일명.jpg"
        NewLine.Field = ""

        Draw_Image.Add(NewLine)
        Refresh_Drawlist()

    End Sub

    Private Sub Button17_Click_1(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button17.Click
        Dim NewLine As S_QRCode
        NewLine.X = 100
        NewLine.Y = 100
        NewLine.Width = 0
        NewLine.Height = 0
        NewLine.Field = ""

        Draw_QRcode.Add(NewLine)
        Refresh_Drawlist()
    End Sub
    'Public Sub qr_Draw()
    '    'Dim scale As Int16
    '    Dim version As Int16
    '    Dim image As Image
    '    Dim data As String
    '    Dim errorCorrect As String
    '    Dim qrCodeEncoder As New QRCodeEncoder()
    '    Dim encoding As String
    '    encoding = cboEncoding.Text
    '    If encoding = "3" Then
    '        qrCodeEncoder.QRCodeEncodeMode = ThoughtWorks.QRCode.Codec.QRCodeEncoder.ENCODE_MODE.BYTE
    '    ElseIf encoding = "1" Then
    '        qrCodeEncoder.QRCodeEncodeMode = ThoughtWorks.QRCode.Codec.QRCodeEncoder.ENCODE_MODE.ALPHA_NUMERIC
    '    ElseIf encoding = "2" Then
    '        qrCodeEncoder.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)
    '            qrCodeEncoder.QRCodeVersion = version
    '        Catch ex As Exception
    '            MessageBox.Show("Invaild Version!")
    '        End Try
    '    End If

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


    '    data = q시공자 & q홈페이지 ' & q관리 & q관리1 & q관리2

    '    image = qrCodeEncoder.Encode(data)          'data설정 임시....................
    '    PictureBox1.Image = image
    'End Sub

    Private Sub Button18_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button18.Click
        Dim NewLine As S_QRCode1
        NewLine.X = 100
        NewLine.Y = 100
        NewLine.Width = 0
        NewLine.Height = 0
        NewLine.Field = ""

        Draw_QRcode1.Add(NewLine)
        Refresh_Drawlist()
    End Sub

    Private Sub 장척3자리ToolStripMenuItem_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles 장척3자리ToolStripMenuItem.Click
        'If Not Me.cb_jc1.Checked Then
        '    MsgBox("기타스타일[장척3자리]를 사용하지 않기떄문에 저장이 되지 않습니다", MsgBoxStyle.Critical, "확인")
        '    Return
        'End If

        'If MsgBox("현재 스타일(기타-장척3자리)을 저장하시겠습니까?", MsgBoxStyle.Information + MsgBoxStyle.YesNo, "기타스타일저장") = MsgBoxResult.Yes Then
        '    Me.SAVE_STYLEC(Me.cmb_style.SelectedIndex & "STYLEJANGCHOK", "J")
        '    NOTICE("스타일(기타-장척3자리)을 저장했습니다", Me.lb_msg)
        'Else
        '    NOTICE("스타일(기타-장척3자리)저장이 취소되었습니다", Me.lb_msg)
        'End If

        'Dim A As New System.Text.StringBuilder
        'A.AppendLine("[기타스타일] 장척3자리 사용이 선택되어있습니다")
        'A.AppendLine()
        'A.AppendLine("기타스타일 저장을 클릭하세요")
        'If Me.cb_jc1.Checked Then
        '    MsgBox(A.ToString, MsgBoxStyle.Critical, "확인")
        '    Return
        'End If

        SAVE_PATTERNII(Me.장척, "CHOKPATTERNII", "J", False, "\장척패턴.TXT")    '//선로명의 패턴을 저장합니다.




    End Sub

    Private Sub cmb_sep_SelectedIndexChanged(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles cmb_sep.SelectedIndexChanged
        Me.preview_window()
    End Sub

    Private Sub cmb_connfield_SelectedValueChanged(sender As System.Object, e As System.EventArgs) Handles cmb_connfield.SelectedValueChanged
        If Me.ListBox1.SelectedIndex < 0 Then Return
        Dim SI As Short = Me.ListBox1.SelectedIndex

        '//새로만들어서 저장한다.
        Set_NewDraw()
        Me.Refresh_Drawlist()
        Me.ListBox1.SelectedIndex = SI
    End Sub

    
    Private Sub Button19_Click(sender As Object, e As EventArgs) Handles Button19.Click
        '//선추가
        Dim NewLine As S_Arrow
        NewLine.PenColor = Drawing.Color.Black
        NewLine.PenWidth = 3
        ' NewLine.FillColor = Drawing.Color.Black

        NewLine.TriHeight = 20
        NewLine.TriWidth = 30
        NewLine.RectX = 10
        NewLine.RectY = 10
        NewLine.RectW = 50
        NewLine.RectH = 50
        NewLine.Field = ""

        Draw_Arrow.Add(NewLine)
        Refresh_Drawlist()
    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



