-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathErrorStream.cs
More file actions
67 lines (57 loc) · 1.29 KB
/
ErrorStream.cs
File metadata and controls
67 lines (57 loc) · 1.29 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
using System.Media;
namespace MuEncode;
public class ErrorStream
{
public bool Beep { get; set; }
private Control? _stream;
public Control Stream { set { _stream = value; } }
private List<Error> _errors;
public ErrorStream(Control stream)
{
if (stream is Label || stream is TextBoxBase)
{
_stream = stream;
_stream.Text = "";
}
else _stream = null;
_errors = new();
}
public ErrorStream(Control stream, bool beep) : this(stream)
{
Beep = beep;
}
public void Write(Error error)
{
if (_stream != null) _stream.Text += error.ToString() + "; ";
_errors.Add(error);
if (Beep) SystemSounds.Beep.Play();
}
public void Write(string text)
{
if (_stream != null) _stream.Text += text + "; ";
_errors.Add(new Error(text));
if (Beep) SystemSounds.Beep.Play();
}
public void WriteLine(Error error)
{
if (_stream != null) _stream.Text += error.ToString() + "\n";
_errors.Add(error);
if (Beep) SystemSounds.Beep.Play();
}
public void WriteLine(string text)
{
if (_stream != null) _stream.Text += text + "\n";
_errors.Add(new Error(text));
if (Beep) SystemSounds.Beep.Play();
}
public void Clear()
{
_stream.Text = "";
}
public override string ToString()
{
string result = "";
foreach (Error e in _errors) result += e.ToString();
return result;
}
}