コード例 #1
0
 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)));
 }
コード例 #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);
        }
コード例 #3
0
 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)));
 }
コード例 #4
0
		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;
		}
コード例 #5
0
ファイル: ScheduleRuleSpan.cs プロジェクト: djMax/AlienForce
 public ScheduleRuleSpan(IDateSpan[] dates, ScheduleRule[] rules)
 {
     Dates = dates;
     Rules = rules;
 }
コード例 #6
0
 public DateSpan(IDateSpan other)
 {
     this.start = other.Start;
     this.end   = other.End;
 }
コード例 #7
0
 /// <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);
 }
コード例 #8
0
 /// <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)));
 }
コード例 #9
0
 /// <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));
 }
コード例 #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);
 }
コード例 #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);
 }
コード例 #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);
 }
コード例 #13
0
 public static bool ContainsPartialInclusive(this IDateSpan source, IDateSpan other)
 {
     return ContainsInclusive(source, other.Start) || ContainsInclusive(source, other.End);
 }
コード例 #14
0
 public static bool ContainsInclusive(this IDateSpan source, IDateSpan other)
 {
     return ((source.Start <= other.Start) && (source.End >= other.End));
 }
コード例 #15
0
 public static bool Contains(this IDateSpan source, IDateSpan other)
 {
     return ((source.Start < other.Start) && (source.End > other.End));
 }