public SolutionFileView()
        {
            this.Colors = new Dictionary <SolutionFileTextFragment, Color>
            {
                { SolutionFileTextFragment.Comment, Color.FromRGB(0, 0x80, 0) },
                { SolutionFileTextFragment.Keyword, Color.Blue },

                { SolutionFileTextFragment.None, Color.None },

                { SolutionFileTextFragment.String, Color.FromRGB(0x80, 0, 0) },
                { SolutionFileTextFragment.Type, Color.FromRGB(43, 145, 175) },

                { SolutionFileTextFragment.XMLKeyword, Color.FromRGB(0, 0, 0xff) },
                { SolutionFileTextFragment.XMLElement, Color.FromRGB(0x80, 0, 0) },
                { SolutionFileTextFragment.XMLAttributeName, Color.FromRGB(0xff, 0, 0) },
                { SolutionFileTextFragment.XMLAttributeValue, Color.FromRGB(0, 0, 0xff) },
                { SolutionFileTextFragment.XMLComment, Color.FromRGB(0, 0x80, 0) },
                { SolutionFileTextFragment.XMLText, Color.None },
            };

            this.Container = new IHTMLDiv();

            this.View = new IHTMLPre().AttachTo(this.Container);
            this.View.style.margin = "0";

            this.Container.style.overflow = IStyle.OverflowEnum.auto;
        }
Esempio n. 2
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)
        {
            var c = new Form1();

            // Error	2	The type 'ScriptCoreLib.JavaScript.DOM.HTML.IHTMLContent' cannot be used as type parameter 'T' in the generic type or method 'ScriptCoreLib.Extensions.FormsExtensions.AttachTo<T>(T, System.Windows.Forms.Control)'. There is no implicit reference conversion from 'ScriptCoreLib.JavaScript.DOM.HTML.IHTMLContent' to 'System.Windows.Forms.Control'.	X:\jsc.svn\examples\javascript\test\TestFormsShadowSplit\TestFormsShadowSplit\Application.cs	37	13	TestFormsShadowSplit
            new IHTMLContent {
            }.AttachTo(
                //c.splitContainer1.Panel2
                c.splitContainer1.Panel2.GetHTMLTargetContainer()
                );

            var s = new IHTMLPre {
                "the shadow dom"
            }.AttachTo(Native.document.documentElement.shadow);

            // forms shall use position fixed
            // to prevent overflow!?

            __Form.InternalHTMLTargetAttachToDocument =
                (that, yield) =>
            {
                if (that.HTMLTarget.parentNode == null)
                {
                    that.HTMLTarget.AttachTo(Native.document.documentElement.shadow);
                }

                // animate!
                yield(true);
            };

            c.Show();
        }
Esempio n. 3
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)
        {
            var s = new IHTMLPre {
                innerText = 1234567L.ToCustomString()
            };

            s.AttachTo(page.body);
        }
Esempio n. 4
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)
        {
            Action getCurrency = async delegate
            {
                var c = await this.GetConversionRate();

                if (c.ContainsKey("GBP"))
                {
                    Console.WriteLine(c["GBP"].ToString());
                }
                Console.WriteLine(c.ToString());
                var p = new IHTMLPre {
                    innerText = c["GBP"].ToString()
                };
                p.AttachTo(page.body);
            };

            getCurrency();
        }
Esempio n. 5
0
        public UltraApplication(IHTMLElement e)
        {
            var note1 = new IHTMLPre
            {
                innerHTML = @"Notice: If flash does not respond to events, you need to clear your cache. 
+ Chrome flash in 'localhost' on Cassini always fails?
  - If so Try http://127.0.0.1 or http://COMPUTERNAME
+ Opera does not pass delegates?
+ IE cannot return from javascript to flash
"
            }.AttachToDocument();

            note1.style.whiteSpace = ScriptCoreLib.JavaScript.DOM.IStyle.WhiteSpaceEnum.pre;
            note1.style.fontSize   = "small";
            note1.style.color      = Color.Red;


            var s = new UltraSprite();

            global::ScriptCoreLib.JavaScript.Extensions.SpriteExtensions.AttachSpriteToDocument(s);

            var SayHello = new IHTMLButton {
                innerText = "Say Hello to flash!"
            }.AttachToDocument();

            SayHello.onclick +=
                delegate
            {
                s.AppendLine("Hello from javascript");

                s.WhenReady(
                    delegate
                {
                    s.AppendLine("What about using the web service?");
                }
                    );
            };

            s.AppendLine("This call is delayed until flash is loaded (1)");
            s.AppendLine("This call is delayed until flash is loaded (2)");
            s.AppendLine("This call is delayed until flash is loaded (3)");

            s.WhenReady(
                delegate
            {
                s.AppendLine("What about using the web service?");
            }
                );

            // passing the interface to flash is delayed until it is loaded, using the getter will fault
            s.WebService        = new AlphaWebService();
            s.WebServiceEnabled = this;

            s.AppendLine("This call is delayed until flash is loaded (4)");

            new IHTMLBreak().AttachToDocument();


            this.WebServiceEnabled = new IHTMLInput(ScriptCoreLib.Shared.HTMLInputTypeEnum.checkbox);

            var WebServiceEnabledLabel = new IHTMLLabel("WebService is enabled for flash", this.WebServiceEnabled);

            new IHTMLDiv(
                WebServiceEnabledLabel,
                WebServiceEnabled
                ).AttachToDocument();

            ButtonsForWebService();
        }
