コード例 #1
0
        private static void ButtonsForWebService()
        {
            AddButtonForGetTime();

            var url = new IHTMLInput(ScriptCoreLib.Shared.HTMLInputTypeEnum.text, "http://example.com");

            url.AttachToDocument();


            var DownloadData = new IHTMLButton {
                innerText = "DownloadData"
            }.AttachToDocument();

            DownloadData.onclick +=
                delegate
            {
                new AlphaWebService().DownloadData(url.value,
                                                   x =>
                {
                    new IHTMLPre {
                        innerText = url.value + Environment.NewLine + Environment.NewLine + x
                    }.AttachToDocument();
                }
                                                   );
            };
        }
コード例 #2
0
		public UltraApplication(IHTMLElement e)
		{
			new IHTMLDiv { innerHTML = "Hello world" }.AttachToDocument();

			var GetTime = new IHTMLButton { innerText = "GetTime" }.AttachToDocument();

			GetTime.onclick +=
				delegate
				{
					new AlphaWebService().GetTime("[client time]: " + DateTime.Now + " [server time]",
						x =>
						{
							new IHTMLDiv { innerText = x }.AttachToDocument();
						}
					);
				};

			var url = new IHTMLInput(ScriptCoreLib.Shared.HTMLInputTypeEnum.text, "http://example.com");

			url.AttachToDocument();

			
			var DownloadData = new IHTMLButton { innerText = "DownloadData" }.AttachToDocument();

			DownloadData.onclick +=
				delegate
				{
					new AlphaWebService().DownloadData(url.value,
						x =>
						{
							new IHTMLPre { innerText = url.value + Environment.NewLine + Environment.NewLine + x }.AttachToDocument();
						}
					);
				};
		}
コード例 #3
0
        public UltraApplication(IHTMLElement e)
        {
            new IHTMLDiv {
                innerHTML = "Hello world"
            }.AttachToDocument();

            var GetTime = new IHTMLButton {
                innerText = "GetTime"
            }.AttachToDocument();

            GetTime.onclick +=
                delegate
            {
                new AlphaWebService().GetTime("[client time]: " + DateTime.Now + " [server time]",
                                              x =>
                {
                    new IHTMLDiv {
                        innerText = x
                    }.AttachToDocument();
                }
                                              );
            };

            var url = new IHTMLInput(ScriptCoreLib.Shared.HTMLInputTypeEnum.text, "http://example.com");

            url.AttachToDocument();


            var DownloadData = new IHTMLButton {
                innerText = "DownloadData"
            }.AttachToDocument();

            DownloadData.onclick +=
                delegate
            {
                new AlphaWebService().DownloadData(url.value,
                                                   x =>
                {
                    new IHTMLPre {
                        innerText = url.value + Environment.NewLine + Environment.NewLine + x
                    }.AttachToDocument();
                }
                                                   );
            };
        }
コード例 #4
0
		private static void ButtonsForWebService()
		{
			AddButtonForGetTime();

			var url = new IHTMLInput(ScriptCoreLib.Shared.HTMLInputTypeEnum.text, "http://example.com");

			url.AttachToDocument();


			var DownloadData = new IHTMLButton { innerText = "DownloadData" }.AttachToDocument();

			DownloadData.onclick +=
				delegate
				{
					new AlphaWebService().DownloadData(url.value,
						x =>
						{
							new IHTMLPre { innerText = url.value + Environment.NewLine + Environment.NewLine + x }.AttachToDocument();
						}
					);
				};
		}
