public void updateTargetDetails()
{
//MIGHT NEED TO USE THIS CODE IN CASE IT CRASHES SAYING ITS TRYING TO ACCES FROM ANOTHER THREAD
if (!_dispatcher.HasShutdownStarted && !_dispatcher.HasShutdownFinished)
{
_dispatcher.Invoke((Action)(() =>
{
string detail = "";
//only attempt to recalculate if there are targets
if (targetPins != null && targetPins.Count > 0 && roverPin != null && roverPin.Location != null)
{
foreach (var target in targetPins)
{
double targetLongitude = target.Location.Longitude;
double targetLatitude = target.Location.Latitude;
ToolTip tt = (ToolTip)(target.ToolTip);
string targetName = tt.Content.ToString();
//string targetLongitudeString = targetLongitude.ToString();
//string targetLatitudeString = targetLatitude.ToString();
double distance = getDistance(roverPin.Location, target.Location);
//Show the name if it has one
if (!string.IsNullOrWhiteSpace(targetName))
{
detail += targetName + ", ";
}
//else //else show the coordinates to identify it
//{
// detail += "(" + targetLongitudeString + ", " + targetLatitudeString + "), ";
//}
detail += "distance: " + distance +"km";
detail += "\n";
}
}
//Only update this once all calculations are done (or set to empty string if no targets are found), so that the property update doesnt trigger more often than needed (it would lower performance)
detailsString = detail;
}));
}
}