// Get the filled Toolbox
        public static ToolboxControl GetToolboxControl()
        {
            // Create the ToolBoxControl.
            ToolboxControl ctrl = new ToolboxControl();

            foreach (var item in _source)
            {
                ctrl.Categories.Add(item);
            }

            // 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;
        }
 public void Add(ToolboxItemWrapper tool)
 {
     if (null == tool)
     {
         throw FxTrace.Exception.ArgumentNull("tool");
     }
     this.tools.Add(tool);
 }
Example #3
0
 public bool Remove(ToolboxItemWrapper tool)
 {
     if (null == tool)
     {
         throw FxTrace.Exception.ArgumentNull("tool");
     }
     return(this.tools.Remove(tool));
 }
 public bool Remove(ToolboxItemWrapper tool)
 {
     if (null == tool)
     {
         throw FxTrace.Exception.ArgumentNull("tool");
     }
     return this.tools.Remove(tool);
 }
Example #5
0
 public void Add(ToolboxItemWrapper tool)
 {
     if (null == tool)
     {
         throw FxTrace.Exception.ArgumentNull("tool");
     }
     this.tools.Add(tool);
 }
 bool TryGetSelectedToolboxItem(out ToolboxItem toolboxItem, out ToolboxItemWrapper toolboxItemWrapper)
 {
     toolboxItem        = null;
     toolboxItemWrapper = null;
     if (null != this.toolsTreeView && null != this.toolsTreeView.SelectedItem)
     {
         ToolboxItemWrapper tool = this.toolsTreeView.SelectedItem as ToolboxItemWrapper;
         if (null != tool && null != tool.ToolboxItem)
         {
             toolboxItem        = tool.ToolboxItem;
             toolboxItemWrapper = tool;
         }
     }
     return(null != toolboxItem);
 }
 void OnToolPropertyChanged(object sender, PropertyChangedEventArgs e)
 {
     try
     {
         ToolboxItemWrapper tool = (ToolboxItemWrapper)sender;
         tool.ResolveToolboxItem();
     }
     catch
     {
         if (!DesignerProperties.GetIsInDesignMode(this))
         {
             throw;
         }
     }
 }
        private ToolboxCategory CreateToolboxCategory(String categoryName, List<Type> activities, Boolean isStandard)
        {
            ToolboxCategory toolboxCategory = new ToolboxCategory(categoryName);

            foreach (Type activity in activities)
            {
                if (!loadedToolboxActivities.Contains(activity))
                {
                    //Cleanup the name of generic activities
                    String name;
                    String[] nameChunks = activity.Name.Split('`');
                    if (nameChunks.Length == 1)
                    {
                        name = activity.Name;
                    }
                    else
                    {
                        name = String.Format("{0}<>", nameChunks[0]);
                    }

                    //ToolboxImagesPath
                    string iconName = Properties.Settings.Default.ToolboxImagesPath + name + ".png"; ;
                    ToolboxItemWrapper tiw =
                      new ToolboxItemWrapper(activity.FullName, activity.Assembly.FullName, iconName, name);

                    toolboxCategory.Add(tiw);

                    if (isStandard)
                    {
                        loadedToolboxActivities.Add(activity);
                    }
                }
            }

            return toolboxCategory;
        }
Example #9
0
        public static ToolboxCategoryItems loadTemplatebox()
        {
            MySQLConnection DBConn = new MySQLConnection(new MySQLConnectionString(Configuration.getDBIp(), "template", Configuration.getDBUsername(), Configuration.getDBPassword()).AsString);
            if (DBConn != null)
            {
                try
                {
                    DBConn.Open();
                    string sql = "select * from template";
                    MySQLDataAdapter mda = new MySQLDataAdapter(sql, DBConn);
                    MySQLCommand mcd = new MySQLCommand(sql, DBConn);
                    mcd.ExecuteNonQuery();
                    DataTable TemplateDataTable = new DataTable();
                    mda.Fill(TemplateDataTable);
                    DBConn.Close();
                    loadSystemIcon();

                    ToolboxCategoryItems toolboxCategoryItems = new ToolboxCategoryItems();
                    ToolboxCategory templates = new System.Activities.Presentation.Toolbox.ToolboxCategory("表单模板");

                    foreach (DataRow dr in TemplateDataTable.Rows)
                    {
                        ToolboxItemWrapper Template = new ToolboxItemWrapper(typeof(Wxwinter.BPM.WFDesigner.Template), dr["NAME"].ToString());
                        templates.Add(Template);
                    }
                    toolboxCategoryItems.Add(templates);
                    parentWindow.statusInfo.Text = "";
                    return toolboxCategoryItems;
                }
                catch (Exception e)
                {
                    parentWindow.statusInfo.Text = "数据库连接失败,请检查网络设置和数据库连接配置";
                    return null;
                }
                
            }
            else
            {
                return null;
            }
        }
