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

addTarget() private method

Add a target to the map (triggered by Add button)
private addTarget ( MarsRover.Location targetLocation ) : void
targetLocation MarsRover.Location
return void
        private void addTarget(Location targetLocation)
        {
            //latitude ranges from -90 to 90
            targetLocation.Latitude = latitude % 90;

            //longitude ranges from -180 to 180
            targetLocation.Longitude = longitude % 180;

            //Initialize target list
            if (targetPins == null)
            {
                targetPins = new List<Pushpin>();
            }

            // The pushpin to add to the map.
            Pushpin targetPin = new Pushpin();
            targetPin.Location = targetLocation;

            //Style the target
            formatTargetPin(targetPin);

            targetPin.MouseRightButtonUp += targetPin_MouseRightButtonUp;

            //Initialize target list
            if (targetPins == null)
            {
                targetPins = new List<Pushpin>();
            }
            targetPins.Add(targetPin);

            //Initialize the pushpin list
            if (pushPinCollection == null)
            {
                pushPinCollection = new ObservableCollection<Pushpin>();
            }
            pushPinCollection.Add(targetPin);

            updateTargetDetails();

            //reset values of the textboxes
            longitudeString = "";
            latitudeString = "";
            targetTitleString = "";

            //reset the data values
            longitude = 0;
            latitude = 0;
        }