Example #1
0
        internal bool IsValidDropContext(HitTestInfo dropLocation)
        {
            if (this.draggedActivities.Count == 0)
            {
                return(false);
            }

            if (dropLocation == null || dropLocation.AssociatedDesigner == null)
            {
                return(false);
            }

            CompositeActivityDesigner compositeDesigner = dropLocation.AssociatedDesigner as CompositeActivityDesigner;

            if (compositeDesigner == null)
            {
                return(false);
            }

            if (!compositeDesigner.IsEditable || !compositeDesigner.CanInsertActivities(dropLocation, new List <Activity>(this.draggedActivities).AsReadOnly()))
            {
                return(false);
            }

            if (!this.wasCtrlKeyPressed && this.existingDraggedActivities.Count > 0)
            {
                //We are trying to move the actvities with designer
                if (!DesignerHelpers.AreAssociatedDesignersMovable(this.draggedActivities))
                {
                    return(false);
                }

                if (IsRecursiveDropOperation(dropLocation.AssociatedDesigner))
                {
                    return(false);
                }

                IDictionary commonParentActivities = Helpers.PairUpCommonParentActivities(this.draggedActivities);
                foreach (DictionaryEntry entry in commonParentActivities)
                {
                    CompositeActivityDesigner compositeActivityDesigner = ActivityDesigner.GetDesigner(entry.Key as Activity) as CompositeActivityDesigner;
                    Activity[] activitiesToMove = (Activity[])((ArrayList)entry.Value).ToArray(typeof(Activity));
                    if (compositeActivityDesigner != null && !compositeActivityDesigner.CanMoveActivities(dropLocation, new List <Activity>(activitiesToMove).AsReadOnly()))
                    {
                        return(false);
                    }
                }
            }

            return(true);
        }
        internal bool IsValidDropContext(System.Workflow.ComponentModel.Design.HitTestInfo dropLocation)
        {
            if (this.draggedActivities.Count == 0)
            {
                return(false);
            }
            if ((dropLocation == null) || (dropLocation.AssociatedDesigner == null))
            {
                return(false);
            }
            CompositeActivityDesigner associatedDesigner = dropLocation.AssociatedDesigner as CompositeActivityDesigner;

            if (associatedDesigner == null)
            {
                return(false);
            }
            if (!associatedDesigner.IsEditable || !associatedDesigner.CanInsertActivities(dropLocation, new List <Activity>(this.draggedActivities).AsReadOnly()))
            {
                return(false);
            }
            if (!this.wasCtrlKeyPressed && (this.existingDraggedActivities.Count > 0))
            {
                if (!DesignerHelpers.AreAssociatedDesignersMovable(this.draggedActivities))
                {
                    return(false);
                }
                if (this.IsRecursiveDropOperation(dropLocation.AssociatedDesigner))
                {
                    return(false);
                }
                foreach (DictionaryEntry entry in Helpers.PairUpCommonParentActivities(this.draggedActivities))
                {
                    CompositeActivityDesigner designer = ActivityDesigner.GetDesigner(entry.Key as Activity) as CompositeActivityDesigner;
                    Activity[] collection = (Activity[])((ArrayList)entry.Value).ToArray(typeof(Activity));
                    if ((designer != null) && !designer.CanMoveActivities(dropLocation, new List <Activity>(collection).AsReadOnly()))
                    {
                        return(false);
                    }
                }
            }
            return(true);
        }