Beispiel #1
0
 public static bool AddEvent(SvgDocument doc, string eventname)
 {
     int num1 = CodeFunc.GetIndexOfString(doc.OuterXml, "function", eventname);
     if (num1 >= 0)
     {
         return false;
     }
     XmlNode node1 = doc.DocumentElement.SelectSingleNode("*[name()='script']");
     XmlElement element1 = doc.CreateElement(doc.Prefix, "script", doc.NamespaceURI);
     if (node1 is XmlElement)
     {
         element1 = (XmlElement) node1;
     }
     element1.SetAttribute("type", doc.NamespaceURI, "text/ecmascript");
     string text1 = string.Empty + "\n\tfunction " + eventname + "\n\t{\n\t\t\n\t}\n\t";
     XmlNode node2 = element1.FirstChild;
     XmlCDataSection section1 = null;
     Label_0092:
     if (node2 is XmlCDataSection)
     {
         section1 = (XmlCDataSection) node2;
     }
     else if (node2 != null)
     {
         node2 = node2.NextSibling;
         goto Label_0092;
     }
     if (section1 == null)
     {
         section1 = doc.CreateCDataSection(text1);
         element1.AppendChild(doc.CreateWhitespace("\n\t"));
         element1.AppendChild(section1);
         element1.AppendChild(doc.CreateWhitespace("\n\t"));
     }
     else
     {
         XmlNode node3 = section1.LastChild;
         section1.Value = section1.Value + text1;
     }
     if (element1.ParentNode == null)
     {
         doc.DocumentElement.PrependChild(element1);
     }
     return true;
 }