RegisterCssBoxGenerator() public method

public RegisterCssBoxGenerator ( LayoutFarm cssBoxGenerator ) : void
cssBoxGenerator LayoutFarm
return void
        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);

            List <HtmlBoxes.HtmlContainer> htmlContUpdateList = new List <HtmlBoxes.HtmlContainer>();

            sampleViewport.Root.ClearingBeforeRender += (s, e) =>
            {
                //1.
                htmlhost.ClearUpdateWaitingCssBoxes();
                //1.
                int j = htmlContUpdateList.Count;
                for (int i = 0; i < j; ++i)
                {
                    var htmlCont = htmlContUpdateList[i];
                    htmlCont.RefreshDomIfNeed();
                    htmlCont.IsInUpdateQueue = false;
                }
                htmlContUpdateList.Clear();
            };
            htmlhost.RegisterCssBoxGenerator(new LayoutFarm.CustomWidgets.MyCustomCssBoxGenerator(htmlhost));
            htmlhost.AttachEssentailHandlers(imageReqHandler, textReq);
            htmlhost.SetHtmlContainerUpdateHandler(htmlCont =>
            {
                if (!htmlCont.IsInUpdateQueue)
                {
                    htmlCont.IsInUpdateQueue = true;
                    htmlContUpdateList.Add(htmlCont);
                }
            });
            return(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;
 }
示例#3
0
        public static HtmlBoxes.HtmlHost CreateHtmlHost(SampleViewport sampleViewport,
                                                        EventHandler <ContentManagers.ImageRequestEventArgs> imageReqHandler,
                                                        EventHandler <ContentManagers.TextRequestEventArgs> textReq)
        {
            HtmlBoxes.HtmlHost htmlhost = new HtmlBoxes.HtmlHost(sampleViewport.P);
            htmlhost.SetRootGraphics(sampleViewport.Root);
            htmlhost.RegisterCssBoxGenerator(new LayoutFarm.CustomWidgets.MyCustomCssBoxGenerator(htmlhost));

            htmlhost.AttachEssentailHandlers(imageReqHandler, textReq);
            htmlhost.SetHtmlContainerUpdateHandler(htmlCont =>
            {
                sampleViewport.Root.AddToUpdateQueue(htmlCont);
            });
            return(htmlhost);
        }
示例#4
0
        public static HtmlBoxes.HtmlHost CreateHtmlHost(AppHost appHost,
                                                        EventHandler <ContentManagers.ImageRequestEventArgs> imageReqHandler,
                                                        EventHandler <ContentManagers.TextRequestEventArgs> textReq)
        {
            List <HtmlBoxes.HtmlVisualRoot> htmlVisualRootUpdateList = new List <HtmlBoxes.HtmlVisualRoot>();

            var config = new HtmlBoxes.HtmlHostCreationConfig()
            {
                RootGraphic = appHost.RootGfx,
                TextService = appHost.RootGfx.TextServices
            };

            //1.
            HtmlBoxes.HtmlHost htmlhost = new HtmlBoxes.HtmlHost(config);  //create html host with config
            appHost.RootGfx.ClearingBeforeRender += (s, e) =>
            {
                //
                htmlhost.ClearUpdateWaitingCssBoxes();
                //
                int j = htmlVisualRootUpdateList.Count;
                for (int i = 0; i < j; ++i)
                {
                    HtmlBoxes.HtmlVisualRoot htmlVisualRoot = htmlVisualRootUpdateList[i];
                    htmlVisualRoot.RefreshDomIfNeed();
                    htmlVisualRoot.IsInUpdateQueue = false;
                }
                htmlVisualRootUpdateList.Clear();
            };
            //2.
            htmlhost.RegisterCssBoxGenerator(new LayoutFarm.CustomWidgets.MyCustomCssBoxGenerator(htmlhost));
            //3.
            htmlhost.AttachEssentailHandlers(imageReqHandler, textReq);
            //4.
            htmlhost.SetHtmlVisualRootUpdateHandler(htmlVisualRoot =>
            {
                if (!htmlVisualRoot.IsInUpdateQueue)
                {
                    htmlVisualRoot.IsInUpdateQueue = true;
                    htmlVisualRootUpdateList.Add(htmlVisualRoot);
                }
            });

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

            if (PaintLab.Svg.VgResourceIO.VgImgIOHandler == null)
            {
                var imgLoadingQ = new ContentManagers.ImageLoadingQueueManager();
                imgLoadingQ.AskForImage += (s, e) =>
                {
                    //check loading policy here
                    //
                    e.SetResultImage(LoadImage(e.ImagSource));
                };
                PaintLab.Svg.VgResourceIO.VgImgIOHandler = (LayoutFarm.ImageBinder binder, PaintLab.Svg.VgVisualElement imgRun, object requestFrom) =>
                {
                    imgLoadingQ.AddRequestImage(binder);
                };
            }

            return(htmlhost);
        }