www.pudn.com > HttpProxy.rar > DetailLog.cs
using System;
using System.Data;
using System.Drawing;
using System.Collections;
using System.ComponentModel;
using System.Windows.Forms;
using HttpProxy.Component;
namespace HttpProxy.UI
{
///
/// DetailLog 类
///
public class DetailLog : System.Windows.Forms.Form
{
private System.Windows.Forms.Timer timerDetail;
private System.Windows.Forms.ListView lvDetail;
private System.ComponentModel.IContainer components;
private static System.Windows.Forms.ColumnHeader[] col;
internal static System.Windows.Forms.ListViewItem lvItem;
internal static string masterThreadId=null;
public DetailLog()
{
//
// Windows 窗体设计器支持所必需的
//
InitializeComponent();
col=new ColumnHeader[]{new ColumnHeader(),new ColumnHeader(),new ColumnHeader(),new ColumnHeader(),new ColumnHeader()};
col[0].Text="线程Id";
col[0].TextAlign=HorizontalAlignment.Left;
col[0].Width=80;
col[1].Text="标志项";
col[1].TextAlign=HorizontalAlignment.Left;
col[1].Width=80;
col[2].Text="传输方向";
col[2].TextAlign=HorizontalAlignment.Left;
col[2].Width=120;
col[3].Text="数据传输量";
col[3].TextAlign=HorizontalAlignment.Left;
col[3].Width=120;
col[4].Text="传输时间";
col[4].TextAlign=HorizontalAlignment.Left;
col[4].Width=120;
this.lvDetail.Columns.AddRange(col);
}
///
/// 清理所有正在使用的资源。
///
protected override void Dispose( bool disposing )
{
if( disposing )
{
if(components != null)
{
components.Dispose();
}
}
base.Dispose( disposing );
}
#region Windows 窗体设计器生成的代码
///
/// 设计器支持所需的方法 - 不要使用代码编辑器修改
/// 此方法的内容。
///
private void InitializeComponent()
{
this.components = new System.ComponentModel.Container();
this.timerDetail = new System.Windows.Forms.Timer(this.components);
this.lvDetail = new System.Windows.Forms.ListView();
this.SuspendLayout();
//
// timerDetail
//
this.timerDetail.Enabled = true;
this.timerDetail.Interval = 5000;
this.timerDetail.Tick += new System.EventHandler(this.timerDetail_Tick);
//
// lvDetail
//
this.lvDetail.Dock = System.Windows.Forms.DockStyle.Fill;
this.lvDetail.Location = new System.Drawing.Point(0, 0);
this.lvDetail.Name = "lvDetail";
this.lvDetail.Size = new System.Drawing.Size(554, 272);
this.lvDetail.TabIndex = 0;
this.lvDetail.View = System.Windows.Forms.View.Details;
//
// DetailLog
//
this.AutoScaleBaseSize = new System.Drawing.Size(6, 14);
this.ClientSize = new System.Drawing.Size(554, 272);
this.Controls.Add(this.lvDetail);
this.FormBorderStyle = System.Windows.Forms.FormBorderStyle.FixedToolWindow;
this.MaximizeBox = false;
this.Name = "DetailLog";
this.ShowInTaskbar = false;
this.StartPosition = System.Windows.Forms.FormStartPosition.CenterParent;
this.Text = "详细日志";
this.Closing += new System.ComponentModel.CancelEventHandler(this.DetailLog_Closing);
this.ResumeLayout(false);
}
#endregion
///
/// Handles the Tick event of the timerDetail control.
///
/// The source of the event.
/// The instance containing the event data.
private void timerDetail_Tick(object sender, System.EventArgs e)
{
foreach(DataRow row in ProxyServer.dsLog.Tables["Child"].Rows)
{
lvItem=new ListViewItem(new string[]{row["ThreadID"].ToString(),row["ID"].ToString(),row["Direction"].ToString(),row["Data"].ToString(),row["Time"].ToString()});
if(masterThreadId ==row["ThreadID"].ToString() && (this.lvDetail.Items.Count<=0 || Convert.ToInt32(this.lvDetail.Items[this.lvDetail.Items.Count-1].SubItems[1].Text)
/// Handles the Closing event of the DetailLog control.
///
/// The source of the event.
/// The instance containing the event data.
private void DetailLog_Closing(object sender, System.ComponentModel.CancelEventArgs e)
{
ProxyMain.DetailLogOpen=false;
}
}
}