Ejemplo n.º 1
0
        /// <summary>
        /// Creates the predefined activities category.
        /// </summary>
        /// <returns></returns>
        /// <remarks></remarks>
        private ToolboxCategory CreatePredefinedActivitiesCategory()
        {
            Assembly assy = Assembly.GetAssembly(typeof(Sequence));
            var      cat  = new ToolboxCategory("Predefined Activities");

            Type[] types = assy
                           .GetTypes()
                           .Where(t => (t.IsSubclassOf(typeof(Activity)) && (!t.IsAbstract) && (!t.ContainsGenericParameters)))
                           .ToArray();

            foreach (var t in types)
            {
                try
                {
                    var inst = (Activity)Activator.CreateInstance(t);
                    if (t.IsVisible)
                    {
                        var wrp = new ToolboxItemWrapper(t, inst.DisplayName);

                        cat.Add(wrp);;
                    }
                }
                catch
                { }
            }
            ;
            return(cat);
        }
Ejemplo n.º 2
0
        public static ToolboxItemWrapper GetItemWrapper(this Type t, string name)
        {
            ToolboxItemWrapper tool3 =
                new ToolboxItemWrapper(t.FullName, t.Assembly.FullName, null, name);

            return(tool3);
        }
Ejemplo n.º 3
0
        private ToolboxControl GetToolboxControl()
        {
            // Create the ToolBoxControl.
            ToolboxControl ctrl = new ToolboxControl();

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

            // 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("System.Activities.Statements.WriteLine",
                                                              typeof(WriteLine).Assembly.FullName, null, "MessageBox");



            // Add the Toolbox items to the category.
            category.Add(tool1);
            category.Add(tool2);
            category.Add(tool3);
            // Add the category to the ToolBox control.
            ctrl.Categories.Add(category);
            return(ctrl);
        }
        // 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);
        }
Ejemplo n.º 5
0
        private static void CreateToolboxBitmapAttributeForActivity
            (AttributeTableBuilder builder, ToolboxItemWrapper builtInActivityType, IList <ResourceReader> resourceReaders)
        {
            Bitmap bitmap;

            foreach (var item in resourceReaders)
            {
                bitmap = ExtractBitmapResource(item, builtInActivityType.BitmapName);
                if (bitmap == null)
                {
                    continue;
                }
                SetBitmapResource(builder, builtInActivityType, bitmap);
                return;
            }

            foreach (var item in resourceReaders)
            {
                bitmap = ExtractBitmapResource(item, "Default");
                if (bitmap == null)
                {
                    continue;
                }
                SetBitmapResource(builder, builtInActivityType, bitmap);
                return;
            }
        }
Ejemplo n.º 6
0
        public object Convert(object value, Type targetType, object parameter, System.Globalization.CultureInfo culture)
        {
            ToolboxItemWrapper itemWrapper = (ToolboxItemWrapper)value;

            if (itemWrapper == null)
            {
                return(null);
            }
            if (itemWrapper.Type == null)
            {
                return(null);
            }
            // var attr = itemWrapper.Type.GetCustomAttribute<Interfaces.ToolboxTooltipAttribute>(false);
            var attr = OpenRPA.Interfaces.Extensions.GetMyCustomAttributes <ToolboxTooltipAttribute>(itemWrapper.Type, false).FirstOrDefault();

            //itemWrapper.Type. .GetMyCustomAttributes<Interfaces.ToolboxTooltipAttribute>(false);
            if (attr != null)
            {
                return(attr.Text);
            }
            if (ToolTipDic.ContainsKey(itemWrapper))
            {
                return(ToolTipDic[itemWrapper]);
            }
            else
            {
                return(null);
            }
        }
Ejemplo n.º 7
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);
        }
Ejemplo n.º 8
0
        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);
        }
Ejemplo n.º 9
0
        private static void SetBitmapResource(AttributeTableBuilder builder, ToolboxItemWrapper builtInActivityType, Bitmap bitmap)
        {
            var tbaType     = typeof(ToolboxBitmapAttribute);
            var imageType   = typeof(Image);
            var constructor = tbaType.GetConstructor(BindingFlags.Instance | BindingFlags.NonPublic, null, new[] { imageType, imageType }, null);
            var tba         = constructor.Invoke(new object[] { bitmap, bitmap }) as ToolboxBitmapAttribute;

            builder.AddCustomAttributes(Type.GetType(string.Format("{0}, {1}", builtInActivityType.ToolName, builtInActivityType.AssemblyName), true), tba);
        }
