public CalendarControl()
 {
     InitializeComponent();
     calendarView.DisplayedOwnersChanged += calendarView_OwnersChanged;
     calendarView.SelectedOwnerChanged += calendarView_OwnersChanged;
     calendarView.SelectedViewChanged += calendarView_SelectedViewChanged;
     ReadOnly = true;
     try
     {
         calendarView.CalendarModel.WorkDays.Add(new WorkDay(DayOfWeek.Saturday));
         WorkTime workStartTime = new WorkTime(5, 0);
         WorkTime workEndTime = new WorkTime(23, 59);
         foreach (WorkDay workDay in calendarView.CalendarModel.WorkDays)
         {
             workDay.WorkStartTime = workStartTime;
             workDay.WorkEndTime = workEndTime;
         }
         Aulas = new List<Aula>();
         List<Facultad> facultades = new Conexion().getFacultades();
         foreach (Facultad f in facultades)
         {
             ColorDef colorDef = new ColorDef(f.Color);
             AppointmentCategoryColor appointmentCategoryColor = new AppointmentCategoryColor(f.Descripcion, Color.Black, f.Color, colorDef);
             calendarView.CategoryColors.Add(appointmentCategoryColor);
             appointmentCategoryColor = new AppointmentCategoryColor(f.Descripcion + "Disabled", Color.Gray, Color.Gray, colorDef);
             calendarView.CategoryColors.Add(appointmentCategoryColor);
         }
     }
     catch { }
 }
示例#2
0
        /// <summary>
        /// Determines if the given time is tagged as a "Work time"
        /// </summary>
        /// <param name="day">Day of week</param>
        /// <param name="time">WorkTime to test</param>
        /// <returns>true if specified "time" is a Work time</returns>
        private bool IsWorkTime(int day, WorkTime time)
        {
            ModelTimeLineViewConnector tlc =
                (ModelTimeLineViewConnector)Connector;

            WorkTime workStartTime = tlc.DayInfo[day].WorkStartTime;
            WorkTime workEndTime = tlc.DayInfo[day].WorkEndTime;

            return (time >= workStartTime && time < workEndTime);
        }
示例#3
0
        /// <summary>
        /// GetSlotState
        /// </summary>
        /// <param name="col"></param>
        /// <returns></returns>
        private eSlotDisplayState GetSlotState(int col)
        {
            eSlotDisplayState state = eSlotDisplayState.None;

            if (DisplayedOwnerKeyIndex == CalendarView.SelectedOwnerIndex)
            {
                if (col >= _SelectedColStart && col < _SelectedColEnd)
                    state |= eSlotDisplayState.Selected;
            }

            DateTime date = StartDate.AddMinutes(col * CalendarView.BaseInterval);
            WorkTime workTime = new WorkTime(date.Hour, date.Minute);

            if (IsWorkTime((int)date.DayOfWeek, workTime) == true)
                state |= eSlotDisplayState.Work;

            return (state);
        }
示例#4
0
 /// <summary>
 /// Determines if the given time is tagged as a "Work time"
 /// </summary>
 /// <param name="time">WorkTime to test</param>
 /// <returns>true if specified "time" is a Work time</returns>
 public bool IsWorkTime(WorkTime time)
 {
     return (time >= WorkStartTime && time < WorkEndTime);
 }
示例#5
0
 /// <summary>
 /// Determines if the given time is tagged as a "Busy time"
 /// </summary>
 /// <param name="time">WorkTime to test</param>
 /// <returns>true if specified "time" is a Busy time</returns>
 public bool IsBusyTime(WorkTime time)
 {
     return ((!BusyStartTime.IsEmpty && !BusyEndTime.IsEmpty) &&
             (time >= BusyStartTime && time < BusyEndTime));
 }
