/// <summary> /// /// </summary> /// <param name="sender"></param> /// <param name="e"></param> public void OnNodeDragStarted(NetworkView sender, NodeDragStartedEventArgs e) { m_CachedNodesDraggingList.Clear(); foreach (NodeViewModel node in e.Nodes) { m_CachedNodesDraggingList.Add(new PositionNodeUndoCommand.NodeDraggingInfo { Node = node, StartX = node.X, StartY = node.Y }); } }
/// <summary> /// Event raised when the user starts to drag a node. /// </summary> private void NodeItem_DragStarted(object source, NodeDragStartedEventArgs e) { e.Handled = true; this.IsDragging = true; this.IsNotDragging = false; this.IsDraggingNode = true; this.IsNotDraggingNode = false; var eventArgs = new NodeDragStartedEventArgs(NodeDragStartedEvent, this, this.SelectedNodes); RaiseEvent(eventArgs); e.Cancel = eventArgs.Cancel; }
/// <summary> /// Called when the mouse cursor is moved. /// </summary> protected override void OnMouseMove(MouseEventArgs e) { base.OnMouseMove(e); if (isDragging) { // // Raise the event to notify that dragging is in progress. // var curMousePoint = e.GetPosition(ParentNodeView); object item = this; if (DataContext != null) { item = DataContext; } var offset = curMousePoint - lastMousePoint; if (offset.X != 0.0 || offset.Y != 0.0) { lastMousePoint = curMousePoint; RaiseEvent(new NodeDraggingEventArgs(NodeDraggingEvent, this, new[] { item }, offset.X, offset.Y)); } } else if (isLeftMouseDown && ParentNodeView.EnableNodeDragging) { // // The user is left-dragging the node, // but don't initiate the drag operation until // the mouse cursor has moved more than the threshold distance. // var curMousePoint = e.GetPosition(ParentNodeView); var dragDelta = curMousePoint - lastMousePoint; var 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. // NodeDragStartedEventArgs eventArgs = new NodeDragStartedEventArgs(NodeDragStartedEvent, this, new[] { this }); RaiseEvent(eventArgs); if (eventArgs.Cancel) { // // Handler of the event disallowed dragging of the node. // isLeftMouseDown = false; isLeftMouseAndControlDown = false; return; } isDragging = true; CaptureMouse(); e.Handled = true; } } }
/// <summary> /// /// </summary> /// <param name="sender"></param> /// <param name="e"></param> private void networkControl_NodeDragStarted(object sender, NodeDragStartedEventArgs e) { ViewModel.OnNodeDragStarted(sender as NetworkView, e); }