OSDN Git Service

remove crf flag and all uses of it
[handbrake-jp/handbrake-jp-git.git] / win / C# / Functions / PresetLoader.cs
index bcc4b1b..3018b91 100644 (file)
@@ -5,6 +5,7 @@
           It may be used under the terms of the GNU General Public License. */\r
 \r
 using System;\r
+using System.Drawing;\r
 using System.Windows.Forms;\r
 \r
 namespace Handbrake.Functions\r
@@ -45,15 +46,20 @@ namespace Handbrake.Functions
 \r
             if (presetQuery.Format != null)\r
             {\r
-                if (presetQuery.Format == "mp4")\r
-                    mainWindow.drop_format.SelectedIndex = 0;\r
-                else if (presetQuery.Format == "m4v")\r
-                    mainWindow.drop_format.SelectedIndex = 1;\r
+                if (presetQuery.Format == "mp4" || presetQuery.Format == "m4v")\r
+                {\r
+                    if (mainWindow.drop_format.SelectedIndex == 0)\r
+                        mainWindow.SetExtension(".mp4");\r
+                    else \r
+                        mainWindow.drop_format.SelectedIndex = 0;\r
+                }\r
                 else if (presetQuery.Format == "mkv")\r
-                    mainWindow.drop_format.SelectedIndex = 2;\r
-\r
-                if (presetQuery.ChapterMarkers && presetQuery.Format == "mp4")\r
-                    mainWindow.drop_format.SelectedIndex = 1;\r
+                {\r
+                    if(mainWindow.drop_format.SelectedIndex == 1)\r
+                        mainWindow.SetExtension(".mkv");\r
+                    else\r
+                        mainWindow.drop_format.SelectedIndex = 1;\r
+                }\r
             }\r
 \r
             mainWindow.check_iPodAtom.CheckState = presetQuery.IpodAtom ? CheckState.Checked : CheckState.Unchecked;\r
@@ -68,13 +74,9 @@ namespace Handbrake.Functions
 \r
             #region Picture\r
             mainWindow.PictureSettings.check_autoCrop.Checked = true;\r
-            if (presetQuery.CropBottom == "0" && presetQuery.CropTop == "0")\r
-                if (presetQuery.CropLeft == "0" && presetQuery.CropRight == "0")\r
-                    mainWindow.PictureSettings.check_customCrop.Checked = true;\r
-\r
             if (pictureSettings) // only Load picture settings if the perset requires it\r
             {\r
-                if (presetQuery.CropTop != null)\r
+                if (presetQuery.CropValues != null)\r
                 {\r
                     int top, bottom, left, right;\r
                     int.TryParse(presetQuery.CropTop, out top);\r
@@ -89,43 +91,42 @@ namespace Handbrake.Functions
                     mainWindow.PictureSettings.crop_right.Value = right;\r
                 }\r
             }\r
+            \r
+            // Set the anamorphic mode 0,1,2,3\r
+            mainWindow.PictureSettings.drp_anamorphic.SelectedIndex = presetQuery.AnamorphicMode;\r
 \r
-            // Reset maxWidth and MaxHeight to 0\r
-            mainWindow.PictureSettings.maxWidth = 0;\r
-            mainWindow.PictureSettings.maxHeight = 0;\r
-\r
-            // Set the width and height\r
+            // Aspect Ratio\r
+            mainWindow.PictureSettings.check_KeepAR.CheckState = presetQuery.keepDisplayAsect ? CheckState.Checked : CheckState.Unchecked;\r
+                \r
+            // Set the Width and height as Required.\r
             if (presetQuery.Width != 0)\r
                 mainWindow.PictureSettings.text_width.Value = presetQuery.Width;\r
-            else if (presetQuery.MaxWidth == 0)\r
-                mainWindow.PictureSettings.text_width.Value = 0;\r
 \r
-            mainWindow.PictureSettings.text_height.Value = presetQuery.Height != 0 ? presetQuery.Height : 0;\r
+            if (presetQuery.Height != 0)\r
+                mainWindow.PictureSettings.text_height.Value = presetQuery.Height;\r
 \r
             // Max Width/Height override Width/Height\r
             if (presetQuery.MaxWidth != 0)\r
-            {\r
                 mainWindow.PictureSettings.text_width.Value = presetQuery.MaxWidth;\r
-                mainWindow.PictureSettings.maxWidth = presetQuery.MaxWidth;\r
-            }\r
 \r
             if (presetQuery.MaxHeight != 0)\r
-            {\r
                 mainWindow.PictureSettings.text_height.Value = presetQuery.MaxHeight;\r
-                mainWindow.PictureSettings.maxHeight = presetQuery.MaxHeight;\r
-            }\r
-            mainWindow.PictureSettings.setMax();\r
 \r
-            // Set the anamorphic mode 0,1,2,3\r
-            mainWindow.PictureSettings.drp_anamorphic.SelectedIndex = presetQuery.AnamorphicMode;\r
+            mainWindow.PictureSettings.PresetMaximumResolution = new Size(presetQuery.MaxWidth, presetQuery.MaxHeight);\r
 \r