Ejemplo n.º 10
0
 private void AddCategoryToToolbox(string categoryName, Type activityType, string displayName)
 {
     if (this.IsValidToolboxActivity(activityType))
     {
         ToolboxCategory    category = this.GetToolboxCategory(categoryName);
         ToolboxItemWrapper toolbox  = new ToolboxItemWrapper(activityType.FullName, activityType.Assembly.FullName, null, displayName);
         toolbox.BitmapName = System.IO.Path.Combine(AppDomain.CurrentDomain.BaseDirectory, "Resources", displayName.Replace("<>", "") + ".png");
         category.Add(toolbox);
     }
 }
Ejemplo n.º 11
0
        private ToolboxControl GetToolboxControl()
        {
            ToolboxControl ctrl = new ToolboxControl();

            foreach (var categoryDefinition in CustomActivityDefinitions.Categories)
            {
                var category = new ToolboxCategory(categoryDefinition.Name);
                foreach (var toolDefinition in categoryDefinition.ActivityTypes)
                {
                    ToolboxItemWrapper tool;
                    if (string.IsNullOrEmpty(toolDefinition.DisplayName))
                    {
                        tool = new ToolboxItemWrapper(toolDefinition.ActivityType);
                    }
                    else
                    {
                        tool = new ToolboxItemWrapper(toolDefinition.ActivityType, toolDefinition.DisplayName);
                    }
                    category.Add(tool);
                }
                ctrl.Categories.Add(category);
            }

            foreach (var categoryDefinition in NativeActivityDefintions.Categories)
            {
                var category = new ToolboxCategory(categoryDefinition.Name);
                foreach (var toolDefinition in categoryDefinition.ActivityTypes)
                {
                    ToolboxItemWrapper tool;
                    if (string.IsNullOrEmpty(toolDefinition.DisplayName))
                    {
                        tool = new ToolboxItemWrapper(toolDefinition.ActivityType);
                    }
                    else
                    {
                        tool = new ToolboxItemWrapper(toolDefinition.ActivityType, toolDefinition.DisplayName);
                    }
                    category.Add(tool);
                }

                ctrl.Categories.Add(category);
            }

            //After converting the native activity icons to local resources, this is not needed anymore.  Keeping the code here because I know I'm going to want this as referenced code
            //Collapse all categories.  This speeds up loading significantly.
            //ctrl.CategoryItemStyle =
            //  new System.Windows.Style(typeof(TreeViewItem))
            //  {
            //    Setters = { new Setter(TreeViewItem.IsExpandedProperty, false) }
            //  };

            return(ctrl);
        }
Ejemplo n.º 12
0
        private ToolboxControl GetToolboxControl()
        {
            ToolboxControl     toolboxControl        = new ToolboxControl();
            ToolboxCategory    toolboxCategory       = new ToolboxCategory("Activities");
            ToolboxCategory    toolboxCategory_Loops = new ToolboxCategory("Loops");
            ToolboxItemWrapper sequence        = new ToolboxItemWrapper(typeof(Sequence));
            ToolboxItemWrapper writeLine       = new ToolboxItemWrapper(typeof(WriteLine));
            ToolboxItemWrapper Statemets_While = new ToolboxItemWrapper(typeof(While));

            toolboxCategory.Add(sequence);
            toolboxCategory.Add(writeLine);
            toolboxCategory_Loops.Add(Statemets_While);
            toolboxControl.Categories.Add(toolboxCategory);
            toolboxControl.Categories.Add(toolboxCategory_Loops);
            return(toolboxControl);
        }
Ejemplo n.º 13
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);
            }
        }