Esempio n. 6
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)
        {
            @"Hello world".ToDocumentTitle();
            // Send data from JavaScript to the server tier

            //IStyleSheet.Default.AddRule("body", "-webkit-transition: background-color .15s linear .1;", 0);

            (Native.document.body.style as dynamic).webkitTransition = "background-color 500ms ease-out";

            Action <ApplicationWebService> bind =
                service =>
            {
                service.MakeCyan = delegate
                {
                    Native.document.body.style.backgroundColor = "cyan";
                };

                service.MakeYellow = delegate
                {
                    Native.document.body.style.backgroundColor = "yellow";
                };

                service.set_backgroundColor = value =>
                {
                    Native.document.body.style.backgroundColor = value;
                };
            };

            bind(this);


            new IHTMLButton {
                innerText = "WebMethod2"
            }.AttachToDocument().WhenClicked(
                async delegate
            {
                var Result = await this.WebMethod2(
                    42,
                    value => value.ToDocumentTitle()
                    );

                foreach (var item in Result)
                {
                    new IHTMLPre {
                        innerText = new { item }.ToString()
                    }.AttachToDocument();
                }
            }
                );

            new IHTMLButton {
                innerText = "WebMethod4"
            }.AttachToDocument().WhenClicked(
                async delegate
            {
                var Result = await this.WebMethod4(
                    42,
                    value => value.ToDocumentTitle()
                    );

                foreach (var item in Result)
                {
                    //new IHTMLPre { innerText = new { item.e }.ToString() }.AttachToDocument();
                    var x = new IHTMLPre {
                        innerText = item.ToString()
                    }.AttachToDocument();

                    var xx      = await item.GetString();
                    x.innerText = xx;
                }
            }
                );

            Func <ApplicationWebService, Task> y = null;

            y =
                async service =>
            {
                var Result = await service.WebMethod8(
                    42,
                    value => value.ToDocumentTitle()
                    );

                new IHTMLBreak {
                }.AttachToDocument();

                Result.WithEach(
                    xservice =>
                {
                    // for new we have to keep rebinding
                    // because the server seems to call our functions even if we do not set them?
                    // can we even send a null delegate to server?
                    bind(xservice);

                    new IHTMLButton {
                        innerText = "WebMethod8 " + new { xservice.xe }.ToString()
                    }.AttachToDocument().WhenClicked(
                        async delegate
                    {
                        await y(xservice);
                    }
                        );
                }
                    );
            };

            new IHTMLButton {
                innerText = "WebMethod8"
            }.AttachToDocument().WhenClicked(
                async delegate
            {
                await y(this);
            }
                );
        }
