コード例 #1
0
        private bool IsRecursiveDropOperation(ActivityDesigner dropTargetDesigner)
        {
            if (dropTargetDesigner == null)
                return false;

            ISelectionService selectionService = (ISelectionService)GetService(typeof(ISelectionService));
            CompositeActivity dropTargetComponent = dropTargetDesigner.Activity as CompositeActivity;
            if (dropTargetComponent == null || selectionService == null)
                return false;

            // First check for activity designer specific recursion - possible recursion when drag-n-drop from outside the current 
            // designer such toolbox or other activity designers.
            WorkflowView workflowView = GetService(typeof(WorkflowView)) as WorkflowView;
            IDesignerHost host = GetService(typeof(IDesignerHost)) as IDesignerHost;
            WorkflowDesignerLoader loader = GetService(typeof(WorkflowDesignerLoader)) as WorkflowDesignerLoader;

            // When drag-n-drop within the same designer, if the drag drop is not within designer or no valid droptarget, we do not do anything
            if (this.draggedActivities.Count == 0 || this.existingDraggedActivities.Count == 0)
                return false;

            //Go thru all the components in dragged components and check for recursive dragdrop
            //Get all the top level activities being dragged dropped
            ArrayList topLevelActivities = new ArrayList(Helpers.GetTopLevelActivities(selectionService.GetSelectedComponents()));
            CompositeActivity parentActivity = dropTargetComponent;
            while (parentActivity != null)
            {
                if (topLevelActivities.Contains(parentActivity))
                    return true;

                parentActivity = parentActivity.Parent;
            }


            return false;
        }
コード例 #2
0
ファイル: DragDropManager.cs プロジェクト: dox0/DotNet471RS3
        private void InitiateDragDrop()
        {
            WorkflowView      parentView       = ParentView;
            ISelectionService selectionService = (ISelectionService)GetService(typeof(ISelectionService));
            IDesignerHost     designerHost     = (IDesignerHost)GetService(typeof(IDesignerHost));

            if (selectionService == null || designerHost == null)
            {
                return;
            }

            // check if we are cutting root component
            ICollection components = selectionService.GetSelectedComponents();

            if (components == null || components.Count < 1 || selectionService.GetComponentSelected(designerHost.RootComponent) || !Helpers.AreAllActivities(components))
            {
                return;
            }

            DragDropEffects effects = DragDropEffects.None;

            try
            {
                // get component serialization service
                this.existingDraggedActivities.AddRange(Helpers.GetTopLevelActivities(components));

                //IMPORTANT: FOR WITHIN DESIGNER COMPONENT MOVE WE REMOVE THE ACTIVITIES BEFORE WE ADD THEM WHICH IS IN
                //ONDRAGDROP FUNCTION. ALTHOUGH THIS VIOLATES THE DODRAGDROP FUNCTION SIMANTICS, WE NEED TO DO THIS
                //SO THAT WE CAN USE THE SAME IDS FOR THE ACTIVITIES
                DragDropEffects allowedEffects = (DesignerHelpers.AreAssociatedDesignersMovable(this.existingDraggedActivities)) ? DragDropEffects.Move | DragDropEffects.Copy : DragDropEffects.Copy;
                IDataObject     dataObject     = CompositeActivityDesigner.SerializeActivitiesToDataObject(ParentView, this.existingDraggedActivities.ToArray());
                effects = parentView.DoDragDrop(dataObject, allowedEffects);

                //
            }
            catch (Exception e)
            {
                DesignerHelpers.ShowError(ParentView, e.Message);
            }
            finally
            {
                //This means drag drop occurred across designer
                if (effects == DragDropEffects.Move && this.existingDraggedActivities.Count > 0)
                {
                    string transactionDescription = String.Empty;
                    if (this.existingDraggedActivities.Count > 1)
                    {
                        transactionDescription = SR.GetString(SR.MoveMultipleActivities, this.existingDraggedActivities.Count);
                    }
                    else
                    {
                        transactionDescription = SR.GetString(SR.MoveSingleActivity, this.existingDraggedActivities[0].GetType());
                    }

                    CompositeActivityDesigner.RemoveActivities(ParentView, this.existingDraggedActivities.AsReadOnly(), transactionDescription);
                }

                this.existingDraggedActivities.Clear();
            }
        }
