Пример #1
0
        private void MainPage_Loaded(object sender, RoutedEventArgs e)
        {
            try
            {
                System.Diagnostics.Debug.WriteLine("Retrieving values");
                locSearch.IsChecked = (bool)settings["locSearch"];
            }

            catch (KeyNotFoundException ex)
            {
                System.Diagnostics.Debug.WriteLine("First Time using the app");
                settings.Add("locSearch", false);
                settings.Save();
            }

            if (locSearch.IsChecked == true)
            {
                AroundMeMap.Visibility = System.Windows.Visibility.Visible;
                UpdateMap();
            }
            else
            {
                AroundMeMap.Visibility = System.Windows.Visibility.Collapsed;
            }
        }
Пример #2
0
        public void SaveSettings()
        {
            DateTime dtDT;
            IsolatedStorageSettings settings = IsolatedStorageSettings.ApplicationSettings;

            // if gbSaveDate == true and 'selected' date is different than previously saved date, then save recently selected date
            settings.TryGetValue <DateTime>("selectdate", out dtDT);

            if ((true == gbSaveDate) && !dtDT.Equals(gdtSelectedDate))
            {
                settings["selectdate"] = gdtSelectedDate;
                settings.Save();
            }

            // if gbSaveDate == false, remove the previously saved 'selected' date, if any
            if ((false == gbSaveDate))
            {
                if (settings.TryGetValue <DateTime>("selectdate", out dtDT))
                {
                    settings.Remove("selectdate");
                }
            }

            settings["saveSelectedDateIsChecked"] = gbSaveDate;
            settings["bShowOnTile"] = gbShowOnTile;
            settings.Save();
        } // SaveSettings();
Пример #3
0
        public bool Remove(string key)
        {
            bool rem = settings.Remove(key);

            settings.Save();
            return(rem);
        }
Пример #4
0
        protected override void OnNavigatedTo(NavigationEventArgs e)
        {
            bool connected = false;

            try
            {
                host.Text = settings["host"] as string;
                port.Text = settings["port"] as string;
                uid.Text  = settings["uid"] as string;
                connected = settings["connected"].Equals(true);
            }
            catch (KeyNotFoundException)
            {
                settings["host"]      = host.Text;
                settings["port"]      = port.Text;
                settings["uid"]       = uid.Text;
                settings["connected"] = connected;
                settings.Save();
            }

            if (connected &&
                (ipcon == null ||
                 ipcon.GetConnectionState() == IPConnection.CONNECTION_STATE_DISCONNECTED))
            {
                Connect();
            }
        }
Пример #5
0
        protected override void OnNavigatedTo(NavigationEventArgs e)
        {
            base.OnNavigatedTo(e);

            recentChatList = new ObservableCollection <Chat>();
            if (appSettings.Contains("recents"))
            {
                recentChatList = appSettings["recents"] as ObservableCollection <Chat>;
            }
            else
            {
                appSettings["recents"] = recentChatList;
                appSettings.Save();
            }

            RecentChatList.ItemsSource = recentChatList;

            savedChatList = new ObservableCollection <Chat>();
            if (appSettings.Contains("savedchats"))
            {
                savedChatList = appSettings["savedchats"] as ObservableCollection <Chat>;
            }
            else
            {
                appSettings["savedchats"] = savedChatList;
                appSettings.Save();
            }

            SavedChatList.ItemsSource = savedChatList;
        }
        private void setlocationButton_Click(object sender, RoutedEventArgs e)
        {
            bool b = false;

            if (setlocationButton.Content.ToString() == "off")
            {
                var result = MessageBox.Show("Turn location service off successfully!");
                if (result == MessageBoxResult.OK)
                {
                    setlocationButton.Content = "on";
                    Dataclass.status          = "cancel";
                    b = true;
                }
                if (_appSettings.Contains("status"))
                {
                    _appSettings["status"] = null;
                    _appSettings.Save();
                }
            }
            if (setlocationButton.Content.ToString() == "on" && b == false)
            {
                var result = MessageBox.Show("Turn location service on successfully!");
                if (result == MessageBoxResult.OK)
                {
                    setlocationButton.Content = "off";
                    Dataclass.status          = "ok";
                }
                if (_appSettings.Contains("status"))
                {
                    _appSettings["status"] = "ok";
                    _appSettings.Save();
                }
            }
        }