Esempio n. 7
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)
        {
            // https://sites.google.com/a/jsc-solutions.net/backlog/knowledge-base/2014/201405/20140517

            this.page = page;
            // historic callsite scoping does not yet support instance references
            that = this;

            page.email.ondblclick  += e => Events.Add(new UIEvent(UIEventsOfInterestAndSignificance.DOM, "email " + new { page.email.value }, IHTMLEvents.ondblclick));
            page.email.onclick     += e => Events.Add(new UIEvent(UIEventsOfInterestAndSignificance.DOM, "email " + new { page.email.value }, IHTMLEvents.onclick));
            page.email.onmouseover += e => Events.Add(new UIEvent(UIEventsOfInterestAndSignificance.DOM, "email " + new { page.email.value }, IHTMLEvents.onmouseover));
            page.email.onmouseout  += e => Events.Add(new UIEvent(UIEventsOfInterestAndSignificance.DOM, "email " + new { page.email.value }, IHTMLEvents.onmouseout));
            page.email.onchange    += e => Events.Add(new UIEvent(UIEventsOfInterestAndSignificance.DOM, "email " + new { page.email.value }, IHTMLEvents.onchange));
            page.email.onfocus     += e => Events.Add(new UIEvent(UIEventsOfInterestAndSignificance.DOM, "email " + new { page.email.value }, IHTMLEvents.onfocus));
            page.email.onblur      += e => Events.Add(new UIEvent(UIEventsOfInterestAndSignificance.DOM, "email " + new { page.email.value }, IHTMLEvents.onblur));
            page.email.onkeyup     += e => Events.Add(new UIEvent(UIEventsOfInterestAndSignificance.DOM, "email " + new { page.email.value }, IHTMLEvents.onkeyup));

            page.EULA.onmouseover += e => Events.Add(new UIEvent(UIEventsOfInterestAndSignificance.DOM, "EULA " + new { }, IHTMLEvents.onmouseover));
            page.EULA.onmouseout  += e => Events.Add(new UIEvent(UIEventsOfInterestAndSignificance.DOM, "EULA " + new { }, IHTMLEvents.onmouseout));
            page.EULA.onfocus     += e => Events.Add(new UIEvent(UIEventsOfInterestAndSignificance.DOM, "EULA " + new { }, IHTMLEvents.onfocus));
            page.EULA.onblur      += e => Events.Add(new UIEvent(UIEventsOfInterestAndSignificance.DOM, "EULA " + new { }, IHTMLEvents.onblur));
            page.EULA.onscroll    += e => Events.Add(new UIEvent(UIEventsOfInterestAndSignificance.DOM, "EULA " + new { }, IHTMLEvents.onscroll));

            window.onfocus  += e => Events.Add(new UIEvent(UIEventsOfInterestAndSignificance.DOM, "window " + new { }, IHTMLEvents.onfocus));
            window.onblur   += e => Events.Add(new UIEvent(UIEventsOfInterestAndSignificance.DOM, "window " + new { }, IHTMLEvents.onblur));
            window.onscroll += e => Events.Add(new UIEvent(UIEventsOfInterestAndSignificance.DOM, "window " + new { }, IHTMLEvents.onscroll));
            //redux
            //window.ondeviceorientation += e => Events.Add(new UIEvent(UIEventsOfInterestAndSignificance.DOM, "window " + new { }, IHTMLEvents.ondeviceorientation));
            window.onresize += e => Events.Add(new UIEvent(UIEventsOfInterestAndSignificance.DOM, "window " + new { }, IHTMLEvents.onresize));

            // ScriptCoreLib could also ask for expression which it could monitor a bit better
            // or we could use variable monitoring speed. slow down when no updates.
            // or we could ask to be notified if a field changes. jsc magic needed?
            new IHTMLPre {
                () => new { Events.Count, LastOrDefault = Events.LastOrDefault() }
            }.AttachToDocument();

            // also send in the performance data

            //:26ms enter Historic:
            //            {
            //                domain = 192.168.1.76, baseURI = http://192.168.1.76:10237/, location = http://192.168.1.76:10237/, xlocation = http://192.168.1.76:10237/, href = http://192.168.1.76:10237/agree }
            //0:26ms event: activate! { hash = , url =  }
            //0:27ms event: onclick
            //        {
            //            href = http://192.168.1.76:10237/agree, MouseButton = 1 }



            css.style.transition = "background-color 300ms linear";

            new IStyle(that.page.HideMe)
            {
                transition = "margin-top 300ms linear"
            };


            new IStyle(that.page.EULA.css)
            {
                borderLeft = "1em solid yellow",
                transition = "border-left 600ms linear",
            };

            new IStyle(that.page.EULA.css[that.page.EULA.async.onscrollToBottom])
            {
                borderLeft = "1em solid green"
            };


            //Native.window.async.onscrollToBottom
            //page.EULA.onscroll
            //page.email.async.onscr

            //page.EULA.onscroll +=
            //    delegate
            //{
            //    Console.WriteLine(new
            //    {
            //        page.EULA.scrollTop,
            //        page.EULA.scrollHeight,
            //        page.EULA.clientHeight
            //    });
            //};


            //page.EULA.async.onscrollToBottom.With(
            //    async onscrollToBottom =>
            //    {
            //        await onscrollToBottom;

            //        page.EULA.style.borderLeft = "1em solid green";
            //    }
            //);



            page.YesIAgree.Historic(
                async(HistoryScope <object> scope) =>
            {
                // indicate we are sending data to server
                css.style.backgroundColor = "yellow";

                //new IStyle(that.page.HideMe)
                // we want it to be undone at back button!
                new IStyle(that.page.HideMe.css)
                {
                    marginTop = -that.page.HideMe.clientHeight + "px"
                };


                // X:\jsc.svn\examples\javascript\async\test\TestChainedAsync\TestChainedAsync\Application.cs


                // we are basically grouping it


                // why is it destroying rewrite?
                new UIEvent(UIEventsOfInterestAndSignificance.ClickAgree, NestedEvents: that.Events.ToArray()).With(
                    e =>
                {
                    that.Events.Clear();
                    that.Events.Add(e);
                }
                    );



                var message = await that.Agree(that.page.email);
                // indicate got data
                css.style.backgroundColor = "cyan";


                var x = new IHTMLPre {
                    new { message }
                }.AttachToDocument();
                that.Events.Add(
                    new UIEvent(UIEventsOfInterestAndSignificance.ClickAgreeComplete, Data: new { message }.ToString())
                    );

                await scope;
                // indicate we went back in time
                // css will be undone bj scriptcorelib!

                // back button!
                x.Orphanize();
                that.Events.Add(
                    new UIEvent(UIEventsOfInterestAndSignificance.ClickAgreeHistoryGoBack)
                    );
            }
                );
        }
