private void OnStatusCopy(object sender, EventArgs e)
        {
            MenuCommand   command = (MenuCommand)sender;
            bool          flag    = false;
            IDesignerHost service = this.serviceProvider.GetService(typeof(IDesignerHost)) as IDesignerHost;

            if ((service != null) && !service.Loading)
            {
                ArrayList c = new ArrayList(this.selectionService.GetSelectedComponents());
                flag = Helpers.AreAllActivities(c);
                if (flag)
                {
                    foreach (Activity activity in c)
                    {
                        if (activity.Site != null)
                        {
                            service = activity.Site.GetService(typeof(IDesignerHost)) as IDesignerHost;
                            if ((service != null) && this.selectionService.GetComponentSelected(service.RootComponent))
                            {
                                flag = false;
                                break;
                            }
                        }
                    }
                }
            }
            command.Enabled = flag;
        }
 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));
     }
 }
        private void OnMenuCut(object sender, EventArgs e)
        {
            IDesignerHost service = this.serviceProvider.GetService(typeof(IDesignerHost)) as IDesignerHost;

            if ((service == null) || !this.selectionService.GetComponentSelected(service.RootComponent))
            {
                ICollection selectedComponents = this.selectionService.GetSelectedComponents();
                if (Helpers.AreAllActivities(selectedComponents) && DesignerHelpers.AreAssociatedDesignersMovable(selectedComponents))
                {
                    this.OnMenuCopy(sender, e);
                    string description = string.Empty;
                    if (selectedComponents.Count > 1)
                    {
                        description = SR.GetString("CutMultipleActivities", new object[] { selectedComponents.Count });
                    }
                    else
                    {
                        ArrayList list = new ArrayList(selectedComponents);
                        if (list.Count > 0)
                        {
                            description = SR.GetString("CutSingleActivity", new object[] { (list[0] as Activity).Name });
                        }
                        else
                        {
                            description = SR.GetString("CutActivity");
                        }
                    }
                    DesignerTransaction transaction = service.CreateTransaction(description);
                    try
                    {
                        this.OnMenuDelete(sender, e);
                        transaction.Commit();
                    }
                    catch
                    {
                        transaction.Cancel();
                    }
                }
            }
        }
예제 #4
0
        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();
            }
        }
예제 #5
0
        private bool CanInitiateDragDrop()
        {
            //Go thru all the selected components and make sure that they can participate in drag drop
            ISelectionService selectionService = (ISelectionService)GetService(typeof(ISelectionService));
            IDesignerHost     designerHost     = (IDesignerHost)GetService(typeof(IDesignerHost));

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

            // 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(false);
            }

            return(true);
        }
        private bool CanInitiateDragDrop()
        {
            ISelectionService service = (ISelectionService)base.GetService(typeof(ISelectionService));
            IDesignerHost     host    = (IDesignerHost)base.GetService(typeof(IDesignerHost));

            if ((service == null) || (host == null))
            {
                return(false);
            }
            ICollection selectedComponents = service.GetSelectedComponents();

            return(((selectedComponents != null) && (selectedComponents.Count >= 1)) && (!service.GetComponentSelected(host.RootComponent) && Helpers.AreAllActivities(selectedComponents)));
        }
        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();
                    }
                }
            }
        }