示例#1
0
        protected void DrawNonWorkHours(PaintEventArgs e, Rectangle rect, DateTime time)
        {
            if (m_Renderer.Theme.HasAppColor(UITheme.AppColor.Weekends) && WeekendDays.Contains(time.DayOfWeek))
            {
                var weekendColor = m_Renderer.Theme.GetAppDrawingColor(UITheme.AppColor.Weekends, 128);

                // If this is also 'today' then convert to gray so it doesn't
                // impose too much when the today colour is laid on top
                if (WantDrawToday(time))
                {
                    weekendColor = DrawingColor.ToGray(weekendColor);
                }

                using (var brush = new SolidBrush(weekendColor))
                    e.Graphics.FillRectangle(brush, rect);
            }
            else if (m_Renderer.Theme.HasAppColor(UITheme.AppColor.NonWorkingHours))
            {
                var nonWorkColor = m_Renderer.Theme.GetAppDrawingColor(UITheme.AppColor.NonWorkingHours, 128);

                // If this is also 'today' then convert to gray so it doesn't
                // impose too much when the today colour is laid on top
                if (WantDrawToday(time))
                {
                    nonWorkColor = DrawingColor.ToGray(nonWorkColor);
                }

                using (SolidBrush brush = new SolidBrush(nonWorkColor))
                {
                    DrawNonWorkHours(e, new HourMin(0, 0), WorkStart, rect, brush);
                    DrawNonWorkHours(e, LunchStart, LunchEnd, rect, brush);
                    DrawNonWorkHours(e, WorkEnd, new HourMin(24, 0), rect, brush);
                }
            }
        }
示例#2
0
        /// <summary>
        /// If date is on the weekend, gets the Friday starting that weekend.
        /// Otherwise gets the NEXT Friday.
        /// </summary>
        /// <param name="date">Selected Date.</param>
        /// <returns></returns>
        public static DateTime FridayOf(DateTime date)
        {
            if (date.DayOfWeek != DayOfWeek.Friday && WeekendDays.Contains(date.DayOfWeek))
            {
                for (DateTime day = date; day.DayOfWeek != DayOfWeek.Thursday; day = day.AddDays(-1))
                {
                    if (day.DayOfWeek == DayOfWeek.Friday)
                    {
                        return(day);
                    }
                }
            }
            else if (date.DayOfWeek != DayOfWeek.Friday)
            {
                for (DateTime day = date; day.DayOfWeek != DayOfWeek.Saturday; day = day.AddDays(1))
                {
                    if (day.DayOfWeek == DayOfWeek.Friday)
                    {
                        return(day);
                    }
                }
            }

            return(date);
        }
示例#3
0
 public static bool IsWeekendDay(this EDaysOfWeekExt dayOfWeek)
 {
     return(WeekendDays.Contains(dayOfWeek));
 }