OSDN Git Service

WinGui:
authorsr55 <sr55@b64f7644-9d1e-0410-96f1-a4d463321fa5>
Fri, 12 Mar 2010 21:59:52 +0000 (21:59 +0000)
committersr55 <sr55@b64f7644-9d1e-0410-96f1-a4d463321fa5>
Fri, 12 Mar 2010 21:59:52 +0000 (21:59 +0000)
Two new options for autocrop.
- Remove Underscores from source name.
- Change to Title Case. (e.g  "Source Name")

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

win/C#/Functions/Main.cs
win/C#/Properties/Settings.Designer.cs
win/C#/Properties/Settings.settings
win/C#/app.config
win/C#/frmOptions.Designer.cs
win/C#/frmOptions.cs

index 3285b5f..ff18317 100644 (file)
@@ -8,8 +8,10 @@ namespace Handbrake.Functions
     using System;\r
     using System.Collections.Generic;\r
     using System.Diagnostics;\r
+    using System.Globalization;\r
     using System.IO;\r
     using System.Net;\r
+    using System.Text;\r
     using System.Text.RegularExpressions;\r
     using System.Threading;\r
     using System.Windows.Forms;\r
@@ -151,7 +153,7 @@ namespace Handbrake.Functions
             foreach (DataGridViewRow item in dataChpt.Rows)\r
             {\r
                 string name;\r
-                chapterMap.TryGetValue((int) item.Cells[0].Value, out name);\r
+                chapterMap.TryGetValue((int)item.Cells[0].Value, out name);\r
                 item.Cells[1].Value = name ?? "Chapter " + item.Cells[0].Value;\r
             }\r
 \r
@@ -176,6 +178,12 @@ namespace Handbrake.Functions
                 // Get the Source Name \r
                 string sourceName = mainWindow.SourceName;\r
 \r
+                if (Properties.Settings.Default.AutoNameRemoveUnderscore)\r
+                    sourceName = sourceName.Replace("_", " ");\r
+\r
+                if (Properties.Settings.Default.AutoNameTitleCase)\r
+                    sourceName = TitleCase(sourceName);\r
+\r
                 // Get the Selected Title Number\r
                 string[] titlesplit = mainWindow.drp_dvdtitle.Text.Split(' ');\r
                 string dvdTitle = titlesplit[0].Replace("Automatic", string.Empty);\r
@@ -254,9 +262,9 @@ namespace Handbrake.Functions
             Process cliProcess = new Process();\r
             ProcessStartInfo handBrakeCli = new ProcessStartInfo("HandBrakeCLI.exe", " -u -v0")\r
                                                 {\r
-                                                    UseShellExecute = false, \r
-                                                    RedirectStandardError = true, \r
-                                                    RedirectStandardOutput = true, \r
+                                                    UseShellExecute = false,\r
+                                                    RedirectStandardError = true,\r
+                                                    RedirectStandardOutput = true,\r
                                                     CreateNoWindow = true\r
                                                 };\r
             cliProcess.StartInfo = handBrakeCli;\r
@@ -471,7 +479,7 @@ namespace Handbrake.Functions
                                                                           UpdateCheckInformation info =\r
                                                                               new UpdateCheckInformation\r
                                                                                   {\r
-                                                                                      NewVersionAvailable = false, \r
+                                                                                      NewVersionAvailable = false,\r
                                                                                       BuildInformation = null\r
                                                                                   };\r
                                                                           callback(new UpdateCheckResult(debug, info));\r
@@ -486,7 +494,7 @@ namespace Handbrake.Functions
                                                                       UpdateCheckInformation info2 =\r
                                                                           new UpdateCheckInformation\r
                                                                               {\r
-                                                                                  NewVersionAvailable = latest > current, \r
+                                                                                  NewVersionAvailable = latest > current,\r
                                                                                   BuildInformation = reader\r
                                                                               };\r
                                                                       callback(new UpdateCheckResult(debug, info2));\r
@@ -509,7 +517,7 @@ namespace Handbrake.Functions
         /// </returns>\r
         public static UpdateCheckInformation EndCheckForUpdates(IAsyncResult result)\r
         {\r
-            UpdateCheckResult checkResult = (UpdateCheckResult) result;\r
+            UpdateCheckResult checkResult = (UpdateCheckResult)result;\r
             return checkResult.Result;\r
         }\r
 \r
@@ -728,7 +736,7 @@ namespace Handbrake.Functions
                     drives.Add(new DriveInformation\r
                                    {\r
                                        Id = id,\r
-                                       VolumeLabel = curDrive.VolumeLabel, \r
+                                       VolumeLabel = curDrive.VolumeLabel,\r
                                        RootDirectory = curDrive.RootDirectory + "VIDEO_TS"\r
                                    });\r
                     id++;\r
