📄 ctrlresultpanel.cs
字号:
using System;
using System.Collections;
using System.ComponentModel;
using System.Drawing;
using System.Data;
using System.Windows.Forms;
namespace DS.EMIS.StartPrepare
{
/// <summary>
/// CtrlResultPanel 的摘要说明。
/// </summary>
public class CtrlResultPanel : System.Windows.Forms.UserControl
{
public delegate void AppendLogHandler(string log);
private System.Windows.Forms.Label label1;
private System.Windows.Forms.TextBox txtCreateTime;
private System.Windows.Forms.RichTextBox txtLog;
/// <summary>
/// 必需的设计器变量。
/// </summary>
private System.ComponentModel.Container components = null;
public CtrlResultPanel()
{
// 该调用是 Windows.Forms 窗体设计器所必需的。
InitializeComponent();
// TODO: 在 InitializeComponent 调用后添加任何初始化
}
/// <summary>
/// 清理所有正在使用的资源。
/// </summary>
protected override void Dispose( bool disposing )
{
if( disposing )
{
if(components != null)
{
components.Dispose();
}
}
base.Dispose( disposing );
}
#region 组件设计器生成的代码
/// <summary>
/// 设计器支持所需的方法 - 不要使用代码编辑器
/// 修改此方法的内容。
/// </summary>
private void InitializeComponent()
{
this.label1 = new System.Windows.Forms.Label();
this.txtCreateTime = new System.Windows.Forms.TextBox();
this.txtLog = new System.Windows.Forms.RichTextBox();
this.SuspendLayout();
//
// label1
//
this.label1.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Right)));
this.label1.Location = new System.Drawing.Point(168, 0);
this.label1.Name = "label1";
this.label1.Size = new System.Drawing.Size(80, 23);
this.label1.TabIndex = 4;
this.label1.Text = "创建时间:";
this.label1.TextAlign = System.Drawing.ContentAlignment.MiddleCenter;
//
// txtCreateTime
//
this.txtCreateTime.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Right)));
this.txtCreateTime.Location = new System.Drawing.Point(248, 0);
this.txtCreateTime.Name = "txtCreateTime";
this.txtCreateTime.ReadOnly = true;
this.txtCreateTime.Size = new System.Drawing.Size(120, 21);
this.txtCreateTime.TabIndex = 5;
this.txtCreateTime.Text = "";
//
// txtLog
//
this.txtLog.Anchor = ((System.Windows.Forms.AnchorStyles)((((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Bottom)
| System.Windows.Forms.AnchorStyles.Left)
| System.Windows.Forms.AnchorStyles.Right)));
this.txtLog.Location = new System.Drawing.Point(8, 24);
this.txtLog.Name = "txtLog";
this.txtLog.ReadOnly = true;
this.txtLog.Size = new System.Drawing.Size(368, 224);
this.txtLog.TabIndex = 3;
this.txtLog.Text = "";
//
// CtrlResultPanel
//
this.Controls.Add(this.txtCreateTime);
this.Controls.Add(this.label1);
this.Controls.Add(this.txtLog);
this.Name = "CtrlResultPanel";
this.Size = new System.Drawing.Size(384, 256);
this.ResumeLayout(false);
}
#endregion
public void Reset()
{
if(this.InvokeRequired)
{
this.Invoke(new MethodInvoker(Reset));
}
else
{
this.txtLog.Clear();
}
}
public void AppendLog(string log)
{
if(this.InvokeRequired)
{
this.Invoke(new AppendLogHandler(AppendLog),new object[]{log});
}
else
{
log = DateTime.Now.ToString()+" :\r\n"+log;
if(!log.EndsWith("\n"))
{
log += "\r\n";
}
this.txtLog.AppendText(log);
Application.DoEvents();
}
}
public DateTime LogCreateTime
{
set
{
this.txtCreateTime.Text = value.GetDateTimeFormats('f')[0].ToString();
}
}
}
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -