BikeInCity.App.Application_Deactivated C# (CSharp) Method

Application_Deactivated() private method

private Application_Deactivated ( object sender, DeactivatedEventArgs e ) : void
sender object
e DeactivatedEventArgs
return void
        private void Application_Deactivated(object sender, DeactivatedEventArgs e)
        {
            //during the deactivation save the current situation to the current state object
              MainPage page = RootFrame.Content as MainPage;

              //save the last opened city
              if (page.CurrentCity != null && page.CurrentCity.City != null)
              {
              SaveLocalCopy(page.CurrentCity.City);
              var city = page.CurrentCity.City;
              city.FromStations = page.CurrentCity.FromNearStations.Select(x => x.Station).ToList();
              city.CurrentStation = page.CurrentCity.CurrentStation.Station;

              city.Lat = page.map.Center.Latitude;
              city.Lng = page.map.Center.Longitude;
              city.Zoom = page.map.ZoomLevel;

              if (PhoneApplicationService.Current.State.ContainsKey("City"))
              {
                PhoneApplicationService.Current.State.Remove("City");
              }
              PhoneApplicationService.Current.State.Add("City", city);
              }
        }