using System; using System.Collections.Generic; using System.Drawing; using System.Drawing.Drawing2D; using System.Windows.Forms; internal class Graph : Ctl { private List d = new List(); public Graph() { Size = new Size(368, 60); Cursor = Cursors.Default; } public void Add(double v) { lock (d) { d.Add(v); if (d.Count > 60) { d.RemoveAt(0); } } } public double[] Snap() { lock (d) { return d.ToArray(); } } protected override void OnPaint(PaintEventArgs e) { Graphics graphics = e.Graphics; Prep(graphics); graphics.Clear(BackColor); G.Fill(graphics, new RectangleF(0f, 0f, Width - 1, Height - 1), 10f, G.Bg); double[] array = Snap(); float num = (float)Width / 60f; for (int i = 0; i < array.Length; i++) { float num2 = (float)Math.Min(1.0, array[i] / 200.0) * (float)(Height - 8); using SolidBrush brush = new SolidBrush(Color.FromArgb(200, G.Acc)); graphics.FillRectangle(brush, (float)(60 - array.Length + i) * num + 1f, (float)(Height - 4) - num2, num - 2f, num2); } float num3 = (float)(Height - 4) - 0.5f * (float)(Height - 8); Pen pen = new Pen(G.Dim, 1f); pen.DashStyle = DashStyle.Dot; using Pen pen2 = pen; graphics.DrawLine(pen2, 0f, num3, Width, num3); } }