protected void OnMouseMove(object sender, MouseEventArgs e) { if (_isLeftMouseDown) { Point newNodePosition = e.GetPosition(null); UIElement uiElement = this; double newXCoord = newNodePosition.X + _nodeOffset.X; double newYCoord = newNodePosition.Y + _nodeOffset.Y; ScaleTransform scaleTransform = FindName("scaleTransform") as ScaleTransform; if (scaleTransform != null) { newXCoord = newNodePosition.X / scaleTransform.ScaleX + _nodeOffset.X; newYCoord = newNodePosition.Y / scaleTransform.ScaleY + _nodeOffset.Y; } if (!IsSelected) { foreach (INodeRenderer renderer in ParentNavigatorView.NodeRenderers.Values) { if (renderer.IsSelected && renderer.Node.Id != this.Node.Id) { renderer.IsSelected = false; } } foreach (IRelationshipRenderer relRenderer in ParentNavigatorView.RelationshipRenderers.Values) { if (relRenderer.IsSelected) { relRenderer.IsSelected = false; } } } MoveNode(new Point(newXCoord, newYCoord), false); if (NodePositionUpdating != null && _nodeDirty) { NodePositionUpdating.Invoke(this, null); } } }
public void MoveNode(Point newLocation, bool forceRelationshipUpdate) { this.SetValue(Canvas.LeftProperty, newLocation.X); this.SetValue(Canvas.TopProperty, newLocation.Y); if (!_nodeDirty) { _originalLocation = Location; } if (newLocation != Location) { _nodeDirty = true; Location = newLocation; } if (forceRelationshipUpdate) { if (NodePositionUpdating != null && _nodeDirty) { NodePositionUpdating.Invoke(this, null); } } }