3 This file is part of the HandBrake source code.
\r
4 Homepage: <http://handbrake.m0k.org/>.
\r
5 It may be used under the terms of the GNU General Public License. */
\r
8 using System.Collections.Generic;
\r
9 using System.ComponentModel;
\r
11 using System.Drawing;
\r
13 using System.Windows.Forms;
\r
15 using System.Threading;
\r
16 using System.Diagnostics;
\r
21 public partial class frmReadDVD : Form
\r
23 private string inputFile;
\r
24 private frmMain mainWindow;
\r
25 private frmDvdInfo dvdInfo;
\r
26 private Parsing.DVD thisDvd;
\r
27 private delegate void UpdateUIHandler();
\r
29 public frmReadDVD(string inputFile, frmMain parent, frmDvdInfo dvdInfoWindow)
\r
31 InitializeComponent();
\r
32 this.inputFile = inputFile;
\r
33 this.mainWindow = parent;
\r
34 this.dvdInfo = dvdInfoWindow;
\r
39 private void startScan()
\r
43 lbl_status.Visible = true;
\r
44 ThreadPool.QueueUserWorkItem(startProc);
\r
46 catch (Exception exc)
\r
48 MessageBox.Show("frmReadDVD.cs - startScan " + exc.ToString());
\r
52 private void updateUIElements()
\r
56 if (this.InvokeRequired)
\r
58 this.BeginInvoke(new UpdateUIHandler(updateUIElements));
\r
61 // Now pass this streamreader to frmMain so that it can be used there.
\r
62 mainWindow.setStreamReader(thisDvd);
\r
64 mainWindow.drp_dvdtitle.Items.Clear();
\r
65 mainWindow.drp_dvdtitle.Items.AddRange(thisDvd.Titles.ToArray());
\r
66 mainWindow.drp_dvdtitle.Text = "Automatic";
\r
67 mainWindow.drop_chapterFinish.Text = "Auto";
\r
68 mainWindow.drop_chapterStart.Text = "Auto";
\r
72 catch (Exception exc)
\r
74 MessageBox.Show("frmReadDVD.cs - updateUIElements " + exc.ToString());
\r
78 Functions.CLI process = new Functions.CLI();
\r
80 private void startProc(object state)
\r
84 string handbrakeCLIPath = Path.Combine(Application.StartupPath, "HandBrakeCLI.exe");
\r
85 string dvdInfoPath = Path.Combine(Path.GetTempPath(), "dvdinfo.dat");
\r
87 // Make we don't pick up a stale dvdinfo.dat (and that we have rights to the file)
\r
88 if (File.Exists(dvdInfoPath))
\r
89 File.Delete(dvdInfoPath);
\r
91 string strCmdLine = String.Format(@"cmd /c """"{0}"" -i ""{1}"" -t0 -v >""{2}"" 2>&1""", handbrakeCLIPath, inputFile, dvdInfoPath);
\r
93 ProcessStartInfo hbParseDvd = new ProcessStartInfo("CMD.exe", strCmdLine);
\r
94 hbParseDvd.WindowStyle = ProcessWindowStyle.Hidden;
\r
95 using (Process hbproc = Process.Start(hbParseDvd))
\r
97 hbproc.WaitForExit();
\r
98 // TODO: Verify exit code if the CLI supports it properly
\r
101 if (!File.Exists(dvdInfoPath))
\r
103 throw new Exception("Unable to retrieve the DVD Info. dvdinfo.dat missing.");
\r
106 using (StreamReader sr = new StreamReader(dvdInfoPath))
\r
108 thisDvd = Parsing.DVD.Parse(sr);
\r
111 updateUIElements();
\r
113 catch (Exception exc)
\r
115 MessageBox.Show("frmReadDVD.cs - startProc " + exc.ToString());
\r