Пример #1
0
 public void AddShapes(VexObject vo, IDefinition def, Matrix m)
 {
     if (def.Name == "circleShape")
     {
         //Matrix m = orgInst.Transformations[0].Matrix;
         Point c = new Point(m.TranslateX, m.TranslateY);
         float r = m.ScaleX * 100 / 2;
         Shapes.Add(new CircleShape2D(def.Name, c, r));
     }
     else if (def is Symbol)
     {
         //Matrix m = orgInst.Transformations[0].Matrix;
         AddShape(def.Name, (Symbol)def, m);
     }
     else if (def is Timeline)
     {
         foreach (Instance inst in ((Timeline)def).Instances)
         {
             IDefinition def2 = vo.Definitions[inst.DefinitionId];
             if (def2 is Symbol && (def2.UserData & (int)DefinitionKind.OutlineStroke) != 0)
             {
                 //todo: Symbol may have multiple Shapes, and only one/some are red outlines
                 //Matrix m = inst.Transformations[0].Matrix;
                 AddShape(def.Name, (Symbol)def2, inst.Transformations[0].Matrix);
             }
         }
     }
 }
Пример #2
0
        public override void GenerateMLPart(VexObject v, IDefinition def, out string fileName)
        {
            this.v   = v;
            this.Log = new StringBuilder();
            fileName = Directory.GetCurrentDirectory() + "/" + v.Name + "_" + def.Id + ".svg";
            xw       = new XamlWriter(fileName, Encoding.UTF8);

            xw.WriteComment(headerComment);

            xw.OpenHeaderTag(def.StrokeBounds.Size.Width, def.StrokeBounds.Size.Height, v.BackgroundColor);

            Dictionary <uint, IDefinition> defList = new Dictionary <uint, IDefinition>();

            defList.Add(1, def);
            WriteDefinitions(defList, true, true);

            //WriteTimelineDefiniton(v.Root, true);
            // Write a rectangle to hold this shape
            Instance inst = new Instance();

            inst.Name         = instancePrefix + def.Id;
            inst.InstanceHash = 1;
            inst.DefinitionId = def.Id;
            inst.Transformations.Add(new Transform(0, 1000, Matrix.Identity, 1, ColorTransform.Identity));
            WriteInstance(def, inst);

            xw.CloseTagAndFlush();

            xw.Close();
        }
Пример #3
0
        public void Convert(VexObject vo, DDW.Swf.SwfCompilationUnit scu)
        {
            curVo = vo;
            if (V2D.OUTPUT_TYPE == OutputType.Xna)
            {
                Gdi.GdiRenderer             gr   = new Gdi.GdiRenderer();
                Dictionary <string, Bitmap> bmps = gr.GenerateTimelineMappedBitmaps(vo);
                paths = gr.ExportBitmaps(bmps);
            }

            Init(scu);
            ParseActions(scu);
            ParseRootTimeline();
            GenerateActionData();
            GenerateJointData();

            string path = scu.FullPath;

            if (V2D.OUTPUT_TYPE == OutputType.Swf)
            {
                path = path.Replace(".swf", ".as");
                GenActionscript gas = new GenActionscript(this, path);
            }
            else
            {
                path = path.Replace(".swf", ".xml");
                GenXNA gx = new GenXNA(this, path, paths);
            }
        }
Пример #4
0
 public ConversionObjects(SwfCompilationUnit scu, VexObject v, string xamlFileName, string message)
 {
     this.scu          = scu;
     this.v            = v;
     this.xamlFileName = xamlFileName;
     this.message      = message;
 }
Пример #5
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);
        }
Пример #6
0
        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;
        }
Пример #7
0
        public override void GenerateXaml(VexObject v, out string xamlFileName)
        {
            this.v       = v;
            this.Log     = new StringBuilder();
            xamlFileName = Directory.GetCurrentDirectory() + "/" + v.Name + ".xaml";
            xw           = new XamlWriter(xamlFileName, Encoding.UTF8);

            xw.WriteComment(headerComment);

#if (IS_TRIAL)
            // turn off watermarking for small files
            isWatermarking = true;
            xw.WriteComment(trialComment);
            if (v.Definitions.Count < 15)
            {
                isWatermarking = false;
            }
#else
            isWatermarking = false;
#endif

            xw.OpenHeaderTag(v.ViewPort.Size.Width, v.ViewPort.Size.Height, v.BackgroundColor);

            WriteDefinitions(v.Definitions, true, false);

            WriteTimelineDefiniton(v.Root, true);

            xw.CloseHeaderTag();

            xw.Close();
        }
