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

namespace nispi.OptionControl
{
    class LogInOptionEvent
    {
        private LogInOption logInOption;
        private bool changeFlag = false;

        public LogInOptionEvent(LogInOption logInOption)
        {
            this.logInOption = logInOption;
            SetEvent();
        }
        public void SetEvent()
        {
            logInOption.maruAutoLoginCBoxParts.Click += new EventHandler(ChangeFlag);
            logInOption.maruIdTBoxParts.TextChanged += new EventHandler(ChangeFlag);
            logInOption.maruPassTBoxParts.TextChanged += new EventHandler(ChangeFlag);

            logInOption.beAutoLoginCBoxParts.Click += new EventHandler(ChangeFlag);
            logInOption.beIdTBoxParts.TextChanged += new EventHandler(ChangeFlag);
            logInOption.bePassTBoxParts.TextChanged += new EventHandler(ChangeFlag);

            logInOption.scBeAutoLoginCBoxParts.Click += new EventHandler(ChangeFlag);
            logInOption.scBeIdTBoxParts.TextChanged += new EventHandler(ChangeFlag);
            logInOption.scBePassTBoxParts.TextChanged += new EventHandler(ChangeFlag);
        }
        public void ResetEvent()
        {
            logInOption.maruAutoLoginCBoxParts.Click -= new EventHandler(ChangeFlag);
            logInOption.maruIdTBoxParts.TextChanged -= new EventHandler(ChangeFlag);
            logInOption.maruPassTBoxParts.TextChanged -= new EventHandler(ChangeFlag);

            logInOption.beAutoLoginCBoxParts.Click -= new EventHandler(ChangeFlag);
            logInOption.beIdTBoxParts.TextChanged -= new EventHandler(ChangeFlag);
            logInOption.bePassTBoxParts.TextChanged -= new EventHandler(ChangeFlag);

            logInOption.scBeAutoLoginCBoxParts.Click -= new EventHandler(ChangeFlag);
            logInOption.scBeIdTBoxParts.TextChanged -= new EventHandler(ChangeFlag);
            logInOption.scBePassTBoxParts.TextChanged -= new EventHandler(ChangeFlag);
        }
        private void ChangeFlag(object sender, EventArgs e)
        {
            this.changeFlag = true;
        }

        public void SetAllOption()
        {
            if (changeFlag == true)
            {
                changeFlag = false;
                {
                    this.logInOption.IsMaruAutoLogIn = this.logInOption.maruAutoLoginCBoxParts.Checked.ToString();
                    this.logInOption.MaruID = this.logInOption.maruIdTBoxParts.Text;
                    this.logInOption.MaruPassWord = this.logInOption.maruPassTBoxParts.Text;
                  
                    this.logInOption.IsBeAutoLogIn = this.logInOption.beAutoLoginCBoxParts.Checked.ToString();
                    this.logInOption.BeID = this.logInOption.beIdTBoxParts.Text;
                    this.logInOption.BePassWord = this.logInOption.bePassTBoxParts.Text;

                    this.logInOption.IsSCBeAutoLogIn = this.logInOption.scBeAutoLoginCBoxParts.Checked.ToString();
                    this.logInOption.SCBeID = this.logInOption.scBeIdTBoxParts.Text;
                    this.logInOption.SCBePassWord = this.logInOption.scBePassTBoxParts.Text;

                    this.logInOption.SaveToFile();
                }
            }
        }
    }
}