-            // Custom Anamorphic Controls\r
-            mainWindow.PictureSettings.check_KeepAR.CheckState = presetQuery.keepDisplayAsect ? CheckState.Checked : CheckState.Unchecked;\r
-            mainWindow.PictureSettings.txt_displayWidth.Text = presetQuery.displayWidthValue.ToString();\r
-            mainWindow.PictureSettings.txt_parWidth.Text = presetQuery.pixelAspectWidth.ToString();\r
-            mainWindow.PictureSettings.txt_parHeight.Text = presetQuery.pixelAspectHeight.ToString();\r
-            mainWindow.PictureSettings.drop_modulus.SelectedItem = presetQuery.AnamorphicModulus;\r
+            // Case where both height and max height are 0 - For built-in presets\r
+            if (presetQuery.MaxHeight == 0 && presetQuery.Height == 0)\r
+                mainWindow.PictureSettings.text_height.Value = 0;\r
+\r
+            if (presetQuery.MaxWidth == 0 && presetQuery.Width == 0)\r
+                if (mainWindow.selectedTitle != null && mainWindow.selectedTitle.Resolution.Width != 0)\r
+                    mainWindow.PictureSettings.text_width.Value = mainWindow.selectedTitle.Resolution.Width;\r
 \r
+            // Custom Anamorphic Controls\r
+            mainWindow.PictureSettings.updownDisplayWidth.Text = presetQuery.displayWidthValue.ToString();\r
+            mainWindow.PictureSettings.updownParHeight.Text = presetQuery.pixelAspectWidth.ToString();\r
+            mainWindow.PictureSettings.updownParWidth.Text = presetQuery.pixelAspectHeight.ToString();\r
+            mainWindow.PictureSettings.drp_modulus.SelectedItem = presetQuery.AnamorphicModulus;\r
 \r
             #endregion\r
 \r
@@ -158,15 +159,10 @@ namespace Handbrake.Functions
                 mainWindow.radio_cq.Checked = true;\r
                 if (presetQuery.VideoEncoder == "H.264 (x264)")\r
                 {\r
+                    double cqStep = Properties.Settings.Default.x264cqstep;\r
                     int value;\r
-                    System.Globalization.CultureInfo culture = System.Globalization.CultureInfo.CreateSpecificCulture("en-US");\r
-\r
-                    double x264step;\r
+                    double x264step = cqStep;\r
                     double presetValue = presetQuery.VideoQuality;\r
-                    double.TryParse(Properties.Settings.Default.x264cqstep,\r
-                                    System.Globalization.NumberStyles.Number,\r
-                                    culture,\r
-                                    out x264step);\r
 \r
                     double x = 51 / x264step;\r
 \r
@@ -182,8 +178,8 @@ namespace Handbrake.Functions
                         double val = Math.Round(calculated, 0);\r
                         int.TryParse(val.ToString(), out value);\r
                     }\r
-\r
-                    mainWindow.slider_videoQuality.Value = value;\r
+                    if (value < mainWindow.slider_videoQuality.Maximum)\r
+                        mainWindow.slider_videoQuality.Value = value;\r
                 }\r
                 else\r
                 {\r
@@ -195,7 +191,6 @@ namespace Handbrake.Functions
 \r
             mainWindow.check_2PassEncode.CheckState = presetQuery.TwoPass ? CheckState.Checked : CheckState.Unchecked;\r
 \r
-\r
             mainWindow.drp_videoFramerate.Text = presetQuery.VideoFramerate;\r
 \r
             mainWindow.check_turbo.CheckState = presetQuery.TurboFirstPass ? CheckState.Checked : CheckState.Unchecked;\r
@@ -216,12 +211,12 @@ namespace Handbrake.Functions
 \r
             #region Audio\r
             // Clear the audio listing\r
-            mainWindow.AudioSettings.clearAudioList();\r
+            mainWindow.AudioSettings.ClearAudioList();\r
 \r
             if (presetQuery.AudioInformation != null)\r
                 foreach (AudioTrack track in presetQuery.AudioInformation)\r
                 {\r
-                    ListViewItem newTrack = new ListViewItem(mainWindow.AudioSettings.getNewID().ToString());\r
+                    ListViewItem newTrack = new ListViewItem(mainWindow.AudioSettings.GetNewID().ToString());\r
 \r
                     newTrack.SubItems.Add("Automatic");\r
                     newTrack.SubItems.Add(track.Encoder);\r
@@ -232,7 +227,7 @@ namespace Handbrake.Functions
                     else\r
                         newTrack.SubItems.Add(track.Bitrate);\r
                     newTrack.SubItems.Add(track.DRC);\r
-                    mainWindow.AudioSettings.addTrackForPreset(newTrack);\r
+                    mainWindow.AudioSettings.AddTrackForPreset(newTrack);\r
                 }\r
             #endregion\r
 \r
@@ -240,7 +235,7 @@ namespace Handbrake.Functions
             mainWindow.x264Panel.x264Query = presetQuery.H264Query;\r
 \r
             // Set the preset name\r
-            mainWindow.groupBox_output.Text = "Output Settings (Preset: " + name + ")";\r
+            mainWindow.labelPreset.Text = "Output Settings (Preset: " + name + ")";\r
             #endregion\r
         }\r
     }\r