示例#1
0
        /// <summary>
        /// Event raised, to query for feedback, while the user is dragging a connection.
        /// </summary>
        private void networkControl_QueryExecutionConnectionFeedback(object sender, QueryExecutionConnectionFeedbackEventArgs e)
        {
            var draggedOutExecutionConnector = (ExecutionConnectorViewModel)e.ExecutionConnectorDraggedOut;
            var draggedOverExecutionConnector = (ExecutionConnectorViewModel)e.DraggedOverExecutionConnector;
            object feedbackIndicator = null;
            bool executionConnectionOk = true;

            this.ViewModel.QueryExecutionConnnectionFeedback(draggedOutExecutionConnector, draggedOverExecutionConnector, out feedbackIndicator, out executionConnectionOk);

            //
            // Return the feedback object to NetworkView.
            // The object combined with the data-template for it will be used to create a 'feedback icon' to
            // display (in an adorner) to the user.
            //
            e.FeedbackIndicator = feedbackIndicator;

            //
            // Let NetworkView know if the connection is ok or not ok.
            //
            e.ExecutionConnectionOk = executionConnectionOk;
        }
        /// <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();
            }
        }