private void GetPathGeometry(Point position) { var sourceInfo = new PathFinder.ConnectorInfo { ConnectorPoint = this._sourceConnector.ConnectorPosition, Orientation = this._sourceConnector.Orientation, ConnectorParentX = this._sourceConnector.ParentViewModel.X, ConnectorParentY = this._sourceConnector.ParentViewModel.Y }; _pathPoints.Clear(); if (this._hitConnector == null) { _pathPoints.AddRange(PathFinder.GetConnectionLine(sourceInfo, position, ConnectorOrientation.NONE)); } else { var hitInfo = new PathFinder.ConnectorInfo { ConnectorPoint = this._hitConnector.ConnectorPosition, Orientation = this._hitConnector.Orientation, ConnectorParentX = this._hitConnector.ParentViewModel.X, ConnectorParentY = this._hitConnector.ParentViewModel.Y }; _pathPoints.AddRange(PathFinder.GetConnectionLine(sourceInfo, hitInfo)); } if (_pathPoints.Count > 0) { var pathFigure = new PathFigure { StartPoint = _pathPoints[0] }; for (int i = 1; i < _pathPoints.Count; i++) { var lineSegment = new LineSegment(_pathPoints[i], true); pathFigure.Segments.Add(lineSegment); } this._pathGeometry.Figures.Clear(); this._pathGeometry.Figures.Add(pathFigure); } }
private void GetPathGeometry(Point position) { this._currentPath = this._currentPath ?? new PathGeometry(); List <Point> pathPoints; var sourceInfo = new PathFinder.ConnectorInfo { ConnectorPoint = this._connection.SourceConnector.ConnectorPosition, Orientation = this._connection.SourceConnector.Orientation, ConnectorParentX = this._connection.SourceConnector.ParentViewModel.X, ConnectorParentY = this._connection.SourceConnector.ParentViewModel.Y }; if (this._hitConnector == null) { pathPoints = PathFinder.GetConnectionLine(sourceInfo, position, ConnectorOrientation.NONE); } else { var hitInfo = new PathFinder.ConnectorInfo { ConnectorPoint = this._hitConnector.ConnectorPosition, Orientation = this._hitConnector.Orientation, ConnectorParentX = this._hitConnector.ParentViewModel.X, ConnectorParentY = this._hitConnector.ParentViewModel.Y }; pathPoints = PathFinder.GetConnectionLine(sourceInfo, hitInfo); } if (pathPoints.Count > 0) { this._currentPath.Figures.Clear(); var figure = new PathFigure(); figure.StartPoint = pathPoints[0]; pathPoints.Remove(pathPoints[0]); figure.Segments.Add(new PolyLineSegment(pathPoints, true)); this._currentPath.Figures.Add(figure); } }