Example #1
0
 private void AddNewPlace(object sender, RoutedEventArgs e)
 {
     string newPlaceName = NewPlaceName.Text.Trim();
     if (newPlaceName.Length == 0)
     {
         MessageBox.Show("please enter a city name");
         return;
     }
     foreach (Place place in App.ViewModel.Places)
     {
         if (place.Name.Equals(newPlaceName))
         {
             MessageBox.Show("please enter a different name");
             return;
         }
     }
     Place p;
     if (!LongitudeBox.Text.Any() || !LatitudeBox.Text.Any())
         p = new Place(NewPlaceName.Text);
     else
     {
         p = new Place(NewPlaceName.Text, Double.Parse(LatitudeBox.Text), Double.Parse(LongitudeBox.Text));
     }
     App.ViewModel.Places.Add(p);
 }
 public void AddPlace(Place place)
 {
     places.Add(place.Name,place);
 }