OSDN Git Service

WinGui:
authorsr55 <sr55@b64f7644-9d1e-0410-96f1-a4d463321fa5>
Thu, 30 Jul 2009 16:10:24 +0000 (16:10 +0000)
committersr55 <sr55@b64f7644-9d1e-0410-96f1-a4d463321fa5>
Thu, 30 Jul 2009 16:10:24 +0000 (16:10 +0000)
- Picture Settings Custom Anamorphic feature, Keep AR mode completed.

git-svn-id: svn://localhost/HandBrake/trunk@2738 b64f7644-9d1e-0410-96f1-a4d463321fa5

win/C#/Controls/PictureSettings.cs
win/C#/frmMain.cs

index 84d3972..8352f52 100644 (file)
@@ -7,27 +7,6 @@ using Handbrake.Parsing;
 \r
 namespace Handbrake.Controls\r
 {\r
-\r
-    //  TODO Custom Anamorphic\r
-    /*  NOT KEEPING DISPLAY ASPECT   == [Complete]\r
-       \r
-        KEEPING DISPLAY ASPECT RATIO == [TODO]\r
-        DAR = DISPLAY WIDTH / DISPLAY HEIGHT (cache after every modification)\r
-        Disable editing: PIXEL WIDTH, PIXEL HEIGHT\r
-        Changing DISPLAY WIDTH:\r
-            Changes HEIGHT to keep DAR\r
-            Changes PIXEL WIDTH to new DISPLAY WIDTH\r
-            Changes PIXEL HEIGHT to STORAGE WIDTH\r
-        Changing HEIGHT\r
-            Changes DISPLAY WIDTH to keep DAR\r
-            Changes PIXEL WIDTH to new DISPLAY WIDTH\r
-            Changes PIXEL HEIGHT to STORAGE WIDTH\r
-        Changing STORAGE_WIDTH:\r
-            Changes PIXEL WIDTH to DISPLAY WIDTH\r
-            Changes PIXEL HEIGHT to new STORAGE WIDTH\r
-     * */\r
-\r
-\r
     public partial class PictureSettings : UserControl\r
     {\r
         private readonly CultureInfo Culture = new CultureInfo("en-US", false);\r
@@ -35,6 +14,7 @@ namespace Handbrake.Controls
 \r
         private Boolean preventChangingWidth, preventChangingHeight, preventChangingCustom, preventChangingDisplayWidth;\r
         private int _PresetMaximumWidth, _PresetMaximumHeight;\r
+        private double cachedDar;\r
         private Title _SourceTitle;\r
 \r
         public PictureSettings()\r
@@ -86,6 +66,7 @@ namespace Handbrake.Controls
                 updownDisplayWidth.Value = calculateAnamorphicSizes().Width;\r
                 updownParWidth.Value = _SourceTitle.ParVal.Width;\r
                 updownParHeight.Value = _SourceTitle.ParVal.Height;\r
+                cachedDar = (double)updownDisplayWidth.Value / (double)text_height.Value;\r
             }\r
         }\r
 \r
@@ -155,6 +136,12 @@ namespace Handbrake.Controls
 \r
                         labelDisplaySize.Text = Math.Truncate(updownDisplayWidth.Value) + "x" + text_height.Value;\r
                     }\r
+\r
+                    if (check_KeepAR.CheckState == CheckState.Checked && Source != null)\r
+                    {\r
+                        updownParWidth.Value = updownDisplayWidth.Value;\r
+                        updownParHeight.Value = text_width.Value;\r
+                    }\r
                     break;\r
                 default:\r
                     labelDisplaySize.Text = calculateAnamorphicSizes().Width + "x" + calculateAnamorphicSizes().Height;\r
@@ -192,6 +179,27 @@ namespace Handbrake.Controls
                     break;\r
                 case 3:\r
                     labelDisplaySize.Text = Math.Truncate(updownDisplayWidth.Value) + "x" + text_height.Value;\r
+\r
+                    if (check_KeepAR.CheckState == CheckState.Checked && Source != null)\r
+                    {\r
+                        // - Changes DISPLAY WIDTH to keep DAR\r
+                        // - Changes PIXEL WIDTH to new DISPLAY WIDTH\r
+                        // - Changes PIXEL HEIGHT to STORAGE WIDTH\r
+                        // DAR = DISPLAY WIDTH / DISPLAY HEIGHT (cache after every modification)\r
+\r
+                        double rawCalculatedDisplayWidth = (double)text_height.Value * cachedDar;\r
+\r
+                        preventChangingDisplayWidth = true; // Start Guards\r
+                        preventChangingWidth = true;\r
+\r
+                        updownDisplayWidth.Value = (decimal)rawCalculatedDisplayWidth;\r
+                        updownParWidth.Value = updownDisplayWidth.Value;\r
+                        updownParHeight.Value = text_width.Value;\r
+\r
+                        preventChangingWidth = false; // Reset Guards\r
+                        preventChangingDisplayWidth = false;\r
+                    }\r
+\r
                     break;\r
                 default:\r
                     labelDisplaySize.Text = calculateAnamorphicSizes().Width + "x" + calculateAnamorphicSizes().Height;\r
@@ -226,6 +234,29 @@ namespace Handbrake.Controls
                 updownParHeight.Value = text_width.Value;\r
                 preventChangingCustom = false;\r
             }\r
+\r
+            if (preventChangingDisplayWidth == false  && check_KeepAR.CheckState == CheckState.Checked)\r
+            {\r
+                // - Changes HEIGHT to keep DAR\r
+                // - Changes PIXEL WIDTH to new DISPLAY WIDTH\r
+                // - Changes PIXEL HEIGHT to STORAGE WIDTH\r
+                // DAR = DISPLAY WIDTH / DISPLAY HEIGHT (cache after every modification)\r
+\r
+                // Calculate new Height Value\r
+                int modulus = 16;\r
+                int.TryParse(drp_modulus.SelectedItem.ToString(), out modulus);\r
+\r
+                int rawCalculatedHeight = (int) ((int)updownDisplayWidth.Value/cachedDar);\r
+                int modulusHeight = rawCalculatedHeight - (rawCalculatedHeight % modulus);\r
+\r
+                // Update value\r
+                preventChangingHeight = true;\r
+                text_height.Value = (decimal)modulusHeight;\r
+                updownParWidth.Value = updownDisplayWidth.Value;\r
+                updownParHeight.Value = text_width.Value;\r
+                preventChangingHeight = false;  \r
+            }\r
+           \r
         }\r
 \r
         // Anamorphic Controls\r
index 0f27287..e40f558 100644 (file)
@@ -1710,7 +1710,6 @@ namespace Handbrake
         #endregion\r
 \r
         #region In-GUI Encode Status (Experimental)\r
-\r
         private void encodeMonitorThread()\r
         {\r
             try\r
@@ -1718,13 +1717,11 @@ namespace Handbrake
                 Parser encode = new Parser(encodeQueue.hbProcess.StandardOutput.BaseStream);\r
                 encode.OnEncodeProgress += encodeOnEncodeProgress;\r
                 while (!encode.EndOfStream)\r
-                {\r
                     encode.readEncodeStatus();\r
-                }\r
             }\r
             catch (Exception exc)\r
             {\r
-                MessageBox.Show(exc.ToString());\r
+                MessageBox.Show(exc.ToString(), "Error", MessageBoxButtons.OK, MessageBoxIcon.Error);\r
             }\r
         }\r
         private void encodeOnEncodeProgress(object Sender, int CurrentTask, int TaskCount, float PercentComplete, float CurrentFps, float AverageFps, TimeSpan TimeRemaining)\r