Пример #1
0
        private ToolboxControl GetToolboxControl()
        {
            var toolboxControl = new ToolboxControl();

            var activitiesToolboxCategory = new ToolboxCategory("Activities");
            var sequence    = new ToolboxItemWrapper(typeof(Sequence));
            var writeLine   = new ToolboxItemWrapper(typeof(WriteLine));
            var fileWriter  = new ToolboxItemWrapper(typeof(FileWriterActivity));
            var ownActivity = new ToolboxItemWrapper(typeof(MyOwnActivityDesigner.OneStepActivity));

            activitiesToolboxCategory.Add(sequence);
            activitiesToolboxCategory.Add(writeLine);
            activitiesToolboxCategory.Add(fileWriter);
            activitiesToolboxCategory.Add(ownActivity);

            var documentActivitiesToolboxCategory = new ToolboxCategory("Documents");
            var document = new ToolboxItemWrapper(typeof(Document));

            documentActivitiesToolboxCategory.Add(document);

            toolboxControl.Categories.Add(activitiesToolboxCategory);
            toolboxControl.Categories.Add(documentActivitiesToolboxCategory);
            return(toolboxControl);
        }
Пример #2
0
        private static void LoadCustomActivities(ToolboxControl tbc, Assembly customAss, string categoryTitle)
        {
            var types = customAss.GetTypes().
                        Where(t => (typeof(Activity).IsAssignableFrom(t) ||
                                    typeof(IActivityTemplateFactory).IsAssignableFrom(t)) &&
                              !t.IsAbstract && t.IsPublic &&
                              !t.IsNested);
            var cat = new ToolboxCategory(categoryTitle);

            foreach (var type in types.OrderBy(t => t.Name))
            {
                //var w = new ToolboxItemWrapper(type, ToGenericTypeString(type));
                if (type.Name.Equals("TestSuiteActivity") ||
                    type.Name.Equals("TestCaseActivity") ||
                    type.Name.Equals("TestScreenActivity"))
                {
                    continue;
                }
                var w = new ToolboxItemWrapper(type, ImageList.GetInstance().GetFileName(type.Name.ToLower()), type.Name);
                cat.Add(w);
            }

            tbc.Categories.Add(cat);
        }
Пример #3
0
        public MainWindow()
        {
            InitializeComponent();

            originalTitle = this.Title;

            //register designers for the standard activities
            DesignerMetadata dm = new DesignerMetadata();

            dm.Register();

            //toolbox
            toolboxControl    = CreateToolbox();
            toolboxArea.Child = toolboxControl;

#if CONTEXTMENU
            //create a context menu item
            CreateContextMenu();
#endif

#if VALIDATION
            errorService = new ValidationErrorService(this.messageListBox);
#endif

            InitializeDesigner();
            StartNewWorkflow();


#if CUSTOMDESIGNER
            //override designer for the standard While activity
            AttributeTableBuilder atb = new AttributeTableBuilder();
            atb.AddCustomAttributes(typeof(While), new DesignerAttribute(
                                        typeof(ActivityLibrary.Design.MyWhileDesigner)));
            MetadataStore.AddAttributeTable(atb.CreateTable());
#endif
        }
Пример #4
0
        private ToolboxControl GetToolboxControl()
        {
            // Create the ToolBoxControl.
            ToolboxControl ctrl = new ToolboxControl();

            // Create a category.
            ToolboxCategory category = new ToolboxCategory("category1");

            // Create Toolbox items.
            ToolboxItemWrapper tool1 =
                new ToolboxItemWrapper("System.Activities.Statements.Assign",
                                       typeof(Assign).Assembly.FullName, null, "Assign");

            ToolboxItemWrapper tool2 = new ToolboxItemWrapper("System.Activities.Statements.Sequence",
                                                              typeof(Sequence).Assembly.FullName, null, "Sequence");

            // Add the Toolbox items to the category.
            category.Add(tool1);
            category.Add(tool2);

            // Add the category to the ToolBox control.
            ctrl.Categories.Add(category);
            return(ctrl);
        }
Пример #5
0
        //这个方法是为了加载控件库
        private static ToolboxControl CreateToolbox()
        {
            var toolboxControl = new ToolboxControl();

            toolboxControl.Categories.Add(
                new ToolboxCategory("控制流")
            {
                new ToolboxItemWrapper(typeof(DoWhile)),
                new ToolboxItemWrapper(typeof(ForEach <>)),
                new ToolboxItemWrapper(typeof(If)),
                new ToolboxItemWrapper(typeof(Parallel)),
                new ToolboxItemWrapper(typeof(ParallelForEach <>)),
                new ToolboxItemWrapper(typeof(Pick)),
                new ToolboxItemWrapper(typeof(PickBranch)),
                new ToolboxItemWrapper(typeof(Sequence)),
                new ToolboxItemWrapper(typeof(Switch <>)),
                new ToolboxItemWrapper(typeof(While)),
            });
            toolboxControl.Categories.Add(
                new ToolboxCategory("流程图")
            {
                new ToolboxItemWrapper(typeof(Flowchart)),
                new ToolboxItemWrapper(typeof(FlowDecision)),
                new ToolboxItemWrapper(typeof(FlowSwitch <>)),
            });
            toolboxControl.Categories.Add(
                new ToolboxCategory("运行时")
            {
                new ToolboxItemWrapper(typeof(Persist)),
            });
            toolboxControl.Categories.Add(
                new ToolboxCategory("基元")
            {
                new ToolboxItemWrapper(typeof(Assign)),
                new ToolboxItemWrapper(typeof(Delay)),
                new ToolboxItemWrapper(typeof(InvokeMethod)),
                new ToolboxItemWrapper(typeof(WriteLine)),
            });
            toolboxControl.Categories.Add(
                new ToolboxCategory("事务")
            {
                new ToolboxItemWrapper(typeof(CancellationScope)),
                new ToolboxItemWrapper(typeof(CompensableActivity)),
                new ToolboxItemWrapper(typeof(Compensate)),
                new ToolboxItemWrapper(typeof(Confirm)),
                new ToolboxItemWrapper(typeof(TransactionScope)),
            });
            toolboxControl.Categories.Add(
                new ToolboxCategory("集合")
            {
                new ToolboxItemWrapper(typeof(AddToCollection <>)),
                new ToolboxItemWrapper(typeof(ClearCollection <>)),
                new ToolboxItemWrapper(typeof(ExistsInCollection <>)),
                new ToolboxItemWrapper(typeof(RemoveFromCollection <>)),
            });

            toolboxControl.Categories.Add(
                new ToolboxCategory("错误处理")
            {
                new ToolboxItemWrapper(typeof(Rethrow)),
                new ToolboxItemWrapper(typeof(Throw)),
                new ToolboxItemWrapper(typeof(TryCatch)),
            });
            //一下为自定义的工作量活动
            //     toolboxControl.Categories.Add(
            //         new ToolboxCategory("MyActivityLibrary") { new ToolboxItemWrapper(typeof(AgreeAuth)), });

            return(toolboxControl);
        }
