Inheritance: RootGraphic, ITopWindowEventRootProvider
示例#1
0
        public static Form CreateNewFormCanvas(
            MyRootGraphic myRootGfx,
            InnerViewportKind internalViewportKind,
            out UISurfaceViewportControl canvasViewport)
        {
            Form      form1                = new Form();
            var       innerViewport        = canvasViewport = new UISurfaceViewportControl();
            Rectangle screenClientAreaRect = new Rectangle(0, 0, 800, 600); //Conv.ToRect(Screen.PrimaryScreen.WorkingArea);

            canvasViewport.InitRootGraphics(myRootGfx, myRootGfx.TopWinEventPortal, internalViewportKind);
            canvasViewport.Bounds =
                new Rectangle(0, 0,
                              screenClientAreaRect.Width,
                              screenClientAreaRect.Height);
            //----------------------
            form1.Controls.Add(canvasViewport);
            //----------------------
            MakeFormCanvas(form1, canvasViewport);

            //TODO: review here
            //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);
        }
示例#2
0
        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();
                };
            }
        }
示例#4
0
 private void cmdShowBasicFormCanvas_Click(object sender, EventArgs e)
 {
     LayoutFarm.UI.UISurfaceViewportControl viewport;
     int w = 800;
     int h = 600;
     MyRootGraphic rootgfx = new MyRootGraphic(
         this.uiPlatformWinForm, 
         w,
         h);
     Form formCanvas = FormCanvasHelper.CreateNewFormCanvas(rootgfx,
        InnerViewportKind.GdiPlus,
        out viewport);
     viewport.PaintMe();
     formCanvas.Show();
     ShowFormLayoutInspector(viewport);
 }
示例#5
0
 private void cmdShowEmbededViewport_Click(object sender, EventArgs e)
 {
     Form simpleForm = new Form();
     simpleForm.Text = "SimpleForm2";
     simpleForm.WindowState = FormWindowState.Maximized;
     Rectangle screenClientAreaRect = Screen.PrimaryScreen.WorkingArea;
     var viewport = new LayoutFarm.UI.UISurfaceViewportControl();
     viewport.Bounds = new Rectangle(0, 0, screenClientAreaRect.Width, screenClientAreaRect.Height);
     simpleForm.Controls.Add(viewport);
     int w = 800;
     int h = 600;
     var rootgfx = new MyRootGraphic(this.uiPlatformWinForm, 
         w, h);
     viewport.InitRootGraphics(rootgfx, rootgfx.TopWinEventPortal,
         InnerViewportKind.GdiPlus);
     viewport.PaintMe();
     simpleForm.Show();
     ShowFormLayoutInspector(viewport);
 }
示例#6
0
        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;

        }
示例#7
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();
                };
            }
        }
示例#8
0
        void CreateReadyForm(
            out LayoutFarm.UI.UISurfaceViewportControl viewport,
            out Form formCanvas)
        {
            var workingArea = Screen.PrimaryScreen.WorkingArea;
            int w = workingArea.Width;
            int h = workingArea.Height;


            MyRootGraphic rootgfx = new MyRootGraphic(this.uiPlatformWinForm,
                w, h);

            //formCanvas = FormCanvasHelper.CreateNewFormCanvas(rootgfx,
            //    this.chkUseGLCanvas.Checked ? InnerViewportKind.GL : InnerViewportKind.GdiPlus,
            //    out viewport);

            InnerViewportKind innerViewportKind = (InnerViewportKind)cmbPlatformSelector.SelectedItem;

            formCanvas = FormCanvasHelper.CreateNewFormCanvas(rootgfx,
              innerViewportKind,
              out viewport);
            formCanvas.Text = "FormCanvas 1";

            viewport.PaintMe();

            formCanvas.WindowState = FormWindowState.Maximized;
            formCanvas.Show();
        }
示例#9
0
        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);
        }
示例#10
0
 public static EaseViewport CreateViewportControl(Form hostForm, int w, int h)
 {
     var rootgfx = new MyRootGraphic(uiPlatformWinForm, 
         w, h);
     LayoutFarm.UI.UISurfaceViewportControl viewport;
     CreateNewFormCanvas(hostForm, rootgfx,
          useOpenGL ? InnerViewportKind.GL : InnerViewportKind.GdiPlus,
          out viewport);
     viewport.PaintMe();
     EaseViewport easeViewport = new EaseViewport(viewport);
     return easeViewport;
 }
示例#11
0
 static void CreateReadyForm(
    out LayoutFarm.UI.UISurfaceViewportControl viewport,
    out Form formCanvas)
 {
     int w = 800;
     int h = 600;
     var rootgfx = new MyRootGraphic(uiPlatformWinForm, 
         w, h);
     var topRenderBox = rootgfx.TopWindowRenderBox;
     formCanvas = FormCanvasHelper.CreateNewFormCanvas(rootgfx,
         useOpenGL ? InnerViewportKind.GL : InnerViewportKind.GdiPlus,
         out viewport);
     formCanvas.Text = "FormCanvas 1";
     viewport.PaintMe();
     formCanvas.WindowState = FormWindowState.Maximized;
     formCanvas.Show();
 }