void HandleAddNameSpacehandleClick(object sender, System.EventArgs e) { CustomAttributeDialog.AddNameSpace(this.scl, this.nameSpaceList); }
// TODO: We can't add new Custom Attributes due to you need an XML document object reference void HandleAddAttributehandleClick(object sender, System.EventArgs e) { // Add a custom Name Space before to add a new one if (this.scl.xmlns == null) { CustomAttributeDialog.AddNameSpace(this.scl, this.nameSpaceList); } // If no custom name space then abort if (this.scl.xmlns != null) { System.Xml.XmlAttribute[] attrArray; if (this.element.AnyAttr == null) { attrArray = new System.Xml.XmlAttribute[1]; } else { attrArray = new System.Xml.XmlAttribute[this.element.AnyAttr.GetLength(0) + 1]; this.element.AnyAttr.CopyTo(attrArray, 0); } string[] ns = new string[this.scl.xmlns.ToArray().Length]; for (int i = 0; i < ns.Length; i++) { ns[i] = "xmlns:" + this.scl.xmlns.ToArray()[i].Name + "=" + this.scl.xmlns.ToArray()[i].Namespace; } EditDialog dlg = new EditDialog(this.scl, ns); dlg.L1 = "Name:"; dlg.L2 = "Value:"; dlg.Text = "Add Custom Attribute"; DialogResult res = dlg.ShowDialog(); if (res == DialogResult.OK) { if (this.xmldoc != null) { System.Console.WriteLine("NameSpace = " + this.scl.xmlns.ToArray()[dlg.NameSpaceIndex]); System.Console.WriteLine("Att name = " + dlg.T1); System.Console.WriteLine("Att value = " + dlg.T2); System.Xml.XmlAttribute a = this.xmldoc.CreateAttribute(dlg.T1, this.scl.xmlns.ToArray()[dlg.NameSpaceIndex] .ToString()); a.Value = dlg.T2; if (this.element.AnyAttr == null) { this.element.AnyAttr = new System.Xml.XmlAttribute [1]; this.element.AnyAttr[1] = a; } // else // this.element.AddXmlAttribute (a); FillAttr(); } } } }