public void DisplayNitifyItemInfo(NotifyItem info) { if (string.IsNullOrEmpty(infoTextbox.Text)) { showInfoLineCount = 0; } showInfoLineCount++; if (showInfoLineCount > MaxDisplayCount) { var line = infoTextbox.Text.Split(new[] { "\r\n" }, StringSplitOptions.None); infoTextbox.Text = string.Join(System.Environment.NewLine, line.Skip(1)); } infoTextbox.AppendText(string.Format("{0} {1}\r\n", DateTime.Now.ToString("HH:mm:ss.fff"), info.message)); }
public void DisplayNitifyItemInfo(NotifyItem info) { ControlSafeOPeration.CtrlSafeOperation.InvokeSafeOperation(infoTextbox, () => { if (string.IsNullOrEmpty(infoTextbox.Text)) { showInfoLineCount = 0; } showInfoLineCount++; if (showInfoLineCount > MaxDisplayCount) { var line = infoTextbox.Text.Split(new[] { "\r\n\r\n" }, StringSplitOptions.None); infoTextbox.Text = string.Join("\r\n\r\n", line.Skip(1)); //infoTextbox.SelectionStart = 0; //int end = infoTextbox.Text.IndexOf("\n\r");//第一行内第一个字符容的索引 //int start = infoTextbox.Text.IndexOf("\n\r")-1;//第二行第一个字符的索引 //infoTextbox.Select(start, end);//选中第一行 //infoTextbox.SelectedText = "";//设置第一行的内容为空 } infoTextbox.AppendText(string.Format("{0} {1}\r\n\r\n", DateTime.Now.ToString("HH:mm:ss.fff"), info.message)); }); }
public void DisplayNitifyItemInfo(NotifyItem info) { DisplayListInfo(info.message); }
public void DisplayNitifyItemInfo(NotifyItem info) { lock (locker) { ControlSafeOPeration.CtrlSafeOperation.InvokeSafeOperation(m_ListView, new Action(() => { m_ListView.SuspendLayout(); m_ListView.BeginUpdate(); ListViewItem item = new ListViewItem(); //item.UseItemStyleForSubItems = false; item.Text = DateTime.Now.ToString("HH:mm:ss.fff"); switch (info.notifyLevel) { case NotifyLevel.DISPLAY: item.SubItems.Add("DisPlay"); item.ImageIndex = 0; break; case NotifyLevel.ALL: item.SubItems.Add("All"); item.ImageIndex = 1; break; case NotifyLevel.FATAL: item.SubItems.Add("Fatal"); item.ImageIndex = 2; break; case NotifyLevel.ERROR: item.SubItems.Add("Error"); item.ImageIndex = 3; break; case NotifyLevel.WARNING: item.SubItems.Add("Warning"); item.ImageIndex = 4; break; case NotifyLevel.DEBUG: item.SubItems.Add("Debug"); item.ImageIndex = 5; break; case NotifyLevel.INFO: item.SubItems.Add("Info"); item.ImageIndex = 6; break; default: break; } item.SubItems.Add(info.message); m_ListView.Items.Add(item); if (m_ListView.Items.Count == 1) { AutoResizeColumnWidth(m_ListView); } else { AutoResizeColumnWidth(m_ListView, item); } m_ListView.Items[m_ListView.Items.Count - 1].EnsureVisible(); //超出显示范围自动清理 if (m_ListView.Items.Count > MaxDisplayCount) { m_ListView.Items.RemoveAt(0); } m_ListView.EndUpdate(); m_ListView.ResumeLayout(); })); } }
public void DisplayNitifyItemInfo(NotifyItem info) { ControlSafeOPeration.CtrlSafeOperation.InvokeSafeOperation(richTextBox, () => { if (string.IsNullOrEmpty(richTextBox.Text)) { showInfoLineCount = 0; } richTextBox.SuspendLayout(); string str = string.Format("{0} {1}\r\n\r\n", DateTime.Now.ToString("HH:mm:ss.fff"), info.message); info.message = str; infoList.Add(info); richTextBox.Clear(); foreach (var item in infoList) { switch (item.notifyLevel) { case NotifyLevel.DISPLAY: richTextBox.SelectionColor = Color.Black; break; case NotifyLevel.ALL: richTextBox.SelectionColor = Color.Blue; break; case NotifyLevel.FATAL: richTextBox.SelectionColor = Color.DarkRed; break; case NotifyLevel.ERROR: richTextBox.SelectionColor = Color.Red; break; case NotifyLevel.WARNING: richTextBox.SelectionColor = Color.DeepPink; break; case NotifyLevel.DEBUG: richTextBox.SelectionColor = Color.Green; break; case NotifyLevel.INFO: richTextBox.SelectionColor = Color.Orange; break; default: break; } richTextBox.AppendText(item.message); } if (showInfoLineCount > MaxDisplayCount) { infoList.RemoveAt(0); //richTextBox.SelectionStart = 0; //richTextBox1.SelectionLength = richTextBox1.GetFirstCharIndexFromLine(1); //richTextBox.SelectionLength =richTextBox.Text.IndexOf("\n\n")+1; //richTextBox.SelectedText=""; } else { showInfoLineCount++; } richTextBox.ResumeLayout(); //richTextBox.Focus(); richTextBox.Select(richTextBox.TextLength, 0); richTextBox.ScrollToCaret(); //richTextBox.Refresh(); }); }
private static void ShowInfo(NotifyLevel level, string msg) { NotifyItem notifyItem = new NotifyItem(level, msg); notifyBoard.DisplayNitifyItemInfo(notifyItem); }
public NotifyItem(NotifyItem othre) { notifyLevel = othre.notifyLevel; message = othre.message; }