]> granicus.if.org Git - handbrake/commitdiff
WinGui:
authorsr55 <sr55.hb@outlook.com>
Sat, 4 Jul 2009 19:55:51 +0000 (19:55 +0000)
committersr55 <sr55.hb@outlook.com>
Sat, 4 Jul 2009 19:55:51 +0000 (19:55 +0000)
- Move all the GUI enable/disable property changes into one function for the picture panel.

git-svn-id: svn://svn.handbrake.fr/HandBrake/trunk@2665 b64f7644-9d1e-0410-96f1-a4d463321fa5

win/C#/Controls/PictureSettings.cs
win/C#/Functions/PresetLoader.cs

index bd367d464c3c3b62544a4d6d8e2b85236567e647..108241a5ba0de5f0f4db5667eeb92b359c523c83 100644 (file)
@@ -193,12 +193,8 @@ namespace Handbrake.Controls
             switch (drp_anamorphic.SelectedIndex)\r
             {\r
                 case 0: // None\r
-                    text_height.Enabled = true;\r
-                    text_width.Enabled = true;\r
                     check_KeepAR.CheckState = CheckState.Checked;\r
-                    check_KeepAR.Enabled = true;\r
-                    disableCustomAnaControls();\r
-                    check_KeepAR.Enabled = true;\r
+                    anamorphicWidgetContoller(0);\r
                     if (selectedTitle != null)\r
                     {\r
                         text_width.Value = maxWidth != 0 ? maxWidth : selectedTitle.Resolution.Width;\r
@@ -206,7 +202,6 @@ namespace Handbrake.Controls
                         setMax();\r
                     }\r
                     lbl_anamorphic.Text = "";\r
-                    lbl_anamprohicLbl.Visible = false;\r
                     break;\r
                 case 1: // Strict\r
                     if (selectedTitle != null)\r
@@ -217,19 +212,13 @@ namespace Handbrake.Controls
                         text_height.Value = selectedTitle.Resolution.Height - (int)crop_top.Value -\r
                                             (int)crop_bottom.Value;\r
                     }\r
-                    text_height.Enabled = false;\r
-                    text_width.Enabled = false;\r
+                    anamorphicWidgetContoller(1);\r
                     check_KeepAR.CheckState = CheckState.Unchecked;\r
-                    check_KeepAR.Enabled = false;\r
-                    disableCustomAnaControls();\r
                     lbl_anamorphic.Text = strictAnamorphic();\r
-                    lbl_anamprohicLbl.Visible = true;\r
                     break;\r
                 case 2: // Loose\r
-                    disableCustomAnaControls();\r
+                    anamorphicWidgetContoller(2);\r
                     storageAspect = 0;\r
-                    text_height.Enabled = false;\r
-                    text_width.Enabled = true;\r
                     if (selectedTitle != null)\r
                     {\r
                         heightModJumpGaurd = true;\r
@@ -238,14 +227,9 @@ namespace Handbrake.Controls
                                             (int)crop_bottom.Value;\r
                     }\r
                     lbl_anamorphic.Text = looseAnamorphic();\r
-                    lbl_anamprohicLbl.Visible = true;\r
                     break;\r
                 case 3: // Custom\r
-\r
-                    // Display Elements\r
-                    enableCustomAnaControls();\r
-                    text_height.Enabled = true;\r
-                    text_width.Enabled = true;\r
+                    anamorphicWidgetContoller(3);  // Display Elements\r
 \r
                     // Actual Work  \r
                     if (selectedTitle != null)\r
@@ -262,18 +246,13 @@ namespace Handbrake.Controls
                     }\r
 \r
                     darValue = calculateDar();\r
-\r
                     check_KeepAR.CheckState = CheckState.Checked;\r
-                    check_KeepAR.Enabled = true;\r
-                    lbl_anamprohicLbl.Visible = true;\r
-\r
                     break;\r
             }\r
 \r
             // A Picture Setting has changed so raise a PictureSettingsChanged event.\r
             if (this.PictureSettingsChanged != null)\r
                 this.PictureSettingsChanged(this, new EventArgs());\r
-\r
         }\r
 \r
         // Custom Anamorphic Controls\r
@@ -584,7 +563,7 @@ namespace Handbrake.Controls
 \r
             return newValue;\r
         }\r
-        private int getResolutionJump(int mod, decimal value, Boolean up)\r
+        private static int getResolutionJump(int mod, decimal value, Boolean up)\r
         {\r
             if (up)\r
                 while ((value % mod) != 0)\r
@@ -595,7 +574,7 @@ namespace Handbrake.Controls
 \r
             return (int)value;\r
         }\r
