示例#1
0
        void InternalSetAcceptsReturn(bool value)
        {
            if (value)
            {
                if (InternalTextField != null)
                {
                    if (InternalTextField_MultiLine == null)
                    {
                        // known situation

                        this.InternalTextField_MultiLine = new IHTMLTextArea(this.InternalTextField.value)
                        {
                            readOnly = this.InternalTextField.readOnly,
                            wrap     = "off"
                        };
                        this.InternalTextField_MultiLine.style.margin        = "0";
                        this.InternalTextField_MultiLine.style.paddingTop    = "0";
                        this.InternalTextField_MultiLine.style.paddingBottom = "0";
                        this.InternalTextField_MultiLine.style.position      = IStyle.PositionEnum.absolute;
                        this.InternalTextField_MultiLine.style.SetLocation(0, 0);
                        this.InternalTextField_MultiLine.style.overflow = IStyle.OverflowEnum.hidden;
                        this.InternalTextField_MultiLine.style.resize   = "none";


                        // is it tested with the shadow dom?
                        var p = this.InternalTextField.parentNode;

                        // we should actually just notify our collection about this change
                        // but instead we do the exchange here at the moment
                        if (p != null)
                        {
                            p.insertBefore(this.InternalTextField_MultiLine, this.InternalTextField);

                            p.removeChild(this.InternalTextField);

                            //Console.WriteLine("InternalSetAcceptsReturn!!");
                        }

                        // lets apply current font - probably is the default font...
                        this.FontFamily = this.InternalFontFamily;
                        this.FontSize   = this.InternalFontSize;

                        Action InternalAutoSizeUpdate =
                            delegate
                        {
                            if (this.InternalTextField_Shadow == null)
                            {
                                return;
                            }

                            this.InternalAutoSizeToText(this.InternalTextField_MultiLine.value);
                        };

                        this.InternalTextField_MultiLine.onchange +=
                            delegate
                        {
                            InternalAutoSizeUpdate();
                        };

                        this.InternalTextField_MultiLine.onkeyup +=
                            delegate
                        {
                            InternalAutoSizeUpdate();
                        };

                        InternalUpdateBackground();
                        InternalUpdateBorderThickness();
                        InternalUpdateForeground();

                        return;
                    }
                }
            }

            throw new NotImplementedException();
        }