Example #10
0
        public static ToolboxCategoryItems loadToolbox()
        {
            loadSystemIcon();

            ToolboxCategoryItems toolboxCategoryItems = new ToolboxCategoryItems();

            //流程图
   /*         ToolboxItemWrapper flowchar = new ToolboxItemWrapper(typeof(System.Activities.Statements.Flowchart), "Flowchart");
            ToolboxItemWrapper flowDecision = new ToolboxItemWrapper(typeof(System.Activities.Statements.FlowDecision), "FlowDecision");
            ToolboxItemWrapper flowSwitch = new ToolboxItemWrapper(typeof(System.Activities.Statements.FlowSwitch<string>), "FlowSwitch");
            
            ToolboxCategory wf4Flowchar = new System.Activities.Presentation.Toolbox.ToolboxCategory("流程图");

            wf4Flowchar.Add(flowchar);
            wf4Flowchar.Add(flowDecision);
            wf4Flowchar.Add(flowSwitch);

            toolboxCategoryItems.Add(wf4Flowchar);

            //状态机

            ToolboxItemWrapper stateMachineWithInitialStateFactory = new ToolboxItemWrapper(typeof(Wxwinter.BPM.Machine.Design.ToolboxItems.StateMachineWithInitialStateFactory), "状态机流程");
            ToolboxItemWrapper state = new ToolboxItemWrapper(typeof(Wxwinter.BPM.Machine.State), "节点");
            ToolboxCategory stateMachineActivity = new System.Activities.Presentation.Toolbox.ToolboxCategory("状态机");

            stateMachineActivity.Add(stateMachineWithInitialStateFactory);
            stateMachineActivity.Add(state);

            */



            //WF4.0 Activity
            
            ToolboxItemWrapper writeLine = new ToolboxItemWrapper(typeof(System.Activities.Statements.WriteLine), "控制台输出");
            ToolboxItemWrapper sequence = new ToolboxItemWrapper(typeof(System.Activities.Statements.Sequence), "Sequence");
            ToolboxItemWrapper Assign = new ToolboxItemWrapper(typeof(System.Activities.Statements.Assign), "Assign");
            ToolboxItemWrapper Delay = new ToolboxItemWrapper(typeof(System.Activities.Statements.Delay), "Delay");
            ToolboxItemWrapper If = new ToolboxItemWrapper(typeof(System.Activities.Statements.If), "If");
            ToolboxItemWrapper ForEach = new ToolboxItemWrapper(typeof(System.Activities.Statements.ForEach<string>), "ForEach");
            ToolboxItemWrapper Switch = new ToolboxItemWrapper(typeof(System.Activities.Statements.Switch<string>), "Switch");
            ToolboxItemWrapper While = new ToolboxItemWrapper(typeof(System.Activities.Statements.While), "While");
            ToolboxItemWrapper DoWhile = new ToolboxItemWrapper(typeof(System.Activities.Statements.DoWhile), "DoWhile");
            ToolboxItemWrapper Parallel = new ToolboxItemWrapper(typeof(System.Activities.Statements.Parallel), "Parallel");
            ToolboxItemWrapper Pick = new ToolboxItemWrapper(typeof(System.Activities.Statements.Pick), "Pick");
            ToolboxItemWrapper PickBranch = new ToolboxItemWrapper(typeof(System.Activities.Statements.PickBranch), "PickBranch");


            ToolboxCategory wf4Activity = new System.Activities.Presentation.Toolbox.ToolboxCategory("Activity");
            
            wf4Activity.Add(writeLine);
            wf4Activity.Add(sequence);
            wf4Activity.Add(Assign);
            wf4Activity.Add(Delay);
            wf4Activity.Add(If);
            wf4Activity.Add(ForEach);
            wf4Activity.Add(Switch);
            wf4Activity.Add(While);
            wf4Activity.Add(DoWhile);
            wf4Activity.Add(Parallel);
            wf4Activity.Add(Pick);
            wf4Activity.Add(PickBranch);

            //toolboxCategoryItems.Add(wf4Activity);
           
            ToolboxItemWrapper CustomParallel = new ToolboxItemWrapper(typeof(Wxwinter.BPM.WFDesigner.CustomActivities.ParallelActivity), "并行活动");
            ToolboxItemWrapper CustomSequence = new ToolboxItemWrapper(typeof(Wxwinter.BPM.WFDesigner.CustomActivities.SequenceActivity), "串行活动");
            ToolboxItemWrapper CustomIf = new ToolboxItemWrapper(typeof(Wxwinter.BPM.WFDesigner.CustomActivities.IfActivity), "If活动");
            ToolboxItemWrapper CustomWhile = new ToolboxItemWrapper(typeof(Wxwinter.BPM.WFDesigner.CustomActivities.WhileActivity), "While循环活动");
            ToolboxItemWrapper CustomException = new ToolboxItemWrapper(typeof(Wxwinter.BPM.WFDesigner.CustomActivities.ExceptionActivity), "异常处理");
            ToolboxItemWrapper CustomEquivalent = new ToolboxItemWrapper(typeof(Wxwinter.BPM.WFDesigner.CustomActivities.Equivalent), "等价替换");
            
            ToolboxCategory CustomActivities = new System.Activities.Presentation.Toolbox.ToolboxCategory("自定义设计器");
            
            CustomActivities.Add(CustomParallel);
            CustomActivities.Add(CustomSequence);
           //CustomActivities.Add(CustomWhile);
           CustomActivities.Add(CustomIf);
           //CustomActivities.Add(CustomException);
           //CustomActivities.Add(CustomEquivalent);

       

            ToolboxItemWrapper 发起审核活动 = new ToolboxItemWrapper(typeof(Wxwinter.BPM.WFDesigner.发起审核活动), "表单流转活动");
         
            ToolboxItemWrapper Template = new ToolboxItemWrapper(typeof(Wxwinter.BPM.WFDesigner.Template), "流转表单模板");
            ToolboxItemWrapper Participant = new ToolboxItemWrapper(typeof(Wxwinter.BPM.WFDesigner.User), "参与者");
            ToolboxItemWrapper EndNode = new ToolboxItemWrapper(typeof(Wxwinter.BPM.WFDesigner.EndNode), "结束节点");
            

            CustomActivities.Add(发起审核活动);
            CustomActivities.Add(Template);
            CustomActivities.Add(Participant);
            CustomActivities.Add(EndNode);
            toolboxCategoryItems.Add(CustomActivities);


            return toolboxCategoryItems;

        }