コード例 #3
0
 private bool IsRecursiveDropOperation(ActivityDesigner dropTargetDesigner)
 {
     if (dropTargetDesigner != null)
     {
         ISelectionService service  = (ISelectionService)base.GetService(typeof(ISelectionService));
         CompositeActivity activity = dropTargetDesigner.Activity as CompositeActivity;
         if ((activity == null) || (service == null))
         {
             return(false);
         }
         base.GetService(typeof(WorkflowView));
         base.GetService(typeof(IDesignerHost));
         base.GetService(typeof(WorkflowDesignerLoader));
         if ((this.draggedActivities.Count == 0) || (this.existingDraggedActivities.Count == 0))
         {
             return(false);
         }
         ArrayList list = new ArrayList(Helpers.GetTopLevelActivities(service.GetSelectedComponents()));
         for (CompositeActivity activity2 = activity; activity2 != null; activity2 = activity2.Parent)
         {
             if (list.Contains(activity2))
             {
                 return(true);
             }
         }
     }
     return(false);
 }
コード例 #4
0
 private void OnMenuCopy(object sender, EventArgs e)
 {
     if (Helpers.AreAllActivities(this.selectionService.GetSelectedComponents()))
     {
         Activity[] topLevelActivities = Helpers.GetTopLevelActivities(this.selectionService.GetSelectedComponents());
         Clipboard.SetDataObject(CompositeActivityDesigner.SerializeActivitiesToDataObject(this.serviceProvider, topLevelActivities));
     }
 }
コード例 #5
0
        private void InitiateDragDrop()
        {
            WorkflowView      parentView = base.ParentView;
            ISelectionService service    = (ISelectionService)base.GetService(typeof(ISelectionService));
            IDesignerHost     host       = (IDesignerHost)base.GetService(typeof(IDesignerHost));

            if ((service != null) && (host != null))
            {
                ICollection selectedComponents = service.GetSelectedComponents();
                if (((selectedComponents != null) && (selectedComponents.Count >= 1)) && (!service.GetComponentSelected(host.RootComponent) && Helpers.AreAllActivities(selectedComponents)))
                {
                    DragDropEffects none = DragDropEffects.None;
                    try
                    {
                        this.existingDraggedActivities.AddRange(Helpers.GetTopLevelActivities(selectedComponents));
                        DragDropEffects allowedEffects = DesignerHelpers.AreAssociatedDesignersMovable(this.existingDraggedActivities) ? (DragDropEffects.Move | DragDropEffects.Copy) : DragDropEffects.Copy;
                        IDataObject     data           = CompositeActivityDesigner.SerializeActivitiesToDataObject(base.ParentView, this.existingDraggedActivities.ToArray());
                        none = parentView.DoDragDrop(data, allowedEffects);
                    }
                    catch (Exception exception)
                    {
                        DesignerHelpers.ShowError(base.ParentView, exception.Message);
                    }
                    finally
                    {
                        if ((none == DragDropEffects.Move) && (this.existingDraggedActivities.Count > 0))
                        {
                            string transactionDescription = string.Empty;
                            if (this.existingDraggedActivities.Count > 1)
                            {
                                transactionDescription = SR.GetString("MoveMultipleActivities", new object[] { this.existingDraggedActivities.Count });
                            }
                            else
                            {
                                transactionDescription = SR.GetString("MoveSingleActivity", new object[] { this.existingDraggedActivities[0].GetType() });
                            }
                            CompositeActivityDesigner.RemoveActivities(base.ParentView, this.existingDraggedActivities.AsReadOnly(), transactionDescription);
                        }
                        this.existingDraggedActivities.Clear();
                    }
                }
            }
        }