Пример #8
0
        public List <Bitmap> GenerateBitmaps(VexObject v)
        {
            List <Bitmap>             result = new List <Bitmap>();
            Dictionary <uint, Bitmap> dbmp   = GenerateMappedBitmaps(v, false);

            result.AddRange(dbmp.Values);
            return(result);
        }
Пример #9
0
        private void DrawBackground(VexObject v)
        {
            Brush      b = new SolidBrush(this.GetColor(v.BackgroundColor));
            RectangleF r = new RectangleF(
                v.ViewPort.Point.X,
                v.ViewPort.Point.X,
                v.ViewPort.Size.Width,
                v.ViewPort.Size.Height);

            g.FillRectangle(b, r);
        }
Пример #10
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;
        }
Пример #11
0
        public static VexTree ProcessSwf(SwfCompilationUnit scu)
        {
            VexTree result = null;

            if (scu.IsValid)
            {
                SwfToVex  s2v = new SwfToVex();
                VexObject vo  = s2v.Convert(scu);
                result = new VexTree();
                result.Convert(vo, scu);
            }
            return(result);
        }
Пример #12
0
        public override void GenerateMLPart(VexObject v, IDefinition def, out string resultFileName)
        {
            this.v   = v;
            this.Log = new StringBuilder();
            string baseFileName = Directory.GetCurrentDirectory() +
                                  "/" +
                                  v.Name +
                                  SILVERLIGHT_SUFFIX +
                                  "_" + def.Id;

            resultFileName = baseFileName + ".html";
            string xamlFileName = baseFileName + ".xaml";

            xw = new XamlWriter(xamlFileName, Encoding.UTF8);

            xw.WriteComment(headerComment);

#if (IS_TRIAL)
            // turn off watermarking for small files
            isWatermarking = true;
            xw.WriteComment(trialComment);
            if (v.Definitions.Count < 15)
            {
                isWatermarking = false;
            }
#else
            isWatermarking = false;
#endif

            xw.OpenHeaderTag(def.StrokeBounds.Size.Width, def.StrokeBounds.Size.Height, v.BackgroundColor);

            Dictionary <uint, IDefinition> defList = new Dictionary <uint, IDefinition>();
            defList.Add(1, def);
            AddImagesPart(defList, true);

            //WriteTimelineDefiniton(v.Root, true);
            // Write a rectangle to hold this shape
            Instance inst = new Instance();
            inst.Name         = instancePrefix + def.Id;
            inst.InstanceHash = 1;
            inst.DefinitionId = def.Id;
            inst.Transformations.Add(new Transform(0, 1000, Matrix.Identity, 1, ColorTransform.Identity));
            WriteInstance(def, inst, true);

            xw.CloseTagAndFlush();

            xw.Close();

            WriteSilverlightHtml(v, resultFileName);
        }
Пример #13
0
        public void Convert(VexObject vo, DDW.Swf.SwfCompilationUnit scu)
        {
            curVo    = vo;
            this.scu = scu;
            Init();
            FilterMarkers();
            ParseActions();
            ParseTimeline(curVo.Root);
            GenerateWorldActionData(); // temp
            GenerateBitamps();

            //genV2d = new GenV2DWorld(this, paths);
            //genV2d.Generate();
        }
Пример #14
0
        public DrawObject(VexObject vo)
        {
            List <Image>    allImages    = vo.GetAllImages();
            List <Symbol>   allSymbols   = vo.GetAllSymbols();
            List <Timeline> allTimelines = vo.GetAllTimelines();

            GenerateNameTables(allTimelines);
            //GetColorNames(allSymbols);

            GetFillsAndStrokes(allSymbols);
            GetDrawSymbols(allSymbols);
            GetDrawImages(allImages);
            GetDrawTimelines(allTimelines);
        }
