Imports System.Drawing
Imports System.Math
Imports System.IO
Imports System.Drawing.Printing
Imports CEpole.C_Epole

Public Class Defalut_PrintForm

    Dim 행정도시 As String = ""
    Dim 지역명 As String = ""
    Dim 번지 As String = ""
    Dim 관리번호1 As String = ""
    Dim 관리번호2 As String = ""

    Dim 문의전화1 As String = ""
    Dim 문의전화2 As String = ""
    Dim 비고1 As String = ""
    Dim 비고2 As String = ""
    Dim 비고3 As String = ""

    'Cls_Tongshin 
    Dim 간선명 As String = "" 'GetSpread(Dv1, "간선명")
    Dim 전주번호 As String = "" 'GetSpread(Dv1, "전주번호")
    Dim 전주번호2 As String = "" 'GetSpread(Dv1, "전주번호2")
    Dim 중계기명 As String = "" 'GetSpread(I, "중계기명")
    Dim 시공일 As String = "" 'GetSpread(I, "시공일")
    Dim 시공자 As String = "" 'GetSpread(I, "시공자")
    Dim 연락처1 As String = "" 'GetSpread(I, "연락처1")
    Dim 연락처2 As String = "" 'GetSpread(I, "연락처2")

    'Cls_LCable
    Dim OLT번호 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 = ""

    Protected QRCODE1 As String = ""
    Protected QRCODE2 As String = ""
    Protected QRCODE3 As String = ""
    Protected QRCODE4 As String = ""
    Protected 일련번호 As String = ""

    Dim Dv1 As DataView

    '//Events
    Public WithEvents pDoc As New PrintDocument
    Public Event StatusMessage(ByVal Message As String, ByVal type As e_EventMessage)
    Public Event SelectedControl(ByVal obj As CEpole.C_label)
    Public Event DesignMode_Change(ByVal Mode As E_DesignMode)

    '//Shadows
    Public SrcTable As DataTable '//이건 각 폼에서 반드시 정의해서 써야한다.
    Public StyleDir As DirectoryInfo
    Public LogFile As String
    Public StyleFileC As String
    Public StyleTag As String
    Public SetForm As Frm_Prnset
    Public DT As DataTable
    Private vDesignMode As E_DesignMode

    Public DisableWaterMark As Boolean = False


    '//Shape 추가 090515
    Public Draw_Line As Shape_line
    Public Draw_Box As Shape_Box
    Public Draw_Image As Shape_Image
    Public Draw_Circle As Shape_Circle
    '//qr추가 20120722
    Public Draw_QRcode As Shape_QRcode

    '//이것들 공개해놓고 디자인모드에서 선택저장해놔도 오류난다
    '//숨김으로 설정하고 프로퍼티 만들어서 놓자
    Private Shadows WithEvents v_picturebox1 As Windows.Forms.PictureBox
    Private Shadows WithEvents v_scrolbar As Windows.Forms.ScrollBar
    Private Shadows WithEvents v_Bn As Windows.Forms.BindingNavigator

    '//캔바스조절용 버튼 정의
    Private Shadows WithEvents bt_canvasD As Windows.Forms.ToolStripButton
    Private Shadows WithEvents bt_canvasU As Windows.Forms.ToolStripButton
    Private Shadows WithEvents bt_canvasL As Windows.Forms.ToolStripButton
    Private Shadows WithEvents bt_canvasR As Windows.Forms.ToolStripButton

    '//스타일저장.패턴저장용 버튼정의
    Private Shadows WithEvents bt_SL As Windows.Forms.ToolStripButton
    Private Shadows WithEvents bt_SL2 As Windows.Forms.ToolStripButton
    'Private Shadows WithEvents bt_SC As Windows.Forms.ToolStripButton
    Private Shadows WithEvents bt_SS As Windows.Forms.ToolStripButton

    '//Normal
    Public AllLabels() As CEpole.C_label    '//전체갯수는 추가할대 셋팅한다.
    Public AllFullLabels() As S_FullLable    '//쪼개지지않은 1개의 아이템이 들어있다.

    Public NoView As Boolean = False   '//LOAD_STYLE 을 잠시 실행하지 않기위햇(중복실행방지)서 둔다.(..이벤트가.. -_-;;너무 중복으로 발생함)
    Public SrcIdx As Integer = -1  '//원본 리뷰에서 클릭된 인덱스
    Public Srcnum As Integer = -1  '//원본 리뷴에서 클릭된 번호값
    Public Srcrow As DataRowView
    Public FirstIdx As Integer = -1 '//새로 생성된 리뷰에서 적용될 인덱스

    Public SelCon As New ArrayList     '//선택된 레이블들이 저장된 배열이다.
    Public SelConDraw As New ArrayList    '//선택된 쉐이프 개체

    Public OnlyOne As CEpole.C_label   '//포커스를 가진 레이블이다.


    Public Dv As DataView   '//데이터뷰(실제로 이 뷰의 데이터를 가지고 출력을 행한다.)

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

    'Public Auto_Log As Boolean  '//로그를 사용할지 안할지
    Public Admin As Boolean
    Public DefStyleIndex As Short '//기본으로 사용할 스타일 인덱스

    Public Arin As New ACC.ARINCLASS
    Private Mylog As New Frm_Log

    Public OldType As Boolean
    Public Fixed() As String    '//고정문자가 들어있는데이터이다.


    ''' <summary>
    ''' 디자인모드를 번환/설정 합니다.
    ''' </summary>
    ''' <value></value>
    ''' <returns></returns>
    ''' <remarks></remarks>
    Public Property DMode() As E_DesignMode
        Get
            Return Me.vDesignMode
        End Get
        Set(ByVal value As E_DesignMode)
            Me.vDesignMode = value
            RaiseEvent StatusMessage("Design Mode = Default TextMode From From_Load Event", e_EventMessage.Normal)
            RaiseEvent DesignMode_Change(value)
        End Set
    End Property

    ''' <summary>
    ''' 현재지정된스타일파일명을 가져옵니다.
    ''' </summary>
    ''' <value></value>
    ''' <returns></returns>
    ''' <remarks></remarks>
    Public ReadOnly Property DesignFile() As FileInfo
        Get
            Return New FileInfo(ReplaceExt(StyleDir.FullName & "\" & StyleList(SetForm.cmb_style.SelectedIndex).File, "Design"))
        End Get
    End Property

#Region "컨트롤연결을 위한 속성선언"
    Public Property Ctl_Button_D() As Windows.Forms.ToolStripButton
        Get
            Return Me.bt_canvasD
        End Get
        Set(ByVal value As System.Windows.Forms.ToolStripButton)
            Me.bt_canvasD = value
        End Set
    End Property

    Public Property Ctl_Button_u() As Windows.Forms.ToolStripButton
        Get
            Return Me.bt_canvasU
        End Get
        Set(ByVal value As System.Windows.Forms.ToolStripButton)
            Me.bt_canvasU = value
        End Set
    End Property

    Public Property Ctl_Button_l() As Windows.Forms.ToolStripButton
        Get
            Return Me.bt_canvasL
        End Get
        Set(ByVal value As System.Windows.Forms.ToolStripButton)
            Me.bt_canvasL = value
        End Set
    End Property

    Public Property Ctl_Button_r() As Windows.Forms.ToolStripButton
        Get
            Return Me.bt_canvasR
        End Get
        Set(ByVal value As System.Windows.Forms.ToolStripButton)
            Me.bt_canvasR = value
        End Set
    End Property

    ''//스타일저장.패턴저장용 버튼정의
    Public Property Ctl_Button_SaveL() As Windows.Forms.ToolStripButton
        Get
            Return Me.bt_SL
        End Get
        Set(ByVal value As System.Windows.Forms.ToolStripButton)
            Me.bt_SL = value
        End Set
    End Property

    Public Property Ctl_Button_SaveL2() As Windows.Forms.ToolStripButton
        Get
            Return Me.bt_SL2
        End Get
        Set(ByVal value As System.Windows.Forms.ToolStripButton)
            Me.bt_SL2 = value
        End Set
    End Property

    'Public Property Ctl_Button_SaveC() As Windows.Forms.ToolStripButton
    '    Get
    '        Return Me.bt_SC
    '    End Get
    '    Set(ByVal value As System.Windows.Forms.ToolStripButton)
    '        Me.bt_SC = value
    '    End Set
    'End Property

    Public Property Ctl_Button_SaveS() As Windows.Forms.ToolStripButton
        Get
            Return Me.bt_SS
        End Get
        Set(ByVal value As System.Windows.Forms.ToolStripButton)
            Me.bt_SS = value
        End Set
    End Property

    '//기타 컨트롤
    Public Property Ctl_PictureBox() As Windows.Forms.PictureBox
        Get
            Return Me.v_picturebox1
        End Get
        Set(ByVal value As System.Windows.Forms.PictureBox)
            Me.v_picturebox1 = value
        End Set
    End Property

    Public Property Ctl_BindingNavi() As Windows.Forms.BindingNavigator
        Get
            Return Me.v_Bn
        End Get
        Set(ByVal value As System.Windows.Forms.BindingNavigator)
            Me.v_Bn = value
        End Set
    End Property

    Public Property Ctl_ScrollBar() As Windows.Forms.ScrollBar
        Get
            Return Me.v_scrolbar
        End Get
        Set(ByVal value As System.Windows.Forms.ScrollBar)
            Me.v_scrolbar = value
        End Set
    End Property


#End Region

    ''' <summary>
    ''' 초기화합니다.
    ''' </summary>
    ''' <remarks></remarks>
    Public Sub Initialize(ByVal V_Srctable As DataTable, ByVal styleTag As String,
                            ByVal v_SettingFile As String, ByVal v_DefStyleIndex As Short, Optional ByVal ADT As DataTable = Nothing, Optional ByVal OT As Boolean = False)

        RaiseEvent StatusMessage("폼을 초기화합니다", e_EventMessage.Normal)

        Me.SrcTable = V_Srctable
        Me.StyleDir = New DirectoryInfo(My.Application.Info.DirectoryPath & "\" & styleTag)
        Me.StyleTag = styleTag
        Me.LogFile = "\LOG_" & Me.StyleTag & ".txt"
        Me.StyleFileC = My.Application.Info.DirectoryPath & "\" & styleTag & "C.ini"
        Me.DefStyleIndex = v_DefStyleIndex
        Me.DT = ADT
        Me.OldType = OT

        Eini = New ACC.MyINI(v_SettingFile)

        If SrcTable Is Nothing Then   '//개발자 기본셋팅으로 설정
            RaiseEvent StatusMessage("개발자 기본셋팅이 설정됩니다.", e_EventMessage.Normal)
            'Auto_Log = True
            Admin = True
            Me.NoView = True
        End If

        '///////////////세부설정 폼을 띄웁니다.
        RaiseEvent StatusMessage("[Default_PrintForm] 세부설정 폼을 초기화합니다.", e_EventMessage.Normal)
        SetForm = New Frm_Prnset(Me)
        SetForm.Top = Me.Top
        SetForm.Left = Me.Left + Me.Width + 10
        SetForm.Show()

        'RaiseEvent StatusMessage("폼 기본설정을 불러옵니다", e_EventMessage.Normal)
        'Me.Load_Setting()   '//현재는 지정된 프린터명만 가져온다.

        RaiseEvent StatusMessage("[Default_PrintForm] 컨트롤을 초기화합니다.", e_EventMessage.Normal)
        Me.SetControls() '//컨트롤을 초기화합니다.

        '//컨텍스트메뉴활성화
        'For Each A As CEpole.C_Epole.S_FullLable In Me.AllFullLabels
        '    '//현재그룹을 넣는다
        '    Dim Itema As Windows.Forms.ToolStripItem = Me.v_cm.Items.Add(A.Desc)
        '    Itema.Tag = "nice" & A.Desc
        '    AddHandler Itema.Click, AddressOf ToolStripMenuItem_Click
        'Next

        RaiseEvent StatusMessage("[Default_PrintForm] 컨트롤의 인덱스값을 초기화합니다.", e_EventMessage.Normal)
        Me.SetControlIndex() '//컨트롤을 초기화합니다.

        RaiseEvent StatusMessage("[Default_PrintForm] 컨트롤의 도움말을 초기화합니다.", e_EventMessage.Normal)
        Me.SetToolTip()  '//컨트롤의 툴팁을 표시합니다.

        RaiseEvent StatusMessage("[Default_PrintForm] 이벤트핸들러를 등록합니다.", e_EventMessage.Normal)
        SetEventHandler()

        RaiseEvent StatusMessage("모든 스타일을 검색합니다.", e_EventMessage.Normal)
        If Me.DT Is Nothing Then
            If Not Me.GetStyleList() Then   '//컨트롤의 툴팁을 표시합니다.
                MsgBox("스타일을 구성하지 못했습니다" & vbCrLf & "출력을 할 수 없습니다", MsgBoxStyle.Critical, "오류")
                Me.Close()
            End If
        Else
            If Not Me.GetStyleList(DT) Then   '//컨트롤의 툴팁을 표시합니다.
                MsgBox("스타일을 구성하지 못했습니다" & vbCrLf & "출력을 할 수 없습니다", MsgBoxStyle.Critical, "오류")
                Me.Close()
            End If
        End If

        RaiseEvent StatusMessage("기본스타일을 설정합니다.", e_EventMessage.Normal)
        If Srcrow Is Nothing Then '//가져온 행값이인덱스가 없으므로 1번째 스타일을 지정한다.
            FirstIdx = 0 '//또한 맨 처음 데이터를 표시하게된다.
        Else
            Srcnum = Srcrow("번호") 'srcTable.Rows(SrcIdx).Item("번호")
            RaiseEvent StatusMessage("선택된 번호값잉 있습니다 = " & Srcnum, e_EventMessage.Normal)
        End If

        Try
            SetForm.cmb_style.SelectedIndex = Me.DefStyleIndex   '//여기서 데이터가 걸러지게된다.
        Catch ex As Exception
            SetForm.cmb_style.SelectedIndex = 0
        End Try
        If SetForm.cmb_style.SelectedIndex = -1 Then
            If SetForm.cmb_style.Items.Count > 0 Then
                SetForm.cmb_style.SelectedIndex = 0
            Else
                MsgBox("선택가능한 스타일이 존재하지않습니다", MsgBoxStyle.Critical, "확인")
            End If
        End If
        If Me.Admin Then Mylog.Show()
    End Sub

    ''' <summary>
    ''' 지정된 폴더에서 스타일파일을 읽어옵니다.
    ''' </summary>
    ''' <remarks></remarks>
    Public Function GetStyleList() As Boolean
        '//스타일명을 가져와서 콤보박스에 표시합니다.
        '//style 폴더아래의 ini 파일전체를 스타일 이라한다.
        '//파일을 읽어서 메모리에 저장한다.
        Dim FileFilter As String = IIf(OldType, "*.ini", "*.cfg")

        If Not StyleDir.Exists Then StyleDir.Create()
        Dim CurIdx As Integer = 0
        Dim StyleCnt As Short

        StyleCnt = StyleDir.GetFiles(FileFilter).GetUpperBound(0)

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



        If StyleCnt = -1 Then
            If MsgBox("선택가능한 스타일이 존재하지 않습니다." & vbCrLf & "새로운 스타일을 생성하시겠습니까?", MsgBoxStyle.OkCancel Or MsgBoxStyle.Critical, "확인") = MsgBoxResult.Ok Then
                If SetForm.Make_NewStyle() = False Then
                    Return False
                Else   '//스타일을 만들었으니 배열을 다시해준다.
                    StyleCnt = StyleDir.GetFiles(FileFilter).GetUpperBound(0)
                    If StyleCnt = -1 Then
                        MsgBox("선택가능한 스타일이 없습니다", MsgBoxStyle.Critical, "확인")
                        Return False
                    End If
                    ReDim StyleList(StyleCnt)
                End If
            Else
                Return False
            End If
        End If
        ReDim StyleList(StyleCnt)

        'Arin.WLog2(Auto_Log, "GetStyleList(파일에서 스타일목을 가져온다)", LogFile)
        SetForm.cmb_style.Items.Clear()

        '//파일명을 가져와서 모두 배열에 저장한다.
        Dim Stylenames As New ArrayList
        Dim InTest As ACC.MyINI


        For Each Fi As IO.FileInfo In StyleDir.GetFiles(FileFilter)
            InTest = New ACC.MyINI(Fi.FullName)
            Stylenames.Add(InTest.Read("style", "desc", "스타일설명") & "/" & Fi.FullName)
        Next

        Stylenames.Sort()
        For Each FIFullName As String In Stylenames
            RaiseEvent StatusMessage("Load StyleFile fileName = " & FIFullName.Split("/")(1), e_EventMessage.Normal)
            GetAllsection(StyleList, FIFullName.Split("/")(1), CurIdx, Me.OldType)
            If (StyleList(CurIdx).visible = False) Then '//1090223 - 미표시 내용
                If DisableWaterMark Then
                    SetForm.cmb_style.Items.Add("[" + CurIdx.ToString() + "] " + StyleList(CurIdx).Desc + "-숨김")
                Else
                    '//일반사용자는 목록을 생성 안함 190223
                End If

            Else
                SetForm.cmb_style.Items.Add("[" + CurIdx.ToString() + "] " + StyleList(CurIdx).Desc)
            End If

            CurIdx += 1
        Next
        Return True
    End Function

    ''' <summary>
    ''' 데이터테이블로부터 스타일목록을 가져옵니다. 필드명은0번째로 합니다.
    ''' </summary>
    ''' <param name="Dt"></param>
    ''' <returns></returns>
    ''' <remarks></remarks>
    Public Function GetStyleList(ByVal Dt As DataTable) As Boolean
        '//스타일명을 가져와서 콤보박스에 표시합니다.
        '//style 폴더아래의 ini 파일전체를 스타일 이라한다.
        '//파일을 읽어서 메모리에 저장한다.
        ' Dim Arinini As MyINI
        If Dt Is Nothing Then Return False
        If Dt.Rows.Count = 0 Then Return False

        Dim FileFilter As String = IIf(OldType, "*.ini", "*.cfg")
        Dim CurIdx As Integer = 0
        Dim StyleCnt As Short = StyleDir.GetFiles("*.cfg").GetUpperBound(0)
        ReDim StyleList(StyleCnt)
        Dim Section, Value As New ArrayList
        Dim SectionIdx As Integer = 0

        SetForm.cmb_style.Items.Clear()
        For Each FI As IO.FileInfo In StyleDir.GetFiles(FileFilter)
            'Arin.WLog2(Auto_Log, "파일명=(" & FI.FullName & ") 의 스타일을 가져옵니다 메모리로", LogFile)
            RaiseEvent StatusMessage("Load StyleFile fileName = " & FI.FullName, e_EventMessage.Normal)
            GetAllsection(StyleList, FI.FullName, CurIdx, Me.OldType)

            If (StyleList(CurIdx).visible = False) Then
                If DisableWaterMark Then
                    SetForm.cmb_style.Items.Add("[" + CurIdx.ToString() + "] " + StyleList(CurIdx).Desc + "-숨김")
                Else
                    '//일반사용자 추가 안함 190223
                End If

            Else
                SetForm.cmb_style.Items.Add("[" + CurIdx.ToString() + "] " + StyleList(CurIdx).Desc)
            End If
            CurIdx += 1
        Next
        Return True
    End Function

    ''' <summary>
    ''' Alllabels 의 아이템을 반환합니다.(index 번호)
    ''' </summary>
    ''' <param name="index"></param>
    ''' <returns></returns>
    ''' <remarks></remarks>
    Public Function Get_Control(ByVal index As Integer) As CEpole.C_label
        'MsgBox(AllLabels(index).ToString())
        Return Me.AllLabels(index)
    End Function

    ''' <summary>
    ''' Label컨트롤의 기본이름등의 초기화 셋팅을 한다.
    ''' </summary>
    ''' <remarks></remarks>
    Public Overridable Sub SetControls()
        MsgBox("SetControls 함수를 재정의하세요 " & vbCrLf & "InitControl을 이용하시오")
    End Sub


    ''' <summary>
    ''' 이벤트핸들할게잇으면 이곳에 정의해서사용한다.
    ''' </summary>
    ''' <remarks></remarks>
    Public Overridable Sub SetEventHandler()
        MsgBox("SetEvnetHandler 함수를 재정의하세요" & vbCrLf & "사용자하지않더라도 정의해야 이메세지가 나오지 않습니다")
    End Sub

    Public Sub InitControl(ByRef IDXnumber As Short, ByRef A_Firstindex As Short, ByRef FirstIndex As Short, ByVal ArrayCount As Short, ByVal LineMaxCharNum As Short, ByVal Chb As Windows.Forms.ToolStripMenuItem, ByVal Desc As String, ByVal Tag As String, Optional ByVal Pattern As String = "", Optional ByVal p_Fixed As Boolean = False, Optional ByVal LineT As E_LineType = E_LineType.sum)   '//각컨트롤을 초기화 한다.
        Dim LoopIndex As Short = 1
        IDXnumber = A_Firstindex
        ReDim Preserve Me.AllFullLabels(A_Firstindex)  '//이건그룹이다.
        Me.AllFullLabels(A_Firstindex).Desc = Desc
        Me.AllFullLabels(A_Firstindex).Tag = Tag
        If Pattern = "" Then
            Me.AllFullLabels(A_Firstindex).Pattern = Tag & "PTRN"
        Else
            Me.AllFullLabels(A_Firstindex).Pattern = Pattern
        End If
        Me.AllFullLabels(A_Firstindex).Moved = False
        Me.AllFullLabels(A_Firstindex).LineType = LineT '//기본값 혼합
        Me.AllFullLabels(A_Firstindex).NumType = "20,0,0"  '//왠만해서 모두 표시하게한다.
        Me.AllFullLabels(A_Firstindex).ApplyPattern = E_PatternType.None
        Me.AllFullLabels(A_Firstindex).LineMaxChar = LineMaxCharNum '//한줄에 최대 4자가오도록 기본값을 설정한다.
        Me.AllFullLabels(A_Firstindex).CheckBox = Chb
        Me.AllFullLabels(A_Firstindex).Fixed = p_Fixed
        'Me.AllFullLabels(A_Firstindex).SeparatePattern = False
        Chb.Text = Desc
        Chb.Visible = True
        For i As Short = FirstIndex To (FirstIndex - 1) + ArrayCount '//여기+1을 변경해서 컨트롤의 세부갯수를 조절한다.
            If LoopIndex = 1 Then Me.AllFullLabels(A_Firstindex).Si = FirstIndex '//1번쨰 줄이라면
            If Me.AllLabels.GetUpperBound(0) < i Then ReDim Preserve Me.AllLabels(i)
            Me.AllLabels(i) = New CEpole.C_label
            Me.AllLabels(i).Tag = Me.AllFullLabels(A_Firstindex).Tag
            Me.AllLabels(i).Desc = Me.AllFullLabels(A_Firstindex).Desc & "[" & LoopIndex & "]"
            Me.AllLabels(i).Name = Me.AllFullLabels(A_Firstindex).Tag & LoopIndex
            Me.AllLabels(i).Idx = i  '//라벨배열의 인덱스
            Me.AllLabels(i).Gidx = A_Firstindex   '//라벨그룹배열의 인덱스
            Me.AllLabels(i).Text = ""
            ' Me.AllLabels(i).UseHPattern = False
            Me.AllLabels(i).Fixed = p_Fixed
            If Pattern <> "" Then Me.AllLabels(i).HasPattern = True '//패턴들어가잇다
            Me.Add_ControlsList(Me.AllLabels(i).Desc)
            LoopIndex += 1
            FirstIndex += 1
        Next
        Me.AllFullLabels(A_Firstindex).Ei = Me.AllLabels.GetUpperBound(0)
        A_Firstindex += 1
    End Sub

    Public Sub InitControl1(ByRef IDXnumber As Short, ByRef A_Firstindex As Short, ByRef FirstIndex As Short, ByVal ArrayCount As Short, ByVal LineMaxCharNum As Short, ByVal Chb As Windows.Forms.ToolStripMenuItem, ByVal Desc As String, ByVal Tag As String, Optional ByVal Pattern As String = "", Optional ByVal p_Fixed As Boolean = False, Optional ByVal LineT As E_LineType = E_LineType.sum)   '//각컨트롤을 초기화 한다.
        Dim LoopIndex As Short = 1
        IDXnumber = A_Firstindex
        ReDim Preserve Me.AllFullLabels(A_Firstindex)  '//이건그룹이다.
        Me.AllFullLabels(A_Firstindex).Desc = Desc
        Me.AllFullLabels(A_Firstindex).Tag = Tag
        If Pattern = "" Then
            Me.AllFullLabels(A_Firstindex).Pattern = Tag & "PTRN"
        Else
            Me.AllFullLabels(A_Firstindex).Pattern = Pattern
        End If
        Me.AllFullLabels(A_Firstindex).Moved = False
        Me.AllFullLabels(A_Firstindex).LineType = LineT '//기본값 혼합
        Me.AllFullLabels(A_Firstindex).NumType = "20,0,0"  '//왠만해서 모두 표시하게한다.
        Me.AllFullLabels(A_Firstindex).ApplyPattern = E_PatternType.None
        Me.AllFullLabels(A_Firstindex).LineMaxChar = LineMaxCharNum '//한줄에 최대 4자가오도록 기본값을 설정한다.
        Me.AllFullLabels(A_Firstindex).CheckBox = Chb
        Me.AllFullLabels(A_Firstindex).Fixed = p_Fixed
        '  Me.AllFullLabels(A_Firstindex).SeparatePattern = False
        Chb.Text = Desc
        Chb.Visible = True
        For i As Short = FirstIndex To (FirstIndex - 1) + ArrayCount '//여기+1을 변경해서 컨트롤의 세부갯수를 조절한다.
            If LoopIndex = 1 Then Me.AllFullLabels(A_Firstindex).Si = FirstIndex '//1번쨰 줄이라면
            If Me.AllLabels.GetUpperBound(0) < i Then ReDim Preserve Me.AllLabels(i)
            Me.AllLabels(i) = New CEpole.C_label
            Me.AllLabels(i).Tag = Me.AllFullLabels(A_Firstindex).Tag
            Me.AllLabels(i).Desc = Me.AllFullLabels(A_Firstindex).Desc & "[" & LoopIndex & "]"
            Me.AllLabels(i).Name = Me.AllFullLabels(A_Firstindex).Tag & LoopIndex
            Me.AllLabels(i).Idx = i  '//라벨배열의 인덱스
            Me.AllLabels(i).Gidx = A_Firstindex   '//라벨그룹배열의 인덱스
            Me.AllLabels(i).Text = ""
            'Me.AllLabels(i).UseHPattern = False
            Me.AllLabels(i).Fixed = p_Fixed
            If Pattern <> "" Then Me.AllLabels(i).HasPattern = True '//패턴들어가잇다
            Me.Add_ControlsList(Me.AllLabels(i).Desc)
            LoopIndex += 1
            FirstIndex += 1
        Next
        Me.AllFullLabels(A_Firstindex).Ei = Me.AllLabels.GetUpperBound(0)
        A_Firstindex += 1
    End Sub
    Public Overridable Sub SetControlIndex()
        MsgBox("SetcontrolIndex 함수를 재정의하세요")
    End Sub

    ''' <summary>
    ''' 데이터를 화면에 표시한다.
    ''' </summary>
    ''' <param name="index"></param>
    ''' <param name="previewWindow"></param>
    ''' <param name="번호패턴검사"></param>
    ''' <remarks></remarks>
    Public Overridable Sub GeTviewData(ByVal index As Integer, ByVal previewWindow As Boolean, Optional ByRef 번호패턴검사 As Integer = -1)
        MsgBox("GeTviewData 함수를 재정의하세요")
    End Sub

    ''' <summary>
    ''' 컨트롤의 툴팁을 표시합니다.(강제아님 ㅋㅋ)
    ''' </summary>
    ''' <remarks></remarks>
    Public Overridable Sub SetToolTip()
        Dim TMSG As System.Text.StringBuilder
        TMSG = New System.Text.StringBuilder()
        TMSG.AppendLine()
        TMSG.AppendLine("<개체선택도움말>")
        TMSG.AppendLine()
        TMSG.AppendLine("[왼쪽클릭] 현재 마우스 아래의 개체를 선택합니다(단일선택)")
        TMSG.AppendLine("[Ctrl+왼쪽클릭] 현재 마우스 아래 개체의 그룹전체가 선택됩니다")
        TMSG.AppendLine("[오른쪽클릭] 현재선택된것외에 추가로 선택합니다(다중선택)")
        TMSG.AppendLine()
        TMSG.AppendLine()
        Me.ToolTip1.SetToolTip(Me.v_picturebox1, TMSG.ToString)

    End Sub

    ''' <summary>
    ''' 입력된 값의 일치하는 태그의 라벨을 초기화합니다.
    ''' </summary>
    ''' <param name="lbl"></param>
    ''' <remarks></remarks>
    Public Sub CLEAR_ITEM(ByVal lbl As S_FullLable, Optional ByVal RaiseMsg As Boolean = True)
        If RaiseMsg Then RaiseEvent StatusMessage("<< [P] Celar_Item Tag=" & lbl.Tag, e_EventMessage.Normal)
        For i As Short = lbl.Si To lbl.Ei
            Me.AllLabels(i).Text = ""
            Me.AllLabels(i).visible = False
        Next
    End Sub


    ''' <summary>
    ''' 문자패턴을 저장합니다.
    ''' </summary>   
    ''' <param name="LOGFILENAME"></param>
    ''' <remarks></remarks>
    Public Sub SAVE_PATTERNII(ByVal flbl As S_FullLable, Optional ByVal LOGFILENAME As String = "\패턴.TXT", Optional ByVal prompt As Boolean = True)   '패턴을 저장합니다. 패턴역시 위치/크기/wordwidth등이 저장됩니다.
        '//이곳은 문자패턴을 저장한다.
        'Dim Arinini As New CommonClassv2.MyINI(StyleDir.FullName & "\" & StyleList(SetForm.cmb_style.SelectedIndex).File)
        Dim Arinini As New ACC.MyINI(ReplaceExt(StyleDir.FullName & "\" & StyleList(SetForm.cmb_style.SelectedIndex).File, flbl.Tag.Substring(0, 1)))
        Dim BUF() As Char = flbl.text.ToCharArray
        Dim mb As String = PATTERN_ENC(flbl.text)
        Dim Pname As String = flbl.Pattern & "II" & mb.ToString
        ' MsgBox("saveii" & Arinini.FileName)
        'If flbl.srccablerow = -1 Then  '//패턴불가능한 싱글라인일경우
        '    If MsgBox("선택한 개체는 패턴이 적용되지않는 개체입니다" & vbCrLf & vbCrLf & "위치정보를 저장하시려면 스타일저장을 하세요" & vbCrLf _
        '    & vbCrLf & "지금 스타일을 저장하시겠습니까?", MsgBoxStyle.Information Or MsgBoxStyle.OkCancel, "확인") = MsgBoxResult.Ok Then
        '        Me.SAVE_STYLE()
        '    End If
        '    Return
        'End If

        If flbl.Fixed Then
            MsgBox("고정문자는 스타일저장을 사용하세요", MsgBoxStyle.Critical, "패턴저장불가")
            Return
        End If

        'If prompt Then
        '    If MsgBox(flbl.Desc & "의 문자패턴을 저장하시겠습니까?", MsgBoxStyle.Information + MsgBoxStyle.OkCancel, "확인") <> MsgBoxResult.Ok Then Return
        'End If

        Arinini.Write(Pname, "DESC", flbl.Desc & "문자패턴저장")
        Arinini.Write(Pname, "LineType", flbl.LineType)
        Arinini.Write(Pname, "NumType", flbl.NumType)

        '  Arinini.Write(Pname, "SepPattern", flbl.SeparatePattern)   '//개별패턴적용여부
        For i As Short = flbl.Si To flbl.Ei
            Dim Lbl As CEpole.C_label = Me.AllLabels(i)
            Arinini.Write(Pname, Lbl.Name & "pos", Lbl.Left & "," & Lbl.Top & "," & Lbl.Width & "," & Lbl.Height)
            Arinini.Write(Pname, Lbl.Name & "font", Lbl.Font.Name & "," & Lbl.Font.Size & "," & Lbl.Font.Underline & "," & Lbl.Font.Bold & "," & Lbl.Font.Italic & "," & Lbl.WordWidth & "," & Lbl.WordHeight)
            Arinini.Write(Pname, Lbl.Name & "visible", Lbl.visible)
            Arinini.Write(Pname, Lbl.Name & "space", Lbl.WordSpace)
            Arinini.Write(Pname, Lbl.Name & "fc", Lbl.ForeColor2.ToArgb.ToString()) '//160515
            '  Arinini.Write(Pname, Lbl.Name & "usepatternh", IIf(Lbl.UseHPattern, "1", "0"))
        Next
        RaiseEvent StatusMessage(">>Save PatternII", e_EventMessage.Normal)
        Me.데이터테이블갱신()
    End Sub

    Public Sub SAVE_PATTERNIIH(ByVal flbl As S_FullLable, Optional ByVal LOGFILENAME As String = "\패턴H.TXT", Optional ByVal prompt As Boolean = True)   '패턴을 저장합니다. 패턴역시 위치/크기/wordwidth등이 저장됩니다.
        '//이곳은 문자패턴을 저장한다.
        'Dim Arinini As New CommonClassv2.MyINI(StyleDir.FullName & "\" & StyleList(SetForm.cmb_style.SelectedIndex).File)
        Dim Arinini As New ACC.MyINI(ReplaceExt(StyleDir.FullName & "\" & StyleList(SetForm.cmb_style.SelectedIndex).File, flbl.Tag.Substring(0, 1)))
        Dim BUF() As Char = flbl.text.ToCharArray
        Dim mb As String = PATTERN_ENC(flbl.text, True)
        Dim Pname As String = flbl.Pattern & "II" & mb.ToString
        ' MsgBox("saveii" & Arinini.FileName)
        'If flbl.srccablerow = -1 Then  '//패턴불가능한 싱글라인일경우
        '    If MsgBox("선택한 개체는 패턴이 적용되지않는 개체입니다" & vbCrLf & vbCrLf & "위치정보를 저장하시려면 스타일저장을 하세요" & vbCrLf _
        '    & vbCrLf & "지금 스타일을 저장하시겠습니까?", MsgBoxStyle.Information Or MsgBoxStyle.OkCancel, "확인") = MsgBoxResult.Ok Then
        '        Me.SAVE_STYLE()
        '    End If
        '    Return
        'End If

        If flbl.Fixed Then
            MsgBox("고정문자는 스타일저장을 사용하세요", MsgBoxStyle.Critical, "패턴저장불가")
            Return
        End If

        'If prompt Then
        '    If MsgBox(flbl.Desc & "의 문자패턴을 저장하시겠습니까?", MsgBoxStyle.Information + MsgBoxStyle.OkCancel, "확인") <> MsgBoxResult.Ok Then Return
        'End If

        Arinini.Write(Pname, "DESC", flbl.Desc & "문자패턴(H)저장")
        Arinini.Write(Pname, "LineType", flbl.LineType)
        Arinini.Write(Pname, "NumType", flbl.NumType)

        '  Arinini.Write(Pname, "SepPattern", flbl.SeparatePattern)   '//개별패턴적용여부
        For i As Short = flbl.Si To flbl.Ei
            Dim Lbl As CEpole.C_label = Me.AllLabels(i)
            Arinini.Write(Pname, Lbl.Name & "pos", Lbl.Left & "," & Lbl.Top & "," & Lbl.Width & "," & Lbl.Height)
            Arinini.Write(Pname, Lbl.Name & "font", Lbl.Font.Name & "," & Lbl.Font.Size & "," & Lbl.Font.Underline & "," & Lbl.Font.Bold & "," & Lbl.Font.Italic & "," & Lbl.WordWidth & "," & Lbl.WordHeight)
            Arinini.Write(Pname, Lbl.Name & "visible", Lbl.visible)
            Arinini.Write(Pname, Lbl.Name & "space", Lbl.WordSpace)
            Arinini.Write(Pname, Lbl.Name & "fc", Lbl.ForeColor2.ToArgb.ToString())
            '  Arinini.Write(Pname, Lbl.Name & "usepatternh", IIf(Lbl.UseHPattern, "1", "0"))
        Next
        RaiseEvent StatusMessage(">>Save PatternIIH", e_EventMessage.Normal)
        Me.데이터테이블갱신()
    End Sub


    'Public Sub SAVE_PATTERNIII(ByVal flbl As S_FullLable, ByVal Lbla As C_label, Optional ByVal LOGFILENAME As String = "\패턴.TXT")   '패턴을 저장합니다. 패턴역시 위치/크기/wordwidth등이 저장됩니다.
    '    '//이곳은 문자패턴을 저장한다.
    '    Dim Arinini As New ACC.MyINI(ReplaceExt(StyleDir.FullName & "\" & StyleList(SetForm.cmb_style.SelectedIndex).File, flbl.Tag.Substring(0, 1)))
    '    'Dim Arinini As New CommonClassv2.MyINI(StyleDir.FullName & "\" & StyleList(SetForm.cmb_style.SelectedIndex).File)
    '    Dim BUF() As Char = flbl.text.ToCharArray
    '    Dim mb As String = PATTERN_ENC(flbl.text)

    '    Dim Pname As String = flbl.Pattern & "III" & mb.ToString & Lbla.Text & "*" & Lbla.Idx    '//원래 문자패턴뒤에 개별패턴을 붙인다. 즉 이것은 패턴이먼저 검출되고나서 추가검출을 한다.
    '    RaiseEvent StatusMessage(">>Uniq Pattern Save PatternIII=" & Pname & "  Object IDX=" & Lbla.Idx & " object Gidx=" & Lbla.Gidx, e_EventMessage.Normal)
    '    '//이 유니크는 반드시 패턴이 있어야한다.
    '    If flbl.ApplyPattern = E_PatternType.None Then
    '        MsgBox("개별문자패턴은 패턴이 저장된문자만 저장이 가능합니다", MsgBoxStyle.Information, "확인")
    '        Return
    '        'Else
    '        '    MsgBox("이기능은 준비중입니다")
    '        '    Return
    '    End If
    '    If flbl.Fixed Then
    '        MsgBox("고정문자는 스타일저장을 사용하세요", MsgBoxStyle.Information, "패턴저장불가")
    '        Return
    '    End If

    '    ' flbl.SeparatePattern = True    '//이그룹의 개별패턴 여부를  True로 저장한다.
    '    Arinini.Write(flbl.Pattern & "III" & mb.ToString, "SepPattern", flbl.SeparatePattern)   '//개별패턴적용여부

    '    Dim Msga As New System.Text.StringBuilder("현재문자(" & Lbla.Text & ") 의 개별문자패턴을 저장하시겠습니까?")
    '    If MsgBox(Msga.ToString, MsgBoxStyle.Information + MsgBoxStyle.OkCancel, "확인") <> MsgBoxResult.Ok Then Return
    '    Arinini.Write(Pname, Lbla.Name & "pos", Lbla.Left & "," & Lbla.Top & "," & Lbla.Width & "," & Lbla.Height)
    '    Arinini.Write(Pname, Lbla.Name & "font", Lbla.Font.Name & "," & Lbla.Font.Size & "," & Lbla.Font.Underline & "," & Lbla.Font.Bold & "," & Lbla.Font.Italic & "," & Lbla.WordWidth & "," & Lbla.WordHeight)
    '    Arinini.Write(Pname, Lbla.Name & "visible", Lbla.visible)
    '    Arinini.Write(Pname, Lbla.Name & "space", Lbla.WordSpace)
    '    'Arinini.Write(Pname, Lbla.Name & "usepatternh", IIf(Lbla.UseHPattern, "1", "0"))
    '    RaiseEvent StatusMessage(">>Save PatternIII", e_EventMessage.Normal)

    '    Me.데이터테이블갱신()

    '    MsgBox("개별문자 저자완료")
    'End Sub

    ''' <summary>
    ''' 입력된 라벨명에해당하는 풀라벨을 반환합니다.
    ''' </summary>
    ''' <param name="labe"></param>
    ''' <returns></returns>
    ''' <remarks></remarks>
    Public Function lbl(ByVal labe As String) As Short
        For i As Short = 0 To Me.AllFullLabels.GetUpperBound(0)
            If Me.AllFullLabels(i).Desc = labe Then
                Return i
            End If
        Next
        Return Nothing
    End Function

    Private Sub 데이터테이블갱신()
        'Arin.WLog2(Auto_Log, "데이터테이블 갱신()", LogFile)
        RaiseEvent StatusMessage("데이터테이블을 갱신합니다(파일에서모든 스타일정보를 다시 불러옵니다)", e_EventMessage.Normal)
        GetAllsection(StyleList, StyleDir.FullName & "\" & StyleList(SetForm.cmb_style.SelectedIndex).File, SetForm.cmb_style.SelectedIndex, Me.OldType)
    End Sub

    ''' <summary>
    ''' 한줄짜리 레이블을 표시합니다.(컨트롤인덱스,표시문자,표시체크박스,설명)
    ''' 예) Parse_Oneline(1,"062-011-1111",me.chkbox1,"전화번호")
    ''' </summary>
    ''' <param name="lbl"></param>
    ''' <remarks></remarks>
    Public Sub Parse_Line(ByRef lbl As S_FullLable)
        If lbl.text = "" OrElse Not lbl.CheckBox.Checked Then '//없거나 표시불가상태일때는 클리어시키고 빠져나간다.
            RaiseEvent StatusMessage("[" & lbl.Desc & "]          데이터가없거나 체크해제 문자=" & lbl.text, e_EventMessage.Parse)
            Me.CLEAR_ITEM(lbl, False)
            Return
        Else
            RaiseEvent StatusMessage("[" & lbl.Desc & "]    문자=" & lbl.text & vbCrLf & " 체크상태:" & lbl.CheckBox.Checked, e_EventMessage.Parse)
        End If
        Parse_Pattern(lbl)
    End Sub

    Public Sub Parse_LineBatch(ByVal Idx_Array() As Short)
        For Each Idx As Short In Idx_Array
            Me.Parse_Line(Me.AllFullLabels(Idx))
        Next
    End Sub

    ''' <summary>
    ''' 패턴을 확인합니다.
    ''' </summary>
    ''' <param name="lbl"></param>
    ''' <remarks></remarks>
    Public Sub Parse_Pattern(ByRef lbl As S_FullLable)
        Dim Wlen As Short = lbl.text.Length
        Dim SepPos As Short = lbl.text.IndexOf(";")
        Dim SrC() As Char = lbl.text.ToCharArray

        Dim pname, pname2 As String
        Dim Cname, Cname2, Lname As String
        Dim Arinini As New ACC.MyINI(StyleDir.FullName & "\" & StyleList(SetForm.cmb_style.SelectedIndex).File)
        Dim CTLPOS() As String  '//위치정보
        Dim CTLFONT() As String
        Dim CTLVISIBLE As Boolean
        Dim PATTERN As String = PATTERN_ENC(lbl.text)
        Dim PATTERN2 As String = PATTERN_ENC(lbl.text, True)
        Dim TOBJ As CEpole.C_label

        Dim 분리인덱스 As E_LineType = E_LineType.sum
        Dim 번호형식 As String = "20,0,0"
        Dim Dr() As DataRow

        'Dim UniqPattern As String = ""   '//개별문자자체에대한 패턴이 저장되어있는 개체의 번호다
        'Dim UniqHeader As String = ""

        Cname = ""
        Lname = ""

        RaiseEvent StatusMessage("<< 패턴검사를 시작합니다[" & lbl.Desc & "] 문자=" & lbl.text & " 길이=" & Wlen, e_EventMessage.Normal)
        lbl.ApplyPattern = E_PatternType.None

        '//문자를먼저확인한다.
        pname = lbl.Pattern & "II" & PATTERN
        pname2 = lbl.Pattern & "II" & PATTERN2

        Cname = pname
        Cname2 = pname2

        '//패턴(H)코드를 검색
        Dim findPatternH As Boolean = False
        If pname2.IndexOf("Z") <> -1 Then   '//패턴(H)는 기존호환으로인해 실제 저장은 Z로 변경되서 저장됨 140703
            Dr = StyleList(SetForm.cmb_style.SelectedIndex).PATTERNTABLE.Select("설명 = '" & pname2 & "DESC'")
            If Dr.GetUpperBound(0) = 0 Then '//데이터가 존재하므로 모두 적용을 한다.
                findPatternH = True
                RaiseEvent StatusMessage("[" & lbl.Desc & "]              문자패턴(H)확인 문자열=" & lbl.text & " 패턴=" & pname2, e_EventMessage.Normal)
                lbl.ApplyPattern = E_PatternType.Character
                lbl.Moved = True
                '//데이터는 최종적으로 번호형식에서 보낸다.

                '분리인덱스 = Arinini.Read(pname, "nseparate", 0)
                Dr = StyleList(SetForm.cmb_style.SelectedIndex).PATTERNTABLE.Select("설명 = '" & pname2 & "LINETYPE'")
                If Dr.GetUpperBound(0) = 0 Then
                    분리인덱스 = Dr(0)(1)
                Else
                    분리인덱스 = E_LineType.sum
                End If

                Dr = StyleList(SetForm.cmb_style.SelectedIndex).PATTERNTABLE.Select("설명 = '" & pname2 & "NUMTYPE'")
                If Dr.GetUpperBound(0) = 0 Then
                    번호형식 = Dr(0)(1)
                Else
                    번호형식 = "20,20,20"
                End If

                For i As Integer = lbl.Si To lbl.Ei
                    TOBJ = Me.AllLabels(i)
                    Try
                        '//상태를 읽어서 바로 적용한다.
                        Dr = StyleList(SetForm.cmb_style.SelectedIndex).PATTERNTABLE.Select("설명 = '" & pname2 & 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 = StyleList(SetForm.cmb_style.SelectedIndex).PATTERNTABLE.Select("설명 = '" & pname2 & TOBJ.Name & "FONT'")
                        If Dr.GetUpperBound(0) = 0 Then
                            CTLFONT = Dr(0)(1).ToString.Split(",")
                            Dim fStyle As FontStyle = FontStyle.Regular
                            If CTLFONT(2).ToUpper() = "TRUE" Then fStyle = fStyle Or FontStyle.Underline
                            If CTLFONT(3).ToUpper() = "TRUE" Then fStyle = fStyle Or FontStyle.Bold
                            If CTLFONT(4).ToUpper() = "TRUE" Then fStyle = fStyle Or FontStyle.Italic

                            TOBJ.Font = New Font(CTLFONT(0), CTLFONT(1), fStyle, GraphicsUnit.Point)
                            TOBJ.WordWidth = CTLFONT(5)  '//장평
                            TOBJ.WordHeight = CTLFONT(6) '//장높이
                        End If

                        Dr = StyleList(SetForm.cmb_style.SelectedIndex).PATTERNTABLE.Select("설명 = '" & pname2 & TOBJ.Name & "VISIBLE'")
                        If Dr.GetUpperBound(0) = 0 Then
                            CTLVISIBLE = Dr(0)(1).ToString
                            TOBJ.visible = CType(CTLVISIBLE, Boolean)
                        End If

                        Dr = StyleList(SetForm.cmb_style.SelectedIndex).PATTERNTABLE.Select("설명 = '" & pname2 & TOBJ.Name & "SPACE'")
                        If Dr.GetUpperBound(0) = 0 Then
                            TOBJ.WordSpace = Dr(0)(1).ToString
                        End If
                    Catch ex As Exception
                        RaiseEvent StatusMessage("[P] Parse_Pattern : 문자패턴(H)오류 = " & ex.Message.ToString, e_EventMessage.Normal)
                    End Try

                    TOBJ.ForeColor = TOBJ.ForeColor2
                Next
            End If
        End If

        If Not findPatternH Then
            '//기존패턴코드를 찾는다.
            Dr = StyleList(SetForm.cmb_style.SelectedIndex).PATTERNTABLE.Select("설명 = '" & pname & "DESC'")

            If Dr.GetUpperBound(0) = 0 Then '//데이터가 존재하므로 모두 적용을 한다.

                RaiseEvent StatusMessage("[" & lbl.Desc & "]              문자패턴확인 문자열=" & lbl.text & " 패턴=" & pname, e_EventMessage.Normal)
                lbl.ApplyPattern = E_PatternType.Character
                lbl.Moved = True
                '//데이터는 최종적으로 번호형식에서 보낸다.

                '분리인덱스 = Arinini.Read(pname, "nseparate", 0)
                Dr = StyleList(SetForm.cmb_style.SelectedIndex).PATTERNTABLE.Select("설명 = '" & pname & "LINETYPE'")
                If Dr.GetUpperBound(0) = 0 Then
                    분리인덱스 = Dr(0)(1)
                Else
                    분리인덱스 = E_LineType.sum
                End If

                Dr = StyleList(SetForm.cmb_style.SelectedIndex).PATTERNTABLE.Select("설명 = '" & pname & "NUMTYPE'")
                If Dr.GetUpperBound(0) = 0 Then
                    번호형식 = Dr(0)(1)
                Else
                    번호형식 = "20,20,20"
                End If

                'Dr = StyleList(SetForm.cmb_style.SelectedIndex).PATTERNTABLE.Select("설명 = '" & pname & "SEPPATTERN'")  '//분리패턴여부
                'If Dr.GetUpperBound(0) = 0 Then
                '    lbl.SeparatePattern = Dr(0)(1)
                'Else
                '    lbl.SeparatePattern = False
                'End If

                ''//개별문자패턴이있는 정보를 불러온다.  UNIQPATTERN
                'Dr = StyleList(SetForm.cmb_style.SelectedIndex).PATTERNTABLE.Select("설명 = '" & pname & "UNIQPATTERN'")
                'If Dr.GetUpperBound(0) = 0 Then   '//데이터가한개 있다면 해당 꺼를 적용하고 
                '    UniqPattern = Dr(0)(1)
                '    UniqHeader = pname
                'Else   '//그렇지않으면 그냥 초기화로 넘어간다.
                '    UniqPattern = ""
                'End If

                Dim UQPattern As Boolean
                For i As Integer = lbl.Si To lbl.Ei
                    TOBJ = Me.AllLabels(i)
                    UQPattern = False
                    '//유니크패턴가용 그룹이면 유니크를 찾는다.
                    'If lbl.SeparatePattern Then '//개별패턴이 적용되는 그룹이라면 먼저 개별패턴을 찾아본다.
                    '    RaiseEvent StatusMessage("Uniq 패턴 그룹입니다.  Uniq 를 먼저 찾아봅니다.", e_EventMessage.Normal)
                    '    Dim SPname As String = lbl.Pattern & "III" & PATTERN & TOBJ.Text & "*" & TOBJ.Idx
                    '    RaiseEvent StatusMessage("Uniq 패턴 Name = " & SPname, e_EventMessage.Normal)
                    '    Try
                    '        '//상태를 읽어서 바로 적용한다.
                    '        Dr = StyleList(SetForm.cmb_style.SelectedIndex).PATTERNTABLE.Select("설명 = '" & SPname & TOBJ.Name & "POS'")
                    '        If Dr.GetUpperBound(0) = 0 Then
                    '            RaiseEvent StatusMessage("Uniq 패턴 발견 이후 일괄 적용됨", e_EventMessage.Normal)
                    '            UQPattern = True
                    '            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 = StyleList(SetForm.cmb_style.SelectedIndex).PATTERNTABLE.Select("설명 = '" & SPname & TOBJ.Name & "FONT'")
                    '        If Dr.GetUpperBound(0) = 0 Then
                    '            UQPattern = True
                    '            CTLFONT = Dr(0)(1).ToString.Split(",")
                    '            TOBJ.Font = New Font(CTLFONT(0), CTLFONT(1), IIf(CTLFONT(3).ToUpper = "TRUE", FontStyle.Bold, FontStyle.Regular), GraphicsUnit.Point)
                    '            TOBJ.WordWidth = CTLFONT(5)  '//장평
                    '            TOBJ.WordHeight = CTLFONT(6) '//장높이
                    '            'MsgBox(CTLFONT(0))
                    '        End If

                    '        Dr = StyleList(SetForm.cmb_style.SelectedIndex).PATTERNTABLE.Select("설명 = '" & SPname & TOBJ.Name & "VISIBLE'")
                    '        If Dr.GetUpperBound(0) = 0 Then
                    '            UQPattern = True
                    '            CTLVISIBLE = Dr(0)(1).ToString
                    '            TOBJ.visible = CType(CTLVISIBLE, Boolean)
                    '        End If

                    '        Dr = StyleList(SetForm.cmb_style.SelectedIndex).PATTERNTABLE.Select("설명 = '" & SPname & TOBJ.Name & "SPACE'")
                    '        If Dr.GetUpperBound(0) = 0 Then
                    '            UQPattern = True
                    '            TOBJ.WordSpace = Dr(0)(1).ToString
                    '        End If
                    '    Catch ex As Exception
                    '        RaiseEvent StatusMessage("[P] Parse_Pattern : 길이패턴오류 = " & ex.Message.ToString, e_EventMessage.Normal)
                    '    End Try
                    'End If
                    If UQPattern = False Then '//유니크패턴이 있었다면 이부분은 건너뛴다
                        ' RaiseEvent StatusMessage("Uniq 패턴 을 발견못했으므로 문자패턴 계속 검색한다.", e_EventMessage.Normal)
                        Try
                            '//상태를 읽어서 바로 적용한다.
                            Dr = StyleList(SetForm.cmb_style.SelectedIndex).PATTERNTABLE.Select("설명 = '" & pname & TOBJ.Name & "POS'")
                            If Dr.GetUpperBound(0) = 0 Then
                                UQPattern = True
                                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 = StyleList(SetForm.cmb_style.SelectedIndex).PATTERNTABLE.Select("설명 = '" & pname & TOBJ.Name & "FONT'")
                            If Dr.GetUpperBound(0) = 0 Then
                                CTLFONT = Dr(0)(1).ToString.Split(",")
                                Dim fStyle As FontStyle = FontStyle.Regular
                                If CTLFONT(2).ToUpper() = "TRUE" Then fStyle = fStyle Or FontStyle.Underline
                                If CTLFONT(3).ToUpper() = "TRUE" Then fStyle = fStyle Or FontStyle.Bold
                                If CTLFONT(4).ToUpper() = "TRUE" Then fStyle = fStyle Or FontStyle.Italic
                                TOBJ.Font = New Font(CTLFONT(0), CTLFONT(1), fStyle, GraphicsUnit.Point)
                                TOBJ.WordWidth = CTLFONT(5)  '//장평
                                TOBJ.WordHeight = CTLFONT(6) '//장높이
                            End If

                            Dr = StyleList(SetForm.cmb_style.SelectedIndex).PATTERNTABLE.Select("설명 = '" & pname & TOBJ.Name & "VISIBLE'")
                            If Dr.GetUpperBound(0) = 0 Then
                                CTLVISIBLE = Dr(0)(1).ToString
                                TOBJ.visible = CType(CTLVISIBLE, Boolean)
                            End If

                            Dr = StyleList(SetForm.cmb_style.SelectedIndex).PATTERNTABLE.Select("설명 = '" & pname & TOBJ.Name & "SPACE'")
                            If Dr.GetUpperBound(0) = 0 Then
                                TOBJ.WordSpace = Dr(0)(1).ToString
                            End If
                        Catch ex As Exception
                            RaiseEvent StatusMessage("[P] Parse_Pattern : 문자패턴오류 = " & ex.Message.ToString, e_EventMessage.Normal)
                        End Try
                    End If

                    TOBJ.ForeColor = TOBJ.ForeColor2 '//160515
                Next
            Else
                RaiseEvent StatusMessage("[P] Parse_Pattern : 문자패턴을 찾ㅇ르수 없습니다." & pname, e_EventMessage.Normal)
            End If
        Else
            RaiseEvent StatusMessage("[P] Parse_Pattern : 문자패턴(H)로인해 넘어갑니다." & pname, e_EventMessage.Normal)
        End If

        If lbl.ApplyPattern = E_PatternType.None Then   '//문자패턴 실패상태
            '//길이패턴을 확인한다.
            pname = lbl.Pattern & "I" & Wlen
            Lname = pname


            Dr = StyleList(SetForm.cmb_style.SelectedIndex).PATTERNTABLE.Select("설명 = '" & pname & "DESC'")
            If Dr.GetUpperBound(0) >= 0 Then
                RaiseEvent StatusMessage("[" & lbl.Desc & "]          길이패턴존재 문자열=" & lbl.text & " 패턴명:" & pname, e_EventMessage.Normal)
                lbl.ApplyPattern = E_PatternType.Length
                lbl.Moved = True
                '분리인덱스 = Arinini.Read(pname, "nseparate", 0)
                Dr = StyleList(SetForm.cmb_style.SelectedIndex).PATTERNTABLE.Select("설명 = '" & pname & "LINETYPE'")
                If Dr.GetUpperBound(0) = 0 Then
                    분리인덱스 = Dr(0)(1)
                Else
                    분리인덱스 = 0
                End If

                '번호형식 = Arinini.Read(pname, "srccablerow", "9,0,0")
                Dr = StyleList(SetForm.cmb_style.SelectedIndex).PATTERNTABLE.Select("설명 = '" & pname & "NUMTYPE'")
                If Dr.GetUpperBound(0) = 0 Then
                    번호형식 = Dr(0)(1)
                Else
                    번호형식 = "20,20,9" '"20,20,9"
                End If

                ''//개별문자패턴이있는 정보를 불러온다.  UNIQPATTERN
                'Dr = StyleList(SetForm.cmb_style.SelectedIndex).PATTERNTABLE.Select("설명 = '" & pname & "UNIQPATTERN'")
                'If Dr.GetUpperBound(0) = 0 Then   '//데이터가한개 있다면 해당 꺼를 적용하고 
                '    UniqPattern = Dr(0)(1)
                '    UniqHeader = pname
                'Else   '//그렇지않으면 그냥 초기화로 넘어간다.
                '    UniqPattern = ""
                'End If

                For i As Integer = lbl.Si To lbl.Ei
                    TOBJ = Me.AllLabels(i)
                    Try
                        '//상태를 읽어서 바로 적용한다.
                        Dr = StyleList(SetForm.cmb_style.SelectedIndex).PATTERNTABLE.Select("설명 = '" & 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 = StyleList(SetForm.cmb_style.SelectedIndex).PATTERNTABLE.Select("설명 = '" & pname & TOBJ.Name & "FONT'")
                        If Dr.GetUpperBound(0) = 0 Then
                            CTLFONT = Dr(0)(1).ToString.Split(",")
                            Dim fStyle As FontStyle = FontStyle.Regular
                            If CTLFONT(2).ToUpper() = "TRUE" Then fStyle = fStyle Or FontStyle.Underline
                            If CTLFONT(3).ToUpper() = "TRUE" Then fStyle = fStyle Or FontStyle.Bold
                            If CTLFONT(4).ToUpper() = "TRUE" Then fStyle = fStyle Or FontStyle.Italic
                            TOBJ.Font = New Font(CTLFONT(0), CTLFONT(1), fStyle, GraphicsUnit.Point)
                            TOBJ.WordWidth = CTLFONT(5)
                            TOBJ.WordHeight = CTLFONT(6)
                            'MsgBox(CTLFONT(0))
                        End If

                        Dr = StyleList(SetForm.cmb_style.SelectedIndex).PATTERNTABLE.Select("설명 = '" & pname & TOBJ.Name & "VISIBLE'")
                        If Dr.GetUpperBound(0) = 0 Then
                            CTLVISIBLE = Dr(0)(1).ToString
                            TOBJ.visible = CType(CTLVISIBLE, Boolean)
                        End If

                        Dr = StyleList(SetForm.cmb_style.SelectedIndex).PATTERNTABLE.Select("설명 = '" & pname & TOBJ.Name & "SPACE'")
                        If Dr.GetUpperBound(0) = 0 Then
                            TOBJ.WordSpace = Dr(0)(1).ToString
                        End If
                    Catch ex As Exception
                        RaiseEvent StatusMessage("[P] Parse_Pattern : 문자패턴오류 = " & ex.Message.ToString, e_EventMessage.Normal)
                    End Try
                    TOBJ.ForeColor = TOBJ.ForeColor2
                Next
            End If
        End If

        If lbl.ApplyPattern = E_PatternType.None Then
            If lbl.Fixed Then
                RaiseEvent StatusMessage("[" & lbl.Desc & "]  고정문자 :: 기본스타일 사용=" & lbl.text, e_EventMessage.Normal)
            Else
                RaiseEvent StatusMessage("[" & lbl.Desc & "]  문자/길이(" & Cname & "/" & Lname & ") 패턴없음 기본스타일 사용=" & lbl.text, e_EventMessage.Normal)
            End If

            Me.CLEAR_ITEM(lbl, False)
            If lbl.Moved Then
                RaiseEvent StatusMessage("[P] 바로전에 변형이감지되어서 초기화합니다.[ " & lbl.Desc & "] 문자=" & lbl.text, e_EventMessage.Normal)
                Me.LOAD_STYLE(lbl.Tag) '//기본스타일로 복원한다.
                lbl.Moved = False
            End If
            Me.AllLabels(lbl.Si).Text = lbl.text
            Me.AllLabels(lbl.Si).visible = True
        Else
            If lbl.Ei > lbl.Si Then    '//멀티 개체일경우에만
                lbl.LineType = 분리인덱스
                lbl.NumType = 번호형식
                SetForm.cmb_sep.SelectedIndex = 분리인덱스
                분리인덱스별출력(lbl)  '//번호형식을 갱신해준다.
            Else   '//싱글개체이다.. 시작 종료오프셋이 동일한다.
                Me.AllLabels(lbl.Si).Text = lbl.text
                Me.AllLabels(lbl.Si).visible = True
                RaiseEvent StatusMessage("[" & lbl.Desc & "]              싱글패턴개체 분리인덱스 사용안함" & pname, e_EventMessage.Normal)
            End If
        End If

        'Dim U1() As String
        'If UniqPattern <> "" Then '//유니크패턴이 있다면 적용한다.  여러개가 잇을지모른다 예를들어 0,2 0번과 2번이 있다는것이다. 물론 예상은 1개다 
        '    RaiseEvent StatusMessage("[" & lbl.Desc & "]              유니크문자를 확인합니다" & UniqPattern, e_EventMessage.Normal)
        '    U1 = UniqPattern.Split(",")
        '    For Each C As String In U1
        '        TOBJ = Me.AllLabels(Val(C))   '//해당 개체를 가져온다. 현재 지정된 문자와 

        '        '//uniqheader 와 실제들어잇는 문자를 통해서 실제로 패턴이 존재하는지 확인하고 있으면 적용한다.

        '        Dr = StyleList(SetForm.cmb_style.SelectedIndex).PATTERNTABLE.Select("설명 = '" & UniqHeader & TOBJ.Name & TOBJ.Text & "_POS'")
        '        If Dr.GetUpperBound(0) = 0 Then
        '            RaiseEvent StatusMessage("[" & lbl.Desc & "]              유니크문자패턴 발견" & UniqHeader & TOBJ.Name & TOBJ.Text & "_POS'", e_EventMessage.Normal)
        '            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 = StyleList(SetForm.cmb_style.SelectedIndex).PATTERNTABLE.Select("설명 = '" & UniqHeader & TOBJ.Name & TOBJ.Text & "_FONT'")
        '        If Dr.GetUpperBound(0) = 0 Then
        '            CTLFONT = Dr(0)(1).ToString.Split(",")
        '            TOBJ.Font = New Font(CTLFONT(0), CTLFONT(1), IIf(CTLFONT(3).ToUpper = "TRUE", FontStyle.Bold, FontStyle.Regular), GraphicsUnit.Point)
        '            TOBJ.WordWidth = CTLFONT(5)
        '            TOBJ.WordHeight = CTLFONT(6)
        '        End If
        '    Next
        'Else
        '    RaiseEvent StatusMessage("[" & lbl.Desc & "]              유니크문자가 엾습니다" & UniqPattern, e_EventMessage.Normal)
        'End If
    End Sub
    Public Sub AddMessage(ByVal Message As String)
        RaiseEvent StatusMessage(Message, e_EventMessage.Normal)
    End Sub

    ''' <summary>
    ''' 현재지정된 개체의 문자패턴을 저장합니다.
    ''' </summary>
    ''' <remarks></remarks>
    Public Sub QSave_PatternII()
        Dim A As New System.Text.StringBuilder
        A.AppendLine("문자패턴을 저장할 개체를 선택하세요")
        A.AppendLine("마우스왼쪽 클릭시 해당 개체가 선택됩니다")

        If Me.OnlyOne Is Nothing Then Return
        If Me.OnlyOne.Fixed Then
            MsgBox("고정길이는 패턴저장을 할 수 없습니다" & vbCrLf & vbCrLf & "스타일 저장을 하세요", MsgBoxStyle.Critical, "확인")
            Return
        End If
        If SetForm.cmb_controls.SelectedIndex = -1 Then
            MsgBox(A.ToString, MsgBoxStyle.Critical, "확인")
            Return
        End If
        Me.SAVE_PATTERNII(Me.AllFullLabels(Me.AllLabels(SetForm.cmb_controls.SelectedIndex).Gidx))
    End Sub

    Public Sub QSave_PatternIIH()
        Dim A As New System.Text.StringBuilder
        A.AppendLine("문자패턴(H)을 저장할 개체를 선택하세요")
        A.AppendLine("마우스왼쪽 클릭시 해당 개체가 선택됩니다")

        If Me.OnlyOne Is Nothing Then Return
        If Me.OnlyOne.Fixed Then
            MsgBox("고정길이는 패턴저장을 할 수 없습니다" & vbCrLf & vbCrLf & "스타일 저장을 하세요", MsgBoxStyle.Critical, "확인")
            Return
        End If
        If SetForm.cmb_controls.SelectedIndex = -1 Then
            MsgBox(A.ToString, MsgBoxStyle.Critical, "확인")
            Return
        End If
        Me.SAVE_PATTERNIIH(Me.AllFullLabels(Me.AllLabels(SetForm.cmb_controls.SelectedIndex).Gidx))
    End Sub

    ''' <summary>
    ''' 현재지정된 개체의 개별문자패턴을 저장합니다.
    ''' </summary>
    ''' <remarks></remarks>
    Public Sub QSave_PatternIII()
        'Dim A As New System.Text.StringBuilder
        'A.AppendLine("개별문자패턴을 저장할 개체를 선택하세요")
        'A.AppendLine("마우스왼쪽 클릭시 해당 개체가 선택됩니다")

        'If Me.OnlyOne Is Nothing Then Return

        'If Me.OnlyOne.Fixed Then
        '    MsgBox("고정길이는 패턴저장을 할 수 없습니다" & vbCrLf & vbCrLf & "스타일 저장을 하세요", MsgBoxStyle.Critical, "확인")
        '    Return
        'End If
        'If SetForm.cmb_controls.SelectedIndex = -1 Then
        '    MsgBox(A.ToString, MsgBoxStyle.Critical, "확인")
        '    Return
        'End If
        'Me.SAVE_PATTERNIII(Me.AllFullLabels(Me.AllLabels(SetForm.cmb_controls.SelectedIndex).Gidx), Me.OnlyOne)
    End Sub

    Private Sub 분리인덱스별출력(ByRef lbl As S_FullLable)
        Me.CLEAR_ITEM(lbl, False) '//멀티라인은 이곳에서 클리어한다.
        Dim A() As Char = lbl.text.ToCharArray
        Dim P() As Short
        Dim Msg As String = lbl.NumType
        Dim MaxChar As Short = lbl.LineMaxChar

        If Msg.IndexOf(",") >= 0 Then '//콤마구분자일경우에는 콤마별로 각 배열에 집어넣고
            ReDim P(Msg.Split(",").GetUpperBound(0))
            Dim Offset As Short = 0
            For Each C As String In Msg.Split(",")
                P(Offset) = CShort(C)
                Offset += 1
            Next
        Else   '//콤마없을때는 한문자가 줄을 의미하게된다.
            ReDim P(Msg.ToCharArray.GetUpperBound(0))
            Dim Offset As Short = 0
            For Each C As Char In Msg.ToCharArray
                P(Offset) = CShort(C.ToString)
                Offset += 1
            Next
        End If

        '//최종생성된 분리인덱스값을 표시
        For Each sh As Short In P
            RaiseEvent StatusMessage("->분리인덱스:" & sh, e_EventMessage.Normal)
        Next
        '//번호형식이 3,3,3 이라고하고 줄번호타입을 3혼합
        RaiseEvent StatusMessage("->분리인덱스별출력(먼저그룹을 클리어한다.) : " & Msg & "최종문자=" & P(0) & "," & P(1) & "," & P(2), e_EventMessage.Normal)

        '//개별표시값에  문제가 있을경우
        If lbl.LineType < E_LineType.Union OrElse lbl.LineType > E_LineType.sum Then
            lbl.LineType = 0
            RaiseEvent StatusMessage("->분리인덱스오류로인해 0번 혼합으로 변경합니다. : " & Msg, e_EventMessage.Normal)
        End If

        Dim CurPos As Short = 0    '//전체문자중 몇번째까지 했다는표시
        Dim CPos As Short = 0       '//몇번째 컨트롤까지 썻다는 표시
        Dim NextCtl As CEpole.C_label = Me.AllLabels(lbl.Si)   '//첫아이템을 선택

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

        Select Case SetForm.cmb_sep.SelectedIndex
            Case 0  '//혼합
                '//형식수가 4를 넘지않으면 개별 넘을경우 통합출력으로한다.
                '//연습데이터 3442 : 345 R23L1 R932
                'MsgBox("번호형식=" & Msg & "/" & 번호 & "/p0=" & P(0))
                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) <= MaxChar Then    '//개별로넣는다
                        If i + 1 < Limit(OK + 1) Then
                            사용한컨트롤위치 += 1
                            Me.AllLabels(lbl.Si + 사용한컨트롤위치).Text &= IIf(A(i) <> ";", A(i), "")
                        ElseIf i + 1 = Limit(OK + 1) Then
                            OK += 1 : If OK > Limit.GetUpperBound(0) Then Exit For
                            사용한컨트롤위치 += 1
                            Me.AllLabels(lbl.Si + 사용한컨트롤위치).Text &= 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.AllLabels(lbl.Si + 사용한컨트롤위치).Text &= IIf(A(i) <> ";", A(i), "")
                        ElseIf i + 1 = Limit(OK + 1) Then
                            Me.AllLabels(lbl.Si + 사용한컨트롤위치).Text &= IIf(A(i) <> ";", A(i), "")
                            OK += 1 : If OK > Limit.GetUpperBound(0) Then Exit For
                            RES = False
                        End If
                    End If
                Next
            Case 1  '//분리(개별출력이므로 번호형식이 필요없다)
                'Me.v_tb_ntype.Enabled = False
                For i As Int16 = 0 To A.GetUpperBound(0) '//개별 12개의 열에 데이터를 출력한다.
                    Me.AllLabels(lbl.Si + i).Text = IIf(A(i) <> ";", A(i), "")
                Next
            Case 2  '//통합              
                Dim OK As Short = -1  '//완료 번호형식 배열값
                For i As Integer = 0 To A.GetUpperBound(0)
                    If i < Limit(OK + 1) Then
                        Me.AllLabels(lbl.Si + OK + 1).Text &= IIf(A(i) <> ";", A(i), "")
                    ElseIf i = Limit(OK + 1) Then
                        OK += 1 : If OK + 1 > Limit.GetUpperBound(0) Then Exit For
                        Me.AllLabels(lbl.Si + OK + 1).Text &= IIf(A(i) <> ";", A(i), "")
                    End If
                Next
        End Select

        For i As Integer = lbl.Si To lbl.Ei
            Me.AllLabels(i).visible = IIf(Me.AllLabels(i).Text = "", False, True)   '//문자있는것들의 Visible 표시
        Next
    End Sub


    ''' <summary>
    ''' 프린트를 준비합니다. 주로 페이지 범위설정입니다.
    ''' </summary>
    ''' <returns></returns>
    ''' <remarks></remarks>
    Public Function Prepare_Print() As Boolean '//범위내의 페이지번호와 일치하는 번호를 찾아서 배열에 할당한다.
        Me.printindex = 0   '//배열의 첫번으로 출력을 준비한다.
        Me.pDoc.DefaultPageSettings.Margins.Left = 0 'SetForm.tb_marginX.Text  '//좌,우 여백 설정
        Me.pDoc.DefaultPageSettings.Margins.Top = 0 'SetForm.tb_marginY.Text

        Me.pDoc.DefaultPageSettings.Landscape = SetForm.MyProperty_Paper.용지방향 ' SetForm.rad_land.Checked ' IIf(Me.cmb_landscape.SelectedIndex = 0, False, True) '//가로,세로 출력결정
        '//프린터명이 지정되어있다면 해당 프린터로설정,없으면 기본프린터
        If SetForm.cmb_prnlist.Text <> "" Then Me.pDoc.PrinterSettings.PrinterName = SetForm.cmb_prnlist.Text

        Dim Prn_Type As C_Epole.E_PrintRange
        If Me.SetForm.rad_rangeall.Checked Then Prn_Type = C_Epole.E_PrintRange.All
        If Me.SetForm.rad_Rangecurr.Checked Then Prn_Type = C_Epole.E_PrintRange.Current
        If Me.SetForm.rad_rangecustom.Checked Then Prn_Type = C_Epole.E_PrintRange.Custom
        If Me.SetForm.rad_repeat.Checked Then Prn_Type = E_PrintRange.FixedStyle

        Return C_Epole.Set_PrnRange(Me.Dv, BS.Position, Me.PrintArray, Prn_Type, Me.SetForm.tb_printrange.Text.Trim)
    End Function

    ''' <summary>
    ''' 프린트 미리보기(화면)를 띄웁니다.
    ''' </summary>
    ''' <remarks></remarks>
    Public Sub Print_Preview()
        'Arin.WLog2(Auto_Log, "print_preview 미리보기 버튼을 눌렀을때다.()", LogFile)
        If Not Prepare_Print() Then
            MsgBox("인쇄가능한 목록이 없거나 인쇄범위(=페이지수)에 문제가 있습니다", MsgBoxStyle.Critical, "확인")
            Return
        End If
        Dim Preview As New Windows.Forms.PrintPreviewDialog()
        Try
            Preview.Document = pDoc
            Preview.ShowDialog()
        Catch EX As Exception
            MsgBox("Prrint_Preview Error : " & EX.Message)
        End Try
    End Sub

    ''' <summary>
    ''' 프린트를 합니다.
    ''' </summary>
    ''' <remarks></remarks>
    Public Sub Print()
        If MsgBox("인쇄를 하시겠습니까?", MsgBoxStyle.Information + MsgBoxStyle.OkCancel, "확인") = MsgBoxResult.Ok Then
            RaiseEvent StatusMessage("<< [P] Print", e_EventMessage.Normal)
            If Me.Prepare_Print() Then
                ' Try
                pDoc.Print()
                '   Catch ex As Exception
                '      MsgBox("인쇄 실패\n" + ex.Message)
                '  End Try

            Else
                MsgBox("인쇄가능한 목록이 없거나 인쇄범위(=페이지수)에 문제가 있습니다", MsgBoxStyle.Critical, "확인")
            End If
        Else
            MsgBox("인쇄가 취소되었습니다", MsgBoxStyle.Critical, "확인")
        End If
    End Sub

    '   Private Sub Build_PrintPage(ByRef Ga As Graphics, ByVal dummycnt As Short, ByVal Print As Boolean, ByVal CNT As Short, ByVal Row As Short)
    Private Sub Build_PrintPage(ByRef Ga As Graphics, ByVal dummycnt As Short, ByVal Print As Boolean)

        Dim Brush As SolidBrush = Nothing
        Dim obj As CEpole.C_label
        Dim NewX, NewY, NewLeft, NewTop As Integer
        Dim SrcG As Graphics = Me.v_picturebox1.CreateGraphics

        '//dummycnt =  0은 처음출력하는 페이지이다.
        If dummycnt = 0 AndAlso SetForm.cmb_imgtype.SelectedIndex = 5 Then  '//화면지접 출력일때의 배경처리
            '  MsgBox(SetForm.Chk_BgImage.Checked.ToString)
            If SetForm.Chk_BgImage.Checked AndAlso Not SetForm.bakimg.BackgroundImage Is Nothing Then
                If Not Print Then    '//미리보기일때  인쇄마진을 넣지않는다.
                    Ga.DrawImage(SetForm.bakimg.BackgroundImage, CInt(SetForm.tb_bakx.Text), CInt(SetForm.tb_baky.Text), CInt(SetForm.tb_bakw.Text), CInt(SetForm.tb_bakh.Text)) '//배경그림
                ElseIf SetForm.chk_prnimg.Checked Then   '//인쇄시출력시(인쇄마진적용)
                    Ga.DrawImage(SetForm.bakimg.BackgroundImage, CInt(SetForm.tb_bakx.Text) + CInt(SetForm.MyProperty_Paper.출력여백X), CInt(SetForm.tb_baky.Text) + CInt(SetForm.MyProperty_Paper.출력여백Y), CInt(SetForm.tb_bakw.Text), CInt(SetForm.tb_bakh.Text)) '//배경그림
                End If
            End If
        End If

        Dim RowIndex As Short = 0
        Dim RowOffsetX As Short = 0
        Dim RowOffsetY As Short = 0

        If SetForm.MyProperty_Paper.분리갯수 > 0 AndAlso dummycnt > 0 Then '//연속출력일때에는 줄구분 값을 사용한다.
            RowIndex = Math.Floor(dummycnt / SetForm.MyProperty_Paper.분리갯수)
            RowOffsetX = RowIndex * SetForm.MyProperty_Paper.분리여백x
            RowOffsetY = RowIndex * SetForm.MyProperty_Paper.분리여백y
        End If


        For i As Integer = 0 To Me.AllLabels.GetUpperBound(0)   '//모든 개체들에 대해서 인쇄를 설정한다.
            obj = Me.AllLabels(i)

            If obj.visible AndAlso obj.Text <> "" Then   '//화면에 보이는것만 한다.      
                For rcnt As Short = 0 To obj.Repeat '//반복기능추가한다

                    If RowIndex > 0 Then '//연속출력일때에는 줄구분 값을 사용한다.

                        '//줄이바뀌는
                        NewLeft = obj.Left + SetForm.MyProperty_Paper.연속여백x * (dummycnt - RowIndex * SetForm.MyProperty_Paper.분리갯수)
                        NewTop = obj.Top + SetForm.MyProperty_Paper.연속여백y * (dummycnt - RowIndex * SetForm.MyProperty_Paper.분리갯수)

                    Else
                        NewLeft = obj.Left + SetForm.MyProperty_Paper.연속여백x * dummycnt
                        NewTop = obj.Top + SetForm.MyProperty_Paper.연속여백y * dummycnt
                    End If

                    NewLeft += RowOffsetX
                    NewTop += RowOffsetY

                    If Print Then '//실제인쇄라면 인쇄여백을 추가로 설정한다.
                        NewLeft += +SetForm.MyProperty_Paper.출력여백X
                        NewTop += SetForm.MyProperty_Paper.출력여백Y
                        Brush = New SolidBrush(obj.ForeColor2) '//160515
                    Else
                        If Me.DMode Then
                            If Not Brush Is Nothing Then Brush.Dispose()
                            Brush = New SolidBrush(Drawing.Color.Gainsboro) '//전경색으로 브러쉬를 만든다.
                        Else
                            If Not Brush Is Nothing Then Brush.Dispose()
                            Brush = New SolidBrush(obj.ForeColor) '//전경색으로 브러쉬를 만든다.
                        End If
                    End If

                    '//여러줄에걸쳐 출력하는경우라면 170715 그 에 맞게 변경해야한다.

                    'If dummy Then  '//2장출력일 때이다.
                    '    If Print Then
                    '        NewLeft = obj.Left + SetForm.MyProperty_Paper.여백x + SetForm.MyProperty_Paper.출력여백X
                    '        NewTop = obj.Top + SetForm.MyProperty_Paper.여백y + SetForm.MyProperty_Paper.출력여백Y
                    '        Brush = New SolidBrush(Color.Black) '//전경색으로 브러쉬를 만든다.
                    '    Else
                    '        NewLeft = obj.Left + SetForm.MyProperty_Paper.여백x
                    '        NewTop = obj.Top + SetForm.MyProperty_Paper.여백y
                    '        If Me.DMode Then
                    '            Brush = New SolidBrush(Color.Gainsboro) '//전경색으로 브러쉬를 만든다.
                    '        Else
                    '            Brush = New SolidBrush(Color.Black) '//전경색으로 브러쉬를 만든다.
                    '        End If
                    '    End If
                    'Else
                    '    If Print Then
                    '        NewLeft = obj.Left + SetForm.MyProperty_Paper.출력여백X
                    '        NewTop = obj.Top + SetForm.MyProperty_Paper.출력여백Y
                    '        Brush = New SolidBrush(Color.Black) '//전경색으로 브러쉬를 만든다.
                    '    Else
                    '        NewLeft = obj.Left
                    '        NewTop = obj.Top
                    '        If Me.DMode Then
                    '            Brush = New SolidBrush(Color.Gainsboro) '//전경색으로 브러쉬를 만든다.
                    '        Else
                    '            Brush = New SolidBrush(obj.ForeColor) '//전경색으로 브러쉬를 만든다.
                    '        End If
                    '    End If
                    'End If

                    If rcnt > 0 Then '//반복횟수가 1이상일때는 offset을 더해준다.
                        NewLeft = NewLeft + rcnt * obj.RepeatX
                        NewTop = NewTop + rcnt * obj.RepeatY
                        If Me.DMode Then
                            If Not Brush Is Nothing Then Brush.Dispose()
                            Brush = New SolidBrush(obj.ForeColor) '//전경색으로 브러쉬를 만든다.
                        Else
                            If Not Brush Is Nothing Then Brush.Dispose()
                            Brush = New SolidBrush(Drawing.Color.LightGreen) '//전경색으로 브러쉬를 만든다.
                        End If
                        If Print Then
                            If Not Brush Is Nothing Then Brush.Dispose()
                            Brush = New SolidBrush(obj.ForeColor)
                        End If

                    End If

                    If obj.WordWidth = 100 AndAlso obj.WordHeight = 100 Then '//이미지확대축소 디지않았을경우
                        Ga.DrawString(obj.text2, obj.Font, Brush, NewLeft, NewTop)
                    Else    '//이미지확대축소 됬을경우     

                        'Dim aNewX = obj.GetSize().Width * (obj.WordWidth / 100.0) '* (Ga.DpiX / SrcG.DpiX)
                        'Dim aNewY = obj.GetSize().Height * (obj.WordHeight / 100.0) ' * (Ga.DpiY / SrcG.DpiY)


                        If Not Print Then
                            NewX = obj.GetSize(Ga).Width * (obj.WordWidth / 100.0) '* (Ga.DpiX / SrcG.DpiX)
                            NewY = obj.GetSize(Ga).Height * (obj.WordHeight / 100.0) ' * (Ga.DpiY / SrcG.DpiY)
                        Else
                            NewX = obj.GetSize(Ga).Width * (obj.WordWidth / 100.0) * (Ga.DpiX / SrcG.DpiX)
                            NewY = obj.GetSize(Ga).Height * (obj.WordHeight / 100.0) * (Ga.DpiY / SrcG.DpiY)
                        End If

                        'If Not Print Then
                        '    NewX = obj.GetSize().Width * (obj.WordWidth / 100.0) '* (Ga.DpiX / SrcG.DpiX)
                        '    NewY = obj.GetSize().Height * (obj.WordHeight / 100.0) ' * (Ga.DpiY / SrcG.DpiY)
                        'Else
                        '    NewX = obj.GetSize().Width * (obj.WordWidth / 100.0) * (Ga.DpiX / SrcG.DpiX)
                        '    NewY = obj.GetSize().Height * (obj.WordHeight / 100.0) * (Ga.DpiY / SrcG.DpiY)
                        'End If

                        Using BMP As New Bitmap(NewX, NewY, Ga)
                            Using G As Graphics = Graphics.FromImage(BMP)
                                G.ScaleTransform((obj.WordWidth / 100.0), (obj.WordHeight / 100.0))
                                Using sf As New StringFormat()
                                    G.DrawString(obj.text2, obj.Font, Brush, 0.0F, 0.0F)
                                End Using
                            End Using
                            Try
                                Ga.DrawImage(BMP, NewLeft, NewTop) ', CInt(GetSize.Width * (vwordwidth / 100)), GetSize.Height)
                            Catch ex As Exception
                                '  MsgBox("Graphic DrawError", MsgBoxStyle.Information, obj.Desc)
                            End Try
                        End Using

                    End If
                Next
            End If
        Next

        '//마지막에 테두리를 그린다.(연속출력시에는 넣지않는다)
        If SetForm.chk_usedraw.Checked AndAlso (SetForm.MyProperty_Paper.그리기개체반복 OrElse dummycnt = 0) Then  '//쉐이프개체를 사용할지 확인여부
            '//라인을 그린다.
            Dim I As Short = 0
            Try
                If Not Me.Draw_Line Is Nothing AndAlso Not Draw_Line.Items Is Nothing Then
                    For Each Rect As S_Line In Me.Draw_Line.Items
                        Dim Pen As New Drawing.Pen(Rect.PenColor, Rect.PenWidth)

                        Dim NewSX As Single = Rect.X
                        Dim NewSY As Single = Rect.Y
                        Dim NewSX2 As Single = Rect.X2
                        Dim NewSY2 As Single = Rect.Y2

                        If RowIndex > 0 Then '//연속출력일때에는 줄구분 값을 사용한다.
                            NewSX += SetForm.MyProperty_Paper.연속여백x * (dummycnt - RowIndex * SetForm.MyProperty_Paper.분리갯수)
                            NewSY += SetForm.MyProperty_Paper.연속여백y * (dummycnt - RowIndex * SetForm.MyProperty_Paper.분리갯수)
                            NewSX2 += SetForm.MyProperty_Paper.연속여백x * (dummycnt - RowIndex * SetForm.MyProperty_Paper.분리갯수)
                            NewSY2 += SetForm.MyProperty_Paper.연속여백y * (dummycnt - RowIndex * SetForm.MyProperty_Paper.분리갯수)
                        Else
                            NewSX += SetForm.MyProperty_Paper.연속여백x * dummycnt
                            NewSY += SetForm.MyProperty_Paper.연속여백y * dummycnt
                            NewSX2 += SetForm.MyProperty_Paper.연속여백x * dummycnt
                            NewSY2 += SetForm.MyProperty_Paper.연속여백y * dummycnt
                        End If

                        NewSX += RowOffsetX
                        NewSY += RowOffsetY

                        NewSX2 += RowOffsetX
                        NewSY2 += RowOffsetY

                        If Print Then
                            NewSX += SetForm.MyProperty_Paper.출력여백X
                            NewSY += SetForm.MyProperty_Paper.출력여백Y

                            NewSX2 += SetForm.MyProperty_Paper.출력여백X
                            NewSY2 += SetForm.MyProperty_Paper.출력여백Y
                        End If

                        Ga.DrawLine(Pen, NewSX, NewSY, NewSX2, NewSY2)

                    Next
                End If

            Catch ex As Exception

            End Try
            '//박스를 그린다.
            I = 0
            Try
                If Not Me.Draw_Box Is Nothing AndAlso Not Me.Draw_Box.Items Is Nothing Then
                    For Each Rect As S_Box In Me.Draw_Box.Items
                        Using Pen As New Drawing.Pen(Rect.PenColor, Rect.PenWidth)

                            Dim NewSX As Single = Rect.X
                            Dim NewSY As Single = Rect.Y

                            If RowIndex > 0 Then '//연속출력일때에는 줄구분 값을 사용한다.
                                NewSX += SetForm.MyProperty_Paper.연속여백x * (dummycnt - RowIndex * SetForm.MyProperty_Paper.분리갯수)
                                NewSY += SetForm.MyProperty_Paper.연속여백y * (dummycnt - RowIndex * SetForm.MyProperty_Paper.분리갯수)
                            Else
                                NewSX += SetForm.MyProperty_Paper.연속여백x * dummycnt
                                NewSY += SetForm.MyProperty_Paper.연속여백y * dummycnt
                            End If

                            NewSX += RowOffsetX
                            NewSY += RowOffsetY

                            If Print Then
                                NewSX += +SetForm.MyProperty_Paper.출력여백X
                                NewSY += +SetForm.MyProperty_Paper.출력여백Y
                            End If

                            If Rect.Radius = 0 Then
                                Ga.DrawRectangle(Pen, NewSX, NewSY, Rect.Width, Rect.Height)
                            Else
                                Dim rRect As Rectangle = New Rectangle(NewSX, NewSY, Rect.Width, Rect.Height)
                                Using rpath As System.Drawing.Drawing2D.GraphicsPath = ACC.MYGDI.GetRoundedRectPath(rRect, Rect.Radius)
                                    Ga.DrawPath(Pen, rpath)
                                End Using
                            End If
                        End Using

                    Next
                End If

            Catch ex As Exception

            End Try
            '//원 그린다.
            I = 0
            Try
                If Not Draw_Circle Is Nothing AndAlso Not Me.Draw_Circle.Items Is Nothing Then
                    For Each Rect As S_Circle In Me.Draw_Circle.Items
                        Using Pen As New Drawing.Pen(Rect.PenColor, Rect.PenWidth)

                            Dim NewSX As Single = Rect.X
                            Dim NewSY As Single = Rect.Y

                            If RowIndex > 0 Then '//연속출력일때에는 줄구분 값을 사용한다.
                                NewSX += SetForm.MyProperty_Paper.연속여백x * (dummycnt - RowIndex * SetForm.MyProperty_Paper.분리갯수)
                                NewSY += SetForm.MyProperty_Paper.연속여백y * (dummycnt - RowIndex * SetForm.MyProperty_Paper.분리갯수)
                            Else
                                NewSX += SetForm.MyProperty_Paper.연속여백x * dummycnt
                                NewSY += SetForm.MyProperty_Paper.연속여백y * dummycnt
                            End If

                            NewSX += RowOffsetX
                            NewSY += RowOffsetY

                            If Print Then
                                NewSX += +SetForm.MyProperty_Paper.출력여백X
                                NewSY += +SetForm.MyProperty_Paper.출력여백Y
                            End If


                            Ga.DrawEllipse(Pen, NewSX, NewSY, Rect.Width, Rect.Height)
                        End Using
                    Next
                End If

            Catch ex As Exception

            End Try
            '//이미지개체를 그린다.
            I = 0
            Try
                If Not Draw_Image Is Nothing AndAlso Not Me.Draw_Image.Items Is Nothing Then
                    For Each Rect As S_Image In Me.Draw_Image.Items
                        Dim F As String = Rect.FileName
                        If F.Trim <> "" Then
                            F = F.Replace(".\", My.Application.Info.DirectoryPath & "\")
                            ' MsgBox(F)

                            If System.IO.File.Exists(F) Then
                                Using Image As Image = Image.FromFile(F)  '//파일로부터 이미지를 가져옴

                                    Dim NewSX As Single = Rect.X
                                    Dim NewSY As Single = Rect.Y

                                    If RowIndex > 0 Then '//연속출력일때에는 줄구분 값을 사용한다.
                                        NewSX += SetForm.MyProperty_Paper.연속여백x * (dummycnt - RowIndex * SetForm.MyProperty_Paper.분리갯수)
                                        NewSY += SetForm.MyProperty_Paper.연속여백y * (dummycnt - RowIndex * SetForm.MyProperty_Paper.분리갯수)
                                    Else
                                        NewSX += SetForm.MyProperty_Paper.연속여백x * dummycnt
                                        NewSY += SetForm.MyProperty_Paper.연속여백y * dummycnt
                                    End If

                                    NewSX += RowOffsetX
                                    NewSY += RowOffsetY

                                    If Print Then
                                        NewSX += +SetForm.MyProperty_Paper.출력여백X
                                        NewSY += +SetForm.MyProperty_Paper.출력여백Y
                                    End If

                                    If Rect.Width = 0 OrElse Rect.Height = 0 Then
                                        Ga.DrawImage(Image, NewSX, NewSY)
                                    Else
                                        Ga.DrawImage(Image, NewSX, NewSY, Rect.Width, Rect.Height)
                                    End If
                                End Using

                            End If
                        End If
                    Next
                End If

            Catch ex As Exception

            End Try
            I = 0
            '//QR코드를 그린다.
            Try
                '//QR코드를 그린다.
                If Not Draw_QRcode Is Nothing AndAlso Not Me.Draw_QRcode.Items Is Nothing Then
                    For Each Rect As S_QRCode In Me.Draw_QRcode.Items
                        'Dim scale As Int16
                        ' Dim version As Int16
                        Dim image As Image = Nothing
                        Dim data As String = ""
                        ' Dim errorCorrect As String
                        Dim qrCodeEncoder1 As New ThoughtWorks.QRCode.Codec.QRCodeEncoder()
                        ' Dim encoding As String


                        qrCodeEncoder1.QRCodeEncodeMode = CInt(Rect.Encoding)
                        qrCodeEncoder1.QRCodeErrorCorrect = CInt(Rect.CLeve)
                        qrCodeEncoder1.QRCodeVersion = Rect.Version
                        qrCodeEncoder1.QRCodeScale = Rect.Size

                        'encoding = "3"
                        '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
                        '        version = Convert.ToInt16("1")
                        '        qrCodeEncoder.QRCodeVersion = version
                        '    Catch ex As Exception

                        '    End Try
                        'End If
                        'errorCorrect = "1"
                        '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

                        If Rect.Format = "" Then Rect.Format = "{DATA}"
                        Rect.Format = Rect.Format.Replace("{DATA}", "{QR1}")
                        Rect.Format = Rect.Format.Replace("{QR}", "{QR1}") '//151029



                        '//151029 qr코드버그처리
                        Dim PrintQRCODE As String = Rect.Format.Replace("{QR1}", QRCODE1)
                        PrintQRCODE = PrintQRCODE.Replace("{QR2}", QRCODE2)
                        PrintQRCODE = PrintQRCODE.Replace("{QR3}", QRCODE3)
                        PrintQRCODE = PrintQRCODE.Replace("{QR4}", QRCODE4)
                        PrintQRCODE = PrintQRCODE.Replace("{번호}", 일련번호)
                        If PrintQRCODE <> "" Then    '//사용자가 입력한 데이터가 있다.

                            'Ga.DrawString(QRCODE, New Font("arial", 30), Brushes.Black, 100, 100)

                            qrCodeEncoder1.QRCodeBackgroundColor = Rect.bColor
                            qrCodeEncoder1.QRCodeForegroundColor = Rect.fColor
                            image = qrCodeEncoder1.Encode(PrintQRCODE, Ga.DpiX, Ga.DpiY)


                            Dim NewSX As Single = Rect.X
                            Dim NewSY As Single = Rect.Y

                            If RowIndex > 0 Then '//연속출력일때에는 줄구분 값을 사용한다.
                                NewSX += SetForm.MyProperty_Paper.연속여백x * (dummycnt - RowIndex * SetForm.MyProperty_Paper.분리갯수)
                                NewSY += SetForm.MyProperty_Paper.연속여백y * (dummycnt - RowIndex * SetForm.MyProperty_Paper.분리갯수)
                            Else
                                NewSX += SetForm.MyProperty_Paper.연속여백x * dummycnt
                                NewSY += SetForm.MyProperty_Paper.연속여백y * dummycnt
                            End If

                            NewSX += RowOffsetX
                            NewSY += RowOffsetY

                            If Print Then
                                NewSX += +SetForm.MyProperty_Paper.출력여백X
                                NewSY += +SetForm.MyProperty_Paper.출력여백Y
                            End If

                            If Rect.Width = 0 OrElse Rect.Height = 0 Then
                                Ga.DrawImage(image, NewSX, NewSY)
                            Else
                                Ga.DrawImage(image, NewSX, NewSY, Rect.Width, Rect.Height)
                            End If

                        End If
                        If Not image Is Nothing Then image.Dispose()
                    Next
                End If

            Catch ex As Exception

            End Try
        End If

    End Sub

    ''' <summary>
    ''' 프린트할 페이지를 작성합니다.
    ''' </summary>
    ''' <param name="sender"></param>
    ''' <param name="e"></param>
    ''' <remarks></remarks>
    Private Sub pDoc_PrintPage(ByVal sender As Object, ByVal e As System.Drawing.Printing.PrintPageEventArgs) Handles pDoc.PrintPage
        RaiseEvent StatusMessage("<< [P] pDoc_PrintPage : Build Print Pages", e_EventMessage.Normal)

        'Dim fmt As New StringFormat(StringFormatFlags.LineLimit)
        'Dim NewFontSize As Int16 = 10
        'Dim dummy As Boolean = False    '//이값이 true 이면 출력시 변위를 지정해서 출력한다.

        If Me.printindex <> -1 And SetForm.rad_repeat.Checked = False Then Me.GeTviewData(Me.PrintArray(Me.printindex), False) '//페이지를 갱신하고 출력을 시작한다.
        e.Graphics.ScaleTransform(SetForm.MyProperty_Paper.가로확대비율, SetForm.MyProperty_Paper.세로확대비율) '//확대,축소비율적용

        If SetForm.MyProperty_Paper.출력장수 < 1 Then SetForm.MyProperty_Paper.출력장수 = 1 '//출력장수 오류보정
        If SetForm.MyProperty_Paper.출력장수 < 2 Then SetForm.MyProperty_Paper.분리갯수 = 0 '//분리갯수 오류보정

        '//190209 water mark
        Dim PrinterName As String = SetForm.cmb_prnlist.Text.ToLower.Trim()
        Dim WaterMark As Boolean = False
        If DisableWaterMark = False AndAlso (PrinterName.IndexOf("xps") <> -1 OrElse PrinterName.IndexOf("pdf") <> -1 OrElse PrinterName.IndexOf("jpg") <> -1 OrElse PrinterName.IndexOf("file") <> -1) Then
            WaterMark = True
        End If

        Dim IncNum As Boolean = False
        For pi As Short = 0 To SetForm.MyProperty_Paper.출력장수 - 1  '//페이지당 연속출력할 횟수
            'Dummyflag:  '//--2장출력일경우 이부분에서 다시 시작한다.
            ' Me.Build_PrintPage(e.Graphics, pi, True, SetForm.cmb_style.SelectedIndex, Me.PrintArray(Me.printindex)) '//여기서연속으로 출력을 하기는하는데

            Me.Build_PrintPage(e.Graphics, pi, True)
            If (WaterMark) Then '//190209
                Using sb As New SolidBrush(System.Drawing.Color.FromArgb(50, Drawing.Color.Black))
                    Using fnt As New Font("Cambria", 40, FontStyle.Bold Or FontStyle.Italic)
                        Dim fs As SizeF = e.Graphics.MeasureString("HAEGWANG.CO.KR", fnt)
                        For i As Integer = 50 To 800 Step 150
                            e.Graphics.DrawString("HAEGWANG.CO.KR", fnt, sb, 50, i)
                        Next
                    End Using
                End Using
            End If
            IncNum = False

            '//한데이터출력하고나서 반복페에지횟수가 있는지확인한다.
            If SetForm.MyProperty_Paper.출력장수 > 1 Then
                ' If Me.cmb_dummy.SelectedIndex <> 0 Then '//다음데이터의 출력이면 여기서 데이터를 갱신해준다.
                If SetForm.MyProperty_Paper.출력방법 <> E_Dummytype.현재복사 Then   '//다음장이있다.
                    If Me.printindex >= 0 AndAlso Me.printindex < Me.PrintArray.GetUpperBound(0) Then
                        Me.printindex += 1  '/1장넘기고 
                        If SetForm.MyProperty_Paper.출력방법 <> E_Dummytype.현재복사 AndAlso SetForm.rad_repeat.Checked = False Then Me.GeTviewData(Me.PrintArray(Me.printindex), False) '//데이터 바꾸는데..화면은 갱신하지 않는다.
                        IncNum = True
                    Else   '//다음장의 출력인데 데이터가없다면 루프를 더이상 돌면안된다.
                        Exit For
                    End If
                End If
            End If


            ''//페이지가 있던없던 2장복사를 먼저 확인한다.
            ''//다음페이지가 잇으면 다음기능을 확인하고 그렇지 않을경우에는 한장복사만 확인한다.
            'If dummy = False AndAlso SetForm.MyProperty_Paper.사용여부 Then   '//2장복사일경우에는  현재복사인지 다음복사인지 체크
            '    dummy = True
            '    If SetForm.MyProperty_Paper.출력방법 = E_Dummytype.현재복사 Then  '//현재복사는 궂이 다음장없어도 가능하다.      
            '        GoTo Dummyflag
            '    Else    '//다음복사이므로 다음장이잇는지 확인하고해야한다.
            '        If Me.printindex >= 0 AndAlso Me.printindex < Me.PrintArray.GetUpperBound(0) Then   '//다음장이있다.
            '            Me.printindex += 1  '/1장넘기고 

            '            '//데이터를 새로 갱신하는데 고정문자는 어차피 같은데이터이므로 갱신을 하지않는다.
            '            If SetForm.rad_repeat.Checked = False Then Me.GeTviewData(Me.PrintArray(Me.printindex), False)

            '            GoTo Dummyflag  '//바로 출력다시한다.
            '        End If
            '        e.HasMorePages = False       '다음장이없으므로 그냥 넘어간다.
            '    End If
            'Else    '//다음장으로넘깁니다.
            '    If Me.printindex >= 0 AndAlso Me.printindex < Me.PrintArray.GetUpperBound(0) Then   '//다음장이있다.
            '        dummy = False   '//장수를 넘어가면 더미를 해제한다.
            '        Me.printindex += 1
            '        e.HasMorePages = True
            '    Else
            '        e.HasMorePages = False
            '    End If
            'End If
        Next

        If Me.printindex >= 0 AndAlso Me.printindex < Me.PrintArray.GetUpperBound(0) Then   '//다음장이있다.
            If Not IncNum Then Me.printindex += 1 '//페이지번호를 증가
            e.HasMorePages = True
        Else
            e.HasMorePages = False
        End If


        e.Graphics.Dispose()
    End Sub

#Region "설정폼에대한 명령어"

    ''' <summary>
    ''' 설정폼 : 개체목록 콤보박스에 목록추가
    ''' </summary>
    ''' <param name="설명"></param>
    ''' <remarks></remarks>
    Public Sub Add_ControlsList(ByVal 설명 As String)
        Me.SetForm.cmb_controls.Items.Add(설명)
    End Sub

    ''' <summary>
    ''' 개체목록 콤보박스 목록을 초기화합니다.
    ''' </summary>
    ''' <remarks></remarks>
    Public Sub Clear_Contollist()
        Me.SetForm.cmb_controls.Items.Clear()
    End Sub

    ''' <summary>
    ''' 설정폼을 화면에 표시/감추기  합니다.
    ''' </summary>
    ''' <value></value>
    ''' <remarks></remarks>
    Public WriteOnly Property SetFormShow() As Boolean
        Set(ByVal value As Boolean)
            If value Then
                Me.SetForm.Show()
            Else
                Me.SetForm.Hide()
            End If
        End Set
    End Property
#End Region

#Region "자주사용하지 않는 함수 (Form함수포함)"

    Public Overridable Sub AdminSetting()
        MsgBox("관리자용 셋팅이 오버라이드되지 않았습니다")
    End Sub

    Public Sub Change_All_FontData(ByVal v_font As Font)
        '//패턴을 포함한 모든데이터의 폰트를 일괄변경합니다.
        '//해당파일전체를 찾아서 루프로 ??font라는 글자를 찾아서 변경

        Dim Usesize As Boolean = False
        If MsgBox("글꼴의 크기및 속성을 적용하시겠습니까?" & vbCrLf & "글꼴만 변경하려면 아니오를 누르세요", MsgBoxStyle.Information Or MsgBoxStyle.OkCancel, "확인") = MsgBoxResult.Ok Then
            Usesize = True
        End If

        Dim styleFile As String = StyleList(SetForm.cmb_style.SelectedIndex).File
        Dim Pattern As String = styleFile.Substring(0, styleFile.LastIndexOf("."))
        Dim FileCnt As Integer = 0
        For Each File As System.IO.FileInfo In StyleDir.GetFiles(Pattern & ".*")
            FileCnt += 1

            Dim Bufa As String = ""
            '//MsgBox(File.FullName & "선택파일")
            '//파일을 읽어서 font= 부분을찾은다음에 해당 라인을 바꿔준다.
            Dim buf As String = My.Computer.FileSystem.ReadAllText(File.FullName, System.Text.Encoding.Default)
            'buf = buf.Replace(vbLf, vbCrLf).Replace(vbCr, vbCrLf)
            'Dim Newbuf As New System.Text.StringBuilder("")
            buf = buf.Trim(vbCr).Trim(vbLf)
            For Each Str As String In buf.Split(vbCrLf) '//줄바꿈으로
                'If MsgBox(Str, MsgBoxStyle.OkCancel) = MsgBoxResult.Ok Then
                '    Exit For
                'End If
                ' If Str.Trim <> "" Then Bufa &= vbCrLf & Str
                ' Str = Str.Replace(vbCr, "").Replace(vbCrLf, "").Replace(vbLf, "")
                Str = Str.Trim.Trim(vbCrLf).Trim(vbCr).Trim(vbLf)
                If Str.Trim <> "" Then
                    If Str.Trim.ToLower.IndexOf("font=") <> -1 Then  '//폰트가잇는 줄을 찾는다.
                        Dim Head As String = Str.Substring(0, Str.IndexOf("="))  '//머리부분
                        Dim Tail As String = Str.Substring(Str.IndexOf("=") + 1)

                        Dim T() As String = Tail.Split(",")
                        T(0) = v_font.Name
                        If Usesize Then
                            T(1) = v_font.Size
                            T(2) = v_font.Underline
                            T(3) = v_font.Bold
                            T(4) = v_font.Italic
                        End If

                        Bufa &= vbCrLf & Head & "=" & T(0) & "," & T(1) & "," & T(2) & "," & T(3) & "," & T(4)
                        For i As Integer = 5 To T.GetUpperBound(0)
                            Bufa = Bufa & "," & T(i)
                        Next
                    Else
                        Bufa &= vbCrLf & Str
                    End If
                End If
            Next
            'Dim LastBuf As New System.Text.StringBuilder
            'For Each S As String In Newbuf.ToString.Split(vbCrLf)
            '    If S.Trim <> "" Then LastBuf.AppendLine(S.Trim(vbCr).Trim(vbLf))
            'Next
            My.Computer.FileSystem.WriteAllText(File.FullName, Bufa, False, System.Text.Encoding.Default)

            'My.Computer.FileSystem.WriteAllText("c:\log.txt", Bufa, False, System.Text.Encoding.Default)
            'Shell("notepad c:\log.txt", AppWinStyle.NormalFocus)
        Next
        Me.데이터테이블갱신()
        Me.preview_window()

        MsgBox("변경완료(" & FileCnt & ")" & vbCrLf & "출력창을 닫은후 다시 여세요", MsgBoxStyle.Information, "확인")

        'For i As Integer = 0 To Me.AllLabels.GetUpperBound(0)
        '    Tobj = Me.AllLabels(i)
        '    '  If Not Tobj.HasPattern Then    '//패턴이 없는 것일경우 패턴잇는것은 따로 저장되잇으므로 저장할 필요없다
        '    '################################ 스타일개별 저장부분추가됨
        '    TagINI = New ACC.MyINI(ReplaceExt(StyleDir.FullName & "\" & StyleList(SetForm.cmb_style.SelectedIndex).File, Tobj.Tag.ToString))
        '    'TagINI = New CommonClassv2.MyINI(CStr(StyleDir.FullName & "\" & StyleList(SetForm.cmb_style.SelectedIndex).File).ToLower.Replace("ini", Tobj.Name.Substring(0, 1)))
        '    If TagINI.Exist = False Then TagINI.Create()
        '    TagINI.Write("STYLE", Tobj.Name & "pos", Tobj.Left & "," & Tobj.Top & "," & Tobj.Width & "," & Tobj.Height)
        '    TagINI.Write("STYLE", Tobj.Name & "font", Tobj.Font.Name & "," & Tobj.Font.Size & "," & Tobj.Font.Underline & "," & Tobj.Font.Bold & "," & Tobj.Font.Italic & "," & Tobj.WordWidth & "," & Tobj.WordHeight)
        '    TagINI.Write("STYLE", Tobj.Name & "visible", "true") '기본값으로 표시로 정해놓고 체크박스 체크한다.
        '    TagINI.Write("STYLE", Tobj.Name & "space", Tobj.WordSpace)
        '    TagINI.Write("STYLE", Tobj.Name & "repeat", Tobj.Repeat & "," & Tobj.RepeatX & "," & Tobj.RepeatY)  '//반복출력정보저장
        '    If Tobj.Fixed Then TagINI.Write("STYLE", Tobj.Name & "mytext", Tobj.Text)
        '    '################################ 스타일개별 저장부분추가됨
        '    '  End If
        'Next

    End Sub


    Public Sub SAVE_STYLE_NEW()
        '//이건 각개별스타일이 개별파일로 들어가도록 변형환 파일입니다
        '//3월20일버젼부터 적용됩니다.
        RaiseEvent StatusMessage("[P] Save_Style : Save Sytle to SeparateFile Default=" & StyleDir.FullName & "\" & StyleList(SetForm.cmb_style.SelectedIndex).File, e_EventMessage.Normal)
        If SetForm.cmb_style.SelectedIndex < 0 Then
            MsgBox("저장할 스타일이 선택되어 있지않습니다", MsgBoxStyle.Critical, "확인")
            Return
        End If


        Dim TagINI As ACC.MyINI
        Dim Tobj As CEpole.C_label

        '//현재 선택된 스타일을 저장합니다.
        For i As Integer = 0 To Me.AllLabels.GetUpperBound(0)
            Tobj = Me.AllLabels(i)
            '  If Not Tobj.HasPattern Then    '//패턴이 없는 것일경우 패턴잇는것은 따로 저장되잇으므로 저장할 필요없다
            '################################ 스타일개별 저장부분추가됨
            TagINI = New ACC.MyINI(ReplaceExt(StyleDir.FullName & "\" & StyleList(SetForm.cmb_style.SelectedIndex).File, Tobj.Tag.ToString))
            'TagINI = New CommonClassv2.MyINI(CStr(StyleDir.FullName & "\" & StyleList(SetForm.cmb_style.SelectedIndex).File).ToLower.Replace("ini", Tobj.Name.Substring(0, 1)))
            If TagINI.Exist = False Then TagINI.Create()
            TagINI.Write("STYLE", Tobj.Name & "pos", Tobj.Left & "," & Tobj.Top & "," & Tobj.Width & "," & Tobj.Height)
            TagINI.Write("STYLE", Tobj.Name & "font", Tobj.Font.Name & "," & Tobj.Font.Size & "," & Tobj.Font.Underline & "," & Tobj.Font.Bold & "," & Tobj.Font.Italic & "," & Tobj.WordWidth & "," & Tobj.WordHeight)
            TagINI.Write("STYLE", Tobj.Name & "visible", "true") '기본값으로 표시로 정해놓고 체크박스 체크한다.
            TagINI.Write("STYLE", Tobj.Name & "space", Tobj.WordSpace)
            TagINI.Write("STYLE", Tobj.Name & "repeat", Tobj.Repeat & "," & Tobj.RepeatX & "," & Tobj.RepeatY)  '//반복출력정보저장
            TagINI.Write("STYLE", Tobj.Name & "fc", Tobj.ForeColor2.ToArgb.ToString())
            If Tobj.Fixed Then TagINI.Write("STYLE", Tobj.Name & "mytext", Tobj.Text)
            '################################ 스타일개별 저장부분추가됨
            '  End If
        Next

        '//데이터표시 체크박스 상태를 저장한다.
        TagINI = New ACC.MyINI(ReplaceExt(StyleDir.FullName & "\" & StyleList(SetForm.cmb_style.SelectedIndex).File, "ck"))
        For Each B As C_Epole.S_FullLable In Me.AllFullLabels
            RaiseEvent StatusMessage("[p] SaveStyle_Checkbox name=" & B.CheckBox.Name, e_EventMessage.Normal)
            TagINI.Write("STYLE", "CheckBox_" & B.CheckBox.Name, B.CheckBox.Checked) 'A.Visible)
        Next

        '///////////////////////////////////////////////////////////////////////////////////////////////////
        TagINI = New ACC.MyINI(StyleDir.FullName & "\" & StyleList(SetForm.cmb_style.SelectedIndex).File)
        TagINI.Write("STYLE", "MarginX", SetForm.MyProperty_Paper.출력여백X)
        TagINI.Write("STYLE", "MarginY", SetForm.MyProperty_Paper.출력여백Y)
        TagINI.Write("STYLE", "ScaleX", SetForm.MyProperty_Paper.가로확대비율)
        TagINI.Write("STYLE", "ScaleY", SetForm.MyProperty_Paper.세로확대비율)
        TagINI.Write("STYLE", "LandScape", Me.pDoc.DefaultPageSettings.Landscape)
        'TagINI.Write("STYLE", "dummy", SetForm.MyProperty_Paper.사용여부)
        TagINI.Write("STYLE", "dummycnt", SetForm.MyProperty_Paper.출력장수)
        'MsgBox("저장장수" & SetForm.MyProperty_Paper.출력장수)

        TagINI.Write("STYLE", "dummytype", SetForm.MyProperty_Paper.출력방법)
        TagINI.Write("STYLE", "dummmyx", SetForm.MyProperty_Paper.연속여백x)
        TagINI.Write("STYLE", "dummmyy", SetForm.MyProperty_Paper.연속여백y)

        TagINI.Write("STYLE", "RowDivCnt", SetForm.MyProperty_Paper.분리갯수)
        TagINI.Write("STYLE", "rowdivx", SetForm.MyProperty_Paper.분리여백x)
        TagINI.Write("STYLE", "rowdivy", SetForm.MyProperty_Paper.분리여백y)
        TagINI.Write("STYLE", "DRAWITEMREPEAT", SetForm.MyProperty_Paper.그리기개체반복)

        TagINI.Write("STYLE", "ViewImage", SetForm.Chk_BgImage.Checked)
        TagINI.Write("STYLE", "fixedstyle", SetForm.rad_repeat.Checked)
        TagINI.Write("STYLE", "printrange", SetForm.tb_printrange.Text)
        TagINI.Write("STYLE", "backimg", SetForm.tb_picfile.Text)

        '///////////////////////////////////////////////////////////////////////////////////////////////////
        '//스타일저장시에 현재 레이아웃상태또한 저장하게한다. 이부분은 스타일불러올때 쓰지는 않고
        '//가로/세로 선택할때 불러오게한다(파일에서 직접 불러오게한다 어차피 한번뿐이므로 궃이 메모리에 올리필요없다
        Me.SaveReadLayOut_NEW(False) '//레이아웃저장한다.
        Me.SaveReadDesignData(False)

        ' NOTICE("기본스타일을 저장했습니다", Me.lb_msg)
        ' Arin.WLog2(Auto_Log, "save style 완료후 데이터테이블 갱신을 호춣 ", LogFile)
        Me.데이터테이블갱신()
        Me.preview_window()

    End Sub
    Public Sub LOAD_STYLEC(ByVal StyleName As String, ByVal Div As String)
        '//기타스타일은 빈도가 적으니 파일에서 불러오기로한다.;;메모리는 싫타.
        Dim Arinini As New ACC.MyINI(Me.StyleFileC)
        If Not Arinini.Exist Then
            MsgBox("기타스타일설정 파일이 존재하지 않습니다\n\n관리자에 문의하세요", MsgBoxStyle.Critical, "오류")
            Return
        End If
        Dim pos(), font(), visible As String '//구전산번호를 구현해본다.
        Dim Tobj As CEpole.C_label
        Dim fcString As String = System.Drawing.Color.Black.ToArgb.ToString()

        For i As Integer = 0 To Me.AllLabels.GetUpperBound(0)
            Tobj = Me.AllLabels(i)

            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")
                    fcString = Arinini.Read(StyleName, Tobj.Name & "fc")
                    If String.IsNullOrWhiteSpace(fcString) Then fcString = System.Drawing.Color.Black.ToArgb.ToString()

                    '//상태를 읽어서 바로 적용한다.
                    Tobj.Location = New Point(pos(0), pos(1))
                    Tobj.Size = New Size(pos(2), pos(3))

                    Dim fStyle As FontStyle = FontStyle.Regular
                    If font(2).ToUpper() = "TRUE" Then fStyle = fStyle Or FontStyle.Underline
                    If font(3).ToUpper() = "TRUE" Then fStyle = fStyle Or FontStyle.Bold
                    If font(4).ToUpper() = "TRUE" Then fStyle = fStyle Or FontStyle.Italic


                    Tobj.Font = New Font(font(0), font(1), fStyle, GraphicsUnit.Point)
                    Tobj.WordWidth = font(5)
                    Tobj.WordHeight = font(6)
                    Tobj.WordSpace = Arinini.Read(StyleName, Tobj.Name & "space", 0)
                    Tobj.visible = CType(visible, Boolean)
                    Tobj.ForeColor2 = System.Drawing.Color.FromArgb(CInt(fcString)) '//160515

                    'MsgBox(Tobj) '


                Else '이곳에 O가올것이다.
                    If Tobj.Name.ToUpper.Substring(0, 1) = Div Then
                        pos = Arinini.Read(StyleName, Tobj.Name & "pos").Split(",")
                        font = Arinini.Read(StyleName, Tobj.Name & "font").Trim(Chr(0)).Split(",")
                        visible = Arinini.Read(StyleName, Tobj.Name & "visible")
                        fcString = Arinini.Read(StyleName, Tobj.Name & "fc")
                        If String.IsNullOrWhiteSpace(fcString) Then fcString = System.Drawing.Color.Black.ToArgb.ToString()

                        '//상태를 읽어서 바로 적용한다.
                        Tobj.Location = New Point(pos(0), pos(1))
                        Tobj.Size = New Size(pos(2), pos(3))

                        Dim fStyle As FontStyle = FontStyle.Regular
                        If font(2).ToUpper() = "TRUE" Then fStyle = fStyle Or FontStyle.Underline
                        If font(3).ToUpper() = "TRUE" Then fStyle = fStyle Or FontStyle.Bold
                        If font(4).ToUpper() = "TRUE" Then fStyle = fStyle Or FontStyle.Italic

                        Tobj.Font = New Font(font(0), font(1), fStyle, GraphicsUnit.Point)
                        Tobj.WordWidth = font(5)
                        Tobj.WordHeight = font(6)
                        Tobj.WordSpace = Arinini.Read(StyleName, Tobj.Name & "space", 0)
                        Tobj.visible = CType(visible, Boolean)
                        Tobj.ForeColor2 = System.Drawing.Color.FromArgb(CInt(fcString)) '//160515

                        'MsgBox(Tobj)


                    End If
                End If
            Catch ex As Exception
                RaiseEvent StatusMessage("[P] Error Load_StyleC : 오류 = " & ex.Message.ToString, e_EventMessage.Normal)
            End Try

            Tobj.ForeColor = Tobj.ForeColor2 '//160515
        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 ACC.MyINI(StyleFileC)
        '//현재 선택된 스타일을 저장합니다.
        Arinini.Write(stylename, "DESC", stylename)
        Dim Tobj As CEpole.C_label

        For i As Integer = 0 To Me.AllLabels.GetUpperBound(0)
            Tobj = Me.AllLabels(i)
            Arinini.Write(stylename, Tobj.Name & "pos", Tobj.Left & "," & Tobj.Top & "," & Tobj.Width & "," & Tobj.Height)
            Arinini.Write(stylename, Tobj.Name & "font", Tobj.Font.Name & "," & Tobj.Font.Size & "," & Tobj.Font.Underline & "," & Tobj.Font.Bold & "," & Tobj.Font.Italic & "," & Tobj.WordWidth & "," & Tobj.WordHeight)
            Arinini.Write(stylename, Tobj.Name & "visible", Tobj.visible)
            Arinini.Write(stylename, Tobj.Name & "space", Tobj.WordSpace)
            Arinini.Write(stylename, Tobj.Name & "fc", Tobj.ForeColor2.ToArgb.ToString())
        Next
        'NOTICE("기타스타일을 저장했습니다", Me.lb_msg)
    End Sub

    ''' <summary>
    ''' 디자인개체들을 저장
    ''' </summary>
    ''' <remarks></remarks>
    Public Sub SaveReadDesignData(ByVal read As Boolean)
        Dim bname As String = "DrawBox"
        Dim lname As String = "DrawLine"
        Dim Iname As String = "DrawImage"
        Dim Cname As String = "Drawcircle"
        Dim qname As String = "DrawQRcode"
        Dim bcnt, Ccnt, lcnt, Icnt, qcnt As Short
        Dim INi As New ACC.MyINI(DesignFile.FullName)

        If read Then
            'MsgBox("디자인데이터 불러오기" & DesignFile.FullName)
            Me.Draw_Box = New Shape_Box
            Me.Draw_Line = New Shape_line
            Me.Draw_Image = New Shape_Image
            Me.Draw_Circle = New Shape_Circle
            Me.Draw_QRcode = New Shape_QRcode

            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.Radius = INi.Read(bname, "box" & i & "rad", 10)
                Me.Draw_Box.Add(L)
            Next

            Ccnt = INi.Read(Cname, "Count", 0)
            For i As Short = 1 To Ccnt '//모두돌아서 저장한다.
                Dim L As New S_Circle
                L.PenColor = Drawing.Color.FromArgb(INi.Read(Cname, "circle" & i & "pencolor", 0))
                L.PenWidth = INi.Read(Cname, "circle" & i & "pensize", 3)
                L.X = INi.Read(Cname, "circle" & i & "x", 0)
                L.Y = INi.Read(Cname, "circle" & i & "y", 0)
                L.Width = INi.Read(Cname, "circle" & i & "x2", 10)
                L.Height = INi.Read(Cname, "circle" & i & "y2", 10)
                'L.Radius = INi.Read(Cname, "box" & i & "rad", 10)
                Me.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)
                Me.Draw_Line.Add(L)
            Next

            Icnt = INi.Read(Iname, "Count", 0)
            For i As Short = 1 To Icnt '//모두돌아서 저장한다.
                Dim L As New S_Image
                L.FileName = INi.Read(Iname, "img" & i & "file", "")
                L.X = INi.Read(Iname, "img" & i & "x", 0)
                L.Y = INi.Read(Iname, "img" & i & "y", 0)
                L.Width = INi.Read(Iname, "img" & i & "x2", 10)
                L.Height = INi.Read(Iname, "img" & i & "y2", 10)
                Me.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.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.Size = INi.Read(qname, "qrcode" & i & "qsize", 10)
                L.Encoding = INi.Read(qname, "qrcode" & i & "qe", 10)
                L.Version = INi.Read(qname, "qrcode" & i & "qv", 10)
                L.CLeve = INi.Read(qname, "qrcode" & i & "qclevel", 10)
                L.Format = INi.Read(qname, "qrcode" & i & "format", "{DATA}")
                L.fColor = System.Drawing.Color.FromArgb(Integer.Parse(INi.Read(qname, "qrcode" & i & "fcolor", Drawing.Color.Black.ToArgb().ToString())))
                L.bColor = System.Drawing.Color.FromArgb(Integer.Parse(INi.Read(qname, "qrcode" & i & "bColor", Drawing.Color.White.ToArgb().ToString())))
                Me.Draw_QRcode.Add(L)

            Next
            SetForm.Refresh_Drawlist()
        Else
            ' MsgBox("디자인데이터 저장" & DesignFile.FullName)
            INi.Write(bname, "Count", Me.Draw_Box.Count)
            For i As Short = 1 To Me.Draw_Box.Count '//모두돌아서 저장한다.
                Dim L As S_Box = Me.Draw_Box.item(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 & "rad", L.Radius)
            Next
            INi.Write(Cname, "Count", Me.Draw_Circle.Count)
            For i As Short = 1 To Me.Draw_Circle.Count '//모두돌아서 저장한다.
                Dim L As S_Circle = Me.Draw_Circle.item(i - 1)
                INi.Write(Cname, "circle" & i & "pencolor", L.PenColor.ToArgb)
                INi.Write(Cname, "circle" & i & "pensize", L.PenWidth)
                INi.Write(Cname, "circle" & i & "x", L.X)
                INi.Write(Cname, "circle" & i & "y", L.Y)
                INi.Write(Cname, "circle" & i & "x2", L.Width)
                INi.Write(Cname, "circle" & i & "y2", L.Height)
                'INi.Write(bname, "circle" & i & "rad", L.Radius)
            Next
            INi.Write(lname, "Count", Me.Draw_Line.Count)
            For i As Short = 1 To Me.Draw_Line.Count '//모두돌아서 저장한다.
                Dim L As S_Line = Me.Draw_Line.Item(i - 1)
                INi.Write(lname, "line" & i & "pencolor", L.PenColor.ToArgb)
                INi.Write(lname, "line" & i & "pensize", L.PenWidth)
                INi.Write(lname, "line" & i & "x", L.X)
                INi.Write(lname, "line" & i & "y", L.Y)
                INi.Write(lname, "line" & i & "x2", L.X2)
                INi.Write(lname, "line" & i & "y2", L.Y2)
            Next
            INi.Write(Iname, "Count", Me.Draw_Image.Count)
            For i As Short = 1 To Me.Draw_Image.Count '//모두돌아서 저장한다.
                Dim L As S_Image = Me.Draw_Image.item(i - 1)
                INi.Write(Iname, "img" & i & "file", L.FileName.Replace(My.Application.Info.DirectoryPath, "."))
                INi.Write(Iname, "img" & i & "x", L.X)
                INi.Write(Iname, "img" & i & "y", L.Y)
                INi.Write(Iname, "img" & i & "x2", L.Width)
                INi.Write(Iname, "img" & i & "y2", L.Height)
            Next

            INi.Write(qname, "Count", Me.Draw_QRcode.Count)
            For i As Short = 1 To Me.Draw_QRcode.Count
                Dim L As S_QRCode = Me.Draw_QRcode.item(i - 1)
                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 & "qsize", L.Size.ToString)
                INi.Write(qname, "qrcode" & i & "qe", CInt(L.Encoding).ToString())
                INi.Write(qname, "qrcode" & i & "qv", CInt(L.Version).ToString())
                INi.Write(qname, "qrcode" & i & "qclevel", CInt(L.CLeve).ToString())

                INi.Write(qname, "qrcode" & i & "format", L.Format)

                INi.Write(qname, "qrcode" & i & "fColor", L.fColor.ToArgb().ToString())
                INi.Write(qname, "qrcode" & i & "bColor", L.bColor.ToArgb().ToString())

            Next

        End If
    End Sub

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

        Dim ini As New ACC.MyINI(ReplaceExt(StyleDir.FullName & "\" & StyleList(SetForm.cmb_style.SelectedIndex).File, "layout"))
        Dim Secname As String = "pagetype" & SetForm.MyProperty_Paper.용지방향 ' IIf(SetForm.rad_land.Checked, 1, 0) 'Me.cmb_landscape.SelectedIndex

        If read = False Then
            ini.Write(Secname, "PictureBox1loc", Me.v_picturebox1.Left & "," & Me.v_picturebox1.Top)
            ini.Write(Secname, "PictureBox1size", Me.v_picturebox1.Width & "," & Me.v_picturebox1.Height)
            ini.Write(Secname, "cmb_styleloc", SetForm.cmb_style.Left & "," & SetForm.cmb_style.Top)
            ini.Write(Secname, "cmb_stylesize", SetForm.cmb_style.Width & "," & SetForm.cmb_style.Height)
            ini.Write(Secname, "mesize", Me.Width & "," & Me.Height)
            ini.Write(Secname, "backimgtype", SetForm.cmb_imgtype.SelectedIndex)
            ini.Write(Secname, "bakimgpos", CInt(SetForm.tb_bakx.Text) & "," & CInt(SetForm.tb_baky.Text)) '//배경이미지 위치
            ini.Write(Secname, "bakimgsize", CInt(SetForm.tb_bakw.Text) & "," & CInt(SetForm.tb_bakh.Text))    '//배경이미지 크기
            ini.Write(Secname, "printimg", SetForm.chk_prnimg.Checked)

        Else   '//여기는 읽는 부분
            SetForm.cmb_imgtype.SelectedIndex = ini.Read(Secname, "backimgtype", 3)  '//기본값 stretch
            SetForm.tb_bakx.Text = ini.Read(Secname, "bakimgpos", "0,0").Split(",")(0)
            SetForm.tb_baky.Text = ini.Read(Secname, "bakimgpos", "0,0").Split(",")(1)
            SetForm.tb_bakw.Text = ini.Read(Secname, "bakimgsize", "300,550").Split(",")(0)
            SetForm.tb_bakh.Text = ini.Read(Secname, "bakimgsize", "300,550").Split(",")(1)
            SetForm.chk_prnimg.Checked = ini.Read(Secname, "printimg", False)
            If SetForm.MyProperty_Paper.용지방향 = E_PaperOrient.세로 Then
                Me.pDoc.DefaultPageSettings.Landscape = False
                v_picturebox1.Location = New Point(ini.Read(Secname, "PictureBox1loc", "3,3").Split(",")(0), ini.Read(Secname, "PictureBox1loc", "3,3").Split(",")(1))
                v_picturebox1.Size = New Size(ini.Read(Secname, "PictureBox1size", "270,479").Split(",")(0), ini.Read(Secname, "PictureBox1size", "270,479").Split(",")(1))
                Me.Size = New Size(ini.Read(Secname, "mesize", "588,632").Split(",")(0), ini.Read(Secname, "mesize", "588,632").Split(",")(1))
            Else
                Me.pDoc.DefaultPageSettings.Landscape = True
                v_picturebox1.Location = New Point(ini.Read(Secname, "PictureBox1loc", "325,3").Split(",")(0), ini.Read(Secname, "PictureBox1loc", "325,3").Split(",")(1))
                v_picturebox1.Size = New Size(ini.Read(Secname, "PictureBox1size", "355,200").Split(",")(0), ini.Read(Secname, "PictureBox1size", "355,200").Split(",")(1))
                Me.Size = New Size(ini.Read(Secname, "mesize", "730,643").Split(",")(0), ini.Read(Secname, "mesize", "730,643").Split(",")(1))
            End If
        End If
    End Sub

    Public Sub LOAD_STYLE(Optional ByVal Div As String = "Z")   '//저장된 스타일을 불러옵니다.
        RaiseEvent StatusMessage("Entering >> Load_Style", e_EventMessage.Normal)

        Dim pos(), font(), visible, mytext, repeat() As String
        Dim Tobj As CEpole.C_label
        Dim DR() As DataRow
        Dim idx As Integer = 0

        '//모든아이템을 돈다
        For i As Integer = 0 To Me.AllLabels.GetUpperBound(0)   '//모든아이템을 돈다.
            Tobj = Me.AllLabels(i)
            If Div.ToUpper = "Z" Then '//모든아이템을 가져오고
                '//메모리에서 찾는다.
                Tobj.Tag = ""
                DR = StyleList(SetForm.cmb_style.SelectedIndex).PATTERNTABLE.Select("설명 = '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 = StyleList(SetForm.cmb_style.SelectedIndex).PATTERNTABLE.Select("설명 = 'STYLE" & Tobj.Name.ToUpper & "FONT'")
                If DR.GetUpperBound(0) = 0 Then
                    font = DR(0)(1).ToString.Split(",")
                    Tobj.WordWidth = font(5)
                    Tobj.WordHeight = font(6)
                    Dim fStyle As FontStyle = FontStyle.Regular
                    If font(2).ToUpper() = "TRUE" Then fStyle = fStyle Or FontStyle.Underline
                    If font(3).ToUpper() = "TRUE" Then fStyle = fStyle Or FontStyle.Bold
                    If font(4).ToUpper() = "TRUE" Then fStyle = fStyle Or FontStyle.Italic
                    Tobj.Font = New Font(font(0), font(1), fStyle, GraphicsUnit.Point)
                    '  MsgBox(font(0))
                End If

                DR = StyleList(SetForm.cmb_style.SelectedIndex).PATTERNTABLE.Select("설명 = 'STYLE" & Tobj.Name.ToUpper & "REPEAT'")
                If DR.GetUpperBound(0) = 0 Then
                    repeat = DR(0)(1).ToString.Split(",")
                    Tobj.Repeat = repeat(0)
                    Tobj.RepeatX = repeat(1)
                    Tobj.RepeatY = repeat(2)

                End If

                DR = StyleList(SetForm.cmb_style.SelectedIndex).PATTERNTABLE.Select("설명 = 'STYLE" & Tobj.Name.ToUpper & "VISIBLE'")
                If DR.GetUpperBound(0) = 0 Then
                    visible = DR(0)(1).ToString
                    Tobj.visible = CType(visible, Boolean)
                End If

                '//160515
                DR = StyleList(SetForm.cmb_style.SelectedIndex).PATTERNTABLE.Select("설명 = 'STYLE" & Tobj.Name.ToUpper & "FC'")
                If DR.GetUpperBound(0) = 0 Then
                    Dim fcstr As String = DR(0)(1).ToString
                    If String.IsNullOrWhiteSpace(fcstr) Then fcstr = System.Drawing.Color.Black.ToArgb.ToString
                    Tobj.ForeColor2 = System.Drawing.Color.FromArgb(CInt(fcstr)) ' CType(visible, Boolean)
                End If

                If Tobj.Fixed Then   '//고정길이 문자열은 문자를 가져온다.
                    RaiseEvent StatusMessage("Static Text Found !! || Name :" & Tobj.Name.ToUpper, e_EventMessage.Normal)
                    DR = StyleList(SetForm.cmb_style.SelectedIndex).PATTERNTABLE.Select("설명 = 'STYLE" & Tobj.Name.ToUpper & "MYTEXT'")
                    If DR.GetUpperBound(0) = 0 Then
                        mytext = DR(0)(1).ToString
                        If mytext <> "" Then
                            RaiseEvent StatusMessage("_0_Static Text : STYLE" & Tobj.Name.ToUpper & " value=" & mytext, e_EventMessage.Normal)
                            Tobj.Text = mytext 'Arin.TextDec(mytext) '//ini구조상 바로저장하면안되기때문에 변환해서 저장한다.
                            RaiseEvent StatusMessage(">>> " & Tobj.Text, e_EventMessage.Normal)
                        End If
                    End If
                End If
                DR = StyleList(SetForm.cmb_style.SelectedIndex).PATTERNTABLE.Select("설명 = 'STYLE" & Tobj.Name.ToUpper & "SPACE'")
                If DR.GetUpperBound(0) = 0 Then Tobj.WordSpace = DR(0)(1).ToString
            Else    '//특정아이템구분일때 

                If Tobj.Name.ToUpper = Div Then

                    '//메모리에서 찾는다.
                    Tobj.Tag = ""
                    DR = StyleList(SetForm.cmb_style.SelectedIndex).PATTERNTABLE.Select("설명 = '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 = StyleList(SetForm.cmb_style.SelectedIndex).PATTERNTABLE.Select("설명 = 'STYLE" & Tobj.Name.ToUpper & "FONT'")
                    If DR.GetUpperBound(0) = 0 Then
                        font = DR(0)(1).ToString.Split(",")
                        Tobj.WordWidth = font(5)
                        Tobj.WordHeight = font(6)
                        Dim fStyle As FontStyle = FontStyle.Regular
                        If font(2).ToUpper() = "TRUE" Then fStyle = fStyle Or FontStyle.Underline
                        If font(3).ToUpper() = "TRUE" Then fStyle = fStyle Or FontStyle.Bold
                        If font(4).ToUpper() = "TRUE" Then fStyle = fStyle Or FontStyle.Italic
                        Tobj.Font = New Font(font(0), font(1), fStyle, GraphicsUnit.Point)
                        ' MsgBox(font(0))
                    End If

                    DR = StyleList(SetForm.cmb_style.SelectedIndex).PATTERNTABLE.Select("설명 = 'STYLE" & Tobj.Name.ToUpper & "REPEAT'")
                    If DR.GetUpperBound(0) = 0 Then
                        repeat = DR(0)(1).ToString.Split(",")
                        Tobj.Repeat = repeat(0)
                        Tobj.RepeatX = repeat(1)
                        Tobj.RepeatY = repeat(2)
                    End If

                    DR = StyleList(SetForm.cmb_style.SelectedIndex).PATTERNTABLE.Select("설명 = 'STYLE" & Tobj.Name.ToUpper & "VISIBLE'")
                    If DR.GetUpperBound(0) = 0 Then
                        visible = DR(0)(1).ToString
                        Tobj.visible = CType(visible, Boolean)
                    End If

                    '//160515
                    DR = StyleList(SetForm.cmb_style.SelectedIndex).PATTERNTABLE.Select("설명 = 'STYLE" & Tobj.Name.ToUpper & "FC'")
                    If DR.GetUpperBound(0) = 0 Then
                        Dim fcstr As String = DR(0)(1).ToString
                        If String.IsNullOrWhiteSpace(fcstr) Then fcstr = System.Drawing.Color.Black.ToArgb.ToString
                        Tobj.ForeColor2 = System.Drawing.Color.FromArgb(CInt(fcstr)) ' CType(visible, Boolean)
                    End If



                    If Tobj.Fixed Then   '//고정길이 문자열은 문자를 가져온다.
                        RaiseEvent StatusMessage("Static Text Found !! || Name :" & Tobj.Name.ToUpper, e_EventMessage.Normal)
                        DR = StyleList(SetForm.cmb_style.SelectedIndex).PATTERNTABLE.Select("설명 = 'STYLE" & Tobj.Name.ToUpper & "MYTEXT'")
                        If DR.GetUpperBound(0) = 0 Then
                            mytext = DR(0)(1).ToString
                            If mytext <> "" Then
                                RaiseEvent StatusMessage("_1_Static Text : STYLE" & Tobj.Name.ToUpper & " value=" & mytext, e_EventMessage.Normal)
                                Tobj.Text = mytext 'Arin.TextDec(mytext) '//ini구조상 바로저장하면안되기때문에 변환해서 저장한다.
                                RaiseEvent StatusMessage(">>> " & Tobj.Text, e_EventMessage.Normal)
                            End If
                        End If
                    End If

                    DR = StyleList(SetForm.cmb_style.SelectedIndex).PATTERNTABLE.Select("설명 = 'STYLE" & Tobj.Name.ToUpper & "SPACE'")
                    If DR.GetUpperBound(0) = 0 Then Tobj.WordSpace = DR(0)(1).ToString

                End If
            End If
            Tobj.ForeColor = Tobj.ForeColor2 '//160515
        Next
        If Div.ToUpper <> "Z" Then
            RaiseEvent StatusMessage("DIV=" & Div & " Exit  :: Load_Style", e_EventMessage.Normal)
            Return '//모든템이아니다
        End If

        RaiseEvent StatusMessage("load_style dIV가 Z로 스탈기본값도 불러온다 || 기본값 체크박스등의 값을 불러온다. 이것은 스타일선택시 한번만 불러온다. ", e_EventMessage.Normal)

        ''''''''''''''''''' 개체조정''우측 스타일 체크박스를 가져온다.
        '//데이터표시 체크박스 상태를 저장한다.
        Dim Arinini As New ACC.MyINI(ReplaceExt(StyleDir.FullName & "\" & StyleList(SetForm.cmb_style.SelectedIndex).File, "ck"))
        'Dim Arinini As New CommonClassv2.MyINI(StyleDir.FullName & "\" & StyleList(SetForm.cmb_style.SelectedIndex).File)
        For Each B As C_Epole.S_FullLable In Me.AllFullLabels
            B.CheckBox.Checked = Arinini.Read("STYLE", "CheckBox_" & B.CheckBox.Name, True) 'A.Visible)
        Next

        '//관리자는 체크박스를 모두 활성화한다.        If Admin Then Me.AdminSetting()
        ''''''''''''''''''''''''''''외'''''''''''''''''''''''''''''''''
        SetForm.MyProperty_Paper.출력여백X = StyleList(SetForm.cmb_style.SelectedIndex).MarginX
        SetForm.MyProperty_Paper.출력여백Y = StyleList(SetForm.cmb_style.SelectedIndex).MarginY
        SetForm.MyProperty_Paper.가로확대비율 = StyleList(SetForm.cmb_style.SelectedIndex).ScaleX
        SetForm.MyProperty_Paper.세로확대비율 = StyleList(SetForm.cmb_style.SelectedIndex).ScaleY

        'New PropertyGrid_Paper.S_Size(StyleList(SetForm.cmb_style.SelectedIndex).ScaleX, StyleList(SetForm.cmb_style.SelectedIndex).ScaleY) ' Arinini.Read("STYLE", "ScaleX", "1.5")
        '= StyleList(SetForm.cmb_style.SelectedIndex).MarginX 'Arinini.Read("STYLE", "MarginX", 10)
        'SetForm.tb_marginY.Text = StyleList(SetForm.cmb_style.SelectedIndex).MarginY ' Arinini.Read("STYLE", "MarginY", 10)

        'SetForm.tb_scaley.Text = StyleList(SetForm.cmb_style.SelectedIndex).ScaleY ' Arinini.Read("STYLE", "ScaleY", "1.3")
        ''''''''''''''''''''''2중'''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''


        '//더미는 이제 사용하지않는다.20090729 변경
        Dim UseDummy As Boolean = StyleList(SetForm.cmb_style.SelectedIndex).Dummy 'Arinini.Read("STYLE", "dummy", False)
        Try
            SetForm.MyProperty_Paper.출력장수 = StyleList(SetForm.cmb_style.SelectedIndex).DummyCnt
            If UseDummy AndAlso SetForm.MyProperty_Paper.출력장수 < 2 Then SetForm.MyProperty_Paper.출력장수 = 2
            If SetForm.MyProperty_Paper.출력장수 < 2 Then SetForm.MyProperty_Paper.출력장수 = 1
        Catch ex As Exception
            If UseDummy Then
                SetForm.MyProperty_Paper.출력장수 = 2
            Else
                SetForm.MyProperty_Paper.출력장수 = 1
            End If
        End Try
        SetForm.MyProperty_Paper.출력방법 = StyleList(SetForm.cmb_style.SelectedIndex).Dummytype ' Arinini.Read("STYLE", "dummytype", 0)
        SetForm.MyProperty_Paper.연속여백x = StyleList(SetForm.cmb_style.SelectedIndex).dummmyx
        SetForm.MyProperty_Paper.연속여백y = StyleList(SetForm.cmb_style.SelectedIndex).dummmyy

        SetForm.MyProperty_Paper.분리갯수 = StyleList(SetForm.cmb_style.SelectedIndex).RowDivCnt
        SetForm.MyProperty_Paper.분리여백x = StyleList(SetForm.cmb_style.SelectedIndex).rowdivx
        SetForm.MyProperty_Paper.분리여백y = StyleList(SetForm.cmb_style.SelectedIndex).rowdivy

        SetForm.MyProperty_Paper.그리기개체반복 = StyleList(SetForm.cmb_style.SelectedIndex).DrawItemRepeat

        'SetForm.tb_secx.Text = StyleList(SetForm.cmb_style.SelectedIndex).dummmyx ' Arinini.Read("STYLE", "dummmyx", "0")
        'SetForm.tb_secy.Text = StyleList(SetForm.cmb_style.SelectedIndex).dummmyy ' Arinini.Read("STYLE", "dummmyy", "300")
        SetForm.tb_picfile.Text = StyleList(SetForm.cmb_style.SelectedIndex).Backimg ' Arinini.Read("STYLE", "backimg", My.Application.Info.DirectoryPath & "\image\wall.bmp").ToString.Trim(Chr(0))

        '//고정문자스타일인지 확인한다
        SetForm.rad_repeat.Checked = StyleList(SetForm.cmb_style.SelectedIndex).FixedStyle ' Arinini.Read("STYLE", "backimg", My.Application.Info.DirectoryPath & "\image\wall.bmp").ToString.Trim(Chr(0))

        '//인쇄범위를 불러온다(고정문자때문에 이것이 저장되엇지만 있어도 나쁠건 없기때문에 넣는다)
        SetForm.tb_printrange.Text = StyleList(SetForm.cmb_style.SelectedIndex).PrintRange

        '//그림표시
        Me.pDoc.DefaultPageSettings.Landscape = StyleList(SetForm.cmb_style.SelectedIndex).LandScape ' Arinini.Read("STYLE", "LandScape", False)
        SetForm.MyProperty_Paper.용지방향 = StyleList(SetForm.cmb_style.SelectedIndex).LandScape

        SetForm.Chk_BgImage.Checked = StyleList(SetForm.cmb_style.SelectedIndex).Viewimage ' Arinini.Read("STYLE", "ViewImage", True)
        RaiseEvent StatusMessage(">> Display Background Image : " & SetForm.Chk_BgImage.Checked, e_EventMessage.Normal)

        If SetForm.Chk_BgImage.Checked Then
            Dim Fn As String = SetForm.GetBgImgFile
            If Fn = "" Then  '//파일명이없으므로 체크박스해제
                RaiseEvent StatusMessage("[그림파일이 지정되지않았습니다", e_EventMessage.Normal)
                SetForm.Chk_BgImage.Checked = False
                SetForm.bakimg = Nothing
                Me.v_picturebox1.BackgroundImage = Nothing
                SetForm.bakimg.BackgroundImage = Nothing
            ElseIf File.Exists(Fn) Then
                If SetForm.cmb_imgtype.SelectedIndex = 5 Then  '//화면에 직접출력일경우
                    RaiseEvent StatusMessage("[배경그림 : 화면에 직접출력", e_EventMessage.Normal)
                    SetForm.bakimg.BackgroundImage = Image.FromFile(Fn)
                Else
                    SetForm.bakimg.BackgroundImage = Image.FromFile(Fn)
                    Me.v_picturebox1.BackgroundImage = SetForm.bakimg.BackgroundImage
                End If
            Else
                RaiseEvent StatusMessage(">> 배경그림파일이 존재하지 않습니다", e_EventMessage.Normal)
                MsgBox("배경그림파일이 존재하지 않습니다" & vbCrLf & "파일명 : " & vbCrLf & Fn, MsgBoxStyle.Critical, "확인")
                SetForm.Chk_BgImage.Checked = False
                Me.v_picturebox1.BackgroundImage = Nothing
                SetForm.bakimg.BackgroundImage = Nothing
            End If
        End If

        RaiseEvent StatusMessage(SetForm.cmb_style.Text & "스타일을 불러왔습니다.", e_EventMessage.Normal)
    End Sub

    Public Function GetSpread(ByVal row As Integer, ByVal col As Integer) As String
        Try
            Return Dv(row)(col)
        Catch ex As Exception
            Return ""
        End Try
    End Function
    Public Function GetSpread(ByVal row As Integer, ByVal colname As String) As String
        Try
            Return Dv(row)(colname)
            'Return Me.CustFP1_Sheet1.Cells(row, col).Value.ToString
        Catch ex As Exception
            Return ""
        End Try
    End Function

    Private Sub Defalut_PrintForm_DesignMode_Change(ByVal Mode As C_Epole.E_DesignMode) Handles Me.DesignMode_Change
        '//변경되면 모든 컨트롤의 색상을 회색으로 변경한다
        If Me.SetForm Is Nothing Then Return
        If Mode Then
            MsgBox("편집가능한 디자인모드는 완성되지않았습니다", MsgBoxStyle.Information, "확인")
        End If
        Me.preview_window()
    End Sub

    Private Sub Defalut_PrintForm_MouseWheel(ByVal sender As Object, ByVal e As System.Windows.Forms.MouseEventArgs) Handles Me.MouseWheel
        If e.Delta < 0 Then
            'If Me.BindingNavigatorPositionItem.Text < Me.BindingNavigatorCountItem.Text Then
            Me.v_Bn.MoveNextItem.PerformClick()
            'Me.BindingNavigatorMoveNextItem.PerformClick()
            'Me.BindingNavigatorPositionItem.Focus()
            'End If
        Else
            If Me.v_Bn.PositionItem.Text > 0 Then
                Me.v_Bn.MovePreviousItem.PerformClick()
                'Me.BindingNavigatorPositionItem.Focus()
            End If
        End If
    End Sub

    Private Sub Print_Form_Move(ByVal sender As Object, ByVal e As System.EventArgs) Handles Me.Move
        If Not SetForm Is Nothing Then
            SetForm.Top = Me.Top
            SetForm.Left = Me.Left + Me.Width + 10
        End If
    End Sub

    Private Sub Print_Form_Resize(ByVal sender As Object, ByVal e As System.EventArgs) Handles Me.Resize
        If Not SetForm Is Nothing Then
            SetForm.Top = Me.Top
            SetForm.Left = Me.Left + Me.Width + 10
        End If
    End Sub
    Private Sub Print_Form_FormClosing(ByVal sender As Object, ByVal e As System.Windows.Forms.FormClosingEventArgs) Handles Me.FormClosing
        If Not SetForm Is Nothing Then SetForm.Close()
        '//현재 폼의 설정을 저장한다.
        '0728 마지막 레코드번호르 저장한다.
        'Dim INi As New CommonClassv2.MyINI(Me.StyleDir.FullName & "\" & StyleList(SetForm.cmb_style.SelectedIndex).File)
        'INi.Write("style", "lastpos", Me.BS.Position)
        'INi = Nothing
    End Sub

    Private Sub Print_Form_Load(ByVal sender As Object, ByVal e As System.EventArgs) Handles Me.Load
        RaiseEvent StatusMessage("Form_Load", e_EventMessage.Normal)
        Me.SetStyle(Windows.Forms.ControlStyles.AllPaintingInWmPaint Or Windows.Forms.ControlStyles.UserPaint Or Windows.Forms.ControlStyles.DoubleBuffer, True) '//더블버퍼링

        '//기본적으로 디자인모드를 텍스트로한다.
        Me.DMode = E_DesignMode.Text
    End Sub

    Private Sub Print_Form_KeyDown(ByVal sender As Object, ByVal e As System.Windows.Forms.KeyEventArgs) Handles Me.KeyDown
        Select Case e.KeyCode
            Case Windows.Forms.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 Windows.Forms.Keys.Down
                If e.Shift Then
                    Me.CtrSize(True, 1)
                Else
                    Me.CtrPos(True, 1)
                End If
                'ViewProperty(Tobj)
                e.Handled = True
            Case Windows.Forms.Keys.Left
                If e.Shift Then
                    Me.CtrSize(False, -1)
                Else
                    Me.CtrPos(False, -1)
                End If
                'ViewProperty(Tobj)
                e.Handled = True
            Case Windows.Forms.Keys.Right
                If e.Shift Then
                    Me.CtrSize(False, 1)
                Else
                    Me.CtrPos(False, 1)
                End If
                'ViewProperty(Tobj)
                e.Handled = True
            Case Windows.Forms.Keys.F5
                Me.bt_SL.PerformClick()
                'Me.QSave_PatternI()
            Case Windows.Forms.Keys.F9
                Me.Print()
            Case Windows.Forms.Keys.P
                If e.Control Then
                    Me.Print()
                End If
            Case Windows.Forms.Keys.F8
                Me.Print_Preview()
            Case Windows.Forms.Keys.V
                If e.Control Then
                    Me.Print_Preview()
                End If
            Case Windows.Forms.Keys.F1
                Show_ShortKey()
            Case Windows.Forms.Keys.H
                If e.Control Then
                    Show_ShortKey()
                End If
            Case Windows.Forms.Keys.F4
                If MsgBox("현재 스타일(기본)을 저장하시겠습니까?", MsgBoxStyle.Information + MsgBoxStyle.YesNo, "스타일저장") = MsgBoxResult.Yes Then
                    SAVE_STYLE_NEW()
                End If
            Case Windows.Forms.Keys.S
                If e.Control Then
                    Me.QSave_PatternII()
                End If
            Case Windows.Forms.Keys.T
                If e.Control Then
                    If MsgBox("현재 스타일(기본)을 저장하시겠습니까?", MsgBoxStyle.Information + MsgBoxStyle.YesNo, "스타일저장") = MsgBoxResult.Yes Then
                        SAVE_STYLE_NEW()
                    End If

                End If
            Case Windows.Forms.Keys.Escape
                Me.Close()
            Case Windows.Forms.Keys.PageDown
                Me.v_Bn.MoveNextItem.PerformClick()
            Case Windows.Forms.Keys.PageUp
                Me.v_Bn.MovePreviousItem.PerformClick()
        End Select


        'RaiseEvent SelectedControl(Me.onlyOne) '//선택개체는 OnlyOne 에도 들어있다.
        SetForm.ViewProperty(Me.OnlyOne, "부모 : 방향키들이 눌렸을떄")  '//키보드로 개체이동시에 개체위치정보를 바로보여준다.
    End Sub
    Public Sub Show_ShortKey()
        Dim A As New Frm_Shortkey
        A.Show()
    End Sub
    Public Sub CtrSizeDraw(ByVal vertical As Boolean, ByVal offset As Short)
        '//쉐이프개체의 크기를 조정한다.
        If Me.SelConDraw Is Nothing OrElse SelConDraw.Count < 1 Then Exit Sub

        For Each sender As CEpole.C_label In SelCon
            Me.AllFullLabels(sender.Gidx).Moved = True

            If vertical Then    '//상하
                If My.Computer.Keyboard.AltKeyDown Then
                    If offset < 0 Then
                        sender.WordHeight -= 1
                    Else
                        sender.WordHeight += 1
                    End If
                ElseIf My.Computer.Keyboard.CtrlKeyDown Then
                    If offset < 0 Then
                        sender.WordHeight -= 10
                    Else
                        sender.WordHeight += 10
                    End If
                Else
                    sender.WordHeight += offset
                End If
            Else    '//좌우
                If My.Computer.Keyboard.AltKeyDown Then
                    If offset < 0 Then
                        sender.WordWidth -= 1
                    Else
                        sender.WordWidth += 1
                    End If
                ElseIf My.Computer.Keyboard.CtrlKeyDown Then
                    If offset < 0 Then
                        sender.WordWidth -= 10
                    Else
                        sender.WordWidth += 10
                    End If
                Else
                    sender.WordWidth += offset
                End If
            End If
        Next

        Me.preview_window()
    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 CEpole.C_label In SelCon
            Me.AllFullLabels(sender.Gidx).Moved = True

            If vertical Then    '//상하
                If My.Computer.Keyboard.AltKeyDown Then
                    If offset < 0 Then
                        sender.WordHeight -= 1
                    Else
                        sender.WordHeight += 1
                    End If
                ElseIf My.Computer.Keyboard.CtrlKeyDown Then
                    If offset < 0 Then
                        sender.WordHeight -= 10
                    Else
                        sender.WordHeight += 10
                    End If
                Else
                    sender.WordHeight += offset
                End If
            Else    '//좌우
                If My.Computer.Keyboard.AltKeyDown Then
                    If offset < 0 Then
                        sender.WordWidth -= 1
                    Else
                        sender.WordWidth += 1
                    End If
                ElseIf My.Computer.Keyboard.CtrlKeyDown Then
                    If offset < 0 Then
                        sender.WordWidth -= 10
                    Else
                        sender.WordWidth += 10
                    End If
                Else
                    sender.WordWidth += offset
                End If
            End If
        Next

        Me.preview_window()
    End Sub
    Public Sub CtrPos(ByVal vertical As Boolean, ByVal offset As Short)
        ' Arin.WLog2(Auto_Log, "ctrpos (선택된 개체들의 위치값을 변경합니다)", LogFile)
        If SelCon Is Nothing OrElse SelCon.Count < 1 Then Exit Sub

        For Each sender As CEpole.C_label In SelCon
            Me.AllFullLabels(sender.Gidx).Moved = True

            If vertical Then    '//좌우측
                If My.Computer.Keyboard.AltKeyDown Then
                    If offset < 0 Then
                        sender.Top -= 1
                    Else
                        sender.Top += 1
                    End If
                ElseIf 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.AltKeyDown Then
                    If offset < 0 Then
                        sender.Left -= 1
                    Else
                        sender.Left += 1
                    End If
                ElseIf 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
        ' Arin.WLog2(Auto_Log, "ctrpos =[ preview 호출합니다]", LogFile)
        Me.preview_window()
        'Me.ViewProperty(sender)
    End Sub


    ''' <summary>
    ''' 드로우 개체의 위치를 조정합니다.
    ''' </summary>
    ''' <param name="vertical"></param>
    ''' <param name="offset"></param>
    ''' <remarks></remarks>
    Public Sub CtrPosDraw(ByVal vertical As Boolean, ByVal offset As Short)
        ' Arin.WLog2(Auto_Log, "ctrpos (선택된 개체들의 위치값을 변경합니다)", LogFile)
        If SelConDraw Is Nothing OrElse SelConDraw.Count < 1 Then Exit Sub

        For Each sender As CEpole.C_label In SelCon
            Me.AllFullLabels(sender.Gidx).Moved = True

            If vertical Then    '//좌우측
                If My.Computer.Keyboard.AltKeyDown Then
                    If offset < 0 Then
                        sender.Top -= 1
                    Else
                        sender.Top += 1
                    End If
                ElseIf 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.AltKeyDown Then
                    If offset < 0 Then
                        sender.Left -= 1
                    Else
                        sender.Left += 1
                    End If
                ElseIf 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
        ' Arin.WLog2(Auto_Log, "ctrpos =[ preview 호출합니다]", LogFile)
        Me.preview_window()
        'Me.ViewProperty(sender)
    End Sub

    ''' <summary>
    ''' 글꼴크기변경
    ''' </summary>
    ''' <param name="vertical"></param>
    ''' <param name="offset"></param>
    ''' <remarks></remarks>
    Public Sub CtrFontSize(ByVal vertical As Boolean, ByVal offset As Short)
        If SelCon Is Nothing OrElse SelCon.Count < 1 Then Exit Sub

        For Each sender As CEpole.C_label In SelCon
            Me.AllFullLabels(sender.Gidx).Moved = True

            If vertical Then    '//상하
                If My.Computer.Keyboard.AltKeyDown Then
                    If offset < 0 Then
                        sender.WordHeight -= 1
                    Else
                        sender.WordHeight += 1
                    End If
                ElseIf My.Computer.Keyboard.CtrlKeyDown Then
                    If offset < 0 Then
                        sender.WordHeight -= 10
                    Else
                        sender.WordHeight += 10
                    End If
                Else
                    sender.WordHeight += offset
                End If
            Else    '//좌우
                If My.Computer.Keyboard.AltKeyDown Then
                    If offset < 0 Then
                        sender.WordWidth -= 1
                    Else
                        sender.WordWidth += 1
                    End If
                ElseIf My.Computer.Keyboard.CtrlKeyDown Then
                    If offset < 0 Then
                        sender.WordWidth -= 10
                    Else
                        sender.WordWidth += 10
                    End If
                Else
                    sender.WordWidth += offset
                End If
            End If
        Next

        Me.preview_window()
    End Sub


    Public Sub CtrFontChange()
        If SelCon Is Nothing OrElse SelCon.Count < 1 Then Exit Sub

        For Each sender As CEpole.C_label In SelCon
            Me.AllFullLabels(sender.Gidx).Moved = True
            sender.Font = New Font("HY견고딕", sender.Font.Size, FontStyle.Regular)
        Next

        Me.preview_window()
    End Sub



    ''' <summary>
    ''' 현재화면을 모두 갱신합니다. 실제데이터만 표시해주는 Preview_window 와는 다르면 이것은 데이터를 갱신하고 preview_window를 재호출합니다
    ''' </summary>
    ''' <param name="Previewwin"></param>
    ''' <remarks></remarks>
    Public Sub Refresh_Window(Optional ByVal Previewwin As Boolean = True)
        Me.GeTviewData(Me.BS.Position, Previewwin)
    End Sub

    ''' <summary>
    ''' 160515
    ''' </summary>
    ''' <param name="fn"></param>
    ''' <remarks></remarks>
    Public Sub SaveImage(fn As String)
        Dim dummy As Boolean = False    '//이값이 true 이면 출력시 변위를 지정해서 출력한다.
        Dim BackScr As New Bitmap(2100, 2970, Imaging.PixelFormat.Format32bppArgb) 'Me.v_picturebox1.CreateGraphics)
        BackScr.SetResolution(300, 300)
        Dim Ga As Graphics = Graphics.FromImage(BackScr)
        Ga.Clear(Drawing.Color.White)

        For pi As Short = 0 To SetForm.MyProperty_Paper.출력장수 - 1  '//페이지당 연속출력할 횟수            
            Build_PrintPage(Ga, pi, True)
        Next
        Ga.Dispose()
        BackScr.Save(fn, System.Drawing.Imaging.ImageFormat.Jpeg)
        BackScr.Dispose()
    End Sub

    Public Sub preview_window()    '//미리보기화면을 생성합니다.
        Dim dummy As Boolean = False    '//이값이 true 이면 출력시 변위를 지정해서 출력한다.
        Dim BackScr As New Bitmap(Me.v_picturebox1.Width, Me.v_picturebox1.Height, Imaging.PixelFormat.Format32bppArgb) 'Me.v_picturebox1.CreateGraphics)
        Dim Ga As Graphics = Graphics.FromImage(BackScr)

        'MsgBox("prewview window")
        If SetForm.MyProperty_Paper.출력장수 < 1 Then SetForm.MyProperty_Paper.출력장수 = 1
        RaiseEvent StatusMessage(">> Preview : 모든개체를 실제 화면에 표시합니다", e_EventMessage.Normal)
        For pi As Short = 0 To SetForm.MyProperty_Paper.출력장수 - 1  '//페이지당 연속출력할 횟수
            'MsgBox("연속횟수" & pi)
            'Build_PrintPage(Ga, pi, False, SetForm.cmb_style.SelectedIndex, Me.PrintArray(Me.printindex))
            'MsgBox(SetForm.NewFp1_Sheet1.ActiveRowIndex)  'QRQR
            Build_PrintPage(Ga, pi, False)
        Next
        Ga.Dispose()
        Me.v_picturebox1.Image = BackScr
    End Sub
#End Region

    Private Sub v_picturebox1_MouseClick(ByVal sender As Object, ByVal e As System.Windows.Forms.MouseEventArgs) Handles v_picturebox1.MouseClick
        If Me.DMode = E_DesignMode.Text Then
            Dim Tobj As CEpole.C_label
            Dim selitem As New ArrayList    '//마우스클릭했을때 여러개가 겹친경우 해당 아이템들을 넣는곳


            Dim g As Graphics = CreateGraphics()
            Tobj = Nothing
            For i As Integer = 0 To Me.AllLabels.GetUpperBound(0)
                If Me.AllLabels(i).visible AndAlso Me.AllLabels(i).Text <> "" AndAlso
                    ((e.X >= Me.AllLabels(i).Left) And e.X <= (Me.AllLabels(i).Left + Me.AllLabels(i).GetSize(g).Width)) _
                    AndAlso ((e.Y >= Me.AllLabels(i).Top) AndAlso (e.Y <= (Me.AllLabels(i).Top + Me.AllLabels(i).GetSize(g).Height))) Then
                    Tobj = Me.AllLabels(i)
                    selitem.Add(Me.AllLabels(i))
                    'Exit For
                End If
            Next
            If Tobj Is Nothing Then Return '//선택된게 없으면 날린다
            Me.OnlyOne = Tobj '//마지막으로 선택된것을 지정해준다(혹 나중에 일괄적용일경우에 마지막꺼기준으로 적용)

            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), CEpole.C_label).Desc)
                Next
                If A.ShowDialog() = Windows.Forms.DialogResult.OK Then
                    Tobj = selitem.Item(A.ListBox1.SelectedIndex)
                Else   '//캔슬시에는 첫번째 아템으로 한다.
                    Tobj = selitem.Item(0)
                End If
                Me.OnlyOne = Tobj '//다중선택에의한 선택시에는 마지막꺼를 넣는다.
                'SetForm.Focus()
                'Me.Focus()
            End If

            Dim Exist As Boolean = False   '//선택개체에 존재여부

            If SelCon Is Nothing Then   '//현재 선택개체데이터가 아에없다면 신규로 추가해준다.
                SelCon = New ArrayList : SelCon.Add(Tobj)
            Else
                If e.Button = Windows.Forms.MouseButtons.Right Then '//Right Click
                    '//팝업메뉴 보여준다.(현재 이기능은 거의 안쓰고있다)
                    Me.cm.Show()
                    Me.cm.Left = e.X
                    Me.cm.Top = e.Y + 10
                    Me.cm.Left = Windows.Forms.Control.MousePosition.X + 10
                    Me.cm.Top = Windows.Forms.Control.MousePosition.Y + 5
                ElseIf e.Button = Windows.Forms.MouseButtons.Left Then '//Left Click
                    If My.Computer.Keyboard.ShiftKeyDown Then '//Add
                        For Each obj As CEpole.C_label In SelCon
                            If obj.Name = Tobj.Name Then    '//이미선택되어있었는데 또 선택되었다면 선택하제
                                obj.ForeColor = obj.ForeColor2 ' Drawing.Color.Black '//160515
                                SelCon.Remove(obj)
                                Exist = True
                                Exit For
                            End If
                        Next
                        If Exist = False Then   '//존재하지 않았으므로 선택개체목록에 추가한다.
                            SelCon.Add(Tobj)
                            Tobj.ForeColor = Drawing.Color.Yellow   '//추가개체는 노랑색
                        End If
                    Else '//Normal LEft click
                        For Each SC As CEpole.C_label In SelCon
                            SC.ForeColor = SC.ForeColor2 'Drawing.Color.Black  '//현재선택된 개체를 모두 검정으로 반전시킨다
                        Next
                        SelCon = New ArrayList : SelCon.Add(Tobj)
                        Tobj.ForeColor = Drawing.Color.DodgerBlue   '//처음선택개체는 퍼런색DodgerBlue 

                        If My.Computer.Keyboard.CtrlKeyDown Then
                            SelCon = New ArrayList '//컨트롤이 눌러졋으면 해당 그룹을 전부 찾는다.
                            For z As Short = 0 To Me.AllLabels.GetUpperBound(0)
                                If Me.AllLabels(z).Name.Substring(0, 1) = Tobj.Name.Substring(0, 1) Then
                                    Me.AllLabels(z).ForeColor = Drawing.Color.Blue
                                    SelCon.Add(Me.AllLabels(z))
                                End If
                            Next
                        End If
                    End If
                Else   '//가운데버튼이다. 가운데는 폰트변경으로한다.
                    SetForm.bt_fontchange.PerformClick()
                End If
            End If

            If Me.SelCon.Count = 0 Then
                SetForm.cmb_controls.Text = ""
            ElseIf Me.SelCon.Count = 1 Then
                SetForm.cmb_controls.Text = Tobj.Desc
            Else    '//여러개의 데이터가 선택되었다면
                SetForm.cmb_controls.Text = "*****" '//다중선택을 지정해준다.
            End If
            RaiseEvent SelectedControl(Tobj) '//선택개체는 OnlyOne 에도 들어있다.

        Else
            MsgBox("디자인모드상태에서 클릭 현재 미지원")
        End If

        Me.preview_window()
    End Sub

    Private Sub v_picturebox1_MouseDoubleClick(ByVal sender As Object, ByVal e As System.Windows.Forms.MouseEventArgs) Handles v_picturebox1.MouseDoubleClick
        '//더블클릭하면 번호표시형태를 변경할수 있게한다.
        If Me.DMode = E_DesignMode.Text Then
            Dim Tobj As CEpole.C_label = Nothing
            Dim g As Graphics = CreateGraphics()
            For i As Integer = 0 To Me.AllLabels.GetUpperBound(0)
                If Me.AllLabels(i).visible AndAlso Me.AllLabels(i).Text <> "" AndAlso
                    ((e.X >= Me.AllLabels(i).Left) And e.X <= (Me.AllLabels(i).Left + Me.AllLabels(i).GetSize(g).Width)) _
                    AndAlso ((e.Y >= Me.AllLabels(i).Top) AndAlso (e.Y <= (Me.AllLabels(i).Top + Me.AllLabels(i).GetSize(g).Height))) Then
                    Tobj = Me.AllLabels(i)
                    Exit For
                End If
            Next
            If Tobj Is Nothing Then Return '//선택된게 없으면 날린다
            Dim Msg As New System.Text.StringBuilder("새로운 번호형식을 입력하세요")
            Msg.AppendLine()
            Msg.AppendLine("예) 9,9,0   각콤마(,)는 한줄의 의미합니다")
            'Dim Val As String = InputBox(Msg.ToString, "변경", Tobj.NumType)
            'If Val = "" Then Return
            'Tobj.NumType = Val
        Else   '//쉐이프모드일때는 다른형태로 작동할예정 현재 작동안함
            MsgBox("쉐이프모드는 미지원입니다")
        End If
        Me.preview_window()

    End Sub

    Public Sub Selected_Style(ByVal SelIndex As Short)
        '//여기서 데이터를 추려내고(필터를 가져온다.)
        'Try
        RaiseEvent StatusMessage(">> Entering : Selected_Style / Index=" & SelIndex, e_EventMessage.Normal)
        If SelIndex < 0 Then SelIndex = 0

        If StyleList.GetUpperBound(0) = -1 Then
            RaiseEvent StatusMessage(">> Exit : No StyleList ", e_EventMessage.Normal)
            Return
        End If
        Dim DataFilter As String = StyleList(SelIndex).Filter
        If DataFilter.Trim = "" Then
            DataFilter = "출력 = true"
        Else
            DataFilter &= " AND 출력 = true"
        End If
        RaiseEvent StatusMessage(">>Sytle Filter = " & DataFilter, e_EventMessage.Normal)
        '///////////////바인딩소스를 초기화한다. 이건 나중에 뷰로 연결하기 위함이다.
        Me.BS.Sort = ""
        Me.BS.DataSource = Nothing

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

        RaiseEvent StatusMessage(">> Create DataView" & DataFilter, e_EventMessage.Normal)
        If Dv.Count <= 0 Then '//데이터가없다면
            MsgBox(StyleList(SelIndex).Desc & "에 해당하는 데이터가존재하지 않습니다" & vbCrLf &
            vbCrLf & "다른 스타일을 선택하세요", MsgBoxStyle.Information, "확인")
            Me.v_picturebox1.Image = Nothing
        Else
            RaiseEvent StatusMessage(">> " & Dv.Count & "개의 데이터가 존재합니다", e_EventMessage.Normal)
            Me.v_scrolbar.Minimum = 0   '//스크롤바 초기화
            Me.v_scrolbar.Maximum = Dv.Count - 1


            Me.LOAD_STYLE()   '//스타일불러오기(여기서 모든컨트롤의 기본 위치와 글꼴이 결정된다)

            Me.SaveReadLayOut_NEW(True) '//배경그림파일의 위치또한 변경해준다. 이건 스타일이 변경됬을때만
            Me.SaveReadDesignData(True)

            If Me.FirstIdx = -1 And Srcnum >= 0 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

            '//임시로 첨에보여줄 데이터를 이전에 저장된레코드번호로한다.
            Dim ini As New ACC.MyINI(Me.StyleDir.FullName & "\" & StyleList(SetForm.cmb_style.SelectedIndex).File)
            RaiseEvent StatusMessage("스타일 선택된 선택ini 파일명 = " & ini.FileName, e_EventMessage.Normal)

            'FirstIdx = ini.Read("style", "lastpos", 0)

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

            RaiseEvent StatusMessage(">> 보여줄 데이터의 인덱스가 " & FirstIdx & " 번 입니다", e_EventMessage.Normal)

            Me.BS.DataSource = Dv 'Dv   '//여기서셋팅되면서 바로 tview 가 작동된다.
            Me.BS.Sort = "정렬번호,번호" ',번호"            
            Me.v_scrolbar.Value = FirstIdx
            Me.BS.Position = FirstIdx

            'MsgBox("ASDF" & Me.BindingNavigatorPositionItem.Text)
            If FirstIdx = 0 Then
                RaiseEvent StatusMessage(">> 보여줄 데이터의 인덱스가 0 번 이라서 GeTviewData 를 호출합니다(왜그런지 기억안남)", e_EventMessage.Normal)
                Me.GeTviewData(BS.Position, True)
            End If
            '                If FirstIdx = 0 Then Me.GeTviewData(Me.BindingNavigatorPositionItem.Text - 1, True)
        End If
        'Catch ex As Exception      '//에러난다면 거의 뭐;;폼을 바로 실행하는경우다
        '    RaiseEvent StatusMessage(" 관리자? SelectedStyle 에오류발생 : " & ex.Message.ToString, e_EventMessage.Normal)
        'End Try
        'Catch ex As Exception
        '    MsgBox("selected 스타일에 오류발생 메세지 : " & ex.ToString)
        'End Try

    End Sub

    Private Sub BS_PositionChanged(ByVal sender As Object, ByVal e As System.EventArgs) Handles BS.PositionChanged
        '포지션 체인지
        If Me.BS.Position >= 0 Then Me.v_scrolbar.Value = (Me.BS.Position)
        If Me.NoView Then
            Me.NoView = False
        Else
            RaiseEvent StatusMessage("BS_Positionchange value=" & BS.Position & " Run GetTviewData", e_EventMessage.Normal)
            Me.GeTviewData(BS.Position, True)
        End If
        SetForm.ViewProperty(Me.OnlyOne, "부모 : 바인딩소스의 위치가 바뀔때")
    End Sub

    Public Sub AddLog(ByVal msg As String)
        Try
            If Me.Admin Then
                Mylog.RichTextBox1.AppendText(msg & vbCrLf)
            End If
        Catch ex As Exception

        End Try

    End Sub

    Private Sub Defalut_PrintForm_StatusMessage(ByVal Message As String, ByVal type As C_Epole.e_EventMessage) Handles Me.StatusMessage
        AddLog(Message)
    End Sub

    ''' <summary>
    ''' 체크박스클릭했을때 일어나는 이벤트이다 각 출력폼에서 정의한다
    ''' </summary>
    ''' <param name="sender"></param>
    ''' <param name="e"></param>
    ''' <remarks></remarks>
    Protected Sub ViewCheck_Click(ByVal sender As Object, ByVal e As System.EventArgs)
        AddLog(">>View CheckBox[" & CType(sender, Windows.Forms.ToolStripMenuItem).Text & "] Checked Click >> Refresh Window")
        Me.Refresh_Window()
    End Sub


#Region "Button 관련"

#Region "버튼 할당 속성"

#End Region

#Region "화면 조절 버튼"
    Private Sub bt_canvasD_MouseDown(ByVal sender As Object, ByVal e As System.Windows.Forms.MouseEventArgs) Handles bt_canvasD.MouseDown

        If e.Button = Windows.Forms.MouseButtons.Right Then
            If My.Computer.Keyboard.CtrlKeyDown Then
                If SetForm.cmb_imgtype.SelectedIndex <> 5 Then
                    MsgBox("배경화면 직접출력을 선택해야 가능합니다", MsgBoxStyle.Information, "확인")
                    Return
                End If
                SetForm.tb_baky.Text += 2
                Me.preview_window()
            Else
                Me.v_picturebox1.Top += 2
            End If

        ElseIf e.Button = Windows.Forms.MouseButtons.Left Then
            If My.Computer.Keyboard.CtrlKeyDown Then
                If SetForm.cmb_imgtype.SelectedIndex <> 5 Then
                    MsgBox("배경화면 직접출력을 선택해야 가능합니다", MsgBoxStyle.Information, "확인")
                    Return
                End If
                SetForm.tb_bakh.Text += 2
                Me.preview_window()
            Else
                Me.v_picturebox1.Height += 2
            End If

        End If


    End Sub

    Private Sub bt_canvasL_MouseDown(ByVal sender As Object, ByVal e As System.Windows.Forms.MouseEventArgs) Handles bt_canvasL.MouseDown
        If e.Button = Windows.Forms.MouseButtons.Right Then
            If My.Computer.Keyboard.CtrlKeyDown Then
                If SetForm.cmb_imgtype.SelectedIndex <> 5 Then
                    MsgBox("배경화면 직접출력을 선택해야 가능합니다", MsgBoxStyle.Information, "확인")
                    Return
                End If
                SetForm.tb_bakx.Text -= 2
                Me.preview_window()
            Else
                Me.v_picturebox1.Left -= 2
            End If

        ElseIf e.Button = Windows.Forms.MouseButtons.Left Then
            If My.Computer.Keyboard.CtrlKeyDown Then
                If SetForm.cmb_imgtype.SelectedIndex <> 5 Then
                    MsgBox("배경화면 직접출력을 선택해야 가능합니다", MsgBoxStyle.Information, "확인")
                    Return
                End If
                SetForm.tb_bakw.Text -= 2
                Me.preview_window()
            Else
                Me.v_picturebox1.Width -= 2
            End If

        End If


    End Sub

    Private Sub bt_canvasR_MouseDown(ByVal sender As Object, ByVal e As System.Windows.Forms.MouseEventArgs) Handles bt_canvasR.MouseDown
        If e.Button = Windows.Forms.MouseButtons.Right Then
            If My.Computer.Keyboard.CtrlKeyDown Then
                If SetForm.cmb_imgtype.SelectedIndex <> 5 Then
                    MsgBox("배경화면 직접출력을 선택해야 가능합니다", MsgBoxStyle.Information, "확인")
                    Return
                End If
                SetForm.tb_bakx.Text += 2
                Me.preview_window()
            Else
                Me.v_picturebox1.Left += 2
            End If

        ElseIf e.Button = Windows.Forms.MouseButtons.Left Then
            If My.Computer.Keyboard.CtrlKeyDown Then
                If SetForm.cmb_imgtype.SelectedIndex <> 5 Then
                    MsgBox("배경화면 직접출력을 선택해야 가능합니다", MsgBoxStyle.Information, "확인")
                    Return
                End If
                SetForm.tb_bakw.Text += 2
                Me.preview_window()
            Else
                Me.v_picturebox1.Width += 2
            End If

        End If

    End Sub

    Private Sub bt_canvasU_MouseDown(ByVal sender As Object, ByVal e As System.Windows.Forms.MouseEventArgs) Handles bt_canvasU.MouseDown

        If e.Button = Windows.Forms.MouseButtons.Right Then
            If My.Computer.Keyboard.CtrlKeyDown Then
                If SetForm.cmb_imgtype.SelectedIndex <> 5 Then
                    MsgBox("배경화면 직접출력을 선택해야 가능합니다", MsgBoxStyle.Information, "확인")
                    Return
                End If
                SetForm.tb_baky.Text -= 2
                Me.preview_window()
            Else
                Me.v_picturebox1.Top -= 5
            End If

        ElseIf e.Button = Windows.Forms.MouseButtons.Left Then
            If My.Computer.Keyboard.CtrlKeyDown Then
                If SetForm.cmb_imgtype.SelectedIndex <> 5 Then
                    MsgBox("배경화면 직접출력을 선택해야 가능합니다", MsgBoxStyle.Information, "확인")
                    Return
                End If
                SetForm.tb_bakh.Text -= 2
                Me.preview_window()
            Else
                Me.v_picturebox1.Height -= 2
            End If
        End If
    End Sub
#End Region


#End Region

#Region "Events"
    Private Sub Defalut_PrintForm_SelectedControl(ByVal obj As C_label) Handles Me.SelectedControl
        '//특정개체가 선택되었을때 (부모그룹에서 패턴적용여부를 찾아표시한다.)
        With Me.AllFullLabels(obj.Gidx)
            Select Case .ApplyPattern
                Case E_PatternType.None
                    'Me.bt_SC.ForeColor = Color.Black
                    Me.bt_SL.ForeColor = Drawing.Color.Black
                Case Else
                    ' Me.bt_SC.ForeColor = Color.Black
                    Me.bt_SL.ForeColor = Drawing.Color.Red
                    'Case E_PatternType.Character    '//문자
                    '    ' Me.bt_SC.ForeColor = Color.Red
                    '    Me.bt_SL.ForeColor = Color.Black
            End Select

            If Not bt_SL2 Is Nothing Then Me.bt_SL2.ForeColor = bt_SL.ForeColor
        End With

        '//패턴저장버튼활성화한다
        If Me.AllFullLabels(obj.Gidx).Fixed Then
            Me.bt_SL.Enabled = False

            ' Me.bt_SC.Enabled = False
        Else
            Me.bt_SL.Enabled = True
            '  Me.bt_SC.Enabled = 1
        End If
        If Not bt_SL2 Is Nothing Then Me.bt_SL2.Enabled = bt_SL.Enabled
    End Sub
#End Region

    Private Sub bt_SL_Click(ByVal sender As Object, ByVal e As System.EventArgs) Handles bt_SL.Click
        If MsgBox("선택된 개체의 패턴을 저장하시겠습니까?", MsgBoxStyle.Information + MsgBoxStyle.OkCancel, "확인") <> MsgBoxResult.Ok Then Return
        Me.QSave_PatternII()
        ' MsgBox("패턴이 저장되었습니다", MsgBoxStyle.Information, "확인")
    End Sub

    Private Sub bt_SL2_Click(ByVal sender As Object, ByVal e As System.EventArgs) Handles bt_SL2.Click
        If MsgBox("선택된 개체의 패턴(H)을 저장하시겠습니까?", MsgBoxStyle.Information + MsgBoxStyle.OkCancel, "확인") <> MsgBoxResult.Ok Then Return
        Me.QSave_PatternIIH()
        ' MsgBox("패턴이 저장되었습니다", MsgBoxStyle.Information, "확인")
    End Sub

    Private Sub bt_SS_Click(ByVal sender As Object, ByVal e As System.EventArgs) Handles bt_SS.Click
        If MsgBox("현재 스타일(기본)을 저장하시겠습니까?", MsgBoxStyle.Information + MsgBoxStyle.YesNo, "스타일저장") = MsgBoxResult.Yes Then
            SAVE_STYLE_NEW()
        Else
            MsgBox("스타일저장을 취소하였습니다", MsgBoxStyle.Critical, "확인")
        End If
    End Sub

    Private Sub v_scrolbar_Scroll(ByVal sender As Object, ByVal e As System.Windows.Forms.ScrollEventArgs) Handles v_scrolbar.Scroll
        If e.NewValue > 0 Then
            Me.BS.Position = e.NewValue
        Else
            AddLog("스크롤바value값이 0보다 작습니다. 소스의 위치를 0으로 설정합니다")
            Me.BS.Position = 0
        End If
    End Sub

    Private Sub v_picturebox1_MouseMove(ByVal sender As Object, ByVal e As System.Windows.Forms.MouseEventArgs) Handles v_picturebox1.MouseMove
        'Me.Text = e.X & "/" & e.Y
        Me.Activate()
        If My.Computer.Keyboard.CtrlKeyDown = True AndAlso My.Computer.Keyboard.AltKeyDown = True Then
            '//선택된 컨트롤을 마우스위치로 이동한다
            If Me.DMode = E_DesignMode.Text Then
                If SelCon Is Nothing OrElse SelCon.Count < 1 Then Exit Sub
                For Each sender1 As CEpole.C_label In SelCon
                    sender1.Left = e.X - (sender1.Width / 2)
                    sender1.Top = e.Y + (sender1.Height / 2)
                Next
            Else
                MsgBox("쉐이프모두 미지원 여긴 개체가 마우스 따라다니는거")
            End If
            Me.preview_window()
        End If
    End Sub

    Private Sub cm_Opening(ByVal sender As System.Object, ByVal e As System.ComponentModel.CancelEventArgs) Handles cm.Opening
        If Me.SelCon.Count > 1 Then
            Me.cm_label.Text = "다중선택"
        Else
            Me.cm_label.Text = CType(Me.SelCon(0), C_label).Desc
        End If
    End Sub

    Private Sub BS_CurrentChanged(sender As System.Object, e As System.EventArgs) Handles BS.CurrentChanged

    End Sub
End Class