Ejemplo n.º 14
0
        private void AddCategoryToToolbox(string categoryName, List <Type> activities)
        {
            List <string> lstignore = new List <string>();
            List <string> lstnew    = new List <string>();


            bool Isvalid = true;

            foreach (Type activityType in activities)
            {
                lstnew.Clear();
                foreach (string str in lstignore)
                {
                    lstnew.Add(str);
                }
                if (this.IsValidToolboxActivity(activityType))
                {
                    ToolboxCategory category = this.GetToolboxCategory(categoryName);

                    if (!this.loadedToolboxActivities[category].Contains(activityType.FullName))
                    {
                        string   displayName;
                        string[] splitName = activityType.Name.Split('`');
                        if (splitName.Length == 1)
                        {
                            displayName = activityType.Name;
                        }
                        else
                        {
                            displayName = string.Format("{0}<>", splitName[0]);
                        }

                        this.loadedToolboxActivities[category].Add(activityType.FullName);
                        Isvalid = true;

                        if (Isvalid)
                        {
                            ToolboxItemWrapper toolbox = new ToolboxItemWrapper(activityType.FullName, activityType.Assembly.FullName, null, displayName);
                            toolbox.BitmapName = System.IO.Path.Combine(AppDomain.CurrentDomain.BaseDirectory, "Resources", displayName.Replace("<>", "") + ".png");
                            category.Add(toolbox);
                        }
                    }
                }
            }
        }
Ejemplo n.º 15
0
        private ToolboxCategory CreateTbxCat(string catName, List <Type> activities, Boolean isStandard)
        {
            ToolboxCategory tc = new ToolboxCategory(catName);

            foreach (var act in activities)
            {
                if (!activitiesInTbx.Contains(act))
                {
                    ToolboxItemWrapper tiw = new ToolboxItemWrapper(act.FullName, act.Assembly.FullName, null, act.Name);
                    tc.Add(tiw);
                    if (isStandard)
                    {
                        activitiesInTbx.Add(act);
                    }
                }
            }
            return(tc);
        }
Ejemplo n.º 16
0
        private ToolboxControl GetToolboxControl()
        {
            //System.Activities.Statements.
            // Create the ToolBoxControl.
            ToolboxControl ctrl = new ToolboxControl();

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

            //AddToCollection<T>

            // 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(Sequence).Assembly.FullName, null, "WriteLine");

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


            string[] list = { "Assign", "CancellationScope", "CompensableActivity", "Compensate", "CompensationExtension", "Confirm", "CreateBookmarkScope", "Delay", "DeleteBookmarkScope", "DoWhile", "DurableTimerExtension", "Flowchart", "FlowDecision", "FlowStep", "InvokeAction", "If", "InvokeDelegate", "InvokeMethod", "NoPersistScope", "Parallel", "Persist", "Pick", "PickBranch", "Rethrow", "Sequence", "State", "StateMachine", "TerminateWorkflow", "Throw", "TransactionScope", "Transition", "While", "WorkflowTerminatedException", "WriteLine" };
            foreach (string item in list)
            {
                ToolboxItemWrapper tool = new ToolboxItemWrapper("System.Activities.Statements." + item,
                                                                 typeof(Sequence).Assembly.FullName, null, item);
                category.Add(tool);
            }

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

            // Add the category to the ToolBox control.
            ctrl.Categories.Add(category);
            return(ctrl);
        }
Ejemplo n.º 17
0
        /// <summary>
        /// Creates a toolbox control.
        /// </summary>
        /// <returns>The control that was created.</returns>
        private ToolboxControl CreateToolboxControl()
        {
            // Create the toolbox control
            var toolbox = new ToolboxControl();

            toolbox.BorderThickness = new Thickness(0);

            // Create toolbox items
            var assignItem   = new ToolboxItemWrapper("System.Activities.Statements.Assign", typeof(Assign).Assembly.FullName, null, "Assign");
            var sequenceItem = new ToolboxItemWrapper("System.Activities.Statements.Sequence", typeof(Sequence).Assembly.FullName, null, "Sequence");

            // Add the items to the toolbox in a category
            var category = new ToolboxCategory("category1");

            category.Add(assignItem);
            category.Add(sequenceItem);
            toolbox.Categories.Add(category);

            return(toolbox);
        }
Ejemplo n.º 18
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);
            }
        }
