Пример #1
0
        protected void CreateCanvas()
        {
            // Create canvas.
            Panel panel = new Panel()
            {
                Dock = DockStyle.Fill, Tag = Constants.META_CANVAS
            };
            Control dockPanel = ServiceManager.Get <IDockingFormService>().CreateDocument(DockState.Document, "Canvas", Constants.META_CANVAS);

            dockPanel.Controls.Add(panel);
            IFlowSharpCanvasService canvasService = ServiceManager.Get <IFlowSharpCanvasService>();

            canvasService.CreateCanvas(panel);
            canvasService.ActiveController.Canvas.EndInit();
            InformServicesOfNewCanvas(canvasService.ActiveController);
        }
Пример #2
0
        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);
            //}
        }