public static bool IntersectsWith(this IDateSpan source, IDateSpan other)
 {
     if ((source == null) || (other == null))
     {
         return false;
     }
     return (((other.Start <= source.Start) && (source.Start < other.End)) || ((source.Start <= other.Start) && (other.Start < source.End)));
 }
Esempio n. 2
0
        private void SetRangeOfWeeks()
        {
            IDateSpan range = ScheduleView.VisibleRange;

            _firstWeek  = CreateSevenDaysWeek(range.Start, true);
            _secondWeek = CreateSevenDaysWeek(_firstWeek.End, false);
            _thirdWeek  = CreateSevenDaysWeek(_secondWeek.End, false);
            _fourthWeek = CreateSevenDaysWeek(_thirdWeek.End, false);
            _fifthWeek  = CreateSevenDaysWeek(_fourthWeek.End, false);
        }
 private static IEnumerable <AppointmentSlot> CreateAppointmentSlots(
     TimeSlotCollectionView timeSlots, IDateSpan intersection, Func <TimeSlot, AppointmentSlot> slotCreator)
 {
     return
         (from g in timeSlots.Groups
          let intersected =
              from slot in g.TimeSlots
              where intersection.IntersectsWith(slot)
              select slot
              where intersected.Count() > 0
              select slotCreator(new TimeSlotGroup(intersected)));
 }
		private void GenerateAppointments(IDateSpan dateSpan)
		{
			ObservableCollection<Appointment> newSource = new ObservableCollection<Appointment>();

			newSource.AddRange(
				from i in Enumerable.Range(0, (dateSpan.End - dateSpan.Start).Days * 24)
				select new Appointment()
				{
					Subject = "Appointment" + i + " " + dateSpan.Start.AddHours(i).ToShortDateString(),
					Start = dateSpan.Start.AddHours(i),
					End = dateSpan.Start.AddHours(i + 1),
				});

			this.Appointments = newSource;
		}
Esempio n. 5
0
 public ScheduleRuleSpan(IDateSpan[] dates, ScheduleRule[] rules)
 {
     Dates = dates;
     Rules = rules;
 }
Esempio n. 6
0
 public DateSpan(IDateSpan other)
 {
     this.start = other.Start;
     this.end   = other.End;
 }
 /// <summary>
 /// Validates the specified date span.
 /// </summary>
 /// <param name="dateSpan">The date span.</param>
 /// <returns></returns>
 public static bool Validate(this IDateSpan dateSpan)
 {
     return((dateSpan.Start != DateTime.MinValue) &&
            (dateSpan.End != DateTime.MaxValue) &&
            dateSpan.Start <= dateSpan.End);
 }
 /// <summary>
 /// Subtracts the interval.
 /// </summary>
 /// <param name="dateSpan">The date span.</param>
 /// <param name="dateTimeInterval">The date time interval.</param>
 /// <returns></returns>
 public static TimeSlot SubtractInterval(this IDateSpan dateSpan, DateTimeInterval dateTimeInterval)
 {
     return(new TimeSlot(
                dateSpan.Start.AddDays(-dateTimeInterval.Days).AddMonths(-dateTimeInterval.Months),
                dateSpan.End.AddDays(-dateTimeInterval.Days).AddMonths(-dateTimeInterval.Months)));
 }
 /// <summary>
 /// <c>Intersectses</c> the with.
 /// </summary>
 /// <param name="source">The source.</param>
 /// <param name="other">The other.</param>
 /// <returns></returns>
 public static bool IntersectsWith(this IDateSpan source, IDateSpan other)
 {
     return((other.Start <= source.Start && source.Start < other.End) ||
            (source.Start <= other.Start && other.Start < source.End));
 }
Esempio n. 10
0
 /// <summary>
 /// Gets the duration of the specified date span.
 /// </summary>
 /// <param name="dateSpan">The date span.</param>
 /// <returns>Duration of the date span as devision of end and start.</returns>
 public static TimeSpan Duration(this IDateSpan dateSpan)
 {
     return(dateSpan.End - dateSpan.Start);
 }
Esempio n. 11
0
 /// <summary>
 /// Determines whether <see cref="DateSpan"/> contains <see cref="DateTime"/>.
 /// </summary>
 /// <param name="source">The source.</param>
 /// <param name="date">The date.</param>
 /// <returns>
 ///     <c>true</c> if contains date; otherwise, <c>false</c>.
 /// </returns>
 public static bool Contains(this IDateSpan source, DateTime date)
 {
     return(source.Start <= date && date < source.End);
 }
Esempio n. 12
0
 /// <summary>
 /// Determines whether <see cref="DateSpan"/> contains another <see cref="DateSpan"/>.
 /// </summary>
 /// <param name="source">The source.</param>
 /// <param name="other">The other.</param>
 /// <returns>
 ///     <c>true</c> if contains another <see cref="DateSpan"/>; otherwise, <c>false</c>.
 /// </returns>
 public static bool Contains(this IDateSpan source, IDateSpan other)
 {
     return(source.Start <= other.Start && source.End >= other.End);
 }
 public static bool ContainsPartialInclusive(this IDateSpan source, IDateSpan other)
 {
     return ContainsInclusive(source, other.Start) || ContainsInclusive(source, other.End);
 }
 public static bool ContainsInclusive(this IDateSpan source, IDateSpan other)
 {
     return ((source.Start <= other.Start) && (source.End >= other.End));
 }
 public static bool Contains(this IDateSpan source, IDateSpan other)
 {
     return ((source.Start < other.Start) && (source.End > other.End));
 }