コード例 #5
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)
        {
            Func<IHTMLAudio, Action<double>> loop = snd =>
            {

                Action iloop = null;

                var r = new IHTMLInput();
                var label = new IHTMLLabel(snd.src, r).AttachToDocument();

                dynamic rr = r;

                rr.type = "range";

                r.AttachToDocument();

                Action newvolume = delegate
                {

                    snd.volume = int.Parse(r.value) / 100;
                };
                r.onchange +=
                    delegate
                    {
                        newvolume();
                    };

                iloop =
                    delegate
                    {
                        Console.WriteLine("at canplaythrough " + new { snd.duration });


                        newvolume();
                        snd.play();


                        snd.onended +=
                            delegate
                            {
                                Console.WriteLine("at onended");

                            };

                        //var xsnd = snd;

                        var xsnd = new IHTMLAudio { src = snd.src };
                        xsnd.autobuffer = true;

                        new ScriptCoreLib.JavaScript.Runtime.Timer(
                            delegate
                            {
                                snd.volume = snd.volume * 0.5;

                                Console.WriteLine("at timer " + new { snd.currentTime, snd.duration });
                                snd = xsnd;
                                iloop();
                            }
                        ).StartTimeout((int)(1000 * snd.duration - 0.8));


                        xsnd.load();
                    };

                snd.autobuffer = true;

                // http://areweplayingyet.org/event-canplaythrough
                Console.WriteLine("waiting for canplaythrough");

                snd.addEventListener(
                      "canplaythrough",
                      new Action(
                          delegate
                          {

                              iloop();
                          }
                      )
                );

                new IHTMLBreak().AttachToDocument();

                return
                    nextvolume =>
                    {


                        r.value = "" + (int)(nextvolume * 100);

                        newvolume();
                    };
            };


            //loop(new helicopter1wav());
            var r0 = loop(new dieselloop());

            var r1 = loop(new dieselloopm5());

            var r2 = loop(new dieselloopm5m5());

            // we need SIN



            var zero = 0;

            var lookup = new[] {
                new double [] {zero, 0, 0},             
                new double [] {0, 0, 1},             
                new double [] {0, 1, 0},             
                new double [] {1, 0, 0},             
            };

            var tween_r0 = NumericEmitter.OfDouble(
                (x, y) =>
                {
                    r0(x);
                }
            );


            var tween_r1 = NumericEmitter.OfDouble(
                (x, y) =>
                {
                    r1(x);
                }
            );

            var tween_r2 = NumericEmitter.OfDouble(
                  (x, y) =>
                  {
                      r2(x);
                  }
              );


            Action masterswitchchanged = delegate
            {
                var masterswitch = int.Parse(page.masterswitch.value);

                Console.WriteLine(
                    new { masterswitch }
                );

                lookup[masterswitch].With(
                    x =>
                    {
                        tween_r0(x[0], 0);
                        tween_r1(x[1], 0);
                        tween_r2(x[2], 0);
                    }
                );
            };
            page.masterswitch.onchange +=
                delegate
                {
                    masterswitchchanged();
                };

            page.masterswitch.value = "" + (lookup.Length - 1);

            masterswitchchanged();
        }