Пример #15
0
        public bool HasSymbols(VexObject v, Timeline tl)
        {
            bool result = false;

            for (int i = 0; i < tl.Instances.Count; i++)
            {
                if (v.Definitions[tl.Instances[i].DefinitionId] is Symbol)
                {
                    result = true;
                    break;
                }
            }
            return(result);
        }
Пример #16
0
        public static V2DContentHolder UilToV2DContent(string path, ContentProcessorContext context)
        {
            V2DContentHolder result = null;

            VexObject vo = LoadFromUIL.Load(path);
            VexTree   vt = new VexTree();

            vt.Convert(vo, null);
            vt.WriteToXml();

            result = vt.GetV2DContent(context);

            return(result);
        }
Пример #17
0
 private void DrawTimeline(VexObject v, Timeline tl)
 {
     for (int i = 0; i < tl.Instances.Count; i++)
     {
         IDefinition def = v.Definitions[tl.Instances[i].DefinitionId];
         if (def is Symbol)
         {
             DrawSymbol((Symbol)def);
         }
         else if (def is Timeline)
         {
             DrawTimeline(v, (Timeline)def);
         }
     }
 }
Пример #18
0
        private bool HasShape(VexObject vo, Timeline tl)
        {
            bool result = false;

            foreach (IInstance inst in tl.Instances)
            {
                IDefinition def = vo.Definitions[inst.DefinitionId];
                if (IsShapeDef(def))
                {
                    result = true;
                    break;
                }
            }
            return(result);
        }
Пример #19
0
        public static V2DContentHolder SwfToV2DContent(SwfCompilationUnit scu, ContentProcessorContext context)
        {
            V2DContentHolder result = null;

            if (scu.IsValid)
            {
                SwfToVex  s2v = new SwfToVex();
                VexObject vo  = s2v.Convert(scu);
                VexTree   vt  = new VexTree();
                vt.Convert(vo, scu);
                vt.WriteToXml();

                result = vt.GetV2DContent(context);
            }
            return(result);
        }
Пример #20
0
        public override void GenerateML(VexObject v, string path, out string resultFileName)
        {
            if (!Directory.Exists(path))
            {
                Directory.CreateDirectory(path);
            }

            this.v   = v;
            this.Log = new StringBuilder();
            string baseFileName =
                path +
                v.Name +
                SILVERLIGHT_SUFFIX;

            baseFileName.Replace('\\', '/');

            resultFileName = baseFileName + ".html";
            string xamlFileName = baseFileName + ".xaml";

            xw = new XamlWriter(xamlFileName, Encoding.UTF8);

            xw.WriteComment(headerComment);

#if (IS_TRIAL)
            // turn off watermarking for small files
            isWatermarking = true;
            xw.WriteComment(trialComment);
            if (v.Definitions.Count < 15)
            {
                isWatermarking = false;
            }
#else
            isWatermarking = false;
#endif

            xw.OpenHeaderTag(v.ViewPort.Size.Width, v.ViewPort.Size.Height, v.BackgroundColor);

            AddImages(v.Definitions, true);

            WriteTimelineDefiniton(v.Root, true);

            xw.CloseTagAndFlush();

            xw.Close();

            WriteSilverlightHtml(v, resultFileName);
        }
Пример #21
0
 private static void DumpTextObject(VexObject vo)
 {
     foreach (uint key in vo.Definitions.Keys)
     {
         IDefinition def = vo.Definitions[key];
         if (def is Text)
         {
             string s = "";
             Text   t = (Text)def;
             for (int i = 0; i < t.TextRuns.Count; i++)
             {
                 s += t.TextRuns[i].Text;
             }
             Console.WriteLine(s);
         }
     }
 }
Пример #22
0
 private void DrawFilteredTimeline(VexObject v, Timeline tl)
 {
     for (int i = 0; i < tl.Instances.Count; i++)
     {
         Instance    inst = (Instance)tl.Instances[i];
         IDefinition def  = v.Definitions[inst.DefinitionId];
         if (def is Symbol)
         {
             DrawFilteredSymbol((Symbol)def);
         }
         else if (def is Timeline)
         {
             DrawFilteredTimeline(v, (Timeline)def);
         }
         else if (def is Text)
         {
             DrawText((Text)def, inst.Transformations[0].Matrix);
         }
     }
 }