示例#6
0
        /// <summary>
        /// Called when WorkEndTime has changed.
        /// </summary>
        /// <param name="oldValue">Old property value.</param>
        /// <param name="newValue">New property value.</param>
        protected virtual void OnWorkEndTimeChanged(WorkTime oldValue, WorkTime newValue)
        {
            OnPropertyChanged(new PropertyChangedEventArgs("WorkEndTime"));

        }
示例#7
0
        private DateTime GetSlotTime(int dayCol, WorkTime wkTime)
        {
            DateTime time = _DayColumns[dayCol].Date;

            time = time.AddHours(wkTime.Hour);
            time = time.AddMinutes(wkTime.Minute);

            return (time);
        }
示例#8
0
        private int GetWorkTimeSlice(WorkTime wkTime)
        {
            int slice = ((wkTime.Hour * MinutesPerHour) +
                wkTime.Minute) / TimeSlotDuration;

            return (slice - StartSlice);
        }
示例#9
0
        /// <summary>
        /// Draws the DaySlot Text
        /// </summary>
        /// <param name="g"></param>
        /// <param name="dayCol"></param>
        /// <param name="dsaList"></param>
        /// <param name="cRect"></param>
        /// <param name="selected"></param>
        private void DrawDaySlotText(Graphics g,
            int dayCol, IEnumerable<DaySlotAppearance> dsaList, Rectangle cRect, bool selected)
        {
            foreach (DaySlotAppearance dsa in dsaList)
            {
                DateTime startTime = GetSlotTime(dayCol, dsa.StartTime);
                DateTime endTime = GetSlotTime(dayCol, dsa.EndTime);

                DateTime e = endTime.AddMinutes(-1);
                WorkTime wkEnd = new WorkTime(e.Hour, e.Minute);

                int start = GetWorkTimeSlice(dsa.StartTime);
                int end = GetWorkTimeSlice(wkEnd);

                Rectangle r = GetSliceRect(dayCol, start);
                r = Rectangle.Union(r, GetSliceRect(dayCol, end));

                Region rgnSave = g.Clip;
                g.SetClip(cRect, CombineMode.Intersect);

                string text = dsa.Text;

                if (CalendarView.DoRenderDaySlotAppearanceText(g,
                    r, dsa, startTime, endTime, selected, ref text) == false)
                {
                    if (String.IsNullOrEmpty(dsa.Text) == false)
                    {
                        eTextFormat tf = GetTextFormat(dsa.TextAlignment);

                        Font font = dsa.Font ?? Font;

                        Color color = (selected == true)
                                          ? (dsa.SelectedTextColor.IsEmpty ? Color.Black : dsa.SelectedTextColor)
                                          : (dsa.TextColor.IsEmpty ? Color.Black : dsa.TextColor);

                        TextDrawing.DrawString(g, text, font, color, r, tf);
                    }
                }

                g.Clip = rgnSave;
            }
        }
示例#10
0
        /// <summary>
        /// Gets the background content brush
        /// for the given time slice
        /// </summary>
        /// <param name="daySlot"></param>
        /// <param name="col">Column index</param>
        /// <param name="slice">Time slice</param>
        /// <returns>Background brush</returns>
        private Brush GetContentBrush(DaySlot daySlot, int col, int slice)
        {
            int start = (StartSlice + slice) * TimeSlotDuration;

            if (slice < NumberOfActiveSlices)
            {
                if (daySlot.Selected == true)
                    return (SelectedBrush);

                WorkTime wkStart = new
                    WorkTime(start / MinutesPerHour, start % MinutesPerHour);

                if (_DayColumns[col].IsWorkTime(wkStart) == true)
                    return (WorkBrush);

                if (_DayColumns[col].IsBusyTime(wkStart) == true)
                    return (BusyBrush);
            }
            else
            {
                return (AllDayBrush);
            }

            return (OffWorkBrush);
        }
