/// <summary> /// Create an instance of SettingsFileInfo from a file path. /// </summary> protected SettingsFileInfo CreateSettingsFileInfo(string filePath) { SettingsFileInfo progInfo = new SettingsFileInfo(); progInfo.Init(filePath); return(progInfo); }
public override bool Equals(object o) { SettingsFileInfo compareToProgInfo = (SettingsFileInfo)o; return(this.Name == compareToProgInfo.Name && this.FileLocationType == compareToProgInfo.FileLocationType && this.FilePath == compareToProgInfo.FilePath); }
public static SettingsFileInfo CreateDefaultTransformPresetFileInfo() { SettingsFileInfo defaultActiveProgram = new SettingsFileInfo(); //Sets the default program defaultActiveProgram.Init(MssFileSystemLocations.FactoryProgramsFolder + DEFAULT_TRANSFORM_PRESET_NAME + "." + TRANSFORM_PRESET_FILE_EXTENSION); return(defaultActiveProgram); }
protected override SettingsFileInfo CreateDefaultActiveSettingsFileInfo() { SettingsFileInfo defaultActiveProgram = new SettingsFileInfo(); //Sets the default program defaultActiveProgram.Init(MssFileSystemLocations.FactoryProgramsFolder + "Blank." + this.SettingsFileExtension); return(defaultActiveProgram); }
/// <summary> /// Loads and active the settings stored at programFilePath /// </summary> public void LoadAndActivateSettingsFromPath(string programFilePath) { if (programFilePath == GetActiveSettingsFile().FilePath) { return; } SettingsFileInfo newSettingsFileInfo = CreateSettingsFileInfo(programFilePath); LoadAndActivateSettingsFromSettingsFileInfo(newSettingsFileInfo); }
/// <summary> /// Loads and active the settings stored in a file whose name is specified by /// newActiveSettingsFileName. /// </summary> public void LoadAndActivateSettingsFromName(string newActiveSettingsFileName) { if (newActiveSettingsFileName == this.ActiveSettingsFileName) { return; } SettingsFileInfo newActiveProgram = GetSettingsFromName(newActiveSettingsFileName); LoadAndActivateSettingsFromSettingsFileInfo(newActiveProgram); }
public SettingsFileInfo GetSettingsFromName(string settingsName) { //Search for the SettingsFileInfo instance associated with settingsName SettingsFileInfo settingsInfo = this.FlatSettingsFileList.Find( (SettingsFileInfo curProgram) => curProgram.Name == settingsName); //settingsInfo could be null if the active settings are external (not user settings or //factory settings) as this would mean they are not in the FlatSettingsFileList if (settingsInfo == null) { settingsInfo = new SettingsFileInfo(); settingsInfo.InitAsExternal(this.ActiveSettingsFileName); } return(settingsInfo); }
/// <summary> /// Loads and active the settings specified by newActiveProgram /// </summary> public void LoadAndActivateSettingsFromSettingsFileInfo(SettingsFileInfo newActiveProgram) { if (newActiveProgram != GetActiveSettingsFile()) { try { FileStream loadProgramStream = new FileStream(newActiveProgram.FilePath, FileMode.Open); LoadSettingsFromFileStream(loadProgramStream); loadProgramStream.Close(); this.ActiveSettingsFileName = newActiveProgram.Name; } catch (FileNotFoundException) { } } }
/// <summary> /// Save the active settings over their previous serialization. If the active settings are /// factory settings or if a file does not already exist for them then the user will be /// able to choose a file to save them to. /// </summary> public void SaveActiveSettingsFile() { SettingsFileInfo activeSettingsFile = GetActiveSettingsFile(); if (activeSettingsFile.FileLocationType == SettingsFileLocationType.Factory || File.Exists(activeSettingsFile.FilePath) == false) { SaveAsActiveSettingsFile(); } else { FileStream newProgramStream = new FileStream(activeSettingsFile.FilePath, FileMode.Truncate); SaveActiveSettingsToFileStream(newProgramStream); newProgramStream.Close(); ReinitializeSettingsFileCollections(); } }
/// <summary> /// Save the active settings to a file specified by the user. /// </summary> public void SaveAsActiveSettingsFile() { SettingsFileInfo activeSettingsFile = GetActiveSettingsFile(); SaveFileDialog dlg = new SaveFileDialog(); dlg.Filter = this.GetSettingsFileFilter(); if (activeSettingsFile.FileLocationType == SettingsFileLocationType.User) { dlg.InitialDirectory = Path.GetDirectoryName(activeSettingsFile.FilePath); dlg.FileName = Path.GetFileName(activeSettingsFile.FilePath); } else { //Factory settings should not be overwritten by the user so the default directory //will be the root folder for uesr settings. dlg.InitialDirectory = this.RootFolderForUserSettings; dlg.FileName = activeSettingsFile.Name + " (copy)." + SettingsFileExtension; } if (dlg.ShowDialog() == DialogResult.OK) { //Create a SettingsFileInfo instance for the newly created file. SettingsFileInfo newActiveSettingsFile = new SettingsFileInfo(); newActiveSettingsFile.Init(dlg.FileName); this.ActiveSettingsFileName = newActiveSettingsFile.Name; OnActiveSettingsFileChanged(); FileStream newSettingsStream = new FileStream(dlg.FileName, FileMode.Create); //Save the settings to the user specified location. SaveActiveSettingsToFileStream(newSettingsStream); newSettingsStream.Close(); ReinitializeSettingsFileCollections(); } }
public VstProgram CreateProgramFromSettingsFileInfo(SettingsFileInfo settingsFileInfo) { VstProgram program = CreateProgram(ParameterInfos); this.ProgramFullNames.Add(settingsFileInfo.Name); program.Name = GetValidProgramName(settingsFileInfo.Name); return program; }
/// <summary> /// Create an instance of SettingsFileInfo from a file path. /// </summary> protected SettingsFileInfo CreateSettingsFileInfo(string filePath) { SettingsFileInfo progInfo = new SettingsFileInfo(); progInfo.Init(filePath); return progInfo; }
public SettingsFileInfo GetSettingsFromName(string settingsName) { //Search for the SettingsFileInfo instance associated with settingsName SettingsFileInfo settingsInfo = this.FlatSettingsFileList.Find( (SettingsFileInfo curProgram) => curProgram.Name == settingsName); //settingsInfo could be null if the active settings are external (not user settings or //factory settings) as this would mean they are not in the FlatSettingsFileList if (settingsInfo == null) { settingsInfo = new SettingsFileInfo(); settingsInfo.InitAsExternal(this.ActiveSettingsFileName); } return settingsInfo; }
protected override SettingsFileInfo CreateDefaultActiveSettingsFileInfo() { SettingsFileInfo defaultActiveProgram = new SettingsFileInfo(); //Sets the default program defaultActiveProgram.Init(MssFileSystemLocations.FactoryProgramsFolder + "Blank." + this.SettingsFileExtension); return defaultActiveProgram; }
public static SettingsFileInfo CreateDefaultTransformPresetFileInfo() { SettingsFileInfo defaultActiveProgram = new SettingsFileInfo(); //Sets the default program defaultActiveProgram.Init(MssFileSystemLocations.FactoryProgramsFolder + DEFAULT_TRANSFORM_PRESET_NAME + "." + TRANSFORM_PRESET_FILE_EXTENSION); return defaultActiveProgram; }