public CustomTreeNode(string text, XmlAttributeCollection attrCollection) { Attributes = attrCollection; if (this.Attributes != null) { this.Text = this.Attributes["name"] == null ? text : this.Attributes["name"].Value; customizedAttributeCollection = new List<CustomizedAttribute>(); foreach (XmlAttribute attribute in attrCollection) { CustomizedAttribute attr = new CustomizedAttribute(attribute, true); customizedAttributeCollection.Add(attr); } } else { this.Text = text; } }
private bool CheckAttrValue(XAttribute xAttribute, CustomizedAttribute customizedAttribute) { return (string.Equals(xAttribute.Name, customizedAttribute.attrName) && string.Equals(xAttribute.Value, customizedAttribute.attrValue)); }
private void SaveUpdatedAttributes() { CustomTreeNode node = (tvOutput.SelectedNode as CustomTreeNode); for (int i = 0; i < node.customizedAttributeCollection.Count; i++) { node.customizedAttributeCollection[i].isUsed = false; } if (dgvAttributes.Rows.Count > 0) { foreach (DataGridViewRow row in dgvAttributes.Rows) { if ((bool)row.Cells[0].Value == true) { int attrIndex = GetCustomizedAttrIndex(node.customizedAttributeCollection, row.Cells[1]); if (attrIndex == -1) { int normalAttrIndex = GetNormalAttrIndex(node.customizedAttributeCollection, row.Cells[1]); if (normalAttrIndex != -1) { node.customizedAttributeCollection[normalAttrIndex].isUsed = true; node.customizedAttributeCollection[normalAttrIndex].attrName = row.Cells[1].Value.ToString(); node.customizedAttributeCollection[normalAttrIndex].attrValue = row.Cells[2].Value.ToString().Trim(); node.Attributes[(string)row.Cells[1].Value].Value = row.Cells[2].Value.ToString().Trim(); } else { CustomizedAttribute attr = new CustomizedAttribute(node.Attributes[row.Cells[1].Value.ToString()], true); row.Cells[0].Value = true; attr.attrName = row.Cells[1].Value.ToString().Trim(); attr.attrValue = row.Cells[2].Value.ToString().Trim(); node.customizedAttributeCollection.Add(attr); } } else { (node.customizedAttributeCollection[attrIndex]).isUsed = true; (node.customizedAttributeCollection[attrIndex]).attrValue = row.Cells[2].Value.ToString().Trim(); node.Attributes[(string)row.Cells[1].Value].Value = row.Cells[2].Value.ToString().Trim(); } } else { int attrIndex = GetCustomizedAttrIndex(node.customizedAttributeCollection, row.Cells[1]); if (attrIndex != -1) { (node.customizedAttributeCollection[attrIndex]).isUsed = false; } } } } }