Пример #1
0
        /// <summary>
        /// Finish the process of loading an existing
        /// or new workflow
        /// </summary>
        /// <returns></returns>
        private Boolean CommonWorkflowLoading()
        {
            Boolean result = false;

            //tell the designer to begin loading
            _designSurface.BeginLoad(_wfLoader);

            //retrieve the designer host
            IDesignerHost designer
                = _designSurface.GetService(typeof(IDesignerHost))
                  as IDesignerHost;

            if (designer == null || designer.RootComponent == null)
            {
                return(false);
            }

            IRootDesigner rootDesigner
                = designer.GetDesigner(designer.RootComponent)
                  as IRootDesigner;

            if (rootDesigner != null)
            {
                SuspendLayout();
                //get the default workflow view from the designer
                _workflowView = rootDesigner.GetView(
                    ViewTechnology.Default)
                                as WorkflowView;
                //add the workflow view to a panel for display
                splitContainer1.Panel2.Controls.Add(_workflowView);
                _workflowView.Dock = DockStyle.Fill;
                _workflowView.Focus();

                //link the propertyGrid with the designer
                propertyGrid1.Site = designer.RootComponent.Site;

                //setup the toolbar for the workflow using the one
                //constructed by the workflow loader
                IToolboxService toolboxService = designer.GetService(
                    typeof(IToolboxService)) as IToolboxService;
                if (toolboxService != null)
                {
                    if (toolboxService is Control)
                    {
                        //add the toolbox control to a panel
                        _toolboxControl = (Control)toolboxService;
                        splitContainer2.Panel1.Controls.Add(
                            _toolboxControl);
                    }
                }

                //get the ISelectionService from the workflow view
                //and add a handler for the SelectionChanged event
                ISelectionService selectionService
                    = ((IServiceProvider)_workflowView).GetService(
                          typeof(ISelectionService)) as ISelectionService;
                if (selectionService != null)
                {
                    selectionService.SelectionChanged += new EventHandler(
                        selectionService_SelectionChanged);
                }

                ResumeLayout();
                result = true;
            }
            return(result);
        }