protected override void OnMouseMove(MouseEventArgs e) { if (e.LeftButton == MouseButtonState.Pressed) { if (_isDragging) { var currentMousePosition = e.GetPosition(ParentGraphControl); var offset = currentMousePosition - _lastMousePosition; _lastMousePosition = currentMousePosition; RaiseEvent(new ConnectorItemDraggingEventArgs(ConnectorDraggingEvent, this, offset.X, offset.Y)); } else { var eventArgs = new ConnectorItemDragStartedEventArgs(ConnectorDragStartedEvent, this); RaiseEvent(eventArgs); if (eventArgs.Cancel) { return; } _isDragging = true; CaptureMouse(); } e.Handled = true; } base.OnMouseMove(e); }
private void OnConnectorItemDragStarted(object sender, ConnectorItemDragStartedEventArgs e) { e.Handled = true; _draggingSourceConnector = (ConnectorItem)e.OriginalSource; var eventArgs = new ConnectionDragStartedEventArgs(ConnectionDragStartedEvent, this, _draggingSourceConnector.ParentElementItem, _draggingSourceConnector); RaiseEvent(eventArgs); _draggingConnectionDataContext = eventArgs.Connection; if (_draggingConnectionDataContext == null) { e.Cancel = true; } }