-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathDebugOutput.cs
executable file
·83 lines (75 loc) · 2.64 KB
/
DebugOutput.cs
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
77
78
79
80
81
82
83
using System;
using System.Drawing;
using System.Windows.Forms;
namespace AutoWikiBrowser.Plugins.Translator
{
/// <summary>
/// Debug-assistant
/// </summary>
public partial class DebugOutput : Form
{
public DebugOutput()
{
InitializeComponent();
HeaderFonts = new Font[] {
new Font("Arial", 14, FontStyle.Bold | FontStyle.Underline),
new Font("Arial", 13, FontStyle.Bold),
new Font("Arial", 12, FontStyle.Bold | FontStyle.Underline),
new Font("Arial", 11, FontStyle.Bold),
new Font("Arial", 10, FontStyle.Bold | FontStyle.Underline),
};
}
/// <summary>
/// Add a section to the debug output
/// </summary>
/// <param name="heading">The heading for the section</param>
/// <param name="text">The body of the section</param>
public void AddSection(string heading, string text)
{
textBox.SelectionFont = HeaderFonts[Math.Max(0, Math.Min(HeaderFont, HeaderFonts.GetUpperBound(0)))];
textBox.SelectedText = heading + "\n";
textBox.SelectionFont = body;
textBox.SelectionIndent += indent;
textBox.SelectedText = text + "\n\n";
textBox.SelectionIndent -= indent;
}
/// <summary>
/// Start a named section
/// </summary>
/// <param name="heading">The title of the section</param>
public void StartSection(string heading)
{
textBox.SelectionFont = HeaderFonts[Math.Max(0, Math.Min(HeaderFont, HeaderFonts.GetUpperBound(0)))];
textBox.SelectedText = heading + "\n";
++HeaderFont;
textBox.SelectionIndent += indent;
}
/// <summary>
/// End a named section
/// </summary>
public void EndSection()
{
System.Diagnostics.Debug.Assert(HeaderFont > 0);
if (HeaderFont > 0)
--HeaderFont;
textBox.SelectionIndent -= indent;
}
/// <summary>
/// Clear the text from the debug assistant
/// </summary>
public void Clear()
{
HeaderFont = 0;
textBox.Text = "";
textBox.SelectionIndent = 0;
}
readonly Font body = new Font("Lucida Console", 10);
int HeaderFont;
Font[] HeaderFonts;
const int indent = 20;
private void button1_Click(object sender, EventArgs e)
{
Hide();
}
}
}