Пример #6
0
 public Toolbox()
 {
     toolbox = new ToolboxControl();
     Content = toolbox;
 }
        private ToolboxControl GetToolboxControl()
        {
            ToolboxControl toolboxControl = new ToolboxControl();


            //var cat = new ToolboxCategory("Standard Activities");
            //var assemblies = new List<Assembly>();
            //assemblies.Add(typeof(Send).Assembly);
            //assemblies.Add(typeof(Delay).Assembly);
            //assemblies.Add(typeof(ReceiveAndSendReplyFactory).Assembly);

            //var query = from asm in assemblies
            //             from type in asm.GetTypes()
            //             where type.IsPublic &&
            //             !type.IsNested &&
            //             !type.IsAbstract &&
            //             !type.ContainsGenericParameters &&
            //             (typeof(Activity).IsAssignableFrom(type) ||
            //             typeof(IActivityTemplateFactory).IsAssignableFrom(type))
            //             orderby type.Name
            //             select new ToolboxItemWrapper(type);

            //query.ToList().ForEach(ti => cat.Add(ti));
            //toolboxControl.Categories.Add(cat);

            toolboxControl.Categories.Add(new ToolboxCategory("Basic Activities")
            {
                new ToolboxItemWrapper(typeof(Sequence)),
                new ToolboxItemWrapper(typeof(WriteLine)),
                new ToolboxItemWrapper(typeof(Assign)),
                new ToolboxItemWrapper(typeof(InvokeWebService))
            });

            toolboxControl.Categories.Add(new ToolboxCategory("Control Flow Activities")
            {
                new ToolboxItemWrapper(typeof(Flowchart)),
                new ToolboxItemWrapper(typeof(FlowSwitch <>)),
                new ToolboxItemWrapper(typeof(FlowDecision)),
                new ToolboxItemWrapper(typeof(Parallel)),
                new ToolboxItemWrapper(typeof(TransactionScope)),
                new ToolboxItemWrapper(typeof(While)),
                new ToolboxItemWrapper(typeof(DoWhile)),
                new ToolboxItemWrapper(typeof(ForEach <>)),
                new ToolboxItemWrapper(typeof(ParallelForEach <>)),
                new ToolboxItemWrapper(typeof(TryCatch)),
                new ToolboxItemWrapper(typeof(Rethrow)),
                new ToolboxItemWrapper(typeof(Delay)),
                new ToolboxItemWrapper(typeof(If)),
                new ToolboxItemWrapper(typeof(Throw))
            });

            toolboxControl.Categories.Add(new ToolboxCategory("Collection Activities")
            {
                new ToolboxItemWrapper(typeof(AddToCollection <>)),
                new ToolboxItemWrapper(typeof(ClearCollection <>)),
                new ToolboxItemWrapper(typeof(RemoveFromCollection <>)),
                new ToolboxItemWrapper(typeof(ExistsInCollection <>))
            });


            toolboxControl.Categories.Add(new ToolboxCategory("Error Handling Activities")
            {
                new ToolboxItemWrapper(typeof(TransactionScope)),
                new ToolboxItemWrapper(typeof(TryCatch)),
                new ToolboxItemWrapper(typeof(Rethrow)),
                new ToolboxItemWrapper(typeof(Throw))
            });

            return(toolboxControl);
        }
		static ToolboxControl CreateToolboxControl()
		{
			ToolboxControl ctrl = new ToolboxControl();
			ToolboxCategoryItemsCollection category = new ToolboxCategoryItemsCollection("Workflow");
			//Adding the toolboxItems to the category.
			category.Tools.Add(new ToolboxItemWrapper("System.Activities.Statements.Sequence",
			                                          "System.Activities, Version=4.0.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35",
			                                          null, "Sequence"));
			ctrl.Categories.Add(category);
			return ctrl;
		}
Пример #9
0
        /// <summary>
        /// Builds the WF toolbox.
        /// </summary>
        /// <returns></returns>
        private ToolboxControl BuildToolbox()
        {
            ToolboxControl toolbox = new ToolboxControl();

            // Load core .NET Bio types
            var bioCategory = new ToolboxCategory(".NET Bio Activities");

            foreach (var activity in GetActivityTypes(typeof(ActivityConstants).Assembly))
            {
                bioCategory.Add(new ToolboxItemWrapper(activity, GetFriendlyName(activity)));
            }
            (new RegisterMetadata()).Register();
            toolbox.Categories.Add(bioCategory);

            // Add standard types
            foreach (var activityList in _standardActivities)
            {
                var category = new ToolboxCategory(activityList.Key);
                foreach (var activity in activityList.Value)
                {
                    category.Add(new ToolboxItemWrapper(activity, GetFriendlyName(activity)));
                }
                toolbox.Categories.Add(category);
            }

            // Load any custom types defined in app.config
            // Get any add-ons
            string searchList = ConfigurationManager.AppSettings["searchList"];

            if (!string.IsNullOrEmpty(searchList))
            {
                string[] dllList = searchList.Split(',');
                foreach (var asmName in dllList)
                {
                    Assembly asm = Assembly.Load(asmName);
                    if (asm != null)
                    {
                        foreach (var activity in GetActivityTypes(asm))
                        {
                            var    dca     = activity.GetCustomAttributes(typeof(DesignerCategoryAttribute)).FirstOrDefault() as DesignerCategoryAttribute;
                            string catName = dca != null ? dca.Category : asm.GetName().Name;

                            var category = toolbox.Categories.FirstOrDefault(tbc => tbc.CategoryName == catName);
                            if (category == null)
                            {
                                category = new ToolboxCategory(catName);
                                toolbox.Categories.Add(category);
                            }
                            category.Add(new ToolboxItemWrapper(activity, GetFriendlyName(activity)));
                        }

                        // See if we can find any metadata registration.
                        foreach (var rmType in asm.GetTypes().Where(t => t.Implements(typeof(IRegisterMetadata))))
                        {
                            try
                            {
                                var irm = Activator.CreateInstance(rmType) as IRegisterMetadata;
                                if (irm != null)
                                {
                                    irm.Register();
                                }
                            }
                            catch
                            {
                            }
                        }
                    }
                }
            }

            return(toolbox);
        }