Esempio n. 8
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 xpage = null)
        {
            // subst a: X:\jsc.svn\examples\java\synergy\jDOSBoxAppletWithWarcraft\jDOSBoxAppletWithWarcraft\bin\Debug\staging\jDOSBoxAppletWithWarcraft.Application\web



            #region ChromeTCPServer
            dynamic self               = Native.self;
            dynamic self_chrome        = self.chrome;
            object  self_chrome_socket = self_chrome.socket;

            if (self_chrome_socket != null)
            {
                //Console.WriteLine("FlashHeatZeeker shall run as a chrome app as server");

                //chrome.Notification.DefaultTitle = "Operation «Heat Zeeker»";
                //chrome.Notification.DefaultIconUrl = new HTML.Images.FromAssets.Preview().src;

                //ChromeTCPServer.TheServerWithStyledForm.Invoke(

                ChromeTCPServer.TheServer.Invoke(
                    AppSource.Text,
                    u => Native.window.open(u)
                    );

                return;
            }
            #endregion



            // https://sites.google.com/a/jsc-solutions.net/backlog/knowledge-base/2014/201402/20140221-war


            // 20 MB disk. How to create one ourselves?
            // view-source:http://www.classicdosgames.com/online/doom19s.html

            //            0011 javassist create javassist.ClassMap
            //System.TypeLoadException: Declaration referenced in a method implementation cannot be a final method.  Type: 'javassist.ClassMap'.  Assembly: 'javassist, Version=0.0.0.0, Culture=neutral, PublicKeyToken=null'.

            // http://www.dosbox.com/wiki/IMGMOUNT#The_.22-size.22_parameter_.28required_to_to_create_bootable_hard_disk_images.29

            var borders = Native.Document.body;

            //dynamic ss = borders.style;

            //ss.webkitTransition = "all 0.3s linear";
            borders.style.transition = "all 0.3s linear";


            borders.style.borderWidth = "3em";
            borders.style.borderStyle = "solid";

            borders.style.borderRightColor  = "rgba(0, 0, 255, 0.5)";
            borders.style.borderLeftColor   = "rgba(0, 0, 255, 0.5)";
            borders.style.borderBottomColor = "rgba(0, 0, 255, 0.5)";
            borders.style.borderTopColor    = "rgba(0, 0, 255, 0.5)";

            var disable_ondeviceorientation = false;

            var errortimer = new Timer(
                delegate
            {
                disable_ondeviceorientation     = true;
                borders.style.borderRightColor  = "rgba(255, 0, 0, 0.2)";
                borders.style.borderLeftColor   = "rgba(255, 0, 0, 0.2)";
                borders.style.borderBottomColor = "rgba(255, 0, 0, 0.2)";
                borders.style.borderTopColor    = "rgba(255, 0, 0, 0.2)";
            }
                );

            xpage._IWantToUseTheApplet.onclick +=
                delegate
            {
                // https://code.google.com/p/chromium/issues/detail?id=288935
                // http://stackoverflow.com/questions/21318087/chrome-packaged-app-using-java-plugin
                // java applets wont work in chrome webview?
                // Initialize ApplicationApplet


                // Version 7 Update 51
                var applet = new ApplicationApplet();

                var container = applet.ToHTMLElement();

                //ApplicationContent.InitializeContent(container);

                var ref4 = "assets/jDOSBoxAppletWithWarcraft/war1.img";

                var location = "" + Native.Document.location;

                //Native.document.baseURI = "assets/jDOSBoxAppletWithWarcraft/";

                // <param name="param1" value="imgmount e http://127.0.0.1:20169/assets/jDOSBoxAppletWithWarcraft/war1.img">

                var cmd = "imgmount e " + location.TakeUntilLastIfAny("/") + "/" + ref4;

                new IHTMLParam {
                    name = "param1", value = cmd
                }.AttachTo(container);
                new IHTMLParam {
                    name = "param2", value = "e:"
                }.AttachTo(container);
                new IHTMLParam {
                    name = "param3", value = "dir"
                }.AttachTo(container);

                // http://stackoverflow.com/questions/4135138/access-denied-java-net-socketpermission-127-0-0-18080-connect-resolve

                new IHTMLParam {
                    name = "param4", value = "ipx"
                }.AttachTo(container);

                //new IHTMLParam { name = "param4", value = "cd war1" }.AttachTo(e);
                //new IHTMLParam { name = "param5", value = "setup" }.AttachTo(e);
                //new IHTMLParam { name = "param6", value = "war" }.AttachTo(e);

                //e.AttachToDocument();

                // java.security.AccessControlException: access denied ("java.net.SocketPermission" "192.168.43.252:24369" "connect,resolve")

                //Native.window.open("about:blank", "_blank", 800, 600, false).With(
                //    w =>
                //    {
                //        #region for non default paths we need explicit location!

                //        var archive = container.AsXElement().Attribute("archive");

                //        archive.Value = location + archive.Value;

                //        #endregion

                //        //<applet archive="assets/jDOSBoxAppletWithWarcraft.Application/jDOSBoxAppletWithWarcraft.ApplicationApplet.jar" scriptable="true" code="jDOSBoxAppletWithWarcraft.ApplicationApplet" width="800" height="600"><param name="codebase_lookup" value="false"><param name="separate_jvm" value="true"><param name="param1" value="imgmount e http://192.168.1.100:13331/assets/jDOSBoxAppletWithWarcraft/war1.img"><param name="param2" value="e:"><param name="param3" value="dir"></applet>


                //        w.onload +=
                //            delegate
                //            {
                // java.security.AccessControlException: access denied
                //new IHTMLBase { href = location }.AttachTo(
                //    w.document.body.parentNode.firstChild
                //    );

                var GrayWindow = new GrayWindow();

                xpage._IWantToUseTheApplet.parentNode.replaceChild(
                    GrayWindow.body,
                    xpage._IWantToUseTheApplet
                    );

                //w.document.title = "dosbox applet for secondary monitor";



                container.AttachTo(GrayWindow.center);
                //            };
                //    }
                //);



                var page = new { Keyboard = Native.Document.body };

                #region onkeydown
                page.Keyboard.onkeydown +=
                    e =>
                {
                    e.preventDefault();
                    e.stopPropagation();


                    int KeyCode = e.KeyCode;
                    if (KeyCode == 13)
                    {
                        KeyCode = 10;
                    }
                    int KeyChar = KeyCode;



                    applet.__MainApplet_keyPressed("" + KeyCode, "" + KeyChar,
                                                   message => Native.window.alert(message)
                                                   );
                };

                page.Keyboard.onkeyup +=
                    e =>
                {
                    e.preventDefault();
                    e.stopPropagation();

                    int KeyCode = e.KeyCode;

                    if (KeyCode == 13)
                    {
                        KeyCode = 10;
                    }



                    int KeyChar = KeyCode;



                    applet.__MainApplet_keyReleased("" + KeyCode, "" + KeyChar,
                                                    message => Native.window.alert(message)
                                                    );
                };
                #endregion


                #region onmousemove
                page.Keyboard.onmouseup +=
                    e =>
                {
                    if (Native.Document.pointerLockElement == page.Keyboard)
                    {
                        e.preventDefault();
                        e.stopPropagation();

                        applet.__MainApplet_mouseReleased();

                        return;
                    }
                };


                page.Keyboard.onmousedown +=
                    e =>
                {
                    if (Native.Document.pointerLockElement == page.Keyboard)
                    {
                        e.preventDefault();
                        e.stopPropagation();


                        applet.__MainApplet_mousePressed();

                        return;
                    }

                    page.Keyboard.requestPointerLock();
                };

                page.Keyboard.onmousemove +=
                    e =>
                {
                    if (Native.Document.pointerLockElement == page.Keyboard)
                    {
                        e.preventDefault();
                        e.stopPropagation();


                        var dx = e.movementX;
                        var dy = e.movementY;

                        applet.__MainApplet_mousemove("" + dx, "" + dy);
                    }
                };
                #endregion

                var status = new IHTMLPre {
                    innerText = ""
                }.AttachToDocument();
                var onmessage = new IHTMLPre {
                    innerText = ""
                }.AttachToDocument();

#if FEventSource
                #region EventSource
                new EventSource().With(
                    s =>
                {
                    //s.status =
                    s["status"] =
                        e =>
                    {
                        status.innerText = "" + e.data;
                    };



                    s.onerror +=
                        e =>
                    {
                        errortimer.StartTimeout(300);
                    };


                    s.onmessage +=
                        e =>
                    {
                        errortimer.Stop();

                        var xml  = "" + e.data;
                        var data = XElement.Parse(xml);

                        //long
                        //    last_ms = long.Parse(data.Attribute("last_ms").Value),

                        //    x = long.Parse(data.Attribute("x").Value),
                        //    y = long.Parse(data.Attribute("y").Value);

                        bool
                        goleft  = 0 < long.Parse(data.Attribute("goleft").Value),
                        goup    = 0 < long.Parse(data.Attribute("goup").Value),
                        goright = 0 < long.Parse(data.Attribute("goright").Value),
                        godown  = 0 < long.Parse(data.Attribute("godown").Value);


                        onmessage.innerText = "" +
                                              new
                        {
                            //last_ms,
                            //x,
                            //y,
                            goleft,
                            goup,
                            goright,
                            godown
                        };

                        borders.style.borderRightColor  = "rgba(255, 255, 255, 0.0)";
                        borders.style.borderLeftColor   = "rgba(255, 255, 255, 0.0)";
                        borders.style.borderBottomColor = "rgba(255, 255, 255, 0.0)";
                        borders.style.borderTopColor    = "rgba(255, 255, 255, 0.0)";

                        //Native.Document.body.style.backgroundColor = "rgba(255, 255, 0, 0.4)";

                        //if (x == 0)
                        //    if (y == 0)
                        //        Native.Document.body.style.backgroundColor = JSColor.None;

                        //shadow_table_dx += (int)x;
                        //shadow_table_dy += (int)y;
                        //shadow_table.style.SetLocation(shadow_table_dx, shadow_table_dy);

                        Action <string> sprite_keyup =
                            x =>
                        {
                            applet.__MainApplet_keyReleased(
                                x, x, Console.WriteLine
                                );
                        };

                        Action <string> sprite_keydown =
                            x =>
                        {
                            applet.__MainApplet_keyPressed(
                                x, x, Console.WriteLine
                                );
                        };

                        sprite_keyup("" + (int)System.Windows.Forms.Keys.Up);
                        sprite_keyup("" + (int)System.Windows.Forms.Keys.Down);
                        sprite_keyup("" + (int)System.Windows.Forms.Keys.Left);
                        sprite_keyup("" + (int)System.Windows.Forms.Keys.Right);

                        if (goup)
                        {
                            borders.style.borderTopColor = "rgba(0, 255, 0, 0.5)";
                            sprite_keydown("" + (int)System.Windows.Forms.Keys.Up);
                        }
                        else if (godown)
                        {
                            borders.style.borderBottomColor = "rgba(0, 255, 0, 0.5)";

                            sprite_keydown("" + (int)System.Windows.Forms.Keys.Down);
                        }

                        if (goleft)
                        {
                            sprite_keydown("" + (int)System.Windows.Forms.Keys.Left);
                            borders.style.borderLeftColor = "rgba(0, 255, 0, 0.5)";
                        }
                        else if (goright)
                        {
                            sprite_keydown("" + (int)System.Windows.Forms.Keys.Right);
                            borders.style.borderRightColor = "rgba(0, 255, 0, 0.5)";
                        }
                    };
                }
                    );
                #endregion
#endif
            };



#if FTILT
            xpage._IAmTheTiltSensorUseThisDeviceToControlTheApplet.onclick +=
                delegate
            {
                borders.style.borderRightColor  = "rgba(255, 0, 0, 0.5)";
                borders.style.borderLeftColor   = "rgba(255, 0, 0, 0.5)";
                borders.style.borderBottomColor = "rgba(255, 0, 0, 0.5)";
                borders.style.borderTopColor    = "rgba(255, 0, 0, 0.5)";

                var goup    = false;
                var goright = false;
                var godown  = false;
                var goleft  = false;

                var zyx = new IHTMLPre {
                    innerText = ""
                }.AttachToDocument();

                #region ondeviceorientation
                Native.window.ondeviceorientation +=
                    e =>
                {
                    if (disable_ondeviceorientation)
                    {
                        return;
                    }

                    #region desktop chrome misreports?
                    // Uncaught ReferenceError: alpha is not defined
                    if ("this.alpha == null".js <bool>(e))
                    {
                        return;
                    }
                    #endregion

                    e.preventDefault();
                    e.stopPropagation();

                    zyx.innerText = new { e.alpha, e.beta, e.gamma }.ToString();

                    var movementX = e.alpha;
                    var movementY = e.beta;
                    var movementZ = e.gamma;

                    borders.style.borderRightColor  = "rgba(255, 255, 255, 0.0)";
                    borders.style.borderLeftColor   = "rgba(255, 255, 255, 0.0)";
                    borders.style.borderBottomColor = "rgba(255, 255, 255, 0.0)";
                    borders.style.borderTopColor    = "rgba(255, 255, 255, 0.0)";

                    goup    = false;
                    goright = false;
                    godown  = false;
                    goleft  = false;

                    if (movementY < -2)
                    {
                        borders.style.borderTopColor = "rgba(0, 255, 0, 0.5)";
                        goup = true;
                    }
                    else if (movementY > 33)
                    {
                        borders.style.borderBottomColor = "rgba(0, 255, 0, 0.5)";
                        godown = true;
                    }

                    if (movementZ < -15)
                    {
                        goleft = true;
                        borders.style.borderLeftColor = "rgba(0, 255, 0, 0.5)";
                    }
                    else if (movementZ > 15)
                    {
                        goright = true;
                        borders.style.borderRightColor = "rgba(0, 255, 0, 0.5)";
                    }
                };
                #endregion

                var id    = new Random().Next();
                var frame = 0;

                #region loop
                Action loop = null;

                //var zdx = 0;
                //var zdy = 0;
                var zgoup    = false;
                var zgoright = false;
                var zgodown  = false;
                var zgoleft  = false;

                loop = delegate
                {
                    frame++;



                    if (frame > 1)
                    {
                        //if (dx == zdx)
                        //    if (dy == zdy)
                        if (zgoup == goup)
                        {
                            if (zgoright == goright)
                            {
                                if (zgodown == godown)
                                {
                                    if (zgoleft == goleft)
                                    {
                                        // check again
                                        Native.window.requestAnimationFrame += loop;

                                        return;
                                    }
                                }
                            }
                        }
                    }

                    //zdx = dx;
                    //zdy = dy;

                    zgoup    = goup;
                    zgoright = goright;
                    zgodown  = godown;
                    zgoleft  = goleft;

                    //dx = 0;
                    //dy = 0;

                    errortimer.Stop();
                    errortimer.StartTimeout(300);

                    service.AtFrame(
                        "" + id,
                        "" + frame,


                        goleft: "" + System.Convert.ToInt32(zgoleft),
                        goup: "" + System.Convert.ToInt32(zgoup),
                        goright: "" + System.Convert.ToInt32(zgoright),
                        godown: "" + System.Convert.ToInt32(zgodown),

                        yield:
                        delegate
                    {
                        disable_ondeviceorientation = false;
                        errortimer.Stop();

                        Native.window.requestAnimationFrame += loop;
                    }
                        );
                };

                Native.window.requestAnimationFrame += loop;
                #endregion
            };
#endif
        }
