示例#1
0
 /// <summary>
 /// Write all settings to an XML file.
 /// </summary>
 /// <param name="settingInfo">The settings information to write to file.</param>
 /// <returns>True if operation was successful; False if not.</returns>
 internal bool WriteSettingsToFile(SettingInformation settingInfo)
 {
     try
     {
         StreamWriter file = new StreamWriter(settingsFile);
         file.Write(settingInfo.ToXML());
         file.Close();
         return true;
     }
     catch (Exception e)
     {
         Logger.Error(e, "WriteSettingsToFile::Storage");
         AlertBox.Show("Failed to write to settings file!");
         return false;
     }
 }
示例#2
0
 /// <summary>
 /// Load all settings from the settings file.
 /// </summary>
 /// <returns>The settings information loaded from the file.</returns>
 internal SettingInformation LoadSettingsFromFile()
 {
     SettingInformation settingInfo = new SettingInformation();
     try
     {
         using (StreamReader file = new StreamReader(settingsFile))
         {
             string xml = file.ReadToEnd();
             settingInfo = xml.Deserialize<SettingInformation>();
             file.Close();
         }
     }
     // Write default settings if file not found or invalid.
     catch (FileNotFoundException e)
     {
         Logger.Error(e, "LoadSettingsFromFile::Storage");
         AlertBox.Show("Settings file not found.\nNew file will be created");
         WriteSettingsToFile(settingInfo);
     }
     catch (System.Runtime.Serialization.SerializationException e)
     {
         Logger.Error(e, "LoadSettingsFromFile::Storage");
         AlertBox.Show("There was an error with the settings file, a new file will be created");
         WriteSettingsToFile(settingInfo);
     }
     return settingInfo;
 }
示例#3
0
 // ******************************************************************
 // Initialization and opening of settings file
 // ******************************************************************
 private void InitializeSettings()
 {
     settingInfo = new SettingInformation();
 }
示例#4
0
 /// <summary>
 /// Completely wipes and re-updates Settings Data
 /// </summary>
 /// <param name="updatedInfo">Pass in an instance of SettingsInformation</param>
 public void UpdateSettings(SettingInformation updatedInfo)
 {
     settingInfo = updatedInfo;
     CustomDictionary.UpdateDictionary(settingInfo.userCommandKeywords, settingInfo.userContextKeywords, settingInfo.userTimeRangeKeywordsType, settingInfo.userTimeRangeType, settingInfo.userTimeRangeKeywordsStartTime, settingInfo.userTimeRangeKeywordsEndTime);
     UpdateDictionaryPostponeSchedule();
 }
示例#5
0
 /// <summary>
 /// This method writes current settings to file
 /// </summary>
 /// <param name="settings"></param>
 /// <returns></returns>
 private bool UpdateSettingsFile(SettingInformation settings)
 {
     return storage.WriteSettingsToFile(settings);
 }
 public static void UpdateSettings(SettingInformation settingsList)
 {
     UpdateSettingsHandler(settingsList, EventArgs.Empty);
 }