protected override void OnStartDemo(SampleViewport viewport) { ////================================================== //html box var htmlHost = HtmlHostCreatorHelper.CreateHtmlHost(viewport, null, null); var htmlBox = new HtmlBox(htmlHost, 800, 400); StringBuilder stbuilder = new StringBuilder(); stbuilder.Append("<html><head></head><body>"); stbuilder.Append("<div>custom box1</div>"); stbuilder.Append("<x id=\"my_custombox1\"></x>"); stbuilder.Append("<div>custom box2</div>"); stbuilder.Append("<x type=\"textbox\" id=\"my_custombox1\"></x>"); stbuilder.Append("</body></html>"); htmlBox.LoadHtmlString(stbuilder.ToString()); viewport.AddContent(htmlBox); //================================================== //textbox var textbox = new LayoutFarm.CustomWidgets.TextBox(400, 100, true); textbox.SetLocation(0, 200); viewport.AddContent(textbox); textbox.Focus(); }
protected override void OnStartModule() { var htmlBox = new HtmlBox(htmlHost, 500, 40); viewport.AddContent(htmlBox); //design buttons here string htmltext = @"<html><head></head><body id='body_elem'> <span id='cmd_box' style='padding:2px'>Box</span> <span id='cmd_rect' style='padding:2px'>Rect</span> <span id='cmd_img' style='padding:2px'>Image</span> </body></html>"; htmlBox.LoadHtmlString(htmltext); var dom1 = htmlBox.HtmlContainer.WebDocument as LayoutFarm.WebDom.IHtmlDocument; if (dom1 != null) { var bodyElemet = dom1.getElementById("body_elem"); bodyElemet.attachEventListener("mousedown", e => { var srcElement = e.ExactHitObject; HtmlBoxes.CssRun run = srcElement as HtmlBoxes.CssRun; if (run != null) { menuItemClick(this, new MenuItemClickEventArgs(run.Text)); } e.StopPropagation(); }); } }
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 virtual void OnStartDemo(SampleViewport viewport) { //html box var contentMx = new LayoutFarm.ContentManagers.ImageContentManager(); contentMx.ImageLoadingRequest += contentMx_ImageLoadingRequest; var host = HtmlHostCreatorHelper.CreateHtmlHost(viewport, (s, e) => contentMx.AddRequestImage(e.ImageBinder), contentMx_LoadStyleSheet); //1. htmlbox int viewportW = viewport.ViewportControl.Width; int viewportH = viewport.ViewportControl.Height; htmlBox = new HtmlBox(host, viewportW, viewportH); viewport.AddContent(htmlBox); if (htmltext == null) { htmltext = @"<html><head></head><body>NOT FOUND!</body></html>"; } htmlBox.LoadHtmlString(htmltext); }
private void ShowReportInPDF() { this.splitContainer1.Panel2.Controls.Clear(); Gizmox.WebGUI.Forms.HtmlBox htmlBox = new HtmlBox(); htmlBox.Dock = DockStyle.Fill; this.splitContainer1.Panel2.Controls.Add(htmlBox); Gizmox.WebGUI.Common.Gateways.GatewayReference gw = new Gizmox.WebGUI.Common.Gateways.GatewayReference(this, "LoadPDF", false); htmlBox.Url = gw.ToString(); }
protected override void OnStart(AppHost host) { { string html = @"<html><head></head><body><div>OK1</div><div>OK2</div></body></html>"; string testFilename = @"D:\projects\HtmlRenderer\Source\Test8_HtmlRenderer.Demo\Samples\0_acid1_dev\00.htm"; //string testFilename = "..\\Test8_HtmlRenderer.Demo\\Samples\\0_acid1_dev\\00.htm"; if (System.IO.File.Exists(testFilename)) { html = System.IO.File.ReadAllText(testFilename); } //html box1 HtmlBoxes.HtmlHost htmlhost = HtmlHostCreatorHelper.CreateHtmlHost(host, null, null); //html box var htmlBox = new HtmlBox(htmlhost, 800, 600); htmlBox.SetLocation(0, 0); //htmlBox.PreferSoftwareRenderer = true; host.AddChild(htmlBox); htmlBox.LoadHtmlString(html); //================================================== } { //html box2 HtmlBoxes.HtmlHost htmlhost = HtmlHostCreatorHelper.CreateHtmlHost(host, null, null); //html box var htmlBox = new HtmlBox(htmlhost, 800, 400); #if DEBUG htmlBox.dbugPreferSoftwareRenderer = true; #endif htmlBox.SetLocation(0, 610);//** host.AddChild(htmlBox); string html = @"<html><head></head><body><div>OK3</div><div>OK4</div></body></html>"; htmlBox.LoadHtmlString(html); //================================================== } //{ // //textbox // var textbox = new LayoutFarm.CustomWidgets.TextBox(400, 25, true); // textbox.SetLocation(0, 0); // host.AddChild(textbox); // textbox.Focus(); //} }
protected override void OnStartDemo(SampleViewport viewport) { this.viewport = viewport; this.htmlhost = HtmlHostCreatorHelper.CreateHtmlHost(viewport, null, null); SetupHtmlMenuBox(); //================================================== //box1 test area //html box this.testHtmlBox = new HtmlBox(htmlhost, 800, 400); testHtmlBox.SetLocation(30, 50); viewport.AddContent(testHtmlBox); string html = @"<html><head></head><body><div id='div1'>OK1</div><div>OK2</div></body></html>"; testHtmlBox.LoadHtmlString(html); //================================================== }
protected override void OnStart(AppHost host, IGameHTMLUI pcx) { _host = host; this.htmlhost = HtmlHostCreatorHelper.CreateHtmlHost(host, null, null); SetupHtmlMenuBox(); //================================================== //box1 test area //html box this.testHtmlBox = new HtmlBox(htmlhost, 800, 400); testHtmlBox.SetLocation(30, 50); host.AddChild(testHtmlBox); string html = @"<html><head></head><body><div id='div1'>OK1</div><div>OK2</div></body></html>"; testHtmlBox.LoadHtmlString(html); //================================================== }
protected override void OnStart(AppHost host) { //html box _host = host; _painter = (GLPainter)host.GetPainter(); var loadingQueueMx = new LayoutFarm.ContentManagers.ImageLoadingQueueManager(); loadingQueueMx.AskForImage += loadingQueue_AskForImg; HtmlHost htmlHost = HtmlHostCreatorHelper.CreateHtmlHost(host, (s, e) => loadingQueueMx.AddRequestImage(e.ImageBinder), contentMx_LoadStyleSheet); // _htmlBox = new HtmlBox(htmlHost, 1024, 800); _htmlBox.SetLocation(0, 300); //test _rootgfx = host.GetRootGraphics(); _rootE = _htmlBox.GetPrimaryRenderElement(_rootgfx); _drawBoard = host.GetDrawBoard(); host.AddChild(_htmlBox); //------- _htmltext = @"<html> <head> <style> .myfont1{font-size:30pt;background-color:yellow} .myfont2{font-size:24pt;background-color:rgb(255,215,0)} </style> </head> <body> <div class='myfont1'>Hello</div> <div class='myfont2'>... from HtmlRenderer</div> </body> </html>"; //if (_htmltext == null) //{ // _htmltext = @"<html><head></head><body>NOT FOUND!</body></html>"; //} _htmlBox.LoadHtmlString(_htmltext); }
protected override void OnStartDemo(SampleViewport viewport) { //html box var contentMx = new LayoutFarm.ContentManagers.ImageContentManager(); contentMx.ImageLoadingRequest += contentMx_ImageLoadingRequest; var host = HtmlHostCreatorHelper.CreateHtmlHost(viewport, (s, e) => contentMx.AddRequestImage(e.ImageBinder), contentMx_LoadStyleSheet); htmlBox = new HtmlBox(host, 1024, 800); viewport.AddContent(htmlBox); if (htmltext == null) { htmltext = @"<html><head></head><body>NOT FOUND!</body></html>"; } htmlBox.LoadHtmlString(htmltext); }
protected override void OnStart(AppHost host, IGameHTMLUI pcx) { htmlHost = HtmlHostCreatorHelper.CreateHtmlHost(host, null, null); ////================================================== //html box { HtmlBox lightHtmlBox = new HtmlBox(htmlHost, 800, 50); lightHtmlBox.SetLocation(50, 450); host.AddChild(lightHtmlBox); //light box can't load full html //all light boxs of the same lightbox host share resource with the host string html = @"<div>OK1</div><div>OK2</div>"; //if you want to use full html-> use HtmlBox instead lightHtmlBox.LoadHtmlFragmentString(html); } //================================================== { HtmlBox lightHtmlBox2 = new HtmlBox(htmlHost, 800, 50); lightHtmlBox2.SetLocation(0, 60); host.AddChild(lightHtmlBox2); //light box can't load full html //all light boxs of the same lightbox host share resource with the host string html2 = @"<div>OK3</div><div>OK4</div>"; //if you want to use ful l html-> use HtmlBox instead lightHtmlBox2.LoadHtmlFragmentString(html2); } //================================================== { HtmlBox lightHtmlBox3 = new HtmlBox(htmlHost, 800, 50); lightHtmlBox3.SetLocation(0, 100); host.AddChild(lightHtmlBox3); //fragment dom //create dom then to thie light box lightHtmlBox3.LoadHtmlDom(CreateSampleHtmlDoc()); } //================================================== //textbox var textbox = new LayoutFarm.CustomWidgets.TextBox(400, 150, true); textbox.SetLocation(0, 200); host.AddChild(textbox); textbox.Focus(); }
protected override void OnStart(AppHost host) { string appPath = host.ExecutablePath; //System.Windows.Forms.Application.ExecutablePath; int pos = appPath.IndexOf("\\bin\\"); if (pos > -1) { string sub01 = appPath.Substring(0, pos); imgFolderPath = sub01 + "\\images"; } //================================================== //html box var htmlBox = new HtmlBox(GetHtmlHost(host), 800, 600); host.AddChild(htmlBox); string html = "<html><head></head><body><div>OK1</div><div>3 Images</div><img src=\"sample01.png\"></img><img src=\"sample01.png\"></img><img src=\"sample01.png\"></img></body></html>"; htmlBox.LoadHtmlString(html); }
protected override void OnStartDemo(SampleViewport viewport) { var htmlhost = HtmlHostCreatorHelper.CreateHtmlHost(viewport, null, null); ////================================================== //html box var htmlBox = new HtmlBox(htmlhost, 800, 400); htmlBox.SetLocation(30, 30); viewport.AddContent(htmlBox); string html = @"<html><head></head><body><div>OK1</div><div>OK2</div></body></html>"; htmlBox.LoadHtmlString(html); //================================================== //textbox var textbox = new LayoutFarm.CustomWidgets.TextBox(400, 100, true); textbox.SetLocation(0, 200); viewport.AddContent(textbox); textbox.Focus(); }
protected override void OnStart(AppHost host) { //html box _host = host; var loadingQueueMx = new LayoutFarm.ContentManagers.ImageLoadingQueueManager(); loadingQueueMx.AskForImage += loadingQueue_AskForImg; HtmlBoxes.HtmlHost htmlHost = HtmlHostCreatorHelper.CreateHtmlHost(host, (s, e) => loadingQueueMx.AddRequestImage(e.ImageBinder), contentMx_LoadStyleSheet); // _htmlBox = new HtmlBox(htmlHost, 1024, 800); _htmlBox.SetLocation(0, 10); //test host.AddChild(_htmlBox); if (_htmltext == null) { _htmltext = @"<html><head></head><body>NOT FOUND!</body></html>"; } _htmlBox.LoadHtmlString(_htmltext); }
protected override void OnStart(AppHost host) { { //html box1 HtmlBoxes.HtmlHost htmlhost = HtmlHostCreatorHelper.CreateHtmlHost(host, null, null); //html box var htmlBox = new HtmlBox(htmlhost, 800, 400); htmlBox.SetLocation(0, 0); //htmlBox.PreferSoftwareRenderer = true; host.AddChild(htmlBox); string html = @"<html><head></head><body><div>OK1</div><div>OK2</div></body></html>"; htmlBox.LoadHtmlString(html); //================================================== } { //html box2 HtmlBoxes.HtmlHost htmlhost = HtmlHostCreatorHelper.CreateHtmlHost(host, null, null); //html box var htmlBox = new HtmlBox(htmlhost, 800, 400); htmlBox.PreferSoftwareRenderer = true; htmlBox.SetLocation(0, 420);//** host.AddChild(htmlBox); string html = @"<html><head></head><body><div>OK3</div><div>OK4</div></body></html>"; htmlBox.LoadHtmlString(html); //================================================== } //{ // //textbox // var textbox = new LayoutFarm.CustomWidgets.TextBox(400, 25, true); // textbox.SetLocation(0, 0); // host.AddChild(textbox); // textbox.Focus(); //} }
public void DownloadFile(string rootPath, string filename, string contexto, HtmlBox html) { HttpResponse response = HttpContext.Current.Response; response.Clear(); response.AddHeader("Content-Type", ContextType.HTML); //"binary/octet-stream"); response.ContentType = ContextType.HTML; //contexto;//"application/octet-stream"; response.Write("Arquivo gerado com sucesso : "); response.Write("<a href='arquivos\\" + filename + "'>download</a>."); response.End(); }
public static void Start() { if (!Glfw.Init()) { Console.WriteLine("can't init glfw"); return; } //--------------------------------------------------- //specific OpenGLES *** Glfw.WindowHint(WindowHint.GLFW_CLIENT_API, (int)OpenGLAPI.OpenGLESAPI); Glfw.WindowHint(WindowHint.GLFW_CONTEXT_CREATION_API, (int)OpenGLContextCreationAPI.GLFW_EGL_CONTEXT_API); Glfw.WindowHint(WindowHint.GLFW_CONTEXT_VERSION_MAJOR, 2); Glfw.WindowHint(WindowHint.GLFW_CONTEXT_VERSION_MINOR, 0); //--------------------------------------------------- Glfw.SwapInterval(1); GlFwForm form1 = GlfwApp.CreateGlfwForm( 800, 600, "PixelFarm + Skia on GLfw and OpenGLES2"); form1.MakeCurrent(); //------------------------------------ //*** GLFWPlatforms.CreateGLESContext(); //------------------------------------ form1.Activate(); int ww_w = 800; int ww_h = 600; int max = Math.Max(ww_w, ww_h); canvasGL2d = PixelFarm.Drawing.GLES2.GLES2Platform.CreateCanvasGL2d(max, max); //------------------------------------ GL.Enable(EnableCap.Blend); GL.BlendFunc(BlendingFactorSrc.SrcAlpha, BlendingFactorDest.OneMinusSrcAlpha); GL.ClearColor(1, 1, 1, 1); //-------------------------------------------------------------------------------- //setup viewport size //set up canvas needUpdateContent = true; //GL.Viewport(0, 0, 800, 600); GL.Viewport(0, 0, max, max); FormRenderUpdateEventArgs formRenderUpdateEventArgs = new FormRenderUpdateEventArgs(); formRenderUpdateEventArgs.form = form1; LayoutFarm.Ease.EaseHost.StartGraphicsHost(); var rootgfx = new MyRootGraphic( LayoutFarm.UI.UIPlatformWinNeutral.platform, LayoutFarm.UI.UIPlatformWinNeutral.platform.GetIFonts(), ww_w, ww_h); var surfaceViewportControl = new LayoutFarm.UI.WinNeutral.UISurfaceViewportControl(); surfaceViewportControl.InitRootGraphics(rootgfx, rootgfx.TopWinEventPortal, InnerViewportKind.GL); //lion fill sample OpenTkEssTest.T108_LionFill lionFill = new OpenTkEssTest.T108_LionFill(); lionFill.Init2(canvasGL2d); GLCanvasPainter painter1 = lionFill.Painter; var myCanvasGL = new PixelFarm.Drawing.GLES2.MyGLCanvas(painter1, 0, 0, 800, 600); //(PixelFarm.Drawing.GLES2.GLES2Platform.CreateCanvas(0, 0, 800, 600, canvasGL2d, painter1); surfaceViewportControl.SetupCanvas(myCanvasGL); SampleViewport viewport = new LayoutFarm.SampleViewport(surfaceViewportControl); HtmlHost htmlHost; htmlHost = HtmlHostCreatorHelper.CreateHtmlHost(viewport, null, null); ////================================================== //html box HtmlBox lightHtmlBox = new HtmlBox(htmlHost, 800, 50); { lightHtmlBox.SetLocation(50, 450); viewport.AddContent(lightHtmlBox); //light box can't load full html //all light boxs of the same lightbox host share resource with the host string html = @"<div>OK1</div><div>OK2</div>"; //if you want to use full html-> use HtmlBox instead lightHtmlBox.LoadHtmlString(html); } form1.SetDrawFrameDelegate(() => { //render each frame if (needUpdateContent) { UpdateViewContent(formRenderUpdateEventArgs); } canvasGL2d.Clear(Color.White); //canvasGL2d.DrawRect(0, 0, 200, 200); ////canvasGL2d.DrawImage(glBmp, 0, 600); //int tmp_x = lightHtmlBox.Left; //int tmp_y = lightHtmlBox.Top; //myCanvasGL.SetCanvasOrigin(tmp_x, tmp_y); canvasGL2d.SmoothMode = CanvasSmoothMode.No; //--------- //flip y axis for html box (and other UI) canvasGL2d.FlipY = true; lightHtmlBox.CurrentPrimaryRenderElement.DrawToThisCanvas( myCanvasGL, new Rectangle(0, 0, 800, 600)); canvasGL2d.FlipY = false; //myCanvasGL.SetCanvasOrigin(tmp_x, -tmp_y); //lion use canvas coordinate system lionFill.TestRender(); //surfaceViewportControl.PaintMe(canvasGL2d); }); while (!GlfwApp.ShouldClose()) { //--------------- //render phase and swap GlfwApp.UpdateWindowsFrame(); /* Poll for and process events */ Glfw.PollEvents(); } Glfw.Terminate(); }
void SetupHtmlMenuBox() { //================================================== this.htmlMenuBox = new HtmlBox(htmlhost, 800, 40); htmlMenuBox.SetLocation(30, 0); viewport.AddContent(htmlMenuBox); string html = @"<html><head></head><body> <div id='menubox'> <span id='test_dom1'>click to toggle!</span> <span id='test_dom2'>test document fragment</span> <span id='test_dom3'>test showdow dom</span> </div> </body></html>"; htmlMenuBox.LoadHtmlString(html); //set event handlers var htmldoc = htmlMenuBox.HtmlContainer.WebDocument as IHtmlDocument; var div_menuBox = htmldoc.getElementById("menubox") as IHtmlElement; if (div_menuBox == null) { return; } //test set innerHTML div_menuBox.attachEventListener("mousedown", (e) => { var contextE = e.SourceHitElement as IHtmlElement; switch (contextE.id) { case "test_dom1": { //test toggle with innerHTML var testHtmlDoc = testHtmlBox.HtmlContainer.WebDocument as IHtmlDocument; var div1 = testHtmlDoc.getElementById("div1") as IHtmlElement; if (div1 != null) { //test set innerHTML div1.innerHTML = testToggle ? "<div>11111</div>" : "<div>22222</div>"; testToggle = !testToggle; } } break; case "test_dom2": { //test toggle with DocumentFragment var testHtmlDoc = testHtmlBox.HtmlContainer.WebDocument as IHtmlDocument; var div1 = testHtmlDoc.getElementById("div1") as IHtmlElement; if (div1 != null) { var docFragment = testHtmlDoc.createDocumentFragment(); if (testToggle) { var node1 = docFragment.createElement("div") as IHtmlElement; node1.appendChild( docFragment.createTextNode("3333")); //TODO: review this docFragment.rootNode.appendChild(node1); } else { var node1 = docFragment.createElement("div") as IHtmlElement; node1.appendChild( docFragment.createTextNode("4444")); //TODO: review this docFragment.rootNode.appendChild(node1); } div1.clear(); div1.appendChild(docFragment.rootNode); testToggle = !testToggle; } } break; case "test_dom3": { //shadow dom! var testHtmlDoc = testHtmlBox.HtmlContainer.WebDocument as IHtmlDocument; var div1 = testHtmlDoc.getElementById("div1") as IHtmlElement; if (div1 != null) { var shadowRoot = testHtmlDoc.createShadowRootElement() as IHtmlElement; if (testToggle) { var node1 = testHtmlDoc.createElement("div") as IHtmlElement; node1.appendChild( testHtmlDoc.createTextNode("XXX")); //TODO: review this //add node1 to shadow root element shadowRoot.appendChild(node1); } else { var node1 = testHtmlDoc.createElement("div") as IHtmlElement; node1.appendChild( testHtmlDoc.createTextNode("YYY")); //TODO: review this //add node1 to shadow root element shadowRoot.appendChild(node1); } div1.clear(); div1.appendChild(shadowRoot); testToggle = !testToggle; } } break; } }); }