示例#1
0
        /// <summary>
        /// This is a javascript application.
        /// </summary>
        /// <param name="page">HTML document rendered by the web server which can now be enhanced.</param>
        public Application(IApp page)
        {
            Console.WriteLine("Application ctor");

            if (page != null)
            {
                if (page.Content != null)
                {
                    if (page.Content.childNodes.Length == 0)
                    {
                        var f = new IFunction("");

                        f.apply(null);

                        ApplicationWebService service = new ApplicationWebService();

                        ApplicationSprite sprite = new ApplicationSprite();

                        sprite.AutoSizeSpriteTo(page.ContentSize);
                        sprite.AttachSpriteTo(page.Content);

                        //Console.WriteLine("init... WhenReady?");

                        //  a.__out_MethodInterface.MgAABkE_bRDa_ancxRw7JDdQ(PQAABosGVzucrRDVfJkoTA(a, b));
                        //sprite.WhenReady(
                        //    delegate
                        //    {
                        //        Console.WriteLine("init... Ready!");
                        //    }
                        //);

                        return;
                    }
                }
            }

            Console.WriteLine("looking for myself...");
            //Native.Window.alert("now what?");

            //Action yield = delegate
            //{
            //    Console.WriteLine("looking for myself... done!");

            //};
            Native.window.requestAnimationFrame +=
                delegate
            {
                Native.Document.getElementsByTagName("embed").WithEach(
                    e =>
                {
                    var embed = (IHTMLEmbedFlash)e;

                    try
                    {
                        // this is a hack
                        //var sprite = new ApplicationSprite();
                        //object sprite_object = sprite;
                        //dynamic a = sprite_object;

                        //a.__InternalElement = embed;


                        //var sprite = (ApplicationSprite)(object)embed;

                        Console.WriteLine("looking for myself... WhenReady?");

                        Initialize(
                            args =>
                        {
                            embed.CallFunction("WhenReady", new[] { args });
                        }
                            );

                        //sprite.WhenReady(yield);
                    }
                    catch
                    { }
                }
                    );
            };
        }
        /// <summary>
        /// This is a javascript application.
        /// </summary>
        /// <param name="page">HTML document rendered by the web server which can now be enhanced.</param>
        public Application(IApp page)
        {
            Console.WriteLine("Application ctor");

            if (page != null)
                if (page.Content != null)
                    if (page.Content.childNodes.Length == 0)
                    {
                        var f = new IFunction("");

                        f.apply(null);

                        ApplicationWebService service = new ApplicationWebService();

                        ApplicationSprite sprite = new ApplicationSprite();

                        sprite.AutoSizeSpriteTo(page.ContentSize);
                        sprite.AttachSpriteTo(page.Content);

                        //Console.WriteLine("init... WhenReady?");

                        //  a.__out_MethodInterface.MgAABkE_bRDa_ancxRw7JDdQ(PQAABosGVzucrRDVfJkoTA(a, b));
                        //sprite.WhenReady(
                        //    delegate
                        //    {
                        //        Console.WriteLine("init... Ready!");
                        //    }
                        //);

                        return;
                    }

            Console.WriteLine("looking for myself...");
            //Native.Window.alert("now what?");

            //Action yield = delegate
            //{
            //    Console.WriteLine("looking for myself... done!");

            //};
            Native.window.requestAnimationFrame +=
                delegate
                {
                    Native.Document.getElementsByTagName("embed").WithEach(
                        e =>
                        {
                            var embed = (IHTMLEmbedFlash)e;

                            try
                            {

                                // this is a hack
                                //var sprite = new ApplicationSprite();
                                //object sprite_object = sprite;
                                //dynamic a = sprite_object;

                                //a.__InternalElement = embed;


                                //var sprite = (ApplicationSprite)(object)embed;

                                Console.WriteLine("looking for myself... WhenReady?");

                                Initialize(
                                    args =>
                                    {
                                        embed.CallFunction("WhenReady", new[] { args });
                                    }
                                );

                                //sprite.WhenReady(yield);
                            }
                            catch
                            { }
                        }
                    );
                };
        }