comparison Implab.Diagnostics.Interactive/TraceViewControl.cs @ 45:d10034588e38 interactive logger

initial work on interactive logger
author cin
date Thu, 17 Apr 2014 03:05:53 +0400
parents
children
comparison
equal deleted inserted replaced
42:3ba6778ed336 45:d10034588e38
1 using System;
2 using System.Collections.Generic;
3 using System.ComponentModel;
4 using System.Drawing;
5 using System.Data;
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 TraceViewControl : UserControl {
13 int m_maxEvents = 1000;
14
15 string m_status = "ready";
16
17 readonly LinkedList<TraceViewItem> m_events = new LinkedList<TraceViewItem>();
18 public TraceViewControl() {
19 InitializeComponent();
20
21 var ticks = Environment.TickCount;
22
23 for (int i = 0; i < 1333; i++) {
24 AddViewItem(new TraceViewItem {
25 indent = i % 4,
26 message = String.Format("Auto generated {0}", i),
27 thread = 2,
28 timestamp = ticks + i*10
29 });
30 }
31 }
32
33 public void AddViewItem(TraceViewItem item) {
34 m_events.AddLast(item);
35 if (m_events.Count > m_maxEvents)
36 m_events.RemoveFirst();
37 }
38
39 protected override void OnPaint(PaintEventArgs e) {
40 base.OnPaint(e);
41
42 if (m_status != null)
43 e.Graphics.DrawString(m_status, DefaultFont, Brushes.Black, 0, 0);
44
45 }
46
47 protected override void OnMouseMove(MouseEventArgs e) {
48 base.OnMouseMove(e);
49
50 m_status = String.Format("({0},{1})", e.X, e.Y);
51 Invalidate();
52 }
53
54 }
55 }