public MainWindow()
        {
            InitializeComponent();
            new BluEnergyXDesignerStart().ShowDialog();
            
            errorService = new ValidationErrorService(this.messageListBox);

            originalTitle = this.Title;
            //register designers for the standard activities
            DesignerMetadata dm = new DesignerMetadata();
            dm.Register();
            //toolbox
            toolboxControl = CreateToolbox();
            toolboxArea.Child = toolboxControl;
            CreateContextMenu();

            InitializeDesigner();
            StartNewWorkflow();

            //override designer for the standard While activity
            AttributeTableBuilder atb = new AttributeTableBuilder();
            atb.AddCustomAttributes(typeof(While), new DesignerAttribute(typeof(ActivityLibrary.Design.MyWhileDesigner)));
            MetadataStore.AddAttributeTable(atb.CreateTable());


        }
Exemple #2
0
       // private readonly MainViewModel mainViewModel;

        public MainWindow()
        {
            InitializeComponent();

            (new DesignerMetadata()).Register();


            (new Wxwinter.BPM.Machine.Design.DesignerMetadata()).Register();



            this.DataContext = this;
            toolBox.bindWindow(this);
            nodeToolboxControl = new ToolboxControl() { Categories = toolBox.loadToolbox() };
                     
            nodePanel.Content = nodeToolboxControl;
            templateListBoxcontrol = new ToolboxControl() { Categories = toolBox.loadTemplatebox() };
            templateList.Content = templateListBoxcontrol;
            userListBoxcontrol = new ToolboxControl() { Categories = toolBox.loadUserbox() };
            userList.Content = userListBoxcontrol;
            
          /*  EditConfig ec = new EditConfig();
            String dbServerIp = ec.ConfigGetValue("dbServerIp");
            String dbUser = ec.ConfigGetValue("dbPassword");
            String dbPassword = ec.ConfigGetValue("dbPassword");*/


        }
        public ActivitiesUserControl()
        {
            InitializeComponent();

            toolboxControl = CreateToolbox();
            toolboxArea.Child = toolboxControl;
        }
        // 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;
        }
        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;
        }
        //构造函数
        public designWindow()
        {
            InitializeComponent();

            (new DesignerMetadata()).Register();

            (new Machine.Design.DesignerMetadata()).Register();

            this.DataContext = this;

            nodeToolboxControl = new ToolboxControl() { Categories = toolBox.loadToolbox() };

            nodePanel.Content = nodeToolboxControl;
        }
        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;
        }
        /// <summary>
        /// Convert ActivityAssemblyItems to ToolboxWrappers
        /// </summary>
        public static ToolboxControl CreateToolboxes(ObservableCollection<ActivityAssemblyItem> activityAssemblyItems, bool isTask)
        {
            var toolboxWrappers = new List<ToolboxCategory>();
            var toolbox = new ToolboxControl();

            CreateUserActivitiesToolbox(activityAssemblyItems, toolboxWrappers);
            CreateBasicActivitiesToolbox(toolboxWrappers);
            if (!isTask)
            {
                CreateTaskActivityToolbox(toolboxWrappers);
            }
            CreateAdvancedActivitiesToolbox(toolboxWrappers);

            foreach (var category in toolboxWrappers)
            {
                toolbox.Categories.Add(category);
            }

            return toolbox;
        }
 public TreeViewContainerStyleSelector(ToolboxControl owner)
 {
     this.owner = owner;
 }
 public TreeViewTemplateSelector(ToolboxControl owner)
 {
     this.owner = owner;
 }
