コード例 #1
0
ファイル: Storage.cs プロジェクト: soulslicer/ToDoPlusPlus
 /// <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
ファイル: Storage.cs プロジェクト: soulslicer/ToDoPlusPlus
 /// <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
ファイル: Settings.cs プロジェクト: RavenXce/ToDo_PlusPlus
 // ******************************************************************
 // Initialization and opening of settings file
 // ******************************************************************
 private void InitializeSettings()
 {
     settingInfo = new SettingInformation();
 }
コード例 #4
0
ファイル: Settings.cs プロジェクト: RavenXce/ToDo_PlusPlus
 /// <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
ファイル: Logic.cs プロジェクト: soulslicer/ToDoPlusPlus
 /// <summary>
 /// This method writes current settings to file
 /// </summary>
 /// <param name="settings"></param>
 /// <returns></returns>
 private bool UpdateSettingsFile(SettingInformation settings)
 {
     return storage.WriteSettingsToFile(settings);
 }
コード例 #6
0
 public static void UpdateSettings(SettingInformation settingsList)
 {
     UpdateSettingsHandler(settingsList, EventArgs.Empty);
 }