Example #1
0
 public CitySettingsModel GetCurrentCity()
 {
     if (EnableLocate && CurrentIndex == -1 && LocatedCity != null)
     {
         return(LocatedCity);
     }
     else if (EnableLocate && CurrentIndex == -1 && LocatedCity == null)
     {
         throw new NullReferenceException("Locate city null");
     }
     else if (!EnableLocate && CurrentIndex == -1 && !SavedCities.IsNullorEmpty())
     {
         CurrentIndex = 0;
         return(SavedCities[CurrentIndex]);
     }
     else if (!SavedCities.IsNullorEmpty() && CurrentIndex >= 0 && SavedCities.Length > CurrentIndex)
     {
         return(SavedCities[CurrentIndex]);
     }
     else
     {
         CurrentIndex = SavedCities.Length - 1;
         return(SavedCities[CurrentIndex]);
     }
 }
Example #2
0
        public void ChangeCurrent(string args)
        {
            var index = Array.FindIndex(SavedCities, x =>
            {
                return(x.Id == args);
            });

            if (index >= 0)
            {
                CurrentIndex = index;
            }

            if (EnableLocate)
            {
                if (SavedCities.IsNullorEmpty() || CurrentIndex < 0)
                {
                    CurrentIndex = -1;
                }
            }
        }
Example #3
0
        private void SaveCities(Windows.Storage.ApplicationDataContainer container)
        {
            int i = 0;

            if (!SavedCities.IsNullorEmpty())
            {
                foreach (var item in SavedCities)
                {
                    var sub = RoamingSettingsHelper.GetContainer(i.ToString());
                    try
                    {
                        sub.WriteGroupSettings(item);
                        i++;
                    }
                    catch (Exception)
                    {
                        continue;
                    }
                }
            }
            container.Values["Count"] = i;
        }