示例#2
0
        //override
        void InternalSetAcceptsReturn(bool value)
        {
            if (value)
            {
                if (InternalTextField != null)
                {
                    if (InternalTextField_MultiLine == null)
                    {
                        // known situation

                        this.InternalTextField_MultiLine = new IHTMLTextArea(this.InternalTextField.value)
                        {
                            readOnly = this.InternalTextField.readOnly,
                            wrap     = "off"
                        };

                        // X:\jsc.svn\examples\javascript\forms\SQLiteConsoleExperiment\SQLiteConsoleExperiment\ApplicationControl.cs

                        //refresh

                        this.InternalTextField_MultiLine.style.margin        = "0";
                        this.InternalTextField_MultiLine.style.paddingTop    = "0";
                        this.InternalTextField_MultiLine.style.paddingBottom = "0";
                        this.InternalTextField_MultiLine.style.position      = IStyle.PositionEnum.absolute;
                        this.InternalTextField_MultiLine.style.SetLocation(0, 0);
                        this.InternalTextField_MultiLine.style.overflow = IStyle.OverflowEnum.hidden;
                        this.InternalTextField_MultiLine.style.resize   = "none";
                        this.InternalTextField_MultiLine.style.outline  = "none";
                        // http://www.electrictoolbox.com/disable-textarea-resizing-safari-chrome/


                        this.BackColor   = this.BackColor;
                        this.ForeColor   = this.ForeColor;
                        this.BorderStyle = this.BorderStyle;


                        if (InternalUpdateScrollBars != null)
                        {
                            InternalUpdateScrollBars();
                        }

                        var p = this.InternalTextField.parentNode;

                        // we should actually just notify our collection about this change
                        // but instead we do the exchange here at the moment
                        if (p != null)
                        {
                            p.insertBefore(this.InternalTextField_MultiLine, this.InternalTextField);

                            p.removeChild(this.InternalTextField);

                            //Console.WriteLine("InternalSetAcceptsReturn!!");
                        }



                        this.InternalTextField_MultiLine.style.width  = "100%";
                        this.InternalTextField_MultiLine.style.height = "100%";

                        // lets apply current font - probably is the default font...
                        //this.FontFamily = this.InternalFontFamily;
                        //this.FontSize = this.InternalFontSize;
                        this.InternalSetFont(this.Font);

                        Action InternalAutoSizeUpdate =
                            delegate
                        {
                            if (this.InternalTextField_Shadow == null)
                            {
                                return;
                            }

                            //this.InternalAutoSizeToText(this.InternalTextField_MultiLine.value);
                        };

                        this.InternalTextField_MultiLine.onchange +=
                            delegate
                        {
                            InternalAutoSizeUpdate();
                            this.InternalRaiseTextChanged();
                        };

                        this.InternalTextField_MultiLine.onkeyup +=
                            delegate
                        {
                            InternalAutoSizeUpdate();
                            this.InternalRaiseTextChanged();
                        };

                        //InternalUpdateBackground();
                        //InternalUpdateBorderThickness();
                        //InternalUpdateForeground();

                        return;
                    }
                }
            }

            throw new NotImplementedException();
        }
        /// <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(IDefault page)
        {
            @"Hello world".ToDocumentTitle();

            var output = new IHTMLTextArea().AttachToDocument();

            var gexf = new XElement("gexf");

            gexf.Add(
                new XElement("meta",
                             new XElement("creator", "jsc"),
                             new XElement("description", "NASDAQSNA")
                             )
                );

            var graph = new XElement("graph",
                                     new XAttribute("mode", "static"),
                                     new XAttribute("defaultedgetype", "directed")
                                     );

            gexf.Add(graph);

            var nodes = new XElement("nodes");

            graph.Add(nodes);

            var edges = new XElement("edges");

            graph.Add(edges);

            output.value    = gexf.ToString();
            output.onfocus +=
                delegate
            {
                output.value = gexf.ToString();
            };
            output.onmouseover +=
                delegate
            {
                output.value = gexf.ToString();
            };

            var NumericNodeIdLookup = new List <string>();

            Func <string, int> GetNumericNodeId =
                k =>
            {
                if (!NumericNodeIdLookup.Contains(k))
                {
                    NumericNodeIdLookup.Add(k);
                }


                return(NumericNodeIdLookup.IndexOf(k));
            };

            #region AddRelatedCompanies
            Func <IHTMLDiv, string, Action, Task> AddRelatedCompanies = null;

            AddRelatedCompanies =
                (c, qid, done) =>
            {
                var nqid = GetNumericNodeId(qid).ToString();
                var cc   = new IHTMLDiv();

                cc.style.marginLeft = "2em";



                var service = new ApplicationWebService
                {
                    qid   = qid,
                    yield = (id, CompanyName, Price) =>
                    {
                        var nid = GetNumericNodeId(id).ToString();

                        if (nodes.Elements().Any(k => k.Attribute("id").Name.LocalName == nid))
                        {
                        }
                        else
                        {
                            nodes.Add(
                                new XElement("node",
                                             new XAttribute("id", nid),
                                             new XAttribute("label", CompanyName)
                                             )
                                );
                        }



                        var btn = new IHTMLButton
                        {
                            innerText = id + " " + CompanyName + " " + Price
                        };

                        btn.style.display = IStyle.DisplayEnum.block;

                        if (qid == id)
                        {
                            btn.disabled = true;

                            if (c == null)
                            {
                                btn.AttachToDocument();
                                cc.AttachToDocument();
                            }
                            else
                            {
                                //btn.AttachTo(c);
                                cc.AttachTo(c);
                            }

                            if (done != null)
                            {
                                done();
                            }
                        }
                        else
                        {
                            edges.Add(
                                new XElement("edge",
                                             new XAttribute("source", nqid),
                                             new XAttribute("target", nid)
                                             )
                                );

                            btn.AttachTo(cc);

                            var ccc = new IHTMLDiv();

                            ccc.AttachTo(cc);

                            int cx = 0;

                            ccc.ToggleVisible();



                            btn.WhenClicked(
                                async delegate
                            {
                                if (cx == 0)
                                {
                                    btn.style.color = JSColor.Red;

                                    await AddRelatedCompanies(ccc, id,
                                                              delegate
                                    {
                                        btn.style.color = JSColor.Blue;
                                    }
                                                              );
                                }


                                cx++;

                                ccc.ToggleVisible();
                            }
                                );
                        }
                    }
                };



                return(service.GetRelatedCompanies());
            };
            #endregion

            AddRelatedCompanies(null, "NASDAQ:FB", null);
            AddRelatedCompanies(null, "NASDAQ:GOOG", null);
        }