Пример #7
0
        /// <summary>
        /// 收藏
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        private void ApplicationBarIconButton_Click_1(object sender, EventArgs e)
        {
            bool isFavor = false;

            if (!settings.Contains("Titles"))
            {
                settings.Add("Titles", linkTitle);
                settings.Save();
                SaveStringToIsolatedStorage(linkTitle, saveContent);
                MessageHelper.Show("收藏成功");
            }
            else
            {
                string[] titleStr = settings["Titles"].ToString().Split(';');
                foreach (var s in titleStr)
                {
                    if (s == linkTitle)
                    {
                        isFavor = true;
                        MessageHelper.Show("该资讯已经收藏过");
                        break;
                    }
                }
                if (!isFavor)
                {
                    settings["Titles"] += ";";
                    settings["Titles"] += linkTitle;

                    settings.Save();
                    SaveStringToIsolatedStorage(linkTitle, saveContent);
                    MessageHelper.Show("收藏成功");
                }
            }
        }
Пример #8
0
        public bool AddOrUpdateValue(string Key, Object value)
        {
            IsolatedStorageSettings settings = IsolatedStorageSettings.ApplicationSettings;

            // If the key exists
            if (settings.Contains(Key))
            {
                bool valueChanged = false;
                // If the value has changed
                if (settings[Key] != value)
                {
                    // Store the new value
                    settings[Key] = value;
                    valueChanged  = true;
                    settings.Save();
                    return(valueChanged);
                }
                else
                {
                    return(valueChanged);
                }
            }
            // Otherwise create the key.
            else
            {
                bool valueChanged = false;
                settings.Add(Key, value);
                valueChanged = true;
                settings.Save();
                return(valueChanged);
            }
        }
Пример #9
0
        /// <summary>
        /// Update a setting value for our application. If the setting does not
        /// exist, then add the setting.
        /// </summary>
        /// <param name="Key"></param>
        /// <param name="value"></param>
        /// <returns></returns>
        public bool AddOrUpdateValue(string Key, Object value)
        {
            bool valueChanged = false;

            // If the key exists
            if (isolatedStore.Contains(Key))
            {
                // If the value has changed
                if (isolatedStore[Key] != value)
                {
                    // Store the new value
                    isolatedStore[Key] = value;
                    valueChanged       = true;

                    isolatedStore.Save();
                    // Messenger.Default.Send("UpdateHtd");
                }
            }
            // Otherwise create the key.
            else
            {
                isolatedStore.Add(Key, value);
                valueChanged = true;

                isolatedStore.Save();
            }
            return(valueChanged);
        }
Пример #10
0
 protected override void OnNavigatedTo(NavigationEventArgs e)
 {
     if (e.IsNavigationInitiator == false && e.NavigationMode == NavigationMode.Back)
     {
         int i = 1;
         if (!settings.Contains("ad"))
         {
             settings.Add("ad", DateTime.Now.ToString("yyyy/mm/dd"));
             settings.Save();
             SetHIDE();
         }
         else
         {
             string k = (string)settings["ad"];
             if (k == DateTime.Now.ToString("yyyy/mm/dd"))
             {
                 SetHIDE();
             }
         }
     }
     if (e.NavigationMode == NavigationMode.New)
     {
         if (settings.Contains("ad"))
         {
             string k = (string)settings["ad"];
             if (k == DateTime.Now.ToString("yyyy/mm/dd"))
             {
                 SetHIDE();
             }
         }
     }
     base.OnNavigatedTo(e);
 }
Пример #11
0
        private void PeriodicalSwitch_Checked(object sender, RoutedEventArgs e)
        {
            PeriodicalSwitch.Content = AppResources.SettingsPageLockScreenPeriodicalSwitchContentChecked;

            appSettings[Constant.SETTINGS_IS_PERIODICALLY_UPDATE] = true;
            appSettings.Save();
        }
Пример #12
0
        protected override void OnNavigatedTo(NavigationEventArgs e)
        {
            if (!App.ViewModel.IsDataLoaded)
            {
                App.ViewModel.LoadData();
            }

            if (!appSettings.Contains(Constants.LOCATION_CONSENT))
            {
                MessageBoxResult result = MessageBox.Show(AppResources.LocationConsent,
                                                          AppResources.LocationConsentCaption, MessageBoxButton.OKCancel);
                if (result == MessageBoxResult.OK)
                {
                    appSettings[Constants.LOCATION_CONSENT] = true;
                }
                else
                {
                    appSettings[Constants.LOCATION_CONSENT] = false;
                }

                appSettings.Save();
            }

            // fav items
            FavoriteItems.Clear();
            if (appSettings.Contains(Constants.FAVORITED_LIST))
            {
                List <int> favs = (List <int>)appSettings[Constants.FAVORITED_LIST];
                foreach (int favId in favs)
                {
                    FavoriteItems.Add(App.ViewModel.Items[favId]);
                }
            }
        }