コード例 #6
0
        private void Setup(System.Action done)
        {
            t = new Timer();

            var text = new IHTMLInput(HTMLInputTypeEnum.text);

            text.className = "TalkToOthers";

            text.AttachToDocument();

            text.onkeypress += delegate(IEvent x)
            {
                if (x.IsReturn)
                {
                    this.CurrentSession.IServer_TalkToOthers(text.value);
                    this.DisplayNotification(text.value, Color.Blue);

                    text.value = "";
                }
            };

            text.style.zIndex = 1000;

            //Native.Document.body.DisableContextMenu();

            //CreateRotatingTank(96 + 48 * 7, 96 + 48 * 1, t, "tree_1", 383, 392);
            //CreateRotatingTank(96 + 48 * 1, 96 + 48 * 2, t, "tank_1", 308, 339);

            int u = 7;
            System.Action idone = null;

            System.Action<System.Action> adone = delegate(System.Action x)
            {
                if (x != null)
                    idone += x;
                u--;

                if (u == 0)
                {
                    if (idone != null)
                    {
                        idone();
                        idone = null;
                    }

                    //done();

                    //t.StartInterval(100);
                }
            };

            done();
            t.StartInterval(100);

            UnitCache.Of("harvester_1", 71, 71 + 31, 48, 48,
                delegate(UnitCache c)
                {
                    adone(delegate
                    {
                        for (int i = 1; i < 10; i++)
                        {
                            Unit.Of(c, 32 * 7, 24 * i, t, 5);
                        }
                    });
                }
            );


            building_1 = UnitCache.Of("building_1", 365, 365 + 17, 72, 72,
                delegate(UnitCache c)
                {

                    adone(delegate
                    {
                        for (int i = 1; i < 5; i++)
                        {
                            var xu = Unit.Of(c, 32 * 14, 72 * i, t, 2);

                            System.Action To3 = null;
                            System.Action To4 = null;
                            System.Action To1r = null;
                            System.Action To1 = null;

                            To3 = delegate
                            {

                                xu.Cache = building_3;
                                xu.WhenDone = To4;

                            };


                            To1r = delegate
                            {
                                xu.ReverseAnimation = true;
                                xu.Cache = building_1;
                                xu.WhenDone = To1;

                            };

                            To1 = delegate
                           {
                               xu.ReverseAnimation = false;
                               xu.Cache = building_1;
                               xu.WhenDone = To3;

                           };


                            To4 = delegate
                               {
                                   xu.Cache = building_4;
                                   xu.WhenDone = To1r;

                               };

                            xu.WhenDone = To3;
                        }
                    });
                }
            );

            UnitCache.Of("building_2", 1252, 1252 + 15, 48, 48,
                delegate(UnitCache c)
                {
                    adone(delegate
                    {
                        for (int i = 1; i < 10; i++)
                        {
                            Unit.Of(c, 32 * 17, 48 * i, t, 6);

                        }
                    });
                }
            );

            building_4 = UnitCache.Of("building_4", 405, 405 + 17, 72, 72, uc => adone(null));

            building_3 = UnitCache.Of("building_3", 393, 393 + 11, 72, 72, uc => adone(null));

            UnitCache.Of("tank_2", 308, 308 + 31, 24, 24,
               delegate(UnitCache c)
               {
                   adone(delegate
                   {
                       for (int i = 1; i < 10; i++)
                       {
                           Unit.Of(c, 32 * 3, 24 * i, t, 3);
                       }
                   });
               }
            );

            explosion_1 = UnitCache.Of("explosion_1", 990, 1015, 78, 121,
               delegate(UnitCache c)
               {
                   adone(delegate
                   {


                       Native.Document.body.onclick +=
                           delegate(IEvent ev)
                           {
                               int cx = ev.CursorX;
                               int cy = ev.CursorY;

                               UserCreateExplosion(cx, cy);
                           };
                   });
               }
            );

            new IHTMLImage("fx/building/power.png").InvokeOnComplete(
                delegate(IHTMLImage img)
                {
                    for (int i = 0; i < 3; i++)
                    {
                        SpawnAnimation(img, 50 + 48 * i, 200, 48, 72, 0, 23, t);

                    }


                }
            );


            new IHTMLImage("fx/building/cy.png").InvokeOnComplete(
                delegate(IHTMLImage img)
                {
                    for (int i = 0; i < 3; i++)
                    {
                        SpawnAnimation(img, 50 + 72 * i, 300, 72, 72, 0, 34, t);

                    }


                }
            );

            new IHTMLImage("fx/building/barrack.png").InvokeOnComplete(
                    delegate(IHTMLImage img)
                    {
                        for (int i = 0; i < 3; i++)
                        {
                            SpawnAnimation(img, 280 + 48 * i, 300, 48, 72, 0, 46, t);

                        }


                    }
                );


            new IHTMLImage("fx/vehicle/veh_cy.png").InvokeOnComplete(
                delegate(IHTMLImage img)
                {
                    for (int i = 0; i < 3; i++)
                    {
                        SpawnAnimation(img, 50 + 48 * i, 400, 48, 48, 0, 31, t);
                    }

                }
            );

            //.InvokeOnComplete(
            //    delegate(IHTMLImage img)
            //    {
            //        this.Explosion = img;

            //        for (int i = 0; i < 3; i++)
            //        {
            //            SpawnAnimation(img, 250 + 48 * i, 200, 78, 121, 0, 25, t);
            //        }

            //    }
            //);
        }