Пример #23
0
        public void GenerateJsonData(VexObject vo, string path, out string filename)
        {
            StringBuilder sb = new StringBuilder();

            if (!Directory.Exists(path))
            {
                Directory.CreateDirectory(path);
            }

            DrawObject drawObject = new DrawObject(vo);

            drawObject.ToJson(sb);

            string dataName = vo.Name + "Data";
            string prefix   = "var " + dataName + " = ";
            string suffix   = "\n;\nvar data = " + dataName + ";\n";

            filename = path + dataName + ".js";
            File.WriteAllText(filename, prefix + sb.ToString() + suffix);
        }
Пример #24
0
        public void Convert(VexObject vo, DDW.Swf.SwfCompilationUnit scu)
        {
            curVo = vo;
            Init(scu);
            FilterMarkers();
            ParseActions(scu);
            ParseRootTimeline();
            ParseNamedDefinitions();
            GenerateWorldActionData();

            Gdi.GdiRenderer gr = new Gdi.GdiRenderer();
            Dictionary <string, List <Bitmap> > bmps = new Dictionary <string, List <Bitmap> >();

            gr.GenerateFilteredBitmaps(vo, usedImages, bmps);

            gr.ExportBitmapsAsPremultiplied(bmps);

            genV2d = new GenV2DWorld(this, usedImages);
            genV2d.Generate();
        }
Пример #25
0
        private Timeline GetNamedSymbol(VexObject v, Timeline tl)
        {
            Timeline result = null;

            if (tl.Name != "")
            {
                result = tl;
            }
            else
            {
                for (int i = 0; i < tl.Instances.Count; i++)
                {
                    uint defId = tl.Instances[i].DefinitionId;
                    if (v.Definitions[defId] is Timeline && ((Timeline)v.Definitions[defId]).Name != "")
                    {
                        result = (Timeline)(v.Definitions[defId]);
                    }
                }
            }

            return(result);
        }