Пример #10
0
        private ToolboxControl CreateTbx()
        {
            Dictionary <string, List <Type> > activitiesToInclude = new Dictionary <string, List <Type> >();

            activitiesToInclude.Add("Control Flow", new List <Type>
            {
                typeof(DoWhile),
                typeof(ForEach <>),
                typeof(If),
                typeof(Parallel),
                typeof(ParallelForEach <>),
                typeof(Pick),
                typeof(PickBranch),
                typeof(Sequence),
                typeof(Switch <>),
                typeof(While),
            });
            activitiesToInclude.Add("Flowchart", new List <Type>
            {
                typeof(Flowchart),
                typeof(FlowDecision),
                typeof(FlowSwitch <>)
            });
            activitiesToInclude.Add("State Machine", new List <Type>
            {
                typeof(StateMachine),
                typeof(State),
                typeof(FinalState)
            });
            activitiesToInclude.Add("Messaging", new List <Type>
            {
                typeof(CorrelationScope),
                typeof(InitializeCorrelation),
                typeof(Receive),
                typeof(ReceiveAndSendReplyFactory),
                typeof(Send),
                typeof(SendAndReceiveReplyFactory),
                typeof(TransactedReceiveScope)
            });
            activitiesToInclude.Add("Runtime", new List <Type>
            {
                typeof(Persist),
                typeof(TerminateWorkflow),
                typeof(NoPersistScope)
            });
            activitiesToInclude.Add("Primitives", new List <Type>
            {
                typeof(Assign),
                typeof(Delay),
                typeof(InvokeDelegate),
                typeof(InvokeMethod),
                typeof(WriteLine)
            });
            activitiesToInclude.Add("Transaction", new List <Type>
            {
                typeof(CancellationScope),
                typeof(CompensableActivity),
                typeof(Compensate),
                typeof(Confirm),
                typeof(TransactionScope)
            });
            activitiesToInclude.Add("Collection", new List <Type>
            {
                typeof(AddToCollection <>),
                typeof(ClearCollection <>),
                typeof(ExistsInCollection <>),
                typeof(RemoveFromCollection <>),
            });
            activitiesToInclude.Add("Error Handling", new List <Type>
            {
                typeof(Rethrow),
                typeof(Throw),
                typeof(TryCatch)
            });
            activitiesToInclude.Add("HR Workflow Service", new List <Type>
            {
                typeof(StartApproval),
                typeof(createAppointment),
                typeof(SendEmail)
            });

            ToolboxControl tb = new ToolboxControl();

            foreach (var category in activitiesToInclude)
            {
                ToolboxCategory cat = CreateTbxCat(category.Key, category.Value, true);
                tb.Categories.Add(cat);
            }
            return(tb);
        }
Пример #11
0
        /// <summary>
        /// Retrieves all Workflow Activities from the loaded assemblies and inserts them into a ToolboxControl
        /// </summary>
        private void InitializeActivitiesToolbox()
        {
            try
            {
                _wfToolbox = new ToolboxControl();

                // load Custom Activity Libraries into current domain
                AppDomain.CurrentDomain.Load("MeetupActivityLibrary");

                // get all loaded assemblies
                IEnumerable <Assembly> appAssemblies = AppDomain.CurrentDomain.GetAssemblies().OrderBy(a => a.GetName().Name);

                // check if assemblies contain activities
                int activitiesCount = 0;
                foreach (Assembly activityLibrary in appAssemblies)
                {
                    var wfToolboxCategory = new ToolboxCategory(activityLibrary.GetName().Name);
                    var actvities         = from
                                            activityType in activityLibrary.GetExportedTypes()
                                            where
                                            (activityType.IsSubclassOf(typeof(Activity)) ||
                                             activityType.IsSubclassOf(typeof(NativeActivity)) ||
                                             activityType.IsSubclassOf(typeof(DynamicActivity)) ||
                                             activityType.IsSubclassOf(typeof(ActivityWithResult)) ||
                                             activityType.IsSubclassOf(typeof(AsyncCodeActivity)) ||
                                             activityType.IsSubclassOf(typeof(CodeActivity)) ||
                                             activityType == typeof(System.Activities.Core.Presentation.Factories.ForEachWithBodyFactory <Type>) ||
                                             activityType == typeof(System.Activities.Statements.FlowNode) ||
                                             activityType == typeof(System.Activities.Statements.State) ||
                                             activityType == typeof(System.Activities.Core.Presentation.FinalState) ||
                                             activityType == typeof(System.Activities.Statements.FlowDecision) ||
                                             activityType == typeof(System.Activities.Statements.FlowNode) ||
                                             activityType == typeof(System.Activities.Statements.FlowStep) ||
                                             activityType == typeof(System.Activities.Statements.FlowSwitch <Type>) ||
                                             activityType == typeof(System.Activities.Statements.ForEach <Type>) ||
                                             activityType == typeof(System.Activities.Statements.Switch <Type>) ||
                                             activityType == typeof(System.Activities.Statements.TryCatch) ||
                                             activityType == typeof(System.Activities.Statements.While)) &&
                                            activityType.IsVisible &&
                                            activityType.IsPublic &&
                                            !activityType.IsNested &&
                                            !activityType.IsAbstract &&
                                            (activityType.GetConstructor(Type.EmptyTypes) != null) &&
                                            !activityType.Name.Contains('`')
                                            orderby
                                            activityType.Name
                                            select
                                            new ToolboxItemWrapper(activityType);

                    actvities.ToList().ForEach(wfToolboxCategory.Add);
                    if (wfToolboxCategory.Tools.Count > 0)
                    {
                        _wfToolbox.Categories.Add(wfToolboxCategory);
                        activitiesCount += wfToolboxCategory.Tools.Count;
                    }
                }
                LabelStatusBar.Content = String.Format("Loaded Activities: {0}", activitiesCount.ToString());
                WfToolboxBorder.Child  = _wfToolbox;
            }
            catch (Exception ex)
            {
                MessageBox.Show(ex.Message);
            }
        }
Пример #12
0
 public MainWindowViewModel()
 {
     // LoadToolboxIconsForBuiltInActivities();
     this.toolboxControl = new ToolboxControl();
     this.InitialiseToolbox();
 }
