using System;
using System.Collections;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Windows.Forms;

using Cosmos.CommonManager;
using Cosmos.Common;
using Cosmos.BaseFrame;
using Cosmos.UserFrame;
using Cosmos.ServiceProvider;

namespace Cosmos.Win
{
    public partial class frmEtcSetting : Form
    {
        #region 변수 선언
        private SManager sManager = new SManager();
        private PosStatus m_cPosStatus = new PosStatus();                           // 기본정보 참조
        private IPosPrinterUs m_objPrinter = null;
        private StateServer StateObject = (StateServer)StateServer.GetInstance();   // StateObject : StateServer Object (객체)

        private readonly Color m_clrSelectFont = Color.FromArgb(255, 255, 255);
        private readonly Color m_clrSelectback = Color.FromArgb(109, 110, 113);

        private readonly Color m_clrNonSelectFont = Color.FromArgb(109, 110, 113);
        private readonly Color m_clrNonSelectback = Color.FromArgb(255, 255, 255);
        #endregion 변수 선언

        #region 생성자 & 소멸자
        public frmEtcSetting()
        {
            InitializeComponent();

            base.SetStyle(ControlStyles.OptimizedDoubleBuffer | ControlStyles.AllPaintingInWmPaint | ControlStyles.ResizeRedraw, true);
            //this.UpdateStyles();

            m_cPosStatus = (PosStatus)StateObject.POS;      // POS 기본정보
            m_objPrinter = (IPosPrinterUs)sManager.InitServiceInstance(ServiceLists.AGENT_OLEDEVICE.DLL, ServiceLists.AGENT_OLEDEVICE.DEVICE_POSPRINTER);
        }

        private void frmEtcSetting_Load(object sender, EventArgs e)
        {
            UserLog.WriteLogFile(UserCom.LOG_IOS, System.Reflection.Assembly.GetExecutingAssembly().ManifestModule.Name,
                    System.Reflection.MethodBase.GetCurrentMethod().DeclaringType.Name + "." + System.Reflection.MethodBase.GetCurrentMethod().Name + "()", "");
            InitControl();

            TitleDisplay();
        }

        private void frmEtcSetting_FormClosing(object sender, FormClosingEventArgs e)
        {
            UserLog.WriteLogFile(UserCom.LOG_IOS, System.Reflection.Assembly.GetExecutingAssembly().ManifestModule.Name,
                    System.Reflection.MethodBase.GetCurrentMethod().DeclaringType.Name + "." + System.Reflection.MethodBase.GetCurrentMethod().Name + "()", lblTitle.Text);
        }
        #endregion 생성자 & 소멸자

