// 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 LoadToolboxItems(string fileName, ToolboxCategoryItems container, bool resetContainer) { if (string.IsNullOrEmpty(fileName)) { throw FxTrace.Exception.AsError(new ArgumentNullException("fileName")); } if (null == container) { throw FxTrace.Exception.AsError(new ArgumentNullException("container")); } if (resetContainer) { container.Clear(); } using (StreamReader reader = File.OpenText(fileName)) { string entry = null; ToolboxCategory category = null; while (null != (entry = reader.ReadLine())) { entry = entry.Trim(); if (entry.Length > 1 && (entry[0] != ';' && entry[0] != '#')) { if (entry.StartsWith("[", StringComparison.CurrentCulture) && entry.EndsWith("]", StringComparison.CurrentCulture)) { string categoryName = entry.Substring(1, entry.Length - 2); category = GetCategoryItem(container, categoryName); } else { if (null == category) { category = GetCategoryItem(container, DefaultCategory); } string[] toolDefinition = entry.Split(';'); string toolName = null; string assembly = null; string displayName = null; string bitmap = null; if (GetToolAssemblyAndName(toolDefinition, ref toolName, ref assembly)) { GetBitmap(toolDefinition, ref bitmap); GetDisplayName(toolDefinition, ref displayName); category.Add(new ToolboxItemWrapper(toolName, assembly, bitmap, displayName)); } else { throw FxTrace.Exception.AsError(new ArgumentOutOfRangeException(FormatExceptionText)); } } } } } }
private ToolboxControl CreateToolbox() { ToolboxControl toolBox = new ToolboxControl(); Dictionary<String, List<Type>> activitiesToInclude = new Dictionary<String, List<Type>>(); activitiesToInclude.Add("Essential", new List<Type> { typeof(Sequence), typeof(If), typeof(Assign), typeof(While), typeof(DoWhile) }); activitiesToInclude.Add("OData Feed", new List<Type> { typeof(Microsoft.Samples.SqlServer.Activities.QueryFeed), typeof(Microsoft.Samples.SqlServer.Activities.EntityProperties), typeof(Microsoft.Samples.SqlServer.Activities.Filter), typeof(WriteLine) }); activitiesToInclude.Add("Publishers", new List<Type> { typeof(Microsoft.Samples.SqlServer.Activities.ActivityPublishers.TablePartPublisher) }); activitiesToInclude.Add("Flowchart", new List<Type> { typeof(Flowchart), typeof(FlowDecision), typeof(FlowSwitch<>) }); foreach (var category in activitiesToInclude) { ToolboxCategory toolboxCategory = CreateToolboxCategory( category.Key, category.Value, true); toolBox.Categories.Add(toolboxCategory); if (toolboxCategory.CategoryName == "Flowchart") { flowchartCategory = toolboxCategory; foreach (var tool in toolboxCategory.Tools) { if (tool.Type == typeof(FlowDecision) || tool.Type == typeof(FlowSwitch<>)) { flowchartActivities.Add(tool); } } } } return toolBox; }
ToolboxCategory GetCategoryItem(ToolboxCategoryItems container, string categoryName) { foreach (ToolboxCategory category in container) { if (0 == string.Compare(category.CategoryName, categoryName, true, CultureInfo.CurrentUICulture)) { return(category); } } ToolboxCategory newCategory = new ToolboxCategory(categoryName); container.Add(newCategory); return(newCategory); }
public WorkflowItemsToolbox() { var toolbox = new ToolboxControl(); var controlElementsCategory = new ToolboxCategory(WorkflowItemsToolboxResources.TBCHeader) { new ToolboxItemWrapper("System.Activities.Statements.Assign", typeof (Assign).Assembly.FullName, null, WorkflowItemsToolboxResources.TBIAssignLabel), new ToolboxItemWrapper("System.Activities.Statements.DoWhile", typeof (DoWhile).Assembly.FullName, null, WorkflowItemsToolboxResources.TBIDoWhileLabel) }; toolbox.Categories.Add(controlElementsCategory); Content = toolbox; Title = WorkflowItemsToolboxResources.LATitle; }
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); } }
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); } }
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; } }
internal void Update(List<IClass> classes) { // Get the list of proejcts that need reloading. var projectContents = (from c in classes select c.ProjectContent).Distinct(); // Reload the assemblies and clear/create toolbox categories foreach(var pc in projectContents) { if (pc.Project != null) { var cp = (CompilableProject)pc.Project; var cat = Control.Categories.FirstOrDefault(ct => ct.CategoryName == cp.AssemblyName); if (cat == null) { cat = new ToolboxCategory(cp.AssemblyName); Control.Categories.Add(cat); } else { cat.Tools.Clear(); } Assembly asm = null; if (File.Exists(cp.OutputAssemblyFullPath)) { // Overwrite the assembly in the cache, we need to reload as we have rebuilt (memory will be used!). asm = Assembly.Load(File.ReadAllBytes(cp.OutputAssemblyFullPath)); if (asm != null) { var tbItems = from tbc in classes where tbc.ProjectContent.AssemblyName == asm.GetName().Name select tbc; foreach (var cl in tbItems) { var t = asm.GetType(cl.FullyQualifiedName); if (!cat.Tools.Any(ti => ti.Type == t)) cat.Add(new ToolboxItemWrapper(t, cl.Name)); } } } } } }
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; }
/// <summary> /// Create toolbox control from activity type list, wrap each activity type into a ToolboxItemWrapper. Group them into ToolboxCategory against ActivityItem.Category property. /// </summary> /// <param name="activityTypes"> /// The activity types. /// </param> /// <returns> /// The Toolbox control contains activity types input from parameter. /// </returns> private static ToolboxCategory CreateToolboxControlFromActivityTypeList(string categoryName, List<Type> activityTypes) { var toolboxCategory = new ToolboxCategory(categoryName); IOrderedEnumerable<ToolboxItemWrapper> wrappers = activityTypes.Select(activityType => new ToolboxItemWrapper(ReplaceWithActivityFactory(activityType), GetDisplayName(null, activityType))) .OrderBy(wrapper => wrapper.DisplayName); foreach (ToolboxItemWrapper wrapper in wrappers) { toolboxCategory.Add(wrapper); } return toolboxCategory; }
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; }
public static void AddCategory(ToolboxCategory cat) { _source.Add(cat); }
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); }
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; } }
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 ToolboxCategory GetToolboxCategory(string name) { if (this.toolboxCategoryMap.ContainsKey(name)) { return this.toolboxCategoryMap[name]; } else { ToolboxCategory category = new ToolboxCategory(name); this.toolboxCategoryMap[name] = category; this.loadedToolboxActivities.Add(category, new List<string>()); this.toolboxControl.Categories.Add(category); return category; } }
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 void CreateAutoAddedToolboxCategory(ToolboxCategory autoCat) { //add this category to the top of the list List<ToolboxCategory> categories = new List<ToolboxCategory>(); categories.Add(autoCat); categories.AddRange(toolboxControl.Categories); toolboxControl.Categories.Clear(); foreach (var cat in categories) { toolboxControl.Categories.Add(cat); } autoAddedCategory = autoCat; }
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; }
private ToolboxCategory GetCategory(string categoryName) { var cat = Categories .SingleOrDefault(c => c.CategoryName == categoryName); if (cat != null) { return cat; } cat = new ToolboxCategory(categoryName); Categories.Add(cat); return cat; }
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; }
/// <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); } }
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; }
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); }
/// <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 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 (cat.CategoryName == "Flowchart") { flowchartCategory = cat; foreach (var tool in cat.Tools) { if (tool.Type == typeof(FlowDecision) || tool.Type == typeof(FlowSwitch<>)) { flowchartActivities.Add(tool); } } } } return tb; }
private void InitialiseToolbox() { Control = new ToolboxControl(); AttributeTableBuilder builder = new AttributeTableBuilder(); foreach (Type type in typeof(System.Activities.Activity).Assembly.GetTypes().Where(t => t.Namespace == "System.Activities.Statements")) { CreateToolboxBitmapAttributeForActivity(builder, type); } foreach (Type type in typeof(System.ServiceModel.Activities.Receive).Assembly.GetTypes().Where(t => t.Namespace == "System.ServiceModel.Activities")) { CreateToolboxBitmapAttributeForActivity(builder, type); } foreach (Type type in typeof(System.ServiceModel.Activities.Presentation.Factories.ReceiveAndSendReplyFactory).Assembly.GetTypes().Where(t => t.Namespace == "System.ServiceModel.Activities.Presentation.Factories")) { CreateToolboxBitmapAttributeForActivity(builder, type); } foreach (Type type in typeof(System.Activities.Statements.Interop).Assembly.GetTypes().Where(t => t.Namespace == "System.Activities.Statements")) { CreateToolboxBitmapAttributeForActivity(builder, type); } MetadataStore.AddAttributeTable(builder.CreateTable()); var 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("Messaging"); cat.Add(new ToolboxItemWrapper(typeof(System.ServiceModel.Activities.CorrelationScope))); cat.Add(new ToolboxItemWrapper(typeof(System.ServiceModel.Activities.InitializeCorrelation))); cat.Add(new ToolboxItemWrapper(typeof(System.ServiceModel.Activities.Receive))); cat.Add(new ToolboxItemWrapper(typeof(System.ServiceModel.Activities.Presentation.Factories.ReceiveAndSendReplyFactory),"ReceiveAndSendReply")); cat.Add(new ToolboxItemWrapper(typeof(System.ServiceModel.Activities.Send))); cat.Add(new ToolboxItemWrapper(typeof(System.ServiceModel.Activities.Presentation.Factories.SendAndReceiveReplyFactory),"SendAndReceiveReply")); cat.Add(new ToolboxItemWrapper(typeof(System.ServiceModel.Activities.TransactedReceiveScope))); 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); cat = new ToolboxCategory("Migration"); cat.Add(new ToolboxItemWrapper(typeof(System.Activities.Statements.Interop))); Control.Categories.Add(cat); }
private void RemoveAutoAddedToolboxCategory() { if (autoAddedCategory != null) { toolboxControl.Categories.Remove(autoAddedCategory); autoAddedCategory = null; } }
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; }
ToolboxCategory GetCategoryItem(ToolboxCategoryItems container, string categoryName) { foreach (ToolboxCategory category in container) { if (0 == string.Compare(category.CategoryName, categoryName, true, CultureInfo.CurrentUICulture)) { return category; } } ToolboxCategory newCategory = new ToolboxCategory(categoryName); container.Add(newCategory); return newCategory; }
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); }