/// <summary> /// Loads the city from the state and populates the screen /// </summary> /// <param name="e"></param> protected override void OnNavigatedTo(System.Windows.Navigation.NavigationEventArgs e) { try { city = ApplicationStateHelper.LoadCityFromAppState(); if (city != null) { // Update the map to show the current location Location ppLoc = new Location(); ppLoc.Latitude = city.Weather.Lat; ppLoc.Longitude = city.Weather.Lon; map.SetView(ppLoc, 10); //update pushpin location and show MapLayer.SetPosition(ppLocation, ppLoc); ppLocation.Visibility = System.Windows.Visibility.Visible; } } catch (System.ArgumentNullException) { MessageBox.Show("Unable to load the Images."); } base.OnNavigatedTo(e); }
/// <summary> /// Loads the city from the state and populates the screen /// </summary> /// <param name="e"></param> protected override void OnNavigatedTo(System.Windows.Navigation.NavigationEventArgs e) { try { city = ApplicationStateHelper.LoadCityFromAppState(); if (city != null) { ImagesListBox.ItemsSource = city.Pictures; } } catch (System.ArgumentNullException) { MessageBox.Show("Unable to load the Images."); } base.OnNavigatedTo(e); }
/// <summary> /// Loads the city from the state and populates the screen /// </summary> /// <param name="e"></param> protected override void OnNavigatedTo(System.Windows.Navigation.NavigationEventArgs e) { try { city = ApplicationStateHelper.LoadCityFromAppState(); selectedPicture = Convert.ToInt16(NavigationContext.QueryString["selectedPicture"]); if (city != null) { LoadImage(); } } catch (System.ArgumentNullException) { MessageBox.Show("Unable to load the Images."); } base.OnNavigatedTo(e); }
/// <summary> /// Loads the city from the state and populates the screen /// </summary> /// <param name="e"></param> protected override void OnNavigatedTo(System.Windows.Navigation.NavigationEventArgs e) { try { city = ApplicationStateHelper.LoadCityFromAppState(); if (city != null) { cityNameTitle.Text = city.Name; Uri uri = new Uri(city.Pictures[0].Image, UriKind.Absolute); imageCity.Source = new BitmapImage(uri); } } catch (System.ArgumentNullException) { MessageBox.Show(Utils.GetMessage("UnableToRetrieveWeather")); } base.OnNavigatedTo(e); }
/// <summary> /// Loads the city from the state and populates the screen /// </summary> /// <param name="e"></param> protected override void OnNavigatedTo(System.Windows.Navigation.NavigationEventArgs e) { try { city = ApplicationStateHelper.LoadCityFromAppState(); if (city != null) { cityNameTitle.Text = city.Name; string description = "<html><body style='background-color:black;color:white;' >" + city.Description + "</body></html>"; var htmlCode = HttpUtility.HtmlDecode(description); webBrowser1.NavigateToString(htmlCode); } } catch (System.ArgumentNullException) { MessageBox.Show("Unable to display the description of the city"); } base.OnNavigatedTo(e); }
/// <summary> /// Loads the city from the state and populates the screen /// </summary> /// <param name="e"></param> protected override void OnNavigatedTo(System.Windows.Navigation.NavigationEventArgs e) { try { city = ApplicationStateHelper.LoadCityFromAppState(); if (city != null) { Uri uri = new Uri(Utils.ResolveWeatherIcon(city.Weather.CurrentWeather[0].Item.Condition.ConditionCode), UriKind.Absolute); iconCurrWeather.Source = new BitmapImage(uri); temp.Text = city.Weather.CurrentWeather[0].Item.Condition.ConditionTemp + "\u00B0C"; condition.Text = city.Weather.CurrentWeather[0].Item.Condition.ConditionText; ForecastListBox.ItemsSource = city.Weather.Forecast.Skip(1).Take(city.Weather.Forecast.Length - 1).ToArray(); } } catch (System.ArgumentNullException) { MessageBox.Show("Unable to load the Forecast."); } base.OnNavigatedTo(e); }
/// <summary> /// Saves the state of the app by storing the city object /// </summary> /// <param name="city"></param> public static void SaveCityToAppState(City city) { PhoneApplicationService.Current.State[City.KEY] = city; }
/// <summary> /// Saves the city object to local storage /// </summary> /// <param name="city"></param> public static void SaveCityToIsolatedStorage(City city) { // persist the data using isolated storage using (var store = IsolatedStorageFile.GetUserStoreForApplication()) using (var stream = new IsolatedStorageFileStream("data.txt", FileMode.Create, FileAccess.Write, store)) { var serializer = new XmlSerializer(typeof(City)); serializer.Serialize(stream, city); } }