private void ResetUnsupportedSettings() { // Legacy Settings forced Reset. this.userSettings[UserSettingConstants.ScalingMode] = VideoScaler.Lanczos; if (!SystemInfo.IsWindows10() || SystemInfo.GetCpuCoreCount < 4) { this.userSettings[UserSettingConstants.ProcessIsolationEnabled] = false; this.userSettings[UserSettingConstants.SimultaneousEncodes] = 1; } }
/// <summary> /// Load Default Settings /// </summary> /// <returns> /// The get defaults. /// </returns> private Dictionary <string, object> GetDefaults() { Dictionary <string, object> defaults = new Dictionary <string, object>(); defaults.Add(UserSettingConstants.Verbosity, 1); // General defaults.Add(UserSettingConstants.UpdateStatus, true); defaults.Add(UserSettingConstants.LastUpdateCheckDate, DateTime.Now.Date.AddDays(-30)); defaults.Add(UserSettingConstants.DaysBetweenUpdateCheck, 1); defaults.Add(UserSettingConstants.DarkThemeMode, DarkThemeMode.Light); defaults.Add(UserSettingConstants.ShowPreviewOnSummaryTab, true); defaults.Add(UserSettingConstants.MainWindowMinimize, false); defaults.Add(UserSettingConstants.ClearCompletedFromQueue, false); defaults.Add(UserSettingConstants.ShowStatusInTitleBar, false); defaults.Add(UserSettingConstants.ShowAddAllToQueue, false); defaults.Add(UserSettingConstants.ShowAddSelectionToQueue, false); defaults.Add(UserSettingConstants.MediaPlayerPath, @"C:\Program Files\VideoLAN\vlc\vlc.exe"); // Output Files defaults.Add(UserSettingConstants.AutoNaming, true); defaults.Add(UserSettingConstants.AutoNamePath, string.Empty); defaults.Add(UserSettingConstants.AutoNameFormat, "{source}-{title}"); defaults.Add(UserSettingConstants.AutonameFilePrePostString, "output_"); defaults.Add(UserSettingConstants.AutoNameTitleCase, true); defaults.Add(UserSettingConstants.AutoNameRemoveUnderscore, true); defaults.Add(UserSettingConstants.AutonameFileCollisionBehaviour, 0); defaults.Add(UserSettingConstants.AlwaysUseDefaultPath, true); defaults.Add(UserSettingConstants.RemovePunctuation, false); defaults.Add(UserSettingConstants.FileOverwriteBehaviour, 0); defaults.Add(UserSettingConstants.UseM4v, 0); // When Done defaults.Add(UserSettingConstants.SendFile, false); defaults.Add(UserSettingConstants.WhenCompleteAction, 0); defaults.Add(UserSettingConstants.WhenDonePerformActionImmediately, false); defaults.Add(UserSettingConstants.PlaySoundWhenDone, false); defaults.Add(UserSettingConstants.PlaySoundWhenQueueDone, false); defaults.Add(UserSettingConstants.WhenDoneAudioFile, string.Empty); // Video defaults.Add(UserSettingConstants.EnableQuickSyncEncoding, true); defaults.Add(UserSettingConstants.EnableQuickSyncDecoding, true); defaults.Add(UserSettingConstants.UseQSVDecodeForNonQSVEnc, false); defaults.Add(UserSettingConstants.EnableVceEncoder, true); defaults.Add(UserSettingConstants.EnableNvencEncoder, true); defaults.Add(UserSettingConstants.EnableQuickSyncLowPower, true); // Advanced defaults.Add(UserSettingConstants.PreventSleep, true); defaults.Add(UserSettingConstants.PauseEncodingOnLowBattery, true); defaults.Add(UserSettingConstants.LowBatteryLevel, 15); defaults.Add(UserSettingConstants.DisableLibDvdNav, false); defaults.Add(UserSettingConstants.PauseOnLowDiskspace, true); defaults.Add(UserSettingConstants.PauseQueueOnLowDiskspaceLevel, 2000000000L); defaults.Add(UserSettingConstants.PreviewScanCount, 10); defaults.Add(UserSettingConstants.MinScanDuration, 10); defaults.Add(UserSettingConstants.ProcessPriorityInt, 3); defaults.Add(UserSettingConstants.X264Step, 0.5); defaults.Add(UserSettingConstants.SaveLogToCopyDirectory, false); defaults.Add(UserSettingConstants.SaveLogWithVideo, false); defaults.Add(UserSettingConstants.ClearOldLogs, true); // Preview defaults.Add(UserSettingConstants.PreviewRotationFlip, false); defaults.Add(UserSettingConstants.LastPreviewDuration, 30); defaults.Add(UserSettingConstants.DefaultPlayer, false); // Experimental defaults.Add(UserSettingConstants.ProcessIsolationEnabled, SystemInfo.IsWindows10()); defaults.Add(UserSettingConstants.ProcessIsolationPort, 8037); defaults.Add(UserSettingConstants.SimultaneousEncodes, 1); // Misc defaults.Add(UserSettingConstants.ScalingMode, 0); defaults.Add(UserSettingConstants.ForcePresetReset, 3); defaults.Add(UserSettingConstants.MetadataPassthru, true); defaults.Add(UserSettingConstants.PreviewShowPictureSettingsOverlay, false); return(defaults); }
/// <summary> /// Load the User Settings /// </summary> private void Load() { try { // Load up the users current settings file. if (File.Exists(this.settingsFile)) { using (StreamReader reader = new StreamReader(this.settingsFile)) { string appSettings = reader.ReadToEnd(); Dictionary <string, object> deserialisedSettings = JsonConvert.DeserializeObject <Dictionary <string, object> >(appSettings); this.userSettings = deserialisedSettings; } } else if (VersionHelper.IsNightly() && File.Exists(this.releaseSettingsFile)) { // Port the release versions config to the nightly. if (!Directory.Exists(DirectoryUtilities.GetUserStoragePath(true))) { Directory.CreateDirectory(DirectoryUtilities.GetUserStoragePath(true)); } File.Copy(this.releaseSettingsFile, this.nightlySettingsFile); using (StreamReader reader = new StreamReader(this.settingsFile)) { string appSettings = reader.ReadToEnd(); Dictionary <string, object> deserialisedSettings = JsonConvert.DeserializeObject <Dictionary <string, object> >(appSettings); this.userSettings = deserialisedSettings; } } else { this.userSettings = new Dictionary <string, object>(); } // Add any missing / new settings Dictionary <string, object> defaults = this.GetDefaults(); foreach (var item in defaults.Where(item => !this.userSettings.Keys.Contains(item.Key))) { this.userSettings.Add(item.Key, item.Value); this.Save(); } // Legacy Settings forced Reset. this.userSettings[UserSettingConstants.ScalingMode] = VideoScaler.Lanczos; if (!SystemInfo.IsWindows10()) { this.userSettings[UserSettingConstants.ProcessIsolationEnabled] = false; } } catch (Exception exc) { try { this.userSettings = this.GetDefaults(); if (File.Exists(this.settingsFile)) { File.Delete(this.settingsFile); } this.Save(); throw new GeneralApplicationException(Resources.UserSettings_YourSettingsHaveBeenReset, Resources.UserSettings_YourSettingsAreCorrupt, exc); } catch (Exception) { throw new GeneralApplicationException(string.Format(Resources.UserSettings_UnableToLoad, this.settingsFile), Resources.UserSettings_UnableToLoadSolution, exc); } } }