//ライセンス情報はAgeOnフォルダのLISENCEフォルダを参照してください
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Drawing;
using nispi.controlclass;

namespace nispi.OptionControl
{
    class OutWardEventForm
    {
        private OutWardForm outWardOption;
        public bool changeFlag = false;


        public OutWardEventForm(OutWardForm outWardOption)
        {
            this.outWardOption = outWardOption;
            SetEvent();
        }
        public void SetEvent()
        {
            this.outWardOption.formForeColorButtonParts.Click += new EventHandler(formForeColorButtonParts_Click);
            this.outWardOption.formBackColorButtonParts.Click += new EventHandler(formBackColorButtonParts_Click);
            this.outWardOption.formResetButtonParts.Click += new EventHandler(formResetButtonParts_Click);

            this.outWardOption.formForeColorButtonParts.Click += new EventHandler(ChangeFlag);
            this.outWardOption.formBackColorButtonParts.Click += new EventHandler(ChangeFlag);
            this.outWardOption.formResetButtonParts.Click += new EventHandler(ChangeFlag);
        }

        public void ResetEvent()
        {
            this.outWardOption.formForeColorButtonParts.Click -= new EventHandler(formForeColorButtonParts_Click);
            this.outWardOption.formBackColorButtonParts.Click -= new EventHandler(formBackColorButtonParts_Click);
            this.outWardOption.formResetButtonParts.Click -= new EventHandler(formResetButtonParts_Click);

            this.outWardOption.formForeColorButtonParts.Click -= new EventHandler(ChangeFlag);
            this.outWardOption.formBackColorButtonParts.Click -= new EventHandler(ChangeFlag);
            this.outWardOption.formResetButtonParts.Click -= new EventHandler(ChangeFlag);
        }

        private void ChangeFlag(object sender, EventArgs e)
        {
            this.changeFlag = true;
        }

        //フォントのウィンドウを開く
        public void formForeColorButtonParts_Click(object sender, EventArgs e)
        {
            ColorSet colorSet = new ColorSet();
            if (true == FormGUI.GetColor(colorSet))
            {
                //ラベルを書き換える。実データは書き換えない
                this.outWardOption.formSampleLabelParts.ForeColor =System.Drawing.Color.FromArgb(
                    colorSet.red,
                    colorSet.green,
                    colorSet.blue);
            }
        }

        //背景色を得る
        public void formBackColorButtonParts_Click(object sender, EventArgs e)
        {
            ColorSet colorSet = new ColorSet();
            if (true == FormGUI.GetColor(colorSet))
            {
                //ラベルを書き換える
                this.outWardOption.formSampleLabelParts.BackColor = System.Drawing.Color.FromArgb(
                    colorSet.red,
                    colorSet.green,
                    colorSet.blue);
            }
        }
        //リセットをする
        public void formResetButtonParts_Click(object sender, EventArgs e)
        {
            this.outWardOption.formSampleLabelParts.ForeColor = SystemColors.WindowText;
            this.outWardOption.formSampleLabelParts.BackColor = SystemColors.Control;
        }

        public void SetAllOption()
        {
            if (changeFlag == true)
            {
                changeFlag = false;
                {
                    //
                    //this.outWardOption.FormFontName = this.outWardOption.formSampleLabelParts.GetFontName();
                    //this.outWardOption.FormFontSize = this.outWardOption.formSampleLabelParts.GetFontSize();

                    this.outWardOption.FormForeColorRed = this.outWardOption.formSampleLabelParts.ForeColor.R;
                    this.outWardOption.FormForeColorGreen = this.outWardOption.formSampleLabelParts.ForeColor.G;
                    this.outWardOption.FormForeColorBlue = this.outWardOption.formSampleLabelParts.ForeColor.B;

                    this.outWardOption.FormBackColorRed = this.outWardOption.formSampleLabelParts.BackColor.R;
                    this.outWardOption.FormBackColorGreen = this.outWardOption.formSampleLabelParts.BackColor.G;
                    this.outWardOption.FormBackColorBlue = this.outWardOption.formSampleLabelParts.BackColor.B;

                    this.outWardOption.SaveFormToFile();

                    //外観を変える
                    /*FormPartsManager.ChangeOutWard();
                    //タブの選択されていない部分の色にも関わるので
                    TabControlPartsManager.ChangeOutWard();

                    WithInCBoxPartsManager.ChangeOutWard();
                    //TextBoxPartsManager.ChangeOutWard();
                    TabPageExPartsManager.ChangeOutWard();
                    StatusStripPartsManager.ChangeOutWard();
                    LabelPartsManager.ChangeOutWard();
                    KakoLogCBoxPartsManager.ChangeOutWard();
                    ButtonPartsManager.ChangeOutWard();

                    ToolStripPartsManager.ChangeOutWard();
                    MenuStripPartsManager.ChangeOutWard();
                    ToolStripMenuItemPartsManager.ChangeOutWard();*/
                }
            }
        }
    }
}