        #region 폼 컨트롤 초기화
        /// <summary>
        /// 폼 컨트롤 초기화
        /// </summary>
        private void InitControl()
        {
            try
            {
                FormManager.SetFormAllControlFont(this, m_cPosStatus.Base.FONT);
                FormManager.SetTextBoxGlobalInfo(this, m_cPosStatus.Global.m_stCultureMaster.nGroupingDigits, m_cPosStatus.Global.m_stCultureMaster.strGroupingSymbol
                    , m_cPosStatus.Global.m_stCultureMaster.nDecimalDigits, m_cPosStatus.Global.m_stCultureMaster.strDecimalSymbol);

                picBack.Image = ImageManager.GetImage(BaseCom.NxImgPath, ImageManager.POP_SIZE_800X600);
                lblTitle.Text = MessageManager.GetLabelMessage(POS_MESSAGE.LABEL.MSG_0321);

                btnExit.Image = ImageManager.GetImage(BaseCom.NxImgPath, ImageManager.BTN_CLOSE);
                if (btnExit.Image != null) btnExit.Text = "";

                btnTitle01.Text = MessageManager.GetLabelMessage(POS_MESSAGE.LABEL.MSG_0776);//.MSG_0321);
                btnTitle02.Text = MessageManager.GetLabelMessage(POS_MESSAGE.LABEL.MSG_0774);//.MSG_0321);

                btnTitle01.ForeColor = m_clrSelectFont;
                btnTitle01.BackColor = m_clrSelectback;

                btnTitle02.ForeColor = m_clrNonSelectFont;
                btnTitle02.BackColor = m_clrNonSelectback;

                lblNameTitle.Text = MessageManager.GetLabelMessage(POS_MESSAGE.LABEL.MSG_0776);
                lblScannerTitle.Text = MessageManager.GetLabelMessage(POS_MESSAGE.LABEL.MSG_0777);
                lblPrintTitle.Text = MessageManager.GetLabelMessage(POS_MESSAGE.LABEL.MSG_0492);

                btnPrint01.Text = MessageManager.GetLabelMessage(POS_MESSAGE.LABEL.MSG_0257);
                btnPrint02.Text = MessageManager.GetLabelMessage(POS_MESSAGE.LABEL.MSG_0257);
                btnPrint03.Text = MessageManager.GetLabelMessage(POS_MESSAGE.LABEL.MSG_0775);

                btnScanner01.Text = MessageManager.GetLabelMessage(POS_MESSAGE.LABEL.MSG_0778);
                btnScanner02.Text = MessageManager.GetLabelMessage(POS_MESSAGE.LABEL.MSG_0779);
                btnScanner03.Text = MessageManager.GetLabelMessage(POS_MESSAGE.LABEL.MSG_0780);
                btnScanner04.Text = MessageManager.GetLabelMessage(POS_MESSAGE.LABEL.MSG_0781);

                pnl01.Visible = true;
                pnl02.Visible = false;

                rdoBtn01.Checked = true;
                radioButton1.Checked = true;

                //ArrayList aPrintData = new ArrayList();

                //aPrintData.Add(PosConst.PRT_HDR.PRT_NOR);
                //aPrintData.Add(PosConst.PRT_HDR.PRT_NOR);
                //aPrintData.Add(PosConst.PRT_HDR.PRT_NOR);
                ////lbPrintData.Items.Add(PosConst.PRT_HDR.PRT_NOR + "123456789012345678901234567890123456789012");
                //aPrintData.Add(PosConst.PRT_HDR.PRT_VER + "      << SCANNER INITIALIZE SETUP >>      ");
                //aPrintData.Add(PosConst.PRT_HDR.PRT_VER);
                //aPrintData.Add(PosConst.PRT_HDR.PRT_NOR + "==============PS/2 SCANNER TYPE===========");
                //aPrintData.Add(PosConst.PRT_HDR.PRT_NOR + "     STEP 1. STANDARD PRODUCT DEFAULTS    ");
                //aPrintData.Add(PosConst.PRT_HDR.PRT_SIS + "~DEFALT.{3");
                //aPrintData.Add(PosConst.PRT_HDR.PRT_NOR);
                //aPrintData.Add(PosConst.PRT_HDR.PRT_NOR + "      STEP 2. STANDARD PRODUCT PAPLTD     ");
                //aPrintData.Add(PosConst.PRT_HDR.PRT_SIS + "~PAPLTD.{3");
                //aPrintData.Add(PosConst.PRT_HDR.PRT_NOR);
                //aPrintData.Add(PosConst.PRT_HDR.PRT_NOR + "        STEP 3. ALL SYMBOLOGIES ON        ");
                //aPrintData.Add(PosConst.PRT_HDR.PRT_SIS + "~ALLENA1.{3");
                //aPrintData.Add(PosConst.PRT_HDR.PRT_NOR);
                //aPrintData.Add(PosConst.PRT_HDR.PRT_NOR + "=======PS/2 SCANNER AND KEYBOARD TYPE=====");
                //aPrintData.Add(PosConst.PRT_HDR.PRT_NOR + "     STEP 1. STANDARD PRODUCT DEFAULTS    ");
                //aPrintData.Add(PosConst.PRT_HDR.PRT_SIS + "~DEFALT.{3");
                //aPrintData.Add(PosConst.PRT_HDR.PRT_NOR);
                //aPrintData.Add(PosConst.PRT_HDR.PRT_NOR + "     STEP 2. IBM PC AT and Compatibles    ");
                //aPrintData.Add(PosConst.PRT_HDR.PRT_SIS + "~PAP_AT.{3");
                //aPrintData.Add(PosConst.PRT_HDR.PRT_NOR);
                //aPrintData.Add(PosConst.PRT_HDR.PRT_NOR + "         STEP 3. ALL SYMBOLOGIES ON       ");
                //aPrintData.Add(PosConst.PRT_HDR.PRT_SIS + "~ALLENA1.{3");
                //aPrintData.Add(PosConst.PRT_HDR.PRT_NOR);
                //aPrintData.Add(PosConst.PRT_HDR.PRT_NOR + "==================USB TYPE================");
                //aPrintData.Add(PosConst.PRT_HDR.PRT_NOR + "     STEP 1. STANDARD PRODUCT DEFAULTS    ");
                //aPrintData.Add(PosConst.PRT_HDR.PRT_SIS + "~DEFALT.{3");
                //aPrintData.Add(PosConst.PRT_HDR.PRT_NOR);
                //aPrintData.Add(PosConst.PRT_HDR.PRT_NOR + "          STEP 2. USB PC KEYBOARD         ");
                //aPrintData.Add(PosConst.PRT_HDR.PRT_SIS + "~TERMID124.{3");
                //aPrintData.Add(PosConst.PRT_HDR.PRT_NOR);
                //aPrintData.Add(PosConst.PRT_HDR.PRT_NOR + "       STEP 3. ADD CR SUFFIX : VSUFCR     ");
                //aPrintData.Add(PosConst.PRT_HDR.PRT_SIS + "~VSUFCR.{3");
                //aPrintData.Add(PosConst.PRT_HDR.PRT_NOR);
                //aPrintData.Add(PosConst.PRT_HDR.PRT_NOR + "    STEP 4. ALL SYMBOLOGIES ON : ALLENA1   ");
                //aPrintData.Add(PosConst.PRT_HDR.PRT_SIS + "~ALLENA1.{3");
                //aPrintData.Add(PosConst.PRT_HDR.PRT_NOR);
                //aPrintData.Add(PosConst.PRT_HDR.PRT_NOR);
                //aPrintData.Add(PosConst.PRT_HDR.PRT_NOR);
                //aPrintData.Add(PosConst.PRT_HDR.PRT_NOR);
                //aPrintData.Add(PosConst.PRT_HDR.PRT_NOR);
                //aPrintData.Add(PosConst.PRT_HDR.PRT_CUT);

                //lbPrintData.Items.Clear();

                //lbPrintData.Items.Add(PosConst.PRT_HDR.PRT_NOR);
                //lbPrintData.Items.Add(PosConst.PRT_HDR.PRT_NOR);
                //lbPrintData.Items.Add(PosConst.PRT_HDR.PRT_NOR);
                ////lbPrintData.Items.Add(PosConst.PRT_HDR.PRT_NOR + "123456789012345678901234567890123456789012");
                //lbPrintData.Items.Add(PosConst.PRT_HDR.PRT_VER + "      << SCANNER INITIALIZE SETUP >>      ");
                //lbPrintData.Items.Add(PosConst.PRT_HDR.PRT_VER);
                //lbPrintData.Items.Add(PosConst.PRT_HDR.PRT_NOR + "==============PS/2 SCANNER TYPE===========");
                //lbPrintData.Items.Add(PosConst.PRT_HDR.PRT_NOR + "     STEP 1. STANDARD PRODUCT DEFAULTS    ");
                //lbPrintData.Items.Add(PosConst.PRT_HDR.PRT_SIS + "~DEFALT.{3");
                //lbPrintData.Items.Add(PosConst.PRT_HDR.PRT_NOR);
                //lbPrintData.Items.Add(PosConst.PRT_HDR.PRT_NOR + "      STEP 2. STANDARD PRODUCT PAPLTD     ");
                //lbPrintData.Items.Add(PosConst.PRT_HDR.PRT_SIS + "~PAPLTD.{3");
                //lbPrintData.Items.Add(PosConst.PRT_HDR.PRT_NOR);
                //lbPrintData.Items.Add(PosConst.PRT_HDR.PRT_NOR + "        STEP 3. ALL SYMBOLOGIES ON        ");
                //lbPrintData.Items.Add(PosConst.PRT_HDR.PRT_SIS + "~ALLENA1.{3");
                //lbPrintData.Items.Add(PosConst.PRT_HDR.PRT_NOR);
                //lbPrintData.Items.Add(PosConst.PRT_HDR.PRT_NOR + "=======PS/2 SCANNER AND KEYBOARD TYPE=====");
                //lbPrintData.Items.Add(PosConst.PRT_HDR.PRT_NOR + "     STEP 1. STANDARD PRODUCT DEFAULTS    ");
                //lbPrintData.Items.Add(PosConst.PRT_HDR.PRT_SIS + "~DEFALT.{3");
                //lbPrintData.Items.Add(PosConst.PRT_HDR.PRT_NOR);
                //lbPrintData.Items.Add(PosConst.PRT_HDR.PRT_NOR + "     STEP 2. IBM PC AT and Compatibles    ");
                //lbPrintData.Items.Add(PosConst.PRT_HDR.PRT_SIS + "~PAP_AT.{3");
                //lbPrintData.Items.Add(PosConst.PRT_HDR.PRT_NOR);
                //lbPrintData.Items.Add(PosConst.PRT_HDR.PRT_NOR + "         STEP 3. ALL SYMBOLOGIES ON       ");
                //lbPrintData.Items.Add(PosConst.PRT_HDR.PRT_SIS + "~ALLENA1.{3");
                //lbPrintData.Items.Add(PosConst.PRT_HDR.PRT_NOR);
                //lbPrintData.Items.Add(PosConst.PRT_HDR.PRT_NOR + "==================USB TYPE================");
                //lbPrintData.Items.Add(PosConst.PRT_HDR.PRT_NOR + "     STEP 1. STANDARD PRODUCT DEFAULTS    ");
                //lbPrintData.Items.Add(PosConst.PRT_HDR.PRT_SIS + "~DEFALT.{3");
                //lbPrintData.Items.Add(PosConst.PRT_HDR.PRT_NOR);
                //lbPrintData.Items.Add(PosConst.PRT_HDR.PRT_NOR + "          STEP 2. USB PC KEYBOARD         ");
                //lbPrintData.Items.Add(PosConst.PRT_HDR.PRT_SIS + "~TERMID124.{3");
                //lbPrintData.Items.Add(PosConst.PRT_HDR.PRT_NOR);
                //lbPrintData.Items.Add(PosConst.PRT_HDR.PRT_NOR + "       STEP 3. ADD CR SUFFIX : VSUFCR     ");
                //lbPrintData.Items.Add(PosConst.PRT_HDR.PRT_SIS + "~VSUFCR.{3");
                //lbPrintData.Items.Add(PosConst.PRT_HDR.PRT_NOR);
                //lbPrintData.Items.Add(PosConst.PRT_HDR.PRT_NOR + "    STEP 4. ALL SYMBOLOGIES ON : ALLENA1   ");
                //lbPrintData.Items.Add(PosConst.PRT_HDR.PRT_SIS + "~ALLENA1.{3");
                //lbPrintData.Items.Add(PosConst.PRT_HDR.PRT_NOR);
                //lbPrintData.Items.Add(PosConst.PRT_HDR.PRT_NOR);
                //lbPrintData.Items.Add(PosConst.PRT_HDR.PRT_NOR);
                //lbPrintData.Items.Add(PosConst.PRT_HDR.PRT_NOR);
                //lbPrintData.Items.Add(PosConst.PRT_HDR.PRT_NOR);
                //lbPrintData.Items.Add(PosConst.PRT_HDR.PRT_CUT);

            }
            catch (Exception ex)
            {
                WinManager.ExceptionMessage(System.Reflection.Assembly.GetExecutingAssembly().ManifestModule.Name,
                    System.Reflection.MethodBase.GetCurrentMethod().DeclaringType.Name + "." + System.Reflection.MethodBase.GetCurrentMethod().Name + "()", ex.Message);
            }
        }
        #endregion 폼 컨트롤 초기화

