source: BMXNET_RPMS_dotNET_UTILITIES-BMX/branch/BMX41000/IHS BMX Framework/IndianHealthService.BMXNet.Tools.ComponentTestBench/LogTranscriptControl.cs@ 1222

Last change on this file since 1222 was 1146, checked in by Sam Habiel, 14 years ago

Initial Import of BMX4

File size: 2.8 KB
Line 
1using System;
2using System.Collections.Generic;
3using System.ComponentModel;
4using System.Drawing;
5using System.Data;
6using System.Text;
7using System.Windows.Forms;
8using IndianHealthService.BMXNet.Services;
9
10
11namespace IndianHealthService.BMXNet.Tools.ComponentTestBench
12{
13 public partial class LogTranscriptControl : UserControl,Log
14 {
15 public LogTranscriptControl()
16 {
17 InitializeComponent();
18 }
19
20
21 private bool _isLogging = true;
22
23 public bool IsLogging
24 {
25 get { return _isLogging; }
26 set { _isLogging = value; }
27 }
28
29 public delegate void UiLogDelegate(string aClass, string aCategory, params string[] lines);
30
31
32 public void Log(string aClass, string aCategory, params string[] lines)
33 {
34 if (!this.IsLogging)
35 {
36 return;
37 }
38
39 // if (this.InvokeRequired)
40 // {
41 // this.Invoke(new UiLogDelegate(this.UiLog), aClass, aCategory, lines);
42 // }
43 // else
44 // {
45 this.UiLog(aClass, aCategory, lines);
46 // }
47
48 }
49
50 protected void UiLog(string aClass, string aCategory, params string[] lines) {
51
52
53 this.transcriptBox.AppendText("\r\n-------------------\r\n");
54 this.transcriptBox.AppendText(DateTime.Now.ToString("HH:MM:ss.mm").PadRight(12)+" "+aClass.PadRight(12) + " " + aCategory.PadRight(12));
55 if (lines.Length == 1)
56 {
57 this.transcriptBox.AppendText(" ");
58 this.transcriptBox.AppendText(lines[0]);
59 } else {
60
61 for (int i=0;i<lines.Length;i++)
62 {
63 this.transcriptBox.AppendText("\r\n");
64 this.transcriptBox.AppendText("[" + (i+1).ToString().PadLeft(2) + "] ");
65 this.transcriptBox.AppendText(lines[i]);
66 }
67 }
68 }
69
70 public void Log(string aClass, string aCategory, Exception anException, params string[] lines)
71 {
72 if (!this.IsLogging)
73 {
74 return;
75 }
76
77 this.Log(aClass, aCategory, lines);
78 this.transcriptBox.AppendText("#####");
79 this.transcriptBox.AppendText(anException.Message);
80 this.transcriptBox.AppendText("#####");
81 this.transcriptBox.AppendText(anException.StackTrace);
82 }
83
84 private void LogTranscriptControl_Load(object sender, EventArgs e)
85 {
86 this.transcriptBox.ScrollBars = ScrollBars.Vertical;
87 this.transcriptBox.WordWrap = true;
88 }
89
90
91 }
92}
Note: See TracBrowser for help on using the repository browser.