Esempio n. 9
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)
        {
            // https://developers.google.com/web/fundamentals/input/touch/touchevents/

            // https://googlesamples.github.io/web-fundamentals/samples/input/touch/touch-demo-1.html

            // https://code.google.com/p/chromium/issues/detail?id=516050
            // http://stackoverflow.com/questions/17886073/do-chrome-and-firefox-support-pointer-event-pressure-tilt-touch-etc-any-so
            // https://mobiforge.com/design-development/html5-pointer-events-api-combining-touch-mouse-and-pen

            // http://arstechnica.com/information-technology/2015/03/chromium-team-reverses-course-will-adopt-ies-merged-mouse-touch-apis/
            // http://www.infoq.com/news/2015/04/google-pointer-events

            // http://www.theverge.com/2015/3/25/8291893/google-chrome-pointer-events-support
            // http://www.zdnet.com/article/google-will-implement-pointer-events-api-in-chrome-after-all/

            // http://www.w3.org/TR/pointerevents/

            // http://question.ikende.com/question/32303938343332303831

            // https://www.chromestatus.com/features/4504699138998272

            // https://msdn.microsoft.com/en-us/library/hh771911(v=vs.85).aspx

            var xPointerEvent = (Native.window as dynamic).PointerEvent;

            // --enable-blink-features=PointerEvent
            new IHTMLPre {
                new { xPointerEvent }
            }.AttachToDocument();

            //  dom.w3c_pointer_events.enabled
            //  dom.w3c_touch_events.enabled
            // https://hacks.mozilla.org/2015/08/pointer-events-now-in-firefox-nightly/
            new IHTMLPre {
                "firefox nightly seems to do pen tilt?"
            }.AttachToDocument();
            // works with ie too.
            // yet oly if we had tilt and pressure
            // does xt even have em natively?

            var onpointerover = new IHTMLPre {
                "onpointerover ?"
            }.AttachToDocument();
            var onpointerdown = new IHTMLPre {
                "onpointerdown ?"
            }.AttachToDocument();
            var onpointermove = new IHTMLPre {
                "onpointermove ?"
            }.AttachToDocument();

            var c = new CanvasRenderingContext2D(800, 200);

            c.canvas.style.border = "1px solid blue";
            c.canvas.AttachToDocument();
            c.canvas.style.SetLocation(0, 0);

            Native.document.body.style.marginTop = "200px";

            c.beginPath();
            c.moveTo(0, 0);

            // whatif xt does not have tilt data available?
            // X:\opensource\unmonitored\WintabDN\FormTestApp\TestForm.cs

            c.canvas.onpointerover += e =>
            {
                // got a stylus dell xt?
                // make sure ip is set to dhcp to get into wifi
                // make sure onenote still works...

                e.stopPropagation();
                e.preventDefault();

                onpointerover.innerText = "onpointerover " + new { e.pointerType, e.tiltX, e.tiltY, e.pressure, e.movementX };
            };

            c.canvas.onpointerdown += e =>
            {
                // got a stylus dell xt?
                // make sure ip is set to dhcp to get into wifi
                // make sure onenote still works...

                e.stopPropagation();
                e.preventDefault();

                onpointerdown.innerText = "onpointerdown " + new { e.pointerType, e.tiltX, e.tiltY, e.pressure, e.movementX };
            };

            //Native.document.body.onpointermove += e =>
            c.canvas.onpointermove += e =>
            {
                // got a stylus dell xt?
                // make sure ip is set to dhcp to get into wifi
                // make sure onenote still works...
                e.stopPropagation();
                e.preventDefault();


                onpointermove.innerText = "onpointermove " + new { e.pointerType, e.tiltX, e.tiltY, e.pressure, e.movementX };


                //Native.document.body.ScrollToBottom();


                if (e.pressure > 0)
                {
                    c.strokeStyle = "red";
                }
                else
                {
                    c.strokeStyle = "blue";
                }
                c.lineTo(e.CursorX, e.CursorY);
                //c.lineTo(e.OffsetX, e.OffsetY);
                //c.lineTo(e.movementX, e.movementY);
                c.stroke();
                // https://web.archive.org/web/20150423093435/http://www.n-trig.com/wintab-compatible-applications/
                // https://web.archive.org/web/20150318140957/http://www.n-trig.com/wintab-2/
                // https://web.archive.org/web/20150316135525/http://www.wacomeng.com/windows/index.html
            };

            // https://sites.google.com/a/jsc-solutions.net/work/knowledge-base/15-dualvr/20151001

            // https://msdn.microsoft.com/en-us/library/windows/hardware/jj151564(v=vs.85).aspx
        }