        #region Control Event
        private void btnPrint_Click(object sender, EventArgs e)
        {
            bool bRtn = false;

            try
            {
                //#20180529 프린터 쓰레드에서 체크 하기 때문에 제외 start
                //포트 연결이 안되는 경우 발생
                //bRtn = m_objPrinter.OpenDevice(PosConst.OPOS_DEVICE.POSPRINTER, PosConst.OPOS_LDN.POSPRINTER);
                //System.Threading.Thread.Sleep(100);

                //if (bRtn == true)
                //{
                //    bRtn = false;

                //    bool bCheckPrinter = true;

                //    //#20171212 프린터 상태 체크 여부 추가 start
                //    //0: 체크, 1: 체크안함
                //    //기존
                //    /*
                //    if (m_cPosStatus.Base.OlePosPrinterModel == PosConst.POS_DEVICE_LIST.POS_PRINTER._1_EPSON)
                //    {
                //        bCheckPrinter = m_objPrinter.CheckPrinter();
                //    }
                //    */
                //    //변경
                //    if (m_cPosStatus.Base.OlePosPrinterModel == PosConst.POS_DEVICE_LIST.POS_PRINTER._1_EPSON && 
                //        m_cPosStatus.Base.OlePosPrinterCheckYn == "0")
                //    {
                //        bCheckPrinter = m_objPrinter.CheckPrinter();
                //    }
                //    //#20171212 프린터 상태 체크 여부 추가 end

                //    //bRtn = m_objPrinter.CheckPrinter();
                //    bRtn = bCheckPrinter;
                //    System.Threading.Thread.Sleep(100);
                //    if (bRtn != true)
                //    {
                //        WinManager.ErrorMessage(MessageManager.GetErrorMessage(POS_MESSAGE.ERROR.MSG_0321));
                //        return;
                //    }
                //}
                //else
                //{
                //    WinManager.ErrorMessage(MessageManager.GetErrorMessage(POS_MESSAGE.ERROR.MSG_0321));
                //    return;
                //}
                //#20180529 프린터 쓰레드에서 체크 하기 때문에 제외 end
                
                if ((UI.CsmButton)sender == btnPrint01)    // 이름표 출력
                {
                    bRtn = false;

                    bRtn = NamePrint();
                    if (bRtn != true)
                    {
                        WinManager.ErrorMessage(MessageManager.GetErrorMessage(POS_MESSAGE.ERROR.MSG_0321));
                        return;
                    }
                }
                else if ((UI.CsmButton)sender == btnPrint02)    // 스캐너 초기화 출력
                {
                    bRtn = false;

                    bRtn = ScannerInit();
                    if (bRtn != true)
                    {
                        WinManager.ErrorMessage(MessageManager.GetErrorMessage(POS_MESSAGE.ERROR.MSG_0321));
                        return;
                    }
                }
                else if ((UI.CsmButton)sender == btnPrint03)    // 프린터 초기화 출력
                {
                    bRtn = false;

                    bRtn = PrintInit();
                    if (bRtn == true)
                    {
                        WinManager.ErrorMessage(MessageManager.GetErrorMessage(POS_MESSAGE.ERROR.MSG_0640));
                    }
                    else
                    {
                        WinManager.ErrorMessage(MessageManager.GetErrorMessage(POS_MESSAGE.ERROR.MSG_0321));
                        return;
                    }
                }
            }
            catch (Exception ex)
            {
                UserLog.WriteLogFile(UserCom.LOG_ERROR,
                                     System.Reflection.Assembly.GetExecutingAssembly().ManifestModule.Name,      // Project Name (프로젝트명)
                                     System.Reflection.MethodBase.GetCurrentMethod().DeclaringType.Name + "." +  // Class Name (Class Name (클래스명))
                                     System.Reflection.MethodBase.GetCurrentMethod().Name + "()",                // Function Name (Function Name (함수명))
                                     ex.Message);
            }
            finally
            {
                m_objPrinter.CloseDevice();
            }
        }

