protected override void OnPaint(PaintEventArgs e) { if (target == null) { return; } Point car = PointToClient(target.PointToScreen(target.PlaceToPoint(target.Selection.Start))); Size fontSize = TextRenderer.MeasureText("W", Font); int column = 0; e.Graphics.FillRectangle(new LinearGradientBrush(new Rectangle(0, 0, Width, Height), BackColor, BackColor2, 270), new Rectangle(0, 0, Width, Height)); float columnWidth = target.CharWidth; var sf = new StringFormat(); sf.Alignment = StringAlignment.Center; sf.LineAlignment = StringAlignment.Near; var zeroPoint = target.PositionToPoint(0); zeroPoint = PointToClient(target.PointToScreen(zeroPoint)); using (var pen = new Pen(TickColor)) using (var textBrush = new SolidBrush(ForeColor)) for (float x = zeroPoint.X; x < Right; x += columnWidth, ++column) { if (column % 10 == 0) { e.Graphics.DrawString(column.ToString(), Font, textBrush, x, 0f, sf); } e.Graphics.DrawLine(pen, (int)x, fontSize.Height + (column % 5 == 0 ? 1 : 3), (int)x, Height - 4); } using (var pen = new Pen(TickColor)) e.Graphics.DrawLine(pen, new Point(car.X - 3, Height - 3), new Point(car.X + 3, Height - 3)); using (var pen = new Pen(CaretTickColor)) { e.Graphics.DrawLine(pen, new Point(car.X - 2, fontSize.Height + 3), new Point(car.X - 2, Height - 4)); e.Graphics.DrawLine(pen, new Point(car.X, fontSize.Height + 1), new Point(car.X, Height - 4)); e.Graphics.DrawLine(pen, new Point(car.X + 2, fontSize.Height + 3), new Point(car.X + 2, Height - 4)); } }