Exemple #1
0
 private void SaveConfigurationToFile()
 {
     try
     {
         Stream stream = System.IO.File.Open(ConfigurationFilePath.FullName, FileMode.Create);
         BinaryFormatter formatter = new BinaryFormatter();
         ConfigurationSaveHelper configSaveHelper = new ConfigurationSaveHelper(config);
         formatter.Serialize(stream, configSaveHelper);
         stream.Close();
     }
     catch (Exception e)
     {
         writeLine("Error saving config: " + e.Message);
         ExceptionHandler.TriggerException("Error saving config: " + e.Message, ExceptionLevel.Error, e);
         throw e;
     }
 }
Exemple #2
0
 public void LoadConfigurationHelper(ConfigurationSaveHelper savedhelper)
 {
     //recreate config from helper.
     foreach (Entities.SettingHelper settinghelper in savedhelper.Settings)
     {
         foreach (Entities.Tab tab in Tabs)
         {
             foreach(Entities.Group group in tab.Groups){
                 if (group.Identifier == settinghelper.Group)
                 {
                     foreach(Entities.Setting setting in group.Settings){
                         if(setting.Identifier==settinghelper.Identifier){
                             int tabindex = Tabs.IndexOf(tab);
                             int groupindex = tab.Groups.IndexOf(group);
                             int settingindex = group.Settings.IndexOf(setting);
                             Tabs[tabindex].Groups[groupindex].Settings[settingindex].Value = settinghelper.Value;
                         }
                     }
                 }
             }
         }
     }
 }