        private void btnTitle_Click(object sender, EventArgs e)
        {
            try
            {
                if ((UI.CsmButton)sender == btnTitle01)    // 이름표 출력
                {
                    pnl02.Visible = false;
                    pnl01.Visible = true;

                    TitleDisplay();

                    pnl01.Location = new Point(21, 103);
                }
                else if ((UI.CsmButton)sender == btnTitle02)    // 스캐너 초기화
                {
                    picScanner.Image = ImageManager.GetImage(BaseCom.NxImgPath, ImageManager.SCANNER_INIT_01);

                    btnScanner01.ForeColor = Color.FromArgb(255, 255, 255);
                    btnScanner01.BackColor = Color.FromArgb(22, 187, 238);

                    btnScanner02.ForeColor = Color.FromArgb(255, 255, 255);
                    btnScanner02.BackColor = Color.FromArgb(109, 110, 113);

                    btnScanner03.ForeColor = Color.FromArgb(255, 255, 255);
                    btnScanner03.BackColor = Color.FromArgb(109, 110, 113);

                    btnScanner04.ForeColor = Color.FromArgb(255, 255, 255);
                    btnScanner04.BackColor = Color.FromArgb(109, 110, 113);

                    pnl02.Location = new Point(22, 99);

                    pnl01.Visible = false;
                    pnl02.Visible = true;

                    TitleDisplay();
                }
            }
            catch (Exception ex)
            {

                WinManager.ExceptionMessage(System.Reflection.Assembly.GetExecutingAssembly().ManifestModule.Name,
                    System.Reflection.MethodBase.GetCurrentMethod().DeclaringType.Name + "." + System.Reflection.MethodBase.GetCurrentMethod().Name + "()", ex.Message);
            }
        }