-        private double getModulusAuto(int mod, double value)\r
+        private static double getModulusAuto(int mod, double value)\r
         {\r
             int modDiv2 = mod / 2;\r
 \r
@@ -696,7 +675,6 @@ namespace Handbrake.Controls
         // Calculate Resolution for Anamorphic functions\r
         private string strictAnamorphic()\r
         {\r
-            // TODO Make sure cropping is Mod2\r
             if (selectedTitle != null)\r
             {\r
                 // Calculate the Actual Height\r
@@ -730,7 +708,7 @@ namespace Handbrake.Controls
 \r
                 if (newHeight < 64)\r
                     newHeight = 64;\r
-                text_height.Value = (decimal)newHeight;   // BUG Out of Range Exception with Width too low here.\r
+                text_height.Value = (decimal)newHeight; \r
 \r
                 // Calculate the anamorphic width\r
                 double parW = newHeight * source_display_width / source_cropped_height;\r
@@ -741,35 +719,66 @@ namespace Handbrake.Controls
                 return Math.Truncate(displayWidth) + "x" + newHeight;\r
             }\r
             return "Select a Title";\r
-\r
         }\r
 \r
-        // GUI\r
-        private void disableCustomAnaControls()\r
-        {\r
-            // Disable Custom Anamorphic Stuff\r
-            lbl_modulus.Visible = false;\r
-            lbl_displayWidth.Visible = false;\r
-            lbl_parWidth.Visible = false;\r
-            lbl_parHeight.Visible = false;\r
-            drop_modulus.Visible = false;\r
-            txt_displayWidth.Visible = false;\r
-            txt_parWidth.Visible = false;\r
-            txt_parHeight.Visible = false;\r
-            check_KeepAR.Enabled = false;\r
-        }\r
-        private void enableCustomAnaControls()\r
-        {\r
-            // Disable Custom Anamorphic Stuff\r
-            lbl_modulus.Visible = true;\r
-            lbl_displayWidth.Visible = true;\r
-            lbl_parWidth.Visible = true;\r
-            lbl_parHeight.Visible = true;\r
-            drop_modulus.Visible = true;\r
-            txt_displayWidth.Visible = true;\r
-            txt_parWidth.Visible = true;\r
-            txt_parHeight.Visible = true;\r
-            check_KeepAR.Enabled = true;\r
+        // Function to control the enable / disable property of the display controls.\r
+        private void anamorphicWidgetContoller(int mode)\r
+        {\r
+\r
+            switch (mode)\r
+            {\r
+                case 0: // None\r
+                    text_height.Enabled = true;\r
+                    text_width.Enabled = true;\r
+                    check_KeepAR.Enabled = true;\r
+                    lbl_anamprohicLbl.Visible = false;\r
+                    break;\r
+                case 1: // Strict\r
+                    text_height.Enabled = false;\r
+                    text_width.Enabled = false;\r
+                    check_KeepAR.Enabled = false;\r
+                    lbl_anamprohicLbl.Visible = true;\r
+                    break;\r
+                case 2: // Loose\r
+                    text_height.Enabled = false;\r
+                    text_width.Enabled = true;\r
+                    check_KeepAR.Enabled = false;\r
+                    lbl_anamprohicLbl.Visible = true;\r
+                    break;\r
+                case 3: // Custom\r
+                    text_height.Enabled = true;\r
+                    text_width.Enabled = true;\r
+                    check_KeepAR.Enabled = true;\r
+                    // Labels\r
+                    lbl_anamprohicLbl.Visible = true;\r
+                    lbl_modulus.Visible = true;\r
+                    lbl_displayWidth.Visible = true;\r
+                    lbl_parWidth.Visible = true;\r
+                    lbl_parHeight.Visible = true;\r
+                    // Controls\r
+                    drop_modulus.Visible = true;\r
+                    txt_displayWidth.Visible = true;\r
+                    txt_parWidth.Visible = true;\r
+                    txt_parHeight.Visible = true;\r
+                    break;\r
+            }\r
+\r
+            // Disable All the custom anamorphic controls if not required.\r
+            if (mode != 3)\r
+            {\r
+                // Labels\r
+                lbl_modulus.Visible = false;\r
+                lbl_displayWidth.Visible = false;\r
+                lbl_parWidth.Visible = false;\r
+                lbl_parHeight.Visible = false;\r
+\r
+                // Controls\r
+                drop_modulus.Visible = false;\r
+                txt_displayWidth.Visible = false;\r
+                txt_parWidth.Visible = false;\r
+                txt_parHeight.Visible = false;\r
+\r
+            }\r
         }\r
 \r
     }\r
index 0b72d2915c0051d75eac94f9bc1a2ebd9c19d343..912d6e519b361a2b853be26b00c13bffa8d43f65 100644 (file)
@@ -123,15 +123,12 @@ namespace Handbrake.Functions
 \r
             mainWindow.PictureSettings.setMax();\r
 \r
-            \r
-\r
             // Custom Anamorphic Controls\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
 \r
-\r
             #endregion\r
 \r
             #region Filters\r