Example #1
0
        protected override bool OnMouseMove(MouseEventArgs eventArgs)
        {
            Point        empty       = Point.Empty;
            WorkflowView parentView  = base.ParentView;
            Point        clientPoint = new Point(eventArgs.X, eventArgs.Y);

            if ((parentView != null) && parentView.IsClientPointInActiveLayout(clientPoint))
            {
                Point editPoint = parentView.ClientPointToLogical(clientPoint);
                if ((eventArgs.Button & MouseButtons.Left) == MouseButtons.Left)
                {
                    if ((!this.EditingInProgress && this.initialDragPoint.HasValue) && ((Math.Abs((int)(this.initialDragPoint.Value.X - editPoint.X)) > SystemInformation.DragSize.Width) || (Math.Abs((int)(this.initialDragPoint.Value.Y - editPoint.Y)) > SystemInformation.DragSize.Height)))
                    {
                        ConnectorEditor connectorEditor = this.GetConnectorEditor(this.initialDragPoint.Value, this.dragPointHitInfo);
                        this.BeginEditing(connectorEditor, this.initialDragPoint.Value);
                    }
                    if (this.EditingInProgress)
                    {
                        this.ContinueEditing(editPoint);
                        if (this.SnappedConnectionPoint != null)
                        {
                            editPoint = this.SnappedConnectionPoint.Location;
                        }
                    }
                }
                else
                {
                    FreeformActivityDesigner connectorContainer = GetConnectorContainer(base.MessageHitTestContext.AssociatedDesigner);
                    this.ConnectablePoints = ((connectorContainer != null) && connectorContainer.EnableUserDrawnConnectors) ? GetHighlightableConnectionPoints(editPoint, base.MessageHitTestContext.AssociatedDesigner) : null;
                }
                empty = editPoint;
            }
            return(this.EditingInProgress | this.UpdateCursor(new Point?(empty)));
        }
Example #2
0
        protected override bool OnMouseDown(MouseEventArgs eventArgs)
        {
            Point empty = Point.Empty;

            if ((eventArgs.Button & MouseButtons.Left) == MouseButtons.Left)
            {
                WorkflowView parentView  = base.ParentView;
                Point        clientPoint = new Point(eventArgs.X, eventArgs.Y);
                if ((parentView != null) && parentView.IsClientPointInActiveLayout(clientPoint))
                {
                    Point editPoint = parentView.ClientPointToLogical(clientPoint);
                    if (this.CanBeginEditing(editPoint, base.MessageHitTestContext))
                    {
                        this.initialDragPoint = new Point?(editPoint);
                        this.dragPointHitInfo = base.MessageHitTestContext;
                    }
                    empty = editPoint;
                }
            }
            else
            {
                this.EndEditing(null);
            }
            return(this.initialDragPoint.HasValue | this.UpdateCursor(new Point?(empty)));
        }
        protected override bool OnDragOver(DragEventArgs eventArgs)
        {
            //Invalidate the dragged images
            if (this.draggedDesignerImages != null)
            {
                Point[] previousLocations = GetDesignerLocations(DragInitiationPoint, this.movedDesignerImagePoint, DraggedActivities);
                InvalidateDraggedImages(previousLocations);
            }

            bool retVal = base.OnDragOver(eventArgs);

            if (this.draggedDesignerImages != null)
            {
                WorkflowView parentView   = ParentView;
                Point        clientPoint  = parentView.PointToClient(new Point(eventArgs.X, eventArgs.Y));
                Point        logicalPoint = parentView.ScreenPointToLogical(new Point(eventArgs.X, eventArgs.Y));

                if (parentView.IsClientPointInActiveLayout(clientPoint))
                {
                    this.movedDesignerImagePoint = logicalPoint;
                }
                else
                {
                    this.movedDesignerImagePoint = DragInitiationPoint;
                }

                //Invalidate the new locations where the image is shown
                Point[] newLocations = GetDesignerLocations(DragInitiationPoint, this.movedDesignerImagePoint, DraggedActivities);
                InvalidateDraggedImages(newLocations);
            }
            return(retVal);
        }
        protected override bool OnScroll(ScrollBar sender, int value)
        {
            if (this.draggedDesignerImages != null)
            {
                Point[] previousLocations = GetDesignerLocations(DragInitiationPoint, this.movedDesignerImagePoint, DraggedActivities);
                InvalidateDraggedImages(previousLocations);
            }

            bool retVal = base.OnScroll(sender, value);

            if (this.draggedDesignerImages != null)
            {
                WorkflowView parentView   = ParentView;
                Point        clientPoint  = parentView.PointToClient(Control.MousePosition);
                Point        logicalPoint = parentView.ScreenPointToLogical(Control.MousePosition);

                if (parentView.IsClientPointInActiveLayout(clientPoint))
                {
                    this.movedDesignerImagePoint = logicalPoint;
                }
                else
                {
                    this.movedDesignerImagePoint = DragInitiationPoint;
                }

                //Invalidate the new locations where the image is shown
                Point[] newLocations = GetDesignerLocations(DragInitiationPoint, this.movedDesignerImagePoint, DraggedActivities);
                InvalidateDraggedImages(newLocations);
            }

            return(retVal);
        }
Example #5
0
        protected override bool OnMouseDown(MouseEventArgs eventArgs)
        {
            Point cursorPoint = Point.Empty;

            //Check if we can start editing
            if ((eventArgs.Button & MouseButtons.Left) == MouseButtons.Left)
            {
                WorkflowView workflowView = ParentView;
                Point        clientPoint  = new Point(eventArgs.X, eventArgs.Y);

                //If the point is not in clickable area then return
                if (workflowView != null && workflowView.IsClientPointInActiveLayout(clientPoint))
                {
                    Point logicalPoint = workflowView.ClientPointToLogical(clientPoint);
                    if (CanBeginEditing(logicalPoint, MessageHitTestContext))
                    {
                        this.initialDragPoint = new Point?(logicalPoint);
                        this.dragPointHitInfo = MessageHitTestContext;
                    }
                    cursorPoint = logicalPoint;
                }
            }
            else
            {
                EndEditing(null);
            }

            //Update the cursor
            bool processedMessage = (this.initialDragPoint != null);

            processedMessage |= UpdateCursor(cursorPoint);
            return(processedMessage);
        }
Example #6
0
        protected override bool OnMouseUp(MouseEventArgs eventArgs)
        {
            //If left button is not down then return
            Point cursorPoint      = Point.Empty;
            bool  processedMessage = EditingInProgress;

            if ((eventArgs.Button & MouseButtons.Left) == MouseButtons.Left)
            {
                WorkflowView workflowView = ParentView;
                Point        clientPoint  = new Point(eventArgs.X, eventArgs.Y);
                if (workflowView != null && workflowView.IsClientPointInActiveLayout(clientPoint))
                {
                    Point logicalPoint = workflowView.ClientPointToLogical(clientPoint);
                    if (EditingInProgress)
                    {
                        EndEditing(logicalPoint);
                    }
                    cursorPoint = logicalPoint;
                }
            }

            //Make sure that whenever the mouse button is up we end the editing mode and update the cursor correctly
            EndEditing(null);
            processedMessage |= UpdateCursor(cursorPoint);
            return(processedMessage);
        }
