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

using SmartX;
using INT99DC_ImageDll;
using INT99DC_7C.Part11_UserManager;
using INT99DC_7C.DialogForms;

namespace INT99DC_7C.Forms
{
    public partial class FormOptionSetting : Form
    {
        #region Field
        private FormMain m_ParentForm;
        #endregion

        #region Constructor
        public FormOptionSetting(FormMain parent)
        {
            InitializeComponent();

            this.ParentForm = parent;
        } 
        #endregion

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

        #region Method
        private void InitializeDesign()
        {
            ImageDll images = new ImageDll();

            if (this.ParentForm.SystemConfig.Language == DataStore.LanguageID.Korean)
            {

            }
            else if (this.ParentForm.SystemConfig.Language == DataStore.LanguageID.English)
            {
                this.labelTitle.Text = "Option Setting";

                this.labelBuadrateWarning.Text = "※ After changing setting, Turn the power off and back on";
                this.labelBuadrateWarning2.Text = "※ Do not change the value except engineer";

                this.buttonSave.DisableImage = new Bitmap(images.GetImage(ImageDll.ButtonImages.engSaveDisable));
                this.buttonSave.DownImage = new Bitmap(images.GetImage(ImageDll.ButtonImages.engSaveDown));
                this.buttonSave.UpImage = new Bitmap(images.GetImage(ImageDll.ButtonImages.engSaveUp));

                this.buttonBack.DisableImage = new Bitmap(images.GetImage(ImageDll.ButtonImages.engBackDisable));
                this.buttonBack.DownImage = new Bitmap(images.GetImage(ImageDll.ButtonImages.engBackDown));
                this.buttonBack.UpImage = new Bitmap(images.GetImage(ImageDll.ButtonImages.engBackUp));
            }
            else if (this.ParentForm.SystemConfig.Language == DataStore.LanguageID.Chinese)
            {
                this.labelTitle.Text = "Option Setting";

                this.labelBuadrateWarning.Text = "※ After changing setting, Turn the power off and back on";
                this.labelBuadrateWarning2.Text = "※ Do not change the value except engineer";

                this.buttonSave.DisableImage = new Bitmap(images.GetImage(ImageDll.ButtonImages.chnSaveDisable));
                this.buttonSave.DownImage = new Bitmap(images.GetImage(ImageDll.ButtonImages.chnSaveDown));
                this.buttonSave.UpImage = new Bitmap(images.GetImage(ImageDll.ButtonImages.chnSaveUp));

                this.buttonBack.DisableImage = new Bitmap(images.GetImage(ImageDll.ButtonImages.chnBackDisable));
                this.buttonBack.DownImage = new Bitmap(images.GetImage(ImageDll.ButtonImages.chnBackDown));
                this.buttonBack.UpImage = new Bitmap(images.GetImage(ImageDll.ButtonImages.chnBackUp));
            }
            else if (this.ParentForm.SystemConfig.Language == DataStore.LanguageID.Czech)
            {
                this.labelTitle.Text = "Option Setting";

                this.labelBuadrateWarning.Text = "※ After changing setting, Turn the power off and back on";
                this.labelBuadrateWarning2.Text = "※ Do not change the value except engineer";

                this.buttonSave.DisableImage = new Bitmap(images.GetImage(ImageDll.ButtonImages.czeSaveDisable));
                this.buttonSave.DownImage = new Bitmap(images.GetImage(ImageDll.ButtonImages.czeSaveDown));
                this.buttonSave.UpImage = new Bitmap(images.GetImage(ImageDll.ButtonImages.czeSaveUp));

                this.buttonBack.DisableImage = new Bitmap(images.GetImage(ImageDll.ButtonImages.czeBackDisable));
                this.buttonBack.DownImage = new Bitmap(images.GetImage(ImageDll.ButtonImages.czeBackDown));
                this.buttonBack.UpImage = new Bitmap(images.GetImage(ImageDll.ButtonImages.czeBackUp));
            }
            else if (this.ParentForm.SystemConfig.Language == DataStore.LanguageID.German)
            {
                this.labelTitle.Text = "Option Setting";

                this.labelBuadrateWarning.Text = "※ After changing setting, Turn the power off and back on";
                this.labelBuadrateWarning2.Text = "※ Do not change the value except engineer";

                this.buttonSave.DisableImage = new Bitmap(images.GetImage(ImageDll.ButtonImages.gerSaveDisable));
                this.buttonSave.DownImage = new Bitmap(images.GetImage(ImageDll.ButtonImages.gerSaveDown));
                this.buttonSave.UpImage = new Bitmap(images.GetImage(ImageDll.ButtonImages.gerSaveUp));

                this.buttonBack.DisableImage = new Bitmap(images.GetImage(ImageDll.ButtonImages.gerBackDisable));
                this.buttonBack.DownImage = new Bitmap(images.GetImage(ImageDll.ButtonImages.gerBackDown));
                this.buttonBack.UpImage = new Bitmap(images.GetImage(ImageDll.ButtonImages.gerBackUp));
            }
            else
            {

            }
        }
        private void DefaultSetting()
        {

        }
        private void InitializeControl()
        { 
            //// 피드백 보드 사용 유무
            //if (this.ParentForm.SystemConfig.IsOptFeedbackBoardUse == true)
            //    this.buttonFeedbackUse.ButtonDown();
            //else
            //    this.buttonFeedbackUse.ButtonUp();

            // 데이터 통계 기능 사용 유무
            if (this.ParentForm.SystemConfig.IsOptDataStatistics == true)
                this.buttonDataStatistics.ButtonDown();
            else
                this.buttonDataStatistics.ButtonUp();

            // Part11 기능 사용 유무
            if (this.ParentForm.SystemConfig.IsPart11 == true)
                this.buttonPart11.ButtonDown();
            else
                this.buttonPart11.ButtonUp();

            this.buttonSave.Visible = false;
        }

