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 //btn_skip.Visible = true;
\r
39 lbl_progress.Text = "0%";
\r
40 //lbl_progress.Visible = true;
\r
41 lbl_status.Visible = true;
\r
42 // throw cli call and parsing on it's own thread
\r
43 ThreadPool.QueueUserWorkItem(startProc);
\r
45 catch (Exception exc)
\r
47 if (Properties.Settings.Default.GuiDebug == "Checked")
\r
49 MessageBox.Show("frmReadDVD.cs - startScan " + exc.ToString());
\r
53 MessageBox.Show(Properties.Settings.Default.defaultError.ToString());
\r
58 private void updateUIElements()
\r
62 if (this.InvokeRequired)
\r
64 this.BeginInvoke(new UpdateUIHandler(updateUIElements));
\r
67 // Now pass this streamreader to frmMain so that it can be used there.
\r
68 mainWindow.setStreamReader(thisDvd);
\r
70 mainWindow.drp_dvdtitle.Items.Clear();
\r
71 mainWindow.drp_dvdtitle.Items.AddRange(thisDvd.Titles.ToArray());
\r
72 mainWindow.drp_dvdtitle.Text = "Automatic";
\r
73 mainWindow.drop_chapterFinish.Text = "Auto";
\r
74 mainWindow.drop_chapterStart.Text = "Auto";
\r
78 catch(Exception exc)
\r
80 if (Properties.Settings.Default.GuiDebug == "Checked")
\r
82 MessageBox.Show("frmReadDVD.cs - updateUIElements " + exc.ToString());
\r
86 MessageBox.Show(Properties.Settings.Default.defaultError.ToString());
\r
91 Functions.CLI process = new Functions.CLI();
\r
93 private void startProc(object state)
\r
95 //string query = "-i " + '"' + inputFile + '"' + " -t0";
\r
96 // hbProc = process.runCli(this, query, true, true, false, true);
\r
100 string appPath = Application.StartupPath.ToString()+ "\\";
\r
101 string strCmdLine = "cmd /c " + '"' + '"' + appPath + "hbcli.exe" + '"' + " -i " + '"' + inputFile + '"' + " -t0 >" + '"'+ appPath + "dvdinfo.dat" + '"' + " 2>&1" + '"';
\r
102 Process hbproc = Process.Start("CMD.exe", strCmdLine);
\r
103 hbproc.WaitForExit();
\r
108 StreamReader sr = new StreamReader(appPath + "dvdinfo.dat");
\r
109 thisDvd = Parsing.DVD.Parse(sr);
\r
112 updateUIElements();
\r
114 catch (Exception exc)
\r
116 if (Properties.Settings.Default.GuiDebug == "Checked")
\r
118 MessageBox.Show("frmReadDVD.cs - startProc " + exc.ToString());
\r
122 MessageBox.Show(Properties.Settings.Default.defaultError.ToString());
\r
128 //*********************************************************************************************************************************************
\r
130 * This has been temporily disabled due to the stderr issue
\r
133 Parsing.Parser readData = new Parsing.Parser(hbProc.StandardError.BaseStream);
\r
134 readData.OnScanProgress += Parser_OnScanProgress;
\r
135 readData.OnReadLine += dvdInfo.HandleParsedData;
\r
136 readData.OnReadToEnd += dvdInfo.HandleParsedData;
\r
138 // Setup the parser
\r
143 updateUIElements();
\r
145 process.closeCLI();
\r
148 //*********************************************************************************************************************************************
\r
151 /*private void Parser_OnScanProgress(object Sender, int CurrentTitle, int TitleCount)
\r
153 if (this.InvokeRequired)
\r
155 this.BeginInvoke(new Parsing.ScanProgressEventHandler(Parser_OnScanProgress), new object[] { Sender, CurrentTitle, TitleCount });
\r
158 int progress = Convert.ToInt32(Convert.ToDouble(CurrentTitle) / Convert.ToDouble(TitleCount) * 100) + 1;
\r
159 if (progress > 100)
\r
163 this.lbl_progress.Text = progress.ToString() + "%";
\r