Esempio n. 1
0
        public static string Convert(string fileName, out SwfCompilationUnit scu, out VexObject v)
        {
            v = null;
            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();
            }
            return result;
        }
Esempio n. 2
0
        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;
        }