LogControl.cs
3.5 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
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
using Common;
using System;
using System.Threading;
using System.Threading.Tasks;
using System.Windows.Forms;
namespace UControl.UC
{
public partial class LogControl : UserControl
{
public LogControl()
{
InitializeComponent();
logView = new LogView();
ShowEdit(false);
}
LogView logView;
public bool ShowDebug
{
get { return logView.ShowDebug; }
set { logView.ShowDebug = value; }
}
public bool ShowInfo { get { return logView.ShowInfo; } set { logView.ShowInfo = value; } }
public bool ShowWarn { get { return logView.ShowWarn; } set { logView.ShowWarn = value; } }
public bool ShowError { get { return logView.ShowError; } set { logView.ShowError = value; } }
/// <summary>
/// 加载需要显示日志类
/// </summary>
/// <param name="logBean">null则显示主日志</param>
public void Init(LogBean logBean = null)
{
if (logBean == null)
{
logView.Init(listView1);
}
else
{
logView.Init(listView1, logBean);
}
}
/// <summary>
/// 最多显示信息数量
/// </summary>
public int MaxDisplayCnt { get { return logView.MaxDisplayMsg; } set { logView.MaxDisplayMsg = value; } }
private void chkShowDebug_CheckedChanged(object sender, EventArgs e)
{
ShowDebug = chkShowDebug.Checked;
}
private void button1_Click(object sender, EventArgs e)
{
logView.ClearLog();
}
private void ShowEdit(bool show)
{
if (IsHandleCreated)
this.Invoke(new Action(() => {
chkShowDebug.Visible = show;
chkShowInfo.Visible = show;
chkShowWarn.Visible = show;
chkShowError.Visible = show;
textBoxMaxCnt.Visible = show;
button1.Visible = show;
showedit = show;
})
);
else
{
chkShowDebug.Visible = show;
chkShowInfo.Visible = show;
chkShowWarn.Visible = show;
chkShowError.Visible = show;
textBoxMaxCnt.Visible = show;
button1.Visible = show;
showedit = show;
}
}
private void chkShowInfo_CheckedChanged(object sender, EventArgs e)
{
ShowInfo = chkShowInfo.Checked;
}
private void chkShowWarn_CheckedChanged(object sender, EventArgs e)
{
ShowWarn = chkShowWarn.Checked;
}
private void chkShowError_CheckedChanged(object sender, EventArgs e)
{
ShowError = chkShowError.Checked;
}
private void textBoxMaxCnt_TextChanged(object sender, EventArgs e)
{
if (int.TryParse(textBoxMaxCnt.Text, out int cnt))
{
MaxDisplayCnt = cnt;
}
else
MaxDisplayCnt = 25;
}
bool showedit = false;
private void listView1_MouseEnter(object sender, EventArgs e)
{
if (showedit)
return;
Task.Factory.StartNew(delegate
{
ShowEdit(true);
Thread.Sleep(5000);
ShowEdit(false);
});
}
}
}