Example #7
0
        protected override bool OnScroll(ScrollBar sender, int value)
        {
            if (this.draggedDesignerImages != null)
            {
                Point[] locations = GetDesignerLocations(base.DragInitiationPoint, this.movedDesignerImagePoint, base.DraggedActivities);
                this.InvalidateDraggedImages(locations);
            }
            bool flag = base.OnScroll(sender, value);

            if (this.draggedDesignerImages != null)
            {
                WorkflowView parentView  = base.ParentView;
                Point        clientPoint = parentView.PointToClient(Control.MousePosition);
                Point        point2      = parentView.ScreenPointToLogical(Control.MousePosition);
                if (parentView.IsClientPointInActiveLayout(clientPoint))
                {
                    this.movedDesignerImagePoint = point2;
                }
                else
                {
                    this.movedDesignerImagePoint = base.DragInitiationPoint;
                }
                Point[] pointArray2 = GetDesignerLocations(base.DragInitiationPoint, this.movedDesignerImagePoint, base.DraggedActivities);
                this.InvalidateDraggedImages(pointArray2);
            }
            return(flag);
        }
Example #8
0
        protected override bool OnDragOver(DragEventArgs eventArgs)
        {
            if (this.draggedDesignerImages != null)
            {
                Point[] locations = GetDesignerLocations(base.DragInitiationPoint, this.movedDesignerImagePoint, base.DraggedActivities);
                this.InvalidateDraggedImages(locations);
            }
            bool flag = base.OnDragOver(eventArgs);

            if (this.draggedDesignerImages != null)
            {
                WorkflowView parentView  = base.ParentView;
                Point        clientPoint = parentView.PointToClient(new Point(eventArgs.X, eventArgs.Y));
                Point        point2      = parentView.ScreenPointToLogical(new Point(eventArgs.X, eventArgs.Y));
                if (parentView.IsClientPointInActiveLayout(clientPoint))
                {
                    this.movedDesignerImagePoint = point2;
                }
                else
                {
                    this.movedDesignerImagePoint = base.DragInitiationPoint;
                }
                Point[] pointArray2 = GetDesignerLocations(base.DragInitiationPoint, this.movedDesignerImagePoint, base.DraggedActivities);
                this.InvalidateDraggedImages(pointArray2);
            }
            return(flag);
        }
Example #9
0
        protected override bool OnMouseMove(MouseEventArgs eventArgs)
        {
            Debug.Assert(this.dropTargetDesigner == null);

            WorkflowView parentView  = ParentView;
            Point        clientPoint = new Point(eventArgs.X, eventArgs.Y);

            //If the point is not a valid point on layout then return
            if (!parentView.IsClientPointInActiveLayout(clientPoint))
            {
                return(false);
            }

            if (eventArgs.Button == MouseButtons.Left)
            {
                Point       logicalPoint = parentView.ClientPointToLogical(clientPoint);
                HitTestInfo hitTestInfo  = MessageHitTestContext;

                if (this.draggedDesigner != null)
                {
                    ((IWorkflowDesignerMessageSink)this.draggedDesigner).OnMouseDragMove(eventArgs);
                }
                else if (parentView.RootDesigner != null && this.dragStarted && (eventArgs.Button & MouseButtons.Left) > 0 && (Math.Abs(this.dragInitiationPoint.X - logicalPoint.X) > SystemInformation.DragSize.Width || Math.Abs(this.dragInitiationPoint.Y - logicalPoint.Y) > SystemInformation.DragSize.Height))
                {
                    //Test if the mouse click was on the designer
                    ActivityDesigner potentialDraggedDesigner = hitTestInfo.AssociatedDesigner;
                    if (potentialDraggedDesigner != null)
                    {
                        //If we can intitiate the drag then do so otherwise just indicate that the designer isbeing dragged
                        if (CanInitiateDragDrop())
                        {
                            InitiateDragDrop();
                            this.dragStarted = false;
                        }
                        else
                        {
                            this.draggedDesigner = potentialDraggedDesigner;
                            ((IWorkflowDesignerMessageSink)this.draggedDesigner).OnMouseDragBegin(this.dragInitiationPoint, eventArgs);
                            parentView.Capture = true;
                        }
                    }
                }
            }
            else
            {
                if (this.draggedDesigner != null)
                {
                    ((IWorkflowDesignerMessageSink)this.draggedDesigner).OnMouseDragEnd();
                }
                this.draggedDesigner = null;
            }

            return(this.draggedDesigner != null);
        }
        protected override bool OnMouseDown(MouseEventArgs eventArgs)
        {
            WorkflowView parentView  = base.ParentView;
            Point        clientPoint = new Point(eventArgs.X, eventArgs.Y);

            if (parentView.IsClientPointInActiveLayout(clientPoint) && (eventArgs.Button == MouseButtons.Left))
            {
                this.dragInitiationPoint = parentView.ClientPointToLogical(clientPoint);
                this.dragStarted         = true;
            }
            return(false);
        }
        protected override bool OnDragOver(DragEventArgs eventArgs)
        {
            WorkflowView parentView = base.ParentView;

            if (parentView.IsClientPointInActiveLayout(parentView.PointToClient(new Point(eventArgs.X, eventArgs.Y))))
            {
                this.SetAutoExpandableDesigner(parentView.MessageHitTestContext.AssociatedDesigner as CompositeActivityDesigner);
            }
            else
            {
                this.SetAutoExpandableDesigner(null);
            }
            return(false);
        }
