/// <summary> /// Init. /// </summary> public DemoForm(PixelFarm.Drawing.GraphicsPlatform p) { this.graphicsPlatform = p; this._htmlPanel = new LayoutFarm.Demo.HtmlPanel(this.graphicsPlatform, 800, 600); this.htmlHost = new LayoutFarm.HtmlBoxes.HtmlHost(p); htmlHost.AttachEssentailHandlers( this.HandleImageRequest, this.HandleStylesheetRequest); _htmlPanel.SetHtmlHost(htmlHost); InitializeComponent(); //_htmlToolTip.ImageLoad += OnImageLoad; //_htmlToolTip.SetToolTip(_htmlPanel, Resources.Tooltip); _htmlEditor.Font = new Font(FontFamily.GenericMonospace, 10); StartPosition = FormStartPosition.CenterScreen; var size = Screen.GetWorkingArea(Point.Empty); Size = new Size((int)(size.Width * 0.7), (int)(size.Height * 0.8)); _updateHtmlTimer = new Timer(OnUpdateHtmlTimerTick); this.Text += " : " + Path.GetDirectoryName(Application.ExecutablePath); this._samplesTreeView.NodeMouseClick += new TreeNodeMouseClickEventHandler(_samplesTreeView_NodeMouseClick); }
protected override void OnStartDemo(SampleViewport viewport) { this.sampleViewport = viewport; imageContentMan = new ContentManagers.ImageContentManager(viewport.Platform); imageContentMan.ImageLoadingRequest += (s, e) => { e.SetResultImage(LoadBitmap(e.ImagSource)); }; //init host myHtmlHost = HtmlHostCreatorHelper.CreateHtmlHost(viewport, (s, e) => this.imageContentMan.AddRequestImage(e.ImageBinder), (s, e) => { }); //----------------------------------------------------- this.groundHtmlBox = new HtmlBox(myHtmlHost, 800, 600); string html = @"<div></div>"; //if you want to use full html-> use HtmlBox instead this.sampleViewport.AddContent(groundHtmlBox); //----------------------------------------------------- groundHtmlBox.LoadHtmlFragmentString(html); this.groundHtmlDoc = groundHtmlBox.HtmlContainer.WebDocument as HtmlDocument; OnHtmlHostCreated(); }
protected override void OnStart(AppHost host, IGameHTMLUI pcx) { _host = host; _imgLoadingQ = new ContentManagers.ImageLoadingQueueManager(); _imgLoadingQ.AskForImage += (s, e) => { e.SetResultImage(host.LoadImage(e.ImagSource)); }; //init host _myHtmlHost = HtmlHostCreatorHelper.CreateHtmlHost(host, (s, e) => _imgLoadingQ.AddRequestImage(e.ImageBinder), (s, e) => { }); //----------------------------------------------------- _groundHtmlBox = new HtmlBox(_myHtmlHost, 800, 600); string html = @"<div></div>"; //if you want to use full html-> use HtmlBox instead _host.AddChild(_groundHtmlBox); //----------------------------------------------------- _groundHtmlBox.LoadHtmlFragmentString(html); _groundHtmlDoc = _groundHtmlBox.HtmlDoc as HtmlDocument; OnHtmlHostCreated(); }
public static HtmlDocument ParseDocument(LayoutFarm.HtmlBoxes.HtmlHost htmlHost, ExternalHtmlTreeWalker externalTreeWalker) { HtmlDocument newdoc = new HtmlDocument(htmlHost); //start from HtmlElement domElem = (HtmlElement)newdoc.RootNode; Stack <HtmlElement> elemStack = new Stack <HtmlElement>(); HtmlElement newDomElem = null; foreach (ExternalHtmlNode node in externalTreeWalker.GetHtmlNodeIter()) { switch (node.HtmlNodeKind) { case ExternalHtmlNodeKind.EnterChildContext: { elemStack.Push(domElem); if (newDomElem != null) { domElem = newDomElem; } } break; case ExternalHtmlNodeKind.ExitChildContext: { domElem = elemStack.Pop(); } break; case ExternalHtmlNodeKind.Attribute: { node.GetAttributeNameAndValue(out string attrName, out string attrValue); DomAttribute attr = newdoc.CreateAttribute(attrName, attrValue); newDomElem.SetAttribute(attr); } break; case ExternalHtmlNodeKind.Element: newDomElem = (HtmlElement)newdoc.CreateElement(node.HtmlElementName); domElem.AddChild(newDomElem); //System.Diagnostics.Debug.WriteLine(new string(' ', node.Level) + node.HtmlElementName); break; case ExternalHtmlNodeKind.TextNode: DomTextNode textnode = newdoc.CreateTextNode(node.CurrentTextNodeContent.ToCharArray()); domElem.AddChild(textnode); //System.Diagnostics.Debug.WriteLine(new string(' ', node.Level) + node.CurrentTextNodeContent); break; case ExternalHtmlNodeKind.Document: //System.Diagnostics.Debug.WriteLine("Root"); break; } } return(newdoc); }
/// <summary> /// Parses the source html to css boxes tree structure. /// </summary> /// <param name="source">the html source to parse</param> public static HtmlDocument ParseDocument(LayoutFarm.HtmlBoxes.HtmlHost htmlHost, TextSource snapSource) { HtmlParser parser = GetHtmlParser(); //------------------------ HtmlDocument newdoc = new HtmlDocument(htmlHost); parser.Parse(snapSource, newdoc, newdoc.RootNode); FreeHtmlParser(parser); return(newdoc); }
/// <summary> /// Init. /// </summary> public DemoForm(PixelFarm.Drawing.GraphicsPlatform p) { this.graphicsPlatform = p; this._htmlPanel = new LayoutFarm.Demo.HtmlPanel(this.graphicsPlatform, 800, 600); this.htmlHost = new LayoutFarm.HtmlBoxes.HtmlHost(); htmlHost.AttachEssentailHandlers( this.HandleImageRequest, this.HandleStylesheetRequest); _htmlPanel.SetHtmlHost(htmlHost); InitializeComponent(); //_htmlToolTip.ImageLoad += OnImageLoad; //_htmlToolTip.SetToolTip(_htmlPanel, Resources.Tooltip); _htmlEditor.Font = new Font(FontFamily.GenericMonospace, 10); StartPosition = FormStartPosition.CenterScreen; var size = Screen.GetWorkingArea(Point.Empty); Size = new Size((int)(size.Width * 0.7), (int)(size.Height * 0.8)); _updateHtmlTimer = new Timer(OnUpdateHtmlTimerTick); this.Text += " : " + Path.GetDirectoryName(Application.ExecutablePath); this._samplesTreeView.NodeMouseClick += new TreeNodeMouseClickEventHandler(_samplesTreeView_NodeMouseClick); }
public void StartModule(LayoutFarm.SampleViewport sampleViewport) { this.viewport = sampleViewport; dzBoardModule = new DesignBoardModule(); menuModule = new MenuBoardModule(); menuModule.menuItemClick += new EventHandler<MenuItemClickEventArgs>(menuModule_menuItemClick); var contentMx = new LayoutFarm.ContentManagers.ImageContentManager(); contentMx.ImageLoadingRequest += contentMx_ImageLoadingRequest; //app specific here documentRootPath = System.Windows.Forms.Application.ExecutablePath; this.htmlHost = HtmlHostCreatorHelper.CreateHtmlHost(viewport, (s, e) => contentMx.AddRequestImage(e.ImageBinder), contentMx_LoadStyleSheet); //1. design board dzBoardModule.StartModule(htmlHost, this.viewport); ////2. canvas board //drawingBoard.StartModule(htmlHost, this.viewport); //3. menu menuModule.StartModule(htmlHost, this.viewport); //------------------------------------------------------ //context knowledge*** //------------------------------------------------------ }
public void StartModule(LayoutFarm.SampleViewport sampleViewport) { this.viewport = sampleViewport; dzBoardModule = new DesignBoardModule(); menuModule = new MenuBoardModule(); menuModule.menuItemClick += new EventHandler <MenuItemClickEventArgs>(menuModule_menuItemClick); var contentMx = new LayoutFarm.ContentManagers.ImageContentManager(sampleViewport.Platform); contentMx.ImageLoadingRequest += contentMx_ImageLoadingRequest; //app specific here documentRootPath = System.Windows.Forms.Application.ExecutablePath; this.htmlHost = HtmlHostCreatorHelper.CreateHtmlHost(viewport, (s, e) => contentMx.AddRequestImage(e.ImageBinder), contentMx_LoadStyleSheet); //1. design board dzBoardModule.StartModule(htmlHost, this.viewport); ////2. canvas board //drawingBoard.StartModule(htmlHost, this.viewport); //3. menu menuModule.StartModule(htmlHost, this.viewport); //------------------------------------------------------ //context knowledge*** //------------------------------------------------------ }
protected override void OnStartDemo(SampleViewport viewport) { this.sampleViewport = viewport; imageContentMan = new ContentManagers.ImageContentManager(); imageContentMan.ImageLoadingRequest += (s, e) => { e.SetResultImage(LoadBitmap(e.ImagSource)); }; //init host myHtmlHost = HtmlHostCreatorHelper.CreateHtmlHost(viewport, (s, e) => this.imageContentMan.AddRequestImage(e.ImageBinder), (s, e) => { }); //----------------------------------------------------- this.groundHtmlBox = new HtmlBox(myHtmlHost, 800, 600); string html = @"<div></div>"; //if you want to use full html-> use HtmlBox instead this.sampleViewport.AddContent(groundHtmlBox); //----------------------------------------------------- groundHtmlBox.LoadHtmlFragmentString(html); this.groundHtmlDoc = groundHtmlBox.HtmlContainer.WebDocument as HtmlDocument; OnHtmlHostCreated(); }