Ejemplo n.º 1
0
 private bool IsOwnerActivityBeingDragged(DragEventArgs e)
 {
     if (this.wfItemPresenter.Item == null)
     {
         return(false);
     }
     else
     {
         // In case of a toolbox drop, DragDropHelper.GetObjectsToBeDropped
         //  will create an instance, which will possibliy pop up a type picker
         //  dialog for generic activities. So check for it first and avoid
         //  pop up dialogs.
         if (DragDropHelper.IsDraggingFromToolbox(e))
         {
             return(false);
         }
         IEnumerable <ModelItem> draggedObjects = DragDropHelper.GetDraggedModelItems(e);
         return(draggedObjects.Contains(this.wfItemPresenter.Item));
     }
 }
Ejemplo n.º 2
0
        bool DoAutoWrapDrop(InsertionPosition insertionPos, DragEventArgs e, IList <object> droppedObjects = null)
        {
            if (droppedObjects == null)
            {
                ModelTreeManager manager      = this.Context.Services.GetRequiredService <ModelTreeManager>();
                EditingScope     editingScope = null;

                try
                {
                    editingScope = ModelItemHelper.TryCreateImmediateEditingScope(manager, SR.WrapInSequenceDescription);

                    droppedObjects = this.GetSortedObjectList(e);

                    if (!this.DoAutoWrapDrop(insertionPos, droppedObjects))
                    {
                        return(false);
                    }

                    if (editingScope != null)
                    {
                        editingScope.Complete();
                    }
                }
                finally
                {
                    if (editingScope != null)
                    {
                        editingScope.Dispose();
                        editingScope = null;
                    }
                }
            }
            else
            {
                if (!this.DoAutoWrapDrop(insertionPos, droppedObjects))
                {
                    return(false);
                }
            }

            if (!DragDropHelper.IsDraggingFromToolbox(e))
            {
                List <WorkflowViewElement> movedViewElements = ObjectList2WorkflowViewElementList(droppedObjects);
                DragDropHelper.SetDragDropMovedViewElements(e, movedViewElements);

                //Backward compatibility for 4.0
                if (droppedObjects.Count == 1 && movedViewElements.Count == 1)
                {
                    #pragma warning disable 618
                    DragDropHelper.SetDragDropCompletedEffects(e, DragDropEffects.Move);
                    #pragma warning restore 618
                }
            }
            else
            {
                Fx.Assert(droppedObjects.Count == 1, "Dropping from Toolbox with count != 1");

                // Set focus if it is dropping from ToolBox.
                // In common drag/drop, the selection setting is done at the end of
                // StartDragging().
                if (this.Item == null)
                {
                    return(true);
                }

                Fx.Assert(typeof(Sequence).IsAssignableFrom(this.Item.ItemType),
                          "Auto Wrap didn't add a sequence. Is Item.Properties[\"Activities\"] still correct?");
                foreach (ModelItem item in this.Item.Properties["Activities"].Collection)
                {
                    // Find the ModelItem whose value is an activity from Toolbox.
                    if (item.GetCurrentValue() == droppedObjects[0])
                    {
                        this.Dispatcher.BeginInvoke(DispatcherPriority.ApplicationIdle, (Action)(() =>
                        {
                            item.Focus();
                        }));
                        break;
                    }
                }
            }

            return(true);
        }