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

using ITC81DB.Forms;
using ITC81DB_ImageDll;

namespace ITC81DB.Controls
{
    public partial class ControlCenterInforAS : UserControl
    {
        #region Field
        private FormMenu m_ParentForm;
        private int m_FirstLineNumber;
        #endregion

        #region Constructor
        public ControlCenterInforAS(FormMenu parent)
        {
            InitializeComponent();

            this.ParentForm = parent;

            this.InitializeDesign();
            this.DefaultSetting();
        }
        #endregion

        #region Property
        public FormMenu ParentForm
        {
            get { return this.m_ParentForm; }
            private set { this.m_ParentForm = value; }
        }

        public int FirstLineNumber
        {
            get { return this.m_FirstLineNumber; }
            set { this.m_FirstLineNumber = value; }
        }
        #endregion

        #region Method
        public void InitializeDesign()
        {
            Class1 images = new Class1();

            if (this.ParentForm.ParentForm.SystemConfig1.Language == DataStore.LanguageID.English)
            {
            }
            else if (this.ParentForm.ParentForm.SystemConfig1.Language == DataStore.LanguageID.Chinese)
            {
            }
            else if (this.ParentForm.ParentForm.SystemConfig1.Language == DataStore.LanguageID.Czech)
            {
            }
            else if (this.ParentForm.ParentForm.SystemConfig1.Language == DataStore.LanguageID.Russian)
            {
            }
            else if (this.ParentForm.ParentForm.SystemConfig1.Language == DataStore.LanguageID.German)
            {
            }
            else if (this.ParentForm.ParentForm.SystemConfig1.Language == DataStore.LanguageID.Spanish)
            {
            }
            else
            {
            }
        }

        public void DefaultSetting()
        {
            FileInfo fileInfo = new FileInfo(this.ParentForm.ParentForm.PathSDCardSystemFile1Folder + "ASinfo.txt");

            if (fileInfo.Exists == false)
            {
                this.ParentForm.ParentForm.smartFileIO.FilePathName = this.ParentForm.ParentForm.PathSDCardSystemFile1Folder + "ASinfo.txt";
                this.ParentForm.ParentForm.smartFileIO.Open(this.ParentForm.ParentForm.BufferSmartUart);

                this.ParentForm.ParentForm.smartFileIO.WriteString("(주)인테크코리아", 0);
                this.ParentForm.ParentForm.smartFileIO.WriteString("Tel.82-32-681-0714 / Fax.82-32-681-0713", 1);
                this.ParentForm.ParentForm.smartFileIO.WriteString("인천광역시 서구 장고개로 217번길 10", 2);
                this.ParentForm.ParentForm.smartFileIO.WriteString("", 3);
                this.ParentForm.ParentForm.smartFileIO.WriteString("sales@intechkorea.com", 4);
                this.ParentForm.ParentForm.smartFileIO.WriteString("http://www.intechkorea.com", 5);

                this.ParentForm.ParentForm.smartFileIO.WriteString("INTECHKOREA CO,.LTD", 6);
                this.ParentForm.ParentForm.smartFileIO.WriteString("Tel.82-32-681-0714 / Fax.82-32-681-0713", 7);
                this.ParentForm.ParentForm.smartFileIO.WriteString("10, Janggogae-ro 217beon-gil, Seo-gu,", 8);
                this.ParentForm.ParentForm.smartFileIO.WriteString("Incheon, Republic of Korea", 9);
                this.ParentForm.ParentForm.smartFileIO.WriteString("sales@intechkorea.com", 10);
                this.ParentForm.ParentForm.smartFileIO.WriteString("http://www.intechkorea.com", 11);

                this.ParentForm.ParentForm.smartFileIO.Close();
            }

            this.ParentForm.ParentForm.smartFileIO.FilePathName = this.ParentForm.ParentForm.PathSDCardSystemFile1Folder + "ASinfo.txt";
            this.ParentForm.ParentForm.smartFileIO.Open(this.ParentForm.ParentForm.BufferSmartUart);

            this.DisplayAsInfo();

            //주소가 한줄일 경우 Email,Website라벨 위치 조정
            if (this.labelAddress2.Text == "")
            {
                this.labelAddress2.Visible = false;
                this.labelEmail.Location = new Point(53, 228);
                this.labelWebsite.Location = new Point(53, 267);
            }
            else
            {
                this.labelAddress2.Visible = true;
                this.labelEmail.Location = new Point(53, 267);
                this.labelWebsite.Location = new Point(53, 306);
            }

            this.ParentForm.ParentForm.smartFileIO.Close();
        }

