/// <summary> /// Copies the current node and its children to the clipboard in text and graphic formats /// </summary> /// <param name="arg"></param> public void copyToClipboard(Argument arg) { DataObject myDataObject; Node n; DrawTree d; Bitmap b; n = (Node)tv.SelectedNode.Tag; System.Text.StringBuilder sb; // builds a string which is the AXL (XML) for the current node sb = arg.writeArgumentXMLstring(n, false); // Creates a new data format. DataFormats.Format myFormat = DataFormats.GetFormat("AXL"); myDataObject = new DataObject(myFormat.Name, sb.ToString()); // Add the text format myDataObject.SetData(copySelectedTreeNodeAsText()); // add graphic d = new DrawTree(0, 0, 1F); // no offset or zoom b = d.drawTree(n); // create image myDataObject.SetData(b); Clipboard.SetDataObject(myDataObject, true); }
/// <summary> /// Transform argument through XSL /// </summary> /// <param name="filename">Source AXL file name</param> /// <param name="stylesheet">XSLT Stylesheet file</param> /// <param name="outfilename">Output File Name</param> /// <param name="arg">Current argument</param> /// <returns></returns> public bool doTransform(string filename, string stylesheet, string outfilename, Argument arg) { StringBuilder sb; XPathDocument xpathdocument; // Get output path outfilepath = System.IO.Path.GetDirectoryName(outfilename); if (outfilepath.IndexOf('\\') >= 0) { outfilepath += '\\'; } // Send text to outfilename, a text file StreamWriter sw = new StreamWriter(outfilename); // //XslTransform xslt = new XslTransform(); XslCompiledTransform xslt = new XslCompiledTransform(); if (filename == null | filename.Equals("")) // empty string means read from current XML { // load current argument into the string sb = arg.writeArgumentXMLstring(arg.findHead(), true); xpathdocument = new XPathDocument(new XmlTextReader(new StringReader(sb.ToString()))); } else { xpathdocument = new XPathDocument(filename); } XmlTextReader xtr = new XmlTextReader(stylesheet); xslt.Load(xtr, null, null); XmlTextWriter writer = new XmlTextWriter(sw); writer.Formatting = Formatting.Indented; // Create an XsltArgumentList. XsltArgumentList xslArg = new XsltArgumentList(); // Add an object to create image TODO Possible error - Current argument can only have a transformed image ImageXSLextension obj = new ImageXSLextension(arg, this.outfilepath); xslArg.AddExtensionObject("urn:image", obj); xslt.Transform(xpathdocument, xslArg, writer); // xslt.Transform(xpathdocument, writer); xtr.Close(); sw.Close(); return(true); }