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 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; }
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(); } }