        private void btnScanner_Click(object sender, EventArgs e)
        {
            if ((UI.CsmButton)sender == btnScanner01)    // 무선스캐너 PC용
            {
                picScanner.Image = ImageManager.GetImage(BaseCom.NxImgPath, ImageManager.SCANNER_INIT_01);

                btnScanner01.ForeColor = Color.FromArgb(255, 255, 255);
                btnScanner01.BackColor = Color.FromArgb(22, 187, 238);

                btnScanner02.ForeColor = Color.FromArgb(255, 255, 255);
                btnScanner02.BackColor = Color.FromArgb(109, 110, 113);

                btnScanner03.ForeColor = Color.FromArgb(255, 255, 255);
                btnScanner03.BackColor = Color.FromArgb(109, 110, 113);

                btnScanner04.ForeColor = Color.FromArgb(255, 255, 255);
                btnScanner04.BackColor = Color.FromArgb(109, 110, 113);
            }
            else if ((UI.CsmButton)sender == btnScanner02)    // 무선스캐너 모바일용
            {
                picScanner.Image = ImageManager.GetImage(BaseCom.NxImgPath, ImageManager.SCANNER_INIT_02);

                btnScanner02.ForeColor = Color.FromArgb(255, 255, 255);
                btnScanner02.BackColor = Color.FromArgb(22, 187, 238);

                btnScanner01.ForeColor = Color.FromArgb(255, 255, 255);
                btnScanner01.BackColor = Color.FromArgb(109, 110, 113);

                btnScanner03.ForeColor = Color.FromArgb(255, 255, 255);
                btnScanner03.BackColor = Color.FromArgb(109, 110, 113);

                btnScanner04.ForeColor = Color.FromArgb(255, 255, 255);
                btnScanner04.BackColor = Color.FromArgb(109, 110, 113);
            }
            else if ((UI.CsmButton)sender == btnScanner03)    // 무선스캐너 인식율향상
            {
                picScanner.Image = ImageManager.GetImage(BaseCom.NxImgPath, ImageManager.SCANNER_INIT_03);

                btnScanner03.ForeColor = Color.FromArgb(255, 255, 255);
                btnScanner03.BackColor = Color.FromArgb(22, 187, 238);

                btnScanner01.ForeColor = Color.FromArgb(255, 255, 255);
                btnScanner01.BackColor = Color.FromArgb(109, 110, 113);

                btnScanner02.ForeColor = Color.FromArgb(255, 255, 255);
                btnScanner02.BackColor = Color.FromArgb(109, 110, 113);

                btnScanner04.ForeColor = Color.FromArgb(255, 255, 255);
                btnScanner04.BackColor = Color.FromArgb(109, 110, 113);
            }
            else if ((UI.CsmButton)sender == btnScanner04)    // iOS키패드
            {
                picScanner.Image = ImageManager.GetImage(BaseCom.NxImgPath, ImageManager.SCANNER_INIT_04);

                btnScanner04.ForeColor = Color.FromArgb(255, 255, 255);
                btnScanner04.BackColor = Color.FromArgb(22, 187, 238);

                btnScanner01.ForeColor = Color.FromArgb(255, 255, 255);
                btnScanner01.BackColor = Color.FromArgb(109, 110, 113);

                btnScanner02.ForeColor = Color.FromArgb(255, 255, 255);
                btnScanner02.BackColor = Color.FromArgb(109, 110, 113);

                btnScanner03.ForeColor = Color.FromArgb(255, 255, 255);
                btnScanner03.BackColor = Color.FromArgb(109, 110, 113);
            }
        }

