ChangeBackgroundColor() public method

public ChangeBackgroundColor ( Color backgroundColor ) : void
backgroundColor PixelFarm.Drawing.Color
return void
Beispiel #1
0
        public override DomElement GetPresentationDomNode(WebDom.Impl.HtmlDocument htmldoc)
        {
            if (pnode != null) return pnode;
            //----------------------------------
            pnode = htmldoc.CreateElement("div");
            pnode.SetAttribute("style", "display:inline-block;width:" + Width + "px;height:" + this.Height + "px;");
            pnode.AddChild("div", div2 =>
            {
                //init
                div2.SetAttribute("style", "padding:5px;background-color:#dddddd;");
                div2.AddChild("span", span =>
                {
                    span.AddTextContent(this.buttonText);
                });
                //------------------------------

                div2.AttachMouseDownEvent(e =>
                {
#if DEBUG
                    div2.dbugMark = 1;
#endif
                    // div2.SetAttribute("style", "padding:5px;background-color:#aaaaaa;");
                    EaseScriptElement ee = new EaseScriptElement(div2);
                    ee.ChangeBackgroundColor(Color.FromArgb(0xaa, 0xaa, 0xaa));
                    //div2.SetAttribute("style", "padding:5px;background-color:#aaaaaa;");
                    e.StopPropagation();
                });
                div2.AttachMouseUpEvent(e =>
                {
#if DEBUG
                    div2.dbugMark = 2;
#endif
                    //div2.SetAttribute("style", "padding:5px;background-color:#dddddd;");

                    EaseScriptElement ee = new EaseScriptElement(div2);
                    ee.ChangeBackgroundColor(Color.FromArgb(0xdd, 0xdd, 0xdd));
                    e.StopPropagation();
                });
            });
            return pnode;
        }
        protected override void OnStartDemo(HtmlPanel panel)
        {
            var htmldoc = panel.HtmlHost.CreatePresentationHtmlDoc();
            var rootNode = htmldoc.RootNode;
            //1. create body node             
            // and content  

            //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

                    });
                });
            });
            //2. add to view 
            panel.LoadHtmlDom(htmldoc,
               LayoutFarm.Composers.CssDefaults.DefaultStyleSheet);
        }