Example #11
0
        public static ToolboxCategoryItems loadUserbox()
        {
            MySQLConnection DBConn = new MySQLConnection(new MySQLConnectionString(Configuration.getDBIp(), "workflow", Configuration.getDBUsername(), Configuration.getDBPassword()).AsString);
            if (DBConn != null)
            {
                try
                {
                    DBConn.Open();
                    string sql1 = "set names gb2312";
                    MySQLCommand DBComm = new MySQLCommand(sql1, DBConn); //設定下達 command
                    DBComm.ExecuteNonQuery();
                    DBComm.Dispose();
                    string sql = "select * from tb_user";
                    MySQLDataAdapter mda = new MySQLDataAdapter(sql, DBConn);
                    DataTable UserDataTable = new DataTable();
                    mda.Fill(UserDataTable);
                    DBConn.Close();
                    loadSystemIcon();

                    ToolboxCategoryItems toolboxCategoryItems = new ToolboxCategoryItems();
                    ToolboxCategory users = new System.Activities.Presentation.Toolbox.ToolboxCategory("系统工作人员");

                    foreach (DataRow dr in UserDataTable.Rows)
                    {
                        //byte[] temp = Encoding.Default.GetBytes(dr["User_Name"].ToString());
                        //temp = System.Text.Encoding.Convert(Encoding.GetEncoding("utf8"), Encoding.GetEncoding("gb2312"), temp);
                        //string username = Encoding.Default.GetString(temp);
                        //ToolboxItemWrapper User = new ToolboxItemWrapper(typeof(Wxwinter.BPM.WFDesigner.User), username);
                        ToolboxItemWrapper User = new ToolboxItemWrapper(typeof(Wxwinter.BPM.WFDesigner.User), dr["User_Name"].ToString());
                        users.Add(User);
                    }
                    toolboxCategoryItems.Add(users);
                    parentWindow.statusInfo.Text = "";
                    return toolboxCategoryItems;
                }
                catch (Exception e)
                {
                    parentWindow.statusInfo.Text = "数据库连接失败,请检查网络设置和数据库连接配置";
                    return null;
                }

            }
            else
            {
                return null;
            }
        }
        bool TryGetSelectedToolboxItem(out ToolboxItem toolboxItem, out ToolboxItemWrapper toolboxItemWrapper)
        {
            toolboxItem = null;
            toolboxItemWrapper = null;
            if (null != this.toolsTreeView && null != this.toolsTreeView.SelectedItem)
            {
                ToolboxItemWrapper tool = this.toolsTreeView.SelectedItem as ToolboxItemWrapper;
                if (null != tool && null != tool.ToolboxItem)
                {
                    toolboxItem = tool.ToolboxItem;
                    toolboxItemWrapper = tool;

                }
            }
            return (null != toolboxItem);
        }