Example #12
0
        protected override bool OnMouseDown(MouseEventArgs eventArgs)
        {
            Point        clientPoint = new Point(eventArgs.X, eventArgs.Y);
            WorkflowView parentView  = base.ParentView;

            if (!parentView.IsClientPointInActiveLayout(clientPoint))
            {
                return(true);
            }
            object activity = null;

            System.Workflow.ComponentModel.Design.HitTestInfo messageHitTestContext = base.MessageHitTestContext;
            if (messageHitTestContext == System.Workflow.ComponentModel.Design.HitTestInfo.Nowhere)
            {
                activity = parentView.RootDesigner.Activity;
            }
            else
            {
                activity = messageHitTestContext.SelectableObject;
            }
            if (activity != null)
            {
                ISelectionService service = base.GetService(typeof(ISelectionService)) as ISelectionService;
                if (service != null)
                {
                    service.SetSelectedComponents(new object[] { activity }, SelectionTypes.Click);
                }
            }
            if (this.currentActiveDesigner != messageHitTestContext.AssociatedDesigner)
            {
                if (this.currentActiveDesigner != null)
                {
                    ((IWorkflowDesignerMessageSink)this.currentActiveDesigner).OnMouseLeave();
                }
                this.currentActiveDesigner = messageHitTestContext.AssociatedDesigner;
                if (this.currentActiveDesigner != null)
                {
                    ((IWorkflowDesignerMessageSink)this.currentActiveDesigner).OnMouseEnter(eventArgs);
                }
            }
            if ((this.currentActiveDesigner != null) && ((Control.ModifierKeys & (Keys.Control | Keys.Shift)) == Keys.None))
            {
                ((IWorkflowDesignerMessageSink)this.currentActiveDesigner).OnMouseDown(eventArgs);
            }
            return(false);
        }
        protected override bool OnMouseMove(MouseEventArgs eventArgs)
        {
            WorkflowView parentView  = base.ParentView;
            Point        clientPoint = new Point(eventArgs.X, eventArgs.Y);

            if (!parentView.IsClientPointInActiveLayout(clientPoint))
            {
                return(false);
            }
            if (eventArgs.Button == MouseButtons.Left)
            {
                Point point2 = parentView.ClientPointToLogical(clientPoint);
                System.Workflow.ComponentModel.Design.HitTestInfo messageHitTestContext = base.MessageHitTestContext;
                if (this.draggedDesigner != null)
                {
                    ((IWorkflowDesignerMessageSink)this.draggedDesigner).OnMouseDragMove(eventArgs);
                }
                else if ((((parentView.RootDesigner != null) && this.dragStarted) && ((eventArgs.Button & MouseButtons.Left) > MouseButtons.None)) && ((Math.Abs((int)(this.dragInitiationPoint.X - point2.X)) > SystemInformation.DragSize.Width) || (Math.Abs((int)(this.dragInitiationPoint.Y - point2.Y)) > SystemInformation.DragSize.Height)))
                {
                    ActivityDesigner associatedDesigner = messageHitTestContext.AssociatedDesigner;
                    if (associatedDesigner != null)
                    {
                        if (this.CanInitiateDragDrop())
                        {
                            this.InitiateDragDrop();
                            this.dragStarted = false;
                        }
                        else
                        {
                            this.draggedDesigner = associatedDesigner;
                            ((IWorkflowDesignerMessageSink)this.draggedDesigner).OnMouseDragBegin(this.dragInitiationPoint, eventArgs);
                            parentView.Capture = true;
                        }
                    }
                }
            }
            else
            {
                if (this.draggedDesigner != null)
                {
                    ((IWorkflowDesignerMessageSink)this.draggedDesigner).OnMouseDragEnd();
                }
                this.draggedDesigner = null;
            }
            return(this.draggedDesigner != null);
        }
Example #14
0
        protected override bool OnMouseMove(MouseEventArgs eventArgs)
        {
            Point        cursorPoint  = Point.Empty;
            WorkflowView workflowView = ParentView;
            Point        clientPoint  = new Point(eventArgs.X, eventArgs.Y);

            if (workflowView != null && workflowView.IsClientPointInActiveLayout(clientPoint))
            {
                Point logicalPoint = workflowView.ClientPointToLogical(clientPoint);

                if ((eventArgs.Button & MouseButtons.Left) == MouseButtons.Left)
                {
                    //Check if we can start editing a connector
                    if (!EditingInProgress && this.initialDragPoint != null &&
                        (Math.Abs(this.initialDragPoint.Value.X - logicalPoint.X) > SystemInformation.DragSize.Width ||
                         Math.Abs(this.initialDragPoint.Value.Y - logicalPoint.Y) > SystemInformation.DragSize.Height))
                    {
                        BeginEditing(GetConnectorEditor(this.initialDragPoint.Value, this.dragPointHitInfo), this.initialDragPoint.Value);
                    }

                    //If the editing is in progress then pump the messages to the edited connector
                    if (EditingInProgress)
                    {
                        ContinueEditing(logicalPoint);
                        if (SnappedConnectionPoint != null)
                        {
                            logicalPoint = SnappedConnectionPoint.Location;
                        }
                    }
                }
                else
                {
                    //Show the points from where we can start drawing connectors
                    FreeformActivityDesigner connectorContainer = ConnectionManager.GetConnectorContainer(MessageHitTestContext.AssociatedDesigner);
                    ConnectablePoints = (connectorContainer != null && connectorContainer.EnableUserDrawnConnectors) ? GetHighlightableConnectionPoints(logicalPoint, MessageHitTestContext.AssociatedDesigner) : null;
                }

                cursorPoint = logicalPoint;
            }

            bool processedMessage = EditingInProgress;

            processedMessage |= UpdateCursor(cursorPoint);
            return(processedMessage);
        }
Example #15
0
        protected override bool OnMouseEnter(MouseEventArgs eventArgs)
        {
            Point        empty       = Point.Empty;
            Point        clientPoint = new Point(eventArgs.X, eventArgs.Y);
            WorkflowView parentView  = base.ParentView;

            if (((parentView != null) && parentView.IsClientPointInActiveLayout(clientPoint)) && !this.EditingInProgress)
            {
                FreeformActivityDesigner connectorContainer = GetConnectorContainer(base.MessageHitTestContext.AssociatedDesigner);
                if ((connectorContainer != null) && connectorContainer.EnableUserDrawnConnectors)
                {
                    Point currentPoint = parentView.ClientPointToLogical(clientPoint);
                    this.ConnectablePoints = GetHighlightableConnectionPoints(currentPoint, base.MessageHitTestContext.AssociatedDesigner);
                    empty = currentPoint;
                }
            }
            return(this.UpdateCursor(new Point?(empty)));
        }