Exemple #11
0
 public TreeViewContainerStyleSelector(ToolboxControl owner)
 {
     this.owner = owner;
 }
        private ToolboxControl CreateToolbox()
        {
            var toolboxControl = new ToolboxControl();

            toolboxControl.Categories.Add(
                new ToolboxCategory("Control Flow")
                    {
                        new ToolboxItemWrapper(typeof(DoWhile)),
                        new ToolboxItemWrapper(typeof(ForEach<>)),
                        new ToolboxItemWrapper(typeof(If)),
                        new ToolboxItemWrapper(typeof(Parallel)),
                        new ToolboxItemWrapper(typeof(ParallelForEach<>)),
                        new ToolboxItemWrapper(typeof(Pick)),
                        new ToolboxItemWrapper(typeof(PickBranch)),
                        new ToolboxItemWrapper(typeof(Sequence)),
                        new ToolboxItemWrapper(typeof(Switch<>)),
                        new ToolboxItemWrapper(typeof(While)),
                    });

            toolboxControl.Categories.Add(
                new ToolboxCategory("Primitives")
                    {
                        new ToolboxItemWrapper(typeof(Assign)),
                        new ToolboxItemWrapper(typeof(Delay)),
                        new ToolboxItemWrapper(typeof(InvokeMethod)),
                        new ToolboxItemWrapper(typeof(WriteLine)),
                    });

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

            toolboxControl.Categories.Add(
                new ToolboxCategory("HTTP")
                    {
                        new ToolboxItemWrapper(typeof(HttpReceiveFactory), "HttpReceive"),
                        new ToolboxItemWrapper(typeof(HttpWorkflowServiceFactory), "HttpWorkflowService"),
                    });

            return toolboxControl;
        }
        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 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;
        }
        /// <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 MainWindowViewModel(DockingManager dockingManager, ResizingPanel horizontalResizingPanel, ResizingPanel verticalResizingPanel, DockablePane tabsPane)
        {
            this.dockingManager = dockingManager;

            dockingManager.ActiveDocumentChanged += delegate(object sender, EventArgs args)
            {
                this.UpdateViews();
            };

            this.toolboxControl = new ToolboxControl();
            this.InitialiseToolbox();

            this.horizontalResizingPanel = horizontalResizingPanel;
            this.verticalResizingPanel = verticalResizingPanel;

            this.tabsPane = tabsPane;

            this.dockableContents = new Dictionary<ContentTypes, DockableContent>();
            this.ViewToolbox();

            string disableDebugViewOutputValue = ConfigurationManager.AppSettings["DisableDebugViewOutput"];
            if (!string.IsNullOrEmpty(disableDebugViewOutputValue))
            {
                this.disableDebugViewOutput = bool.Parse(disableDebugViewOutputValue);
            }
        }
Exemple #18
0
 public Toolbox()
 {
     toolbox = new ToolboxControl();
     Content = toolbox;
 }
        private ToolboxControl CreateToolbox()
        {
            var toolboxControl = new ToolboxControl();

            toolboxControl.Categories.Add(
                new ToolboxCategory("Control Flow")
                    {
                        new ToolboxItemWrapper(typeof(DoWhile)),
                        new ToolboxItemWrapper(typeof(ForEach<>)),
                        new ToolboxItemWrapper(typeof(If)),
                        new ToolboxItemWrapper(typeof(Parallel)),
                        new ToolboxItemWrapper(typeof(ParallelForEach<>)),
                        new ToolboxItemWrapper(typeof(Pick)),
                        new ToolboxItemWrapper(typeof(PickBranch)),
                        new ToolboxItemWrapper(typeof(Sequence)),
                        new ToolboxItemWrapper(typeof(Switch<>)),
                        new ToolboxItemWrapper(typeof(While)),
                    });

            toolboxControl.Categories.Add(
                new ToolboxCategory("Primitives")
                    {
                        new ToolboxItemWrapper(typeof(Assign)),
                        new ToolboxItemWrapper(typeof(Delay)),
                        new ToolboxItemWrapper(typeof(InvokeMethod)),
                        new ToolboxItemWrapper(typeof(WriteLine)),
                    });

            return toolboxControl;
        }
Exemple #20
0
        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);
        }
        protected void LoadToolBox()
        {
            var tbc = new ToolboxControl
            {
                CategoryItemStyle = new Style(typeof (TreeViewItem))
                {
                    Setters = {new Setter(TreeViewItem.IsExpandedProperty, false)}
                }
            };

            Dispatcher.BeginInvoke(new Action(() => ToolboxBorder.Child = tbc));
            Dispatcher.BeginInvoke(new Action(() => LoadDefaultActivities(tbc)));
            //Load the dll contain TestSuite, it means the ActivityLib.dll loaded here
            //var customAss = typeof (TestSuiteActivity).Assembly;
            //const string categoryTitle = "AutoX Automation";
            //LoadCustomActivities(tbc, customAss, categoryTitle);

            //support the users create there own automation activities, just add the dll name to appsettings
            var ass = Configuration.Settings("Assemmblies", "");
            if (string.IsNullOrEmpty(ass)) return;
            var split = new[] {';'};
            var asses = ass.Split(split);
            foreach (var a in asses)
            {
                if (!string.IsNullOrWhiteSpace(a))
                {
                    //Dispatcher.BeginInvoke(
                    //    new Action(() => LoadCustomActivities(tbc, Assembly.LoadFrom(a), "Custom Activities")));
                    LoadCustomActivities(tbc, Assembly.LoadFrom(a), "Custom Activities");
                }
            }
        }
 public TreeViewTemplateSelector(ToolboxControl owner)
 {
     this.owner = owner;
 }
        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;
        }
        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);
        }