private void lbAvailableProperties_MouseDoubleClick(object sender, MouseEventArgs e) { try { InstallerProp installerProp = lbAvailableProperties.SelectedItem as InstallerProp; selectedInstallerProp = installerProp; this.DialogResult = DialogResult.OK; } catch (Exception ex) { FrontendUtils.ShowError(ex.Message, ex); } }
private void btnAddProperty_Click(object sender, EventArgs e) { try { if (IsValidToAddProperty(gbProperty.Controls)) { if (lbAvailableProps.FindStringExact(txtPropertyName.Text) == ListBox.NoMatches) { InstallerProp selectedInstallerPropertyObject = new InstallerProp(txtPropertyName.Text, txtPropertyDesc.Text, cboPropertyType.SelectedIndex == 0 ? InstallerProp.PropType.StringProperty : InstallerProp.PropType.BooleanProperty, txtPropertyValue.Visible ? txtPropertyValue.Text : cboPropertyValue.SelectedItem.ToString().ToLower()); lbAvailableProps.Items.Add(selectedInstallerPropertyObject); ResetPorpertyDefinitionPart(); } else { FrontendUtils.ShowInformation("The property name is already in use, please choose a unique name!", true); } } else { FrontendUtils.ShowInformation("Please make sure all fields are filled", true); } } catch (Exception ex) { FrontendUtils.ShowError(ex.Message, ex); } }
private void PopulateAllAvailableProperties(string pathToInstallerFile) { lbAvailableProps.Items.Clear(); string installerFile = FrontendUtils.ReadFile(pathToInstallerFile); Regex reg = new Regex(@"\bStart-Properties(.*)End-Properties\b", RegexOptions.Singleline); string match = reg.Match(installerFile).Groups[1].Value; Regex propertyValues = new Regex(@"\bproperty\(name:'(\S+)'.*?description = '(.*?)'.*?type = (\S+).*?(defaultValue = (\S+))\b", RegexOptions.Singleline); MatchCollection propertyValuesMatches = propertyValues.Matches(match); foreach (Match propertyValuesMatch in propertyValuesMatches) { InstallerProp installerPropertyObject = new InstallerProp(propertyValuesMatch.Groups[1].Value, propertyValuesMatch.Groups[2].Value, string.Equals(propertyValuesMatch.Groups[3].Value.Trim(new char[] { '\'' }), "boolean") ? InstallerProp.PropType.BooleanProperty : InstallerProp.PropType.StringProperty, propertyValuesMatch.Groups[5].Value.Trim(new char[] { '\'' })); lbAvailableProps.Items.Add(installerPropertyObject); } }