RoverOperator.Content.GPSViewViewModel.formatTargetPin C# (CSharp) Method

formatTargetPin() private method

Change the style of the target pins
private formatTargetPin ( Pushpin targetPin ) : void
targetPin Pushpin
return void
        private void formatTargetPin(Pushpin targetPin)
        {
            ToolTip tt = new ToolTip();

            //Title is not mandatory
            if (!string.IsNullOrWhiteSpace(targetTitleString))
            {
                //to enforce unique Name
                int counter = 0;

                while (String.IsNullOrWhiteSpace(targetPin.Name) && !String.IsNullOrWhiteSpace(targetTitleString))
                {
                    //Start counter at 1, stop incrementing when looping finishes
                    counter++;
                    try
                    {
                        targetPin.Name = targetTitleString.Replace(" ", "");
                    }
                    catch
                    {
                        //targetPin.Name = targetTitleString.Replace(" ", "") + "_" + counter;
                        targetPin.Name = "";
                        break;
                    }
                }

                tt.Content = targetTitleString + ": ";
            }
            else
            {
                //avoids null tooltip content.
                tt.Content = "";
            }

            tt.Content += targetPin.Location.Latitude + ", " + targetPin.Location.Longitude;
            targetPin.ToolTip = tt;

            targetPin.Background = new System.Windows.Media.SolidColorBrush(System.Windows.Media.Color.FromRgb(0, 255, 0));
        }