-
Notifications
You must be signed in to change notification settings - Fork 2
Expand file tree
/
Copy pathDebugWindow.cs
More file actions
76 lines (65 loc) · 1.77 KB
/
DebugWindow.cs
File metadata and controls
76 lines (65 loc) · 1.77 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
71
72
73
74
75
76
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Runtime.InteropServices;
using System.Text;
using System.Threading.Tasks;
using System.Windows.Forms;
namespace IL2WinWing
{
public partial class DebugWindow : Form
{
public bool printText { get; private set; } = false;
public DebugWindow()
{
InitializeComponent();
}
public void AddText(string text)
{
if (!printText)
{
return;
}
if (InvokeRequired)
{
Invoke(new Action<string>(AddText), text);
return;
}
string[] lines = text.Split(new string[] { Environment.NewLine }, StringSplitOptions.None);
foreach (string line in lines)
{
debugTextBox?.AppendText(line + Environment.NewLine);
}
}
public void ClearText()
{
if (InvokeRequired)
{
Invoke(new Action(ClearText));
return;
}
debugTextBox.Clear();
}
private void toggleBtn_Click(object sender, EventArgs e)
{
printText = !printText;
toggleBtn.Text = printText ? "Stop" : "Start";
}
private void closeBtn_Click(object sender, EventArgs e)
{
printText = false;
this.Close();
}
private void clearBtn_Click(object sender, EventArgs e)
{
debugTextBox.Clear();
}
private void DebugWindow_Closing(object sender, FormClosingEventArgs e)
{
printText = false;
}
}
}