コード例 #1
0
        /// <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);
        }
コード例 #2
0
        public override bool Equals(object o)
        {
            SettingsFileInfo compareToProgInfo = (SettingsFileInfo)o;

            return(this.Name == compareToProgInfo.Name &&
                   this.FileLocationType == compareToProgInfo.FileLocationType &&
                   this.FilePath == compareToProgInfo.FilePath);
        }
コード例 #3
0
        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);
        }
コード例 #4
0
        protected override SettingsFileInfo CreateDefaultActiveSettingsFileInfo()
        {
            SettingsFileInfo defaultActiveProgram = new SettingsFileInfo();

            //Sets the default program
            defaultActiveProgram.Init(MssFileSystemLocations.FactoryProgramsFolder + "Blank." +
                                      this.SettingsFileExtension);

            return(defaultActiveProgram);
        }
コード例 #5
0
        /// <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);
        }
コード例 #6
0
        /// <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);
        }
コード例 #7
0
        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);
        }
コード例 #8
0
        /// <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)
                {
                }
            }
        }
コード例 #9
0
        /// <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();
            }
        }
コード例 #10
0
        /// <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();
            }
        }
コード例 #11
0
        public VstProgram CreateProgramFromSettingsFileInfo(SettingsFileInfo settingsFileInfo)
        {
            VstProgram program = CreateProgram(ParameterInfos);
            this.ProgramFullNames.Add(settingsFileInfo.Name);
            program.Name = GetValidProgramName(settingsFileInfo.Name);

            return program;
        }
コード例 #12
0
 /// <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;
 }
コード例 #13
0
        /// <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();
            }
        }
コード例 #14
0
        /// <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)
                {

                }
            }
        }
コード例 #15
0
        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;
        }
コード例 #16
0
        protected override SettingsFileInfo CreateDefaultActiveSettingsFileInfo()
        {
            SettingsFileInfo defaultActiveProgram = new SettingsFileInfo();
            //Sets the default program
            defaultActiveProgram.Init(MssFileSystemLocations.FactoryProgramsFolder + "Blank." +
                                        this.SettingsFileExtension);

            return defaultActiveProgram;
        }
コード例 #17
0
        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;
        }