private void SubitemDefinition_Load(object sender, EventArgs e) { textBoxKey.Text = subitemKey; buttonOk.Enabled = (!string.IsNullOrEmpty(subitemKey)); textBoxDescription.Text = subitemDescription; switch (subitemType) { case "singleselect": case "multiselect": if (subitemDefaultValue != null) { comboBoxSelect.SelectedIndex = comboBoxSelect.FindString(subitemDefaultValue.ToString()); } break; case "textfield": case "password": textBoxDefaultValue.Text = subitemDefaultValue as string; textBoxEmptyText.Text = subitemEmptyText; break; case "combobox": break; } checkBoxDisabled.Checked = subitemDisabled; checkBoxHidden.Checked = subitemHidden; checkBoxPreventMark.Checked = subitemPreventMark; textBoxWidth.Text = subitemWidth; textBoxHeight.Text = subitemHeight; textBoxInvalid.Text = subitemInvalidText; checkBoxStatic.Checked = subitemStaticCombo; checkBoxStatic.Enabled = (string.IsNullOrEmpty(subitemKey)); if (subitemBaseParams != null) { foreach (NameValue item in subitemBaseParams) { var clone = new NameValue(item.value, item.name); listBoxBaseParams.Items.Add(clone); } } textBoxRoot.Text = subitemRoot; textBoxApiStore.Text = subitemApi; textBoxDynamicValueField.Text = subitemValueField; textBoxDynamicDisplayField.Text = subitemDisplayField; radioButtonDynamicValueField.Checked = subitemValueFieldUnique; radioButtonDynamicDisplayField.Checked = subitemDisplayFieldUnique; checkBoxEditable.Checked = subitemEditable; checkBoxAutoSelect.Checked = subitemAutoSelect; CheckBoxForceSelection.Checked = subitemForceSelection; checkBoxAllowBlank.Checked = subitemAllowBlank; textBoxMinLength.Text = subitemMinLength; textBoxMaxLength.Text = subitemMaxLength; comboBoxType.SelectedIndex = comboBoxType.FindString(subitemvType); textBoxRegEx.Text = subitemRegex; textBoxFn.Text = subitemFn; textBoxBlankText.Text = subitemBlankText; checkBoxHtmlEncode.Checked = subitemHtmlEncode; checkBoxGrow.Checked = subitemGrow; textBoxGrowMin.Text = subitemGrowMin; textBoxGrowMax.Text = subitemGrowMax; textBoxMaxLengthText.Text = subitemMaxLengthText; textBoxMinLengthText.Text = subitemMinLengthText; foreach (var control in tabControlDefinition.Controls) { var tab = control as TabPage; if (tab != null) { foreach (var item in tab.Controls) { var field = item as Control; if (field != null) { field.MouseEnter += new System.EventHandler(this.OnMouseEnter); field.Enter += new System.EventHandler(this.OnMouseEnter); field.MouseLeave += new System.EventHandler(this.OnMouseLeave); } } } } }
private void buttonOk_Click(object sender, EventArgs e) { subitemKey = textBoxKey.Text; subitemDescription = textBoxDescription.Text; switch (subitemType) { case "singleselect": case "multiselect": subitemDefaultValue = comboBoxSelect.Text; break; case "textfield": case "password": subitemDefaultValue = textBoxDefaultValue.Text; subitemEmptyText = textBoxEmptyText.Text; break; case "combobox": break; } subitemDisabled = checkBoxDisabled.Checked; subitemHidden = checkBoxHidden.Checked; subitemPreventMark = checkBoxPreventMark.Checked; subitemWidth = textBoxWidth.Text; subitemHeight = textBoxHeight.Text; subitemInvalidText = textBoxInvalid.Text; subitemStaticCombo = checkBoxStatic.Checked; if (subitemBaseParams != null) { subitemBaseParams.Clear(); foreach (NameValue item in listBoxBaseParams.Items) { var clone = new NameValue(item.value, item.name); subitemBaseParams.Add(clone); } } subitemRoot = textBoxRoot.Text; subitemApi = textBoxApiStore.Text; subitemValueField = textBoxDynamicValueField.Text; subitemDisplayField = textBoxDynamicDisplayField.Text; subitemValueFieldUnique = radioButtonDynamicValueField.Checked; subitemDisplayFieldUnique = radioButtonDynamicDisplayField.Checked; subitemEditable = checkBoxEditable.Checked; subitemAutoSelect = checkBoxAutoSelect.Checked; subitemForceSelection = CheckBoxForceSelection.Checked; subitemAllowBlank = checkBoxAllowBlank.Checked; subitemMinLength = textBoxMinLength.Text; subitemMaxLength = textBoxMaxLength.Text; subitemvType = comboBoxType.Text; subitemRegex = textBoxRegEx.Text; if (!string.IsNullOrWhiteSpace(subitemRegex) && !subitemRegex.StartsWith("/")) { subitemRegex = "/" + subitemRegex; } if (!string.IsNullOrWhiteSpace(subitemRegex) && !subitemRegex.Substring(subitemRegex.Length - 2).StartsWith("/") && !subitemRegex.EndsWith("/")) { subitemRegex = subitemRegex + "/"; } textBoxRegEx.Text = subitemRegex; subitemFn = textBoxFn.Text; subitemFn = subitemFn.Replace("\r\n", "").Replace("\r", "").Replace("\n", ""); if (!string.IsNullOrEmpty(subitemFn) && !(subitemFn.StartsWith("{") || subitemFn.EndsWith("}"))) { subitemFn = string.Format("{{{0}}}", subitemFn); } subitemBlankText = textBoxBlankText.Text; subitemGrow = checkBoxGrow.Checked; if (subitemGrow) { subitemGrowMin = textBoxGrowMin.Text; subitemGrowMax = textBoxGrowMax.Text; } else { subitemGrowMin = ""; subitemGrowMax = ""; } subitemHtmlEncode = checkBoxHtmlEncode.Checked; if (!string.IsNullOrEmpty(subitemMaxLength)) { subitemMaxLengthText = textBoxMaxLengthText.Text; } else { subitemMaxLengthText = ""; } if (!string.IsNullOrEmpty(subitemMinLength)) { subitemMinLengthText = textBoxMinLengthText.Text; } else { subitemMinLengthText = ""; } this.Close(); }