public static Form CreateNewFormCanvas( MyRootGraphic myRootGfx, InnerViewportKind internalViewportKind, out LayoutFarm.UI.UISurfaceViewportControl canvasViewport) { Form form1 = new Form(); var innerViewport = canvasViewport = new LayoutFarm.UI.UISurfaceViewportControl(); Rectangle screenClientAreaRect = Conv.ToRect(Screen.PrimaryScreen.WorkingArea); canvasViewport.InitRootGraphics(myRootGfx, myRootGfx.TopWinEventPortal, internalViewportKind); canvasViewport.Bounds = new System.Drawing.Rectangle(0, 0, screenClientAreaRect.Width, screenClientAreaRect.Height); //---------------------- form1.Controls.Add(canvasViewport); //---------------------- MakeFormCanvas(form1, canvasViewport); form1.SizeChanged += (s, e) => { if (form1.WindowState == FormWindowState.Maximized) { Screen currentScreen = GetScreenFromX(form1.Left); //make full screen ? if (innerViewport != null) { innerViewport.Size = currentScreen.WorkingArea.Size; } } }; //---------------------- return(form1); }
public static void CreateConvasControlOnExistingControl( Control landingControl, int xpos, int ypos, int w, int h, InnerViewportKind internalViewportKind, out LayoutFarm.UI.UISurfaceViewportControl canvasViewport) { //1. init InitWinform(); IFontLoader fontLoader = s_fontstore; //2. PixelFarm.Drawing.ITextService ifont = null; switch (internalViewportKind) { default: ifont = PixelFarm.Drawing.WinGdi.WinGdiPlusPlatform.GetIFonts(); //ifont = new OpenFontTextService(); break; case InnerViewportKind.GL: ifont = new OpenFontTextService(); break; } PixelFarm.Drawing.WinGdi.WinGdiPlusPlatform.SetFontLoader(fontLoader); // //--------------------------------------------------------------------------- MyRootGraphic myRootGfx = new MyRootGraphic( w, h, ifont ); //--------------------------------------------------------------------------- var innerViewport = canvasViewport = new LayoutFarm.UI.UISurfaceViewportControl(); Rectangle screenClientAreaRect = Conv.ToRect(Screen.PrimaryScreen.WorkingArea); canvasViewport.InitRootGraphics(myRootGfx, myRootGfx.TopWinEventPortal, internalViewportKind); canvasViewport.Bounds = new System.Drawing.Rectangle(xpos, ypos, screenClientAreaRect.Width, screenClientAreaRect.Height); landingControl.Controls.Add(canvasViewport); // Form ownerForm = landingControl.FindForm(); if (ownerForm != null) { ownerForm.FormClosing += (s, e) => { innerViewport.Close(); }; } }
public static void CreateCanvasControlOnExistingControl( Control landingControl, int xpos, int ypos, int w, int h, InnerViewportKind internalViewportKind, out GraphicsViewRoot view_root) { //1. init InitWinform(); IInstalledTypefaceProvider fontLoader = YourImplementation.CommonTextServiceSetup.FontLoader; //2. switch (internalViewportKind) { default: //gdi, gdi on gles break; case InnerViewportKind.PureAgg: case InnerViewportKind.AggOnGLES: case InnerViewportKind.GLES: { var openFontTextService = new Typography.Text.OpenFontTextService(); openFontTextService.SvgBmpBuilder = PaintLab.SvgBuilderHelper.ParseAndRenderSvg; PixelFarm.Drawing.GLES2.GLES2Platform.TextService = openFontTextService; Typography.Text.GlobalTextService.TxtClient = openFontTextService.CreateNewServiceClient(); } break; } PixelFarm.Drawing.WinGdi.WinGdiPlusPlatform.SetInstalledTypefaceProvider(fontLoader); //--------------------------------------------------------------------------- //3. root graphics PixelFarm.Drawing.Rectangle screenClientAreaRect = Conv.ToRect(Screen.PrimaryScreen.WorkingArea); w = screenClientAreaRect.Width; h = screenClientAreaRect.Height; MyRootGraphic myRootGfx = new MyRootGraphic(w, h); //4. create event bridge that will bridge from native window event to root graphics AbstractTopWindowBridge bridge = GetTopWindowBridge(internalViewportKind, myRootGfx, myRootGfx.TopWinEventPortal); //5. actualWinUI is platform specific var actualWinUI = new LayoutFarm.UI.MyWinFormsControl(); actualWinUI.Size = new System.Drawing.Size(w, h); landingControl.Controls.Add(actualWinUI); //so we create abstraction of actual UI IGpuOpenGLSurfaceView viewAbstraction = actualWinUI.CreateWindowWrapper(bridge); var viewRoot = view_root = new GraphicsViewRoot( screenClientAreaRect.Width, screenClientAreaRect.Height); view_root.InitRootGraphics( myRootGfx, myRootGfx.TopWinEventPortal, internalViewportKind, viewAbstraction, bridge); //TODO: review here again myRootGfx.SetDrawboardReqDelegate(view_root.GetDrawBoard); //------ //TODO: review here view_root.SetBounds(xpos, ypos, screenClientAreaRect.Width, screenClientAreaRect.Height); // Form ownerForm = landingControl.FindForm(); if (ownerForm != null) { ownerForm.FormClosing += (s, e) => { //TODO: review here viewRoot.Close(); }; } }
public static Form CreateNewFormCanvas( int w, int h, InnerViewportKind internalViewportKind, out LayoutFarm.UI.UISurfaceViewportControl canvasViewport) { //1. init InitWinform(); IFontLoader fontLoader = s_fontstore; //2. PixelFarm.Drawing.ITextService ifont = null; switch (internalViewportKind) { default: //ifont = PixelFarm.Drawing.WinGdi.WinGdiPlusPlatform.GetIFonts(); ifont = new OpenFontTextService(); break; case InnerViewportKind.GL: ifont = new OpenFontTextService(); break; } PixelFarm.Drawing.WinGdi.WinGdiPlusPlatform.SetFontLoader(fontLoader); // //--------------------------------------------------------------------------- MyRootGraphic myRootGfx = new MyRootGraphic( w, h, ifont ); //--------------------------------------------------------------------------- var innerViewport = canvasViewport = new LayoutFarm.UI.UISurfaceViewportControl(); Rectangle screenClientAreaRect = Conv.ToRect(Screen.PrimaryScreen.WorkingArea); canvasViewport.InitRootGraphics(myRootGfx, myRootGfx.TopWinEventPortal, internalViewportKind); canvasViewport.Bounds = new System.Drawing.Rectangle(10, 10, screenClientAreaRect.Width, screenClientAreaRect.Height); //---------------------- Form form1 = new Form(); //LayoutFarm.Dev.FormNoBorder form1 = new Dev.FormNoBorder(); form1.Controls.Add(canvasViewport); //---------------------- MakeFormCanvas(form1, canvasViewport); form1.SizeChanged += (s, e) => { if (form1.WindowState == FormWindowState.Maximized) { Screen currentScreen = GetScreenFromX(form1.Left); //make full screen ? if (innerViewport != null) { innerViewport.Size = currentScreen.WorkingArea.Size; } } }; //---------------------- return(form1); }