        private void DisplayAsInfo()
        {
            string readText = "";
            bool readCheck = false;

            if (this.ParentForm.ParentForm.SystemConfig1.Language == DataStore.LanguageID.Korean)
                this.FirstLineNumber = 0;
            else if (this.ParentForm.ParentForm.SystemConfig1.Language == DataStore.LanguageID.English)
                this.FirstLineNumber = 6;
            else if (this.ParentForm.ParentForm.SystemConfig1.Language == DataStore.LanguageID.Chinese)
                this.FirstLineNumber = 12;
            else if (this.ParentForm.ParentForm.SystemConfig1.Language == DataStore.LanguageID.Czech)
                this.FirstLineNumber = 18;
            else
                this.FirstLineNumber = 6;

            readText = this.ParentForm.ParentForm.smartFileIO.ReadString(this.FirstLineNumber + 0);
            if (readText == "")
                this.FirstLineNumber = 6;

            readText = this.ParentForm.ParentForm.smartFileIO.ReadString(6);
            if (readText == "")
                this.FirstLineNumber = 0;

            #region 회사별 AS정보 입력
            readText = this.ParentForm.ParentForm.smartFileIO.ReadString(this.FirstLineNumber + 0, ref readCheck);
            if (readCheck == true)
            {
                if (this.labelCompany.Text != readText.Trim())
                    this.labelCompany.Text = readText.Trim();
            }
            else
                this.labelCompany.Text = "";

            readText = this.ParentForm.ParentForm.smartFileIO.ReadString(this.FirstLineNumber + 1, ref readCheck);
            if (readCheck == true)
            {
                if (this.labelTelNumber.Text != readText)
                    this.labelTelNumber.Text = readText;
            }
            else
                this.labelTelNumber.Text = "";

            readText = this.ParentForm.ParentForm.smartFileIO.ReadString(this.FirstLineNumber + 2, ref readCheck);
            if (readCheck == true)
            {
                if (this.labelAddress1.Text != readText)
                    this.labelAddress1.Text = readText;
            }
            else
                this.labelAddress1.Text = "";


            readText = this.ParentForm.ParentForm.smartFileIO.ReadString(this.FirstLineNumber + 3, ref readCheck);
            if (readCheck == true)
            {
                if (this.labelAddress2.Text != readText)
                    this.labelAddress2.Text = readText;
            }
            else
                this.labelAddress2.Text = "";

            readText = this.ParentForm.ParentForm.smartFileIO.ReadString(this.FirstLineNumber + 4, ref readCheck);
            if (readCheck == true)
            {
                if (this.labelEmail.Text != readText)
                    this.labelEmail.Text = readText;
            }
            else
                this.labelEmail.Text = "";

            readText = this.ParentForm.ParentForm.smartFileIO.ReadString(this.FirstLineNumber + 5, ref readCheck);
            if (readCheck == true)
            {
                if (this.labelWebsite.Text != readText)
                    this.labelWebsite.Text = readText;
            }
            else
                this.labelWebsite.Text = "";
            #endregion
        }

        public void DisplayRefresh(SystemStatus status)
        {
            this.ParentForm.ParentForm.CurrentSystemStatus.CurrentDisplay = DataStore.DisplayStore.InforAS;
            this.ParentForm.ParentForm.SetDisplayMode(DataStore.DisplayMode.Menu);
            this.ParentForm.DisplayTitleRoot(this.ParentForm.ParentForm.CurrentSystemStatus);
        }
        #endregion

        #region Event Handler

        #endregion
    }
}