        public void DisplayRefresh()
        {
            this.InitializeControl();
        }
        #endregion

        #region Override Member
        protected override void OnLoad(EventArgs e)
        {
            base.OnLoad(e);

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

        #region Event Handler
        private void buttonBack_Click(object sender, EventArgs e)
        {
            this.ParentForm.ChildFormMenu.DisplayRefresh();
            ((FormMain)(Owner)).smartForm.Show((int)DataStore.FormStore.FormMenu);
        }
        private void buttonSave_Click(object sender, EventArgs e)
        {
            //// 피드백 보드 사용 유무
            //if (this.buttonFeedbackUse.ButtonStatus == SmartButton.BUTSTATUS.DOWN)
            //    this.ParentForm.SystemConfig.IsOptFeedbackBoardUse = true;
            //else
            //    this.ParentForm.SystemConfig.IsOptFeedbackBoardUse = false;

            // 데이터 통계 기능 사용 유무
            if (this.buttonDataStatistics.ButtonStatus == SmartButton.BUTSTATUS.DOWN)
                this.ParentForm.SystemConfig.IsOptDataStatistics = true;
            else
                this.ParentForm.SystemConfig.IsOptDataStatistics = false;


            // Part11 기능 사용 유무
            if (this.buttonPart11.ButtonStatus == SmartButton.BUTSTATUS.DOWN)
            {
                this.ParentForm.SystemConfig.IsPart11 = true;
                this.ParentForm.SystemConfig.IsLogin = true;
                this.ParentForm.SystemConfig.IsDataBackup = true;
            }
            else
            {
                this.ParentForm.SystemConfig.IsPart11 = false;
                this.ParentForm.SystemConfig.IsLogin = false;
                this.ParentForm.SystemConfig.IsDataBackup = false;

                // Delete user list
                UserManager.UserManager_UserAllDel();
            }

            this.ParentForm.SaveSystemConfigurationFile(this.ParentForm.SystemConfig);
            this.smartGroupBox1.Enabled = false;
            this.buttonBack.Visible = false;
        }
        private void buttonDataStatistics_Click(object sender, EventArgs e)
        {
            if (this.buttonSave.Visible == false)
                this.buttonSave.Visible = true;
        }
        private void buttonPart11_Click(object sender, EventArgs e)
        {
            if (this.buttonPart11.ButtonStatus == SmartButton.BUTSTATUS.DOWN)
            {
                this.buttonPart11.ButtonDown();
                this.buttonDataStatistics.ButtonDown();
            }
            else
            {
                this.buttonPart11.ButtonUp();
                this.buttonDataStatistics.ButtonUp();
            }

            if (this.buttonSave.Visible == false)
                this.buttonSave.Visible = true;
        }
        #endregion
    }
}