Пример #13
0
        /// <summary>
        /// 初始化用户定义的主题文件
        /// </summary>
        private void InitTheme()
        {
            string themeName;

            if (AppSettings.Contains("ThemeName"))
            {
                themeName = AppSettings["ThemeName"].ToString();
                AppSettings.Save();
            }
            else
            {
                themeName = "ShinyBlue";
                AppSettings.Add("ThemeName", themeName);
                AppSettings.Save();
            }

            Application.Current.Resources.MergedDictionaries.Clear();
            ResourceDictionary newStyle3 = new ResourceDictionary();
            Uri uri = new Uri("/SMT.SAAS.Themes;component/" + themeName + ".xaml", UriKind.Relative);

            newStyle3.Source = uri;
            Application.Current.Resources.MergedDictionaries.Add(newStyle3);

            ResourceDictionary newStyle_toolkit = new ResourceDictionary();
            Uri uri_toolkit = new Uri("/SMT.SAAS.Themes;component/ToolKitResource.xaml", UriKind.Relative);

            newStyle_toolkit.Source = uri_toolkit;
            Application.Current.Resources.MergedDictionaries.Add(newStyle_toolkit);

            ResourceDictionary newStyle_template = new ResourceDictionary();
            Uri uri_template = new Uri("/SMT.SAAS.Themes;component/ControlTemplate.xaml", UriKind.Relative);

            newStyle_template.Source = uri_template;
            Application.Current.Resources.MergedDictionaries.Add(newStyle_template);
        }
 // Constructor
 public MainPage()
 {
     InitializeComponent();
     jd            = new PhoneNumberChooserTask();
     jd.Completed += jd_Completed;
     _appSettings  = IsolatedStorageSettings.ApplicationSettings;
     if (_appSettings.Contains("status"))
     {
         if (_appSettings["status"] != null)
         {
             Dataclass.status = "ok";
         }
         else
         {
             Dataclass.status = "cancel";
         }
     }
     else
     {
         var result = MessageBox.Show("Some Emergency Positioning Tool features need your location in order to work. You can turn this off at any time under the settings menu.", "Allow app to access and use your location?", MessageBoxButton.OKCancel);
         if (result == MessageBoxResult.OK)
         {
             _appSettings.Add("status", "ok");
             _appSettings.Save();
             Dataclass.status = "ok";
         }
         if (result == MessageBoxResult.Cancel)
         {
             _appSettings.Add("status", null);
             _appSettings.Save();
             Dataclass.status = "cancel";
         }
     }
 }
Пример #15
0
        /// <summary>
        /// Update a setting value for our application. If the setting does not
        /// exist, then add the setting.
        /// </summary>
        /// <param name="Key"></param>
        /// <param name="value"></param>
        /// <returns></returns>
        public bool AddOrUpdateValue(string Key, Object value)
        {
            bool valueChanged = false;

            // If the key exists
            if (_settings.Contains(Key))
            {
                // If the value has changed
                if (_settings[Key] != value)
                {
                    // Store the new value
                    _settings[Key] = value;
                    valueChanged   = true;
                    _settings.Save();
                }
            }
            // Otherwise create the key.
            else
            {
                _settings.Add(Key, value);
                valueChanged = true;
                _settings.Save();
            }
            return(valueChanged);
        }
Пример #16
0
        /// <summary>
        /// 添加到药箱
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        private void addBar_Click(object sender, EventArgs e)
        {
            if (!settings.Contains("drugbox"))
            {
                settings.Add("drugbox", id);
                saveName(id, name);
                MessageHelper.Show("添加成功");
            }
            else
            {
                string[] titleStr = settings["drugbox"].ToString().Split(';');
                foreach (var s in titleStr)
                {
                    if (s == id)
                    {
                        isFavor = true;
                        MessageHelper.Show("该药品已经添加过");
                        break;
                    }
                }
                if (!isFavor)
                {
                    settings["drugbox"] += ";";
                    settings["drugbox"] += id;

                    saveName(id, name);
                    MessageHelper.Show("添加成功");
                }
            }
            settings.Save();
        }
Пример #17
0
 public void Add(string key, object value)
 {
     if (!setting.Contains(key))
     {
         setting.Add(key, value);
         setting.Save();
     }
 }
Пример #18
0
 public static void SaveSetting <T>(string key, T value)
 {
     lock (obj)
     {
         settings[key] = value;
         settings.Save();
     }
 }
Пример #19
0
        void saveAppBarButton_Click(object sender, EventArgs e)
        {
            appSettings["usingCustomHost"] = usingCustomHost;
            appSettings["customHost"]      = CustomHostTextBox.Text;
            appSettings["usingLiveTile"]   = usingLiveTile;

            appSettings.Save();
        }
Пример #20
0
        protected override void AddOrUpdateNative(IEnumerable <KeyValuePair <string, string> > saves)
        {
            foreach (var item in saves)
            {
                prefs[item.Key] = item.Value;
            }

            prefs.Save();
        }
