public void LoadSettings()
        {
            isLoading = true;
            this.flowMain.SuspendLayout();

            for (int i = flowMain.Controls.Count - 1; i > 2; i--)
            {
                flowMain.Controls.RemoveAt(i);
            }

            foreach (var split in splitsState)
            {
                SplitSettings setting = new SplitSettings();
                setting.cboName.DisplayMember = "SplitName";
                setting.cboName.ValueMember   = "Type";
                setting.cboName.DataSource    = SplitComboData();
                setting.cboName.Text          = split.name;
                setting.txtValue.Text         = split.value;
                setting.chkSplit.Checked      = split.doSplit;
                AddHandlers(setting);

                flowMain.Controls.Add(setting);
            }

            this.chkAutoStart.Checked      = this.autoStart;
            this.chkAutoReset.Checked      = this.autoReset;
            this.chkShowMapDisplay.Checked = this.showMapDisplay;

            isLoading = false;
            this.flowMain.ResumeLayout(true);
        }
        public void UpdateSettings()
        {
            if (isLoading)
            {
                return;
            }

            splitsState.Clear();
            foreach (Control c in flowMain.Controls)
            {
                if (c is SplitSettings)
                {
                    SplitSettings setting = (SplitSettings)c;
                    if (!string.IsNullOrEmpty(setting.cboName.Text) && !string.IsNullOrEmpty(setting.txtValue.Text))
                    {
                        Split split = new Split();
                        split.name    = setting.cboName.Text;
                        split.value   = setting.txtValue.Text;
                        split.doSplit = setting.chkSplit.Checked;

                        splitsState.Add(split);
                    }
                }
            }

            this.autoStart      = chkAutoStart.Checked;
            this.autoReset      = chkAutoReset.Checked;
            this.showMapDisplay = chkShowMapDisplay.Checked;

            parent.oriState.UpdateAutoStart(this.autoStart);
            parent.oriState.UpdateAutoReset(this.autoReset);
            parent.oriState.UpdateSplits(this.splitsState);
        }
        private void txtHitbox_OnNewHitbox(object sender, EventArgs e)
        {
            SplitSettings splitSetting = (SplitSettings)this.ActiveControl;

            if (splitSetting.ControlType != "Hitbox")
            {
                return;
            }
            splitSetting.txtValue.Text = display.lastHitbox.ToString();
        }
        private void txtHitbox_TextChanged(object sender, EventArgs e)
        {
            SplitSettings splitSetting = (SplitSettings)((TextBox)sender).Parent;

            if (splitSetting.ControlType != "Hitbox")
            {
                return;
            }
            display.lastHitbox = new Vector4(splitSetting.txtValue.Text);
        }
 private void RemoveHandlers(SplitSettings setting)
 {
     setting.txtValue.Enter               -= txtHitbox_GotFocus;
     setting.txtValue.Leave               -= txtHitbox_LostFocus;
     setting.txtValue.TextChanged         += txtHitbox_TextChanged;
     setting.cboName.SelectedIndexChanged -= cboName_SelectedIndexChanged;
     setting.btnRemove.Click              -= btnRemove_Click;
     setting.btnUp.Click   -= btnUp_Click;
     setting.btnDown.Click -= btnDown_Click;
 }
 private void AddHandlers(SplitSettings setting)
 {
     setting.txtValue.Enter               += txtHitbox_GotFocus;
     setting.txtValue.Leave               += txtHitbox_LostFocus;
     setting.txtValue.TextChanged         += txtHitbox_TextChanged;
     setting.cboName.SelectedIndexChanged += cboName_SelectedIndexChanged;
     setting.btnRemove.Click              += btnRemove_Click;
     setting.btnUp.Click             += btnUp_Click;
     setting.btnDown.Click           += btnDown_Click;
     setting.chkSplit.CheckedChanged += chkBox_CheckedChanged;
 }
        private void txtHitbox_GotFocus(object sender, EventArgs e)
        {
            SplitSettings splitSetting = (SplitSettings)((TextBox)sender).Parent;

            if (splitSetting.ControlType != "Hitbox")
            {
                return;
            }
            display.Show();
            display.OnNewHitbox += txtHitbox_OnNewHitbox;
            display.lastHitbox   = new Vector4(splitSetting.txtValue.Text);
        }
        private void txtHitbox_LostFocus(object sender, EventArgs e)
        {
            UpdateSettings();
            SplitSettings splitSetting = (SplitSettings)((TextBox)sender).Parent;

            if (splitSetting.ControlType != "Hitbox")
            {
                return;
            }
            display.Hide();
            display.OnNewHitbox -= txtHitbox_OnNewHitbox;
            display.UndrawRectangle();
        }
        private void btnAddSplit_Click(object sender, EventArgs e)
        {
            SplitSettings setting = new SplitSettings();

            setting.cboName.DisplayMember = "SplitName";
            setting.cboName.ValueMember   = "Type";
            setting.cboName.DataSource    = SplitComboData();
            setting.cboName.Text          = "Start";
            setting.txtValue.Text         = "True";
            setting.chkSplit.Checked      = false;
            AddHandlers(setting);

            flowMain.Controls.Add(setting);
            UpdateSettings();
        }
 private void RemoveHandlers(SplitSettings setting) {
     setting.txtValue.Enter -= txtHitbox_GotFocus;
     setting.txtValue.Leave -= txtHitbox_LostFocus;
     setting.txtValue.TextChanged += txtHitbox_TextChanged;
     setting.cboName.SelectedIndexChanged -= cboName_SelectedIndexChanged;
     setting.btnRemove.Click -= btnRemove_Click;
     setting.btnUp.Click -= btnUp_Click;
     setting.btnDown.Click -= btnDown_Click;
 }
 private void AddHandlers(SplitSettings setting) {
     setting.txtValue.Enter += txtHitbox_GotFocus;
     setting.txtValue.Leave += txtHitbox_LostFocus;
     setting.txtValue.TextChanged += txtHitbox_TextChanged;
     setting.cboName.SelectedIndexChanged += cboName_SelectedIndexChanged;
     setting.btnRemove.Click += btnRemove_Click;
     setting.btnUp.Click += btnUp_Click;
     setting.btnDown.Click += btnDown_Click;
     setting.chkDontSplit.CheckedChanged += chkBox_CheckedChanged;
 }
        public void LoadSettings() {
            isLoading = true;
            this.flowMain.SuspendLayout();

            for (int i = flowMain.Controls.Count - 1; i > 1; i--) {
                flowMain.Controls.RemoveAt(i);
            }

            foreach (var split in splitsState) {
                SplitSettings setting = new SplitSettings();
                setting.cboName.DisplayMember = "SplitName";
                setting.cboName.ValueMember = "Type";
                setting.cboName.DataSource = SplitComboData();
                setting.cboName.Text = split.name;
                setting.txtValue.Text = split.value;
                setting.chkDontSplit.Checked = split.dontSplit;
                AddHandlers(setting);

                flowMain.Controls.Add(setting);
            }

            this.chkAutoStart.Checked = this.autoStart;
            this.chkAutoReset.Checked = this.autoReset;
            this.chkShowMapDisplay.Checked = this.showMapDisplay;

            isLoading = false;
            this.flowMain.ResumeLayout(true);
        }
        private void btnAddSplit_Click(object sender, EventArgs e) {
            SplitSettings setting = new SplitSettings();
            setting.cboName.DisplayMember = "SplitName";
            setting.cboName.ValueMember = "Type";
            setting.cboName.DataSource = SplitComboData();
            setting.cboName.Text = "Start";
            setting.txtValue.Text = "True";
            setting.chkDontSplit.Checked = false;
            AddHandlers(setting);

            flowMain.Controls.Add(setting);
            UpdateSettings();
        }