コード例 #6
0
        protected override void OnKeyDown(KeyEventArgs e)
        {
            if (e == null)
            {
                throw new ArgumentNullException("e");
            }
            ISelectionService service = base.GetService(typeof(ISelectionService)) as ISelectionService;

            if (((service != null) ? service.PrimarySelection : null) != null)
            {
                List <Activity> list = new List <Activity>(Helpers.GetTopLevelActivities(service.GetSelectedComponents()));
                if (((e.KeyCode == Keys.Left) || (e.KeyCode == Keys.Right)) || ((e.KeyCode == Keys.Up) || (e.KeyCode == Keys.Down)))
                {
                    Size empty = Size.Empty;
                    if (e.KeyCode == Keys.Left)
                    {
                        empty = new Size(-5, 0);
                    }
                    else if (e.KeyCode == Keys.Right)
                    {
                        empty = new Size(5, 0);
                    }
                    else if (e.KeyCode == Keys.Up)
                    {
                        empty = new Size(0, -5);
                    }
                    else if (e.KeyCode == Keys.Down)
                    {
                        empty = new Size(0, 5);
                    }
                    foreach (Activity activity in list)
                    {
                        ActivityDesigner designer = ActivityDesigner.GetDesigner(activity);
                        if (designer != null)
                        {
                            base.ParentView.InvalidateClientRectangle(new Rectangle(designer.Location, designer.Size));
                            designer.Location += empty;
                            base.ParentView.InvalidateClientRectangle(new Rectangle(designer.Location, designer.Size));
                        }
                    }
                    base.PerformLayout();
                    e.Handled = true;
                }
                else if (e.KeyCode == Keys.Delete)
                {
                    foreach (object obj3 in service.GetSelectedComponents())
                    {
                        ConnectorHitTestInfo info = obj3 as ConnectorHitTestInfo;
                        if (info != null)
                        {
                            FreeformActivityDesigner associatedDesigner = info.AssociatedDesigner as FreeformActivityDesigner;
                            if (associatedDesigner != null)
                            {
                                ReadOnlyCollection <Connector> connectors = associatedDesigner.Connectors;
                                int num = info.MapToIndex();
                                if (num < connectors.Count)
                                {
                                    service.SetSelectedComponents(new object[] { info }, SelectionTypes.Remove);
                                    associatedDesigner.RemoveConnector(connectors[num]);
                                    object obj4 = associatedDesigner;
                                    if (connectors.Count > 0)
                                    {
                                        obj4 = new ConnectorHitTestInfo(associatedDesigner, HitTestLocations.Connector | HitTestLocations.Designer, (num > 0) ? (num - 1) : num);
                                    }
                                    service.SetSelectedComponents(new object[] { obj4 }, SelectionTypes.Replace);
                                }
                            }
                        }
                    }
                    e.Handled = true;
                }
                if (!e.Handled)
                {
                    base.OnKeyDown(e);
                }
            }
        }
コード例 #7
0
ファイル: WindowManager.cs プロジェクト: dox0/DotNet471RS3
        protected override bool OnKeyDown(KeyEventArgs eventArgs)
        {
            if (eventArgs != null && (eventArgs.KeyCode == Keys.PageUp || eventArgs.KeyCode == Keys.PageDown))
            {
                UpdateViewOnPageUpDown(eventArgs.KeyCode == Keys.PageUp);
            }
            ISelectionService selectionService = ((IServiceProvider)this.ParentView).GetService(typeof(ISelectionService)) as ISelectionService;

            //enter key (
            if (eventArgs.KeyCode == Keys.Enter)
            {
                // on enter key we want to do DoDefault of the designer
                IDesigner designer = ActivityDesigner.GetDesigner(selectionService.PrimarySelection as Activity) as IDesigner;
                if (designer != null)
                {
                    designer.DoDefaultAction();
                    eventArgs.Handled = true;
                }
            }
            else if (eventArgs.KeyCode == Keys.Escape)
            {
                if (!eventArgs.Handled)
                {
                    CompositeActivityDesigner parentDesigner = ActivityDesigner.GetParentDesigner(selectionService.PrimarySelection);
                    if (parentDesigner != null)
                    {
                        selectionService.SetSelectedComponents(new object[] { parentDesigner.Activity }, SelectionTypes.Replace);
                    }

                    eventArgs.Handled = true;
                }
            }
            else if (eventArgs.KeyCode == Keys.Delete)
            {
                // check if we are cutting root component
                IDesignerHost designerHost = ((IServiceProvider)this.ParentView).GetService(typeof(IDesignerHost)) as IDesignerHost;
                if (!(designerHost == null || selectionService.GetComponentSelected(designerHost.RootComponent)))
                {
                    //Check that we are cutting all activities
                    //Check if we are in writable context
                    ICollection components = selectionService.GetSelectedComponents();
                    if (DesignerHelpers.AreComponentsRemovable(components))
                    {
                        // check if we can delete these
                        List <Activity> topLevelActivities     = new List <Activity>(Helpers.GetTopLevelActivities(selectionService.GetSelectedComponents()));
                        bool            needToDelete           = (topLevelActivities.Count > 0);
                        IDictionary     commonParentActivities = Helpers.PairUpCommonParentActivities(topLevelActivities);
                        foreach (DictionaryEntry entry in commonParentActivities)
                        {
                            CompositeActivityDesigner compositeActivityDesigner = ActivityDesigner.GetDesigner(entry.Key as Activity) as CompositeActivityDesigner;
                            if (compositeActivityDesigner != null && !compositeActivityDesigner.CanRemoveActivities(new List <Activity>((Activity[])((ArrayList)entry.Value).ToArray(typeof(Activity))).AsReadOnly()))
                            {
                                needToDelete = false;
                            }
                        }

                        if (needToDelete)
                        {
                            List <ConnectorHitTestInfo> connectors = new List <ConnectorHitTestInfo>();
                            foreach (object component in components)
                            {
                                ConnectorHitTestInfo connector = component as ConnectorHitTestInfo;
                                if (connector != null)
                                {
                                    connectors.Add(connector);
                                }
                            }

                            //cache selcted connectors before calling this func
                            CompositeActivityDesigner.RemoveActivities((IServiceProvider)this.ParentView, topLevelActivities.AsReadOnly(), SR.GetString(SR.DeletingActivities));

                            //add connectors back to the selection service
                            if (selectionService != null && connectors.Count > 0)
                            {
                                selectionService.SetSelectedComponents(connectors, SelectionTypes.Add);
                            }

                            eventArgs.Handled = true;
                        }
                    }
                }
            }
            //navigation (left, right, up, down, tab, shift-tab)
            else if (eventArgs.KeyCode == Keys.Left || eventArgs.KeyCode == Keys.Right || eventArgs.KeyCode == Keys.Up || eventArgs.KeyCode == Keys.Down || eventArgs.KeyCode == Keys.Tab)
            {
                //we'll pass it to the parent designer of the primary selected designer
                //sequential designers just navigate between their children
                //free form designers may move their children on arrow keys and navigate on tab
                ActivityDesigner designer = ActivityDesigner.GetDesigner(selectionService.PrimarySelection as Activity) as ActivityDesigner;
                if (designer != null && designer.ParentDesigner != null)
                {
                    //we will let the parent see if it wants to handle the event,
                    //otherwise the selected designer itself will be called from a designer message filter below
                    ((IWorkflowDesignerMessageSink)designer.ParentDesigner).OnKeyDown(eventArgs);
                    eventArgs.Handled = true;
                }
            }

            if (!eventArgs.Handled)
            {
                ActivityDesigner designerWithFocus = GetDesignerWithFocus();
                if (designerWithFocus != null)
                {
                    ((IWorkflowDesignerMessageSink)designerWithFocus).OnKeyDown(eventArgs);
                }
            }

            return(eventArgs.Handled);
        }
