private void AssignDelegates()
    {
        designerView = workflowDesigner.Context.Services.GetService<DesignerView>();
        modelService = workflowDesigner.Context.Services.GetService<ModelService>();

        //Handle Flow Diagram
        designerView.PreviewMouseDoubleClick += new System.Windows.Input.MouseButtonEventHandler(designerView_PreviewMouseDoubleClick);
    }
        //加载流程
        void loadWorkflowFromFile(string workflowFilePathName)
        {
            desienerPanel.Content = null;
            propertyPanel.Content = null;

            designer = new WorkflowDesigner();

            try
            {
                designer.Load(workflowFilePathName);

                modelService = designer.Context.Services.GetService<ModelService>();

                rootModelItem = modelService.Root;

                undoEngine = designer.Context.Services.GetService<UndoEngine>();

                undoEngine.UndoUnitAdded += delegate(object ss, UndoUnitEventArgs ee)
                                           {
                                               designer.Flush(); //调用Flush使designer.Text得到数据
                                               desigeerActionList.Items.Add(string.Format("{0}  ,   {1}", DateTime.Now.ToString(), ee.UndoUnit.Description));
                                           };

                designerView = designer.Context.Services.GetService<DesignerView>();

                designerView.WorkflowShellBarItemVisibility = ShellBarItemVisibility.Arguments    //如果不使用Activity做根,无法出现参数选项
                                                              | ShellBarItemVisibility.Imports
                                                              | ShellBarItemVisibility.MiniMap
                                                              | ShellBarItemVisibility.Variables
                                                               | ShellBarItemVisibility.Zoom
                                                              ;

                desienerPanel.Content = designer.View;

                propertyPanel.Content = designer.PropertyInspectorView;

            }
            catch (SystemException ex)
            {
                MessageBox.Show(ex.Message);
            }
        }
        public override void Initialize(EditingContext context)
        {
            this.context = context;
            AttachedPropertiesService propertiesService = this.context.Services.GetService<AttachedPropertiesService>();
            helpService = this.context.Services.GetService<IIntegratedHelpService>();

            oldSelection = this.context.Items.GetValue<Selection>();
            isPrimarySelectionProperty = new AttachedProperty<bool>()
                {
                    Getter = (modelItem) => (this.context.Items.GetValue<Selection>().PrimarySelection == modelItem),
                    Name = "IsPrimarySelection",
                    OwnerType = typeof(Object)
                };

            isSelectionProperty = new AttachedProperty<bool>()
            {
                Getter = (modelItem) => (((IList)this.context.Items.GetValue<Selection>().SelectedObjects).Contains(modelItem)),
                Name = "IsSelection",
                OwnerType = typeof(Object)
            };


            propertiesService.AddProperty(isPrimarySelectionProperty);
            propertiesService.AddProperty(isSelectionProperty);
            



            if (this.context.Services.GetService<ViewService>() == null)
            {
                view = new System.Activities.Presentation.View.DesignerView(this.context);
                WorkflowViewService viewService = new WorkflowViewService(context);
                WorkflowViewStateService viewStateService = new WorkflowViewStateService(context);
                this.context.Services.Publish<ViewService>(viewService);
                this.context.Services.Publish<VirtualizedContainerService>(new VirtualizedContainerService(this.context));
                this.context.Services.Publish<ViewStateService>(viewStateService);
                this.context.Services.Publish<DesignerView>(view);

                WorkflowAnnotationAdornerService annotationService = new WorkflowAnnotationAdornerService();
                annotationService.Initialize(this.context, view.scrollViewer);
                this.context.Services.Publish<AnnotationAdornerService>(annotationService);

                this.context.Services.Subscribe<ModelService>(delegate(ModelService modelService)
                {
                    this.modelService = modelService;
                    if (modelService.Root != null)
                    {
                        view.MakeRootDesigner(modelService.Root);
                    }
                    view.RestoreDesignerStates();
                    this.context.Items.Subscribe<Selection>(new SubscribeContextCallback<Selection>(OnItemSelected));
                });
            }

            if (helpService != null)
            {
                helpService.AddContextAttribute(string.Empty, KeywordForWorkflowDesignerHomePage, HelpKeywordType.F1Keyword); 
            }
        }
 private void OnModelServiceAvailable(ModelService modelService)
 {
     this.modelService = modelService;
 }
 void OnModelServiceAvailable(ModelService modelService)
 {
     if (modelService != null)
     {
         this.modelService = modelService;
     }
 }
        private List<Type> GetReferencedActivities(ModelService modelService)
        {
            IEnumerable<ModelItem> items = modelService.Find(modelService.Root, typeof(Activity));
            List<Type> activities = new List<Type>();
            foreach (ModelItem item in items) 
            {
                if (!namespacesToIgnore.Contains(item.ItemType.Namespace))
                {
                    activities.Add(item.ItemType);
                }
            }

            return activities;
        }
Exemple #7
0
 private static IEnumerable<ModelItem> GetSubModelItems(ModelService ms, ModelItem model)
 {
     List<ModelItem> result = new List<ModelItem>();
     if (ms != null)
     {
         ModelItem root = model == null ? ms.Root : model;
         result.AddRange(ms.Find(root, typeof(Activity)));
     }
     return result;
 }