void CreateConfig() { RegistrySaver.RemoveAllRegistryValues(RegistrySaver.RegConfigName); CurrentConfig = new VRConfig(); this.DataContext = CurrentConfig; //crutch. for refactoring CurrentConfig.selectedSceneNodeView = null; //AppLogger.Add("New config initialized"); UpdateTitle(); }
void CreateConfig() { RegistrySaver.RemoveAllRegistryValues(RegistrySaver.configName); currentConfig = new VRConfig(); this.DataContext = currentConfig; //crutch. for refactoring currentConfig.selectedSceneNodeView = null; AppLogger.Add("New config initialized"); SetTitle(); SetViewportPreview(); }
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"); } }