private void setCheckbox(CheckBox cb, XmlInputConfiguration xmlConfig, string key, XmlElement[] eIncomingMetaInfo) { string setting = (string)xmlConfig[key] ?? Constants.DEFAULTAUTOESCAPE; // Get the data held in the config (Y/N) if (isTrueString(setting)) cb.Checked = true; else cb.Checked = false; }
public Control GetConfigurationControl( AlteryxGuiToolkit.Document.Properties docProperties, XmlElement eConfig, XmlElement[] eIncomingMetaInfo, int nToolId, string strToolName) { XmlInputConfiguration xmlConfig = XmlInputConfiguration.LoadFromConfiguration(eConfig); if (xmlConfig == null) return this; /////////////////////////////////////////////////////////////////// // Populate GUI Controls with saved config information // /////////////////////// // FIELD COMBOX BOXES // setComboBox(comboBoxExePathField, xmlConfig, Constants.EXEPATHFIELDKEY, eIncomingMetaInfo); ///////////// // CHECKBOX // setCheckbox(checkBoxAutoEscape, xmlConfig, Constants.AUTOESCAPEKEY, eIncomingMetaInfo); ///////////////////////// // SELECTED COLUMNS BOX // setCheckedListBox(checkedListBoxSelectedCols, xmlConfig, Constants.SELECTEDCOLSKEY, eIncomingMetaInfo); /////////////////////////////////////////////////////////////////// // Output Fields // textBoxStdOutField.Text = xmlConfig.StdOutField; textBoxRetCodeField.Text = xmlConfig.RetCodeField; textBoxExceptionField.Text = xmlConfig.ExceptionField; textBoxDiagnosticField.Text = xmlConfig.DiagnosticField; return this; }
private void setComboBox(ComboBox cbox, XmlInputConfiguration xmlConfig, string key, XmlElement[] eIncomingMetaInfo) { string target = (string)xmlConfig[key]; cbox.Items.Clear(); if (eIncomingMetaInfo == null || eIncomingMetaInfo[0] == null) { // No incoming connection; Just add the field and select it cbox.Items.Add(target); cbox.SelectedIndex = 0; } else { // We have an incoming connection var xmlElementMetaInfo = eIncomingMetaInfo[0]; var xmlElementRecordInfo = xmlElementMetaInfo.FirstChild; foreach (XmlElement elementChild in xmlElementRecordInfo) { string fieldName = elementChild.GetAttribute("name"); string fieldType = elementChild.GetAttribute("type"); if (isStringType(fieldType)) cbox.Items.Add(fieldName); } // If the messageField matches a possible field in the combo box, make it the selected field. // If the field does not match, do not select anything and blank the field. if (!string.IsNullOrWhiteSpace(target)) { int selectedIndex = cbox.FindStringExact(target); if (selectedIndex >= 0) cbox.SelectedIndex = selectedIndex; // Found; Select this item } } // end of "if (eIncomingMetaInfo == null || eIncomingMetaInfo[0] == null)" }
private void setCheckedListBox(CheckedListBox box, XmlInputConfiguration xmlConfig, string key, XmlElement[] eIncomingMetaInfo) { string csvTargets = (string)xmlConfig[key]; // Split the csv string[] targets = csvTargets.Split(','); bool bCheckAll = false; if (targets.Length == 1 && String.Equals(targets[0], Constants.DEFAULTSELECTEDCOLS, StringComparison.OrdinalIgnoreCase)) { targets = new string[0]; bCheckAll = true; } // If there are no selected columns, clear the targets list if (targets.Length == 1 && String.Equals(targets[0], Constants.ZEROSELECTEDCOLS, StringComparison.OrdinalIgnoreCase)) targets = new string[0]; box.Items.Clear(); if (eIncomingMetaInfo == null || eIncomingMetaInfo[0] == null) { // No incoming connection; // Cycle through the targets, adding them as missing foreach (string target in targets) { if (!bCheckAll) box.Items.Add(target + MISSING, true); } } else { // We have an incoming connection var xmlElementMetaInfo = eIncomingMetaInfo[0]; var xmlElementRecordInfo = xmlElementMetaInfo.FirstChild; string fieldName = ""; foreach (XmlElement elementChild in xmlElementRecordInfo) { fieldName = elementChild.GetAttribute("name"); bool bSelected = false; foreach (string target in targets) { // If the current field on the inbound stream is selected, set the checked flag bSelected = bSelected || String.Equals(fieldName, target, StringComparison.OrdinalIgnoreCase); } // If bCheckAll is set, select this column anyway bSelected = bSelected || bCheckAll; box.Items.Add(fieldName, bSelected); } // Add the missing fields foreach (string target in targets) { bool bExists = false; foreach (XmlElement elementChild in xmlElementRecordInfo) { fieldName = elementChild.GetAttribute("name"); // If the current field in the target list exists, set the exists flag bExists = bExists || String.Equals(fieldName, target, StringComparison.OrdinalIgnoreCase); } if (!bExists) { // Target does not exist in the inbound fields list, so it is missing box.Items.Add(target + MISSING, true); } } } }