@@ -736,5 +744,21 @@ namespace Handbrake.Functions
             }\r
             return drives;\r
         }\r
+\r
+        public static string TitleCase(string input)\r
+        {\r
+            string[] tokens = input.Split(' ');\r
+            StringBuilder sb = new StringBuilder(input.Length);\r
+            foreach (string s in tokens)\r
+            {\r
+                sb.Append(s[0].ToString().ToUpper());\r
+                sb.Append(s.Substring(1).ToLower());\r
+                sb.Append(" ");\r
+            }\r
+\r
+            return sb.ToString().Trim();\r
+        }\r
+\r
+\r
     }\r
 }
\ No newline at end of file
index 1a15914..c911a94 100644 (file)
@@ -500,5 +500,29 @@ namespace Handbrake.Properties {
                 this["showCliForInGuiEncodeStatus"] = value;\r
             }\r
         }\r
+        \r
+        [global::System.Configuration.UserScopedSettingAttribute()]\r
+        [global::System.Diagnostics.DebuggerNonUserCodeAttribute()]\r
+        [global::System.Configuration.DefaultSettingValueAttribute("False")]\r
+        public bool AutoNameTitleCase {\r
+            get {\r
+                return ((bool)(this["AutoNameTitleCase"]));\r
+            }\r
+            set {\r
+                this["AutoNameTitleCase"] = value;\r
+            }\r
+        }\r
+        \r
+        [global::System.Configuration.UserScopedSettingAttribute()]\r
+        [global::System.Diagnostics.DebuggerNonUserCodeAttribute()]\r
+        [global::System.Configuration.DefaultSettingValueAttribute("False")]\r
+        public bool AutoNameRemoveUnderscore {\r
+            get {\r
+                return ((bool)(this["AutoNameRemoveUnderscore"]));\r
+            }\r
+            set {\r
+                this["AutoNameRemoveUnderscore"] = value;\r
+            }\r
+        }\r
     }\r
 }\r
index c9c75d0..1e4b938 100644 (file)
     <Setting Name="showCliForInGuiEncodeStatus" Type="System.Boolean" Scope="User">\r
       <Value Profile="(Default)">True</Value>\r
     </Setting>\r
+    <Setting Name="AutoNameTitleCase" Type="System.Boolean" Scope="User">\r
+      <Value Profile="(Default)">False</Value>\r
+    </Setting>\r
+    <Setting Name="AutoNameRemoveUnderscore" Type="System.Boolean" Scope="User">\r
+      <Value Profile="(Default)">False</Value>\r
+    </Setting>\r
   </Settings>\r
 </SettingsFile>
\ No newline at end of file
index d1401d0..1c4e603 100644 (file)
       <setting name="showCliForInGuiEncodeStatus" serializeAs="String">\r
         <value>True</value>\r
       </setting>\r
+      <setting name="AutoNameTitleCase" serializeAs="String">\r
+        <value>False</value>\r
+      </setting>\r
+      <setting name="AutoNameRemoveUnderscore" serializeAs="String">\r
+        <value>False</value>\r
+      </setting>\r
     </Handbrake.Properties.Settings>\r
   </userSettings>\r
   <startup />\r
index dac9e9a..86bdc09 100644 (file)
@@ -40,6 +40,8 @@ namespace Handbrake
             this.drp_completeOption = new System.Windows.Forms.ComboBox();\r
             this.tab_options = new System.Windows.Forms.TabControl();\r
             this.tab_general = new System.Windows.Forms.TabPage();\r
+            this.check_TitleCase = new System.Windows.Forms.CheckBox();\r
+            this.check_removeUnderscores = new System.Windows.Forms.CheckBox();\r
             this.check_growlEncode = new System.Windows.Forms.CheckBox();\r
             this.check_GrowlQueue = new System.Windows.Forms.CheckBox();\r
             this.check_m4v = new System.Windows.Forms.CheckBox();\r
@@ -200,6 +202,8 @@ namespace Handbrake
             // \r
             // tab_general\r
             // \r
+            this.tab_general.Controls.Add(this.check_TitleCase);\r
+            this.tab_general.Controls.Add(this.check_removeUnderscores);\r
             this.tab_general.Controls.Add(this.check_growlEncode);\r
             this.tab_general.Controls.Add(this.check_GrowlQueue);\r
             this.tab_general.Controls.Add(this.check_m4v);\r
@@ -225,6 +229,33 @@ namespace Handbrake
             this.tab_general.Text = "General";\r
             this.tab_general.UseVisualStyleBackColor = true;\r
             // \r