Esempio n. 10
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)
        {
            // X:\jsc.svn\examples\javascript\async\AsyncWindowUncaughtError\AsyncWindowUncaughtError\ApplicationWebService.cs

            // intellitrace
            // a self debugging programe?
            // can we have buttons for debugging?
            // https://www.youtube.com/watch?v=4vtKRE9an_I
            // could we have live patching, remote debugging via udp?

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

            Next.disabled = true;

            Func <Task> Next_onclick = async delegate
            {
                Next.disabled = false;
                await Next.async.onclick;
                Next.disabled = true;
            };

            trace trace = async(string filepath, int linenumber, string line) =>
            {
                // could we go backwards in time too?
                // like intellitrace?

                var debugged = new IHTMLPre {
                }.AttachToDocument();



                // should we allow chaning constants?
                // by patching const load opcodes?

                var l = new IHTMLSpan {
                    "" + linenumber
                }.AttachToDocument();



                l.title = filepath;

                l.style.marginRight = "2em";
                l.style.color       = "darkcyan";

                l.AttachTo(debugged);

                // could we use css to do syntax highlight?
                var prefixToHide = "await trace();";

                // perhaps the next step would be to send us the origina stack usage IL
                // we see in the jsc reflector?
                var c = new IHTMLSpan {
                    line.Replace(prefixToHide, "")
                };

                c.style.marginRight = "2em";
                //c.style.color = "blue";
                c.style.backgroundColor = "yellow";

                c.AttachTo(debugged);

                await Next_onclick();

                c.style.backgroundColor = "";
            };

            interactive <string> __string = async(string data, string filepath, int linenumber, string line) =>
            {
                var i = new IHTMLInput {
                    value = data
                }.AttachToDocument();

                await Next_onclick();

                return(i.value);
            };


            //Func<>
            Func <string, Task <string> > program =
                // a simulaton of a program
                async data =>
            {
                await trace(); new IHTMLPre {
                    await __string("hello")
                }.AttachToDocument();
                await trace(); new IHTMLPre {
                    await __string("world")
                }.AttachToDocument();


                await trace(); return("done!");
            };

            new IHTMLButton {
                "Step Into"
            }.AttachToDocument().onclick +=
                async e =>
            {
                new IHTMLHorizontalRule().AttachToDocument();

                e.Element.disabled = true;
                var value = await program("data");

                e.Element.disabled = false;

                new IHTMLPre {
                    new { value }
                }.AttachToDocument();
            };


            new IHTMLButton {
                "Run"
            }.AttachToDocument().onclick +=
                async e =>
            {
                // enum to string?
                new IHTMLHorizontalRule().AttachToDocument();

                var x = Next_onclick;
                // slow down the program
                Next_onclick = async delegate { await Task.Delay(300); };


                e.Element.disabled = true;
                var value = await program("data");

                e.Element.disabled = false;

                Next_onclick = x;

                new IHTMLPre {
                    new { value }
                }.AttachToDocument();
            };
        }