Example #13
0
        private static bool CreateTaskActivityToolbox(ICollection<ToolboxCategory> toolboxCategories)
        {
            bool isToolboxInitialized = false;
            Type taskType = typeof(TaskActivity);
            ToolboxCategory taskToolboxCategory = new ToolboxCategory("Multipe Author");

            string tooltip = string.Format("{0} {1}", "TaskActivity", "v1.0.0.0");
            if (!ActivityTypeToToolTipConverter.ToolTipDictionary.ContainsKey(taskType))
            {
                ActivityTypeToToolTipConverter.ToolTipDictionary.Add(taskType, tooltip);
                ToolboxItemWrapper taskToolboxItemWrapper = new ToolboxItemWrapper(taskType, "TaskActivity");
                taskToolboxCategory.Add(taskToolboxItemWrapper);
                toolboxCategories.Add(taskToolboxCategory);
            }

            isToolboxInitialized = true;
            return isToolboxInitialized;
        }
Example #14
0
        private ToolboxControl GetToolboxControl()
        {
            // Create the ToolBoxControl.
            ToolboxControl ctrl = new ToolboxControl();

            // Create a category.
            ToolboxCategory category = new ToolboxCategory("Available");
            ToolboxCategory category2 = new ToolboxCategory("Custom");
            // 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");

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

            ToolboxItemWrapper tool4 = new ToolboxItemWrapper("ConDep.activities.CopyFileActivity",
                typeof(CopyFileActivity).Assembly.FullName, null, "CopyFile");

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

            // Add the category to the ToolBox control.
            ctrl.Categories.Add(category);
            ctrl.Categories.Add(category2);
            return ctrl;
        }
        private void LoadDefaultActivities(ToolboxControl tbc)
        {
            var dict = new ResourceDictionary
            {
                Source =
                    new Uri(
                        "pack://application:,,,/System.Activities.Presentation;component/themes/icons.xaml")
            };
            Resources.MergedDictionaries.Add(dict);

            var standtypes = typeof (Activity).Assembly.GetTypes().
                Where(t => (typeof (Activity).IsAssignableFrom(t) ||
                            typeof (IActivityTemplateFactory)
                                .IsAssignableFrom(t)) && !t.IsAbstract &&
                           t.IsPublic &&
                           !t.IsNested && HasDefaultConstructor(t));

            var primary = new ToolboxCategory("Native Activities");

            foreach (var type in standtypes.OrderBy(t => t.Name))
            {
                var w = new ToolboxItemWrapper(type, ToGenericTypeString(type));
                if (!AddIcon(type, _builder))
                {
                    primary.Add(w);
                }
                //else
                //{
                //    //secondary.Add(w);
                //}
            }

            MetadataStore.AddAttributeTable(_builder.CreateTable());
            tbc.Categories.Add(primary);
        }
        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);
        }
