2 using System.Windows.Forms;
\r
3 using System.Threading;
\r
4 using System.Diagnostics;
\r
9 public partial class frmGenPreview : Form
\r
11 private delegate void UpdateHandler();
\r
12 QueryGenerator queryGen = new QueryGenerator();
\r
13 Functions.Encode process = new Functions.Encode();
\r
17 public frmGenPreview(frmMain mw)
\r
19 InitializeComponent();
\r
20 this.mainWindow = mw;
\r
21 cb_duration.SelectedIndex = 0;
\r
22 cb_preview.SelectedIndex = 0;
\r
25 private void btn_play_Click(object sender, EventArgs e)
\r
27 // Get the Destination of the sample video.
\r
28 String currently_playing = "";
\r
29 if (mainWindow.text_destination.Text != "")
\r
30 currently_playing = mainWindow.text_destination.Text.Replace(".m", "_sample.m").Replace(".avi", "_sample.avi").Replace(".ogm", "_sample.ogm");
\r
32 // Launch VLC and play video.
\r
33 if (currently_playing != "")
\r
35 if (File.Exists(currently_playing))
\r
37 if (File.Exists(Properties.Settings.Default.VLC_Path))
\r
39 String args = "\"" + currently_playing + "\"";
\r
40 ProcessStartInfo vlc = new ProcessStartInfo(Properties.Settings.Default.VLC_Path, args);
\r
42 lbl_status.Text = "VLC will now launch.";
\r
45 MessageBox.Show("Unable to detect VLC Player. \nPlease make sure VLC is installed and the directory specified in the program options is correct.", "VLC", MessageBoxButtons.OK, MessageBoxIcon.Warning);
\r
47 MessageBox.Show("Unable to find the preview file. Either the file was deleted or the encode failed. Check the activity log for details.", "VLC", MessageBoxButtons.OK, MessageBoxIcon.Warning);
\r
51 private void btn_encode_Click(object sender, EventArgs e)
\r
53 String query = queryGen.GeneratePreviewQuery(mainWindow, cb_duration.Text, cb_preview.Text);
\r
54 ThreadPool.QueueUserWorkItem(procMonitor, query);
\r
56 private void procMonitor(object state)
\r
58 // Make sure we are not already encoding and if we are then display an error.
\r
60 MessageBox.Show("Handbrake is already encoding a video!", "Status", MessageBoxButtons.OK, MessageBoxIcon.Warning);
\r
64 hbProc = process.runCli(this, (string)state);
\r
65 hbProc.WaitForExit();
\r
70 // Update the UI now that the encode has finished.
\r
71 private void encodingMessage()
\r
77 BeginInvoke(new UpdateHandler(encodingMessage));
\r
80 lbl_status.Text = "Encoding, Please wait ...";
\r
82 catch (Exception exc)
\r
84 MessageBox.Show(exc.ToString());
\r
88 // Update the UI now that the encode has finished.
\r
89 private void updateUIElements()
\r
95 BeginInvoke(new UpdateHandler(updateUIElements));
\r
99 btn_play.Visible = true;
\r
100 toolStripSeparator1.Visible = true;
\r
101 lbl_status.Text = "Your sample is ready to play.";
\r
103 catch (Exception exc)
\r
105 MessageBox.Show(exc.ToString());
\r