void okButton_Click(object sender, EventArgs e) { Value = ComboBoxes .Select(c => PossibleValues[c.SelectedIndex]) .ToArray(); DialogResult = System.Windows.Forms.DialogResult.OK; Close(); }
/// <summary> /// Adds a selection region to the form, consisting of a ComboBox and a Label (for indicating the purpose of the former). /// <para/> /// The value of the ComboBox in this region will be put into the <c>Value</c> property in the order the ComboBoxes /// are added onto the page. /// </summary> /// <param name="height">The current height of the control, used for adding controls down the form.</param> /// <param name="index">The current TabIndex of the controls added to the form.</param> /// <param name="label">The label for this particular ComboBox.</param> private void AddSelection(ref int height, ref int index, string label) { // add combo box ComboBox comboBoxControl = new ComboBox() { DropDownStyle = ComboBoxStyle.DropDownList, Height = 23, Width = ComboBoxWidth, Top = height, Left = 12 + LabelWidth + 8, TabIndex = index++, Font = this.Font }; foreach (char possibleValue in PossibleValues) { // lack of value-type array covariance means I have to iterate this manually comboBoxControl.Items.Add(possibleValue); } comboBoxControl.SelectedIndex = 0; // add label Label labelControl = new Label() { Text = label, TextAlign = System.Drawing.ContentAlignment.TopRight, AutoSize = false, Height = 15, Width = LabelWidth, Top = height + 3, Font = this.Font, Left = 12 }; ComboBoxes.Add(comboBoxControl); Controls.Add(comboBoxControl); Controls.Add(labelControl); height += 23 + 6; }
[ExcludeFromCodeCoverage] // TODO: could maybe remove after creating a test of this private void InitComboBoxes(ComboBoxes comboBox) { switch (comboBox) { case ComboBoxes.Scale: SelectedScaleX = INIT_SCALE; SelectedScaleY = INIT_SCALE; SelectedScaleZ = INIT_SCALE; break; case ComboBoxes.Rotate: SelectedRotateX = INIT_ROTATE; SelectedRotateY = INIT_ROTATE; SelectedRotateZ = INIT_ROTATE; break; default: var ex = new ArgumentOutOfRangeException(nameof(comboBox), comboBox, null); var logMessage = $"[{GetType().Name}] Exception at {MethodBase.GetCurrentMethod()}: {ex.Message}"; Container.Resolve <ILoggerFacade>().Log(logMessage, Category.Exception, Priority.High); throw ex; } }
/// <summary> /// The EnableRowControls method. /// </summary> /// <param name="privilege">The privilege to enable the row for.</param> private void EnableRowControls(Privilege privilege) { var comboBox = ComboBoxes.FirstOrDefault(cbx => cbx.Name == "cbx" + privilege.PermissionId); if (comboBox == null) { return; } var priorityButton = GetButtonByName("pri" + privilege.PermissionId); var sourceButton = GetButtonByName("btn" + privilege.PermissionId); comboBox.SelectedIndex = privilege.IsRestricted ? 2 : 1; priorityButton.Text = privilege.Priority.ToString(); priorityButton.Enabled = true; priorityButton.Tag = privilege; if (sourceButton != null) { sourceButton.Enabled = privilege.IsRestricted; } HandleRelations(comboBox); }
public void AddComboBox(string name, RedComboBox checkBox)//addcheckboxhere! { ComboBoxes.Add(name, checkBox); }