Beispiel #1
0
 public static void MakeFormCanvas(Form form1, GraphicsViewRoot surfaceViewportControl)
 {
     form1.FormClosing += (s, e) =>
     {
         surfaceViewportControl.Close();
     };
 }
Beispiel #2
0
 public static Form CreateNewFormCanvas(
     int w, int h,
     InnerViewportKind internalViewportKind,
     out GraphicsViewRoot canvasViewport)
 {
     return(CreateNewFormCanvas(0, 0, w, h, internalViewportKind, out canvasViewport));
 }
Beispiel #3
0
        public static Form CreateNewFormCanvas(
            int xpos, int ypos,
            int w, int h,
            InnerViewportKind internalViewportKind,
            out GraphicsViewRoot canvasViewport)
        {
            //create new form with new user control
            Form form1 = new Form();

            CreateCanvasControlOnExistingControl(
                form1,
                xpos, ypos, w, h, internalViewportKind,
                out canvasViewport);

            //----------------------
            MakeFormCanvas(form1, canvasViewport);

            GraphicsViewRoot innerViewport = canvasViewport;

            form1.SizeChanged += (s, e) =>
            {
                if (form1.WindowState == FormWindowState.Maximized)
                {
                    Screen currentScreen = GetScreenFromX(form1.Left);
                    //make full screen ?
                    if (innerViewport != null)
                    {
                        var size = Screen.PrimaryScreen.WorkingArea.Size;
                        innerViewport.SetSize(size.Width, size.Height);
                    }
                }
            };
            //----------------------
            return(form1);
        }
Beispiel #4
0
 public void BindSurface(LayoutFarm.UI.GraphicsViewRoot surfaceViewport)
 {
     _myWidth         = 800;
     _myHeight        = 600;
     _surfaceViewport = surfaceViewport;
     _rootGfx         = surfaceViewport.RootGfx;
 }
Beispiel #5
0
        public static void ShowFormLayoutInspector(LayoutFarm.UI.GraphicsViewRoot viewroot)
        {
            var formLayoutInspector = new LayoutFarm.Dev.FormLayoutInspector();

            formLayoutInspector.Show();

            formLayoutInspector.Connect(viewroot);
            formLayoutInspector.Show();
        }
Beispiel #6
0
        public void Connect(LayoutFarm.UI.GraphicsViewRoot vwport)
        {
#if DEBUG
            _viewroot = vwport;
            IdbugOutputWindow outputWin = vwport.IdebugOutputWin;
            outputWin.dbug_VisualRootDrawMsg     += _rootDrawMsgEventHandler;
            outputWin.dbug_VisualRootHitChainMsg += artUISurfaceViewport1_dbug_VisualRootHitChainMsg;
            outputWin.dbug_EnableAllDebugInfo();
#endif
        }
Beispiel #7
0
        static void ShowFormLayoutInspector(LayoutFarm.UI.GraphicsViewRoot viewroot)
        {
            var formLayoutInspector = new LayoutFarm.Dev.FormLayoutInspector();

            formLayoutInspector.Show();
            formLayoutInspector.FormClosed += (s, e2) =>
            {
                formLayoutInspector = null;
            };
            formLayoutInspector.Connect(viewroot);
        }
        public void BindSurface(LayoutFarm.UI.GraphicsViewRoot surfaceViewport)
        {
            _myWidth  = 800;
            _myHeight = 600;

            _surfaceViewport = surfaceViewport;
            _rootGfx         = surfaceViewport.RootGfx;
            //----------------------

            _nativeWindow = surfaceViewport.MyNativeWindow;
            _nativeWindow.MakeCurrent();
        }
Beispiel #9
0
        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();
                };
            }
        }
Beispiel #10
0
 public static void SetUISurfaceViewportControl(LayoutFarm.AppHostConfig config, LayoutFarm.UI.GraphicsViewRoot vw)
 {
     //---------------------------------------
     //this specific for WindowForm viewport
     //---------------------------------------
     System.Drawing.Rectangle primScreenWorkingArea = System.Windows.Forms.Screen.PrimaryScreen.WorkingArea;
     config.ScreenW = primScreenWorkingArea.Width;
     config.ScreenH = primScreenWorkingArea.Height;
     config.RootGfx = vw.RootGfx;
     //
     switch (vw.InnerViewportKind)
     {
     case InnerViewportKind.GdiPlusOnGLES:
     case InnerViewportKind.AggOnGLES:
         SetUpSoftwareRendererOverGLSurface(
             config,
             vw.MyNativeWindow,
             vw.GLPainterCore(),
             vw.GetGLPainter(),
             vw.InnerViewportKind);
         break;
     }
 }