OSDN Git Service

WinGui:
authorsr55 <sr55@b64f7644-9d1e-0410-96f1-a4d463321fa5>
Mon, 14 Sep 2009 15:07:37 +0000 (15:07 +0000)
committersr55 <sr55@b64f7644-9d1e-0410-96f1-a4d463321fa5>
Mon, 14 Sep 2009 15:07:37 +0000 (15:07 +0000)
- Fix: DVD volume name now used for autoName function rather than Video_TS folder. (Thanks RandomEngy)

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

win/C#/Functions/Main.cs
win/C#/frmMain.cs

index dd618cb..6f8efaa 100644 (file)
@@ -130,7 +130,7 @@ namespace Handbrake.Functions
             if (mainWindow.drp_dvdtitle.Text != "Automatic")\r
             {\r
                 // Get the Source Name \r
-                string sourceName = Path.GetFileNameWithoutExtension(mainWindow.sourcePath);\r
+                string sourceName = mainWindow.SourceName;\r
 \r
                 // Get the Selected Title Number\r
                 string[] titlesplit = mainWindow.drp_dvdtitle.Text.Split(' ');\r
index 2a32be7..4e3a73f 100644 (file)
@@ -35,6 +35,9 @@ namespace Handbrake
         private Form splash;\r
         public string sourcePath;\r
         private string lastAction;\r
+        private SourceType selectedSourceType;\r
+        private string dvdDrivePath;\r
+        private string dvdDriveLabel;\r
 \r
         // Delegates **********************************************************\r
         private delegate void UpdateWindowHandler();\r
@@ -181,6 +184,21 @@ namespace Handbrake
         }\r
         #endregion\r
 \r
+        #region Properties\r
+        public string SourceName\r
+        {\r
+            get\r
+            {\r
+                if (this.selectedSourceType == SourceType.DvdDrive)\r
+                {\r
+                    return this.dvdDriveLabel;\r
+                }\r
+\r
+                return Path.GetFileNameWithoutExtension(this.sourcePath);\r
+            }\r
+        }\r
+        #endregion\r
+\r
         #region Events\r
         // Encoding Events for setting up the GUI\r
         private void events()\r
@@ -825,22 +843,28 @@ namespace Handbrake
         private void btn_dvd_source_Click(object sender, EventArgs e)\r
         {\r
             if (DVD_Open.ShowDialog() == DialogResult.OK)\r
+            {\r
+                this.selectedSourceType = SourceType.Folder;\r
                 selectSource(DVD_Open.SelectedPath);\r
+            }\r
             else\r
                 UpdateSourceLabel();\r
         }\r
         private void btn_file_source_Click(object sender, EventArgs e)\r
         {\r
             if (ISO_Open.ShowDialog() == DialogResult.OK)\r
+            {\r
+                this.selectedSourceType = SourceType.VideoFile;\r
                 selectSource(ISO_Open.FileName);\r
+            }\r
             else\r
                 UpdateSourceLabel();\r
         }\r
         private void mnu_dvd_drive_Click(object sender, EventArgs e)\r
         {\r
-            if (!mnu_dvd_drive.Text.Contains("VIDEO_TS")) return;\r
-            string[] path = mnu_dvd_drive.Text.Split(' ');\r
-            selectSource(path[0]);\r
+            if (this.dvdDrivePath == null) return;\r
+            this.selectedSourceType = SourceType.DvdDrive;\r
+            selectSource(this.dvdDrivePath);\r
         }\r
         private void selectSource(string file)\r
         {\r
@@ -1573,7 +1597,7 @@ namespace Handbrake
         }\r
         private void UpdateSourceLabel()\r
         {\r
-            labelSource.Text = string.IsNullOrEmpty(sourcePath) ? "Select \"Source\" to continue." : Path.GetFileName(sourcePath);\r
+            labelSource.Text = string.IsNullOrEmpty(sourcePath) ? "Select \"Source\" to continue." : this.SourceName;\r
         }\r
         #endregion\r
 \r
@@ -1655,7 +1679,9 @@ namespace Handbrake
                     {\r
                         if (File.Exists(curDrive.RootDirectory + "VIDEO_TS\\VIDEO_TS.IFO"))\r
                         {\r
-                            mnu_dvd_drive.Text = curDrive.RootDirectory + "VIDEO_TS (" + curDrive.VolumeLabel + ")";\r
+                            this.dvdDrivePath = curDrive.RootDirectory + "VIDEO_TS";\r
+                            this.dvdDriveLabel = curDrive.VolumeLabel;\r
+                            mnu_dvd_drive.Text = this.dvdDrivePath + " (" + this.dvdDriveLabel + ")";\r
                             foundDrive = true;\r
                             break;\r
                         }\r
@@ -1735,6 +1761,16 @@ namespace Handbrake
         }\r
         #endregion\r
 \r
+        #region enum\r
+        private enum SourceType\r
+        {\r
+            None = 0,\r
+            Folder,\r
+            DvdDrive,\r
+            VideoFile\r
+        }\r
+        #endregion\r
+\r
         // This is the END of the road ****************************************\r
     }\r
 }
\ No newline at end of file