virtual public bool shiftEvent(TimeSpan ChangeInTime, SubCalendarEvent[] UpdatedSubCalEvents) { TimeLine UpdatedTimeLine = new TimeLine(this.Start+ChangeInTime,this.End+ChangeInTime); foreach (SubCalendarEvent eachSubCalendarEvent in UpdatedSubCalEvents) { if(!(UpdatedTimeLine.IsTimeLineWithin(eachSubCalendarEvent.RangeTimeLine))) { return false; } } StartDateTime = StartDateTime + ChangeInTime; EndDateTime = EndDateTime + ChangeInTime; ArrayOfSubEvents = UpdatedSubCalEvents.ToArray(); return true; }
public List<TimeLine> getOnlyPertinentTimeFrame(TimeLine[] ArraytOfFreeSpots, TimeLine myTimeLine) { /* * Name: Jerome Biotidara * Description: Function only takes a TImeLine and Array Of TimeLine FreeSpots. It returns a List Of TimeLine In whcih each elements exist within the range of TimeLine */ List<TimeLine> PertinentTimeLine = new List<TimeLine>(); List<TimeLine> OutLiers = new List<TimeLine>(); foreach (TimeLine MyFreeTimeLine in ArraytOfFreeSpots) { if (myTimeLine.IsTimeLineWithin(MyFreeTimeLine)) { PertinentTimeLine.Add(MyFreeTimeLine); } else { OutLiers.Add(MyFreeTimeLine); } } foreach (TimeLine Outlier in OutLiers)//this can be embedded in the preceeding foreach loop above in the else branch { if (myTimeLine.IsDateTimeWithin(Outlier.Start)) { PertinentTimeLine.Add(new TimeLine(Outlier.Start, myTimeLine.End)); } else { if (myTimeLine.IsDateTimeWithin(Outlier.End)) { PertinentTimeLine.Add(new TimeLine(myTimeLine.Start, Outlier.End)); } else { if (Outlier.IsTimeLineWithin(myTimeLine)) { PertinentTimeLine.Add(Outlier); } } } } return PertinentTimeLine; //return new List<TimeLine>(); }
public List<BusyTimeLine> getBusyTimeLineWithinSlots(TimeLine MyTimeLineRange) { List<BusyTimeLine> ActiveSlots = new List<BusyTimeLine>(); foreach (BusyTimeLine MyBusyTimeline in ActiveTimeSlots) { if (MyTimeLineRange.IsTimeLineWithin(MyBusyTimeline)) { ActiveSlots.Add(MyBusyTimeline); } } return ActiveSlots; }
public List<BusyTimeLine> getBusyTimeLineWithinSlots(DateTime StartTime, DateTime EndTime) { TimeLine TempTimeLine = new TimeLine(StartTime,EndTime); List <BusyTimeLine> ActiveSlots = new List<BusyTimeLine>(); foreach(BusyTimeLine MyBusyTimeline in ActiveTimeSlots) { if(TempTimeLine.IsTimeLineWithin(MyBusyTimeline)) { ActiveSlots.Add(MyBusyTimeline); } } return ActiveSlots; }
List<BusyTimeLine>[] getEdgeElements(TimeLine MyRangeOfTimeLine, BusyTimeLine[] ArrayOfTInterferringime) { List<BusyTimeLine> ListOfEdgeElements = new List<BusyTimeLine>(); List<BusyTimeLine> StartEdge = new List<BusyTimeLine>(); List<BusyTimeLine> EndEdge = new List<BusyTimeLine>(); int i=0; for (; i < ArrayOfTInterferringime.Length; i++) { if (!MyRangeOfTimeLine.IsTimeLineWithin(ArrayOfTInterferringime[i])) { ListOfEdgeElements.Add(ArrayOfTInterferringime[i]); } } i = 0; for (; i < ListOfEdgeElements.Count; i++) { if (ListOfEdgeElements[i].Start < MyRangeOfTimeLine.Start) { StartEdge.Add(ListOfEdgeElements[i]); } else { EndEdge.Add(ListOfEdgeElements[i]); } } List<BusyTimeLine>[] StartAndEndEdgeList = new List<BusyTimeLine>[2]; StartAndEndEdgeList[0] = StartEdge; StartAndEndEdgeList[1] = EndEdge; return StartAndEndEdgeList; }
virtual public bool shiftEvent(TimeSpan ChangeInTime, SubCalendarEvent[] UpdatedSubCalEvents) { TimeLine UpdatedTimeLine = new TimeLine(this.Start+ChangeInTime,this.End+ChangeInTime); bool retValue = true; foreach (SubCalendarEvent eachSubCalendarEvent in UpdatedSubCalEvents)//test if the updated locations for the subevents fall within the shifted timeline { if(!(UpdatedTimeLine.IsTimeLineWithin(eachSubCalendarEvent.RangeTimeLine))) { return false; } } foreach (SubCalendarEvent eachSubCalendarEvent in UpdatedSubCalEvents) { if (!updateSubEvent(eachSubCalendarEvent.SubEvent_ID, eachSubCalendarEvent)) { retValue = false;//there was some error updating the subevent } } StartDateTime = StartDateTime + ChangeInTime; EndDateTime = EndDateTime + ChangeInTime; return retValue; }