LayoutFarm.HtmlHostCreatorHelper.CreateHtmlHost C# (CSharp) Method

CreateHtmlHost() public static method

public static CreateHtmlHost ( SampleViewport sampleViewport, EventHandler imageReqHandler, EventHandler textReq ) : HtmlHost
sampleViewport SampleViewport
imageReqHandler EventHandler
textReq EventHandler
return LayoutFarm.HtmlBoxes.HtmlHost
        public static HtmlBoxes.HtmlHost CreateHtmlHost(SampleViewport sampleViewport,
            EventHandler<ContentManagers.ImageRequestEventArgs> imageReqHandler,
            EventHandler<ContentManagers.TextRequestEventArgs> textReq)
        {
            HtmlBoxes.HtmlHost htmlhost = new HtmlBoxes.HtmlHost();
            htmlhost.SetRootGraphics(sampleViewport.Root);
            htmlhost.RegisterCssBoxGenerator(new LayoutFarm.CustomWidgets.MyCustomCssBoxGenerator(htmlhost));
            htmlhost.AttachEssentailHandlers(imageReqHandler, textReq);
            htmlhost.SetHtmlContainerUpdateHandler(htmlCont =>
            {
                sampleViewport.Root.AddToUpdateQueue(htmlCont);
            });
            return htmlhost;
        }
    }

Usage Example

        HtmlBoxes.HtmlHost GetHtmlHost(AppHost host)
        {
            if (htmlHost == null)
            {
                htmlHost = HtmlHostCreatorHelper.CreateHtmlHost(host,
                                                                //1. img request
                                                                (s, e) =>
                {
                    //load resource -- sync or async?
                    string absolutePath = imgFolderPath + "\\" + e.ImageBinder.ImageSource;
                    if (!System.IO.File.Exists(absolutePath))
                    {
                        return;
                    }

                    //load create and load bitmap
                    e.ImageBinder.SetLocalImage(host.LoadImage(absolutePath));
                },
                                                                //2. stylesheet request
                                                                (s, e) =>
                {
                });
            }
            return(htmlHost);
        }
All Usage Examples Of LayoutFarm.HtmlHostCreatorHelper::CreateHtmlHost
HtmlHostCreatorHelper