private void checkedListBoxAD_ItemCheck()

in src/IdFix/FormSettings.cs [322:364]


        private void checkedListBoxAD_ItemCheck(object sender, ItemCheckEventArgs e)
        {
            //If nothing is selected, reset the boxes.
            switch (checkedListBoxAD.CheckedItems.Count)
            {
                case 0:
                    if (e.NewValue == CheckState.Checked)
                    {
                        //A new value is added
                        if (searchBaseCheckBox.Checked)
                        {
                            //The problem here is that nothing is marked as checked at this point.
                            //So we have to assume that this happened at that index.
                            ResetSearchBase(e.Index);
                            //Enable the textbox too
                            textBoxSearchBase.Enabled = true;
                        }
                    }
                    break;
                case 1:
                    //If we go from 1->0 or 1->2, we have to uncheck.
                    if (searchBaseCheckBox.Checked)
                    {
                        searchBaseCheckBox.Checked = false;
                        textBoxSearchBase.Enabled = false;
                        textBoxSearchBase.Text = String.Empty;
                    }
                    break;
                case 2:
                    if (e.NewValue == CheckState.Unchecked)
                    {
                        if (searchBaseCheckBox.Checked)
                        {
                            //This will end up being one item checked.
                            //Reset searchBase.
                            int index = e.Index == 0 ? 1 : 0;
                            ResetSearchBase(index);
                            textBoxSearchBase.Enabled = true;
                        }
                    }
                    break;
            }
        }