        private void btnExit_Click(object sender, EventArgs e)
        {
            this.Close();
        }
        #endregion Control Event

        #region User Method
        /// <summary>
        /// 타이틀 색상 전환 표시
        /// </summary>
        private void TitleDisplay()
        {
            try
            {
                if (pnl01.Visible == true)
                {
                    //글자색변경
                    //배경색변경
                    btnTitle01.ForeColor = m_clrSelectFont;
                    btnTitle01.BackColor = m_clrSelectback;

                    btnTitle02.ForeColor = m_clrNonSelectFont;
                    btnTitle02.BackColor = m_clrNonSelectback;

                }
                else if (pnl02.Visible == true)
                {
                    btnTitle02.ForeColor = m_clrSelectFont;
                    btnTitle02.BackColor = m_clrSelectback;

                    btnTitle01.ForeColor = m_clrNonSelectFont;
                    btnTitle01.BackColor = m_clrNonSelectback;
                }
            }
            catch (Exception ex)
            {

                WinManager.ExceptionMessage(System.Reflection.Assembly.GetExecutingAssembly().ManifestModule.Name,
                    System.Reflection.MethodBase.GetCurrentMethod().DeclaringType.Name + "." + System.Reflection.MethodBase.GetCurrentMethod().Name + "()", ex.Message);
            }

        }