Пример #26
0
        protected void WriteSilverlightHtml(VexObject v, string fileName)
        {
            using (TextWriter tw = new StreamWriter(fileName))
            {
                tw.WriteLine(@"<!DOCTYPE html PUBLIC ""-//W3C//DTD XHTML 1.0 Transitional//EN"" ""http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"">");
                tw.WriteLine(@"<html xmlns=""http://www.w3.org/1999/xhtml"" xml:lang=""en"">");
                tw.WriteLine(@" <head>");
                tw.WriteLine(@"   <title>Silverlight</title>");
                tw.WriteLine(@"   <script type=""text/javascript"">");
                tw.WriteLine(@"    if(!window.Silverlight)window.Silverlight={};Silverlight._silverlightCount=0;Silverlight.ua=null;Silverlight.available=false;Silverlight.fwlinkRoot=""http://go.microsoft.com/fwlink/?LinkID="";Silverlight.StatusText=""Get Microsoft Silverlight"";Silverlight.EmptyText="""";Silverlight.detectUserAgent=function(){var a=window.navigator.userAgent;Silverlight.ua={OS:""Unsupported"",Browser:""Unsupported""};if(a.indexOf(""Windows NT"")>=0)Silverlight.ua.OS=""Windows"";else if(a.indexOf(""PPC Mac OS X"")>=0)Silverlight.ua.OS=""MacPPC"";else if(a.indexOf(""Intel Mac OS X"")>=0)Silverlight.ua.OS=""MacIntel"";if(Silverlight.ua.OS!=""Unsupported"")if(a.indexOf(""MSIE"")>=0){if(navigator.userAgent.indexOf(""Win64"")==-1)if(parseInt(a.split(""MSIE"")[1])>=6)Silverlight.ua.Browser=""MSIE""}else if(a.indexOf(""Firefox"")>=0){var b=a.split(""Firefox/"")[1].split("".""),c=parseInt(b[0]);if(c>=2)Silverlight.ua.Browser=""Firefox"";else{var d=parseInt(b[1]);if(c==1&&d>=5)Silverlight.ua.Browser=""Firefox""}}else if(a.indexOf(""Safari"")>=0)Silverlight.ua.Browser=""Safari""};Silverlight.detectUserAgent();Silverlight.isInstalled=function(d){var c=false,a=null;try{var b=null;if(Silverlight.ua.Browser==""MSIE"")b=new ActiveXObject(""AgControl.AgControl"");else if(navigator.plugins[""Silverlight Plug-In""]){a=document.createElement(""div"");document.body.appendChild(a);a.innerHTML='<embed type=""application/x-silverlight"" />';b=a.childNodes[0]}if(b.IsVersionSupported(d))c=true;b=null;Silverlight.available=true}catch(e){c=false}if(a)document.body.removeChild(a);return c};Silverlight.createObject=function(l,g,m,j,k,i,h){var b={},a=j,c=k;a.source=l;b.parentElement=g;b.id=Silverlight.HtmlAttributeEncode(m);b.width=Silverlight.HtmlAttributeEncode(a.width);b.height=Silverlight.HtmlAttributeEncode(a.height);b.ignoreBrowserVer=Boolean(a.ignoreBrowserVer);b.inplaceInstallPrompt=Boolean(a.inplaceInstallPrompt);var e=a.version.split(""."");b.shortVer=e[0]+"".""+e[1];b.version=a.version;a.initParams=i;a.windowless=a.isWindowless;a.maxFramerate=a.framerate;for(var d in c)if(c[d]&&d!=""onLoad""&&d!=""onError""){a[d]=c[d];c[d]=null}delete a.width;delete a.height;delete a.id;delete a.onLoad;delete a.onError;delete a.ignoreBrowserVer;delete a.inplaceInstallPrompt;delete a.version;delete a.isWindowless;delete a.framerate;if(Silverlight.isInstalled(b.version)){if(Silverlight._silverlightCount==0)if(window.addEventListener)window.addEventListener(""onunload"",Silverlight.__cleanup,false);else window.attachEvent(""onunload"",Silverlight.__cleanup);var f=Silverlight._silverlightCount++;a.onLoad=""__slLoad""+f;a.onError=""__slError""+f;window[a.onLoad]=function(a){if(c.onLoad)c.onLoad(document.getElementById(b.id),h,a)};window[a.onError]=function(a,b){if(c.onError)c.onError(a,b);else Silverlight.default_error_handler(a,b)};slPluginHTML=Silverlight.buildHTML(b,a)}else slPluginHTML=Silverlight.buildPromptHTML(b);if(b.parentElement)b.parentElement.innerHTML=slPluginHTML;else return slPluginHTML};Silverlight.supportedUserAgent=function(){var a=Silverlight.ua,b=a.OS==""Unsupported""||a.Browser==""Unsupported""||a.OS==""Windows""&&a.Browser==""Safari""||a.OS.indexOf(""Mac"")>=0&&a.Browser==""IE"";return !b};Silverlight.buildHTML=function(c,d){var a=[],e,i,g,f,h;if(Silverlight.ua.Browser==""Safari""){a.push(""<embed "");e="""";i="" "";g='=""';f='""';h=' type=""application/x-silverlight""/>'+""<iframe style='visibility:hidden;height:0;width:0'/>""}else{a.push('<object type=""application/x-silverlight""');e="">"";i=' <param name=""';g='"" value=""';f='"" />';h=""</object>""}a.push(' id=""'+c.id+'"" width=""'+c.width+'"" height=""'+c.height+'"" '+e);for(var b in d)if(d[b])a.push(i+Silverlight.HtmlAttributeEncode(b)+g+Silverlight.HtmlAttributeEncode(d[b])+f);a.push(h);return a.join("""")};Silverlight.default_error_handler=function(e,b){var d,c=b.ErrorType;d=b.ErrorCode;var a=""\nSilverlight error message     \n"";a+=""ErrorCode: ""+d+""\n"";a+=""ErrorType: ""+c+""       \n"";a+=""Message: ""+b.ErrorMessage+""     \n"";if(c==""ParserError""){a+=""XamlFile: ""+b.xamlFile+""     \n"";a+=""Line: ""+b.lineNumber+""     \n"";a+=""Position: ""+b.charPosition+""     \n""}else if(c==""RuntimeError""){if(b.lineNumber!=0){a+=""Line: ""+b.lineNumber+""     \n"";a+=""Position: ""+b.charPosition+""     \n""}a+=""MethodName: ""+b.methodName+""     \n""}alert(a)};Silverlight.createObjectEx=function(b){var a=b,c=Silverlight.createObject(a.source,a.parentElement,a.id,a.properties,a.events,a.initParams,a.context);if(a.parentElement==null)return c};Silverlight.buildPromptHTML=function(i){var a=null,f=Silverlight.fwlinkRoot,c=Silverlight.ua.OS,b=""92822"",d;if(i.inplaceInstallPrompt){var h;if(Silverlight.available){d=""94376"";h=""94382""}else{d=""92802"";h=""94381""}var g=""93481"",e=""93483"";if(c==""Windows""){b=""92799"";g=""92803"";e=""92805""}else if(c==""MacIntel""){b=""92808"";g=""92804"";e=""92806""}else if(c==""MacPPC""){b=""92807"";g=""92815"";e=""92816""}a='<table border=""0"" cellpadding=""0"" cellspacing=""0"" width=""205px""><tr><td><img title=""Get Microsoft Silverlight"" onclick=""javascript:Silverlight.followFWLink({0});"" style=""border:0; cursor:pointer"" src=""{1}""/></td></tr><tr><td style=""background:#C7C7BD; text-align: center; color: black; font-family: Verdana; font-size: 9px; padding-bottom: 0.05cm; ;padding-top: 0.05cm"" >By clicking <b>Get Microsoft Silverlight</b> you accept the <a title=""Silverlight License Agreement"" href=""{2}"" target=""_top"" style=""text-decoration: underline; color: #36A6C6""><b>Silverlight license agreement</b></a>.</td></tr><tr><td style=""border-left-style: solid; border-right-style: solid; border-width: 2px; border-color:#c7c7bd; background: #817d77; color: #FFFFFF; text-align: center; font-family: Verdana; font-size: 9px"">Silverlight updates automatically, <a title=""Silverlight Privacy Statement"" href=""{3}"" target=""_top"" style=""text-decoration: underline; color: #36A6C6""><b>learn more</b></a>.</td></tr><tr><td><img src=""{4}""/></td></tr></table>';a=a.replace(""{2}"",f+g);a=a.replace(""{3}"",f+e);a=a.replace(""{4}"",f+h)}else{if(Silverlight.available)d=""94377"";else d=""92801"";if(c==""Windows"")b=""92800"";else if(c==""MacIntel"")b=""92812"";else if(c==""MacPPC"")b=""92811"";a='<div style=""width: 205px; height: 67px; background-color: #FFFFFF""><img onclick=""javascript:Silverlight.followFWLink({0});"" style=""border:0; cursor:pointer"" src=""{1}"" alt=""Get Microsoft Silverlight""/></div>'}a=a.replace(""{0}"",b);a=a.replace(""{1}"",f+d);return a};Silverlight.__cleanup=function(){for(var a=Silverlight._silverlightCount-1;a>=0;a--){window[""__slLoad""+a]=null;window[""__slError""+a]=null}if(window.removeEventListener)window.removeEventListener(""unload"",Silverlight.__cleanup,false);else window.detachEvent(""onunload"",Silverlight.__cleanup)};Silverlight.followFWLink=function(a){top.location=Silverlight.fwlinkRoot+String(a)};Silverlight.HtmlAttributeEncode=function(c){var a,b="""";if(c==null)return null;for(var d=0;d<c.length;d++){a=c.charCodeAt(d);if(a>96&&a<123||a>64&&a<91||a>43&&a<58&&a!=47||a==95)b=b+String.fromCharCode(a);else b=b+""&#""+a+"";""}return b}");

                tw.Write(@"    function createMySilverlightPlugin(){Silverlight.createObject(""");
                int    index    = fileName.LastIndexOf(v.Name);
                string xamlName = fileName.Substring(index);
                xamlName = xamlName.Replace(".html", ".xaml");
                tw.Write(xamlName);                               // name
                tw.Write(@""",parentElement,""mySilverlightPlugin"",{width:'");
                tw.Write(v.ViewPort.Size.Width);                  // width
                tw.Write(@"',height:'");
                tw.Write(v.ViewPort.Size.Height);                 // height
                tw.Write(@"',inplaceInstallPrompt:true,background:'#");
                tw.Write(v.BackgroundColor.Value.ToString("X6")); // color
                tw.Write(@"',isWindowless:'false',framerate:'");
                tw.Write(v.FrameRate);                            // frame rate
                tw.WriteLine(@"',version:'1.0'},{onError:null,onLoad:null},null);}");

                tw.WriteLine(@"   </script>");
                tw.WriteLine(@" </head>");
                tw.WriteLine(@" <body>");
                tw.WriteLine(@"	 <div id=""mySilverlightPluginHost""> </div>");
                tw.WriteLine(@"	 <script type=""text/javascript"">");
                tw.WriteLine(@"	 var parentElement = document.getElementById(""mySilverlightPluginHost"");");
                tw.WriteLine(@"	 createMySilverlightPlugin();");
                tw.WriteLine(@"	 </script>");
                tw.WriteLine(@" </body>");
                tw.WriteLine(@"</html>");
            }
        }
Пример #27
0
        public void GenerateBinaryData(VexObject vo, string path, out string filename)
        {
            string dataName = vo.Name + "Data";

            filename = path + dataName + ".dat";

            if (!Directory.Exists(path))
            {
                Directory.CreateDirectory(path);
            }

            FileStream    stream = new FileStream(filename, FileMode.Create);
            VexDrawWriter writer = new VexDrawWriter(stream);

            DrawObject drawObject = new DrawObject(vo);

            writer.WriteDrawObject(drawObject);

            stream.Flush();

            //byte[] bytes = stream.ToArray();
            stream.Close();
        }
Пример #28
0
        /// <summary>
        /// Generates a dictionary of Symbol id and rendered bitmap.
        /// </summary>
        /// <param name="v"></param>
        /// <returns></returns>
        public Dictionary <uint, Bitmap> GenerateMappedBitmaps(VexObject v, bool includeImages)
        {
            Dictionary <uint, Bitmap> result = new Dictionary <uint, Bitmap>();

            foreach (uint key in v.Definitions.Keys)
            {
                IDefinition def = v.Definitions[key];
                if (def is Symbol)
                {
                    Symbol symbol   = (Symbol)def;
                    Bitmap myBitmap = new Bitmap(
                        (int)symbol.StrokeBounds.Size.Width + 1,
                        (int)symbol.StrokeBounds.Size.Height + 1);
                    myBitmap.SetResolution(96, 96);

                    translateMatrix = new System.Drawing.Drawing2D.Matrix(
                        1, 0, 0, 1, -symbol.StrokeBounds.Point.X, -symbol.StrokeBounds.Point.Y);
                    g = Graphics.FromImage(myBitmap);
                    g.SmoothingMode      = SmoothingMode.AntiAlias;
                    g.InterpolationMode  = InterpolationMode.HighQualityBicubic;
                    g.CompositingMode    = CompositingMode.SourceOver;
                    g.CompositingQuality = CompositingQuality.AssumeLinear;

                    DrawSymbol(symbol);

                    result.Add(symbol.Id, myBitmap);
                    translateMatrix.Dispose();
                }
                else if (includeImages && def is Vex.Image)
                {
                    Bitmap bmp = new Bitmap(def.Path);
                    result.Add(def.Id, bmp);
                }
            }
            return(result);
        }
Пример #29
0
        public override void GenerateML(VexObject v, string path, out string mlFileName)
        {
            if (!Directory.Exists(path))
            {
                Directory.CreateDirectory(path);
            }

            this.v     = v;
            this.Log   = new StringBuilder();
            mlFileName = path + v.Name + ".svg";
            xw         = new SvgWriter(mlFileName, Encoding.UTF8);

            xw.WriteComment(headerComment);

            xw.OpenHeaderTag(v.ViewPort.Size.Width, v.ViewPort.Size.Height, v.BackgroundColor);

            WriteDefinitions(v.Definitions, true, false);

            WriteTimelineDefiniton(v.Root, true);

            xw.CloseTagAndFlush();

            xw.Close();
        }
Пример #30
0
        //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);
        }