void StudioController_OnDatabaseChanged(string serverName, string databaseName) { if (_userPref == null) { _userPref = UserPreferencesStorage.Load(); } _userPref.StoreByName(UserPref_ServerDatabase + serverName, databaseName); _userPref.Save(); InvokeInUI(() => { ReloadDatabaseList(false, setFocus: false); }); }
public static UserPreferencesStorage Load() { if (_preferences != null) { return(_preferences); } try { var isoStore = GetIsolatedStorageFile(); if (isoStore.GetFileNames(_settingFileName).Length > 0) { _preferences = new UserPreferencesStorage(); using (var iStream = new IsolatedStorageFileStream(_settingFileName, FileMode.Open, isoStore)) { using (var reader = new StreamReader(iStream)) { while (true) { var lineKey = reader.ReadLine(); var lineValue = reader.ReadLine(); if ((lineKey == null) || (lineValue == null)) { break; } _preferences.Add(new Entry() { Key = lineKey, Value = lineValue }); } } } return(_preferences); //return Serializator.Load<UserPreferencesStorage>(fullName); } } catch (Exception ex) { log.Info("Could not load user preferences:" + ex.Message); } _preferences = new UserPreferencesStorage(); return(_preferences); }
private void UserControl_Loaded(Object sender, RoutedEventArgs e) { try { log.Info("XAML Loaded..."); var scroll = itemsControl.FindChild <ScrollContentPresenter>(); _userPref = UserPreferencesStorage.Load(); _cfg = _persistor.Restore <Config.DogConfig>(_userPref); UpdateDetector = new UpdateDetector(_userPref); UpdateDetector.NewVersionFound += UpdateDetector_NewVersionFound; _processor.RequestFailed += new Action <Request, Exception>(_processor_RequestFailed); StudioController.Initialise(); StudioController.SetConfiguration(_cfg); StudioController.OnServersAdded += StudioController_OnServersAdded; StudioController.OnServersRemoved += StudioController_OnServersRemoved; StudioController.OnDatabaseChanged += StudioController_OnDatabaseChanged; StudioController.ShowYourself += new System.Action(StudioController_ShowYourself); ReloadServers(); ResultsFontSize = _cfg.FontSize; var lastSrvName = _userPref.GetByName(UserPref_LastSelectedServer); RestoreLastSearchTextFromUserProfile(); // select first server if ((cbServer.SelectedIndex == -1) && (cbServer.Items.Count > 1)) { cbServer.SelectedIndex = 0; } } catch (Exception ex) { log.Error("Fatal error loading main control:" + ex.Message, ex); } }