Ejemplo n.º 1
0
 /// <summary>
 /// Event raised while the user is dragging a connection.
 /// </summary>
 private void networkControl_ExecutionConnectionDragging(object sender, ExecutionConnectionDraggingEventArgs e)
 {
     Point curDragPoint = Mouse.GetPosition(networkControl);
     var executionConnection = (ExecutionConnectionViewModel)e.ExecutionConnection;
     this.ViewModel.ExecutionConnectionDragging(curDragPoint, executionConnection);
 }
        /// <summary>
        /// Event raised while the user is dragging a connector.
        /// </summary>
        private void ExecutionConnectorItem_Dragging(object source, ExecutionConnectorItemDraggingEventArgs e)
        {
            e.Handled = true;

            Trace.Assert((ExecutionConnectorItem)e.OriginalSource == this.draggedOutExecutionConnectorItem);

            Point mousePoint = Mouse.GetPosition(this);
            //
            // Raise an event so that application code can compute intermediate connection points.
            //
            var executionConnectionDraggingEventArgs =
                new ExecutionConnectionDraggingEventArgs(ExecutionConnectionDraggingEvent, this,
                        this.draggedOutNodeDataContext, this.draggingExecutionConnectionDataContext,
                        this.draggedOutExecutionConnectorDataContext);

            RaiseEvent(executionConnectionDraggingEventArgs);

            //
            // Figure out if the connection has been dragged over a connector.
            //

            ExecutionConnectorItem executionConnectorDraggedOver = null;
            object executionConnectorDataContextDraggedOver = null;
            bool dragOverSuccess = DetermineExecutionConnectorItemDraggedOver(mousePoint, out executionConnectorDraggedOver, out executionConnectorDataContextDraggedOver);
            if (executionConnectorDraggedOver != null)
            {
                //
                // Raise an event so that application code can specify if the connector
                // that was dragged over is valid or not.
                //
                var queryFeedbackEventArgs =
                    new QueryExecutionConnectionFeedbackEventArgs(QueryExecutionConnectionFeedbackEvent, this, this.draggedOutNodeDataContext, this.draggingExecutionConnectionDataContext,
                            this.draggedOutExecutionConnectorDataContext, executionConnectorDataContextDraggedOver);

                RaiseEvent(queryFeedbackEventArgs);

                if (queryFeedbackEventArgs.FeedbackIndicator != null)
                {
                    //
                    // A feedback indicator was specified by the event handler.
                    // This is used to indicate whether the connection is good or bad!
                    //
                    AddFeedbackAdorner(executionConnectorDraggedOver, queryFeedbackEventArgs.FeedbackIndicator);
                }
                else
                {
                    //
                    // No feedback indicator specified by the event handler.
                    // Clear any existing feedback indicator.
                    //
                    ClearFeedbackAdorner();
                }
            }
            else
            {
                //
                // Didn't drag over any valid connector.
                // Clear any existing feedback indicator.
                //
                ClearFeedbackAdorner();
            }
        }