Пример #13
0
        private ToolboxControl GetToolboxControl()
        {
            ToolboxControl Control = new ToolboxControl();

            var cat = new ToolboxCategory("Android");

            cat.Add(new ToolboxItemWrapper(typeof(ActivityLibrary.GetIntIDList), "GetIntIDList"));
            //cat.Add(new ToolboxItemWrapper(typeof(ActivityLibrary.ReadLayouts), "ReadLayouts"));
            cat.Add(new ToolboxItemWrapper(typeof(ActivityLibrary.ReadLayoutAttribute), "ReadLayoutAttribute"));
            cat.Add(new ToolboxItemWrapper(typeof(ActivityLibrary.ReadMenuAttribute), "ReadMenuAttribute"));
            cat.Add(new ToolboxItemWrapper(typeof(ActivityLibrary.ReadManifestAttribute), "ReadManifestAttribute"));
            cat.Add(new ToolboxItemWrapper(typeof(ActivityLibrary.ClearResults), "ClearResponse"));
            cat.Add(new ToolboxItemWrapper(typeof(ActivityLibrary.WriteResponse), "WriteResponse"));
            cat.Add(new ToolboxItemWrapper(typeof(ActivityLibrary.GetControlIntIds), "GetControlIntIds"));
            cat.Add(new ToolboxItemWrapper(typeof(ActivityLibrary.SearchInCode), "SearchJavaCode"));

            // cat.Add(new ToolboxItemWrapper(typeof(ActivityLibrary.Activity1), "Activity1"));
            Control.Categories.Add(cat);


            cat = new ToolboxCategory("Control Flow");
            cat.Add(new ToolboxItemWrapper(typeof(System.Activities.Statements.DoWhile)));
            cat.Add(new ToolboxItemWrapper(typeof(System.Activities.Statements.ForEach <>), "ForEach<T>"));
            cat.Add(new ToolboxItemWrapper(typeof(System.Activities.Statements.If)));
            cat.Add(new ToolboxItemWrapper(typeof(System.Activities.Statements.Parallel)));
            cat.Add(new ToolboxItemWrapper(typeof(System.Activities.Statements.ParallelForEach <>), "ParallelForEach<T>"));
            cat.Add(new ToolboxItemWrapper(typeof(System.Activities.Statements.Pick)));
            cat.Add(new ToolboxItemWrapper(typeof(System.Activities.Statements.PickBranch)));
            cat.Add(new ToolboxItemWrapper(typeof(System.Activities.Statements.Sequence)));
            cat.Add(new ToolboxItemWrapper(typeof(System.Activities.Statements.Switch <>), "Switch<T>"));
            cat.Add(new ToolboxItemWrapper(typeof(System.Activities.Statements.While)));
            Control.Categories.Add(cat);


            cat = new ToolboxCategory("FlowChart");
            cat.Add(new ToolboxItemWrapper(typeof(System.Activities.Statements.Flowchart)));
            cat.Add(new ToolboxItemWrapper(typeof(System.Activities.Statements.FlowDecision)));
            cat.Add(new ToolboxItemWrapper(typeof(System.Activities.Statements.FlowSwitch <>), "FlowSwitch<T>"));
            Control.Categories.Add(cat);


            cat = new ToolboxCategory("Runtime");
            cat.Add(new ToolboxItemWrapper(typeof(System.Activities.Statements.Persist)));
            cat.Add(new ToolboxItemWrapper(typeof(System.Activities.Statements.TerminateWorkflow)));
            Control.Categories.Add(cat);

            cat = new ToolboxCategory("Primitives");
            cat.Add(new ToolboxItemWrapper(typeof(System.Activities.Statements.Assign)));
            cat.Add(new ToolboxItemWrapper(typeof(System.Activities.Statements.Delay)));
            cat.Add(new ToolboxItemWrapper(typeof(System.Activities.Statements.InvokeMethod)));
            cat.Add(new ToolboxItemWrapper(typeof(System.Activities.Statements.WriteLine)));
            Control.Categories.Add(cat);

            cat = new ToolboxCategory("Transaction");
            cat.Add(new ToolboxItemWrapper(typeof(System.Activities.Statements.CancellationScope)));
            cat.Add(new ToolboxItemWrapper(typeof(System.Activities.Statements.CompensableActivity)));
            cat.Add(new ToolboxItemWrapper(typeof(System.Activities.Statements.Compensate)));
            cat.Add(new ToolboxItemWrapper(typeof(System.Activities.Statements.Confirm)));
            cat.Add(new ToolboxItemWrapper(typeof(System.Activities.Statements.TransactionScope)));
            Control.Categories.Add(cat);

            cat = new ToolboxCategory("Collection");
            cat.Add(new ToolboxItemWrapper(typeof(System.Activities.Statements.AddToCollection <>), "AddToCollection<T>"));
            cat.Add(new ToolboxItemWrapper(typeof(System.Activities.Statements.ClearCollection <>), "ClearCollection<T>"));
            cat.Add(new ToolboxItemWrapper(typeof(System.Activities.Statements.ExistsInCollection <>), "ExistsInCollection<T>"));
            cat.Add(new ToolboxItemWrapper(typeof(System.Activities.Statements.RemoveFromCollection <>), "RemoveFromCollection<T>"));
            Control.Categories.Add(cat);

            cat = new ToolboxCategory("Error Handling");
            cat.Add(new ToolboxItemWrapper(typeof(System.Activities.Statements.Rethrow)));
            cat.Add(new ToolboxItemWrapper(typeof(System.Activities.Statements.Throw)));
            cat.Add(new ToolboxItemWrapper(typeof(System.Activities.Statements.TryCatch)));
            Control.Categories.Add(cat);

            return(Control);
        }
Пример #14
0
        private ToolboxControl GetDefaultToolbox()
        {
            ToolboxControl toolbox = new ToolboxControl();

            ToolboxCategory c1 = new ToolboxCategory("Control Flow");

            c1.Add(new ToolboxItemWrapper(typeof(DoWhile)));
            c1.Add(new ToolboxItemWrapper(typeof(ForEachWithBodyFactory <>), "ForEach<T>"));
            c1.Add(new ToolboxItemWrapper(typeof(If)));
            c1.Add(new ToolboxItemWrapper(typeof(System.Activities.Statements.Parallel)));
            c1.Add(new ToolboxItemWrapper(typeof(ParallelForEachWithBodyFactory <>), "ParallelForEach<T>"));
            c1.Add(new ToolboxItemWrapper(typeof(PickWithTwoBranchesFactory), "Pick"));
            c1.Add(new ToolboxItemWrapper(typeof(PickBranch)));
            c1.Add(new ToolboxItemWrapper(typeof(Sequence)));
            c1.Add(new ToolboxItemWrapper(typeof(Switch <>), "Switch<T>"));
            c1.Add(new ToolboxItemWrapper(typeof(While)));
            toolbox.Categories.Add(c1);

            ToolboxCategory c2 = new ToolboxCategory("Flowchart");

            c2.Add(new ToolboxItemWrapper(typeof(Flowchart)));
            c2.Add(new ToolboxItemWrapper(typeof(FlowDecision)));
            c2.Add(new ToolboxItemWrapper(typeof(FlowSwitch <>), "FlowSwitch<T>"));
            toolbox.Categories.Add(c2);

            ToolboxCategory c3 = new ToolboxCategory("StateMachine");

            c3.Add(new ToolboxItemWrapper(typeof(StateMachineWithInitialStateFactory), "StateMachine"));
            c3.Add(new ToolboxItemWrapper(typeof(State)));
            c3.Add(new ToolboxItemWrapper(typeof(FinalState)));
            toolbox.Categories.Add(c3);

            ToolboxCategory c4 = new ToolboxCategory("Runtime");

            c4.Add(new ToolboxItemWrapper(typeof(Persist)));
            c4.Add(new ToolboxItemWrapper(typeof(TerminateWorkflow)));
            c4.Add(new ToolboxItemWrapper(typeof(NoPersistScope)));
            toolbox.Categories.Add(c4);

            ToolboxCategory c5 = new ToolboxCategory("Primitives");

            c5.Add(new ToolboxItemWrapper(typeof(Assign)));
            c5.Add(new ToolboxItemWrapper(typeof(Assign <>), "Assign<T>"));
            c5.Add(new ToolboxItemWrapper(typeof(Delay)));
            c4.Add(new ToolboxItemWrapper(typeof(Persist)));
            c5.Add(new ToolboxItemWrapper(typeof(InvokeMethod)));
            c4.Add(new ToolboxItemWrapper(typeof(InvokeDelegate)));
            c5.Add(new ToolboxItemWrapper(typeof(WriteLine)));
            toolbox.Categories.Add(c5);

            ToolboxCategory c7 = new ToolboxCategory("Collection");

            c7.Add(new ToolboxItemWrapper(typeof(AddToCollection <>), "AddToCollection<T>"));
            c7.Add(new ToolboxItemWrapper(typeof(ClearCollection <>), "ClearCollection<T>"));
            c7.Add(new ToolboxItemWrapper(typeof(ExistsInCollection <>), "ExistsInCollection<T>"));
            c7.Add(new ToolboxItemWrapper(typeof(RemoveFromCollection <>), "RemoveFromCollection<T>"));
            toolbox.Categories.Add(c7);

            ToolboxCategory c8 = new ToolboxCategory("Error Handling");

            c8.Add(new ToolboxItemWrapper(typeof(Rethrow)));
            c8.Add(new ToolboxItemWrapper(typeof(Throw)));
            c8.Add(new ToolboxItemWrapper(typeof(TryCatch)));
            toolbox.Categories.Add(c8);
            return(toolbox);

            ToolboxCategory c9 = new ToolboxCategory("Messaging");

            c9.Add(new ToolboxItemWrapper(typeof(CorrelationScope), "CorrelationScope"));
            c9.Add(new ToolboxItemWrapper(typeof(InitializeCorrelation)));
            c9.Add(new ToolboxItemWrapper(typeof(Receive)));
            c9.Add(new ToolboxItemWrapper(typeof(Send)));
            c9.Add(new ToolboxItemWrapper(typeof(ReceiveReply)));
            c9.Add(new ToolboxItemWrapper(typeof(SendReply)));
            c9.Add(new ToolboxItemWrapper(typeof(TransactedReceiveScope)));
            toolbox.Categories.Add(c9);
        }
