Welcome to mirror list, hosted at ThFree Co, Russian Federation.

github.com/ClusterM/hakchi2.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
Diffstat (limited to 'LiveViewForm.cs')
-rw-r--r--LiveViewForm.cs56
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();
+ }
+ }
+}