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);
                    }
                }
            }
        }
 public SchedulerControl()
 {
     InitializeComponent();
     HeaderOneHeight     = 32;
     HeaderTwoHeight     = 20;
     BarSpacing          = 32;
     BarHeight           = 20;
     MajorWidth          = 140;
     MinorWidth          = 20;
     TimeResolution      = TimeResolution.Day;
     this.DoubleBuffered = true;
     _mViewport          = new ControlViewport(this)
     {
         WheelDelta = BarSpacing
     };
     //AllowTaskDragDrop = true;
     ShowSlack      = true;
     ShowTaskLabels = true;
     this.Dock      = DockStyle.Fill;
     this.Margin    = new Padding(0, 0, 0, 0);
     this.Padding   = new Padding(0, 0, 0, 0);
     HeaderFormat   = new HeaderFormat()
     {
         Color         = Brushes.Black,
         Border        = new Pen(SystemColors.ActiveBorder),
         GradientLight = SystemColors.ButtonHighlight,
         GradientDark  = SystemColors.ButtonFace
     };
     MajorLabelFormat = new HeaderLabelFormat()
     {
         Font      = Font,
         Color     = HeaderFormat.Color,
         Margin    = 3,
         TextAlign = ChartTextAlign.MiddleCenter
     };
     MinorLabelFormat = new HeaderLabelFormat()
     {
         Font      = Font,
         Color     = HeaderFormat.Color,
         Margin    = 3,
         TextAlign = ChartTextAlign.MiddleCenter
     };
 }
Esempio n. 3
0
 /// <summary>
 /// Initialize a new instance of HeaderPaintEventArgs with the editable default font and header format
 /// </summary>
 public HeaderPaintEventArgs(Graphics graphics, Rectangle clipRect, SchedulerControl chart, Font font, HeaderFormat format)
     : base(graphics, clipRect, chart)
 {
     this.Font   = font;
     this.Format = format;
 }