Пример #21
0
 public void Add(string key, object value)
 {
     if (Contains(key))
     {
         Settings.Remove(key);
     }
     Settings.Add(key, value);
     Settings.Save();
 }
Пример #22
0
 private void ShowImage_Loaded(object sender, RoutedEventArgs e)
 {
     if (!settings.Contains("ShowImage"))
     {
         settings.Add("ShowImage", true);
         settings.Save();
     }
     ShowImage.IsChecked = (bool)settings["ShowImage"];
 }
Пример #23
0
 private void SaveConsole()
 {
     if (userSettings.Contains("console"))
     {
         userSettings.Remove("console");
     }
     userSettings.Add("console", console.Text);
     userSettings.Save();
 }
Пример #24
0
        public static void CacheDb(DatabaseInfo info,
                                   string name, Database database)
        {
            _info = info;
            _standards.Clear();
            Database = database;

            _appSettings[KEY_DATABASE] = name;
            _appSettings.Save();
        }
Пример #25
0
        /// <summary>
        /// Sets one value to IsolatedStorage and saves it immediately.
        /// </summary>
        /// <param name="item">Defines which setting item is set</param>
        /// <param name="value">The value of the setting item</param>
        public static void SetValue(object value, [CallerMemberName] string key = "")
        {
            WithLocking(() =>
            {
                Store[key] = value;
                Store.Save();

                OnSettingChanged(key, value);
            });
        }
Пример #26
0
        // was passiert wenn die seite geladen wird?
        void InfoPage_Loaded(object sender, RoutedEventArgs e)
        {
            // gps an oder aus?
            if (IsolatedStorageSettings.ApplicationSettings.Contains("GpsAllowed"))
            {
                zwischenwert            = Convert.ToBoolean(settings["GpsAllowed"]);
                toggleSwitch1.IsChecked = zwischenwert;
            }



            // lese gps genauigkeit aus

            if (zwischenwert == true)
            {
                toggleSwitch1.Content = "AN";
                if (IsolatedStorageSettings.ApplicationSettings.Contains("GpsDetail"))
                {
                    GpsGenauigkeit = Convert.ToString(settings["GpsDetail"]);

                    if (GpsGenauigkeit == "standard")
                    {
                        button5.IsEnabled = false;
                        button6.IsEnabled = true;
                    }
                    else if (GpsGenauigkeit == "hoch")
                    {
                        button5.IsEnabled = true;
                        button6.IsEnabled = false;
                    }
                }
                else if (!IsolatedStorageSettings.ApplicationSettings.Contains("GpsDetail"))
                {
                    if (!settings.Contains("GpsDetail"))
                    {
                        settings.Add("GpsDetail", "standard");
                    }
                    else
                    {
                        settings["GpsDetail"] = "standard";
                    }
                    settings.Save();

                    button5.IsEnabled = false;
                    button6.IsEnabled = true;
                }
            }
            else if (zwischenwert == false)
            {
                toggleSwitch1.Content = "AUS";
                button5.IsEnabled     = false;
                button6.IsEnabled     = false;
            }
            //throw new NotImplementedException();
        }
Пример #27
0
 public async Task RemoveObject(string key)
 {
     await Task.Factory.StartNew(() =>
     {
         if (_settings.Contains(key))
         {
             _settings.Remove(key);
             _settings.Save();
         }
     });
 }
Пример #28
0
 // Called when the app is deactivating. Saves the time of the deactivation and the
 // session type of the app instance to isolated storage.
 public void SaveCurrentDeactivationSettings()
 {
     if (AddOrUpdateValue(DeactivateSettingKey, DateTimeOffset.Now))
     {
         settings.Save();
     }
     if (AddOrUpdateValue(LaunchTypeKey, launchType))
     {
         settings.Save();
     }
 }
Пример #29
0
        protected override void OnNavigatedTo(NavigationEventArgs e)
        {
            base.OnNavigatedTo(e);

            if (!AppSettings.Contains(Constants.SYNC_KEY))
            {
                AppSettings[Constants.SYNC_KEY] = true;
                AppSettings.Save();
            }
            SyncSwitch.IsChecked = (bool)AppSettings[Constants.SYNC_KEY];
        }
Пример #30
0
        // Called when the app is deactivating. Saves the time of the deactivation and the
        // session type of the app instance to isolated storage.
        public void SaveCurrentDeactivationSettings()
        {
            if (AddOrUpdateValue("DeactivateTime", DateTimeOffset.Now))
            {
                settings.Save();
            }

            if (AddOrUpdateValue("SessionType", sessionType))
            {
                settings.Save();
            }
        }