Example #16
0
        protected override bool OnDragEnter(DragEventArgs eventArgs)
        {
            bool flag = base.OnDragEnter(eventArgs);

            if (this.draggedDesignerImages == null)
            {
                WorkflowView parentView  = base.ParentView;
                Point        clientPoint = parentView.PointToClient(new Point(eventArgs.X, eventArgs.Y));
                Point        point2      = parentView.ScreenPointToLogical(new Point(eventArgs.X, eventArgs.Y));
                if (parentView.IsClientPointInActiveLayout(clientPoint))
                {
                    this.movedDesignerImagePoint = point2;
                    return(flag);
                }
                this.movedDesignerImagePoint = base.DragInitiationPoint;
            }
            return(flag);
        }
        protected override bool OnDragEnter(DragEventArgs eventArgs)
        {
            bool retVal = base.OnDragEnter(eventArgs);

            if (this.draggedDesignerImages == null)
            {
                WorkflowView parentView   = ParentView;
                Point        clientPoint  = parentView.PointToClient(new Point(eventArgs.X, eventArgs.Y));
                Point        logicalPoint = parentView.ScreenPointToLogical(new Point(eventArgs.X, eventArgs.Y));
                if (parentView.IsClientPointInActiveLayout(clientPoint))
                {
                    this.movedDesignerImagePoint = logicalPoint;
                }
                else
                {
                    this.movedDesignerImagePoint = DragInitiationPoint;
                }
            }

            return(retVal);
        }
        protected override bool OnMouseDown(MouseEventArgs eventArgs)
        {
            Debug.Assert(this.draggedDesigner == null);
            Debug.Assert(this.dropTargetDesigner == null);

            WorkflowView parentView = ParentView;
            Point clientPoint = new Point(eventArgs.X, eventArgs.Y);

            //If the point is not a valid point on layout then return
            if (!parentView.IsClientPointInActiveLayout(clientPoint))
                return false;

            //Cache the point where the mouse was clicked
            if (eventArgs.Button == MouseButtons.Left)
            {
                this.dragInitiationPoint = parentView.ClientPointToLogical(clientPoint);
                this.dragStarted = true;
            }

            return false;
        }
Example #19
0
        protected override bool OnMouseUp(MouseEventArgs eventArgs)
        {
            Point empty             = Point.Empty;
            bool  editingInProgress = this.EditingInProgress;

            if ((eventArgs.Button & MouseButtons.Left) == MouseButtons.Left)
            {
                WorkflowView parentView  = base.ParentView;
                Point        clientPoint = new Point(eventArgs.X, eventArgs.Y);
                if ((parentView != null) && parentView.IsClientPointInActiveLayout(clientPoint))
                {
                    Point point3 = parentView.ClientPointToLogical(clientPoint);
                    if (this.EditingInProgress)
                    {
                        this.EndEditing(new Point?(point3));
                    }
                    empty = point3;
                }
            }
            this.EndEditing(null);
            return(editingInProgress | this.UpdateCursor(new Point?(empty)));
        }
Example #20
0
        protected override bool OnMouseEnter(MouseEventArgs eventArgs)
        {
            Point        cursorPoint  = Point.Empty;
            Point        clientPoint  = new Point(eventArgs.X, eventArgs.Y);
            WorkflowView workflowView = ParentView;

            if (workflowView != null && workflowView.IsClientPointInActiveLayout(clientPoint) && !EditingInProgress)
            {
                //Highlight the connection points to indicate where user can start drawing connectors
                FreeformActivityDesigner connectorContainer = ConnectionManager.GetConnectorContainer(MessageHitTestContext.AssociatedDesigner);
                if (connectorContainer != null && connectorContainer.EnableUserDrawnConnectors)
                {
                    Point logicalPoint = workflowView.ClientPointToLogical(clientPoint);
                    ConnectablePoints = GetHighlightableConnectionPoints(logicalPoint, MessageHitTestContext.AssociatedDesigner);
                    cursorPoint       = logicalPoint;
                }
            }

            bool processedMessage = UpdateCursor(cursorPoint);

            return(processedMessage);
        }
Example #21
0
        protected override bool OnDragDrop(DragEventArgs eventArgs)
        {
            //Invalidate the entire rectangle so that we draw active placement glyphs on connectors
            WorkflowView parentView = ParentView;

            parentView.InvalidateClientRectangle(Rectangle.Empty);

            //By default we do not allow any drag drop operation
            eventArgs.Effect = DragDropEffects.None;

            DestroyDragFeedbackImages();

            //Get the coordinates
            Point clientPoint  = parentView.PointToClient(new Point(eventArgs.X, eventArgs.Y));
            Point logicalPoint = parentView.ScreenPointToLogical(new Point(eventArgs.X, eventArgs.Y));

            //Now we check if the drag drop was in any valid area, if not then do not proceed further
            if (!parentView.IsClientPointInActiveLayout(clientPoint))
            {
                if (this.dropTargetDesigner != null)
                {
                    ((IWorkflowDesignerMessageSink)this.dropTargetDesigner).OnDragLeave();
                }
                this.wasCtrlKeyPressed  = false;
                this.dropTargetDesigner = null;
                this.draggedActivities.Clear();
                return(false);
            }

            //Now we have a potential for successful drag drop, so construct drag event arguments with logical coordinates
            this.wasCtrlKeyPressed = ((eventArgs.KeyState & 8) == 8);
            ActivityDragEventArgs dragdropEventArgs = new ActivityDragEventArgs(eventArgs, this.dragInitiationPoint, logicalPoint, this.draggedActivities);

            //Now check which designer is under the cursor, if we have the same designer as the old one
            //If not then we set the new one as drop target and pump in messages
            HitTestInfo hitTestInfo = MessageHitTestContext;

            if (this.dropTargetDesigner != hitTestInfo.AssociatedDesigner)
            {
                if (this.dropTargetDesigner != null)
                {
                    ((IWorkflowDesignerMessageSink)this.dropTargetDesigner).OnDragLeave();
                    this.dropTargetDesigner = null;
                }

                if (hitTestInfo.AssociatedDesigner != null)
                {
                    this.dropTargetDesigner = hitTestInfo.AssociatedDesigner;
                    if (this.dropTargetDesigner != null)
                    {
                        ((IWorkflowDesignerMessageSink)this.dropTargetDesigner).OnDragEnter(dragdropEventArgs);
                    }
                }
            }

            //We now have appropriate droptarget designer
            try
            {
                if (this.dropTargetDesigner != null)
                {
                    //We do not allow recursive drag and drop
                    if (!this.wasCtrlKeyPressed && IsRecursiveDropOperation(this.dropTargetDesigner) ||
                        (this.dropTargetDesigner is CompositeActivityDesigner && !((CompositeActivityDesigner)this.dropTargetDesigner).IsEditable))
                    {
                        ((IWorkflowDesignerMessageSink)this.dropTargetDesigner).OnDragLeave();
                        dragdropEventArgs.Effect = DragDropEffects.None;
                    }
                    else
                    {
                        // IMPORTANT: Don't use draggedActivities variable, because components which are
                        // there may not be created using the assembly references  added to ITypeResultionService
                        // this.workflowView.time the components will be created using the assembly references got added to the project
                        List <Activity> droppedActivities      = new List <Activity>();
                        string          transactionDescription = SR.GetString(SR.DragDropActivities);

                        //This means that we are trying to move activities so we use the same activities for drop
                        if (!this.wasCtrlKeyPressed && this.existingDraggedActivities.Count > 0)
                        {
                            droppedActivities.AddRange(this.existingDraggedActivities);
                            if (droppedActivities.Count > 1)
                            {
                                transactionDescription = SR.GetString(SR.MoveMultipleActivities, droppedActivities.Count);
                            }
                            else if (droppedActivities.Count == 1)
                            {
                                transactionDescription = SR.GetString(SR.MoveSingleActivity, droppedActivities[0].GetType());
                            }
                        }
                        else
                        {
                            droppedActivities.AddRange(CompositeActivityDesigner.DeserializeActivitiesFromDataObject(ParentView, eventArgs.Data, true));
                            if (droppedActivities.Count > 0)
                            {
                                transactionDescription = SR.GetString(SR.CreateActivityFromToolbox, droppedActivities[0].GetType());
                            }
                        }

                        //Now that we have what needs to be dropped, we start the actual drag and drop
                        IDesignerHost       designerHost = GetService(typeof(IDesignerHost)) as IDesignerHost;
                        DesignerTransaction transaction  = null;
                        if (droppedActivities.Count > 0)
                        {
                            transaction = designerHost.CreateTransaction(transactionDescription);
                        }

                        dragdropEventArgs = new ActivityDragEventArgs(eventArgs, this.dragInitiationPoint, logicalPoint, droppedActivities);

                        try
                        {
                            ((IWorkflowDesignerMessageSink)this.dropTargetDesigner).OnDragDrop(dragdropEventArgs);

                            if (dragdropEventArgs.Effect == DragDropEffects.Move)
                            {
                                this.existingDraggedActivities.Clear();
                            }

                            if (transaction != null)
                            {
                                transaction.Commit();
                            }
                        }
                        catch (Exception e)
                        {
                            if (transaction != null)
                            {
                                transaction.Cancel();
                            }
                            throw e;
                        }

                        //We deserialize the designers and try to store the designer states
                        if (droppedActivities.Count > 0)
                        {
                            Stream componentStateStream = eventArgs.Data.GetData(DragDropManager.CF_DESIGNERSTATE) as Stream;
                            if (componentStateStream != null)
                            {
                                Helpers.DeserializeDesignersFromStream(droppedActivities, componentStateStream);
                            }

                            //Set the current selection
                            ISelectionService selectionService = (ISelectionService)GetService(typeof(ISelectionService));
                            if (selectionService != null)
                            {
                                selectionService.SetSelectedComponents(droppedActivities, SelectionTypes.Replace);
                            }
                        }

                        //Active the design surface
                        if (designerHost != null)
                        {
                            designerHost.Activate();
                        }
                    }
                }
            }
            catch (Exception ex)
            {
                //We purposely consume application thrown exception which are result of user cancelling the action
                //during dragdrop where we popup UI Wizards during drag drop. Ref: InvokeWebService
                ((IWorkflowDesignerMessageSink)this.dropTargetDesigner).OnDragLeave();
                dragdropEventArgs.Effect = DragDropEffects.None;

                string dragDropException = ex.Message;
                if (ex.InnerException != null && !String.IsNullOrEmpty(ex.InnerException.Message))
                {
                    dragDropException = ex.InnerException.Message;
                }

                string errorMessage = DR.GetString(DR.Error_FailedToDeserializeComponents);
                errorMessage += "\r\n" + DR.GetString(DR.Error_Reason, dragDropException);
                DesignerHelpers.ShowError(ParentView, errorMessage);

                if (ex != CheckoutException.Canceled)
                {
                    throw new Exception(errorMessage, ex);
                }
            }
            finally
            {
                //Make sure that mouse over designer is set to null
                this.wasCtrlKeyPressed = false;
                this.draggedActivities.Clear();
                this.dropTargetDesigner  = null;
                this.exceptionInDragDrop = false;
                eventArgs.Effect         = dragdropEventArgs.Effect;
            }

            return(true);
        }
