Commit 123aacbd LN

日志修改

1 个父辈 73363f32
...@@ -57,7 +57,7 @@ namespace OnlineStore.ACPackingStore ...@@ -57,7 +57,7 @@ namespace OnlineStore.ACPackingStore
// LogUtil.logBox = this.logBox; // LogUtil.logBox = this.logBox;
// HideForm(); // HideForm();
LoadOk = true; LoadOk = true;
LogUtil.logBox = this.logBox; LogUtil.logBox = this.logBox;
this.timer1.Start(); this.timer1.Start();
} }
......
...@@ -18,8 +18,7 @@ namespace OnlineStore.Common ...@@ -18,8 +18,7 @@ namespace OnlineStore.Common
public static Dictionary<int, DateTime> lastErrorLogTime = new Dictionary<int, DateTime>(); public static Dictionary<int, DateTime> lastErrorLogTime = new Dictionary<int, DateTime>();
public static System.Windows.Forms.RichTextBox logBox = null; public static System.Windows.Forms.RichTextBox logBox = null;
public static int showCount = 20; public static int showCount = 20;
public static bool debug_opened = false; public static bool debug_opened = false;
...@@ -96,18 +95,28 @@ namespace OnlineStore.Common ...@@ -96,18 +95,28 @@ namespace OnlineStore.Common
{ {
try try
{ {
//if (logList.Count > 0)
//{
// logList.RemoveAt(0);
//}
//if (logList.Count >= showCount)
//{
// logList.RemoveAt(logList.Count - 1);
//}
//System.DateTime now = System.DateTime.Now;
//logList.Insert(0, now.ToLongTimeString() + " " + msg + Environment.NewLine);
//logList.Insert(0, Environment.NewLine);
if (logList.Count > 0) if (logList.Count > 0)
{ {
logList.RemoveAt(0); // logList.RemoveAt(0);
} }
if (logList.Count >= showCount) if (logList.Count >= showCount)
{ {
logList.RemoveAt(logList.Count - 1); logList.RemoveAt(0);
} }
System.DateTime now = System.DateTime.Now;
logList.Insert(0, now.ToLongTimeString() + " " + msg + Environment.NewLine);
logList.Insert(0, Environment.NewLine);
string text = ""; string text = "";
foreach (string str in logList) foreach (string str in logList)
{ {
...@@ -116,8 +125,16 @@ namespace OnlineStore.Common ...@@ -116,8 +125,16 @@ namespace OnlineStore.Common
if (logBox == null) if (logBox == null)
{ {
return; return;
} }
logBox.Text = text;
logBox.Text = text;
System.DateTime now = System.DateTime.Now;
logList.Add(now.ToLongTimeString() + " " + msg + Environment.NewLine);
// logBox.Focus(); //使文本框获取焦点
logBox.AppendText(now.ToLongTimeString() + " " + msg + Environment.NewLine); //增加文本
logBox.Select(logBox.Text.Length, 0); //设置光标的位置到文本尾
logBox.ScrollToCaret(); //滚动到控件光标处
} }
catch (Exception ex) catch (Exception ex)
{ {
......
支持 Markdown 格式
你添加了 0 到此讨论。请谨慎行事。
Finish editing this message first!