/// <summary> /// Update the Configuration option settings, optionally write to file /// </summary> /// <param name="configOptions">Configuration option settings</param> /// <param name="write">Write to configuration file immediately</param> public void UpdateConfigOptions(ConfSettings configOptions, bool write) { // Clone it, to avoid conflict mceBuddyConfSettings.conversionTasks = new List<ConversionJobOptions>(); mceBuddyConfSettings.monitorTasks = new List<MonitorJobOptions>(); mceBuddyConfSettings.generalOptions = new GeneralOptions(); mceBuddyConfSettings.generalOptions = configOptions.generalOptions; // Copy of the General Options foreach (MonitorJobOptions mjo in configOptions.monitorTasks) AddOrUpdateMonitorTask(mjo, true); // Add the MonitorTasks foreach (ConversionJobOptions cjo in configOptions.conversionTasks) AddOrUpdateConversionTask(cjo, true); // Add the Conversion Tasks if (write) WriteSettings(); }
/// <summary> /// A MCEBuddyConf object is initialized and a new config file is created/written from the MCEBuddyConf parameters passed. /// If no config file is specified, default values are initialized and no config file is written /// </summary> /// <param name="configOptions">Set of MCEBuddyConf parameters to copy</param> /// <param name="configFile">Path to config file</param> public MCEBuddyConf(ConfSettings configOptions, string configFile = "") { if (configFile == null) configFile = ""; // don't use null as it leads to excessive reads / writes of win.ini mceBuddyConfSettings.conversionTasks = new List<ConversionJobOptions>(); mceBuddyConfSettings.monitorTasks = new List<MonitorJobOptions>(); mceBuddyConfSettings.generalOptions = new GeneralOptions(); mceBuddyConfSettings.generalOptions = configOptions.generalOptions; // Copy of the General Options foreach (MonitorJobOptions mjo in configOptions.monitorTasks) AddOrUpdateMonitorTask(mjo, true); // Add the MonitorTasks foreach (ConversionJobOptions cjo in configOptions.conversionTasks) AddOrUpdateConversionTask(cjo, true); // Add the Conversion Tasks if (!String.IsNullOrEmpty(configFile)) { configIni = new Ini(configFile); WriteSettings(); // Write the settings to the config file } }
public bool UpdateConfigParameters(ConfSettings configOptions) { if (EngineRunning()) // Check if engine has been stopped return false; Monitor.Enter(monitorLock); // Only one action update the object at a time // Set the engine running flag to Stop, just in case wrong settings were passed configOptions.generalOptions.engineRunning = false; MCEBuddyConf.GlobalMCEConfig = new MCEBuddyConf(configOptions, GlobalDefs.ConfigFile); // Create a new object and write the settings ReadConfig(); // Load the new configuration Monitor.Exit(monitorLock); return true; }