Example #22
0
        protected override bool OnDragOver(DragEventArgs eventArgs)
        {
            //By default we do not allow any drag drop operation
            eventArgs.Effect       = DragDropEffects.None;
            this.wasCtrlKeyPressed = false;
            this.dragImageSnapped  = false;

            //Get the coordinates
            WorkflowView parentView   = ParentView;
            Point        clientPoint  = parentView.PointToClient(new Point(eventArgs.X, eventArgs.Y));
            Point        logicalPoint = parentView.ScreenPointToLogical(new Point(eventArgs.X, eventArgs.Y));

            //Update the drag image position
            Point oldDragImagePoint = this.dragImagePointInClientCoOrd;

            this.dragImagePointInClientCoOrd = new Point(clientPoint.X + SystemInformation.CursorSize.Width / 4, clientPoint.Y + SystemInformation.CursorSize.Height / 4);

            //Now check if the drag point is in active layout if not then clear the designer
            if (!parentView.IsClientPointInActiveLayout(clientPoint))
            {
                if (this.dropTargetDesigner != null)
                {
                    ((IWorkflowDesignerMessageSink)this.dropTargetDesigner).OnDragLeave();
                }
                this.dropTargetDesigner = null;
            }
            else
            {
                //Now we have a potential for successful drag drop, so construct drag event arguments with logical coordinates
                this.wasCtrlKeyPressed = ((eventArgs.KeyState & 8) == 8);
                ActivityDragEventArgs dragdropEventArgs = new ActivityDragEventArgs(eventArgs, this.dragInitiationPoint, logicalPoint, this.draggedActivities);

                //Now check which designer is under the cursor, if there is no designer then we return
                HitTestInfo      hitTestInfo = MessageHitTestContext;
                ActivityDesigner potentialDropTargetDesigner = hitTestInfo.AssociatedDesigner;
                if (potentialDropTargetDesigner != null)
                {
                    CompositeActivityDesigner compositeDesigner = potentialDropTargetDesigner as CompositeActivityDesigner;
                    if ((!this.wasCtrlKeyPressed && IsRecursiveDropOperation(potentialDropTargetDesigner)) ||
                        (compositeDesigner != null && !compositeDesigner.IsEditable))
                    {
                        dragdropEventArgs.Effect    = DragDropEffects.None;
                        potentialDropTargetDesigner = null;
                    }
                }

                //If the designers differ then send appropriate messages
                if (this.dropTargetDesigner != potentialDropTargetDesigner)
                {
                    if (this.dropTargetDesigner != null)
                    {
                        ((IWorkflowDesignerMessageSink)this.dropTargetDesigner).OnDragLeave();
                    }

                    this.dropTargetDesigner = potentialDropTargetDesigner;

                    if (this.dropTargetDesigner != null)
                    {
                        ((IWorkflowDesignerMessageSink)this.dropTargetDesigner).OnDragEnter(dragdropEventArgs);
                    }
                }
                else
                {
                    //Looks like we got the same designer
                    if (this.dropTargetDesigner != null)
                    {
                        ((IWorkflowDesignerMessageSink)this.dropTargetDesigner).OnDragOver(dragdropEventArgs);
                    }

                    //Check if there is a potential for the drag image to be snapped
                    if (DragDropEffects.None != dragdropEventArgs.Effect && !dragdropEventArgs.DragImageSnapPoint.IsEmpty)
                    {
                        Point midPointInClientCoOrd = parentView.LogicalPointToClient(dragdropEventArgs.DragImageSnapPoint);
                        Size  dragImageIconSize     = parentView.LogicalSizeToClient(AmbientTheme.DragImageIconSize);
                        this.dragImagePointInClientCoOrd = new Point(midPointInClientCoOrd.X - dragImageIconSize.Width / 2, midPointInClientCoOrd.Y - dragImageIconSize.Height / 2);
                        this.dragImageSnapped            = true;
                    }
                }

                eventArgs.Effect = dragdropEventArgs.Effect;
            }

            //


            if (this.dragImage != null)
            {
                parentView.InvalidateClientRectangle(new Rectangle(oldDragImagePoint, this.dragImage.Size));
                parentView.InvalidateClientRectangle(new Rectangle(this.dragImagePointInClientCoOrd, this.dragImage.Size));
            }

            if (eventArgs.Effect == DragDropEffects.None && this.exceptionInDragDrop)
            {
                eventArgs.Effect = (this.wasCtrlKeyPressed) ? DragDropEffects.Copy : DragDropEffects.Move;
            }

            return(true);
        }
