protected override void OnPaint(PaintEventArgs e) { base.OnPaint(e); lock (lockObject) { using (GraphicsPath path = new GraphicsPath()) using (GraphicsPath path2 = new GraphicsPath()) using (Pen pathPen = new Pen(ForeColor, 3)) using (Pen pathPen2 = new Pen(Color.FromArgb(150, ForeColor), 3)) using (Brush brush = new SolidBrush(Color.FromArgb(130, ForeColor2))) { int lineNum = 0; float xOffset = ClientRectangle.Width; float stepLength = ClientRectangle.Width / 2f / (float)(chunkSize - 1); for (int index = values.Count - 2; index > -1; index -= 1) { lineNum++; float yScale1 = values[index + 1] / (float)YScale; float yScale2 = values[index] / (float)YScale; float y1 = ClientRectangle.Height - (ClientRectangle.Height * yScale1); float y2 = ClientRectangle.Height - (ClientRectangle.Height * yScale2); path.AddLine(xOffset, y1, xOffset -= stepLength, y2); if (lineNum == chunkSize) { break; } } lineNum = 0; xOffset = ClientRectangle.Width / 2f; for (int index = values2.Count - 2; index > -1; index -= 1) { lineNum++; float yScale1 = values2[index + 1] / (float)YScale; float yScale2 = values2[index] / (float)YScale; float y1 = ClientRectangle.Height - (ClientRectangle.Height * yScale1); float y2 = ClientRectangle.Height - (ClientRectangle.Height * yScale2); path2.AddLine(xOffset, y1, xOffset -= stepLength, y2); if (lineNum == chunkSize) { break; } } e.Graphics.DrawLine(Pens.Blue, ClientRectangle.Width / 2f, 0, ClientRectangle.Width / 2f, ClientRectangle.Bottom); SmoothingMode oldMode = e.Graphics.SmoothingMode; e.Graphics.SmoothingMode = SmoothingMode.AntiAlias; e.Graphics.TextRenderingHint = TextRenderingHint.AntiAlias; if (showValue) { StringFormat stringFormat = new StringFormat(); stringFormat.Alignment = StringAlignment.Center; stringFormat.LineAlignment = StringAlignment.Center; stringFormat.FormatFlags = StringFormatFlags.NoWrap; string textualValue = values.LastOrDefault().ToString(); int fontSize = TextUtils.GetFontSize(e.Graphics, textualValue, Font, ClientRectangle.Size); e.Graphics.DrawString(textualValue, new Font(Font.FontFamily, fontSize), brush, ClientRectangle, stringFormat); } e.Graphics.DrawPath(pathPen, path); e.Graphics.DrawPath(pathPen2, path2); e.Graphics.SmoothingMode = oldMode; } ControlPaint.DrawBorder(e.Graphics, ClientRectangle, Color.DarkGray, ButtonBorderStyle.Solid); } }