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 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); }