Example #23
0
        protected override bool OnDragEnter(DragEventArgs eventArgs)
        {
            //We purposely pass the DragEnter thru to the next behavior so that the WindowingBehavior can clear the
            //active designer
            Debug.Assert(this.dropTargetDesigner == null);

            //Invalidate the entire rectangle so that we draw active placement glyphs on connectors
            WorkflowView parentView = ParentView;

            parentView.InvalidateClientRectangle(Rectangle.Empty);

            //By default we do not allow any drag drop operation
            eventArgs.Effect       = DragDropEffects.None;
            this.wasCtrlKeyPressed = false;

            //Now cache the components which are getting dragged so that we don't need to create them again and again
            if (this.existingDraggedActivities.Count > 0)
            {
                this.draggedActivities.AddRange(this.existingDraggedActivities);
            }
            else
            {
                try
                {
                    Activity[] activities = CompositeActivityDesigner.DeserializeActivitiesFromDataObject(ParentView, eventArgs.Data);
                    if (activities != null)
                    {
                        this.draggedActivities.AddRange(activities);
                    }
                }
                catch
                {
                    this.exceptionInDragDrop = true;
                }
            }

            //Get the coordinates
            Point clientPoint  = parentView.PointToClient(new Point(eventArgs.X, eventArgs.Y));
            Point logicalPoint = parentView.ScreenPointToLogical(new Point(eventArgs.X, eventArgs.Y));

            //Now try to create the drag image and invalidate the area so that we can draw the dragged image
            Debug.Assert(this.dragImage == null);
            CreateDragFeedbackImages(this.draggedActivities);
            if (this.dragImage != null)
            {
                this.dragImagePointInClientCoOrd = new Point(clientPoint.X + SystemInformation.CursorSize.Width / 4, clientPoint.Y + SystemInformation.CursorSize.Height / 4);
            }

            //If the hit is not in the layouts then we need to bail out, this is very important
            if (!parentView.IsClientPointInActiveLayout(clientPoint))
            {
                return(false);
            }

            //Now we have a potential for successful drag drop, so construct drag event arguments with logical coordinates
            this.wasCtrlKeyPressed = ((eventArgs.KeyState & 8) == 8);
            ActivityDragEventArgs dragdropEventArgs = new ActivityDragEventArgs(eventArgs, this.dragInitiationPoint, logicalPoint, this.draggedActivities);

            //Now check which designer is under the cursor, if there is no designer then we return
            HitTestInfo      hitTestInfo = MessageHitTestContext;
            ActivityDesigner potentialDropTargetDesigner = hitTestInfo.AssociatedDesigner;

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

            //Now that we found a potential droptarget designer, make sure that we can start drag drop
            //If the drag drop can not be performed then return.
            if (!this.wasCtrlKeyPressed && IsRecursiveDropOperation(potentialDropTargetDesigner))
            {
                return(false);
            }

            CompositeActivityDesigner compositeDesigner = potentialDropTargetDesigner as CompositeActivityDesigner;

            if (compositeDesigner != null && !compositeDesigner.IsEditable)
            {
                return(false);
            }

            //Now that we can truely perform drag and drop operation we can pump in the message
            this.dropTargetDesigner = potentialDropTargetDesigner;
            ((IWorkflowDesignerMessageSink)this.dropTargetDesigner).OnDragEnter(dragdropEventArgs);

            //Check the return value, if this is a potential snap location then we need to snap the image
            if (!dragdropEventArgs.DragImageSnapPoint.IsEmpty)
            {
                Point midPointInClientCoOrd = parentView.LogicalPointToClient(dragdropEventArgs.DragImageSnapPoint);
                Size  dragImageIconSize     = parentView.LogicalSizeToClient(AmbientTheme.DragImageIconSize);
                this.dragImagePointInClientCoOrd = new Point(midPointInClientCoOrd.X - dragImageIconSize.Width / 2, midPointInClientCoOrd.Y - dragImageIconSize.Height / 2);
                this.dragImageSnapped            = true;
            }

            eventArgs.Effect = dragdropEventArgs.Effect;

            if (eventArgs.Effect == DragDropEffects.None && this.exceptionInDragDrop)
            {
                eventArgs.Effect = (this.wasCtrlKeyPressed) ? DragDropEffects.Copy : DragDropEffects.Move;
            }

            return(true);
        }
        protected override bool OnDragDrop(DragEventArgs eventArgs)
        {
            WorkflowView parentView = base.ParentView;

            parentView.InvalidateClientRectangle(Rectangle.Empty);
            eventArgs.Effect = DragDropEffects.None;
            this.DestroyDragFeedbackImages();
            Point clientPoint = parentView.PointToClient(new Point(eventArgs.X, eventArgs.Y));
            Point point       = parentView.ScreenPointToLogical(new Point(eventArgs.X, eventArgs.Y));

            if (!parentView.IsClientPointInActiveLayout(clientPoint))
            {
                if (this.dropTargetDesigner != null)
                {
                    ((IWorkflowDesignerMessageSink)this.dropTargetDesigner).OnDragLeave();
                }
                this.wasCtrlKeyPressed  = false;
                this.dropTargetDesigner = null;
                this.draggedActivities.Clear();
                return(false);
            }
            this.wasCtrlKeyPressed = (eventArgs.KeyState & 8) == 8;
            ActivityDragEventArgs e = new ActivityDragEventArgs(eventArgs, this.dragInitiationPoint, point, this.draggedActivities);

            System.Workflow.ComponentModel.Design.HitTestInfo messageHitTestContext = base.MessageHitTestContext;
            if (this.dropTargetDesigner != messageHitTestContext.AssociatedDesigner)
            {
                if (this.dropTargetDesigner != null)
                {
                    ((IWorkflowDesignerMessageSink)this.dropTargetDesigner).OnDragLeave();
                    this.dropTargetDesigner = null;
                }
                if (messageHitTestContext.AssociatedDesigner != null)
                {
                    this.dropTargetDesigner = messageHitTestContext.AssociatedDesigner;
                    if (this.dropTargetDesigner != null)
                    {
                        ((IWorkflowDesignerMessageSink)this.dropTargetDesigner).OnDragEnter(e);
                    }
                }
            }
            try
            {
                if (this.dropTargetDesigner != null)
                {
                    if ((!this.wasCtrlKeyPressed && this.IsRecursiveDropOperation(this.dropTargetDesigner)) || ((this.dropTargetDesigner is CompositeActivityDesigner) && !((CompositeActivityDesigner)this.dropTargetDesigner).IsEditable))
                    {
                        ((IWorkflowDesignerMessageSink)this.dropTargetDesigner).OnDragLeave();
                        e.Effect = DragDropEffects.None;
                    }
                    else
                    {
                        List <Activity> draggedActivities = new List <Activity>();
                        string          description       = SR.GetString("DragDropActivities");
                        if (!this.wasCtrlKeyPressed && (this.existingDraggedActivities.Count > 0))
                        {
                            draggedActivities.AddRange(this.existingDraggedActivities);
                            if (draggedActivities.Count > 1)
                            {
                                description = SR.GetString("MoveMultipleActivities", new object[] { draggedActivities.Count });
                            }
                            else if (draggedActivities.Count == 1)
                            {
                                description = SR.GetString("MoveSingleActivity", new object[] { draggedActivities[0].GetType() });
                            }
                        }
                        else
                        {
                            draggedActivities.AddRange(CompositeActivityDesigner.DeserializeActivitiesFromDataObject(base.ParentView, eventArgs.Data, true));
                            if (draggedActivities.Count > 0)
                            {
                                description = SR.GetString("CreateActivityFromToolbox", new object[] { draggedActivities[0].GetType() });
                            }
                        }
                        IDesignerHost       host        = base.GetService(typeof(IDesignerHost)) as IDesignerHost;
                        DesignerTransaction transaction = null;
                        if (draggedActivities.Count > 0)
                        {
                            transaction = host.CreateTransaction(description);
                        }
                        e = new ActivityDragEventArgs(eventArgs, this.dragInitiationPoint, point, draggedActivities);
                        try
                        {
                            ((IWorkflowDesignerMessageSink)this.dropTargetDesigner).OnDragDrop(e);
                            if (e.Effect == DragDropEffects.Move)
                            {
                                this.existingDraggedActivities.Clear();
                            }
                            if (transaction != null)
                            {
                                transaction.Commit();
                            }
                        }
                        catch (Exception exception)
                        {
                            if (transaction != null)
                            {
                                transaction.Cancel();
                            }
                            throw exception;
                        }
                        if (draggedActivities.Count > 0)
                        {
                            Stream data = eventArgs.Data.GetData("CF_WINOEDESIGNERCOMPONENTSSTATE") as Stream;
                            if (data != null)
                            {
                                Helpers.DeserializeDesignersFromStream(draggedActivities, data);
                            }
                            ISelectionService service = (ISelectionService)base.GetService(typeof(ISelectionService));
                            if (service != null)
                            {
                                service.SetSelectedComponents(draggedActivities, SelectionTypes.Replace);
                            }
                        }
                        if (host != null)
                        {
                            host.Activate();
                        }
                    }
                }
            }
            catch (Exception exception2)
            {
                ((IWorkflowDesignerMessageSink)this.dropTargetDesigner).OnDragLeave();
                e.Effect = DragDropEffects.None;
                string message = exception2.Message;
                if ((exception2.InnerException != null) && !string.IsNullOrEmpty(exception2.InnerException.Message))
                {
                    message = exception2.InnerException.Message;
                }
                string str3 = DR.GetString("Error_FailedToDeserializeComponents", new object[0]) + "\r\n" + DR.GetString("Error_Reason", new object[] { message });
                DesignerHelpers.ShowError(base.ParentView, str3);
                if (exception2 != CheckoutException.Canceled)
                {
                    throw new Exception(str3, exception2);
                }
            }
            finally
            {
                this.wasCtrlKeyPressed = false;
                this.draggedActivities.Clear();
                this.dropTargetDesigner  = null;
                this.exceptionInDragDrop = false;
                eventArgs.Effect         = e.Effect;
            }
            return(true);
        }
        protected override bool OnDragEnter(DragEventArgs eventArgs)
        {
            WorkflowView parentView = base.ParentView;

            parentView.InvalidateClientRectangle(Rectangle.Empty);
            eventArgs.Effect       = DragDropEffects.None;
            this.wasCtrlKeyPressed = false;
            if (this.existingDraggedActivities.Count > 0)
            {
                this.draggedActivities.AddRange(this.existingDraggedActivities);
            }
            else
            {
                try
                {
                    Activity[] collection = CompositeActivityDesigner.DeserializeActivitiesFromDataObject(base.ParentView, eventArgs.Data);
                    if (collection != null)
                    {
                        this.draggedActivities.AddRange(collection);
                    }
                }
                catch
                {
                    this.exceptionInDragDrop = true;
                }
            }
            Point clientPoint = parentView.PointToClient(new Point(eventArgs.X, eventArgs.Y));
            Point point       = parentView.ScreenPointToLogical(new Point(eventArgs.X, eventArgs.Y));

            this.CreateDragFeedbackImages(this.draggedActivities);
            if (this.dragImage != null)
            {
                this.dragImagePointInClientCoOrd = new Point(clientPoint.X + (SystemInformation.CursorSize.Width / 4), clientPoint.Y + (SystemInformation.CursorSize.Height / 4));
            }
            if (!parentView.IsClientPointInActiveLayout(clientPoint))
            {
                return(false);
            }
            this.wasCtrlKeyPressed = (eventArgs.KeyState & 8) == 8;
            ActivityDragEventArgs e = new ActivityDragEventArgs(eventArgs, this.dragInitiationPoint, point, this.draggedActivities);
            ActivityDesigner      associatedDesigner = base.MessageHitTestContext.AssociatedDesigner;

            if (associatedDesigner == null)
            {
                return(false);
            }
            if (!this.wasCtrlKeyPressed && this.IsRecursiveDropOperation(associatedDesigner))
            {
                return(false);
            }
            CompositeActivityDesigner designer2 = associatedDesigner as CompositeActivityDesigner;

            if ((designer2 != null) && !designer2.IsEditable)
            {
                return(false);
            }
            this.dropTargetDesigner = associatedDesigner;
            ((IWorkflowDesignerMessageSink)this.dropTargetDesigner).OnDragEnter(e);
            if (!e.DragImageSnapPoint.IsEmpty)
            {
                Point point3 = parentView.LogicalPointToClient(e.DragImageSnapPoint);
                Size  size   = parentView.LogicalSizeToClient(AmbientTheme.DragImageIconSize);
                this.dragImagePointInClientCoOrd = new Point(point3.X - (size.Width / 2), point3.Y - (size.Height / 2));
                this.dragImageSnapped            = true;
            }
            eventArgs.Effect = e.Effect;
            if ((eventArgs.Effect == DragDropEffects.None) && this.exceptionInDragDrop)
            {
                eventArgs.Effect = this.wasCtrlKeyPressed ? DragDropEffects.Copy : DragDropEffects.Move;
            }
            return(true);
        }
        protected override bool OnDragOver(DragEventArgs eventArgs)
        {
            eventArgs.Effect       = DragDropEffects.None;
            this.wasCtrlKeyPressed = false;
            this.dragImageSnapped  = false;
            WorkflowView parentView  = base.ParentView;
            Point        clientPoint = parentView.PointToClient(new Point(eventArgs.X, eventArgs.Y));
            Point        point       = parentView.ScreenPointToLogical(new Point(eventArgs.X, eventArgs.Y));
            Point        dragImagePointInClientCoOrd = this.dragImagePointInClientCoOrd;

            this.dragImagePointInClientCoOrd = new Point(clientPoint.X + (SystemInformation.CursorSize.Width / 4), clientPoint.Y + (SystemInformation.CursorSize.Height / 4));
            if (!parentView.IsClientPointInActiveLayout(clientPoint))
            {
                if (this.dropTargetDesigner != null)
                {
                    ((IWorkflowDesignerMessageSink)this.dropTargetDesigner).OnDragLeave();
                }
                this.dropTargetDesigner = null;
            }
            else
            {
                this.wasCtrlKeyPressed = (eventArgs.KeyState & 8) == 8;
                ActivityDragEventArgs e = new ActivityDragEventArgs(eventArgs, this.dragInitiationPoint, point, this.draggedActivities);
                ActivityDesigner      associatedDesigner = base.MessageHitTestContext.AssociatedDesigner;
                if (associatedDesigner != null)
                {
                    CompositeActivityDesigner designer2 = associatedDesigner as CompositeActivityDesigner;
                    if ((!this.wasCtrlKeyPressed && this.IsRecursiveDropOperation(associatedDesigner)) || ((designer2 != null) && !designer2.IsEditable))
                    {
                        e.Effect           = DragDropEffects.None;
                        associatedDesigner = null;
                    }
                }
                if (this.dropTargetDesigner != associatedDesigner)
                {
                    if (this.dropTargetDesigner != null)
                    {
                        ((IWorkflowDesignerMessageSink)this.dropTargetDesigner).OnDragLeave();
                    }
                    this.dropTargetDesigner = associatedDesigner;
                    if (this.dropTargetDesigner != null)
                    {
                        ((IWorkflowDesignerMessageSink)this.dropTargetDesigner).OnDragEnter(e);
                    }
                }
                else
                {
                    if (this.dropTargetDesigner != null)
                    {
                        ((IWorkflowDesignerMessageSink)this.dropTargetDesigner).OnDragOver(e);
                    }
                    if ((e.Effect != DragDropEffects.None) && !e.DragImageSnapPoint.IsEmpty)
                    {
                        Point point4 = parentView.LogicalPointToClient(e.DragImageSnapPoint);
                        Size  size   = parentView.LogicalSizeToClient(AmbientTheme.DragImageIconSize);
                        this.dragImagePointInClientCoOrd = new Point(point4.X - (size.Width / 2), point4.Y - (size.Height / 2));
                        this.dragImageSnapped            = true;
                    }
                }
                eventArgs.Effect = e.Effect;
            }
            if (this.dragImage != null)
            {
                parentView.InvalidateClientRectangle(new Rectangle(dragImagePointInClientCoOrd, this.dragImage.Size));
                parentView.InvalidateClientRectangle(new Rectangle(this.dragImagePointInClientCoOrd, this.dragImage.Size));
            }
            if ((eventArgs.Effect == DragDropEffects.None) && this.exceptionInDragDrop)
            {
                eventArgs.Effect = this.wasCtrlKeyPressed ? DragDropEffects.Copy : DragDropEffects.Move;
            }
            return(true);
        }
