diff options
author | Alexey 'Cluster' Avdyukhin <clusterrr@clusterrr.com> | 2018-03-20 20:57:05 +0300 |
---|---|---|
committer | Alexey 'Cluster' Avdyukhin <clusterrr@clusterrr.com> | 2018-03-20 20:57:05 +0300 |
commit | f7598533f7629330cb0c8a3e85da02e590badfc0 (patch) | |
tree | 1c208a1098f4f3f913e4b0ad60c565f056fbf190 /LiveViewForm.cs | |
parent | a1590b08308921b95656046224bc3dd75131b42c (diff) |
...or Live View
Diffstat (limited to 'LiveViewForm.cs')
-rw-r--r-- | LiveViewForm.cs | 56 |
1 files changed, 56 insertions, 0 deletions
diff --git a/LiveViewForm.cs b/LiveViewForm.cs new file mode 100644 index 00000000..1c247632 --- /dev/null +++ b/LiveViewForm.cs @@ -0,0 +1,56 @@ +using System;
+using System.Collections.Generic;
+using System.ComponentModel;
+using System.Data;
+using System.Diagnostics;
+using System.Drawing;
+using System.Linq;
+using System.Text;
+using System.Threading;
+using System.Windows.Forms;
+
+namespace com.clusterrr.hakchi_gui
+{
+ public partial class LiveViewForm : Form
+ {
+ Thread screenShotThread;
+
+ public LiveViewForm()
+ {
+ InitializeComponent();
+ screenShotThread = new Thread(screenShotLoop);
+ screenShotThread.Start();
+ }
+
+ void screenShotLoop()
+ {
+ while (true)
+ {
+ try
+ {
+ var screenshot = WorkerForm.TakeScreenshot(false);
+ Invoke(new Action(delegate ()
+ {
+ pictureBox.Image = screenshot;
+ }));
+ }
+ catch (ThreadAbortException)
+ {
+ screenShotThread = null;
+ return;
+ }
+ catch (Exception ex)
+ {
+ Debug.WriteLine("Error: " + ex.Message + ex.StackTrace);
+ Thread.Sleep(1000);
+ }
+ }
+ }
+
+ private void LifeViewForm_FormClosing(object sender, FormClosingEventArgs e)
+ {
+ if (screenShotThread != null)
+ screenShotThread.Abort();
+ }
+ }
+}
|