本文整理汇总了C#中My24HourTimerWPF.TimeLine.InterferringTimeLine方法的典型用法代码示例。如果您正苦于以下问题:C# TimeLine.InterferringTimeLine方法的具体用法?C# TimeLine.InterferringTimeLine怎么用?C# TimeLine.InterferringTimeLine使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类My24HourTimerWPF.TimeLine
的用法示例。
在下文中一共展示了TimeLine.InterferringTimeLine方法的5个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: getInterferringSubEvents
private SubCalendarEvent[] getInterferringSubEvents(TimeLine EventRange, List<CalendarEvent> NonCommitedCalendarEvemts=null)
{
//CalendarEvent MyCalendarEvent
List<SubCalendarEvent> MyArrayOfInterferringSubCalendarEvents = new List<SubCalendarEvent>(0);//List that stores the InterFerring List
int i = 0;
int lengthOfCalendarSubEvent = 0;
foreach (KeyValuePair<string, CalendarEvent> MyCalendarEventDictionaryEntry in AllEventDictionary)
{
i = 0;
if (MyCalendarEventDictionaryEntry.Value.RepetitionStatus)
{
lengthOfCalendarSubEvent = MyCalendarEventDictionaryEntry.Value.AllRepeatSubCalendarEvents.Length;
SubCalendarEvent[] ArrayOfSubcalendarEventsFromRepeatingEvents = MyCalendarEventDictionaryEntry.Value.AllRepeatSubCalendarEvents;
for (i = 0; i < lengthOfCalendarSubEvent; i++)
{
//if ((EventRange.IsDateTimeWithin(ArrayOfSubcalendarEventsFromRepeatingEvents[i].Start)) || (EventRange.IsDateTimeWithin(ArrayOfSubcalendarEventsFromRepeatingEvents[i].End)))
if (EventRange.InterferringTimeLine(ArrayOfSubcalendarEventsFromRepeatingEvents[i].RangeTimeLine) != null)
{
MyArrayOfInterferringSubCalendarEvents.Add(ArrayOfSubcalendarEventsFromRepeatingEvents[i]);
}
}
}
else
{
lengthOfCalendarSubEvent = MyCalendarEventDictionaryEntry.Value.AllEvents.Length;
for (i = 0; i < lengthOfCalendarSubEvent; i++)
{
//if ((EventRange.IsDateTimeWithin(MyCalendarEventDictionaryEntry.Value.AllEvents[i].Start)) || (EventRange.IsDateTimeWithin(MyCalendarEventDictionaryEntry.Value.AllEvents[i].End)))
if (EventRange.InterferringTimeLine(MyCalendarEventDictionaryEntry.Value.AllEvents[i].RangeTimeLine) != null)
{
MyArrayOfInterferringSubCalendarEvents.Add(MyCalendarEventDictionaryEntry.Value.AllEvents[i]);
}
}
}
}
if (NonCommitedCalendarEvemts != null)
{
foreach ( CalendarEvent eachCalendarEvent in NonCommitedCalendarEvemts)
{
i = 0;
if (eachCalendarEvent.RepetitionStatus)
{
lengthOfCalendarSubEvent = eachCalendarEvent.AllRepeatSubCalendarEvents.Length;
SubCalendarEvent[] ArrayOfSubcalendarEventsFromRepeatingEvents = eachCalendarEvent.AllRepeatSubCalendarEvents;
for (i = 0; i < lengthOfCalendarSubEvent; i++)
{
//if ((EventRange.IsDateTimeWithin(ArrayOfSubcalendarEventsFromRepeatingEvents[i].Start)) || (EventRange.IsDateTimeWithin(ArrayOfSubcalendarEventsFromRepeatingEvents[i].End)))
if (EventRange.InterferringTimeLine(ArrayOfSubcalendarEventsFromRepeatingEvents[i].RangeTimeLine) != null)
{
MyArrayOfInterferringSubCalendarEvents.Add(ArrayOfSubcalendarEventsFromRepeatingEvents[i]);
}
}
}
else
{
lengthOfCalendarSubEvent = eachCalendarEvent.AllEvents.Length;
for (i = 0; i < lengthOfCalendarSubEvent; i++)
{
//if ((EventRange.IsDateTimeWithin(MyCalendarEventDictionaryEntry.Value.AllEvents[i].Start)) || (EventRange.IsDateTimeWithin(MyCalendarEventDictionaryEntry.Value.AllEvents[i].End)))
if (EventRange.InterferringTimeLine(eachCalendarEvent.AllEvents[i].RangeTimeLine) != null)
{
MyArrayOfInterferringSubCalendarEvents.Add(eachCalendarEvent.AllEvents[i]);
}
}
}
}
}
return MyArrayOfInterferringSubCalendarEvents.ToArray();
}
示例2: stitchRestrictedSubCalendarEvent
List<mTuple<bool, SubCalendarEvent>> stitchRestrictedSubCalendarEvent(List<mTuple<bool, SubCalendarEvent>> Arg1, TimeLine RestrictingTimeLine)
{
/*
* Description: function tries to stitich Restricted SubCalEvents. It starts with the most restricted within timeline as the first node. This first node pins itself to the right It stitches the tree towards the right of the node. Makes a recursive call to stitchRestrictedSubCalendarEvent. pin the returned List and itself to the right hand side then tries to stitck the left hand side
*/
List<mTuple<bool, SubCalendarEvent>> retValue = Arg1.ToList();
TimeSpan SumOfAllSubCalEvent = Utility.SumOfActiveDuration(Utility.mTupleToSubCalEvents(Arg1));
if (RestrictingTimeLine.TimelineSpan <= SumOfAllSubCalEvent)
{
;
}
List<mTuple<bool, SubCalendarEvent>> CopyOfAllList = Arg1.ToList();
if (retValue.Count < 1)//if arg1 is empty return the list
{
return retValue;
}
List<SubCalendarEvent> AllSubCalEvents = Utility.mTupleToSubCalEvents(Arg1);
List<mTuple<TimeLine, SubCalendarEvent>> AvaialableTimeSpan = new List<mTuple<TimeLine, SubCalendarEvent>>();
int indexOfSmallest = -2222;
int i=0;
TimeLine InterferringTimeLine = RestrictingTimeLine.CreateCopy();
TimeSpan SmallestAssignedTimeSpan = new TimeSpan(3650, 0, 0, 0);//sets the smallest TimeSpan To 10 years
DateTime SmallestDateTime = new DateTime(3000, 12, 31);
/*if (SmallestAssignedTimeSpan < ZeroTimeSpan)
{
SmallestAssignedTimeSpan=
}*/
foreach (SubCalendarEvent eachSubCalendarEvent in AllSubCalEvents)//gets the feasible timeLine foreach SubCalendarEvent
{
InterferringTimeLine = RestrictingTimeLine.InterferringTimeLine(eachSubCalendarEvent.getCalendarEventRange);
if ((InterferringTimeLine != null)&&(InterferringTimeLine.TimelineSpan>=eachSubCalendarEvent.ActiveDuration))
{
AvaialableTimeSpan.Add(new mTuple<TimeLine, SubCalendarEvent>(InterferringTimeLine, eachSubCalendarEvent));
TimeSpan CurrentRealignedTimeSpan = InterferringTimeLine.TimelineSpan - eachSubCalendarEvent.ActiveDuration;
if (CurrentRealignedTimeSpan <= ZeroTimeSpan)
{
;
}
if ((CurrentRealignedTimeSpan <= SmallestAssignedTimeSpan))//Checks if the remaining timeSpan is less than currently smallest fittable remaining space
{
if (AllSubCalEvents[i].getCalendarEventRange.End < SmallestDateTime)
{
indexOfSmallest = i;
SmallestAssignedTimeSpan = CurrentRealignedTimeSpan;
SmallestDateTime=AllSubCalEvents[indexOfSmallest].getCalendarEventRange.End;
}
}
}
i++;
}
//Build Strict Towards right of the tree
if (AvaialableTimeSpan.Count > 0)
{
int InitialSmallest = indexOfSmallest;
indexOfSmallest = AvaialableTimeSpan.Select(obj => obj.Item2).ToList().IndexOf(AllSubCalEvents[indexOfSmallest]);
AvaialableTimeSpan[indexOfSmallest].Item2.PinSubEventsToStart(RestrictingTimeLine);
mTuple<bool, SubCalendarEvent> PivotNode = CopyOfAllList.Where(obj => (obj.Item2 == AvaialableTimeSpan[indexOfSmallest].Item2)).ToList()[0];
DateTime StartTimeOfRightTree = PivotNode.Item2.End;
DateTime EndTimeOfRightTree = RestrictingTimeLine.End;
TimeLine RightTimeLine = new TimeLine(StartTimeOfRightTree, EndTimeOfRightTree);
CopyOfAllList.Remove(PivotNode);
Tuple<SubCalendarEvent, SubCalendarEvent> BoundaryElement = new Tuple<SubCalendarEvent,SubCalendarEvent>(null,PivotNode.Item2);
Dictionary<TimeSpan, Dictionary<string, mTuple<bool, SubCalendarEvent>>> PossibleEntries_Cpy= new Dictionary<TimeSpan,Dictionary<string,mTuple<bool,SubCalendarEvent>>>();
foreach(mTuple<bool, SubCalendarEvent> eachmtuple in CopyOfAllList)
{
if(PossibleEntries_Cpy.ContainsKey(eachmtuple.Item2.RangeSpan))
{
PossibleEntries_Cpy[eachmtuple.Item2.RangeSpan].Add(eachmtuple.Item2.ID,eachmtuple);
}
else
{
PossibleEntries_Cpy.Add(eachmtuple.Item2.RangeSpan, new Dictionary<string,mTuple<bool,SubCalendarEvent>>());
PossibleEntries_Cpy[eachmtuple.Item2.RangeSpan].Add(eachmtuple.Item2.ID,eachmtuple);
}
}
TimeLine RangeForSnugElements = new TimeLine(RestrictingTimeLine.Start, PivotNode.Item2.Start);
List<SubCalendarEvent> OptimizedForLeft = OptimizeArrangeOfSubCalEvent(RangeForSnugElements, BoundaryElement, new List<mTuple<int, TimeSpanWithStringID>>(), PossibleEntries_Cpy, 0);
//OptimizedForLeft = new List<SubCalendarEvent>();
//.........这里部分代码省略.........
示例3: InterferringTimeLine
public TimeLine InterferringTimeLine(TimeLine PossibleTimeLine)
{
DateTime InterferringStarTime;
DateTime InterferringEndTime;
if ((this.Start == PossibleTimeLine.Start) && (this.End == PossibleTimeLine.End))//checks if both "this and "PossibleTimeLine" are within the same range
{
return this.CreateCopy();
}
if (this.doesTimeLineInterfere(PossibleTimeLine))
{
InterferringStarTime = PossibleTimeLine.Start;
if (this.Start > PossibleTimeLine.Start)
{
InterferringStarTime = this.Start;
}
InterferringEndTime = this.End;
if (this.End > PossibleTimeLine.End)
{
InterferringEndTime = PossibleTimeLine.End;
}
return new TimeLine(InterferringStarTime, InterferringEndTime);
}
else
{
if (PossibleTimeLine.doesTimeLineInterfere(this))
return PossibleTimeLine.InterferringTimeLine(this);//checks if PossibleTimeLine is the same as or bigger than "this" timeline
}
return null;
}
示例4: getInterferringSubEvents
private SubCalendarEvent[] getInterferringSubEvents(TimeLine EventRange, List<CalendarEvent> NonCommitedCalendarEvemts = null)
{
#if enableMultithreading
ConcurrentBag<SubCalendarEvent> MyArrayOfInterferringSubCalendarEvents = new ConcurrentBag<SubCalendarEvent>();//List that stores the InterFerring List
int lengthOfCalendarSubEvent = 0;
Parallel.ForEach(AllEventDictionary, MyCalendarEventDictionaryEntry =>
{
int i = 0;
if (MyCalendarEventDictionaryEntry.Value.RepetitionStatus)
{
SubCalendarEvent[] ArrayOfSubcalendarEventsFromRepeatingEvents = MyCalendarEventDictionaryEntry.Value.AllActiveRepeatSubCalendarEvents.Where(obj => obj != null).ToArray();//hack alert you should be able to remove the LINQ test for null
lengthOfCalendarSubEvent = ArrayOfSubcalendarEventsFromRepeatingEvents.Length;
Parallel.ForEach(MyCalendarEventDictionaryEntry.Value.AllActiveRepeatSubCalendarEvents.Where(obj => obj != null).Where(obj => EventRange.InterferringTimeLine(obj.RangeTimeLine) != null), EacSubCal =>
{
MyArrayOfInterferringSubCalendarEvents.Add(EacSubCal);
}
);
}
else
{
SubCalendarEvent[] ArrayOfSubcalendarEventsFromNonRepeatingEvents = MyCalendarEventDictionaryEntry.Value.AllActiveSubEvents.Where(obj => obj != null).ToArray();//hack alert you should be able to remove the LINQ test for null
lengthOfCalendarSubEvent = ArrayOfSubcalendarEventsFromNonRepeatingEvents.Length;
Parallel.ForEach(MyCalendarEventDictionaryEntry.Value.AllActiveSubEvents.Where(obj => obj != null).Where(obj => EventRange.InterferringTimeLine(obj.RangeTimeLine) != null), EacSubCal =>
{
MyArrayOfInterferringSubCalendarEvents.Add(EacSubCal);
}
);
}
}
);
if (NonCommitedCalendarEvemts != null)
{
foreach (CalendarEvent eachCalendarEvent in NonCommitedCalendarEvemts)
{
int i = 0;
if (eachCalendarEvent.RepetitionStatus)
{
lengthOfCalendarSubEvent = eachCalendarEvent.AllActiveRepeatSubCalendarEvents.Length;
SubCalendarEvent[] ArrayOfSubcalendarEventsFromRepeatingEvents = eachCalendarEvent.AllActiveRepeatSubCalendarEvents;
Parallel.ForEach(eachCalendarEvent.AllActiveRepeatSubCalendarEvents.Where(obj => obj != null).Where(obj => EventRange.InterferringTimeLine(obj.RangeTimeLine) != null), EacSubCal =>
{
MyArrayOfInterferringSubCalendarEvents.Add(EacSubCal);
}
);
/*
for (i = 0; i < lengthOfCalendarSubEvent; i++)
{
//if ((EventRange.IsDateTimeWithin(ArrayOfSubcalendarEventsFromRepeatingEvents[i].Start)) || (EventRange.IsDateTimeWithin(ArrayOfSubcalendarEventsFromRepeatingEvents[i].End)))
if (EventRange.InterferringTimeLine(ArrayOfSubcalendarEventsFromRepeatingEvents[i].RangeTimeLine) != null)
{
MyArrayOfInterferringSubCalendarEvents.Add(ArrayOfSubcalendarEventsFromRepeatingEvents[i]);
}
}*/
}
else
{
SubCalendarEvent[] ArrayOfSubcalendarEventsFromNonRepeatingEvents = eachCalendarEvent.AllActiveSubEvents.Where(obj => obj != null).ToArray();//hack alert you should be able to remove the LINQ test for null
lengthOfCalendarSubEvent = ArrayOfSubcalendarEventsFromNonRepeatingEvents.Length;
Parallel.ForEach(eachCalendarEvent.AllActiveSubEvents.Where(obj => obj != null).Where(obj => EventRange.InterferringTimeLine(obj.RangeTimeLine) != null), EacSubCal =>
{
MyArrayOfInterferringSubCalendarEvents.Add(EacSubCal);
}
);
/*for (i = 0; i < lengthOfCalendarSubEvent; i++)
{
//if ((EventRange.IsDateTimeWithin(MyCalendarEventDictionaryEntry.Value.AllEvents[i].Start)) || (EventRange.IsDateTimeWithin(MyCalendarEventDictionaryEntry.Value.AllEvents[i].End)))
//if (MyCalendarEventDictionaryEntry.Value.AllEvents[i]!=null)
{
if (EventRange.InterferringTimeLine(ArrayOfSubcalendarEventsFromNonRepeatingEvents[i].RangeTimeLine) != null)
{
MyArrayOfInterferringSubCalendarEvents.Add(ArrayOfSubcalendarEventsFromNonRepeatingEvents[i]);
}
}
}*/
}
}
}
return MyArrayOfInterferringSubCalendarEvents.ToArray();
//.........这里部分代码省略.........
示例5: PlaceSubCalEventInLowestCostPosition
List<SubCalendarEvent> PlaceSubCalEventInLowestCostPosition(TimeLine MyLimitingTimeLine, SubCalendarEvent mySubcalevent, List<SubCalendarEvent> OptimizedArrangementOfEvent)
{
/**Hack Solution Start, this just assumes all events are right next to each other and appends mySubcalevetn to the end. It also shifts this sub cal event to represent this shift **/
DateTime RelativeStartTime = MyLimitingTimeLine.Start + Utility.SumOfActiveDuration(OptimizedArrangementOfEvent);
TimeLine encasingTimeLine = MyLimitingTimeLine.InterferringTimeLine(mySubcalevent.getCalendarEventRange);
IEnumerable<SubCalendarEvent> Interferringevents = getInterferringSubEvents(encasingTimeLine, OptimizedArrangementOfEvent);
List<SubCalendarEvent> ListSofar = Interferringevents.ToList();
List<List<SubCalendarEvent>> AllPertinentList = new List<List<SubCalendarEvent>>();
List<SubCalendarEvent> retValue = OptimizedArrangementOfEvent.ToList();
retValue.Add(mySubcalevent);
#if EnableRestrictedLocationOptimization
int NumberOfLists = ListSofar.Count;
int LastInt = 0;
List<SubCalendarEvent> currList;
if (ListSofar.Count > 0)
{
ListSofar.RemoveAt(0);
IEnumerable<int> AllValidIndexes = ListSofar.Select(obj => OptimizedArrangementOfEvent.IndexOf(obj));
foreach (int eachInt in AllValidIndexes)
{
currList = OptimizedArrangementOfEvent.ToList();
currList.Insert(eachInt, mySubcalevent);
AllPertinentList.Add(currList);
LastInt = eachInt;
}
currList = OptimizedArrangementOfEvent.ToList();
currList.Insert(LastInt + 1, mySubcalevent);
AllPertinentList.Add(currList);
List<List<SubCalendarEvent>> ListThatWorks = new List<List<SubCalendarEvent>>();
foreach (List<SubCalendarEvent> eachList in AllPertinentList)
{
if (Utility.PinSubEventsToStart(eachList, MyLimitingTimeLine))
{
#if createCopyOfImplementation
List<SubCalendarEvent> eachListCpy = eachList.Select(obj => obj.createCopy()).ToList();
ListThatWorks.Add(eachListCpy);
#else
ListThatWorks.Add(eachList);
#endif
}
}
double lowestSofar = double.MaxValue;
foreach (List<SubCalendarEvent> eachList in ListThatWorks)
{
double currDistance = Utility.calculateDistance(eachList.ToList(), CalendarEvent.DistanceMatrix);
if (currDistance < lowestSofar)
{
lowestSofar=currDistance;
#if createCopyOfImplementation
retValue = eachList.SelectMany(obj => retValue.Where(obj0 => obj0.ID == obj.ID)).ToList(); ;
#else
retValue =eachList;
#endif
}
}
}
Utility.PinSubEventsToStart(retValue, MyLimitingTimeLine);
#endif
return retValue;
}