Example #27
0
        protected override bool OnMouseDown(MouseEventArgs eventArgs)
        {
            Point clientPoint = new Point(eventArgs.X, eventArgs.Y);

            //If the point is not in clickable area then return
            WorkflowView parentView = ParentView;

            if (!parentView.IsClientPointInActiveLayout(clientPoint))
            {
                return(true);
            }

            //Check if the mouse is hit on designer
            object      selectedObject = null;
            HitTestInfo hitTestInfo    = MessageHitTestContext;

            if (hitTestInfo == HitTestInfo.Nowhere)
            {
                selectedObject = parentView.RootDesigner.Activity;
            }
            else
            {
                selectedObject = hitTestInfo.SelectableObject;
            }

            //Selection service handles KeyModifiers, ctrl and shift will be handled as per the standard behavior
            if (selectedObject != null)
            {
                ISelectionService selectionService = GetService(typeof(ISelectionService)) as ISelectionService;
                if (selectionService != null)
                {
                    selectionService.SetSelectedComponents(new object[] { selectedObject }, SelectionTypes.Primary);
                }
            }

            //Designer designates an area as action area if there is some special significance associated with the area ie Expand Collapse
            //In such cases we give activity designer an oppertunity to take action when mouse click happens on the area
            //if there are Ctrl or Shift keys pressed, only do the selection change, dont call the child designer
            //Now that the designer is selected
            if (this.currentActiveDesigner != hitTestInfo.AssociatedDesigner)
            {
                if (this.currentActiveDesigner != null)
                {
                    ((IWorkflowDesignerMessageSink)this.currentActiveDesigner).OnMouseLeave();
                }

                this.currentActiveDesigner = hitTestInfo.AssociatedDesigner;

                if (this.currentActiveDesigner != null)
                {
                    ((IWorkflowDesignerMessageSink)this.currentActiveDesigner).OnMouseEnter(eventArgs);
                }
            }

            if (this.currentActiveDesigner != null && ((Control.ModifierKeys & (Keys.Control | Keys.Shift)) == 0))
            {
                ((IWorkflowDesignerMessageSink)this.currentActiveDesigner).OnMouseDown(eventArgs);
            }

            return(false);
        }