Пример #15
0
 public void DeleteControl(ToolboxControl todelete)
 {
     clickedControl = todelete;
     rightclick_DeleteControlClick(null, null);
 }
        /// <summary>
        /// Retrieves all Workflow Activities from the loaded assemblies and inserts them into a ToolboxControl
        /// </summary>
        private void InitializeActivitiesToolbox()
        {
            try
            {
                _wfToolbox = new ToolboxControl();

                //load dependency
                AppDomain.CurrentDomain.Load("Twilio.Api");
                // load Custom Activity Libraries into current domain
                AppDomain.CurrentDomain.Load("MeetupActivityLibrary");
                // load System Activity Libraries into current domain; uncomment more if libraries below available on your system
                AppDomain.CurrentDomain.Load("System.Activities");
                AppDomain.CurrentDomain.Load("System.ServiceModel.Activities");
                AppDomain.CurrentDomain.Load("System.Activities.Core.Presentation");
                //AppDomain.CurrentDomain.Load("Microsoft.Workflow.Management");
                //AppDomain.CurrentDomain.Load("Microsoft.Activities.Extensions");
                //AppDomain.CurrentDomain.Load("Microsoft.Activities");
                //AppDomain.CurrentDomain.Load("Microsoft.Activities.Hosting");
                //AppDomain.CurrentDomain.Load("Microsoft.PowerShell.Utility.Activities");
                //AppDomain.CurrentDomain.Load("Microsoft.PowerShell.Security.Activities");
                //AppDomain.CurrentDomain.Load("Microsoft.PowerShell.Management.Activities");
                //AppDomain.CurrentDomain.Load("Microsoft.PowerShell.Diagnostics.Activities");
                //AppDomain.CurrentDomain.Load("Microsoft.Powershell.Core.Activities");
                //AppDomain.CurrentDomain.Load("Microsoft.PowerShell.Activities");

                // get all loaded assemblies
                IEnumerable <Assembly> appAssemblies = AppDomain.CurrentDomain.GetAssemblies().OrderBy(a => a.GetName().Name);

                // check if assemblies contain activities
                int activitiesCount = 0;
                foreach (Assembly activityLibrary in appAssemblies)
                {
                    var wfToolboxCategory = new ToolboxCategory(activityLibrary.GetName().Name);
                    var actvities         = from
                                            activityType in activityLibrary.GetExportedTypes()
                                            where
                                            (activityType.IsSubclassOf(typeof(Activity)) ||
                                             activityType.IsSubclassOf(typeof(NativeActivity)) ||
                                             activityType.IsSubclassOf(typeof(DynamicActivity)) ||
                                             activityType.IsSubclassOf(typeof(ActivityWithResult)) ||
                                             activityType.IsSubclassOf(typeof(AsyncCodeActivity)) ||
                                             activityType.IsSubclassOf(typeof(CodeActivity)) ||
                                             activityType == typeof(System.Activities.Core.Presentation.Factories.ForEachWithBodyFactory <Type>) ||
                                             activityType == typeof(System.Activities.Statements.FlowNode) ||
                                             activityType == typeof(System.Activities.Statements.State) ||
                                             activityType == typeof(System.Activities.Core.Presentation.FinalState) ||
                                             activityType == typeof(System.Activities.Statements.FlowDecision) ||
                                             activityType == typeof(System.Activities.Statements.FlowNode) ||
                                             activityType == typeof(System.Activities.Statements.FlowStep) ||
                                             activityType == typeof(System.Activities.Statements.FlowSwitch <Type>) ||
                                             activityType == typeof(System.Activities.Statements.ForEach <Type>) ||
                                             activityType == typeof(System.Activities.Statements.Switch <Type>) ||
                                             activityType == typeof(System.Activities.Statements.TryCatch) ||
                                             activityType == typeof(System.Activities.Statements.While)) &&
                                            activityType.IsVisible &&
                                            activityType.IsPublic &&
                                            !activityType.IsNested &&
                                            !activityType.IsAbstract &&
                                            (activityType.GetConstructor(Type.EmptyTypes) != null)
                                            //&& !activityType.Name.Contains('`')
                                            orderby
                                            activityType.Name
                                            select
                                            new ToolboxItemWrapper(activityType);

                    actvities.ToList().ForEach(wfToolboxCategory.Add);

                    if (wfToolboxCategory.Tools.Count > 0)
                    {
                        _wfToolbox.Categories.Add(wfToolboxCategory);
                        activitiesCount += wfToolboxCategory.Tools.Count;
                    }
                }
                //fixed ForEach
                _wfToolbox.Categories.Add(
                    new System.Activities.Presentation.Toolbox.ToolboxCategory
                {
                    CategoryName = "CustomForEach",
                    Tools        =
                    {
                        new ToolboxItemWrapper(typeof(System.Activities.Core.Presentation.Factories.ForEachWithBodyFactory <>)),
                        new ToolboxItemWrapper(typeof(System.Activities.Core.Presentation.Factories.ParallelForEachWithBodyFactory <>))
                    }
                }
                    );

                LabelStatusBar.Content = String.Format("Loaded Activities: {0}", activitiesCount.ToString());
                WfToolboxBorder.Child  = _wfToolbox;
            }
            catch (Exception ex)
            {
                MessageBox.Show(ex.Message);
            }
        }
