Mercurial > repos > IBDev-IBBoard.WarFoundry.GUI.WinForms
annotate FrmDebugOutput.cs @ 17:475d3cdb75f4
* White space cleanup
no-open-ticket
author | IBBoard <dev@ibboard.co.uk> |
---|---|
date | Wed, 17 Jun 2009 14:05:31 +0000 |
parents | 19bdbb80999c |
children | 7c366fe55635 |
rev | line source |
---|---|
3
8935971e307c
Fixes #1 - Correctly license code
IBBoard <dev@ibboard.co.uk>
parents:
0
diff
changeset
|
1 // This file (FrmDebugOutput.cs) is a part of the IBBoard.WarFoundry.GUI.WinForms project and is copyright 2009 IBBoard. |
8935971e307c
Fixes #1 - Correctly license code
IBBoard <dev@ibboard.co.uk>
parents:
0
diff
changeset
|
2 // |
8935971e307c
Fixes #1 - Correctly license code
IBBoard <dev@ibboard.co.uk>
parents:
0
diff
changeset
|
3 // The file and the library/program it is in are licensed under the GNU LGPL license, either version 3 of the License or (at your option) any later version. Please see COPYING.LGPL for more information and the full license. |
8935971e307c
Fixes #1 - Correctly license code
IBBoard <dev@ibboard.co.uk>
parents:
0
diff
changeset
|
4 |
0 | 5 using System; |
6 using System.Drawing; | |
7 using System.Collections; | |
8 using System.ComponentModel; | |
9 using System.Text; | |
10 using System.Windows.Forms; | |
11 using IBBoard.Lang; | |
12 using IBBoard.Logging; | |
13 using IBBoard.Windows.Forms; | |
14 | |
15 namespace IBBoard.WarFoundry | |
16 { | |
17 /// <summary> | |
18 /// Summary description for FrmDebugOutput. | |
19 /// </summary> | |
20 public class FrmDebugOutput : IBBForm | |
21 { | |
22 private System.Windows.Forms.ListBox lstDebugItems; | |
23 private System.Windows.Forms.ComboBox cmbDebugLevel; | |
24 private System.Windows.Forms.Label lblDebugLevel; | |
25 /// <summary> | |
26 /// Required designer variable. | |
27 /// </summary> | |
28 private System.ComponentModel.Container components = null; | |
29 private System.Windows.Forms.ContextMenu contextMenu; | |
30 private System.Windows.Forms.MenuItem miCopy; | |
31 private System.Windows.Forms.TextBox txtDetail; | |
32 private System.Windows.Forms.Splitter splitter1; | |
33 private System.Windows.Forms.Panel panel1; | |
10
19bdbb80999c
Closes #47 - Remove magic numbers
IBBoard <dev@ibboard.co.uk>
parents:
3
diff
changeset
|
34 //private int MAX_LIST_LENGTH = 50; |
0 | 35 |
36 public FrmDebugOutput() | |
37 { | |
38 //this.logger = logger; | |
39 //logger.LogUpdatedEvent+=new IBBoard.Logging.Logger.LogUpdatedDelegate(logger_LogUpdatedEvent); | |
40 // | |
41 // Required for Windows Form Designer support | |
42 // | |
43 InitializeComponent(); | |
44 | |
45 /*if (LogLevels.Debug >= logger.LogLevel) | |
46 { | |
47 cmbDebugLevel.Items.Add(LogLevels.Debug); | |
48 } | |
49 | |
50 if (LogLevels.Info >= logger.LogLevel) | |
51 { | |
52 cmbDebugLevel.Items.Add(LogLevels.Info); | |
53 } | |
54 | |
55 if (LogLevels.Warning >= logger.LogLevel) | |
56 { | |
57 cmbDebugLevel.Items.Add(LogLevels.Warning); | |
58 } | |
59 | |
60 if (LogLevels.Error >= logger.LogLevel) | |
61 { | |
62 cmbDebugLevel.Items.Add(LogLevels.Error); | |
63 } | |
64 | |
65 if (LogLevels.Critical >= logger.LogLevel) | |
66 { | |
67 cmbDebugLevel.Items.Add(LogLevels.Critical); | |
68 }*/ | |
69 | |
70 this.Name = "DebugOutputForm"; | |
71 | |
10
19bdbb80999c
Closes #47 - Remove magic numbers
IBBoard <dev@ibboard.co.uk>
parents:
3
diff
changeset
|
72 //cmbDebugLevel.SelectedItem = logger.LogLevel; |
0 | 73 |
74 Translation.Translate(this, true); | |
75 | |
76 fillDebugList(); | |
77 } | |
78 | |
79 /// <summary> | |
80 /// Clean up any resources being used. | |
81 /// </summary> | |
82 protected override void Dispose( bool disposing ) | |
83 { | |
84 if( disposing ) | |
85 { | |
86 if(components != null) | |
87 { | |
88 components.Dispose(); | |
89 } | |
90 } | |
91 base.Dispose( disposing ); | |
92 } | |
93 | |
94 #region Windows Form Designer generated code | |
95 /// <summary> | |
96 /// Required method for Designer support - do not modify | |
97 /// the contents of this method with the code editor. | |
98 /// </summary> | |
99 private void InitializeComponent() | |
100 { | |
101 this.lstDebugItems = new System.Windows.Forms.ListBox(); | |
102 this.contextMenu = new System.Windows.Forms.ContextMenu(); | |
103 this.miCopy = new System.Windows.Forms.MenuItem(); | |
104 this.cmbDebugLevel = new System.Windows.Forms.ComboBox(); | |
105 this.lblDebugLevel = new System.Windows.Forms.Label(); | |
106 this.txtDetail = new System.Windows.Forms.TextBox(); | |
107 this.splitter1 = new System.Windows.Forms.Splitter(); | |
108 this.panel1 = new System.Windows.Forms.Panel(); | |
109 this.SuspendLayout(); | |
110 // | |
111 // lstDebugItems | |
112 // | |
113 this.lstDebugItems.ContextMenu = this.contextMenu; | |
114 this.lstDebugItems.Dock = System.Windows.Forms.DockStyle.Fill; | |
115 this.lstDebugItems.IntegralHeight = false; | |
116 this.lstDebugItems.Location = new System.Drawing.Point(0, 24); | |
117 this.lstDebugItems.Name = "lstDebugItems"; | |
118 this.lstDebugItems.ScrollAlwaysVisible = true; | |
119 this.lstDebugItems.SelectionMode = System.Windows.Forms.SelectionMode.MultiExtended; | |
120 this.lstDebugItems.Size = new System.Drawing.Size(656, 144); | |
121 this.lstDebugItems.TabIndex = 0; | |
122 this.lstDebugItems.MouseDown += new System.Windows.Forms.MouseEventHandler(this.lstDebugItems_MouseDown); | |
123 this.lstDebugItems.SelectedIndexChanged += new System.EventHandler(this.lstDebugItems_SelectedIndexChanged); | |
124 // | |
125 // contextMenu | |
126 // | |
127 this.contextMenu.MenuItems.AddRange(new System.Windows.Forms.MenuItem[] { | |
128 this.miCopy}); | |
129 this.contextMenu.Popup += new System.EventHandler(this.contextMenu_Popup); | |
130 // | |
131 // miCopy | |
132 // | |
133 this.miCopy.Index = 0; | |
134 this.miCopy.Text = "&Copy"; | |
135 this.miCopy.Click += new System.EventHandler(this.miCopy_Click); | |
136 // | |
137 // cmbDebugLevel | |
138 // | |
139 this.cmbDebugLevel.Location = new System.Drawing.Point(190, 2); | |
140 this.cmbDebugLevel.Name = "cmbDebugLevel"; | |
141 this.cmbDebugLevel.Size = new System.Drawing.Size(464, 21); | |
142 this.cmbDebugLevel.TabIndex = 1; | |
143 this.cmbDebugLevel.SelectedIndexChanged += new System.EventHandler(this.cmbDebugLevel_SelectedIndexChanged); | |
144 // | |
145 // lblDebugLevel | |
146 // | |
147 this.lblDebugLevel.Location = new System.Drawing.Point(16, 0); | |
148 this.lblDebugLevel.Name = "lblDebugLevel"; | |
149 this.lblDebugLevel.Size = new System.Drawing.Size(168, 21); | |
150 this.lblDebugLevel.TabIndex = 2; | |
151 this.lblDebugLevel.Text = "debug level:"; | |
152 this.lblDebugLevel.TextAlign = System.Drawing.ContentAlignment.MiddleRight; | |
153 // | |
154 // txtDetail | |
155 // | |
156 this.txtDetail.Dock = System.Windows.Forms.DockStyle.Bottom; | |
157 this.txtDetail.Location = new System.Drawing.Point(0, 172); | |
158 this.txtDetail.Multiline = true; | |
159 this.txtDetail.Name = "txtDetail"; | |
160 this.txtDetail.ReadOnly = true; | |
161 this.txtDetail.ScrollBars = System.Windows.Forms.ScrollBars.Vertical; | |
162 this.txtDetail.Size = new System.Drawing.Size(656, 64); | |
163 this.txtDetail.TabIndex = 3; | |
164 this.txtDetail.TabStop = false; | |
165 this.txtDetail.Text = ""; | |
166 this.txtDetail.KeyDown += new System.Windows.Forms.KeyEventHandler(this.txtDetail_KeyDown); | |
167 // | |
168 // splitter1 | |
169 // | |
170 this.splitter1.Cursor = System.Windows.Forms.Cursors.HSplit; | |
171 this.splitter1.Dock = System.Windows.Forms.DockStyle.Bottom; | |
172 this.splitter1.Location = new System.Drawing.Point(0, 168); | |
173 this.splitter1.MinExtra = 50; | |
174 this.splitter1.MinSize = 50; | |
175 this.splitter1.Name = "splitter1"; | |
176 this.splitter1.Size = new System.Drawing.Size(656, 4); | |
177 this.splitter1.TabIndex = 4; | |
178 this.splitter1.TabStop = false; | |
179 // | |
180 // panel1 | |
181 // | |
182 this.panel1.Dock = System.Windows.Forms.DockStyle.Top; | |
183 this.panel1.Location = new System.Drawing.Point(0, 0); | |
184 this.panel1.Name = "panel1"; | |
185 this.panel1.Size = new System.Drawing.Size(656, 24); | |
186 this.panel1.TabIndex = 5; | |
187 // | |
188 // FrmDebugOutput | |
189 // | |
190 this.AutoScaleBaseSize = new System.Drawing.Size(5, 13); | |
191 this.ClientSize = new System.Drawing.Size(656, 236); | |
192 this.Controls.Add(this.lblDebugLevel); | |
193 this.Controls.Add(this.cmbDebugLevel); | |
194 this.Controls.Add(this.lstDebugItems); | |
195 this.Controls.Add(this.splitter1); | |
196 this.Controls.Add(this.panel1); | |
197 this.Controls.Add(this.txtDetail); | |
198 this.FormBorderStyle = System.Windows.Forms.FormBorderStyle.FixedDialog; | |
199 this.Name = "FrmDebugOutput"; | |
200 this.ShowInTaskbar = false; | |
201 this.StartPosition = System.Windows.Forms.FormStartPosition.CenterParent; | |
202 this.Text = "FrmDebugOutput"; | |
203 this.ResumeLayout(false); | |
204 | |
205 } | |
206 #endregion | |
207 | |
208 private void cmbDebugLevel_SelectedIndexChanged(object sender, System.EventArgs e) | |
209 { | |
210 fillDebugList(); | |
211 } | |
212 | |
213 private void fillDebugList() | |
214 { | |
215 lstDebugItems.Items.Clear(); | |
216 /*LogItem[] items = logger.GetLogItems((LogLevels)cmbDebugLevel.SelectedItem); | |
217 int last = items.Length - 1; | |
218 int stop = last - MAX_LIST_LENGTH; | |
219 | |
220 if (stop < 0) | |
221 { | |
222 stop = 0; | |
223 } | |
224 | |
225 //reverse fill the list so that we can have newest items at the top | |
226 for (int i = last; i >= stop; i--) | |
227 { | |
228 lstDebugItems.Items.Add(items[i]); | |
229 }*/ | |
230 } | |
231 | |
232 private void logger_LogUpdatedEvent(LogItem item) | |
233 { | |
234 /*if (item.Level >= (LogLevels)cmbDebugLevel.SelectedItem) | |
235 { | |
236 lock (lstDebugItems) | |
237 { | |
238 lstDebugItems.Items.Insert(0, item); | |
239 | |
240 if (lstDebugItems.Items.Count > MAX_LIST_LENGTH) | |
241 { | |
242 lstDebugItems.Items.RemoveAt(lstDebugItems.Items.Count - 1); | |
243 } | |
244 } | |
245 }*/ | |
246 } | |
247 | |
248 private void miCopy_Click(object sender, System.EventArgs e) | |
249 { | |
250 if (lstDebugItems.SelectedIndices.Count==1) | |
251 { | |
252 Clipboard.SetDataObject(lstDebugItems.SelectedItem.ToString()); | |
253 } | |
254 else if (lstDebugItems.SelectedIndices.Count > 1) | |
255 { | |
256 StringBuilder sb = new StringBuilder(); | |
257 | |
258 foreach (int idx in lstDebugItems.SelectedIndices) | |
259 { | |
260 sb.Append(lstDebugItems.Items[idx].ToString()+Environment.NewLine); | |
261 } | |
262 | |
263 Clipboard.SetDataObject(sb.ToString().Trim()); | |
264 } | |
265 } | |
266 | |
267 private void contextMenu_Popup(object sender, System.EventArgs e) | |
268 { | |
269 foreach (MenuItem mi in contextMenu.MenuItems) | |
270 { | |
271 mi.Visible = lstDebugItems.SelectedIndex > -1; | |
272 } | |
273 } | |
274 | |
275 private void lstDebugItems_MouseDown(object sender, System.Windows.Forms.MouseEventArgs e) | |
276 { | |
277 if (e.Button == MouseButtons.Right) | |
278 { | |
279 int idx = lstDebugItems.IndexFromPoint(e.X, e.Y); | |
280 | |
281 if (lstDebugItems.SelectedIndices.Contains(idx)) | |
282 { | |
283 lstDebugItems.SelectedIndex = idx; | |
284 } | |
285 } | |
286 } | |
287 | |
288 private void lstDebugItems_SelectedIndexChanged(object sender, System.EventArgs e) | |
289 { | |
290 if (lstDebugItems.SelectedIndex > -1) | |
291 { | |
292 LogItem item = (LogItem)lstDebugItems.SelectedItem; | |
293 txtDetail.Text = item.ToString() + Environment.NewLine + Environment.NewLine + "Stack Trace: "+ item.StackTrace; | |
294 } | |
295 else | |
296 { | |
297 txtDetail.Text = ""; | |
298 } | |
299 } | |
300 | |
301 private void txtDetail_KeyDown(object sender, System.Windows.Forms.KeyEventArgs e) | |
302 { | |
303 if(e.KeyData == (Keys.Control|Keys.A) && e.Control) | |
304 { | |
305 txtDetail.SelectAll(); | |
306 } | |
307 } | |
308 } | |
309 } |