コード例 #8
0
        protected override bool OnKeyDown(KeyEventArgs eventArgs)
        {
            if ((eventArgs != null) && ((eventArgs.KeyCode == Keys.PageUp) || (eventArgs.KeyCode == Keys.Next)))
            {
                this.UpdateViewOnPageUpDown(eventArgs.KeyCode == Keys.PageUp);
            }
            ISelectionService service = ((IServiceProvider)base.ParentView).GetService(typeof(ISelectionService)) as ISelectionService;

            if (eventArgs.KeyCode == Keys.Enter)
            {
                IDesigner designer = ActivityDesigner.GetDesigner(service.PrimarySelection as Activity);
                if (designer != null)
                {
                    designer.DoDefaultAction();
                    eventArgs.Handled = true;
                }
            }
            else if (eventArgs.KeyCode == Keys.Escape)
            {
                if (!eventArgs.Handled)
                {
                    CompositeActivityDesigner parentDesigner = ActivityDesigner.GetParentDesigner(service.PrimarySelection);
                    if (parentDesigner != null)
                    {
                        service.SetSelectedComponents(new object[] { parentDesigner.Activity }, SelectionTypes.Replace);
                    }
                    eventArgs.Handled = true;
                }
            }
            else if (eventArgs.KeyCode == Keys.Delete)
            {
                IDesignerHost host = ((IServiceProvider)base.ParentView).GetService(typeof(IDesignerHost)) as IDesignerHost;
                if ((host != null) && !service.GetComponentSelected(host.RootComponent))
                {
                    ICollection selectedComponents = service.GetSelectedComponents();
                    if (DesignerHelpers.AreComponentsRemovable(selectedComponents))
                    {
                        List <Activity> activities = new List <Activity>(Helpers.GetTopLevelActivities(service.GetSelectedComponents()));
                        bool            flag       = activities.Count > 0;
                        foreach (DictionaryEntry entry in Helpers.PairUpCommonParentActivities(activities))
                        {
                            CompositeActivityDesigner designer3 = ActivityDesigner.GetDesigner(entry.Key as Activity) as CompositeActivityDesigner;
                            if ((designer3 != null) && !designer3.CanRemoveActivities(new List <Activity>((Activity[])((ArrayList)entry.Value).ToArray(typeof(Activity))).AsReadOnly()))
                            {
                                flag = false;
                            }
                        }
                        if (flag)
                        {
                            List <ConnectorHitTestInfo> components = new List <ConnectorHitTestInfo>();
                            foreach (object obj2 in selectedComponents)
                            {
                                ConnectorHitTestInfo item = obj2 as ConnectorHitTestInfo;
                                if (item != null)
                                {
                                    components.Add(item);
                                }
                            }
                            CompositeActivityDesigner.RemoveActivities(base.ParentView, activities.AsReadOnly(), SR.GetString("DeletingActivities"));
                            if ((service != null) && (components.Count > 0))
                            {
                                service.SetSelectedComponents(components, SelectionTypes.Add);
                            }
                            eventArgs.Handled = true;
                        }
                    }
                }
            }
            else if (((eventArgs.KeyCode == Keys.Left) || (eventArgs.KeyCode == Keys.Right)) || (((eventArgs.KeyCode == Keys.Up) || (eventArgs.KeyCode == Keys.Down)) || (eventArgs.KeyCode == Keys.Tab)))
            {
                ActivityDesigner designer4 = ActivityDesigner.GetDesigner(service.PrimarySelection as Activity);
                if ((designer4 != null) && (designer4.ParentDesigner != null))
                {
                    ((IWorkflowDesignerMessageSink)designer4.ParentDesigner).OnKeyDown(eventArgs);
                    eventArgs.Handled = true;
                }
            }
            if (!eventArgs.Handled)
            {
                ActivityDesigner designerWithFocus = this.GetDesignerWithFocus();
                if (designerWithFocus != null)
                {
                    ((IWorkflowDesignerMessageSink)designerWithFocus).OnKeyDown(eventArgs);
                }
            }
            return(eventArgs.Handled);
        }
