Ejemplo n.º 1
0
        /// <summary>
        /// Provides command for the skin to change the current location.
        /// </summary>
        /// <param name="item">The location item.</param>
        public void ChangeLocation(ListItem item)
        {
            City city = (City)item.AdditionalProperties[KEY_CITY];

            _preferredLocationCode = city.Id;
            StartBackgroundRefresh(city);

            // also save the last selected city to settings
            WeatherSettings settings = ServiceRegistration.Get <ISettingsManager>().Load <WeatherSettings>();

            settings.LocationCode = city.Id;
            ServiceRegistration.Get <ISettingsManager>().Save(settings);
            WeatherMessaging.SendWeatherMessage(WeatherMessaging.MessageType.LocationChanged);
        }
Ejemplo n.º 2
0
        /// <summary>
        /// Saves the current state to the settings file.
        /// </summary>
        public void SaveSettings()
        {
            ISettingsManager settingsManager = ServiceRegistration.Get <ISettingsManager>();
            WeatherSettings  settings        = settingsManager.Load <WeatherSettings>();

            // Apply new locations list
            settings.LocationsList = Locations;
            // Check if preferred location still in list, if not then set the first available
            if (settings.LocationsList.Find(loc => loc.Id == settings.LocationCode) == null && settings.LocationsList.Count > 0)
            {
                settings.LocationCode = settings.LocationsList[0].Id;
            }
            settingsManager.Save(settings);
            WeatherMessaging.SendWeatherMessage(WeatherMessaging.MessageType.LocationChanged);
        }