Пример #1
0
        private void DrawScale(Graphics graphics, Rectangle clipRect, Font font, HeaderFormat headerformat, List <RectangleF> labelRects, List <DateTime> dates)
        {
            TimelinePaintEventArgs e = null;
            DateTime datetime        = dates[0]; // these initialisation values matter

            for (int i = 0; i < labelRects.Count; i++)
            {
                // Give user a chance to format the tickmark that is to be drawn
                // https://blog.nicholasrogoff.com/2012/05/05/c-datetime-tostring-formats-quick-reference/
                datetime = dates[i];
                GetLabel(datetime, out HeaderLabel minor, out HeaderLabel major);
                e = new TimelinePaintEventArgs(graphics, clipRect, control, datetime, new DateTime(), minor, major);
                PaintTimeline?.Invoke(this, e);

                // Draw the label if not already handled by the user
                if (!e.Handled)
                {
                    if (!string.IsNullOrEmpty(minor.Text))
                    {
                        // Draw minor label
                        var textbox = graphics.TextBoxAlign(minor.Text, minor.Format.TextAlign, minor.Format.Font, labelRects[i], minor.Format.Margin);
                        graphics.DrawString(minor.Text, minor.Format.Font, minor.Format.Color, textbox);
                    }

                    if (!string.IsNullOrEmpty(major.Text))
                    {
                        // Draw major label
                        var majorLabelRect = new RectangleF(labelRects[i].X, viewport.Y, control.MajorWidth, control.HeaderOneHeight);
                        var textbox        = graphics.TextBoxAlign(major.Text, major.Format.TextAlign, major.Format.Font, majorLabelRect, major.Format.Margin);
                        graphics.DrawString(major.Text, major.Format.Font, major.Format.Color, textbox);
                        //__DrawMarker(graphics, labelRects[i].X + MinorWidth / 2f, _mViewport.Y + HeaderOneHeight - 2f);
                    }
                }
            }
        }
Пример #2
0
 protected virtual void OnPaintTimeline(TimelinePaintEventArgs e)
 {
     PaintTimeline?.Invoke(this, e);
 }