示例#11
0
        /// <summary>
        /// Gets the array of DaySlot information
        /// </summary>
        /// <param name="sliceStart"></param>
        /// <param name="sliceEnd"></param>
        /// <param name="dayStart"></param>
        /// <param name="dayEnd"></param>
        /// <returns>array of DaySlots</returns>
        private DaySlot[,] GetDaySlots(int sliceStart, int sliceEnd, int dayStart, int dayEnd)
        {
            DaySlot[,] daySlots = new DaySlot[dayEnd - dayStart + 1, sliceEnd - sliceStart + 1];

            for (int i = dayStart; i <= dayEnd; i++)
            {
                for (int j = sliceStart; j <= sliceEnd; j++)
                {
                    DaySlot daySlot = new DaySlot();

                    daySlots[i - dayStart, j - sliceStart] = daySlot;

                    daySlot.Bounds = GetSliceRect(i, j);
                    daySlot.Selected = SliceIsSelected(i, j);

                    if (j <= sliceEnd &&
                        CalendarView.HasViewDisplayCustomizations == true)
                    {
                        int start = ((StartSlice + j) * TimeSlotDuration) % 1440;
                        int end = Math.Min(start + TimeSlotDuration, 1439);

                        WorkTime wkStart = new WorkTime(start / MinutesPerHour, start % MinutesPerHour);
                        WorkTime wkEnd = new WorkTime(end / MinutesPerHour, end % MinutesPerHour);

                        daySlot.Appearance = CalendarView.ViewDisplayCustomizations.GetDaySlotAppearance(
                            OwnerKey, _DayColumns[i].Date, wkStart, wkEnd);
                    }
                }
            }

            return (daySlots);
        }
示例#12
0
        private void GetTimeSliceData()
        {
            _LocalStartSlice = 0;
            _LocalNumberOfSlices = (HoursPerDay * MinutesPerHour) / TimeSlotDuration + 1;

            if (CalendarView.ShowOnlyWorkDayHours == true)
            {
                WorkTime startTime = new WorkTime(23, 59);
                WorkTime endTime = new WorkTime(0, 0);

                for (int i = 0; i < NumberOfColumns; i++)
                {
                    DayColumn dc = _DayColumns[i];

                    if (dc.WorkStartTime.IsEmpty == false || dc.WorkEndTime.IsEmpty == false)
                    {
                        if (dc.WorkStartTime < startTime)
                            startTime = dc.WorkStartTime;

                        if (dc.WorkEndTime > endTime)
                            endTime = dc.WorkEndTime;
                    }
                }

                if (endTime > startTime)
                {
                    int startMinutes = (startTime.Hour * MinutesPerHour) + startTime.Minute;
                    int endMinutes = (endTime.Hour * MinutesPerHour) + endTime.Minute;

                    _LocalStartSlice = startMinutes / TimeSlotDuration;
                    _LocalNumberOfSlices = (endMinutes - startMinutes) / TimeSlotDuration + 1;
                }

                if (StartSlice >= 0)
                {
                    int endSlice = _LocalStartSlice + _LocalNumberOfSlices;

                    if (_LocalStartSlice > StartSlice)
                        _LocalStartSlice = StartSlice;

                    if (StartSlice + NumberOfActiveSlices > endSlice)
                        endSlice = StartSlice + NumberOfActiveSlices;

                    _LocalNumberOfSlices = endSlice - _LocalStartSlice;
                }
            }

            StartSlice = _LocalStartSlice;
            NumberOfSlices = _LocalNumberOfSlices;
            
            TimeSliceHeight = (float)ViewRect.Height / NumberOfActiveSlices;
        }
示例#13
0
 /// <summary>
 /// Initializes a new instance of the WorkDay class.
 /// </summary>
 /// <param name="dayOfWeek"></param>
 /// <param name="workStartTime"></param>
 /// <param name="workEndTime"></param>
 public WorkDay(DayOfWeek dayOfWeek, WorkTime workStartTime, WorkTime workEndTime)
 {
     _DayOfWeek = dayOfWeek;
     _WorkStartTime = workStartTime;
     _WorkEndTime = workEndTime;
 }