/// <summary>
        /// Sets the Visibility for Settings within a specific Panel (Global, Active, or Dead)
        /// </summary>
        /// <param name="type">The Type of pannel to set visibility settings for</param>
        private void SetViewVisibility(SettingInstanceType type)
        {
            switch (type)
            {
            case SettingInstanceType.Active:
                foreach (var setting in _settings.ActiveSettings.Where(s => s.HideInUiWhen.Count > 0))
                {
                    SetIndividualVisibility(setting, flpActive, false);
                }
                break;

            case SettingInstanceType.Dead:
                foreach (var setting in _settings.DeadSettings.Where(s => s.HideInUiWhen.Count > 0))
                {
                    SetIndividualVisibility(setting, flpDead, true);
                }
                break;

            case SettingInstanceType.Global:
                foreach (var setting in _settings.GlobalSettings.Where(s => s.HideInUiWhen.Count > 0))
                {
                    SetIndividualVisibility(setting, flpGlobal, false);
                }
                break;
            }
        }
        /// <summary>
        /// Used from the Settings UI Only - Sets the instance value of the setting.
        /// </summary>
        /// <param name="settingName">Name of Setting to Set a value for.</param>
        /// <param name="type">Type of Setting to Set (Active/Dead/Global)</param>
        /// <param name="value">The New Instance Value of the Setting</param>
        internal void SetSetting(string settingName, SettingInstanceType type, int value)
        {
            AlgorithmSetting setting;

            //Select the Proper Collection.
            switch (type)
            {
            case SettingInstanceType.Active:
                setting = ActiveSettings.First(v => v.Name == settingName);
                break;

            case SettingInstanceType.Dead:
                setting = DeadSettings.First(v => v.Name == settingName);
                break;

            case SettingInstanceType.Global:
                setting = GlobalSettings.First(v => v.Name == settingName);
                break;

            default:
                throw new ArgumentException("Invalid SettingInstanceType Enum", "type");
            }

            //Set the Value in the Proper Collection
            setting.Value = value;
        }
        private void BuildSettingsPanel(IEnumerable <AlgorithmSetting> settings, FlowLayoutPanel flowPanel, SettingInstanceType type)
        {
            //Dynamically Build the form Controls.
            var index      = 0;
            var tabCounter = 3;

            foreach (var setting in settings)
            {
                var panel = new Panel();
                panel.Size = new Size(210, 40);
                panel.Name = $"panel{index}";
                panel.Tag  = setting.Name;

                var newLabel = new Label();
                newLabel.AutoSize = true;
                newLabel.Location = new Point(0, 0);
                newLabel.Name     = $"label{index}";
                newLabel.Size     = new Size(210, 13);
                newLabel.TabIndex = tabCounter;
                newLabel.Text     = $"{setting.Name}:";

                panel.Controls.Add(newLabel);

                tabCounter++;
                if (setting.PossibleValues.Count > 0)
                {
                    //Create Drop Down
                    var newDropDown = new ComboBox();

                    newDropDown.DropDownStyle     = ComboBoxStyle.DropDownList;
                    newDropDown.Location          = new Point(0, 15);
                    newDropDown.FormattingEnabled = true;
                    newDropDown.Name     = $"dropDown{index}";
                    newDropDown.Size     = new Size(210, 21);
                    newDropDown.TabIndex = tabCounter;
                    newDropDown.Tag      = setting.Name;

                    newDropDown.DataSource    = setting.PossibleValues;
                    newDropDown.DisplayMember = "Key";
                    newDropDown.ValueMember   = "Value";

                    //Data binding only takes place AFTER control is rendered... this is a workaround to have the initial value set.
                    EventHandler visibleChangedHandler = null;
                    visibleChangedHandler = delegate {
                        newDropDown.SelectedValue   = setting.Value;
                        newDropDown.VisibleChanged -= visibleChangedHandler; // Only do this once!
                    };
                    newDropDown.VisibleChanged += visibleChangedHandler;

                    //assign the correct event handler (active or Dead/Global)
                    switch (type)
                    {
                    case SettingInstanceType.Active:
                        newDropDown.SelectedValueChanged += DropDown_SelectedActiveValueChanged;
                        break;

                    case SettingInstanceType.Dead:
                        newDropDown.SelectedValueChanged += DropDown_SelectedDeadValueChanged;
                        break;

                    case SettingInstanceType.Global:
                        newDropDown.SelectedValueChanged += DropDown_SelectedGlobalValueChanged;
                        break;
                    }

                    ToolTip newToolTip = new ToolTip();
                    newToolTip.SetToolTip(newDropDown, setting.Description);

                    panel.Controls.Add(newDropDown);
                }
                else
                {
                    //Create TextBox for adding Int type Values.
                    var newNumericUpDown = new NumericUpDown();

                    newNumericUpDown.Location = new Point(0, 15);
                    newNumericUpDown.Name     = $"numericUpDown{index}";
                    newNumericUpDown.Size     = new Size(210, 21);
                    newNumericUpDown.TabIndex = tabCounter;
                    newNumericUpDown.Tag      = setting.Name;
                    newNumericUpDown.Maximum  = setting.MaxValue;
                    newNumericUpDown.Minimum  = setting.MinValue;

                    newNumericUpDown.Value = setting.Value;

                    //assign the correct event handler (active or Dead/Global)
                    switch (type)
                    {
                    case SettingInstanceType.Active:
                        newNumericUpDown.ValueChanged += NumericUpDown_ActiveValueChanged;
                        break;

                    case SettingInstanceType.Dead:
                        newNumericUpDown.ValueChanged += NumericUpDown_DeadValueChanged;
                        break;

                    case SettingInstanceType.Global:
                        newNumericUpDown.ValueChanged += NumericUpDown_GlobalValueChanged;
                        break;
                    }

                    ToolTip newToolTip = new ToolTip();
                    newToolTip.SetToolTip(newNumericUpDown, setting.Description);

                    panel.Controls.Add(newNumericUpDown);
                }

                flowPanel.Controls.Add(panel);

                index++;
                tabCounter++;
            }
        }