コード例 #1
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;
        }
コード例 #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);
            //}
        }