Пример #17
0
        private void AddToolBox()
        {
            var tc = GetToolboxControl();

            Toolbox = tc;
        }
        private void AddToolBox()
        {
            ToolboxControl tc = GetToolboxControl();

            this.toolboxPanel.Content = tc;
        }
Пример #19
0
        private ToolboxControl GetToolboxControl()
        {
            // Create the ToolBoxControl.
            ToolboxControl ctrl = new ToolboxControl();

            var categories = new List <ToolboxCategory>
            {
                new ToolboxCategory("ControlFlow")
                {
                    new ToolboxItemWrapper(typeof(DoWhile), "DoWhile", "DoWhile"),
                    new ToolboxItemWrapper(typeof(ForEach <>), "ForEach", "ForEach"),
                    new ToolboxItemWrapper(typeof(If), "If", "If"),
                    new ToolboxItemWrapper(typeof(Parallel), "Parallel", "Parallel"),
                    new ToolboxItemWrapper(typeof(ParallelForEach <>), "ParallelForEach", "ParallelForEach<T>"),
                    new ToolboxItemWrapper(typeof(Pick), "Pick", "Pick"),
                    new ToolboxItemWrapper(typeof(PickBranch), "PickBranch", "PickBranch"),
                    new ToolboxItemWrapper(typeof(Sequence), "Sequence", "Sequence"),
                    new ToolboxItemWrapper(typeof(Switch <>), "Switch", "Switch<T>"),
                    new ToolboxItemWrapper(typeof(While), "While", "While")
                },
                new ToolboxCategory("Flowchart")
                {
                    new ToolboxItemWrapper(typeof(Flowchart), "Flowchart", "Flowchart"),
                    new ToolboxItemWrapper(typeof(FlowSwitch <>), "FlowSwitch", "FlowSwitch<T>"),
                    new ToolboxItemWrapper(typeof(FlowDecision), "FlowDecision", "FlowDecision")
                },
                //new ToolboxCategory("Runtime")
                //{
                //    new ToolboxItemWrapper(typeof(Persist), "Persist", "Persist"),
                //    new ToolboxItemWrapper(typeof(TerminateWorkflow), "TerminateWorkflow", "TerminateWorkflow")
                //},
                new ToolboxCategory("Primitives")
                {
                    new ToolboxItemWrapper(typeof(Assign), "Assign", "Assign"),
                    new ToolboxItemWrapper(typeof(Assign <>), "Assign", "Assign<T>"),
                    new ToolboxItemWrapper(typeof(Delay), "Delay", "Delay"),
                    new ToolboxItemWrapper(typeof(InvokeMethod), "InvokeMethod", "InvokeMethod"),
                    new ToolboxItemWrapper(typeof(WriteLine), "WriteLine", "WriteLine")
                },
                //new ToolboxCategory("Transaction")
                //{
                //    new ToolboxItemWrapper(typeof(CancellationScope), "CancellationScope", "CancellationScope"),
                //    new ToolboxItemWrapper(typeof(CompensableActivity), "CompensableActivity", "CompensableActivity"),
                //    new ToolboxItemWrapper(typeof(Compensate), "Compensate", "Compensate"),
                //    new ToolboxItemWrapper(typeof(Confirm), "Confirm", "Confirm"),
                //    new ToolboxItemWrapper(typeof(TransactionScope), "TransactionScope", "TransactionScope")
                //},
                new ToolboxCategory("Collection")
                {
                    new ToolboxItemWrapper(typeof(AddToCollection <>), "AddToCollection", "AddToCollection<T>"),
                    new ToolboxItemWrapper(typeof(ClearCollection <>), "ClearCollection", "ClearCollection<T>"),
                    new ToolboxItemWrapper(typeof(ExistsInCollection <>), "ExistsInCollection", "ExistsInCollection<T>"),
                    new ToolboxItemWrapper(typeof(RemoveFromCollection <>), "RemoveFromCollection", "RemoveFromCollection<T>")
                },
                new ToolboxCategory("ErrorHandling")
                {
                    new ToolboxItemWrapper(typeof(Rethrow), "Rethrow", "Rethrow"),
                    new ToolboxItemWrapper(typeof(Throw), "Throw", "Throw"),
                    new ToolboxItemWrapper(typeof(TryCatch), "TryCatch", "TryCatch")
                }
                //new ToolboxCategory("CCH")
                //{
                //    new ToolboxItemWrapper(typeof(CreateClient), "CreateClient", "CreateClient"),
                //    new ToolboxItemWrapper(typeof(CreateTask), "CreateTask", "CreateTask")
                //}
            };

            var activityTypes = new List <ToolboxItemWrapper>();

            categories.ForEach(cat => cat.Tools.ToList().ForEach(activityTypes.Add));
            ToolboxIconCreator.LoadToolboxIcons(activityTypes, this.GetIconReaders().ToList());
            categories.ForEach(cat => ctrl.Categories.Add(cat));

            return(ctrl);
        }
        /// <summary>
        /// Retrieves all Workflow Activities from the loaded assemblies and inserts them into a ToolboxControl
        /// </summary>
        private void InitializeActivitiesToolbox()
        {
            try
            {
                new Autossential.Activities.Design.DesignerMetadata().Register();
                _wfToolbox = new ToolboxControl();

                AppDomain.CurrentDomain.Load("Autossential.Activities");
                var assemblies = AppDomain.CurrentDomain.GetAssemblies().OrderBy(p => p.GetName().Name);

                int activitiesCount = 0;
                foreach (var asm in assemblies)
                {
                    var category   = new ToolboxCategory(asm.GetName().Name);
                    var activities = GetActivities(asm);
                    foreach (var a in activities)
                    {
                        category.Add(a);
                    }

                    if (category.Tools.Count > 0)
                    {
                        _wfToolbox.Categories.Add(category);
                        activitiesCount += category.Tools.Count;
                    }
                }

                LabelStatusBar.Content = String.Format("Loaded Activities: {0}", activitiesCount.ToString());
                WfToolboxBorder.Child  = _wfToolbox;
            }
            catch (Exception ex)
            {
                MessageBox.Show(ex.Message);
            }

            //try
            //{
            //    _wfToolbox = new ToolboxControl();

            //    //load dependency
            //    //AppDomain.CurrentDomain.Load("Twilio.Api");
            //    AppDomain.CurrentDomain.Load("Autossential.Activities");
            //    // load Custom Activity Libraries into current domain
            //    //AppDomain.CurrentDomain.Load("MeetupActivityLibrary");
            //    // load System Activity Libraries into current domain; uncomment more if libraries below available on your system
            //    //AppDomain.CurrentDomain.Load("System.Activities");
            //    //AppDomain.CurrentDomain.Load("System.ServiceModel.Activities");
            //    //AppDomain.CurrentDomain.Load("System.Activities.Core.Presentation");
            //    //AppDomain.CurrentDomain.Load("Microsoft.Workflow.Management");
            //    //AppDomain.CurrentDomain.Load("Microsoft.Activities.Extensions");
            //    //AppDomain.CurrentDomain.Load("Microsoft.Activities");
            //    //AppDomain.CurrentDomain.Load("Microsoft.Activities.Hosting");
            //    //AppDomain.CurrentDomain.Load("Microsoft.PowerShell.Utility.Activities");
            //    //AppDomain.CurrentDomain.Load("Microsoft.PowerShell.Security.Activities");
            //    //AppDomain.CurrentDomain.Load("Microsoft.PowerShell.Management.Activities");
            //    //AppDomain.CurrentDomain.Load("Microsoft.PowerShell.Diagnostics.Activities");
            //    //AppDomain.CurrentDomain.Load("Microsoft.Powershell.Core.Activities");
            //    //AppDomain.CurrentDomain.Load("Microsoft.PowerShell.Activities");

            //    // get all loaded assemblies
            //    IEnumerable<Assembly> appAssemblies = AppDomain.CurrentDomain.GetAssemblies().OrderBy(a => a.GetName().Name);


            // //   new Autossential.Activities.Design.DesignerMetadata().Register();

            //    // check if assemblies contain activities
            //    int activitiesCount = 0;
            //    foreach (Assembly activityLibrary in appAssemblies)
            //    {

            //        var wfToolboxCategory = new ToolboxCategory(activityLibrary.GetName().Name);
            //        var actvities = from
            //                            activityType in activityLibrary.GetExportedTypes()
            //                        where
            //                            (activityType.IsSubclassOf(typeof(Activity))
            //                            || activityType.IsSubclassOf(typeof(NativeActivity))
            //                            || activityType.IsSubclassOf(typeof(DynamicActivity))
            //                            || activityType.IsSubclassOf(typeof(ActivityWithResult))
            //                            || activityType.IsSubclassOf(typeof(AsyncCodeActivity))
            //                            || activityType.IsSubclassOf(typeof(CodeActivity))
            //                            || activityType == typeof(System.Activities.Core.Presentation.Factories.ForEachWithBodyFactory<Type>)
            //                            || activityType == typeof(System.Activities.Statements.FlowNode)
            //                            || activityType == typeof(System.Activities.Statements.State)
            //                            || activityType == typeof(System.Activities.Core.Presentation.FinalState)
            //                            || activityType == typeof(System.Activities.Statements.FlowDecision)
            //                            || activityType == typeof(System.Activities.Statements.FlowNode)
            //                            || activityType == typeof(System.Activities.Statements.FlowStep)
            //                            || activityType == typeof(System.Activities.Statements.FlowSwitch<Type>)
            //                            || activityType == typeof(System.Activities.Statements.ForEach<Type>)
            //                            || activityType == typeof(System.Activities.Statements.Switch<Type>)
            //                            || activityType == typeof(System.Activities.Statements.TryCatch)
            //                            || activityType == typeof(System.Activities.Statements.While))
            //                            && activityType.IsVisible
            //                            && activityType.IsPublic
            //                            && !activityType.IsNested
            //                            && !activityType.IsAbstract
            //                            && (activityType.GetConstructor(Type.EmptyTypes) != null)
            //                            && !activityType.Name.Contains('`') //optional, for extra cleanup
            //                        orderby
            //                            activityType.Name
            //                        select
            //                            new ToolboxItemWrapper(activityType);

            //        actvities.ToList().ForEach(wfToolboxCategory.Add);

            //        if (wfToolboxCategory.Tools.Count > 0)
            //        {
            //            _wfToolbox.Categories.Add(wfToolboxCategory);
            //            activitiesCount += wfToolboxCategory.Tools.Count;
            //        }
            //    }
            //    //fixed ForEach
            //    _wfToolbox.Categories.Add(
            //           new System.Activities.Presentation.Toolbox.ToolboxCategory
            //           {
            //               CategoryName = "CustomForEach",
            //               Tools = {
            //                    new ToolboxItemWrapper(typeof(System.Activities.Core.Presentation.Factories.ForEachWithBodyFactory<>)),
            //                    new ToolboxItemWrapper(typeof(System.Activities.Core.Presentation.Factories.ParallelForEachWithBodyFactory<>))
            //               }
            //           }
            //    );

            //    LabelStatusBar.Content = String.Format("Loaded Activities: {0}", activitiesCount.ToString());
            //    WfToolboxBorder.Child = _wfToolbox;
            //}
            //catch (Exception ex)
            //{
            //    MessageBox.Show(ex.Message);
            //}
        }
