protected override void OnStart(AppHost host, IGameHTMLUI pcx)
        {
            base.OnStart(host, pcx); //setup

            WebDom.DomElement rootNode = _groundHtmlDoc.RootNode;

            //style 2, lambda and adhoc attach event
            rootNode.AddChild("body", body =>
            {
                body.AddChild("div", div =>
                {
                    div.AddChild("span", span =>
                    {
                        span.AddTextContent("ABCD");
                        //3. attach event to specific span
                        span.AttachMouseDownEvent(e =>
                        {
#if DEBUG
                            var s_span = new EaseScriptElement(span);
                            s_span.ChangeFontColor(PixelFarm.Drawing.Color.Blue);
#endif

                            e.StopPropagation();
                        });
                    });
                    div.AddChild("span", span =>
                    {
                        span.AddTextContent("EFGHIJK");
                        span.AttachMouseDownEvent(e =>
                        {
                            span.ClearAllElements();
                            span.AddTextContent("LMNOP0003");
                            var s_span = new EaseScriptElement(span);
                            s_span.ChangeFontColor(PixelFarm.Drawing.Color.Red);
                            s_span.ChangeBackgroundColor(PixelFarm.Drawing.Color.Yellow);
                        });
                        span.AttachMouseUpEvent(e =>
                        {
                            var s_span = new EaseScriptElement(span);
                            s_span.ChangeFontColor(PixelFarm.Drawing.Color.Black);
                            s_span.ChangeBackgroundColor(PixelFarm.Drawing.Color.White);
                        });
                    });
                    //----------------------
                    div.AttachEvent(UIEventName.MouseDown, e =>
                    {
#if DEBUG
                        //this will not print
                        //if e has been stop by its child
                        // System.Diagnostics.Debugger.Break();
                        //Console.WriteLine("div");
#endif
                    });
                });
            });
        }
Exemple #2
0
 public override WebDom.DomElement GetPresentationDomNode(WebDom.Impl.HtmlDocument htmldoc)
 {
     if (pnode != null) return pnode;
     //--------------------------------
     pnode = htmldoc.CreateElement("div");
     pnode.SetAttribute("style", "font:10pt tahoma;overflow:scroll;height:300px;");
     int j = items.Count;
     if (j > 0)
     {
         for (int i = 0; i < j; ++i)
         {
             //itemnode
             pnode.AddChild(items[i].GetPresentationNode(pnode));
         }
     }
     return pnode;
 }
        public static MyHtmlVisualRoot CreateHtmlVisualRootFromFragmentHtml(
            HtmlHost htmlHost,
            string htmlFragment,
            HtmlRenderBox htmlFrgmentRenderBox)
        {
            HtmlDocument htmldoc = htmlHost.CreateNewSharedHtmlDoc();

            WebDom.DomElement myHtmlBodyElement = htmldoc.CreateElement("body");
            htmldoc.RootNode.AddChild(myHtmlBodyElement);
            //data is wraped up within div?
            //TODO: review this, use shadow dom instead
            WebDom.DomElement newDivHost = htmldoc.CreateElement("div");
            myHtmlBodyElement.AddChild(newDivHost);
            WebDocumentParser.ParseHtmlDom(
                new LayoutFarm.WebDom.Parser.TextSource(htmlFragment.ToCharArray()),
                htmldoc,
                newDivHost);
            //1. builder
            RenderTreeBuilder renderTreeBuilder = htmlHost.GetRenderTreeBuilder();
            //-------------------------------------------------------------------
            //2. generate render tree
            CssBox rootElement = renderTreeBuilder.BuildCssRenderTree(
                htmldoc,
                htmldoc.CssActiveSheet,
                htmlFrgmentRenderBox);
            //3. create small htmlContainer

            MyHtmlVisualRoot htmlContainer = new MyHtmlVisualRoot(htmlHost);

            htmlContainer.WebDocument = newDivHost.OwnerDocument;
            htmlContainer.SetRootCssBox(rootElement);
            htmlContainer.SetMaxSize(htmlFrgmentRenderBox.Width, 0);
            //htmlContainer.SetRootRenderElement(htmlFrgmentRenderBox);

            //
            LayoutVisitor lay = htmlHost.GetSharedHtmlLayoutVisitor(htmlContainer);

            htmlContainer.PerformLayout(lay);
            htmlHost.ReleaseHtmlLayoutVisitor(lay);
            htmlFrgmentRenderBox.SetHtmlContainer(htmlContainer, rootElement);
            return(htmlContainer);
        }
Exemple #4
0
        public override WebDom.DomElement GetPresentationDomNode(WebDom.Impl.HtmlDocument htmldoc)
        {
            if (pnode != null)
            {
                return(pnode);
            }
            //--------------------------------
            pnode = htmldoc.CreateElement("div");
            pnode.SetAttribute("style", "font:10pt tahoma;overflow:scroll;height:300px;");
            int j = items.Count;

            if (j > 0)
            {
                for (int i = 0; i < j; ++i)
                {
                    //itemnode
                    pnode.AddChild(items[i].GetPresentationNode(pnode));
                }
            }
            return(pnode);
        }
Exemple #5
0
        public WebDom.DomElement GetPresentationNode(WebDom.DomElement hostNode)
        {
            if (pnode != null)
            {
                return(pnode);
            }
            //------------------------------
            if (itemText == null)
            {
                itemText = "";
            }
            var ownerdoc = hostNode.OwnerDocument;

            pnode = ownerdoc.CreateElement("div");
            // pnode.SetAttribute("style", "font:10pt tahoma");

            textSpanNode = ownerdoc.CreateElement("span");
            textSpanNode.AddChild(ownerdoc.CreateTextNode(itemText.ToCharArray()));
            pnode.AddChild(textSpanNode);
            return(pnode);
        }
        public static void ParseHtmlDom(TextSource snapSource, IHtmlDocument htmldoc, WebDom.DomElement parentElement)
        {
            var parser = GetHtmlParser();

            //------------------------
            parser.Parse(snapSource, (LayoutFarm.WebDom.Impl.HtmlDocument)htmldoc, parentElement);
            FreeHtmlParser(parser);
        }
Exemple #7
0
 protected void AddToViewport(HtmlWidgets.HtmlWidgetBase htmlWidget)
 {
     //
     WebDom.DomElement presentationDomNode = htmlWidget.GetPresentationDomNode((HtmlElement)_groundHtmlDoc.RootNode);
     _groundHtmlDoc.BodyElement.AddChild(presentationDomNode);
 }
Exemple #8
0
 public EaseDomElement(WebDom.DomElement domElement)
 {
     this.easeScriptElement = new EaseScriptElement(domElement);
 }
Exemple #9
0
        public WebDom.DomElement GetPresentationNode(WebDom.DomElement hostNode)
        {
            if (pnode != null) return pnode;
            //------------------------------
            if (itemText == null)
            {
                itemText = "";
            }
            var ownerdoc = hostNode.OwnerDocument;
            pnode = ownerdoc.CreateElement("div");
            // pnode.SetAttribute("style", "font:10pt tahoma");

            textSpanNode = ownerdoc.CreateElement("span");
            textSpanNode.AddChild(ownerdoc.CreateTextNode(itemText.ToCharArray()));
            pnode.AddChild(textSpanNode);
            return pnode;
        }