Esempio n. 1
0
        public static void SaveConfig()
        {
            try
            {
                string configPath = FileSystemHelper.GetAbsolutePath("Config\\Config.xml");
                if (!Directory.Exists(FileSystemHelper.GetAbsolutePath("Config")))
                {
                    Directory.CreateDirectory(FileSystemHelper.GetAbsolutePath("Config"));
                }

                WorkConfig = WriteConfig(configPath, WorkConfig);
            }
            catch (Exception e)
            {
                MessageBox.Show("Failed to save config file.\n\n" + e, "Failed to save config file", MessageBoxButton.OK, MessageBoxImage.Error);
                WorkConfig = null;
            }
        }
Esempio n. 2
0
        public static void ReadConfig()
        {
            try
            {
                List <DictionaryConfig> dictionariesListBackup = null;
                if (WorkConfig != null && WorkConfig.Dictionaries != null)
                {
                    dictionariesListBackup = WorkConfig.Dictionaries;
                }

                string configPath = FileSystemHelper.GetAbsolutePath("Config\\Config.xml");
                WorkConfig = ReadConfig <WorkConfig>(configPath);
                WorkConfig.Dictionaries = dictionariesListBackup ?? WorkConfig.Dictionaries;
            }
            catch (Exception e)
            {
                MessageBox.Show("Failed to read config file.\n\n" + e, "Failed to read config file", MessageBoxButton.OK, MessageBoxImage.Error);
                WorkConfig = null;
            }
        }