Пример #21
0
        private ToolboxControl CreateToolbox()
        {
            Dictionary <String, List <Type> > activitiesToInclude =
                new Dictionary <String, List <Type> >();

            activitiesToInclude.Add("Basic", new List <Type>
            {
                typeof(Sequence),
                typeof(If),
                typeof(While),
                typeof(Assign),
                typeof(WriteLine)
            });

            activitiesToInclude.Add("Flowchart", new List <Type>
            {
                typeof(Flowchart),
                typeof(FlowDecision),
                typeof(FlowSwitch <>)
            });

            activitiesToInclude.Add("Collections", new List <Type>
            {
                typeof(ForEachWithBodyFactory <>),
                typeof(ParallelForEachWithBodyFactory <>),
                typeof(ExistsInCollection <>),
                typeof(AddToCollection <>),
                typeof(RemoveFromCollection <>),
                typeof(ClearCollection <>),
            });

            activitiesToInclude.Add("Error Handling", new List <Type>
            {
                typeof(TryCatch),
                typeof(Throw),
                typeof(TransactionScope)
            });

            ToolboxControl tb = new ToolboxControl();

            foreach (var category in activitiesToInclude)
            {
                ToolboxCategory cat = CreateToolboxCategory(
                    category.Key, category.Value, true);
                tb.Categories.Add(cat);

#if FLOWCHART
                if (cat.CategoryName == "Flowchart")
                {
                    flowchartCategory = cat;
                    foreach (var tool in cat.Tools)
                    {
                        if (tool.Type == typeof(FlowDecision) ||
                            tool.Type == typeof(FlowSwitch <>))
                        {
                            flowchartActivities.Add(tool);
                        }
                    }
                }
#endif
            }

            return(tb);
        }