Example #17
0
        public static ToolboxCategoryItems loadToolbox()
        {
            loadSystemIcon();

            ToolboxCategoryItems toolboxCategoryItems = new ToolboxCategoryItems();

            //流程图
            ToolboxItemWrapper flowchar = new ToolboxItemWrapper(typeof(System.Activities.Statements.Flowchart), "Flowchart");
            ToolboxItemWrapper flowDecision = new ToolboxItemWrapper(typeof(System.Activities.Statements.FlowDecision), "FlowDecision");
            ToolboxItemWrapper flowSwitch = new ToolboxItemWrapper(typeof(System.Activities.Statements.FlowSwitch<string>), "FlowSwitch");

            ToolboxCategory wf4Flowchar = new System.Activities.Presentation.Toolbox.ToolboxCategory("流程图");

            wf4Flowchar.Add(flowchar);
            wf4Flowchar.Add(flowDecision);
            wf4Flowchar.Add(flowSwitch);

            toolboxCategoryItems.Add(wf4Flowchar);

            //状态机

            ToolboxItemWrapper stateMachineWithInitialStateFactory = new ToolboxItemWrapper(typeof(Machine.Design.ToolboxItems.StateMachineWithInitialStateFactory), "状态机流程");
            ToolboxItemWrapper state = new ToolboxItemWrapper(typeof(Machine.State), "节点");
            ToolboxCategory stateMachineActivity = new System.Activities.Presentation.Toolbox.ToolboxCategory("状态机");

            stateMachineActivity.Add(stateMachineWithInitialStateFactory);
            stateMachineActivity.Add(state);

            toolboxCategoryItems.Add(stateMachineActivity);

            //WF4.0 Activity
            ToolboxItemWrapper writeLine = new ToolboxItemWrapper(typeof(System.Activities.Statements.WriteLine), "WriteLine");
            ToolboxItemWrapper sequence = new ToolboxItemWrapper(typeof(System.Activities.Statements.Sequence), "Sequence");
            ToolboxItemWrapper Assign = new ToolboxItemWrapper(typeof(System.Activities.Statements.Assign), "Assign");
            ToolboxItemWrapper Delay = new ToolboxItemWrapper(typeof(System.Activities.Statements.Delay), "Delay");
            ToolboxItemWrapper If = new ToolboxItemWrapper(typeof(System.Activities.Statements.If), "If");
            ToolboxItemWrapper ForEach = new ToolboxItemWrapper(typeof(System.Activities.Statements.ForEach<string>), "ForEach");
            ToolboxItemWrapper Switch = new ToolboxItemWrapper(typeof(System.Activities.Statements.Switch<string>), "Switch");
            ToolboxItemWrapper While = new ToolboxItemWrapper(typeof(System.Activities.Statements.While), "While");
            ToolboxItemWrapper DoWhile = new ToolboxItemWrapper(typeof(System.Activities.Statements.DoWhile), "DoWhile");
            ToolboxItemWrapper Parallel = new ToolboxItemWrapper(typeof(System.Activities.Statements.Parallel), "Parallel");
            ToolboxItemWrapper Pick = new ToolboxItemWrapper(typeof(System.Activities.Statements.Pick), "Pick");
            ToolboxItemWrapper PickBranch = new ToolboxItemWrapper(typeof(System.Activities.Statements.PickBranch), "PickBranch");

            ToolboxCategory wf4Activity = new System.Activities.Presentation.Toolbox.ToolboxCategory("Activity");

            wf4Activity.Add(writeLine);
            wf4Activity.Add(sequence);
            wf4Activity.Add(Assign);
            wf4Activity.Add(Delay);
            wf4Activity.Add(If);
            wf4Activity.Add(ForEach);
            wf4Activity.Add(Switch);
            wf4Activity.Add(While);
            wf4Activity.Add(DoWhile);
            wf4Activity.Add(Parallel);
            wf4Activity.Add(Pick);
            wf4Activity.Add(PickBranch);

            toolboxCategoryItems.Add(wf4Activity);

            //文档活动
            //ToolboxItemWrapper StartActivity = new ToolboxItemWrapper(typeof(StartActivity), "开始活动");
            ToolboxItemWrapper DocActivity = new ToolboxItemWrapper(typeof(DocActivity), "文档审批");
            ToolboxItemWrapper EndActivity = new ToolboxItemWrapper(typeof(EndActivity), "结束活动");
            ToolboxCategory DocActivitys = new System.Activities.Presentation.Toolbox.ToolboxCategory("文档活动");
            //DocActivitys.Add(StartActivity);
            DocActivitys.Add(DocActivity);
            DocActivitys.Add(EndActivity);

            toolboxCategoryItems.Add(DocActivitys);

            return toolboxCategoryItems;
        }