        /// <summary>
        /// 이름표 출력
        /// </summary>
        /// <returns></returns>
        private bool NamePrint()
        {
            bool bRet = false;

            try
            {
                ArrayList aPrintData = new ArrayList();
                string sNameNm = string.Empty;
                sNameNm = CmUtil.MidH(txtName.Text.Trim(), 0, 20).Trim();

                if (CmUtil.LenH(sNameNm) <= 21) sNameNm = CmUtil.LPadH("", 10 - (CmUtil.LenH(sNameNm) / 2)) + sNameNm;

                // 상단 이미지 출력
                if (PosMstManager.GetPosOption(POS_OPTION.OPT409) != "0")
                {
                    aPrintData.Add(PosConst.PRT_HDR.PRT_TBM);
                }
                else
                {
                    aPrintData.Add(PosConst.PRT_HDR.PRT_NOR);
                }

                aPrintData.Add(PosConst.PRT_HDR.PRT_BIG + sNameNm);

                // 하단 이미지 출력
                if (PosMstManager.GetPosOption(POS_OPTION.OPT410) != "0")
                {
                    aPrintData.Add(PosConst.PRT_HDR.PRT_NOR);
                    aPrintData.Add(PosConst.PRT_HDR.PRT_BBM);
                }
                else
                {
                    aPrintData.Add(PosConst.PRT_HDR.PRT_NOR);
                }

                aPrintData.Add(PosConst.PRT_HDR.PRT_CUT);

                string[] arPrintData = (string[])aPrintData.ToArray(typeof(string));

                bRet = m_objPrinter.ReceiptPrinter(arPrintData);

                //if (txtName.Text != null && txtName.Text != "")
                //{
                //    string[] sPrintData = new string[0];
                //    string sNameNm = string.Empty;
                //    sNameNm = CmUtil.MidH(txtName.Text.Trim(), 0, 20);

                //    if (CmUtil.LenH(sNameNm) <= 21) sNameNm = CmUtil.LPadH("", 10 - (CmUtil.LenH(sNameNm) / 2)) + sNameNm;

                //    sPrintData = new string[] { PosConst.PRT_HDR.PRT_TBM,
                //                                PosConst.PRT_HDR.PRT_BIG + sNameNm, 
                //                                PosConst.PRT_HDR.PRT_NOR,
                //                                PosConst.PRT_HDR.PRT_BBM,
                //                                PosConst.PRT_HDR.PRT_CUT };
                //    bRet = m_objPrinter.ReceiptPrinter(sPrintData);
                //}

                return bRet;
            }
            catch (Exception ex)
            {
                UserLog.WriteLogFile(UserCom.LOG_ERROR,
                                     System.Reflection.Assembly.GetExecutingAssembly().ManifestModule.Name,      // Project Name (프로젝트명)
                                     System.Reflection.MethodBase.GetCurrentMethod().DeclaringType.Name + "." +  // Class Name (Class Name (클래스명))
                                     System.Reflection.MethodBase.GetCurrentMethod().Name + "()",                // Function Name (Function Name (함수명))
                                     ex.Message);
            }

            return bRet;
        }