コード例 #9
0
        private void OnStatusPaste(object sender, EventArgs e)
        {
            MenuCommand command = (MenuCommand)sender;

            command.Enabled = false;
            object primarySelection = this.selectionService.PrimarySelection;
            CompositeActivityDesigner parentDesigner = ActivityDesigner.GetDesigner(primarySelection as Activity) as CompositeActivityDesigner;

            if (parentDesigner == null)
            {
                parentDesigner = ActivityDesigner.GetParentDesigner(primarySelection);
            }
            if ((parentDesigner != null) && parentDesigner.IsEditable)
            {
                IDesignerHost   host       = this.serviceProvider.GetService(typeof(IDesignerHost)) as IDesignerHost;
                IToolboxService service    = (IToolboxService)this.serviceProvider.GetService(typeof(IToolboxService));
                IDataObject     dataObject = Clipboard.GetDataObject();
                if (((dataObject != null) && (host != null)) && ((dataObject.GetDataPresent("CF_WINOEDESIGNERCOMPONENTS") || (service == null)) || service.IsSupported(dataObject, host)))
                {
                    System.Workflow.ComponentModel.Design.HitTestInfo insertLocation = null;
                    if (primarySelection is System.Workflow.ComponentModel.Design.HitTestInfo)
                    {
                        insertLocation = (System.Workflow.ComponentModel.Design.HitTestInfo)primarySelection;
                    }
                    else if (primarySelection is CompositeActivity)
                    {
                        insertLocation = new System.Workflow.ComponentModel.Design.HitTestInfo(parentDesigner, HitTestLocations.Designer);
                    }
                    else if (primarySelection is Activity)
                    {
                        Activity                  item     = primarySelection as Activity;
                        CompositeActivity         parent   = item.Parent;
                        CompositeActivityDesigner designer = ActivityDesigner.GetDesigner(parent) as CompositeActivityDesigner;
                        if (designer != null)
                        {
                            insertLocation = new ConnectorHitTestInfo(designer, HitTestLocations.Designer, parent.Activities.IndexOf(item) + 1);
                        }
                    }
                    ICollection activities = null;
                    try
                    {
                        activities = CompositeActivityDesigner.DeserializeActivitiesFromDataObject(this.serviceProvider, dataObject);
                    }
                    catch (CheckoutException exception)
                    {
                        if (exception != CheckoutException.Canceled)
                        {
                            throw exception;
                        }
                    }
                    command.Enabled = ((activities != null) && (insertLocation != null)) && parentDesigner.CanInsertActivities(insertLocation, new List <Activity>(Helpers.GetTopLevelActivities(activities)).AsReadOnly());
                }
            }
        }