Esempio n. 11
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(IDefaultPage page)
        {
            new JSCSolutionsNETImage().ToBackground(page.Item1.style, false);
            new JSCSolutionsNETImage().ToBackground(page.Item2.style, false);


            // Update document title
            // http://do.jsc-solutions.net/Update-document-title

            @"Hello world".ToDocumentTitle();
            // Send xml to server
            // http://do.jsc-solutions.net/Send-xml-to-server

            var v = new SolutionFileView();

            var f = new SolutionFile();

            f.WriteHTMLElement(StockPageDefault.Element);

            v.File = f;

            var Container = new IHTMLDiv();

            Container.style.position = IStyle.PositionEnum.relative;
            Container.style.display  = IStyle.DisplayEnum.inline_block;
            Container.style.width    = "600px";
            Container.style.height   = "400px";
            Container.style.border   = "1px solid gray";

            var ToolbarHeight = "1.3em";
            var Content       = new IHTMLDiv().AttachTo(Container);

            Content.style.position = IStyle.PositionEnum.absolute;
            Content.style.left     = "0px";
            Content.style.top      = "0px";
            Content.style.right    = "0px";
            Content.style.bottom   = ToolbarHeight;


            var Toolbar = new IHTMLDiv().AttachTo(Container);

            Toolbar.style.backgroundColor = Color.FromGray(0xef);
            Toolbar.style.position        = IStyle.PositionEnum.absolute;
            Toolbar.style.left            = "0px";
            Toolbar.style.height          = ToolbarHeight;
            Toolbar.style.right           = "0px";
            Toolbar.style.bottom          = "0px";

            Action <IHTMLImage, string, Action> AddToolbarButton =
                (img, text, handler) =>
            {
                var span = new IHTMLSpan {
                    innerText = text
                };

                span.style.paddingLeft  = "1.5em";
                span.style.paddingRight = "0.3em";

                var a = new IHTMLAnchor
                {
                    img, span
                };

                img.style.verticalAlign = "middle";
                img.border         = 0;
                img.style.position = IStyle.PositionEnum.absolute;

                a.style.backgroundColor = Color.FromGray(0xef);
                a.style.color           = Color.Black;
                a.style.textDecoration  = "none";
                a.style.fontFamily      = IStyle.FontFamilyEnum.Tahoma;

                a.href     = "javascript: void(0);";
                a.onclick +=
                    delegate
                {
                    handler();
                };
                a.style.display = IStyle.DisplayEnum.inline_block;
                a.style.height  = "100%";


                a.onmousemove +=
                    delegate
                {
                    a.style.backgroundColor = Color.FromGray(0xff);
                };

                a.onmouseout +=
                    delegate
                {
                    a.style.backgroundColor = Color.FromGray(0xef);
                };

                Toolbar.Add(a);
            };


            v.Container.style.height = "100%";
            v.Container.AttachTo(Content);


            Content.Add(v.Container);

            var i = CreateEditor();

            i.AttachTo(Content);



            var ii = new IHTMLPre().AttachTo(Content);

            ii.style.position   = IStyle.PositionEnum.absolute;
            ii.style.left       = "0px";
            ii.style.top        = "0px";
            ii.style.right      = "0px";
            ii.style.bottom     = "0px";
            ii.style.overflow   = IStyle.OverflowEnum.auto;
            ii.style.padding    = "0px";
            ii.style.margin     = "0px";
            ii.style.whiteSpace = IStyle.WhiteSpaceEnum.normal;

            v.Container.style.display = IStyle.DisplayEnum.none;
            i.style.display           = IStyle.DisplayEnum.empty;
            ii.style.display          = IStyle.DisplayEnum.none;

            AddToolbarButton(new RTA_mode_design(), "Design",
                             delegate
            {
                v.Container.style.display = IStyle.DisplayEnum.none;
                ii.style.display          = IStyle.DisplayEnum.none;
                i.style.display           = IStyle.DisplayEnum.empty;
            }
                             );

            AddToolbarButton(new RTA_mode_html(), "Source",
                             delegate
            {
                v.Container.style.display = IStyle.DisplayEnum.empty;
                ii.style.display          = IStyle.DisplayEnum.none;
                i.style.display           = IStyle.DisplayEnum.none;

                f.Clear();

                i.WhenContentReady(
                    body =>
                {
                    f.WriteHTMLElement(body.AsXElement());

                    // update
                    v.File = f;
                }
                    );
            }
                             );

            AddToolbarButton(new RTA_mode_html(), "Source raw",
                             delegate
            {
                v.Container.style.display = IStyle.DisplayEnum.none;
                ii.style.display          = IStyle.DisplayEnum.empty;
                i.style.display           = IStyle.DisplayEnum.none;



                i.WhenContentReady(
                    body =>
                {
                    ii.innerText = body.AsXElement().ToString();
                }
                    );
            }
                             );

            page.PageContainer.Add(Container);

            new ApplicationWebService().WebMethod2(
                new XElement(@"Document",
                             new object[] {
                new XElement(@"Data",
                             new object[] {
                    @"Hello world"
                }
                             ),
                new XElement(@"Client",
                             new object[] {
                    @"Unchanged text"
                }
                             )
            }
                             ),
                delegate(XElement doc)
            {
                // Show server message as document title
                // http://do.jsc-solutions.net/Show-server-message-as-document-title

                doc.Element(@"Data").Value.ToDocumentTitle();
            }
                );
        }