        /// <summary>
        /// 스캐너 초기화
        /// </summary>
        /// <returns></returns>
        private bool ScannerInit()
        {
            bool bRet = false;

            try
            {
                ArrayList aPrintData = new ArrayList();

                aPrintData.Add(PosConst.PRT_HDR.PRT_NOR);
                aPrintData.Add(PosConst.PRT_HDR.PRT_NOR);
                aPrintData.Add(PosConst.PRT_HDR.PRT_NOR);
                //lbPrintData.Items.Add(PosConst.PRT_HDR.PRT_NOR + "123456789012345678901234567890123456789012");
                aPrintData.Add(PosConst.PRT_HDR.PRT_VER + "      << SCANNER INITIALIZE SETUP >>      ");
                aPrintData.Add(PosConst.PRT_HDR.PRT_VER);
                aPrintData.Add(PosConst.PRT_HDR.PRT_NOR + "==============PS/2 SCANNER TYPE===========");
                aPrintData.Add(PosConst.PRT_HDR.PRT_NOR + "     STEP 1. STANDARD PRODUCT DEFAULTS    ");
                aPrintData.Add(PosConst.PRT_HDR.PRT_SIS + "~DEFALT.{3");
                aPrintData.Add(PosConst.PRT_HDR.PRT_NOR);
                aPrintData.Add(PosConst.PRT_HDR.PRT_NOR + "      STEP 2. STANDARD PRODUCT PAPLTD     ");
                aPrintData.Add(PosConst.PRT_HDR.PRT_SIS + "~PAPLTD.{3");
                aPrintData.Add(PosConst.PRT_HDR.PRT_NOR);
                aPrintData.Add(PosConst.PRT_HDR.PRT_NOR + "        STEP 3. ALL SYMBOLOGIES ON        ");
                aPrintData.Add(PosConst.PRT_HDR.PRT_SIS + "~ALLENA1.{3");
                aPrintData.Add(PosConst.PRT_HDR.PRT_NOR);
                aPrintData.Add(PosConst.PRT_HDR.PRT_NOR + "=======PS/2 SCANNER AND KEYBOARD TYPE=====");
                aPrintData.Add(PosConst.PRT_HDR.PRT_NOR + "     STEP 1. STANDARD PRODUCT DEFAULTS    ");
                aPrintData.Add(PosConst.PRT_HDR.PRT_SIS + "~DEFALT.{3");
                aPrintData.Add(PosConst.PRT_HDR.PRT_NOR);
                aPrintData.Add(PosConst.PRT_HDR.PRT_NOR + "     STEP 2. IBM PC AT and Compatibles    ");
                aPrintData.Add(PosConst.PRT_HDR.PRT_SIS + "~PAP_AT.{3");
                aPrintData.Add(PosConst.PRT_HDR.PRT_NOR);
                aPrintData.Add(PosConst.PRT_HDR.PRT_NOR + "         STEP 3. ALL SYMBOLOGIES ON       ");
                aPrintData.Add(PosConst.PRT_HDR.PRT_SIS + "~ALLENA1.{3");
                aPrintData.Add(PosConst.PRT_HDR.PRT_NOR);
                aPrintData.Add(PosConst.PRT_HDR.PRT_NOR + "==================USB TYPE================");
                aPrintData.Add(PosConst.PRT_HDR.PRT_NOR + "     STEP 1. STANDARD PRODUCT DEFAULTS    ");
                aPrintData.Add(PosConst.PRT_HDR.PRT_SIS + "~DEFALT.{3");
                aPrintData.Add(PosConst.PRT_HDR.PRT_NOR);
                aPrintData.Add(PosConst.PRT_HDR.PRT_NOR + "          STEP 2. USB PC KEYBOARD         ");
                aPrintData.Add(PosConst.PRT_HDR.PRT_SIS + "~TERMID124.{3");
                aPrintData.Add(PosConst.PRT_HDR.PRT_NOR);
                aPrintData.Add(PosConst.PRT_HDR.PRT_NOR + "       STEP 3. ADD CR SUFFIX : VSUFCR     ");
                aPrintData.Add(PosConst.PRT_HDR.PRT_SIS + "~VSUFCR.{3");
                aPrintData.Add(PosConst.PRT_HDR.PRT_NOR);
                aPrintData.Add(PosConst.PRT_HDR.PRT_NOR + "    STEP 4. ALL SYMBOLOGIES ON : ALLENA1   ");
                aPrintData.Add(PosConst.PRT_HDR.PRT_SIS + "~ALLENA1.{3");
                aPrintData.Add(PosConst.PRT_HDR.PRT_NOR);
                aPrintData.Add(PosConst.PRT_HDR.PRT_NOR);
                aPrintData.Add(PosConst.PRT_HDR.PRT_NOR);
                aPrintData.Add(PosConst.PRT_HDR.PRT_NOR);
                aPrintData.Add(PosConst.PRT_HDR.PRT_NOR);
                aPrintData.Add(PosConst.PRT_HDR.PRT_CUT);


                string[] arPrintData = (string[])aPrintData.ToArray(typeof(string));

                bRet = m_objPrinter.ReceiptPrinter(arPrintData);

                return bRet;
            }
            catch (Exception ex)
            {
                UserLog.WriteLogFile(UserCom.LOG_ERROR,
                                     System.Reflection.Assembly.GetExecutingAssembly().ManifestModule.Name,      // Project Name (프로젝트명)
                                     System.Reflection.MethodBase.GetCurrentMethod().DeclaringType.Name + "." +  // Class Name (Class Name (클래스명))
                                     System.Reflection.MethodBase.GetCurrentMethod().Name + "()",                // Function Name (Function Name (함수명))
                                     ex.Message);
            }

            return bRet;
        }

        /// <summary>
        /// 프린터 초기화
        /// </summary>
        /// <returns></returns>
        private bool PrintInit()
        {
            bool bRet = false;

            try
            {
                m_objPrinter.ResetDevice();

                // 프린터 초기화는 리턴값이 없다. 그래서 그냥 실행되면 true 값을 넘겨준다.
                bRet = true;

                return bRet;
            }
            catch (Exception ex)
            {
                UserLog.WriteLogFile(UserCom.LOG_ERROR,
                                     System.Reflection.Assembly.GetExecutingAssembly().ManifestModule.Name,      // Project Name (프로젝트명)
                                     System.Reflection.MethodBase.GetCurrentMethod().DeclaringType.Name + "." +  // Class Name (Class Name (클래스명))
                                     System.Reflection.MethodBase.GetCurrentMethod().Name + "()",                // Function Name (Function Name (함수명))
                                     ex.Message);
                return bRet;
            }
        }
        #endregion User Method
    }
}
