Debug接口

IDebugOut定义:

Code

 

BaseDebugOut定义:

Code

 

SourceDebugOutArgs定义:

Code

 

具体实现:

FormDebugOut定义:


 1 using System;
 2 using System.Collections.Generic;
 3 using System.Text;
 4 using Com.Debug;
 5 
 6 namespace FormDebugText
 7 {
 8     /// <summary>
 9     /// 输出类
10     /// </summary>
11     public class FormDebugOut:BaseDebugOut
12     {
13         public override string ToString()
14         {
15             return "FormDebugOut";
16         }
17         private DebugOutText _outText;
18 
19         public FormDebugOut()
20         {
21             
22         }
23         #region 重写函数
24 
25         public override void FireDebug(object sender, SourceDebugOutArgs args)
26         {
27             base.FireDebug(sender, args);
28             _outText.BeginInvoke(new SourceDebugOutEventHandler(DebugOut), new object[] { sender, args });
29         }
30         #endregion
31 
32         private void DebugOut(object sender,SourceDebugOutArgs args)
33         {
34             if (args != null)
35                 _outText.WriteLine(args.Message);
36             else
37                 _outText.WriteLine(sender.ToString());
38         }
39 
40         public override void Show()
41         {
42             _outText = new DebugOutText();
43             this.ShowUI = _outText;
44             base.Show();
45         }
46     }
47 }
48 
49 

 

DebugOutText定义:


 1 using System;
 2 using System.Collections.Generic;
 3 using System.ComponentModel;
 4 using System.Drawing;
 5 using System.Data;
 6 using System.Text;
 7 using System.Windows.Forms;
 8 
 9 namespace FormDebugText
10 {
11     public partial class DebugOutText : UserControl
12     {
13         public DebugOutText()
14         {
15             InitializeComponent();
16         }
17 
18         public void WriteLine(string mesage)
19         {
20             if (richTextBox1.Lines.Length > 2000)
21             {
22                 richTextBox1.Text = "";
23             }
24 
25             StringBuilder build = new StringBuilder(this.richTextBox1.Text);
26             this.richTextBox1.Text = build.Insert(0, mesage + "\r\n").ToString();
27         }
28     }
29 }
30 
31 

 

posted @ 2008-11-27 15:15  离思  阅读(2021)  评论(1编辑  收藏  举报