示例#4
0
        public Application(IHTMLElement e)
        {
            Native.Document.title = "IntelliSense1";

            var c = new IHTMLDiv
            {
            }.AttachToDocument();

            c.onmouseover +=
                delegate
            {
                c.style.backgroundColor = "#efefff";
            };

            c.onmouseout +=
                delegate
            {
                c.style.backgroundColor = "";
            };


            c.style.margin     = "2em";
            c.style.padding    = "2em";
            c.style.border     = "1px solid #777777";
            c.style.borderLeft = "2em solid #777777";


            new IHTMLDiv
            {
                new IHTMLAnchor
                {
                    innerText = "Write javascript, flash and java applets within a C# project.",
                    href      = "http://www.jsc-solutions.net"
                }
            }.AttachTo(c);


            {
                var btn = new IHTMLButton {
                    innerText = "UltraWebService"
                }.AttachTo(c);

                btn.onclick +=
                    delegate
                {
                    new UltraWebService().GetTime("time: ",
                                                  result =>
                    {
                        new IHTMLDiv {
                            innerText = result
                        }.AttachTo(c);
                    }
                                                  );
                };
            }

            var Editor = new IHTMLDiv().AttachToDocument();

            Editor.style.position        = IStyle.PositionEnum.relative;
            Editor.style.backgroundColor = "#efefef";
            Editor.style.SetSize(400, 200);
            //Editor.style.overflow = IStyle.OverflowEnum.auto;

            var CodeShadowContainer = new IHTMLDiv().AttachTo(Editor);
            var CodeShadowSize      = new IHTMLSpan().AttachTo(CodeShadowContainer);
            var CodeShadow          = new IHTMLSpan().AttachTo(CodeShadowContainer);
            var CodeShadowLine      = new IHTMLSpan().AttachTo(CodeShadowContainer);
            var CodeShadowMenu      = new IHTMLDiv().AttachTo(CodeShadowContainer);

            CodeShadowMenu.style.backgroundColor = "red";

            var Code = new IHTMLTextArea().AttachTo(Editor);

            Code.style.SetLocation(0, 0, 400, 200);

            CodeShadowSize.style.position = IStyle.PositionEnum.absolute;
            CodeShadowSize.style.SetLocation(0, 0);

            CodeShadow.style.position = IStyle.PositionEnum.absolute;
            CodeShadow.style.SetLocation(0, 0);

            CodeShadowLine.style.position = IStyle.PositionEnum.absolute;
            CodeShadowLine.style.SetLocation(0, 0);

            CodeShadowContainer.style.SetLocation(0, 0, 400, 200);

            Action Update =
                delegate
            {
                CodeShadowSize.innerText = Code.value;

                var n = Code.value.Substring(0, Code.SelectionStart).Replace("\r", "");

                CodeShadow.innerText     = n;
                CodeShadowLine.innerText = n.SkipUntilLastIfAny("\n");

                //var w = CodeShadowSize.offsetWidth;
                //if (w < 400)
                //    w = 400;

                //var h = CodeShadowSize.offsetHeight;
                //if (h < 200)
                //    h = 200;

                //Code.style.SetSize(w, h);

                if (n.EndsWith("."))
                {
                    CodeShadowMenu.style.SetLocation(
                        CodeShadowLine.offsetWidth,
                        CodeShadow.offsetHeight,
                        64, 32
                        );
                }
                else
                {
                    CodeShadowMenu.style.SetLocation(
                        CodeShadowLine.offsetWidth,
                        CodeShadow.offsetHeight,
                        12, 12
                        );
                }
            };

            Code.onkeyup +=
                delegate
            {
                Update();
            };

            Code.onchange +=
                delegate
            {
                Update();
            };

            Code.onmouseup +=
                delegate
            {
                Update();
            };

            Action <IStyle> SetStyle =
                style =>
            {
                style.padding = "0";
                style.margin  = "0";
                style.display = IStyle.DisplayEnum.inline;

                style.fontFamily = ScriptCoreLib.JavaScript.DOM.IStyle.FontFamilyEnum.Verdana;
                style.fontSize   = "1em";

                // http://www.tagindex.net/css/form/line_height.html
                // http://www.eskimo.com/~bloo/indexdot/css/properties/dimension/lineheight.htm
                style.lineHeight = "200%";

                // http://www.w3schools.com/CSS/pr_text_white-space.asp
                style.whiteSpace = IStyle.WhiteSpaceEnum.pre;
                //style.textWrap =
            };

            Code.style.border = "0";

            // http://www.idocs.com/tags/forms/_TEXTAREA_WRAP.html
            Code.wrap                  = "off";
            Code.style.overflow        = IStyle.OverflowEnum.hidden;
            Code.style.backgroundColor = JSColor.Transparent;

            //if (IsMicrosoftInternetExplorer)
            //{
            //    CodeShadow.style.lineHeight = "125%";
            //}

            CodeShadow.style.color           = "gray";
            CodeShadow.style.backgroundColor = "yellow";

            CodeShadowLine.style.color           = "gray";
            CodeShadowLine.style.backgroundColor = "cyan";

            SetStyle(Code);
            SetStyle(CodeShadowSize);
            SetStyle(CodeShadow);
            SetStyle(CodeShadowLine);

            Code.value = "hello1\nhello2\nhello3 WWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWW\n...";
            Update();
        }