OSDN Git Service

WinGui:
[handbrake-jp/handbrake-jp-git.git] / win / C# / Controls / PictureSettings.cs
index 7704a36..88f0e8f 100644 (file)
@@ -6,18 +6,16 @@ using Handbrake.Parsing;
 namespace Handbrake.Controls\r
 {\r
     // TODO\r
-\r
-    // - Fix MAX Width / Height Code.\r
     // - Tie in the cropping controls.\r
     \r
     public partial class PictureSettings : UserControl\r
     {\r
         // Globals\r
-        int maxWidth, maxHeight;\r
+        public int maxWidth, maxHeight;\r
         int widthVal, heightVal;\r
         private double darValue;\r
-        private double storageAspect = 0; // Storage Aspect Cache for current source and title\r
-        public Title selectedTitle { get; set; }\r
+        private double storageAspect; // Storage Aspect Cache for current source and title\r
+        public Title selectedTitle { private get; set; }\r
         private Boolean heightChangeGuard;\r
         private Boolean looseAnamorphicHeightGuard;\r
         private Boolean heightModJumpGaurd;\r
@@ -61,14 +59,14 @@ namespace Handbrake.Controls
                 text_height.Value = selectedTitle.Resolution.Height - (int)crop_top.Value - (int)crop_bottom.Value;\r
             }\r
 \r
-\r
-\r
             if (drp_anamorphic.SelectedIndex == 3)\r
             {\r
                 txt_parWidth.Text = selectedTitle.ParVal.Width.ToString();\r
                 txt_parHeight.Text = selectedTitle.ParVal.Height.ToString();\r
                 txt_displayWidth.Text = displayWidth().ToString();\r
             }\r
+\r
+            setMax();\r
         }\r
         public void setMax()\r
         {\r
@@ -83,6 +81,9 @@ namespace Handbrake.Controls
         // Basic Picture Setting Controls\r
         private void text_width_ValueChanged(object sender, EventArgs e)\r
         {\r
+            maxWidth = 0;\r
+            setMax();\r
+            \r
             // Get the Modulus\r
             int mod;\r
             int.TryParse(drop_modulus.SelectedItem.ToString(), out mod);\r
@@ -94,7 +95,7 @@ namespace Handbrake.Controls
             switch (drp_anamorphic.SelectedIndex)\r
             {\r
                 case 0:\r
-                    if (calculateUnchangeValue(true) != -1)\r
+                    if (calculateUnchangeValue(true) != -1 && check_KeepAR.Checked)\r
                         text_height.Value = calculateUnchangeValue(true);\r
                     break;\r
                 case 1:\r
@@ -111,6 +112,9 @@ namespace Handbrake.Controls
         }\r
         private void text_height_ValueChanged(object sender, EventArgs e)\r
         {\r
+            maxHeight = 0;\r
+            setMax();\r
+\r
             // Get the Modulus\r
             int mod;\r
             int.TryParse(drop_modulus.SelectedItem.ToString(), out mod);\r
@@ -176,22 +180,21 @@ namespace Handbrake.Controls
             switch (drp_anamorphic.SelectedIndex)\r
             {\r
                 case 0: // None\r
-                    text_height.BackColor = Color.White;\r
-                    text_width.BackColor = Color.White;\r
                     text_height.Enabled = true;\r
                     text_width.Enabled = true;\r
                     check_KeepAR.CheckState = CheckState.Checked;\r
                     check_KeepAR.Enabled = true;\r
                     disableCustomAnaControls();\r
-                    text_width.Text = widthVal.ToString();\r
-                    text_height.Text = heightVal.ToString();\r
+                    if (selectedTitle != null)\r
+                    {\r
+                        text_width.Value = selectedTitle.Resolution.Width;\r
+                        text_height.Value = selectedTitle.Resolution.Height;\r
+                    }\r
                     check_KeepAR.Enabled = true;\r
                     lbl_anamorphic.Text = "";\r
                     lbl_anamprohicLbl.Visible = false;\r
                     break;\r
                 case 1: // Strict\r
-                    text_height.BackColor = Color.LightGray;\r
-                    text_width.BackColor = Color.LightGray;\r
                     if (selectedTitle != null)\r
                     {\r
                         heightModJumpGaurd = true;\r
@@ -210,13 +213,11 @@ namespace Handbrake.Controls
                     disableCustomAnaControls();\r
                     storageAspect = 0;\r
                     text_height.Enabled = false;\r
-                    text_height.BackColor = Color.LightGray;\r
                     text_width.Enabled = true;\r
-                    text_width.BackColor = Color.White;\r
                     if (selectedTitle != null)\r
                     {\r
                         heightModJumpGaurd = true;\r
-                        text_width.Value = selectedTitle.Resolution.Width - (int) crop_left.Value - (int) crop_right.Value;\r
+                        text_width.Value = selectedTitle.Resolution.Width;\r
                         text_height.Value = selectedTitle.Resolution.Height - (int) crop_top.Value - (int) crop_bottom.Value;\r
                     }\r
                     lbl_anamorphic.Text = looseAnamorphic();\r
@@ -226,8 +227,6 @@ namespace Handbrake.Controls
 \r
                     // Display Elements\r
                     enableCustomAnaControls();\r
-                    text_height.BackColor = Color.White;\r
-                    text_width.BackColor = Color.White;\r
                     text_height.Enabled = true;\r
                     text_width.Enabled = true;\r
 \r
@@ -270,7 +269,7 @@ namespace Handbrake.Controls
                 customAnamorphic(txt_parWidth);\r
         }\r
         \r
-        // Cropping Control\r
+        // Cropping Controls\r
         private void check_autoCrop_CheckedChanged(object sender, EventArgs e)\r
         {\r
             crop_left.Enabled = false;\r
@@ -299,6 +298,26 @@ namespace Handbrake.Controls
                 crop_bottom.Text = "0";\r
             }\r
         }\r
+        private void crop_left_ValueChanged(object sender, EventArgs e)\r
+        {\r
+            if (crop_left.Value % 2 != 0)\r
+                crop_left.Value++;\r
+        }\r
+        private void crop_right_ValueChanged(object sender, EventArgs e)\r
+        {\r
+            if (crop_right.Value % 2 != 0)\r
+                crop_right.Value++;\r
+        }\r
+        private void crop_top_ValueChanged(object sender, EventArgs e)\r
+        {\r
+            if (crop_top.Value % 2 != 0)\r
+                crop_top.Value++;\r
+        }\r
+        private void crop_bottom_ValueChanged(object sender, EventArgs e)\r
+        {\r
+            if (crop_bottom.Value % 2 != 0)\r
+                crop_bottom.Value++;\r
+        }\r
 \r
         // Custom Anamorphic Code\r
         private void customAnamorphic(Control control)\r