コード例 #10
0
        private void OnStatusDelete(object sender, EventArgs e)
        {
            MenuCommand command = (MenuCommand)sender;

            command.Enabled = false;
            IDesignerHost service = this.serviceProvider.GetService(typeof(IDesignerHost)) as IDesignerHost;

            if (((service == null) || (service.RootComponent == null)) || !this.selectionService.GetComponentSelected(service.RootComponent))
            {
                ICollection selectedComponents = this.selectionService.GetSelectedComponents();
                if (DesignerHelpers.AreComponentsRemovable(selectedComponents))
                {
                    foreach (DictionaryEntry entry in Helpers.PairUpCommonParentActivities(Helpers.GetTopLevelActivities(selectedComponents)))
                    {
                        CompositeActivityDesigner designer = ActivityDesigner.GetDesigner(entry.Key as Activity) as CompositeActivityDesigner;
                        if ((designer != null) && !designer.CanRemoveActivities(new List <Activity>((Activity[])((ArrayList)entry.Value).ToArray(typeof(Activity))).AsReadOnly()))
                        {
                            command.Enabled = false;
                            return;
                        }
                    }
                    command.Enabled = true;
                }
            }
        }
コード例 #11
0
        private void OnMenuPaste(object sender, EventArgs e)
        {
            object primarySelection = this.selectionService.PrimarySelection;
            CompositeActivityDesigner parentDesigner = ActivityDesigner.GetDesigner(primarySelection as Activity) as CompositeActivityDesigner;

            if (parentDesigner == null)
            {
                parentDesigner = ActivityDesigner.GetParentDesigner(primarySelection);
            }
            if ((parentDesigner != null) && parentDesigner.IsEditable)
            {
                IDataObject dataObject = Clipboard.GetDataObject();
                ICollection activities = null;
                try
                {
                    activities = CompositeActivityDesigner.DeserializeActivitiesFromDataObject(this.serviceProvider, dataObject, true);
                }
                catch (Exception exception)
                {
                    if (exception != CheckoutException.Canceled)
                    {
                        throw new Exception(DR.GetString("ActivityInsertError", new object[0]) + "\n" + exception.Message, exception);
                    }
                }
                if (activities == null)
                {
                    throw new InvalidOperationException(DR.GetString("InvalidOperationBadClipboardFormat", new object[0]));
                }
                System.Workflow.ComponentModel.Design.HitTestInfo insertLocation = null;
                if (primarySelection is System.Workflow.ComponentModel.Design.HitTestInfo)
                {
                    insertLocation = (System.Workflow.ComponentModel.Design.HitTestInfo)primarySelection;
                }
                else if (primarySelection is CompositeActivity)
                {
                    insertLocation = new System.Workflow.ComponentModel.Design.HitTestInfo(parentDesigner, HitTestLocations.Designer);
                }
                else if (primarySelection is Activity)
                {
                    Activity                  item     = primarySelection as Activity;
                    CompositeActivity         parent   = item.Parent;
                    CompositeActivityDesigner designer = ActivityDesigner.GetDesigner(parent) as CompositeActivityDesigner;
                    if (designer != null)
                    {
                        insertLocation = new ConnectorHitTestInfo(designer, HitTestLocations.Designer, parent.Activities.IndexOf(item) + 1);
                    }
                }
                List <Activity> list = new List <Activity>(Helpers.GetTopLevelActivities(activities));
                if ((insertLocation == null) || !parentDesigner.CanInsertActivities(insertLocation, list.AsReadOnly()))
                {
                    throw new Exception(SR.GetString("Error_NoPasteSupport"));
                }
                IExtendedUIService service = this.serviceProvider.GetService(typeof(IExtendedUIService)) as IExtendedUIService;
                if (service != null)
                {
                    foreach (Activity activity3 in activities)
                    {
                        service.AddAssemblyReference(activity3.GetType().Assembly.GetName());
                    }
                }
                CompositeActivityDesigner.InsertActivities(parentDesigner, insertLocation, list.AsReadOnly(), SR.GetString("PastingActivities"));
                Stream data = dataObject.GetData("CF_WINOEDESIGNERCOMPONENTSSTATE") as Stream;
                if (data != null)
                {
                    Helpers.DeserializeDesignersFromStream(activities, data);
                }
                this.selectionService.SetSelectedComponents(list.ToArray(), SelectionTypes.Replace);
                this.workflowView.EnsureVisible(this.selectionService.PrimarySelection);
            }
        }