protected override void OnPaint(PaintEventArgs e) { SuspendLayout(); e.Graphics.FillRectangle(Brushes.LightGray, new RectangleF(0, e.ClipRectangle.Height - Timebar.Height, Width, Timebar.Height)); for (int i = 0; i < Width; i++) { e.Graphics.DrawLine(Pens.Black, IndexToPosition(i), e.ClipRectangle.Height - Timebar.Height, IndexToPosition(i), e.ClipRectangle.Height); var span = ((double)i / (double)Timebar.GetLevel(Timebar.Scale)).ToString(); e.Graphics.DrawString(span, DefaultFont, Brushes.Black, IndexToPosition(i) - Convert.ToInt32(e.Graphics.MeasureString(i.ToString(), DefaultFont).Width / 2), e.ClipRectangle.Height - Timebar.Height - 15); for (int j = 1; j < SPACER; j++) { int start_w = IndexToPosition(i); e.Graphics.DrawLine(Pens.DarkGray, start_w + SPACER_TICK * j, e.ClipRectangle.Height - Timebar.Height, start_w + SPACER_TICK * j, e.ClipRectangle.Height); } } if (_Index > -1) { e.Graphics.FillRectangle(SystemBrushes.Highlight, IndexToRectangle(_Index)); } base.OnPaint(e); ResumeLayout(); }
public void RefreshControls() { foreach (Control item in Controls) { if (item.Tag == null) { item.Tag = item.Width; } item.Width = (int)item.Tag * Timebar.GetLevel(Timebar.Scale); } }