void tv_AfterSelect(object sender, TreeViewEventArgs e) { TreeView tv = (TreeView)sender; if (tv.SelectedNode != null) { if (tv.SelectedNode.Name == "root") { partName = ""; selectedFileName = uint.MaxValue; } else { uint nm = uint.Parse(tv.SelectedNode.Name); if (selectedFileName != nm) { partName = tv.SelectedNode.Name; selectedFileName = nm; IDefinition def = vexObjects[this.fileIndex].Definitions[selectedFileName]; WPFRenderer wpfr = new WPFRenderer(); string xamlFileName; wpfr.GenerateXamlPart(vexObjects[this.fileIndex], def, out xamlFileName); Silverlight10Renderer slfr = new Silverlight10Renderer(); string slFileName; slfr.GenerateXamlPart(vexObjects[this.fileIndex], def, out slFileName); } } RefreshContentPane(); } }
public static string Convert( bool isSilverlight, SwfCompilationUnit scu, VexObject v, out string xamlFileName) { string result = "Failed to convert."; SwfToVex s2v = new SwfToVex(); v = s2v.Convert(scu); result = "\n\n**** Converting to Vex ****\n"; result += s2v.Log.ToString(); XamlRenderer xr; if (isSilverlight) { xr = new Silverlight10Renderer(); } else { xr = new WPFRenderer(); } xr.GenerateXaml(v, out xamlFileName); result += "\n\n**** Converting to Xaml ****\n"; result += xr.Log.ToString(); result += "\n\nSuccess."; return result; }
private void ExportXAML(object sender, EventArgs e) { string path = CurrentStage.ExportFolderFull; string xamlFileName; MLRenderer xr = new WPFRenderer(); xr.GenerateML(currentStage.vexObject, path, out xamlFileName); }
public static string Convert( string fileName, bool isSilverlight, out SwfCompilationUnit scu, out VexObject v, out string xamlFileName) { string result = "Failed to convert."; FileStream fs = new FileStream(fileName, FileMode.Open, FileAccess.Read); BinaryReader br = new BinaryReader(fs); string name = Path.GetFileNameWithoutExtension(fileName); SwfReader r = new SwfReader(br.ReadBytes((int)fs.Length)); scu = new SwfCompilationUnit(r, name); if (scu.IsValid) { result = "\n\n**** Converting to SwfCompilationUnit ****\n"; #if DEBUG StringWriter sw = new StringWriter(); IndentedTextWriter w = new IndentedTextWriter(sw); scu.Dump(w); Debug.WriteLine(sw.ToString()); #endif result += scu.Log.ToString(); SwfToVex s2v = new SwfToVex(); v = s2v.Convert(scu); result += "\n\n**** Converting to Vex ****\n"; result += s2v.Log.ToString(); XamlRenderer xr; if (isSilverlight) { xr = new Silverlight10Renderer(); } else { xr = new WPFRenderer(); } xr.GenerateXaml(v, out xamlFileName); result += "\n\n**** Converting to Xaml ****\n"; result += xr.Log.ToString(); result += "\n\nSuccess."; } else { result = "Not a valid swf file: " + fileName; v = null; xamlFileName = ""; } return result; }
//public static GdiForm gf; static void Main(string[] args) { string fileName = "test14.swf"; if (args.Length > 0) { fileName = args[0]; } FileStream fs = new FileStream(fileName, FileMode.Open, FileAccess.Read); BinaryReader br = new BinaryReader(fs); SwfReader r = new SwfReader(br.ReadBytes((int)fs.Length)); SwfCompilationUnit scu = new SwfCompilationUnit(r); //StringWriter sw = new StringWriter(); //IndentedTextWriter w = new IndentedTextWriter(sw); //scu.Dump(w); //Debug.WriteLine(sw.ToString()); SwfToVex s2v = new SwfToVex(); VexObject v = s2v.Convert(scu); XamlRenderer xr = new WPFRenderer(); xr.GenerateXaml(v); //GdiRenderer gr = new GdiRenderer(); //List<Bitmap> bmps = gr.GenerateBitmaps(v); ////gr.ExportBitmaps(bmps); //gf = new GdiForm(bmps); //Application.EnableVisualStyles(); //Application.Run(gf); }
private void mnuFilePrint_Click(object sender, RoutedEventArgs e) { PrintDialog pDlg = new PrintDialog(); if (pDlg.ShowDialog() == true) { WPFRenderer renderer = new WPFRenderer(); renderer.Begin(); circuitDisplay.Document.Render(renderer); renderer.End(); FixedDocument document = renderer.GetDocument(new Size(pDlg.PrintableAreaWidth, pDlg.PrintableAreaHeight)); pDlg.PrintDocument(document.DocumentPaginator, m_documentTitle + " - Circuit Diagram"); } }
private void mnuFileExport_Click(object sender, RoutedEventArgs e) { Microsoft.Win32.SaveFileDialog sfd = new Microsoft.Win32.SaveFileDialog(); sfd.Title = "Export"; string filter = "PNG (*.png)|*.png|Scalable Vector Graphics (*.svg)|*.svg|XPS (*.xps)|*.xps"; // Add plugin exporters foreach (IDocumentWriter pluginWriter in PluginManager.EnabledExportWriters) filter += String.Format("|{0} (*{1})|*{1}", pluginWriter.FileTypeName, pluginWriter.FileTypeExtension); sfd.Filter = filter; sfd.InitialDirectory = Environment.SpecialFolder.MyDocuments.ToString(); if (sfd.ShowDialog() == true) { string extension = System.IO.Path.GetExtension(sfd.FileName); if (extension == ".svg") { SVGRenderer renderer = new SVGRenderer(circuitDisplay.Document.Size.Width, circuitDisplay.Document.Size.Height); renderer.Begin(); circuitDisplay.Document.Render(renderer); renderer.End(); System.IO.File.WriteAllBytes(sfd.FileName, renderer.SVGDocument.ToArray()); } else if (extension == ".png") { winExportPNG exportPNGWindow = new winExportPNG(); exportPNGWindow.Owner = this; exportPNGWindow.OriginalWidth = circuitDisplay.Width; exportPNGWindow.OriginalHeight = circuitDisplay.Height; exportPNGWindow.Update(); if (exportPNGWindow.ShowDialog() == true) { WPFRenderer renderer = new WPFRenderer(); renderer.Begin(); circuitDisplay.Document.Render(renderer); renderer.End(); using (var memoryStream = renderer.GetPNGImage2(exportPNGWindow.OutputWidth, exportPNGWindow.OutputHeight, circuitDisplay.Document.Size.Width, circuitDisplay.Document.Size.Height, exportPNGWindow.OutputBackgroundColour == "White")) { FileStream fileStream = new FileStream(sfd.FileName, FileMode.Create, FileAccess.Write, FileShare.Read); memoryStream.WriteTo(fileStream); fileStream.Close(); } } } else if (extension == ".xps") { WPFRenderer renderer = new WPFRenderer(); renderer.Begin(); circuitDisplay.Document.Render(renderer); renderer.End(); FixedDocument doc = renderer.GetDocument(new Size(circuitDisplay.Document.Size.Width, circuitDisplay.Document.Size.Height)); using (XpsDocument xdoc = new XpsDocument(sfd.FileName, FileAccess.Write)) { XpsDocumentWriter writer = XpsDocument.CreateXpsDocumentWriter(xdoc); writer.Write(doc.DocumentPaginator); } } else if (extension == ".emf") // Disabled { EMFRenderer renderer = new EMFRenderer((int)circuitDisplay.Document.Size.Width, (int)circuitDisplay.Document.Size.Height); renderer.Begin(); circuitDisplay.Document.Render(renderer); renderer.End(); using (FileStream stream = new FileStream(sfd.FileName, FileMode.Create, FileAccess.Write, FileShare.Read)) { renderer.WriteEnhMetafile(stream); } } else { // Create the document writer IDocumentWriter writer = PluginManager.EnabledExportWriters[sfd.FilterIndex - 3]; IDictionary<IOComponentType, EmbedComponentData> embedComponents = new Dictionary<IOComponentType, EmbedComponentData>(); if (writer is IElementDocumentWriter) (writer as IElementDocumentWriter).Document = circuitDisplay.Document.ToIODocument(out embedComponents); writer.Begin(); if (writer is IVisualDocumentWriter) { (writer as IVisualDocumentWriter).RenderContext.Begin(); circuitDisplay.Document.Render((writer as IVisualDocumentWriter).RenderContext); (writer as IVisualDocumentWriter).RenderContext.End(); } using (FileStream stream = new FileStream(sfd.FileName, FileMode.Create, FileAccess.Write, FileShare.Read)) { writer.Write(stream); } writer.End(); } } }