//Change the status to what the user has chosen private void ChangeStatus_Click(object sender, RoutedEventArgs e) { MenuItem menuItem = (MenuItem)sender; team.setStatus(getMenuItemStatus(menuItem)); //Clearing the arrow if the team got to where they are going if (getMenuItemStatus(menuItem).Equals("available") || getMenuItemStatus(menuItem).Equals("intervening")) { RemoveArrow(); } //Handling the case when the user sets the status of a team to intervening if (getMenuItemStatus(menuItem).Equals("intervening")) { //Handling the case of when the user sets a team to intervening but it is not assigned to an intervention yet. Create the new intervention and assign the team to it. if (interventionPin == null) { Intervention intervention = new Intervention(); //Getting references to the new team and intervention pins TeamPin teamPin = null; //Need to get a reference to the new teamPin and not use "this" because the map has been redrawn upon the intervention creation, i.e. this TeamPin is outdated InterventionPin relatedInterventionPin = null; foreach (Pin pin in pinList) { if (pin.relatedObject == team) { teamPin = (TeamPin)pin; } if (pin.relatedObject == intervention) { relatedInterventionPin = (InterventionPin)pin; break; } } //Setting the position of the intervention to be the position of the team and calling collision detection on the teamPin for the team to be added to the intervention relatedInterventionPin.setPinPosition(teamPin.getX(), teamPin.getY()); teamPin.CollisionDetectionAndResolution(false); relatedInterventionPin.getIntervention().InterveningTeamArrived(team); } else { //Set team as "In position" on the intervention interventionPin.getIntervention().InterveningTeamArrived(team); } } }