aboutsummaryrefslogtreecommitdiffstatshomepage
path: root/OpenSim/Tools/OpenSim.GridLaunch/GUI/WinForm/ucLogWindow.cs
diff options
context:
space:
mode:
Diffstat (limited to 'OpenSim/Tools/OpenSim.GridLaunch/GUI/WinForm/ucLogWindow.cs')
-rw-r--r--OpenSim/Tools/OpenSim.GridLaunch/GUI/WinForm/ucLogWindow.cs54
1 files changed, 54 insertions, 0 deletions
diff --git a/OpenSim/Tools/OpenSim.GridLaunch/GUI/WinForm/ucLogWindow.cs b/OpenSim/Tools/OpenSim.GridLaunch/GUI/WinForm/ucLogWindow.cs
new file mode 100644
index 0000000..7b35c15
--- /dev/null
+++ b/OpenSim/Tools/OpenSim.GridLaunch/GUI/WinForm/ucLogWindow.cs
@@ -0,0 +1,54 @@
1using System;
2using System.Collections.Generic;
3using System.ComponentModel;
4using System.Drawing;
5using System.Data;
6using System.Text;
7using System.Windows.Forms;
8
9namespace OpenSim.GridLaunch.GUI.WinForm
10{
11 public partial class ucLogWindow : UserControl
12 {
13 // If text in window is more than this
14 private static readonly int logWindowMaxTextLength = 20000;
15 // Remove this much from start of it
16 private static int logWindowTrunlTextLength = 10000;
17
18 public ucLogWindow()
19 {
20 if (logWindowMaxTextLength < logWindowTrunlTextLength)
21 logWindowTrunlTextLength = logWindowMaxTextLength / 2;
22
23 InitializeComponent();
24 }
25
26 public delegate void textWriteDelegate(Color color, string LogText);
27 public void Write(Color color, string LogText)
28 {
29 // Check if we to pass task on to GUI thread
30 if (this.InvokeRequired)
31 {
32 this.Invoke(new textWriteDelegate(Write), color, LogText);
33 return;
34 }
35 // Append to window
36 try
37 {
38 if (!txtLog.IsDisposed)
39 txtLog.AppendText(LogText);
40 } catch { }
41 }
42
43 private void txtLog_TextChanged(object sender, EventArgs e)
44 {
45 // Go to bottom of window
46 txtLog.ScrollToCaret();
47
48 // Make sure amount of text in window doesn't grow too big
49 if (txtLog.Text.Length > logWindowMaxTextLength)
50 txtLog.Text = txtLog.Text.Remove(0, logWindowTrunlTextLength);
51 }
52
53 }
54}