private void OnPreviewPinMouseDown(PinViewModel pinViewModel, MouseButtonEventArgs e) { if (pinViewModel.Pin.Direction != PinDirection.Input) { _endLinkPoint = ViewModel.BeginLinkage(pinViewModel); CaptureMouse(); } else { _endLinkPoint = ViewModel.BeginRelinkage(pinViewModel); CaptureMouse(); } }
protected override void OnPreviewMouseUp(MouseButtonEventArgs e) { base.OnPreviewMouseUp(e); if (_canvasDragStartPoint != null) { ReleaseMouseCapture(); _canvasDragStartPoint = null; } var hitTestResult = VisualTreeHelper.HitTest(this, e.GetPosition(this)); var originalSource = hitTestResult.VisualHit; if (_endLinkPoint != null) { ReleaseMouseCapture(); PinViewModel pinViewModel = null; var bullet = VisualTreeUtils.FindParent <Bullet>(originalSource); if (bullet != null) { pinViewModel = VisualTreeUtils.FindDataContext <PinViewModel>(bullet); } OnPreviewPinMouseUp(pinViewModel, e); _endLinkPoint = null; } if (_nodeDraged != null) { ReleaseMouseCapture(); _nodeDraged = null; } // if (_currentRope != null) // { // var hitTestResult = VisualTreeHelper.HitTest(this, e.GetPosition(this)); // var pin = VisualTreeUtils.FindParent<Pin>(hitTestResult.VisualHit); // var ropeAdded = false; // if (pin != null) // { // if (_currentRope.EndPoint == _currentRopeFreePoint) // { // if (pin.IsInputPin) // { // if (InnerControls.OfType<Rope>().All(rope => rope.EndPoint != _pinLocations[pin])) // { // _currentRope.EndPoint = _pinLocations[pin]; // Node.Link(_sourcePin.Node, _sourcePin.NodePin, pin.Node, pin.NodePin); // pin.Node.Pulse(); // ropeAdded = true; // } // } // } // else // { // if (!pin.IsInputPin) // { // _currentRope.BeginPoint = _pinLocations[pin]; // Node.Link(pin.Node, pin.NodePin, _targetPin.Node, _targetPin.NodePin); // pin.Node.Pulse(); // ropeAdded = true; // } // } // } // // if (!ropeAdded) // { // InnerControls.Remove(_currentRope); // } // // _currentRope = null; // _currentRopeFreePoint = null; // } }
protected override void OnPreviewMouseUp(MouseButtonEventArgs e) { base.OnPreviewMouseUp(e); if (_canvasDragStartPoint != null) { ReleaseMouseCapture(); _canvasDragStartPoint = null; } var hitTestResult = VisualTreeHelper.HitTest(this, e.GetPosition(this)); var originalSource = hitTestResult.VisualHit; if (_endLinkPoint != null) { ReleaseMouseCapture(); PinViewModel pinViewModel = null; var bullet = VisualTreeUtils.FindParent<Bullet>(originalSource); if (bullet != null) { pinViewModel = VisualTreeUtils.FindDataContext<PinViewModel>(bullet); } OnPreviewPinMouseUp(pinViewModel, e); _endLinkPoint = null; } if (_nodeDraged != null) { ReleaseMouseCapture(); _nodeDraged = null; } // if (_currentRope != null) // { // var hitTestResult = VisualTreeHelper.HitTest(this, e.GetPosition(this)); // var pin = VisualTreeUtils.FindParent<Pin>(hitTestResult.VisualHit); // var ropeAdded = false; // if (pin != null) // { // if (_currentRope.EndPoint == _currentRopeFreePoint) // { // if (pin.IsInputPin) // { // if (InnerControls.OfType<Rope>().All(rope => rope.EndPoint != _pinLocations[pin])) // { // _currentRope.EndPoint = _pinLocations[pin]; // Node.Link(_sourcePin.Node, _sourcePin.NodePin, pin.Node, pin.NodePin); // pin.Node.Pulse(); // ropeAdded = true; // } // } // } // else // { // if (!pin.IsInputPin) // { // _currentRope.BeginPoint = _pinLocations[pin]; // Node.Link(pin.Node, pin.NodePin, _targetPin.Node, _targetPin.NodePin); // pin.Node.Pulse(); // ropeAdded = true; // } // } // } // // if (!ropeAdded) // { // InnerControls.Remove(_currentRope); // } // // _currentRope = null; // _currentRopeFreePoint = null; // } }