summaryrefslogtreecommitdiffstats
path: root/win/C#/frmReadDVD.cs
diff options
context:
space:
mode:
authorbrianmario <[email protected]>2007-07-11 02:24:48 +0000
committerbrianmario <[email protected]>2007-07-11 02:24:48 +0000
commit1f013f7fed5b0103afe4e33a860be91b2e94f660 (patch)
tree752287ade8c65dc22edac75af53d526081869d11 /win/C#/frmReadDVD.cs
parentec8aaeacdf2eebb162abb54f419035e10cdd2e73 (diff)
updated some Form.Show calls to Form.ShowDialog
updating frmReadDVD to throw CLI call on it's own thread to prevent UI lockup added ToString overrides in Parsing.AudioTrack, Parsing.Subtitle and Parsing.Title misc interface/notification updates to frmReadDVD upon starting the scan process git-svn-id: svn://svn.handbrake.fr/HandBrake/trunk@671 b64f7644-9d1e-0410-96f1-a4d463321fa5
Diffstat (limited to 'win/C#/frmReadDVD.cs')
-rw-r--r--win/C#/frmReadDVD.cs60
1 files changed, 33 insertions, 27 deletions
diff --git a/win/C#/frmReadDVD.cs b/win/C#/frmReadDVD.cs
index 0d8e109e9..caf9d5853 100644
--- a/win/C#/frmReadDVD.cs
+++ b/win/C#/frmReadDVD.cs
@@ -12,20 +12,44 @@ namespace Handbrake
{
public partial class frmReadDVD : Form
{
+ private string inputFile;
+ private frmMain mainWindow;
+ private Parsing.DVD thisDvd;
+ private delegate void UpdateUIHandler();
- string inputFile;
- frmMain mainWindow;
-
- public frmReadDVD(string inputFile, frmMain window)
+ public frmReadDVD(string inputFile, frmMain parent)
{
InitializeComponent();
this.inputFile = inputFile;
- this.mainWindow = window;
+ this.mainWindow = parent;
}
private void btn_ok_Click(object sender, EventArgs e)
{
-
+ lbl_status.Visible = true;
+ btn_ok.Enabled = false;
+ lbl_pressOk.Visible = false;
+ // throw cli call and parsing on it's own thread
+ System.Threading.ThreadPool.QueueUserWorkItem(startProc);
+ }
+
+ private void updateUIElements()
+ {
+ if (this.InvokeRequired)
+ {
+ this.BeginInvoke(new UpdateUIHandler(updateUIElements));
+ return;
+ }
+ // Now pass this streamreader to frmMain so that it can be used there.
+ mainWindow.setStreamReader(thisDvd);
+
+ mainWindow.drp_dvdtitle.Items.Clear();
+ mainWindow.drp_dvdtitle.Items.AddRange(thisDvd.Titles.ToArray());
+ this.Close();
+ }
+
+ private void startProc(object state)
+ {
string query = "-i " + '"' + inputFile + '"' + " -t0";
System.Diagnostics.Process hbProc = new System.Diagnostics.Process();
hbProc.StartInfo.FileName = "hbcli.exe";
@@ -35,33 +59,15 @@ namespace Handbrake
hbProc.StartInfo.UseShellExecute = false;
hbProc.StartInfo.CreateNoWindow = true;
-
hbProc.Start();
- StreamReader readData = new StreamReader(new BufferedStream(hbProc.StandardError.BaseStream));
+ Parsing.Parser readData = new Parsing.Parser(hbProc.StandardError.BaseStream);
hbProc.WaitForExit();
hbProc.Close();
// Setup the parser
- Parsing.DVD thisDvd = Parsing.DVD.Parse(readData);
-
- // Now pass this streamreader to frmMain so that it can be used there.
- mainWindow.setStreamReader(thisDvd);
-
- // Setup frmMain drp_dvdTitle with the title information in the form: 1 (02:34:11)
- int count = thisDvd.Titles.Count -1;
- int counter = 0;
- string title;
+ thisDvd = Parsing.DVD.Parse(readData);
- while (count >= counter)
- {
- title = thisDvd.Titles[counter].TitleNumber.ToString() + " (" + thisDvd.Titles[counter].Duration.ToString() + ")";
- mainWindow.drp_dvdtitle.Items.Add(title);
- counter++;
- }
- this.Close();
+ updateUIElements();
}
-
-
-
}
} \ No newline at end of file