summaryrefslogtreecommitdiffstats
path: root/win
diff options
context:
space:
mode:
authorsr55 <[email protected]>2008-04-06 23:33:28 +0000
committersr55 <[email protected]>2008-04-06 23:33:28 +0000
commit05f9f27ea044b17f739faf49e40deaff64e89389 (patch)
tree91641a99cc997d14fa9b8aca227375aeb2d663b0 /win
parentce3d163596c85310131033a73569494ad8a3a759 (diff)
WinGui:
- Activity window now updates every 3 seconds during an encode, so the user can now watch the encode log as it is generated by the CLI. git-svn-id: svn://svn.handbrake.fr/HandBrake/trunk@1384 b64f7644-9d1e-0410-96f1-a4d463321fa5
Diffstat (limited to 'win')
-rw-r--r--win/C#/frmActivityWindow.Designer.cs1
-rw-r--r--win/C#/frmActivityWindow.cs53
2 files changed, 45 insertions, 9 deletions
diff --git a/win/C#/frmActivityWindow.Designer.cs b/win/C#/frmActivityWindow.Designer.cs
index 6a8b4dc4e..ac1e6f1ac 100644
--- a/win/C#/frmActivityWindow.Designer.cs
+++ b/win/C#/frmActivityWindow.Designer.cs
@@ -45,6 +45,7 @@ namespace Handbrake
//
// rtf_actLog
//
+ this.rtf_actLog.Cursor = System.Windows.Forms.Cursors.IBeam;
this.rtf_actLog.DetectUrls = false;
this.rtf_actLog.Location = new System.Drawing.Point(12, 12);
this.rtf_actLog.Name = "rtf_actLog";
diff --git a/win/C#/frmActivityWindow.cs b/win/C#/frmActivityWindow.cs
index 031b8d79f..3fc29a8f4 100644
--- a/win/C#/frmActivityWindow.cs
+++ b/win/C#/frmActivityWindow.cs
@@ -12,6 +12,7 @@ using System.Drawing;
using System.Text;
using System.Windows.Forms;
using System.IO;
+using System.Threading;
namespace Handbrake
@@ -21,25 +22,58 @@ namespace Handbrake
/// <summary>
/// This window should be used to display the RAW output of the handbrake CLI which is produced during an encode.
/// </summary>
+ ///
+ Thread monitorFile;
public frmActivityWindow()
{
InitializeComponent();
- this.rtf_actLog.Text = string.Empty;
- }
+ this.rtf_actLog.Text = string.Empty;
+ monitorFile = new Thread(autoUpdate);
+ }
+
private void btn_close_Click(object sender, EventArgs e)
{
- this.Hide();
+ monitorFile.Abort();
+ this.Hide();
}
private void frmActivityWindow_Load(object sender, EventArgs e)
{
this.rtf_actLog.Text = string.Empty;
- readFile();
+ rtf_actLog.Text = readFile();
+
+ monitorFile.Start();
+ }
+
+ private void autoUpdate(object state)
+ {
+ while (true)
+ {
+ updateTextFromThread();
+ Thread.Sleep(3000);
+ }
}
+
+ private delegate void UpdateUIHandler();
+ private void updateTextFromThread()
+ {
+ if (this.InvokeRequired)
+ {
+ this.BeginInvoke(new UpdateUIHandler(updateTextFromThread));
+ return;
+ }
+ rtf_actLog.Text = readFile();
+ this.rtf_actLog.SelectionStart = this.rtf_actLog.Text.Length -1;
+ this.rtf_actLog.ScrollToCaret();
- private void readFile()
+ if (rtf_actLog.Text.Contains("HandBrake has exited."))
+ monitorFile.Abort();
+ }
+
+ private string readFile()
{
+ string log = "";
try
{
// hb_encode_log.dat is the primary log file. Since .NET can't read this file whilst the CLI is outputing to it,
@@ -59,16 +93,17 @@ namespace Handbrake
string line = sr.ReadLine();
while (line != null)
{
- this.rtf_actLog.AppendText(line + System.Environment.NewLine);
+ log = log + (line + System.Environment.NewLine);
line = sr.ReadLine();
}
sr.Close();
}
catch (Exception exc)
{
- rtf_actLog.Clear();
- rtf_actLog.Text = "Please wait until the encode has finished to view the log. \n\n\n" + exc.ToString();
+ MessageBox.Show("An Error has occured! \n\n" + exc.ToString(), "Warning", MessageBoxButtons.OK, MessageBoxIcon.Warning);
}
+
+ return log;
}
private void btn_copy_Click(object sender, EventArgs e)
@@ -80,7 +115,7 @@ namespace Handbrake
private void btn_refresh_Click(object sender, EventArgs e)
{
rtf_actLog.Clear();
- readFile();
+ rtf_actLog.Text = readFile();
}