+            // check_TitleCase\r
+            // \r
+            this.check_TitleCase.Anchor = System.Windows.Forms.AnchorStyles.Left;\r
+            this.check_TitleCase.AutoSize = true;\r
+            this.check_TitleCase.Location = new System.Drawing.Point(297, 279);\r
+            this.check_TitleCase.Name = "check_TitleCase";\r
+            this.check_TitleCase.Size = new System.Drawing.Size(151, 17);\r
+            this.check_TitleCase.TabIndex = 101;\r
+            this.check_TitleCase.Text = "Change case to Title Case";\r
+            this.ToolTip.SetToolTip(this.check_TitleCase, "For the {source} option:.\r\nChange the source name to Title Case\r\ne.g \"MOVIE NAME\"" +\r
+                    " to \"Movie Name\"\r\n");\r
+            this.check_TitleCase.UseVisualStyleBackColor = true;\r
+            this.check_TitleCase.CheckedChanged += new System.EventHandler(this.check_TitleCase_CheckedChanged);\r
+            // \r
+            // check_removeUnderscores\r
+            // \r
+            this.check_removeUnderscores.Anchor = System.Windows.Forms.AnchorStyles.Left;\r
+            this.check_removeUnderscores.AutoSize = true;\r
+            this.check_removeUnderscores.Location = new System.Drawing.Point(108, 279);\r
+            this.check_removeUnderscores.Name = "check_removeUnderscores";\r
+            this.check_removeUnderscores.Size = new System.Drawing.Size(183, 17);\r
+            this.check_removeUnderscores.TabIndex = 100;\r
+            this.check_removeUnderscores.Text = "Remove Underscores from Name";\r
+            this.ToolTip.SetToolTip(this.check_removeUnderscores, "For the {source} option:\r\nRemove any underscores from the source name.\r\n\r\n");\r
+            this.check_removeUnderscores.UseVisualStyleBackColor = true;\r
+            this.check_removeUnderscores.CheckedChanged += new System.EventHandler(this.check_removeUnderscores_CheckedChanged);\r
+            // \r
             // check_growlEncode\r
             // \r
             this.check_growlEncode.Anchor = System.Windows.Forms.AnchorStyles.Left;\r
@@ -259,7 +290,7 @@ namespace Handbrake
             // \r
             this.check_m4v.Anchor = System.Windows.Forms.AnchorStyles.Left;\r
             this.check_m4v.AutoSize = true;\r
-            this.check_m4v.Location = new System.Drawing.Point(108, 279);\r
+            this.check_m4v.Location = new System.Drawing.Point(108, 303);\r
             this.check_m4v.Name = "check_m4v";\r
             this.check_m4v.Size = new System.Drawing.Size(319, 17);\r
             this.check_m4v.TabIndex = 82;\r
@@ -1567,5 +1598,7 @@ namespace Handbrake
         private System.Windows.Forms.Label label33;\r
         internal System.Windows.Forms.CheckBox check_clearOldLogs;\r
         internal System.Windows.Forms.CheckBox check_showCliForInGUIEncode;\r
+        internal System.Windows.Forms.CheckBox check_TitleCase;\r
+        internal System.Windows.Forms.CheckBox check_removeUnderscores;\r
     }\r
 }
\ No newline at end of file
index 6aa612d..b5b7429 100644 (file)
@@ -81,6 +81,12 @@ namespace Handbrake
             if (Properties.Settings.Default.useM4v)\r
                 check_m4v.CheckState = CheckState.Checked;\r
 \r
+            // Remove Underscores\r
+            check_removeUnderscores.Checked = Properties.Settings.Default.AutoNameRemoveUnderscore;\r
+\r
+            // Title case\r
+            check_TitleCase.Checked = Properties.Settings.Default.AutoNameTitleCase;\r
+\r
             // #############################\r
             // Picture Tab\r
             // #############################\r
@@ -265,6 +271,16 @@ namespace Handbrake
             Properties.Settings.Default.useM4v = check_m4v.Checked;\r
         }\r
 \r
+        private void check_removeUnderscores_CheckedChanged(object sender, EventArgs e)\r
+        {\r
+            Properties.Settings.Default.AutoNameRemoveUnderscore = check_removeUnderscores.Checked;\r
+        }\r
+\r
+        private void check_TitleCase_CheckedChanged(object sender, EventArgs e)\r
+        {\r
+            Properties.Settings.Default.AutoNameTitleCase = check_TitleCase.Checked;\r
+        }\r
+\r
         #endregion\r
 \r
         #region Picture\r
@@ -471,5 +487,6 @@ namespace Handbrake
             Properties.Settings.Default.Save(); // Small hack for Vista. Seems to work fine on XP without this\r
             this.Close();\r
         }\r
+\r
     }\r
 }
\ No newline at end of file