Mercurial > pub > ImplabNet
comparison Implab.Diagnostics.Interactive/TraceForm.cs @ 50:f8cbe84cfdb1
Слияние с interactive logger
| author | cin |
|---|---|
| date | Fri, 18 Apr 2014 12:37:48 +0400 |
| parents | d9d794b61bb9 |
| children | cbb0bd8fc0d1 |
comparison
equal
deleted
inserted
replaced
| 44:e5ec543feee3 | 50:f8cbe84cfdb1 |
|---|---|
| 1 using System; | |
| 2 using System.Collections.Generic; | |
| 3 using System.ComponentModel; | |
| 4 using System.Data; | |
| 5 using System.Drawing; | |
| 6 using System.Linq; | |
| 7 using System.Text; | |
| 8 using System.Threading.Tasks; | |
| 9 using System.Windows.Forms; | |
| 10 | |
| 11 namespace Implab.Diagnostics.Interactive { | |
| 12 public partial class TraceForm : Form { | |
| 13 readonly Dictionary<int, Color> m_threadColors = new Dictionary<int,Color>(); | |
| 14 readonly Random m_rand = new Random(); | |
| 15 | |
| 16 public event EventHandler PauseEvents; | |
| 17 | |
| 18 public event EventHandler ResumeEvents; | |
| 19 | |
| 20 public TraceForm() { | |
| 21 InitializeComponent(); | |
| 22 } | |
| 23 | |
| 24 protected override void OnFormClosing(FormClosingEventArgs e) { | |
| 25 base.OnFormClosing(e); | |
| 26 if (!e.Cancel && e.CloseReason == CloseReason.UserClosing) { | |
| 27 e.Cancel = true; | |
| 28 Hide(); | |
| 29 } | |
| 30 } | |
| 31 | |
| 32 public void AddTraceEvent(TraceViewItem item) { | |
| 33 traceViewItemBindingSource.Add(item); | |
| 34 eventsDataGrid.FirstDisplayedScrollingRowIndex = eventsDataGrid.RowCount - 1; | |
| 35 } | |
| 36 | |
| 37 Color GetThreadColor(int thread) { | |
| 38 Color result; | |
| 39 if (!m_threadColors.TryGetValue(thread, out result)) { | |
| 40 result = Color.FromArgb(m_rand.Next(4)*64, m_rand.Next(4)*64, m_rand.Next(4)*64); | |
| 41 m_threadColors[thread] = result; | |
| 42 } | |
| 43 return result; | |
| 44 } | |
| 45 | |
| 46 private void eventsDataGrid_CellFormatting(object sender, DataGridViewCellFormattingEventArgs e) { | |
| 47 var data = (TraceViewItem)traceViewItemBindingSource[e.RowIndex]; | |
| 48 if (e.ColumnIndex == messageDataGridViewTextBoxColumn.Index) | |
| 49 e.CellStyle.Padding = new Padding(data.Indent * 10,0,0,0); | |
| 50 e.CellStyle.ForeColor = GetThreadColor(data.Thread); | |
| 51 } | |
| 52 } | |
| 53 } |
