private void createCellElement(XmlNode chNode, Dictionary <string, object> cellDictionary) { //formula if (chNode.HasChildNodes) { CellForm cellForm = new CellForm(); String cellName = chNode.Attributes[0].Value; cellForm.createFormSizes(cellElementList(chNode.ChildNodes)); cellForm.Text = "Cell " + cellName; cellForm.General_DescriptionBox.Text = chNode.Attributes[1].Value; cellForm.General_DescriptionBox.Select(0, 0); if (chNode.ChildNodes.Count == 2) { cellForm.inputBox.Text = chNode.ChildNodes.Item(0).Attributes[1].Value; cellForm.OutputBox.Text = chNode.ChildNodes.Item(1).Attributes[0].Value; cellDictionary.Add(cellName, cellForm); } else { foreach (XmlNode child in chNode.ChildNodes) { if (child.Name.Equals("input")) { foreach (Control ctr in cellForm.Controls) { if (ctr is TextBox && ctr.Name.Equals(child.Attributes[0].Value)) { ctr.Text = child.Attributes[1].Value; break; } } } if (child.Name.Equals("output")) { cellForm.OutputBox.Text = child.Attributes[0].Value; } } cellDictionary.Add(cellName, cellForm); } } //value else { GeneralForm cellForm = new GeneralForm(); String cellName = chNode.Attributes[0].Value; cellForm.Text = "Cell " + cellName; cellForm.General_DescriptionGFBox.Text = chNode.Attributes[1].Value; cellForm.General_DescriptionGFBox.Select(0, 0); cellDictionary.Add(cellName, cellForm); } }
private void modifyCellWithFormulaNode(XmlNode node, CellForm form) { node.Attributes[1].Value = form.General_DescriptionBox.Text; foreach (XmlNode chNode in node.ChildNodes) { if (!chNode.Name.Equals("output")) { if (form.argumentsText.ContainsKey(chNode.Attributes[0].Value)) { chNode.Attributes[1].Value = form.argumentsText[chNode.Attributes[0].Value]; } } else { chNode.Attributes[0].Value = form.argumentsText["OutputBox"]; } } }
private XmlElement createInputCellAttr(XmlElement parentElement, String parentName, CellForm form) { XmlElement child; XmlAttribute cellAttr; XmlAttribute descriptionAttr; foreach (KeyValuePair <String, String> children in form.argumentsText) { if (!children.Key.Equals("General_DescriptionBox") && (!children.Key.Equals("OutputBox"))) { child = doc.CreateElement(string.Empty, "input", string.Empty); cellAttr = doc.CreateAttribute("cell"); descriptionAttr = doc.CreateAttribute("description"); cellAttr.Value = children.Key; descriptionAttr.Value = children.Value; child.SetAttributeNode(cellAttr); child.SetAttributeNode(descriptionAttr); parentElement.AppendChild(child); } } child = doc.CreateElement(string.Empty, "output", string.Empty); descriptionAttr = doc.CreateAttribute("description"); descriptionAttr.Value = form.OutputBox.Text; child.SetAttributeNode(descriptionAttr); parentElement.AppendChild(child); return(parentElement); }
public void addCellWithFormulaToWorksheet(String elementName, String worksheetName, CellForm form) { XmlNode node = checkNode("//Worksheet", worksheetName); if (node != null) { XmlNode childNode = getNodeByWorksheet(node.ChildNodes, elementName); if (childNode != null) { modifyCellWithFormulaNode(childNode, form); } else { element = doc.CreateElement(string.Empty, "Cell", string.Empty); XmlNode worksheet = checkNode("//Worksheet", worksheetName); worksheet.AppendChild(createInputCellAttr(createAttrNode(element, elementName, form.General_DescriptionBox.Text), elementName, form)); } } }