Пример #22
0
        public ToolboxControl InitializeActivitiesToolbox()
        {
            try
            {
                var Toolbox = new ToolboxControl();
                // get all loaded assemblies
                IEnumerable <System.Reflection.Assembly> appAssemblies = AppDomain.CurrentDomain.GetAssemblies().OrderBy(a => a.GetName().Name)
                                                                         .Where(a => a.GetName().Name != "System.ServiceModel.Activities");

                // check if assemblies contain activities
                int activitiesCount = 0;
                foreach (System.Reflection.Assembly activityLibrary in appAssemblies)
                {
                    try
                    {
                        string[] excludeActivities = { "AddValidationError",      "AndAlso",             "AssertValidation",     "CreateBookmarkScope",    "DeleteBookmarkScope", "DynamicActivity",
                                                       "CancellationScope",       "CompensableActivity", "Compensate",           "Confirm",                "GetChildSubtree",     "GetParentChain", "GetWorkflowTree",    "Add`3",         "And`3",                       "As`2", "Cast`2",
                                                       "Cast`2",                  "ArgumentValue`1",     "ArrayItemReference`1", "ArrayItemValue`1",       "Assign`1",            "Constraint`1",   "CSharpReference`1",  "CSharpValue`1", "DelegateArgumentReference`1",
                                                       "DelegateArgumentValue`1", "Divide`3",            "DynamicActivity`1",    "Equal`3",                "FieldReference`2",    "FieldValue`2",   "ForEach`1",          "InvokeAction",  "InvokeDelegate",
                                                       "ArgumentReference`1",     "VariableReference`1", "VariableValue`1",      "VisualBasicReference`1", "VisualBasicValue`1",  "InvokeMethod`1" };

                        var wfToolboxCategory = new ToolboxCategory(activityLibrary.GetName().Name);
                        var actvities         = from
                                                activityType in activityLibrary.GetExportedTypes()
                                                where
                                                (activityType.IsSubclassOf(typeof(Activity)) ||
                                                 activityType.IsSubclassOf(typeof(NativeActivity)) ||
                                                 activityType.IsSubclassOf(typeof(DynamicActivity)) ||
                                                 activityType.IsSubclassOf(typeof(ActivityWithResult)) ||
                                                 activityType.IsSubclassOf(typeof(AsyncCodeActivity)) ||
                                                 activityType.IsSubclassOf(typeof(CodeActivity)) ||
                                                 activityType.GetInterfaces().Contains(typeof(IActivityTemplateFactory))
                                                ) &&
                                                activityType.IsVisible &&
                                                activityType.IsPublic &&
                                                !activityType.IsNested &&
                                                !activityType.IsAbstract &&
                                                (activityType.GetConstructor(Type.EmptyTypes) != null) &&
                                                !excludeActivities.Contains(activityType.Name) &&
                                                !activityType.Name.StartsWith("InvokeAction`") &&
                                                !activityType.Name.StartsWith("InvokeFunc`") &&
                                                !activityType.Name.StartsWith("Subtract`") &&
                                                !activityType.Name.StartsWith("GreaterThan`") &&
                                                !activityType.Name.StartsWith("GreaterThanOrEqual`") &&
                                                !activityType.Name.StartsWith("LessThan`") &&
                                                !activityType.Name.StartsWith("LessThanOrEqual`") &&
                                                !activityType.Name.StartsWith("Literal`") &&
                                                !activityType.Name.StartsWith("MultidimensionalArrayItemReference`") &&
                                                !activityType.Name.StartsWith("Multiply`") &&
                                                !activityType.Name.StartsWith("New`") &&
                                                !activityType.Name.StartsWith("NewArray`") &&
                                                !activityType.Name.StartsWith("Or`") &&
                                                !activityType.Name.StartsWith("OrElse") &&
                                                !activityType.Name.EndsWith("`2") &&
                                                !activityType.Name.EndsWith("`3")
                                                orderby
                                                activityType.Name
                                                select
                                                new ToolboxItemWrapper(activityType, activityType.Name.Replace("`1", ""));
                        actvities.ToList().ForEach(wfToolboxCategory.Add);

                        if (wfToolboxCategory.Tools.Count > 0)
                        {
                            Toolbox.Categories.Add(wfToolboxCategory);
                            activitiesCount += wfToolboxCategory.Tools.Count;
                            //if(wfToolboxCategory.CategoryName == "System.Activities")
                            //{
                            //    wfToolboxCategory.Tools.Add(new ToolboxItemWrapper(typeof(System.Activities.Core.Presentation.Factories.ForEachWithBodyFactory<>), "ForEach"));
                            //    wfToolboxCategory.Tools.Add(new ToolboxItemWrapper(typeof(System.Activities.Core.Presentation.Factories.ParallelForEachWithBodyFactory<>), "ParallelForEach"));
                            //}
                        }
                    }
                    catch (Exception)
                    {
                    }
                }
                return(Toolbox);
            }
            catch (Exception ex)
            {
                Log.Error(ex, "");
                MessageBox.Show("InitializeActivitiesToolbox: " + ex.Message);
                return(null);
            }
        }
Пример #23
0
        /// <summary>
        /// Retrieves all Workflow Activities from the loaded assemblies and inserts them into a ToolboxControl
        /// </summary>
        private void InitializeActivitiesToolbox()
        {
            try
            {
                _wfToolbox = new ToolboxControl();

                // Create a category.
                var stateMachineCategory = new ToolboxCategory("StateMachine");

                // Create Toolbox items.
                var tool1 = new ToolboxItemWrapper("System.Activities.Statements.StateMachine",
                                                   typeof(StateMachine).Assembly.FullName, null, "StateMachine");

                var tool2 = new ToolboxItemWrapper("System.Activities.Statements.State",
                                                   typeof(State).Assembly.FullName, null, "State");

                var tool3 = new ToolboxItemWrapper("System.Activities.Core.Presentation.FinalState",
                                                   typeof(FinalState).Assembly.FullName, null, "FinalState");

                // Add the Toolbox items to the category.
                stateMachineCategory.Add(tool1);
                stateMachineCategory.Add(tool2);
                stateMachineCategory.Add(tool3);

                // Create a category.
                var primitiveCategory = new ToolboxCategory("Primitive");

                // Create Toolbox items.
                var pTool1 = new ToolboxItemWrapper("System.Activities.Statements.Assign",
                                                    typeof(Assign).Assembly.FullName, null, "Assign");

                var pTool2 = new ToolboxItemWrapper("System.Activities.Statements.Delay",
                                                    typeof(Delay).Assembly.FullName, null, "Delay");

                var pTool3 = new ToolboxItemWrapper("ActivityLibrary.Wait",
                                                    typeof(ActivityLibrary.Wait).Assembly.FullName, null, "Wait");

                var pTool4 = new ToolboxItemWrapper("ActivityLibrary.WaitFor",
                                                    typeof(ActivityLibrary.WaitFor).Assembly.FullName, null, "WaitFor");

                var pTool5 = new ToolboxItemWrapper("System.Activities.Statements.If",
                                                    typeof(If).Assembly.FullName, null, "If");

                //var pTool5 = new ToolboxItemWrapper("System.Activities.Statements.WriteLine",
                //    typeof(WriteLine).Assembly.FullName, null, "WriteLine");

                // Add the Toolbox items to the category.
                primitiveCategory.Add(pTool1);
                primitiveCategory.Add(pTool2);
                primitiveCategory.Add(pTool3);
                primitiveCategory.Add(pTool4);
                primitiveCategory.Add(pTool5);

                // Add the category to the ToolBox control.
                _wfToolbox.Categories.Add(stateMachineCategory);
                _wfToolbox.Categories.Add(primitiveCategory);

                WfToolboxBorder.Child = _wfToolbox;
            }
            catch (Exception ex)
            {
                MessageBox.Show(ex.Message);
            }
        }