private void SetDefaultConfig() { string configPath = RegistrySaver.ReadStringFromRegistry(RegistrySaver.RegConfigName); if (string.IsNullOrEmpty(configPath)) { CreateConfig(); } else { ConfigFileParser(configPath); } }
private void Save(bool isSaveAs) { //TEMP: only launcher tab is available return; if (currentConfig.Validate()) { try { string currentFileName = RegistrySaver.ReadStringFromRegistry(RegistrySaver.configName); if (!isSaveAs && File.Exists(currentFileName)) { File.WriteAllText(currentFileName, currentConfig.CreateConfig()); } else { SaveFileDialog saveFileDialog = new SaveFileDialog(); saveFileDialog.Filter = configFileExtention; if (saveFileDialog.ShowDialog() == true) { currentFileName = saveFileDialog.FileName; currentConfig.name = Path.GetFileNameWithoutExtension(currentFileName); RegistrySaver.RemoveAllRegistryValues(RegistrySaver.configName); RegistrySaver.AddRegistryValue(RegistrySaver.configName, currentFileName); File.WriteAllText(currentFileName, currentConfig.CreateConfig()); } } SetTitle(); AppLogger.Add("Config saved to " + currentFileName); } catch (Exception exception) { InfoDialog errorDialog = new InfoDialog("Error! \nCan not save configuration file. \nSee exception message in Log"); errorDialog.Owner = this; errorDialog.Width = 350; errorDialog.Height = 200; errorDialog.Show(); AppLogger.Add("ERROR! Can not save config to file. EXCEPTION: " + exception.Message); } } else { InfoDialog errorDialog = new InfoDialog("Error! \nCan not save configuration file. \nWrong config. See errors in Log"); errorDialog.Owner = this; errorDialog.Width = 350; errorDialog.Height = 200; errorDialog.Show(); AppLogger.Add("ERROR! Can not save config to file. Errors in configuration"); } }