OSDN Git Service

LinGui: enable libdvdnav by default
[handbrake-jp/handbrake-jp-git.git] / win / C# / frmMain.cs
index a668cc6..a377aca 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
@@ -711,7 +729,7 @@ namespace Handbrake
                     if (overwrite == DialogResult.Yes)\r
                     {\r
                         if (encodeQueue.Count == 0)\r
-                            encodeQueue.AddJob(query, sourcePath, text_destination.Text);\r
+                            encodeQueue.AddJob(query, sourcePath, text_destination.Text, (rtf_query.Text != ""));\r
 \r
                         queueWindow.setQueue();\r
                         if (encodeQueue.Count > 1)\r
@@ -723,7 +741,7 @@ namespace Handbrake
 \r
                         if (ActivityWindow != null)\r
                             ActivityWindow.SetLogView(false);\r
-                        \r
+\r
                     }\r
                     this.Focus();\r
                 }\r
@@ -746,11 +764,13 @@ namespace Handbrake
                     DialogResult result = MessageBox.Show("There is already a queue item for this destination path. \n\n If you continue, the encode will be overwritten. Do you wish to continue?",\r
                   "Warning", MessageBoxButtons.YesNo, MessageBoxIcon.Warning);\r
                     if (result == DialogResult.Yes)\r
-                        encodeQueue.AddJob(query, sourcePath, text_destination.Text);\r
+                        encodeQueue.AddJob(query, sourcePath, text_destination.Text, (rtf_query.Text != ""));\r
 \r
                 }\r
                 else\r
-                    encodeQueue.AddJob(query, sourcePath, text_destination.Text);\r
+                    encodeQueue.AddJob(query, sourcePath, text_destination.Text, (rtf_query.Text != ""));\r
+\r
+                lbl_encode.Text = encodeQueue.Count + " encode(s) pending in the queue";\r
 \r
                 queueWindow.Show();\r
             }\r
@@ -786,6 +806,8 @@ namespace Handbrake
             if (ActivityWindow == null)\r
                 ActivityWindow = new frmActivityWindow(file, encodeQueue, this);\r
 \r
+            ActivityWindow.SetLogView(!encodeQueue.isEncoding);\r
+\r
             ActivityWindow.Show();\r
         }\r
         #endregion\r
@@ -823,24 +845,30 @@ namespace Handbrake
         private void btn_dvd_source_Click(object sender, EventArgs e)\r
         {\r
             if (DVD_Open.ShowDialog() == DialogResult.OK)\r
-                selectSource(DVD_Open.SelectedPath, 1);\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
-                selectSource(ISO_Open.FileName, 2);\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], 3);\r
+            if (this.dvdDrivePath == null) return;\r
+            this.selectedSourceType = SourceType.DvdDrive;\r
+            selectSource(this.dvdDrivePath);\r
         }\r
-        private void selectSource(string file, int type)\r
+        private void selectSource(string file)\r
         {\r
             Check_ChapterMarkers.Enabled = true;\r
             lastAction = "scan";\r
@@ -861,18 +889,8 @@ namespace Handbrake
                 return;\r
             }\r
 \r
-            switch (type) // Start the scan\r
-            {\r
-                case 1: // btn_dvd_source_Click()\r
-                case 3: // mnu_dvd_drive_Click()\r
-                    sourcePath = Path.GetFullPath(file);\r
-                    startScan(file);\r
-                    break;\r
-                case 2: // btn_file_source_Click()\r
-                    sourcePath = Path.GetFileName(file);\r
-                    startScan(file);\r
-                    break;\r
-            }\r
+            sourcePath = Path.GetFileName(file);\r
+            startScan(file);\r
         }\r
         private void drp_dvdtitle_Click(object sender, EventArgs e)\r
         {\r
@@ -931,6 +949,7 @@ namespace Handbrake
                 Subtitles.drp_subtitleTracks.Items.Add("Foreign Audio Search (Bitmap)");\r
                 Subtitles.drp_subtitleTracks.Items.AddRange(selectedTitle.Subtitles.ToArray());\r
                 Subtitles.drp_subtitleTracks.SelectedIndex = 0;\r
+                Subtitles.Clear();\r
                 Subtitles.setSubtitleTrackAuto();\r
             }\r
 \r
@@ -1127,9 +1146,8 @@ namespace Handbrake
                 else\r
                     newExtension = ".mp4";\r
 \r
-            text_destination.Text = text_destination.Text.Replace(".mp4", newExtension);\r
-            text_destination.Text = text_destination.Text.Replace(".m4v", newExtension);\r
-            text_destination.Text = text_destination.Text.Replace(".mkv", newExtension);\r
+            if (Path.HasExtension(newExtension))\r
+                text_destination.Text = Path.ChangeExtension(text_destination.Text, newExtension);\r
         }\r
 \r
         //Video Tab\r
@@ -1582,7 +1600,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
@@ -1633,7 +1651,7 @@ namespace Handbrake
                 }\r
 \r
                 lbl_encode.Visible = true;\r
-                lbl_encode.Text = "Encoding in Progress";\r
+                lbl_encode.Text = "Encoding with " + encodeQueue.Count + " encode(s) pending";\r
                 btn_start.Text = "Stop";\r
                 btn_start.ToolTipText = "Stop the encoding process.";\r
                 btn_start.Image = Properties.Resources.stop;\r
@@ -1664,7 +1682,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
@@ -1744,6 +1764,15 @@ 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
         // This is the END of the road ****************************************\r
     }\r
 }
\ No newline at end of file