private void __DrawRegularTaskAndGroup(Graphics graphics, TaskPaintEventArgs e, ScheduleEvent task, RectangleF taskRect)
        {
            var fill = taskRect;

            fill.Width = (int)(fill.Width * 1);
            graphics.FillRectangle(e.Format.BackFill, taskRect);
            graphics.FillRectangle(e.Format.ForeFill, fill);
            graphics.DrawRectangle(e.Format.Border, taskRect);
        }
        private int _DrawTasks(Graphics graphics, Rectangle clipRect)
        {
            var   viewRect    = _mViewport.Rectangle;
            int   row         = 0;
            var   pen         = new Pen(Color.Gray);
            float labelMargin = this.MinorWidth / 2.0f + 3.0f;

            pen.DashStyle = DashStyle.Dot;
            TaskPaintEventArgs e;

            foreach (var task in _mChartTaskRects.Keys)
            {
                // Get the taskrect
                var taskrect = _mChartTaskRects[task];
                // Only begin drawing when the taskrect is to the left of the clipRect's right edge
                if (taskrect.Left <= viewRect.Right)
                {
                    e = new TaskPaintEventArgs(graphics, clipRect, this, task, row, this.Font, task.Format);
                    PaintTask?.Invoke(this, e);

                    if (viewRect.IntersectsWith(taskrect))
                    {
                        __DrawRegularTaskAndGroup(graphics, e, task, taskrect);
                    }

                    // write text
                    if (this.ShowTaskLabels && task.Name != string.Empty)
                    {
                        var name    = task.Name;
                        var txtrect = graphics.TextBoxAlign(name, ChartTextAlign.MiddleLeft, e.Font, taskrect, labelMargin);
                        txtrect.Offset(taskrect.Width, 0);
                        if (viewRect.IntersectsWith(txtrect))
                        {
                            graphics.DrawString(name, e.Font, e.Format.Color, txtrect);
                        }
                    }

                    // draw slack
                    if (this.ShowSlack)
                    {
                        var slackrect = _mChartSlackRects[task];
                        if (viewRect.IntersectsWith(slackrect))
                        {
                            graphics.FillRectangle(e.Format.SlackFill, slackrect);
                        }
                    }
                }
                row++;
            }
            return(row);
        }
        private int DrawScheduleEvents(Graphics graphics, SchedulerModels models, Rectangle clipRect)
        {
            var   viewRect    = viewport.Rectangle;
            var   pen         = new Pen(Color.Gray);
            float labelMargin = control.MinorWidth / 2.0f + 3.0f;

            pen.DashStyle = DashStyle.Dot;
            TaskPaintEventArgs e;

            foreach (var task in models.EventRectangles.Keys)
            {
                // Get the taskrect
                var taskrect = models.EventRectangles[task];
                // Only begin drawing when the taskrect is to the left of the clipRect's right edge
                if (taskrect.Left <= viewRect.Right)
                {
                    e = new TaskPaintEventArgs(graphics, clipRect, control, task, task.Row, control.Font, task.Format);
                    PaintTask?.Invoke(control, e);

                    if (viewRect.IntersectsWith(taskrect))
                    {
                        DrawScheduleEvent(graphics, e, task, taskrect);
                    }

                    // write text
                    if (control.ShowTaskLabels && task.Name != string.Empty)
                    {
                        var name    = task.Name;
                        var txtrect = graphics.TextBoxAlign(name, ChartTextAlign.MiddleLeft, e.Font, taskrect, labelMargin);
                        txtrect.Offset(taskrect.Width, 0);
                        if (viewRect.IntersectsWith(txtrect))
                        {
                            graphics.DrawString(name, e.Font, e.Format.Color, txtrect);
                        }
                    }

                    // draw slack
                    if (control.ShowSlack)
                    {
                        var slackrect = models.EventSlackRectangles[task];
                        if (viewRect.IntersectsWith(slackrect))
                        {
                            graphics.FillRectangle(e.Format.SlackFill, slackrect);
                        }
                    }
                }
            }
            return(1);
        }
        private void __DrawTaskParts(Graphics graphics, TaskPaintEventArgs e, ScheduleEvent task, Pen pen)
        {
            var parts = _mChartTaskPartRects[task];

            // Draw line indicator
            var firstRect = parts[0].Value;
            var lastRect  = parts[parts.Count - 1].Value;
            var y_coord   = (firstRect.Top + firstRect.Bottom) / 2.0f;
            var point1    = new PointF(firstRect.Right, y_coord);
            var point2    = new PointF(lastRect.Left, y_coord);

            graphics.DrawLine(pen, point1, point2);

            // Draw Part Rectangles
            var taskRects = parts.Select(x => x.Value).ToArray();

            graphics.FillRectangles(e.Format.BackFill, taskRects);

            // Draw % complete indicators
            graphics.FillRectangles(e.Format.ForeFill, parts.Select(x => new RectangleF(x.Value.X, x.Value.Y, x.Value.Width * 1, x.Value.Height)).ToArray());

            // Draw border
            graphics.DrawRectangles(e.Format.Border, taskRects);
        }