summaryrefslogtreecommitdiffstats
path: root/win/C#/frmGenPreview.cs
diff options
context:
space:
mode:
authorsr55 <[email protected]>2008-12-16 18:01:48 +0000
committersr55 <[email protected]>2008-12-16 18:01:48 +0000
commit89b5566c50b3f19c760351845a85c3efa4afe10f (patch)
treea53adf8349e8da34b95f2c61c90d1f9c09b67195 /win/C#/frmGenPreview.cs
parentc26a35a7b7a5839946123c9670aac337c8bcf518 (diff)
WinGui:
- Preview Generator Window. Can generate previews form 5 to 60 seconds long. Will launch VLC (from a user specified (in options) install path) to play back the clip. Note: Clip duration is currently waiting for a patch to the CLI, so this part won't work yet. - Experimental in-gui VLC media player via ActiveX. (This causes a Blue Screen of Death (See comments in code), however if anyone can fix this and submit a patch, id be grateful) Alternative suggestions welcome! git-svn-id: svn://svn.handbrake.fr/HandBrake/trunk@2036 b64f7644-9d1e-0410-96f1-a4d463321fa5
Diffstat (limited to 'win/C#/frmGenPreview.cs')
-rw-r--r--win/C#/frmGenPreview.cs115
1 files changed, 115 insertions, 0 deletions
diff --git a/win/C#/frmGenPreview.cs b/win/C#/frmGenPreview.cs
new file mode 100644
index 000000000..3d6528de9
--- /dev/null
+++ b/win/C#/frmGenPreview.cs
@@ -0,0 +1,115 @@
+using System;
+using System.Collections.Generic;
+using System.ComponentModel;
+using System.Data;
+using System.Drawing;
+using System.Text;
+using System.Windows.Forms;
+using System.Threading;
+using System.Diagnostics;
+using System.IO;
+
+namespace Handbrake
+{
+ public partial class frmGenPreview : Form
+ {
+ private delegate void UpdateHandler();
+ Handbrake.QueryGenerator queryGen = new Handbrake.QueryGenerator();
+ Functions.Encode process = new Functions.Encode();
+ Process hbProc;
+ frmMain mainWindow;
+ Boolean playing = false;
+
+ public frmGenPreview(frmMain mw)
+ {
+ InitializeComponent();
+ this.mainWindow = mw;
+ }
+
+ private void btn_play_Click(object sender, EventArgs e)
+ {
+ String currently_playing;
+
+ // Get the Destination of the sample video.
+ currently_playing = "";
+ if (mainWindow.text_destination.Text != "")
+ currently_playing = mainWindow.text_destination.Text.Replace(".m", "_sample.m").Replace(".avi", "_sample.avi").Replace(".ogm", "_sample.ogm");
+
+ // Launch VLC and play video.
+ if (currently_playing != "")
+ {
+ if (File.Exists(Properties.Settings.Default.VLC_Path))
+ {
+ String args = "\"" + currently_playing + "\"";
+ ProcessStartInfo vlc = new ProcessStartInfo(Properties.Settings.Default.VLC_Path, args);
+ Process.Start(vlc);
+ lbl_status.Text = "VLC will now launch.";
+ }
+ else
+ {
+ 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.Information);
+ }
+ }
+ }
+
+ private void btn_encode_Click(object sender, EventArgs e)
+ {
+ String query = queryGen.GeneratePreviewQuery(mainWindow, cb_duration.Text);
+ ThreadPool.QueueUserWorkItem(procMonitor, query);
+ }
+ private void procMonitor(object state)
+ {
+ // Make sure we are not already encoding and if we are then display an error.
+ if (hbProc != null)
+ MessageBox.Show("Handbrake is already encoding a video!", "Status", MessageBoxButtons.OK, MessageBoxIcon.Warning);
+ else
+ {
+ encodingMessage();
+ hbProc = process.runCli(this, (string)state);
+ hbProc.WaitForExit();
+ hbProc = null;
+ updateUIElements();
+ }
+ }
+ // Update the UI now that the encode has finished.
+ private void encodingMessage()
+ {
+ try
+ {
+ if (this.InvokeRequired)
+ {
+ this.BeginInvoke(new UpdateHandler(encodingMessage));
+ return;
+ }
+ lbl_status.Text = "Encoding, Please wait ...";
+ }
+ catch (Exception exc)
+ {
+ MessageBox.Show(exc.ToString());
+ }
+ }
+
+ // Update the UI now that the encode has finished.
+ private void updateUIElements()
+ {
+ try
+ {
+ if (this.InvokeRequired)
+ {
+ this.BeginInvoke(new UpdateHandler(updateUIElements));
+ return;
+ }
+
+ btn_play.Visible = true;
+ toolStripSeparator1.Visible = true;
+ lbl_status.Text = "Your sample is ready to play.";
+ }
+ catch (Exception exc)
+ {
+ MessageBox.Show(exc.ToString());
+ }
+ }
+
+
+ }
+}