-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathDebugForm.cs
More file actions
70 lines (60 loc) · 1.13 KB
/
DebugForm.cs
File metadata and controls
70 lines (60 loc) · 1.13 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows.Forms;
namespace Hotwire
{
public partial class DebugForm : Form
{
private HotwirePort _port;
public DebugForm()
{
InitializeComponent();
}
protected override void OnClosing(CancelEventArgs e)
{
base.OnClosing(e);
e.Cancel = true;
Hide();
}
public HotwirePort Port
{
get
{
return _port;
}
set
{
if (_port != null)
_port.DataAvailable -= Port_DataAvailable;
_port = value;
if (_port != null)
_port.DataAvailable += Port_DataAvailable;
}
}
private void Port_DataAvailable()
{
if (InvokeRequired)
BeginInvoke(new Action(Port_DataAvailable));
else
{
string text = ASCIIEncoding.ASCII.GetString(_port.GetData());
textBox.Text = text;
}
}
private void buttonClose_Click(object sender, EventArgs e)
{
Hide();
}
private void buttonClear_Click(object sender, EventArgs e)
{
_port.ClearData();
textBox.Text = "";
}
}
}