private void DrawTransparentTimeslot(Graphics g, Timeslot t, Color color) { Rectangle r = TimeslotRectangle(t); g.FillRectangle(new SolidBrush(Color.FromArgb(80, color)), r); g.DrawRectangle(new Pen(color, 3f), r); }
private void DrawActive(Graphics g, Timeslot timeslot, Color color) { Rectangle r = TimeslotRectangle(timeslot); r.X++; r.Y++; r.Width--; r.Height--; g.FillRectangle(LinearGradientActive(r.Location, Cell_.Width, Cell_.Height, color), r); }
public Rectangle TimeslotRectangle(Timeslot t) { Rectangle r = new Rectangle(Table_.Location, Cell_); r.Offset(Cell_.Width * (t.Day - (ShowWeekend_ ? 0 : 1)), Cell_.Height * (t.Start.DayMinutes - HourStart * 60) / 60); r.Height = (int)Math.Ceiling(t.TotalMinutes / 60f * Cell_.Height); return(r); }
/// <summary> /// Find an unavailable timeslot within the given range. /// </summary> /// <returns>The first unavailable timeslot found within the range, or null if none were found.</returns> public Unavailability FindUnavailableDuring(Timeslot timeslot) { foreach (Unavailability u in UnavailableList) { if (u.ClashesWith(timeslot)) { return(u); } } return(null); }
/// <summary> /// Finds a class within a given time range. /// </summary> /// <returns>The first class found, or null if none were found.</returns> public Session FindClassDuring(Timeslot timeslot, bool selected) { foreach (Session session in ClassList) { if (selected && !session.Stream.Selected) { continue; } if (session.ClashesWith(timeslot)) { return(session); } } return(null); }
private void DrawTimeslotText(Graphics g, Timeslot t, String text) { if (text == null || text.Length == 0) { return; } StringFormat format = new StringFormat(); format.Alignment = StringAlignment.Center; format.LineAlignment = StringAlignment.Center; Rectangle r = TimeslotRectangle(t); g.DrawString(text, Font, Brushes.Black, r, format); }
protected override void OnMouseDown(MouseEventArgs e) { base.OnMouseDown(e); TimeOfWeek time = FindClickTime(e); if (TimeOfWeek.ReferenceEquals(time, null)) { return; } if (EnableDrag_ && e.Button == MouseButtons.Left && Timetable_ != null) { DragSession_ = Timetable_.FindClassAt(time, !ShowAll_); Unavailability dragUnavail = Timetable_.FindUnavailableAt(time); if (DragSession_ != null) { BeginDrag(DragSession_.Stream.Type); DragCursor_ = DragCursor(DragSession_); DoDragDrop(DragSession_.Stream.Type, DragDropEffects.Move); EndDrag(); DragCursor_ = null; } else if (dragUnavail != null) { HoverUnavail_ = null; Invalidate(); DragCursor_ = DragCursor(dragUnavail); DoDragDrop(dragUnavail, DragDropEffects.Move); HoverUnavail_ = null; Invalidate(); DragCursor_ = null; } } if (TimetableMouseDown != null) { TimetableMouseDown(this, new TimetableEventArgs(e, time)); } }
private void DrawTimeslotActive(Graphics g, Timeslot t, Color color) { Rectangle r = TimeslotRectangle(t); // solid color g.FillRectangle(new SolidBrush(color), r); // gradient System.Drawing.Drawing2D.LinearGradientBrush brush = LinearGradientActive(r.Location, Cell_.Width, Cell_.Height, color); Rectangle q = new Rectangle(r.X, r.Y, r.Width, r.Height); if (r.Height > Cell_.Height * 2) { r.Height = Cell_.Height * 2; } g.FillRectangle(brush, r); g.DrawRectangle(Pens.Black, q); }
private void DrawGrayArea(Graphics g) { if (Timetable_ == null) { return; } for (int day = (ShowWeekend_ ? 0 : 1); day < (ShowWeekend_ ? 7 : 6); day++) { for (int hour = HourStart_; hour < HourEnd_; hour++) { Timeslot time = new Timeslot(day, hour, 0, hour + 1, 0); if (!Timetable_.ClassDuring(time, false)) { DrawTimeslot(g, time, Color.LightGray); } } } }
public Session(Timeslot time, string location) : base(time) { Location_ = location; }
public Unavailability(string name, Timeslot time) : base(time) { Name_ = name; }
/// <summary> /// Check if there is a class within a given time range. /// </summary> public bool ClassDuring(Timeslot timeslot, bool selected) { return(FindClassDuring(timeslot, selected) != null); }
/// <summary> /// Check if there is an unavailable timeslot within the given timeslot. /// </summary> public bool UnavailableDuring(Timeslot timeslot) { return(FindUnavailableDuring(timeslot) != null); }
protected override void OnDragOver(DragEventArgs drgevent) { TimeOfWeek time = FindClickTime(PointToClient(new Point(drgevent.X, drgevent.Y))); // outside of table bounds? if (TimeOfWeek.ReferenceEquals(time, null)) { // clear current preview (at edge of timetable) EndPreviewStream(); // cannot drag outside of the actual table drgevent.Effect = DragDropEffects.None; return; } // dragging a class if (drgevent.Data.GetDataPresent(typeof(Session)) || drgevent.Data.GetDataPresent(typeof(Type))) { drgevent.Effect = DragDropEffects.Move; Type dragType; if (drgevent.Data.GetDataPresent(typeof(Session))) { dragType = ((Session)drgevent.Data.GetData(typeof(Session))).Stream.Type; } else { dragType = (Type)drgevent.Data.GetData(typeof(Type)); } Session session = Timetable.From(dragType).FindClassAt(time, false); if (session == null) { EndPreviewStream(); } else { PreviewEquiv(session.Stream); } } // dragging an unavailability else if (drgevent.Data.GetDataPresent(typeof(Unavailability))) { Unavailability dragUnavail = (Unavailability)drgevent.Data.GetData(typeof(Unavailability)); TimeLength offset = new TimeLength(dragUnavail.StartMinute); TimeOfWeek start = time - dragUnavail.Length / 2; start -= offset; start.RoundToNearestHour(); start += offset; HoverUnavail_ = new Timeslot(start.Day, (TimeOfDay)start, (TimeOfDay)start + dragUnavail.Length); if (HoverUnavail_.StartTime < new TimeOfDay(HourStart_, 0) || HoverUnavail_.EndTime > new TimeOfDay(HourEnd_, 0)) { drgevent.Effect = DragDropEffects.None; HoverUnavail_ = null; } else { drgevent.Effect = DragDropEffects.Move; } Invalidate(); } else { base.OnDragOver(drgevent); } }
public Session(Timeslot time, string location, Stream stream) : base(time) { Location_ = location; Stream_ = stream; }
public DialogResult ShowDialog(Timetable timetable, Timeslot timeslot, int earliest, int latest) { return(ShowDialog(timetable, new Unavailability("", timeslot), earliest, latest)); }
/// <summary> /// Check if a given timeslot is free. /// </summary> /// <returns>True if there is nothing on during the timeslot.</returns> public bool FreeDuring(Timeslot timeslot, bool selected) { return(!ClassDuring(timeslot, selected) && !UnavailableDuring(timeslot)); }