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