summaryrefslogtreecommitdiffstats
path: root/win/C#/frmReadDVD.cs
diff options
context:
space:
mode:
authorsr55 <[email protected]>2008-04-04 21:13:59 +0000
committersr55 <[email protected]>2008-04-04 21:13:59 +0000
commitd6239a451833361425f47f2f5c23aed5b57faa2a (patch)
tree0ca4d45442d856365cc873f1abe4469700b765b7 /win/C#/frmReadDVD.cs
parenta798655972e09b6c80351b3337b28bc02270dc5c (diff)
WinGui:
- Automatically select the longest title after a scan has completed. git-svn-id: svn://svn.handbrake.fr/HandBrake/trunk@1380 b64f7644-9d1e-0410-96f1-a4d463321fa5
Diffstat (limited to 'win/C#/frmReadDVD.cs')
-rw-r--r--win/C#/frmReadDVD.cs41
1 files changed, 40 insertions, 1 deletions
diff --git a/win/C#/frmReadDVD.cs b/win/C#/frmReadDVD.cs
index edb59873f..98f2110d1 100644
--- a/win/C#/frmReadDVD.cs
+++ b/win/C#/frmReadDVD.cs
@@ -14,6 +14,7 @@ using System.Windows.Forms;
using System.IO;
using System.Threading;
using System.Diagnostics;
+using System.Collections;
namespace Handbrake
@@ -67,6 +68,44 @@ namespace Handbrake
mainWindow.drop_chapterFinish.Text = "Auto";
mainWindow.drop_chapterStart.Text = "Auto";
+ // Now select the longest title
+ int current_largest = 0;
+ Handbrake.Parsing.Title title2Select = thisDvd.Titles[0];
+
+ foreach (Handbrake.Parsing.Title x in thisDvd.Titles)
+ {
+ string title = x.ToString();
+ if (title != "Automatic")
+ {
+ string[] y = title.Split(' ');
+ string time = y[1].Replace("(", "").Replace(")", "");
+ string[] z = time.Split(':');
+
+ int hours = int.Parse(z[0]) * 60 * 60;
+ int minutes = int.Parse(z[1]) * 60;
+ int seconds = int.Parse(z[2]);
+ int total_sec = hours + minutes + seconds;
+
+ if (current_largest == 0)
+ {
+ current_largest = hours + minutes + seconds;
+ title2Select = x;
+ }
+ else
+ {
+ if (total_sec > current_largest)
+ {
+ current_largest = total_sec;
+ title2Select = x;
+ }
+ }
+ }
+
+ }
+
+
+ mainWindow.drp_dvdtitle.SelectedItem = title2Select;
+
this.Close();
}
catch (Exception exc)
@@ -100,7 +139,7 @@ namespace Handbrake
if (!File.Exists(dvdInfoPath))
{
- throw new Exception("Unable to retrieve the DVD Info. dvdinfo.dat missing.");
+ throw new Exception("Unable to retrieve the DVD Info. dvdinfo.dat is missing.");
}
using (StreamReader sr = new StreamReader(dvdInfoPath))