Example #18
0
        /// <summary>
        /// The initialize user activities toolbox.
        ///  Include the Favorite toolbox
        /// </summary>
        private static bool CreateUserActivitiesToolbox(IEnumerable<ActivityAssemblyItem> activityAssemblyItems, ICollection<ToolboxCategory> toolboxCategories)
        {
            var errorMessage = new StringBuilder();
            string fullActivityLibraryName = null;
            var isToolboxInitialized = false;
            var allCachedAssemblies = new List<Assembly>();

            // Load all local assemblies
            foreach (ActivityAssemblyItem assemblyItem in activityAssemblyItems)
            {
                // See if we even NEED to load this Activity Assembly
                if (assemblyItem.ActivityItems.All(assemblyItem1 => !assemblyItem1.UserSelected))
                {
                    // None of the Activities are marked as Selected then we skip loading this assembly
                    continue;
                }

                if (assemblyItem.Assembly == null)
                {
                    continue; // Caching is still busy refreshing assemblies. ToolboxControlService will be called again after refresh finishes.
                }

                // Get the FullName of the Activity Assembly
                fullActivityLibraryName = assemblyItem.AssemblyName.FullName;

                // Load the Referenced non .NET Assemblies
                var loadedAssembly = assemblyItem.Assembly;

                // Add the Assembly to the Cached assemblies
                allCachedAssemblies.Add(loadedAssembly);

                // Register designer metadata. If you don't do this, the design
                RegisterMetadtaInAssembly(assemblyItem);
            }
            // Load all cached ActivityItems
            var allCachedActivityItems = new List<ActivityItem>();

            foreach (ActivityAssemblyItem item in activityAssemblyItems)
            {
                if (item.UserSelected == false)
                {
                    continue;
                }

                IEnumerable<ActivityItem> userSelectedActivityItems = item.ActivityItems.Where(ai => ai.UserSelected);
                allCachedActivityItems.AddRange(userSelectedActivityItems);
            }

            var groups = allCachedActivityItems.GroupBy(ai => ai.Category).OrderBy(group => group.Key);

            // Generate toolbox categories
            ActivityTypeToToolTipConverter.ToolTipDictionary.Clear();

            var favoriteToolboxCategory = new ToolboxCategory("Favorite");
            toolboxCategories.Add(favoriteToolboxCategory);
            foreach (var group in groups)
            {
                var userToolboxCategory = new ToolboxCategory(group.Key);

                foreach (ActivityItem activityItem in group.OrderBy(act => act.Name))
                {
                    var parent = activityAssemblyItems.First(aai => aai.Matches(activityItem.ParentAssemblyName));
                    if (parent.Assembly == null)
                        continue;
                    var hostAssembly = parent.Assembly;
                    var activityType = hostAssembly.GetType(activityItem.FullName);

                    if (null == activityType || activityType.IsVisible == false)
                    {
                        continue;
                    }
                    // Make sure we check the dictionary to avoid inserting duplicate keys which throws an exception
                    if (!ActivityTypeToToolTipConverter.ToolTipDictionary.ContainsKey(activityType))
                    {
                        string versionString = parent.AssemblyName.Version == null
                            ? "No version"
                            : string.Format("v{0}", parent.Version);
                        var tooltip = string.IsNullOrWhiteSpace(activityItem.Description)
                            ? string.Format("{0}", versionString)
                            : string.Format("{0}, {1}", versionString, activityItem.Description);
                        ActivityTypeToToolTipConverter.ToolTipDictionary.Add(activityType, tooltip);
                        // TODO - We need to distinguish between Activity Libraries.
                        var userToolboxItemWrapper = new ToolboxItemWrapper(activityType, GetDisplayName(activityItem, activityType));
                        // AppDomain.CurrentDomain.AssemblyResolve event will be triggered here.
                        userToolboxCategory.Add(userToolboxItemWrapper);
                    }

                    if (activityItem.IsUserFavorite)
                    {
                        var favoriteToolboxItemWrapper = new ToolboxItemWrapper(activityType, GetDisplayName(activityItem, activityType));
                        favoriteToolboxCategory.Add(favoriteToolboxItemWrapper);
                    }
                }

                if (userToolboxCategory.Tools.Count > 0)
                {
                    toolboxCategories.Add(userToolboxCategory);
                }

            }

            isToolboxInitialized = true;

            return isToolboxInitialized;
        }
 private ToolboxCategory CreateToolboxCategory(String categoryName, List<Type> activities, Boolean isStandard)
 {
     ToolboxCategory tc = new ToolboxCategory(categoryName);
     foreach (Type activity in activities)
     {
         if (!loadedToolboxActivities.Contains(activity))
         {
             //cleanup the name of generic activities
             String name;
             String[] nameChunks = activity.Name.Split('`');
             if (nameChunks.Length == 1)
             {
                 name = activity.Name;
             }
             else
             {
                 name = String.Format("{0}<>", nameChunks[0]);
             }
             ToolboxItemWrapper tiw = new ToolboxItemWrapper(
             activity.FullName, activity.Assembly.FullName,
             null, name);
             tc.Add(tiw);
             if (isStandard)
             {
                 loadedToolboxActivities.Add(activity);
             }
         }
     }
     return tc;
 }
        private ToolboxControl GetToolboxControl()
        {
            var toolBoxControl = new ToolboxControl();

            var toolBoxCategory = new ToolboxCategory("Http Requests");

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

            //var ifActivity = new ToolboxItemWrapper("System.Activities.Statements.If",
            //    typeof(If).Assembly.FullName, null, "If-Else");

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

            var httpRequestActivity = new ToolboxItemWrapper("RestBox.Activities.HttpRequestActivityModel",
                typeof(HttpRequestActivityModel).Assembly.FullName, null, "Http Request");

            var httpRequestIfElseActivity = new ToolboxItemWrapper("RestBox.Activities.HttpRequestIfElseActivityModel",
                typeof(HttpRequestIfElseActivityModel).Assembly.FullName, null, "Decision");

            var retryUntilActivity = new ToolboxItemWrapper("RestBox.Activities.RetryUntilActivityModel",
                typeof(RetryUntilActivityModel).Assembly.FullName, null, "Retry Until");

            toolBoxCategory.Add(sequenceActivity);
            //toolBoxCategory.Add(ifActivity);
            toolBoxCategory.Add(httpRequestActivity);
            toolBoxCategory.Add(httpRequestIfElseActivity);
            toolBoxCategory.Add(retryUntilActivity);
            //toolBoxCategory.Add(parallelActivity);

            toolBoxControl.Categories.Add(toolBoxCategory);
            return toolBoxControl;
        }