From f42863e26f1cf17b9db69519482f3fbd4ee24f53 Mon Sep 17 00:00:00 2001 From: sr55 Date: Sat, 9 Jan 2010 21:41:37 +0000 Subject: [PATCH] WinGui: - Fixed the preset loader. It would not set the quality slider if RF51 was used. git-svn-id: svn://localhost/HandBrake/trunk@3059 b64f7644-9d1e-0410-96f1-a4d463321fa5 --- win/C#/Functions/PresetLoader.cs | 67 ++++++++++++++++++++-------------------- 1 file changed, 33 insertions(+), 34 deletions(-) diff --git a/win/C#/Functions/PresetLoader.cs b/win/C#/Functions/PresetLoader.cs index 3018b915..645a2ba8 100644 --- a/win/C#/Functions/PresetLoader.cs +++ b/win/C#/Functions/PresetLoader.cs @@ -50,12 +50,12 @@ namespace Handbrake.Functions { if (mainWindow.drop_format.SelectedIndex == 0) mainWindow.SetExtension(".mp4"); - else + else mainWindow.drop_format.SelectedIndex = 0; } else if (presetQuery.Format == "mkv") { - if(mainWindow.drop_format.SelectedIndex == 1) + if (mainWindow.drop_format.SelectedIndex == 1) mainWindow.SetExtension(".mkv"); else mainWindow.drop_format.SelectedIndex = 1; @@ -91,13 +91,13 @@ namespace Handbrake.Functions mainWindow.PictureSettings.crop_right.Value = right; } } - + // Set the anamorphic mode 0,1,2,3 mainWindow.PictureSettings.drp_anamorphic.SelectedIndex = presetQuery.AnamorphicMode; // Aspect Ratio mainWindow.PictureSettings.check_KeepAR.CheckState = presetQuery.keepDisplayAsect ? CheckState.Checked : CheckState.Unchecked; - + // Set the Width and height as Required. if (presetQuery.Width != 0) mainWindow.PictureSettings.text_width.Value = presetQuery.Width; @@ -154,40 +154,39 @@ namespace Handbrake.Functions } // Quality - if (presetQuery.VideoQuality != 0) + + mainWindow.radio_cq.Checked = true; + if (presetQuery.VideoEncoder == "H.264 (x264)") { - mainWindow.radio_cq.Checked = true; - if (presetQuery.VideoEncoder == "H.264 (x264)") - { - double cqStep = Properties.Settings.Default.x264cqstep; - int value; - double x264step = cqStep; - double presetValue = presetQuery.VideoQuality; - - double x = 51 / x264step; - - double calculated = presetValue / x264step; - calculated = x - calculated; - - int.TryParse(calculated.ToString(), out value); - - // This will sometimes occur when the preset was generated - // with a different granularity, so, round and try again. - if (value == 0) - { - double val = Math.Round(calculated, 0); - int.TryParse(val.ToString(), out value); - } - if (value < mainWindow.slider_videoQuality.Maximum) - mainWindow.slider_videoQuality.Value = value; - } - else + double cqStep = Properties.Settings.Default.x264cqstep; + int value; + double x264step = cqStep; + double presetValue = presetQuery.VideoQuality; + + double x = 51 / x264step; + + double calculated = presetValue / x264step; + calculated = x - calculated; + + int.TryParse(calculated.ToString(), out value); + + // This will sometimes occur when the preset was generated + // with a different granularity, so, round and try again. + if (value == 0) { - int presetVal; - int.TryParse(presetQuery.VideoQuality.ToString(), out presetVal); - mainWindow.slider_videoQuality.Value = presetVal; + double val = Math.Round(calculated, 0); + int.TryParse(val.ToString(), out value); } + if (value <= mainWindow.slider_videoQuality.Maximum) + mainWindow.slider_videoQuality.Value = value; } + else + { + int presetVal; + int.TryParse(presetQuery.VideoQuality.ToString(), out presetVal); + mainWindow.slider_videoQuality.Value = presetVal; + } + mainWindow.check_2PassEncode.CheckState = presetQuery.TwoPass ? CheckState.Checked : CheckState.Unchecked; -- 2.11.0