コード例 #1
0
        private void AreaSelector_Load(object sender, EventArgs e)
        {
            UserConfigJson userConfig = UserConfiguration.GetConfiguration();

            try
            {
                _checkedChangesFromCode = true;
                checkBox2.Checked       = (bool)userConfig.ShowConnectionNotifications;
                checkBox3.Checked       = (bool)userConfig.ShowAlertsFromUnknownAreas;
                checkBox1.Checked       = IsStartsOnStartup();
            }
            catch (Exception ex)
            {
                Trace.WriteLine(ex.ToString());
            }
            finally
            {
                _checkedChangesFromCode = false;
            }

            Dictionary <string, UserCityConfig> userConfigDictionary = userConfig.CityConfigs.ToDictionary(x => x.City);

            List <UserCityConfig> finalUserConfig    = new List <UserCityConfig>();
            List <ListViewItem>   finalListViewItems = new List <ListViewItem>();

            for (int i = 0; i < Cities.ListOfCities.Count; i++)
            {
                string city = Cities.ListOfCities[i].City;

                UserCityConfig userCityConfig;

                if (!userConfigDictionary.TryGetValue(city, out userCityConfig))
                {
                    userCityConfig      = new UserCityConfig();
                    userCityConfig.City = city;
                }

                ListViewItem item = new ListViewItem(new string[] { userCityConfig.City, ToDisplay(userCityConfig.DisplayAlerts), ToDisplay(userCityConfig.SoundAlerts) });
                item.Tag = userCityConfig;

                finalUserConfig.Add(userCityConfig);
                finalListViewItems.Add(item);
            }

            _userConfig    = finalUserConfig.ToArray();
            _listViewItems = finalListViewItems.ToArray();

            RefillListView();
        }
コード例 #2
0
 private void LoadUserConfiguration()
 {
     LoadUserConfiguration(UserConfiguration.GetConfiguration());
 }