protected void EnableCanvasPaint()
        {
            // Enable canvas paint after all initialization has completed,
            // because adding certain controls, like TextboxShape, causes a panel canvas OnPaint to be called
            // when the TextboxShape is being added to the toolbox canvas, and this results in all shapes
            // attempting to draw, and they are not fully initialized at this point!
            IFlowSharpCanvasService canvasService = ServiceManager.Get <IFlowSharpCanvasService>();

            canvasService.Controllers.ForEach(c => c.Canvas.EndInit());
            canvasService.Controllers.ForEach(c => c.Canvas.Invalidate());
            IFlowSharpToolboxService toolboxService = ServiceManager.Get <IFlowSharpToolboxService>();

            toolboxService.Controller.Canvas.EndInit();
            toolboxService.Controller.Canvas.Invalidate();
        }
Beispiel #2
0
        protected void EnableCanvasPaint()
        {
            // Enable canvas paint after all initialization has completed,
            // because adding certain controls, like TextboxShape, causes a panel canvas OnPaint to be called
            // when the TextboxShape is being added to the toolbox canvas, and this results in all shapes
            // attempting to draw, and they are not fully initialized at this point!
            IFlowSharpCanvasService canvasService = ServiceManager.Get <IFlowSharpCanvasService>();

            canvasService.Controllers.ForEach(c => c.Canvas.EndInit());
            canvasService.Controllers.ForEach(c => c.Canvas.Invalidate());
            IFlowSharpToolboxService toolboxService = ServiceManager.Get <IFlowSharpToolboxService>();

            // Will be null if canvas was not created when app starts.  Sanity check here
            // mainly for when we debug a form with no panels initialized by default.
            if (toolboxService.Controller != null)
            {
                toolboxService.Controller.Canvas.EndInit();
                toolboxService.Controller.Canvas.Invalidate();
            }
        }
Beispiel #3
0
        protected void InitializeFlowSharp()
        {
            var canvasService = Program.ServiceManager.Get<IFlowSharpCanvasService>();
            canvasService.CreateCanvas(pnlFlowSharp);
            canvasService.ActiveController.Canvas.EndInit();
            canvasService.ActiveController.Canvas.Invalidate();

            // Initialize Toolbox so we can drop shapes
            IFlowSharpToolboxService toolboxService = Program.ServiceManager.Get<IFlowSharpToolboxService>();

            // We don't display the toolbox, but we need a container.
            Panel pnlToolbox = new Panel();
            pnlToolbox.Visible = false;
            Controls.Add(pnlToolbox);

            toolboxService.CreateToolbox(pnlToolbox);
            toolboxService.InitializeToolbox();

            var mouseController = Program.ServiceManager.Get<IFlowSharpMouseControllerService>();
            mouseController.Initialize(canvasService.ActiveController);
            nudPeerNumber.Maximum = NUM_DHT - 1;
        }
        protected void OnContentLoaded(object sender, ContentLoadedEventArgs e)
        {
            switch (e.Metadata.LeftOf(","))
            {
            case Constants.META_CANVAS:
                pnlFlowSharp = new Panel()
                {
                    Dock = DockStyle.Fill, Tag = Constants.META_CANVAS
                };
                e.DockContent.Controls.Add(pnlFlowSharp);
                e.DockContent.Text = "Canvas";
                IFlowSharpCanvasService canvasService = ServiceManager.Get <IFlowSharpCanvasService>();
                canvasService.CreateCanvas(pnlFlowSharp);
                BaseController baseController = ServiceManager.Get <IFlowSharpCanvasService>().ActiveController;

                if (e.Metadata.Contains(","))
                {
                    string filename   = e.Metadata.Between(",", ",");
                    string canvasName = e.Metadata.RightOfRightmostOf(",");
                    canvasName         = String.IsNullOrWhiteSpace(canvasName) ? "Canvas" : canvasName;
                    e.DockContent.Text = canvasName;
                    LoadFileIntoCanvas(filename, canvasName, baseController);
                }

                // ServiceManager.Get<IFlowSharpMouseControllerService>().Initialize(baseController);
                break;

            case Constants.META_TOOLBOX:
                pnlToolbox = new Panel()
                {
                    Dock = DockStyle.Fill, Tag = Constants.META_TOOLBOX
                };
                e.DockContent.Controls.Add(pnlToolbox);
                e.DockContent.Text = "Toolbox";
                break;

            case Constants.META_PROPERTYGRID:
                propGrid = new PropertyGrid()
                {
                    Dock = DockStyle.Fill, Tag = Constants.META_PROPERTYGRID
                };
                e.DockContent.Controls.Add(propGrid);
                e.DockContent.Text = "Property Grid";
                ServiceManager.Get <IFlowSharpPropertyGridService>().Initialize(propGrid);
                break;

            default:
                ContentResolver.Fire(this, e);
                break;
            }

            // Associate the toolbox with a canvas controller after both canvas and toolbox panels are created.
            // !!! This handles the defaultLayout configuration. !!!
            if ((e.Metadata == Constants.META_CANVAS || e.Metadata == Constants.META_TOOLBOX) && (pnlFlowSharp != null && pnlToolbox != null))
            {
                IFlowSharpCanvasService  canvasService    = ServiceManager.Get <IFlowSharpCanvasService>();
                BaseController           canvasController = canvasService.ActiveController;
                IFlowSharpToolboxService toolboxService   = ServiceManager.Get <IFlowSharpToolboxService>();
                toolboxService.CreateToolbox(pnlToolbox);
                toolboxService.InitializeToolbox();
                toolboxService.InitializePluginsInToolbox();
                toolboxService.UpdateToolboxPaths();
            }

            //if ((e.Metadata == Constants.META_CANVAS || e.Metadata == Constants.META_PROPERTYGRID) && (pnlFlowSharp != null && propGrid != null))
            //{
            //    ServiceManager.Get<IFlowSharpPropertyGridService>().Initialize(propGrid);
            //}
        }