private void DrawHeader(Graphics graphics, SchedulerModels models, Rectangle clipRect) { var info = models.HeaderInfo; var viewRect = viewport.Rectangle; // Draw header backgrounds var e = new HeaderPaintEventArgs(graphics, clipRect, control, control.Font, control.HeaderFormat); //OnPaintHeader(e); var gradient = new LinearGradientBrush(info.H1Rect, e.Format.GradientLight, e.Format.GradientDark, LinearGradientMode.Vertical); graphics.FillRectangles(gradient, new RectangleF[] { info.H1Rect, info.H2Rect }); graphics.DrawRectangles(e.Format.Border, new RectangleF[] { info.H1Rect, info.H2Rect }); // Draw the header scales DrawScale(graphics, clipRect, e.Font, e.Format, info.LabelRects, info.DateTimes); // draw "Now" line float xf = control.GetSpan(control.Scheduler.Now); var pen = new Pen(e.Format.Border.Color) { DashStyle = DashStyle.Dash, Color = Color.Red }; graphics.DrawLine(pen, new PointF(xf, viewport.Y), new PointF(xf, viewport.Rectangle.Bottom)); }
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 DrawColumns(Graphics graphics, SchedulerModels models) { // draw column lines graphics.DrawRectangles(control.HeaderFormat.Border, models.HeaderInfo.Columns.ToArray()); // fill weekend columns for (int i = 0; i < models.HeaderInfo.DateTimes.Count; i++) { var date = models.HeaderInfo.DateTimes[i]; // highlight weekends for day time scale if (date.DayOfWeek == DayOfWeek.Sunday || date.DayOfWeek == DayOfWeek.Saturday) { var pattern = new System.Drawing.Drawing2D.HatchBrush(System.Drawing.Drawing2D.HatchStyle.Percent20, control.HeaderFormat.Border.Color, Color.Transparent); graphics.FillRectangle(pattern, models.HeaderInfo.Columns[i]); } } }
public void PaintChart(Graphics graphics, SchedulerModels models, Rectangle clipRect) { graphics.Clear(Color.White); int row = 0; if (control.Scheduler != null) { // generate rectangles control.GenerateModels(); // set model view matrix graphics.Transform = viewport.Projection; // draw columns in the background DrawColumns(graphics, models); // draw bar charts row = DrawScheduleEvents(graphics, models, clipRect); // draw the header DrawHeader(graphics, models, clipRect); } // flush graphics.Flush(); }
public SchedulerModelGenerator(HotelSchedulerControl.SchedulerControl control, IViewport viewport, SchedulerModels models) { this.viewport = viewport; this.control = control; this.models = models; }
public SchedulerPainter(HotelSchedulerControl.SchedulerControl control, SchedulerModels models, IViewport viewport) { this.control = control; this.viewport = viewport; this.models = models; }