2 using System.Collections.Generic;
\r
3 using System.ComponentModel;
\r
5 using System.Drawing;
\r
7 using System.Windows.Forms;
\r
9 using System.Threading;
\r
10 using System.Diagnostics;
\r
15 public partial class frmReadDVD : Form
\r
17 private string inputFile;
\r
18 private frmMain mainWindow;
\r
19 private frmDvdInfo dvdInfo;
\r
20 private Parsing.DVD thisDvd;
\r
21 private Process hbProc;
\r
22 private delegate void UpdateUIHandler();
\r
24 public frmReadDVD(string inputFile, frmMain parent, frmDvdInfo dvdInfoWindow)
\r
26 InitializeComponent();
\r
27 this.inputFile = inputFile;
\r
28 this.mainWindow = parent;
\r
29 this.dvdInfo = dvdInfoWindow;
\r
34 private void startScan()
\r
38 lbl_status.Visible = true;
\r
39 ThreadPool.QueueUserWorkItem(startProc);
\r
41 catch (Exception exc)
\r
43 if (Properties.Settings.Default.GuiDebug == "Checked")
\r
45 MessageBox.Show("frmReadDVD.cs - startScan " + exc.ToString());
\r
49 MessageBox.Show(Properties.Settings.Default.defaultError.ToString());
\r
54 private void updateUIElements()
\r
58 if (this.InvokeRequired)
\r
60 this.BeginInvoke(new UpdateUIHandler(updateUIElements));
\r
63 // Now pass this streamreader to frmMain so that it can be used there.
\r
64 mainWindow.setStreamReader(thisDvd);
\r
66 mainWindow.drp_dvdtitle.Items.Clear();
\r
67 mainWindow.drp_dvdtitle.Items.AddRange(thisDvd.Titles.ToArray());
\r
68 mainWindow.drp_dvdtitle.Text = "Automatic";
\r
69 mainWindow.drop_chapterFinish.Text = "Auto";
\r
70 mainWindow.drop_chapterStart.Text = "Auto";
\r
74 catch(Exception exc)
\r
76 if (Properties.Settings.Default.GuiDebug == "Checked")
\r
78 MessageBox.Show("frmReadDVD.cs - updateUIElements " + exc.ToString());
\r
82 MessageBox.Show(Properties.Settings.Default.defaultError.ToString());
\r
87 Functions.CLI process = new Functions.CLI();
\r
89 private void startProc(object state)
\r
93 string appPath = Application.StartupPath.ToString()+ "\\";
\r
94 string strCmdLine = "cmd /c " + '"' + '"' + appPath + "HandBrakeCLI.exe" + '"' + " -i " + '"' + inputFile + '"' + " -t0 >" + '"' + appPath + "dvdinfo.dat" + '"' + " 2>&1" + '"';
\r
95 Process hbproc = Process.Start("CMD.exe", strCmdLine);
\r
96 hbproc.WaitForExit();
\r
101 StreamReader sr = new StreamReader(appPath + "dvdinfo.dat");
\r
102 thisDvd = Parsing.DVD.Parse(sr);
\r
105 updateUIElements();
\r
107 catch (Exception exc)
\r
109 if (Properties.Settings.Default.GuiDebug == "Checked")
\r
111 MessageBox.Show("frmReadDVD.cs - startProc " + exc.ToString());
\r
115 MessageBox.Show(Properties.Settings.Default.defaultError.ToString());
\r