OSDN Git Service

WinGui:
[handbrake-jp/handbrake-jp-git.git] / win / C# / Functions / PresetLoader.cs
index 6730b8e..1366414 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,14 +46,9 @@ namespace Handbrake.Functions
 \r
             if (presetQuery.Format != null)\r
             {\r
-                if (presetQuery.Format == "mp4")\r
+                if (presetQuery.Format == "mp4" || presetQuery.Format == "m4v")\r
                     mainWindow.drop_format.SelectedIndex = 0;\r
-                else if (presetQuery.Format == "m4v")\r
-                    mainWindow.drop_format.SelectedIndex = 1;\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
 \r
@@ -67,14 +63,12 @@ namespace Handbrake.Functions
             #endregion\r
 \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
+                mainWindow.PictureSettings.check_autoCrop.Checked = true;\r
+\r
+                if (presetQuery.CropValues != null)\r
                 {\r
                     int top, bottom, left, right;\r
                     int.TryParse(presetQuery.CropTop, out top);\r
@@ -89,43 +83,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
@@ -159,8 +152,6 @@ namespace Handbrake.Functions
                 if (presetQuery.VideoEncoder == "H.264 (x264)")\r
                 {\r
                     int value;\r
-                    System.Globalization.CultureInfo culture = System.Globalization.CultureInfo.CreateSpecificCulture("en-US");\r
-\r
                     double x264step = Properties.Settings.Default.x264cqstep;\r
                     double presetValue = presetQuery.VideoQuality;\r
 \r
@@ -178,10 +169,7 @@ namespace Handbrake.Functions
                         double val = Math.Round(calculated, 0);\r
                         int.TryParse(val.ToString(), out value);\r
                     }\r
-\r
-                    int safevalue;\r
-                    int.TryParse(value.ToString(culture), out safevalue);\r
-                    mainWindow.slider_videoQuality.Value = safevalue;\r
+                    mainWindow.slider_videoQuality.Value = value;\r
                 }\r
                 else\r
                 {\r
@@ -238,7 +226,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