Provides HTML rendering using the text property.
WinForms control that will render html content in it's client rectangle.
If AutoScroll is true and the layout of the html resulted in its content beyond the client bounds of the panel it will show scrollbars (horizontal/vertical) allowing to scroll the content.
If AutoScroll is false html content outside the client bounds will be clipped.
The control will handle mouse and keyboard events on it to support html text selection, copy-paste and mouse clicks.

The major differential to use HtmlPanel or HtmlLabel is size and scrollbars.
If the size of the control depends on the html content the HtmlLabel should be used.
If the size is set by some kind of layout then HtmlPanel is more suitable, also shows scrollbars if the html contents is larger than the control client rectangle.

AutoScroll:

Allows showing scrollbars if html content is placed outside the visible boundaries of the panel.

LinkClicked event:

Raised when the user clicks on a link in the html.
Allows canceling the execution of the link.

StylesheetLoad event:

Raised when a stylesheet is about to be loaded by file path or URI by link element.
This event allows to provide the stylesheet manually or provide new source (file or uri) to load from.
If no alternative data is provided the original source will be used.

ImageLoad event:

Raised when an image is about to be loaded by file path or URI.
This event allows to provide the image manually, if not handled the image will be loaded from file or download from URI.

RenderError event:

Raised when an error occurred during html rendering.

Inheritance: System.Windows.Forms.ScrollableControl
Exemplo n.º 1
0
        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.AttachEvent(UIEventName.MouseDown, e =>
                        {
#if DEBUG
                            // System.Diagnostics.Debugger.Break();
                            //test change span property

                            //clear prev content and add new  text content
                            span.ClearAllElements();
                            span.AddTextContent("XYZ0001");

                            //affect layout of html dom
                            panel.ForceRefreshHtmlDomChange(htmldoc);
#endif

                            e.StopPropagation();
                        });
                    });

                    div.AddChild("span", span =>
                    {
                        span.AddTextContent("EFGHIJK");
                    });

                    //----------------------

                    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);
        }
        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
                            // System.Diagnostics.Debugger.Break();                           
                            //test change span property 
                            //clear prev content and add new  text content 
                            span.ClearAllElements();
                            span.AddTextContent("XYZ0001");
#endif

                            e.StopPropagation();
                        });
                    });
                    div.AddChild("span", span =>
                    {
                        span.AddTextContent("EFGHIJK");
                        span.AttachMouseDownEvent(e =>
                        {
                            span.ClearAllElements();
                            span.AddTextContent("LMNOP0003");
                        });
                    });
                    //----------------------
                    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);
        }
        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.AttachEvent(UIEventName.MouseDown, e =>
                        {
                            //-------------------------------
                            //mousedown on specific span !
                            //-------------------------------
#if DEBUG
                            // System.Diagnostics.Debugger.Break();
                            //Console.WriteLine("span");
#endif

                            //test stop propagation
                            e.StopPropagation();
                        });
                    });
                    //----------------------
                    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);
        }
        protected override void OnStartDemo(HtmlPanel panel)
        {
            var htmldoc = panel.HtmlHost.CreatePresentationHtmlDoc();
            var rootNode = htmldoc.RootNode;
            //1. create body node             
            // and content 

            DomElement body, div, span;
            //style 1
            rootNode.AddChild("body")
                        .AddChild("div", out div)
                            .AddChild("span", out span);
            //-------------------------------------------- 
            span.AddTextContent("ABCD");
            //2. add to view 
            panel.LoadHtmlDom(htmldoc,
               LayoutFarm.Composers.CssDefaults.DefaultStyleSheet);
            //3. attach event to specific span
            span.AttachEvent(UIEventName.MouseDown, e =>
            {
                //-------------------------------
                //mousedown on specific span !
                //-------------------------------
#if DEBUG
                // System.Diagnostics.Debugger.Break();
                //Console.WriteLine("span");
#endif
                //test stop propagation 
                e.StopPropagation();
            });
            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

            });
        }
Exemplo n.º 5
0
 public void StartDemo(HtmlPanel panel)
 {
     this.OnStartDemo(panel);
 }
Exemplo n.º 6
0
 protected virtual void OnStartDemo(HtmlPanel panel)
 {
 }
Exemplo n.º 7
0
 public void StartDemo(HtmlPanel panel)
 {
     this.OnStartDemo(panel);
 }
Exemplo n.º 8
0
 protected virtual void OnStartDemo(HtmlPanel panel)
 {
 }
Exemplo n.º 9
0
        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);
        }
Exemplo n.º 10
0
        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);
        }