#if FRAMEWORK20 using System; using System.Collections.Generic; using System.Drawing; using DevComponents.Schedule.Model; namespace DevComponents.DotNetBar.Schedule { public class DayColumn { #region Consts public const int NumberOfTimeSlices = 48; #endregion #region Private variables private Rectangle _Bounds; // Slot bounding rectangle private DateTime _Date; // Column date private float _TimeSliceHeight; // TimeSlice height private WorkTime _BusyStartTime; // Busy time private WorkTime _BusyEndTime; private WorkTime _WorkStartTime; // Work time private WorkTime _WorkEndTime; private List // Column CalendarItems _CalendarItems = new List(); private bool _NeedRecalcLayout = true; #endregion /// /// Constructor /// /// Slice height public DayColumn(float timeSliceHeight) { _TimeSliceHeight = timeSliceHeight; } #region Public properties #region BoundingRect /// /// Gets and sets the week bounding Rectangle /// public Rectangle Bounds { get { return (_Bounds); } set { if (_Bounds.Equals(value) == false) { int yOffset = value.Y - _Bounds.Y; _Bounds = value; if (yOffset != 0) OffsetItemRects(yOffset); } } } /// /// Offsets the bounding rectangles for the /// DayColumn's non-extended appointments /// /// Amount to offset private void OffsetItemRects(int yOffset) { for (int i = 0; i < _CalendarItems.Count; i++) { Rectangle r = _CalendarItems[i].Bounds; r.Y += yOffset; _CalendarItems[i].Bounds = r; } } #endregion #region Date /// /// Gets and sets the column date /// public DateTime Date { get { return (_Date); } set { _Date = value; } } #endregion #region TimeSliceHeight /// /// Gets and sets the TimeSlice height /// public float TimeSliceHeight { get { return (_TimeSliceHeight); } set { _TimeSliceHeight = value; } } #endregion #region WorkTime properties /// /// Gets and sets the busy time start /// public WorkTime BusyStartTime { get { return (_BusyStartTime); } set { _BusyStartTime = value; } } /// /// Gets and sets the busy time end /// public WorkTime BusyEndTime { get { return (_BusyEndTime); } set { _BusyEndTime = value; } } /// /// Gets and sets the work time start /// public WorkTime WorkStartTime { get { return (_WorkStartTime); } set { _WorkStartTime = value; } } /// /// Gets and sets the work time end /// public WorkTime WorkEndTime { get { return (_WorkEndTime); } set { _WorkEndTime = value; } } #endregion #region CalendarItems /// /// Gets the column CalendarItems list /// public List CalendarItems { get { return (_CalendarItems); } } #endregion #region NeedRecalcLayout public bool NeedRecalcLayout { get { return (_NeedRecalcLayout); } set { _NeedRecalcLayout = value; } } #endregion #endregion #region Public methods /// /// Determines if the given time is tagged as a "Busy time" /// /// WorkTime to test /// true if specified "time" is a Busy time public bool IsBusyTime(WorkTime time) { return ((!BusyStartTime.IsEmpty && !BusyEndTime.IsEmpty) && (time >= BusyStartTime && time < BusyEndTime)); } /// /// Determines if the given time is tagged as a "Work time" /// /// WorkTime to test /// true if specified "time" is a Work time public bool IsWorkTime(WorkTime time) { if (WorkStartTime <= WorkEndTime) return (time >= WorkStartTime && time < WorkEndTime); return (time < WorkEndTime || time >= WorkStartTime); } #endregion } } #endif