/// <summary>
        /// Event raised when the user starts to drag a connector.
        /// </summary>
        private void ExecutionConnectorItem_DragStarted(object source, ExecutionConnectorItemDragStartedEventArgs e)
        {
            this.Focus();

            e.Handled = true;

            this.IsDragging = true;
            this.IsNotDragging = false;
            this.IsDraggingExecutionConnection = true;
            this.IsNotDraggingExecutionConnection = false;

            this.draggedOutExecutionConnectorItem = (ExecutionConnectorItem)e.OriginalSource;
            var nodeItem = this.draggedOutExecutionConnectorItem.ParentNodeItem;
            this.draggedOutNodeDataContext = nodeItem.DataContext != null ? nodeItem.DataContext : nodeItem;
            this.draggedOutExecutionConnectorDataContext = this.draggedOutExecutionConnectorItem.DataContext != null ? this.draggedOutExecutionConnectorItem.DataContext : this.draggedOutExecutionConnectorItem;

            //
            // Raise an event so that application code can create a connection and
            // add it to the view-model.
            //
            ExecutionConnectionDragStartedEventArgs eventArgs = new ExecutionConnectionDragStartedEventArgs(ExecutionConnectionDragStartedEvent, this, this.draggedOutNodeDataContext, this.draggedOutExecutionConnectorDataContext);
            RaiseEvent(eventArgs);

            //
            // Retrieve the the view-model object for the connection was created by application code.
            //
            this.draggingExecutionConnectionDataContext = eventArgs.ExecutionConnection;

            if (draggingExecutionConnectionDataContext == null)
            {
                //
                // Application code didn't create any connection.
                //
                e.Cancel = true;
                return;
            }
        }
        /// <summary>
        /// The mouse cursor has been moved.
        /// </summary>        
        protected override void OnMouseMove(MouseEventArgs e)
        {
            base.OnMouseMove(e);

            if (isDragging)
            {
                //
                // Raise the event to notify that dragging is in progress.
                //

                Point curMousePoint = e.GetPosition(this.ParentNetworkView);
                Vector offset = curMousePoint - lastMousePoint;
                if (offset.X != 0.0 &&
                    offset.Y != 0.0)
                {
                    lastMousePoint = curMousePoint;

                    RaiseEvent(new ExecutionConnectorItemDraggingEventArgs(ExecutionConnectorDraggingEvent, this, offset.X, offset.Y));
                }

                e.Handled = true;
            }
            else if (isLeftMouseDown)
            {
                if (this.ParentNetworkView != null &&
                    this.ParentNetworkView.EnableConnectionDragging)
                {
                    //
                    // The user is left-dragging the connector and connection dragging is enabled,
                    // but don't initiate the drag operation until 
                    // the mouse cursor has moved more than the threshold distance.
                    //
                    Point curMousePoint = e.GetPosition(this.ParentNetworkView);
                    var dragDelta = curMousePoint - lastMousePoint;
                    double dragDistance = Math.Abs(dragDelta.Length);
                    if (dragDistance > DragThreshold)
                    {
                        //
                        // When the mouse has been dragged more than the threshold value commence dragging the node.
                        //

                        //
                        // Raise an event to notify that that dragging has commenced.
                        //
                        var eventArgs = new ExecutionConnectorItemDragStartedEventArgs(ExecutionConnectorDragStartedEvent, this);
                        RaiseEvent(eventArgs);

                        if (eventArgs.Cancel)
                        {
                            //
                            // Handler of the event disallowed dragging of the node.
                            //
                            isLeftMouseDown = false;
                            return;
                        }

                        isDragging = true;
                        this.CaptureMouse();
                        e.Handled = true;
                    }
                }
            }
        }