Ejemplo n.º 19
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");


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


            //ToolboxItemWrapper tool4 = new ToolboxItemWrapper("ActivityLibrary.CodeActivity1",
            //    typeof(ActivityLibrary.CodeActivity1).Assembly.FullName, null, "CodeActivit1");


            ToolboxItemWrapper tool5 = new ToolboxItemWrapper("ActivityLibrary.Activity1",
                                                              typeof(ActivityLibrary.Activity1).Assembly.FullName, null, "Activity1");



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

            // Add the category to the ToolBox control.
            ctrl.Categories.Add(category);
            return(ctrl);
        }
Ejemplo n.º 20
0
        private ToolboxControl GetToolboxControl()
        {
            ToolboxControl ctrl = new ToolboxControl();

            ToolboxCategory category = new ToolboxCategory("category1");

            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("UiPathTeam.BooleanActivities.ActivityIf", typeof(ActivityIf).Assembly.FullName, null, "ActivityIf");
            ToolboxItemWrapper tool4 = new ToolboxItemWrapper("UiPathTeam.BooleanActivities.ActivityTrue", typeof(ActivityTrue).Assembly.FullName, null, "ActivityTrue");
            ToolboxItemWrapper tool6 = new ToolboxItemWrapper("UiPathTeam.BooleanActivities.ActivityFalse", typeof(ActivityFalse).Assembly.FullName, null, "ActivityFalse");
            ToolboxItemWrapper tool7 = new ToolboxItemWrapper("UiPathTeam.BooleanActivities.ActivityAnd", typeof(ActivityAnd).Assembly.FullName, null, "ActivityAnd");
            ToolboxItemWrapper tool8 = new ToolboxItemWrapper("UiPathTeam.BooleanActivities.VBExpression`1", typeof(VBExpression <>).Assembly.FullName, null, "VBExpression");


            ToolboxItemWrapper tool9 = new ToolboxItemWrapper("UiPathTeam.BooleanActivities.ActivityEquals`1", typeof(ActivityEquals <>).Assembly.FullName, null, "ActivityEquals");


            ToolboxItemWrapper tool10 = new ToolboxItemWrapper("UiPathTeam.BooleanActivities.ActivityWhile", typeof(ActivityWhile).Assembly.FullName, null, "ActivityWhile");

            category.Add(tool1);
            category.Add(tool2);
            category.Add(tool3);
            category.Add(tool4);
            category.Add(tool6);
            category.Add(tool7);
            category.Add(tool8);
            category.Add(tool9);
            category.Add(tool10);

            ToolboxItemWrapper tool5 = new ToolboxItemWrapper(typeof(WriteLine));

            category.Add(tool5);

            ctrl.Categories.Add(category);

            return(ctrl);
        }
Ejemplo n.º 21
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);
        }
Ejemplo n.º 22
0
        /// <summary>
        /// Creates the service model activities category.
        /// </summary>
        /// <returns></returns>
        /// <remarks></remarks>
        private ToolboxCategory CreateServiceModelActivitiesCategory()
        {
            Assembly assy = Assembly.GetAssembly(typeof(Send));
            var      cat  = new ToolboxCategory("Service Activities");

            Type[] types = assy
                           .GetTypes()
                           .Where(t => (t.IsSubclassOf(typeof(Activity)) && (!t.IsAbstract) && (!t.ContainsGenericParameters)))
                           .OrderBy(t => t.FullName)
                           .ToArray();
            if (types != null)
            {
                foreach (var t in types)
                {
                    Activity inst;
                    try
                    {
                        inst = (Activity)Activator.CreateInstance(t);
                        if (t.IsVisible)
                        {
                            var wrp = new ToolboxItemWrapper(t, inst.DisplayName);
                            cat.Add(wrp);;
                        }
                    }
                    catch
                    {
                    }
                    finally
                    {
                        inst = null;
                    }
                }
            }
            ;
            return(cat);
        }
Ejemplo n.º 23
0
        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);
        }
Ejemplo n.º 24
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);
        }
Ejemplo n.º 25
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);
        }
Ejemplo n.º 26
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);
        }
Ejemplo n.º 27
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);
            }
        }