当前位置: 首页>>代码示例>>C#>>正文


C# TimeLine.CreateCopy方法代码示例

本文整理汇总了C#中My24HourTimerWPF.TimeLine.CreateCopy方法的典型用法代码示例。如果您正苦于以下问题:C# TimeLine.CreateCopy方法的具体用法?C# TimeLine.CreateCopy怎么用?C# TimeLine.CreateCopy使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在My24HourTimerWPF.TimeLine的用法示例。


在下文中一共展示了TimeLine.CreateCopy方法的8个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。

示例1: ClumpSubCalendarEvent

 public ClumpSubCalendarEvent(List<SubCalendarEvent> Appendables, TimeLine BoundaryTimeLine)
 {
     Appendables=Appendables.OrderBy(obj => obj.getCalendarEventRange.End).ToList();
     SubCalendarEvent RelativeSubEvent = Appendables[0];
     Appendables.Remove(RelativeSubEvent);
     ClumpSubCalendarEvent myThis = new ClumpSubCalendarEvent(RelativeSubEvent, Appendables, BoundaryTimeLine.CreateCopy());
     SubCalEventsOverLapWithBase = myThis.SubCalEventsOverLapWithBase;
     //List<SubCalendarEvent> NonOverLapping;
     BaseEvent= myThis.BaseEvent;
     this.BoundaryTimeLine =myThis.BoundaryTimeLine;
     //List<SubCalendarEvent> BaseClump;
     //List<ClumpSubCalendarEvent> NonOverLapping_Clump;
     BreakOffClump= myThis.BreakOffClump;
     ClumpedResults= myThis.ClumpedResults;
     BaseReferenceStartTime = myThis.BaseReferenceStartTime;
 }
开发者ID:jerbio,项目名称:My24HourTimerWPF,代码行数:16,代码来源:ClumpSubCalendarEvent.cs

示例2: reAlignSubCalEvents

        List<mTuple<bool, SubCalendarEvent>> reAlignSubCalEvents(TimeLine BoundaryTimeLine, List<mTuple<bool, SubCalendarEvent>> ListOfEvents)
        {
            DateTime ReferenceTime = BoundaryTimeLine.Start;
            TimeLine Boundary_Cpy = BoundaryTimeLine.CreateCopy();
            List<mTuple<bool, SubCalendarEvent>> myClashers = new System.Collections.Generic.List<mTuple<bool, SubCalendarEvent>>();


            foreach (mTuple<bool, SubCalendarEvent> eachmTuple in ListOfEvents)
            {



                if (!eachmTuple.Item2.PinSubEventsToStart(Boundary_Cpy))
                {
                    myClashers.Add(eachmTuple);

                    //throw new Exception("error in your shift algorithm");
                }
                else
                {
                    Boundary_Cpy = new TimeLine(eachmTuple.Item2.End, BoundaryTimeLine.End);
                };
            }


            ThisWillClash.Add(myClashers);


            return ListOfEvents;
        }
开发者ID:jerbio,项目名称:WagTapWeb,代码行数:30,代码来源:Schedule.cs

示例3: 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>();
//.........这里部分代码省略.........
开发者ID:jerbio,项目名称:WagTapWeb,代码行数:101,代码来源:Schedule.cs

示例4: stitchUnRestrictedSubCalendarEvent


//.........这里部分代码省略.........

                    bool breakForLoop = false;
                    bool PreserveRestrictedIndex = false;
                    for (; FrontPartialCounter < ListOfFrontPartialsStartTime.Count; FrontPartialCounter++)
                    {
                        TimeLineUpdated = null;
                        DateTime PertinentFreeSpotStart = EarliestReferenceTIme;
                        DateTime PertinentFreeSpotEnd;
                        if (CompleteArranegement.Count == 46)
                        {
                            ;
                        }
                        if ((ListOfFrontPartialsStartTime[FrontPartialCounter] < RestrictedStopper))
                        {
                            PertinentFreeSpotEnd = ListOfFrontPartialsStartTime[FrontPartialCounter];
                            //FrontPartials_Dict.Remove(ListOfFrontPartialsStartTime[FrontPartialCounter]);
                            ListOfFrontPartialsStartTime.RemoveAt(FrontPartialCounter);
                            --FrontPartialCounter;
                            PreserveRestrictedIndex = true;
                        }
                        else
                        {
                            PertinentFreeSpotEnd = RestrictedStopper;

                            if (breakForLoop)
                            {//populates with final boundary for each restricted
                                PertinentFreeSpot = new TimeLine(PertinentFreeSpotStart, PertinentFreeSpotEnd);

                                BorderElementBeginning = CompleteArranegement.Count>0?CompleteArranegement[CompleteArranegement.Count-1]:null;//Checks if Complete arrangement has partially being filled. Sets Last elements as boundary Element
                                BorderElementEnd = restrictedSnugFitAvailable[i].Item2;//uses restricted value as boundary element
                                LowestCostArrangement = OptimizeArrangeOfSubCalEvent(PertinentFreeSpot, new Tuple<SubCalendarEvent, SubCalendarEvent>(BorderElementBeginning, BorderElementEnd), CompatibleWithList.Values.ToList(), PossibleEntries_Cpy,Occupancy);
                                DateTime EarliestTimeForBetterEarlierReferenceTime = PertinentFreeSpot.Start;
                                LastSubCalElementForEarlierReferenceTime = ((CompleteArranegement.Count < 1) || (CompleteArranegement == null) ? null : CompleteArranegement[CompleteArranegement.Count - 1]);
                                    FreeSpotUpdated = PertinentFreeSpot.CreateCopy();
                                if (LowestCostArrangement.Count > 0)
                                {
                                    if (!(LowestCostArrangement[0].getCalendarEventRange.Start == PertinentFreeSpot.Start))//Pin SubEvents To Start
                                    {//if the first element is not a partial Sub Cal Event element
                                        FreeSpotUpdated = new TimeLine(EarliestReferenceTIme, PertinentFreeSpot.End);
                                        Utility.PinSubEventsToStart(LowestCostArrangement, FreeSpotUpdated);
                                    }
                                    else
                                    {
                                        FreeSpotUpdated = PertinentFreeSpot.CreateCopy();// new TimeLine(LowestCostArrangement[0].getCalendarEventRange.Start, PertinentFreeSpot.End);
                                        Utility.PinSubEventsToStart(LowestCostArrangement, PertinentFreeSpot);
                                    }
                                    EarliestReferenceTIme = PertinentFreeSpot.End;// LowestCostArrangement[LowestCostArrangement.Count - 1].End;

                                    SubCalendarEvent LastSubCalEvent = LowestCostArrangement[LowestCostArrangement.Count - 1];
                                    EarliestTimeForBetterEarlierReferenceTime = LastSubCalEvent.End;
                                    LastSubCalElementForEarlierReferenceTime = LastSubCalEvent;
                                    
                                }
                                TimeLineUpdated = null;
                                TimeLineUpdated = ObtainBetterEarlierReferenceTime(LowestCostArrangement, CalendarIDAndNonPartialSubCalEvents, RestrictedStopper - EarliestTimeForBetterEarlierReferenceTime, EarliestReferenceTIme, new TimeLine(FreeSpotUpdated.Start, FreeBoundary.End), LastSubCalElementForEarlierReferenceTime);
                                if (TimeLineUpdated != null)
                                {
                                    LowestCostArrangement = TimeLineUpdated.Item2;
                                    EarliestReferenceTIme = TimeLineUpdated.Item1;
                                }
                                

                                foreach (SubCalendarEvent eachSubCalendarEvent in LowestCostArrangement)
                                {
                                    --CompatibleWithList[eachSubCalendarEvent.ActiveDuration].Item1;
                                    PossibleEntries_Cpy[eachSubCalendarEvent.ActiveDuration].Remove(eachSubCalendarEvent.ID);
开发者ID:jerbio,项目名称:WagTapWeb,代码行数:67,代码来源:Schedule.cs

示例5: ReArrangeTimeLineWithinWithinCalendaEventRange


//.........这里部分代码省略.........
            LatestEndTime = MyEdgeElements[1].Count > 0 ? MyEdgeElements[1].OrderBy(obj => obj.End).ToList()[MyEdgeElements[1].Count - 1].End : RangeForScheduleUpdate.End;
            EarliestStartTime = EarliestStartTime < Now ? Now : EarliestStartTime;

            refinedStartTimeAndInterferringEvents = getStartTimeWhenCurrentTimeClashesWithSubcalevent(ArrayOfInterferringSubEvents, EarliestStartTime);
            EarliestStartTime = refinedStartTimeAndInterferringEvents.Item2;
            ArrayOfInterferringSubEvents = refinedStartTimeAndInterferringEvents.Item1.ToArray();
            RangeForScheduleUpdate = new TimeLine(EarliestStartTime, LatestEndTime);
            
            TimeSpan SumOfAllEventsTimeSpan = Utility.SumOfActiveDuration(ArrayOfInterferringSubEvents.ToList());//sum all events

            while (SumOfAllEventsTimeSpan >= RangeForScheduleUpdate.TimelineSpan)//loops untill the sum all the interferring events can possibly fit within the timeline. Essentially possibly fittable
            {
                EarliestStartTime = ArrayOfInterferringSubEvents.OrderBy(obj => obj.getCalendarEventRange.Start).ToList()[0].getCalendarEventRange.Start;//attempts to get subcalevent with a calendarevent with earliest start time
                LatestEndTime = ArrayOfInterferringSubEvents.OrderBy(obj => obj.getCalendarEventRange.End).ToList()[ArrayOfInterferringSubEvents.Length - 1].getCalendarEventRange.End;//attempts to get subcalevent with a calendarevent with latest Endtime
                EarliestStartTime = EarliestStartTime < Now ? Now : EarliestStartTime;
                refinedStartTimeAndInterferringEvents = getStartTimeWhenCurrentTimeClashesWithSubcalevent(ArrayOfInterferringSubEvents, EarliestStartTime);
                EarliestStartTime = refinedStartTimeAndInterferringEvents.Item2;
                ArrayOfInterferringSubEvents = refinedStartTimeAndInterferringEvents.Item1.ToArray();
                RangeForScheduleUpdate = new TimeLine(EarliestStartTime, LatestEndTime);//updates range of scan
                collectionOfInterferringSubCalEvents = getInterferringSubEvents(RangeForScheduleUpdate, NoneCommitedCalendarEventsEvents).ToList();//updates interferring events list
                ArrayOfInterferringSubEvents = collectionOfInterferringSubCalEvents.ToArray();
                ArrayOfInterferringSubEvents.OrderBy(obj => obj.End);
                MyEdgeElements = getEdgeElements(RangeForScheduleUpdate, ArrayOfInterferringSubEvents);
                EarliestStartTime = MyEdgeElements[0].Count > 0 ? MyEdgeElements[0].OrderBy(obj => obj.Start).ToList()[0].Start : RangeForScheduleUpdate.Start;
                LatestEndTime = MyEdgeElements[1].Count > 0 ? MyEdgeElements[1].OrderBy(obj => obj.End).ToList()[MyEdgeElements[1].Count - 1].End : RangeForScheduleUpdate.End;
                EarliestStartTime = EarliestStartTime < Now ? Now : EarliestStartTime;


                refinedStartTimeAndInterferringEvents = getStartTimeWhenCurrentTimeClashesWithSubcalevent(ArrayOfInterferringSubEvents, EarliestStartTime);
                EarliestStartTime = refinedStartTimeAndInterferringEvents.Item2;
                ArrayOfInterferringSubEvents = refinedStartTimeAndInterferringEvents.Item1.ToArray();

                RangeForScheduleUpdate = new TimeLine(EarliestStartTime, LatestEndTime);
                TimeSpan newSumOfAllTimeSpans = Utility.SumOfActiveDuration(ArrayOfInterferringSubEvents.ToList());
                if (newSumOfAllTimeSpans == SumOfAllEventsTimeSpan)
                {
                    throw new Exception("You have events that cannot fit our time frame");
                }
                else 
                {
                    SumOfAllEventsTimeSpan = newSumOfAllTimeSpans;
                }

            }*/

            
            
            Dictionary<CalendarEvent, List<SubCalendarEvent>> DictionaryWithBothCalendarEventIDAndListOfInterferringSubEvents = new Dictionary<CalendarEvent, List<SubCalendarEvent>>();
            List<SubCalendarEvent> RigidSubCalendarEvents = new List<SubCalendarEvent>(0);
            List<BusyTimeLine> RigidSubCalendarEventsBusyTimeLine = new List<BusyTimeLine>(0);


            RigidSubCalendarEvents = ArrayOfInterferringSubEvents.Where(obj => obj.Rigid).ToList();
            RigidSubCalendarEventsBusyTimeLine = RigidSubCalendarEvents.Select(obj => obj.ActiveSlot).ToList();

            double OccupancyOfTimeLineSPan = (double)SumOfAllEventsTimeSpan.Ticks / (double)RangeForScheduleUpdate.TimelineSpan.Ticks;
            
            ArrayOfInterferringSubEvents = Utility.NotInList(ArrayOfInterferringSubEvents.ToList(), RigidSubCalendarEvents).ToArray();//remove rigid elements
            
            
            //List<CalendarEvent>[]SubEventsTimeCategories= CategorizeSubEventsTimeLine
            /*
             * SubEventsTimeCategories has 4 list of containing lists.
             * 1st is a List with Elements Starting before The Mycalendaervent timeline and ends after the busytimeline
             * 2nd is a list with elements starting before the mycalendarvent timeline but ending before the myevent timeline
             * 3rd is a list with elements starting after the Mycalendar event start time but ending after the Myevent timeline
             * 4th is a list with elements starting after the MyCalendar event start time and ends before the Myevent timeline 
             * */
            DictionaryWithBothCalendarEventIDAndListOfInterferringSubEvents = generateDictionaryWithBothCalendarEventIDAndListOfInterferringSubEvents(ArrayOfInterferringSubEvents.ToList(), NoneCommitedCalendarEventsEvents);//generates a dictionary of a Calendar Event and the interferring events in the respective Calendar event
            //DictionaryWithBothCalendarEventIDAndListOfInterferringSubEvents.Add(MyCalendarEvent, MyCalendarEvent.AllEvents.ToList());//artificially adds enew calendar event to dictionary


            List<CalendarEvent> SortedInterFerringCalendarEvents_Deadline = DictionaryWithBothCalendarEventIDAndListOfInterferringSubEvents.Keys.ToList();
            SortedInterFerringCalendarEvents_Deadline = SortedInterFerringCalendarEvents_Deadline.OrderBy(obj => obj.End).ToList();

            TimeLine ReferenceTimeLine = RangeForScheduleUpdate.CreateCopy();


            ReferenceTimeLine.AddBusySlots(RigidSubCalendarEventsBusyTimeLine.ToArray());//Adds all the rigid elements

            TimeLine[] ArrayOfFreeSpots = getOnlyPertinentTimeFrame(getAllFreeSpots_NoCompleteSchedule(ReferenceTimeLine), ReferenceTimeLine).ToArray();
            ArrayOfFreeSpots = getOnlyPertinentTimeFrame(ArrayOfFreeSpots, ReferenceTimeLine).ToArray();

            Dictionary<TimeLine, List<CalendarEvent>> DictTimeLineAndListOfCalendarevent = new System.Collections.Generic.Dictionary<TimeLine, System.Collections.Generic.List<CalendarEvent>>();
            List<List<List<SubCalendarEvent>>> SnugListOfPossibleSubCalendarEventsClumps = BuildAllPossibleSnugLists(SortedInterFerringCalendarEvents_Deadline, MyCalendarEvent, DictionaryWithBothCalendarEventIDAndListOfInterferringSubEvents, ReferenceTimeLine, OccupancyOfTimeLineSPan);
            //Remember Jerome, I need to implement a functionality that permutates through the various options of pin to start option. So take for example two different event timeline that are pertinent to a free spot however one has a dead line preceeding the other, there will be a pin to start for two scenarios, one for each calendar event in which either of them gets pinned first.

            List<SubCalendarEvent>SerializedResult=SnugListOfPossibleSubCalendarEventsClumps[0].SelectMany(obj => obj).ToList();

            int TotalUpdatedSchedule= SerializedResult.Count+RigidSubCalendarEvents.Count;

            if (TotalUpdatedSchedule != collectionOfInterferringSubCalEvents.Count)
            {
                MyCalendarEvent.UpdateError(new CustomErrors(true, "There is a clash in event"));
            }
            NoneCommitedCalendarEventsEvents.Remove(MyCalendarEvent);

            return EvaluateEachSnugPossibiliyOfSnugPossibility(SnugListOfPossibleSubCalendarEventsClumps, ReferenceTimeLine, MyCalendarEvent);
            ;//this will not be the final output. I'll need some class that stores the current output of both rearrange busytimelines and deleted timelines
        }
开发者ID:jerbio,项目名称:WagTapWeb,代码行数:101,代码来源:Schedule.cs

示例6: ReArrangeClashingEventsofRigid


//.........这里部分代码省略.........
            {
                NoneCommitedCalendarEventsEvents.Remove(MyCalendarEvent);//removes my cal event
                return new KeyValuePair<CalendarEvent, TimeLine>(null,null);
            }
            RangeForScheduleUpdate = new TimeLine(EarliestStartTime, LatestEndTime);

            Tuple<TimeLine, IEnumerable<SubCalendarEvent>> allInterferringSubCalEventsAndTimeLine = getAllInterferringEventsAndTimeLineInCurrentEvaluation(ArrayOfInterferringSubEvents, NoneCommitedCalendarEventsEvents, RangeForScheduleUpdate);


            ArrayOfInterferringSubEvents = allInterferringSubCalEventsAndTimeLine.Item2.ToArray();
            RangeForScheduleUpdate = allInterferringSubCalEventsAndTimeLine.Item1;



            TimeSpan SumOfAllEventsTimeSpan = Utility.SumOfActiveDuration(ArrayOfInterferringSubEvents);


            int i = 0;
            /*
            
            ArrayOfInterferringSubEvents.OrderBy(obj => obj.End);//SortSubCalendarEvents(ArrayOfInterferringSubEvents.ToList(), false).ToArray();
            List<IDefinedRange>[] MyEdgeElements = getEdgeElements(RangeForScheduleUpdate, ArrayOfInterferringSubEvents);
            EarliestStartTime = MyEdgeElements[0].Count > 0 ? MyEdgeElements[0].OrderBy(obj => obj.Start).ToList()[0].Start : RangeForScheduleUpdate.Start;
            LatestEndTime = MyEdgeElements[1].Count > 0 ? MyEdgeElements[1].OrderBy(obj => obj.End).ToList()[MyEdgeElements[1].Count - 1].End : RangeForScheduleUpdate.End;
            EarliestStartTime = EarliestStartTime < Now ? Now : EarliestStartTime;

            refinedStartTimeAndInterferringEvents = getStartTimeWhenCurrentTimeClashesWithSubcalevent(ArrayOfInterferringSubEvents, EarliestStartTime);
            EarliestStartTime = refinedStartTimeAndInterferringEvents.Item2;
            ArrayOfInterferringSubEvents = refinedStartTimeAndInterferringEvents.Item1.ToArray();
            RangeForScheduleUpdate = new TimeLine(EarliestStartTime, LatestEndTime);
            TimeSpan SumOfAllEventsTimeSpan = Utility.SumOfActiveDuration(ArrayOfInterferringSubEvents.ToList());

            while (SumOfAllEventsTimeSpan >= RangeForScheduleUpdate.TimelineSpan)//loops untill the sum all the interferring events can possibly fit within the timeline. Essentially possibly fittable
            {
                EarliestStartTime = ArrayOfInterferringSubEvents.OrderBy(obj => obj.getCalendarEventRange.Start).ToList()[0].getCalendarEventRange.Start;//attempts to get subcalevent with a calendarevent with earliest start time
                LatestEndTime = ArrayOfInterferringSubEvents.OrderBy(obj => obj.getCalendarEventRange.End).ToList()[ArrayOfInterferringSubEvents.Length - 1].getCalendarEventRange.End;//attempts to get subcalevent with a calendarevent with latest Endtime
                EarliestStartTime = EarliestStartTime < Now ? Now : EarliestStartTime;
                refinedStartTimeAndInterferringEvents = getStartTimeWhenCurrentTimeClashesWithSubcalevent(ArrayOfInterferringSubEvents, EarliestStartTime);
                EarliestStartTime = refinedStartTimeAndInterferringEvents.Item2;
                ArrayOfInterferringSubEvents = refinedStartTimeAndInterferringEvents.Item1.ToArray();
                RangeForScheduleUpdate = new TimeLine(EarliestStartTime, LatestEndTime);//updates range of scan
                collectionOfInterferringSubCalEvents = getInterferringSubEvents(RangeForScheduleUpdate, NoneCommitedCalendarEventsEvents).ToList();//updates interferring events list
                ArrayOfInterferringSubEvents = collectionOfInterferringSubCalEvents.ToArray();
                ArrayOfInterferringSubEvents.OrderBy(obj => obj.End);
                MyEdgeElements = getEdgeElements(RangeForScheduleUpdate, ArrayOfInterferringSubEvents);
                EarliestStartTime = MyEdgeElements[0].Count > 0 ? MyEdgeElements[0].OrderBy(obj => obj.Start).ToList()[0].Start : RangeForScheduleUpdate.Start;
                LatestEndTime = MyEdgeElements[1].Count > 0 ? MyEdgeElements[1].OrderBy(obj => obj.End).ToList()[MyEdgeElements[1].Count - 1].End : RangeForScheduleUpdate.End;
                EarliestStartTime = EarliestStartTime < Now ? Now : EarliestStartTime;

                refinedStartTimeAndInterferringEvents = getStartTimeWhenCurrentTimeClashesWithSubcalevent(ArrayOfInterferringSubEvents, EarliestStartTime);
                EarliestStartTime = refinedStartTimeAndInterferringEvents.Item2;
                ArrayOfInterferringSubEvents = refinedStartTimeAndInterferringEvents.Item1.ToArray();

                RangeForScheduleUpdate = new TimeLine(EarliestStartTime, LatestEndTime);
                SumOfAllEventsTimeSpan = Utility.SumOfActiveDuration(ArrayOfInterferringSubEvents.ToList());
            }*/

            Dictionary<CalendarEvent, List<SubCalendarEvent>> DictionaryWithBothCalendarEventIDAndListOfInterferringSubEvents = new Dictionary<CalendarEvent, List<SubCalendarEvent>>();
            List<SubCalendarEvent> RigidSubCalendarEvents = new List<SubCalendarEvent>(0);

            RigidSubCalendarEvents = ArrayOfInterferringSubEvents.Where(obj => obj.Rigid).ToList();
            
            List<BusyTimeLine> RigidSubCalendarEventsBusyTimeLine = new List<BusyTimeLine>(0);
            RigidSubCalendarEventsBusyTimeLine = RigidSubCalendarEvents.Select(obj => obj.ActiveSlot).ToList();
            i = 0;
            double OccupancyOfTimeLineSPan = (double)SumOfAllEventsTimeSpan.Ticks / (double)RangeForScheduleUpdate.TimelineSpan.Ticks;

            ArrayOfInterferringSubEvents = Utility.NotInList(ArrayOfInterferringSubEvents.ToList(), RigidSubCalendarEvents).ToArray();//removes rigid elements

            DictionaryWithBothCalendarEventIDAndListOfInterferringSubEvents = generateDictionaryWithBothCalendarEventIDAndListOfInterferringSubEvents(ArrayOfInterferringSubEvents.ToList(), NoneCommitedCalendarEventsEvents);
            

            List<CalendarEvent> SortedInterFerringCalendarEvents_Deadline = DictionaryWithBothCalendarEventIDAndListOfInterferringSubEvents.Keys.ToList();
            SortedInterFerringCalendarEvents_Deadline = SortedInterFerringCalendarEvents_Deadline.OrderBy(obj => obj.End).ToList();







            TimeLine ReferenceTimeLine = RangeForScheduleUpdate.CreateCopy();
            ReferenceTimeLine.AddBusySlots(RigidSubCalendarEventsBusyTimeLine.ToArray());//Adds all the rigid elements

            TimeLine[] ArrayOfFreeSpots = getOnlyPertinentTimeFrame(getAllFreeSpots_NoCompleteSchedule(ReferenceTimeLine), ReferenceTimeLine).ToArray();
            ArrayOfFreeSpots = getOnlyPertinentTimeFrame(ArrayOfFreeSpots, ReferenceTimeLine).ToArray();

            Dictionary<TimeLine, List<CalendarEvent>> DictTimeLineAndListOfCalendarevent = new System.Collections.Generic.Dictionary<TimeLine, System.Collections.Generic.List<CalendarEvent>>();

            



            List<List<List<SubCalendarEvent>>> SnugListOfPossibleSubCalendarEventsClumps = BuildAllPossibleSnugLists(SortedInterFerringCalendarEvents_Deadline, MyCalendarEvent, DictionaryWithBothCalendarEventIDAndListOfInterferringSubEvents, ReferenceTimeLine,OccupancyOfTimeLineSPan);
            //Remember Jerome, I need to implement a functionality that permutates through the various options of pin to start option. So take for example two different event timeline that are pertinent to a free spot however one has a dead line preceeding the other, there will be a pin to start for two scenarios, one for each calendar event in which either of them gets pinned first.

            NoneCommitedCalendarEventsEvents.Remove(MyCalendarEvent);

            return EvaluateEachSnugPossibiliyOfSnugPossibility(SnugListOfPossibleSubCalendarEventsClumps, ReferenceTimeLine, MyCalendarEvent);
        }
开发者ID:jerbio,项目名称:WagTapWeb,代码行数:101,代码来源:Schedule.cs

示例7: EvaluateEachSnugPossibiliyOfSnugPossibility

        KeyValuePair<CalendarEvent, TimeLine> EvaluateEachSnugPossibiliyOfSnugPossibility(List<List<List<SubCalendarEvent>>> SnugPossibilityPermutation, TimeLine ReferenceTimeLine, CalendarEvent ReferenceCalendarEvent)
        {
            TimeLine CopyOfReferenceTimeLine;
            List<TimeLine> SnugPossibilityTimeLine = new System.Collections.Generic.List<TimeLine>();
            Dictionary<BusyTimeLine, SubCalendarEvent> MyBusyTimeLineToSubCalendarEventDict = new System.Collections.Generic.Dictionary<BusyTimeLine, SubCalendarEvent>();

            foreach (List<List<SubCalendarEvent>> SnugPermutation in SnugPossibilityPermutation)//goes each permutation of snug possibility generated
            {

                CopyOfReferenceTimeLine = ReferenceTimeLine.CreateCopy();
                //SnugPossibilityTimeLine.Add(CopyOfReferenceTimeLine);
                List<TimeLine> ListOfFreeSpots=getOnlyPertinentTimeFrame(getAllFreeSpots_NoCompleteSchedule(CopyOfReferenceTimeLine), CopyOfReferenceTimeLine);
                List<SubCalendarEvent> ReassignedSubEvents = new System.Collections.Generic.List<SubCalendarEvent>();
                for (int i=0; i<ListOfFreeSpots.Count;i++)
                {
                    DateTime RelativeStartTime = ListOfFreeSpots[i].Start;

                    foreach (SubCalendarEvent MySubCalendarEvent in SnugPermutation[i])
                    {
                        SubCalendarEvent CopyOfMySubCalendarEvent = MySubCalendarEvent.createCopy();
                        TimeSpan MySubCalendarDuration = (CopyOfMySubCalendarEvent.End - CopyOfMySubCalendarEvent.Start);
                        DateTime RelativeEndtime = RelativeStartTime + MySubCalendarDuration;
                        CopyOfMySubCalendarEvent.ReassignTime(RelativeStartTime, RelativeEndtime);
                        CopyOfMySubCalendarEvent.ActiveSlot = new BusyTimeLine(CopyOfMySubCalendarEvent.ID, RelativeStartTime, RelativeEndtime);//Note this is a hack to resolve the reassignment of time since we dont know currently know the distiction between BusyTimeLine and SubCalendarEvent(TimeLine)
                        TimeLine MyTimeLine=CopyOfMySubCalendarEvent.EventTimeLine;
                        CopyOfReferenceTimeLine.MergeTimeLines(MyTimeLine);
                        RelativeStartTime = CopyOfMySubCalendarEvent.End;
                        MyBusyTimeLineToSubCalendarEventDict.Add(CopyOfMySubCalendarEvent.ActiveSlot, CopyOfMySubCalendarEvent);
                    }
                }
                SnugPossibilityTimeLine.Add(CopyOfReferenceTimeLine);
            }
            Dictionary<CalendarEvent, TimeLine> CalendarEvent_EvaluationIndexDict = new System.Collections.Generic.Dictionary<CalendarEvent, TimeLine>();
            Dictionary<string, double> DictionaryGraph = new System.Collections.Generic.Dictionary<string, double>();

            foreach (TimeLine MyTimeLine in SnugPossibilityTimeLine)
            {
                CalendarEvent MyEventCopy=ReferenceCalendarEvent.createCopy();

                foreach (BusyTimeLine MyBusyPeriod in MyTimeLine.OccupiedSlots)
                {
                    EventID MyEventID = new EventID(MyBusyPeriod.TimeLineID);
                    string ParentCalendarEventID = MyEventID.getLevelID(0);
                    if (MyEventCopy.ID == ParentCalendarEventID)
                    {

                        SubCalendarEvent MySubCalendarEvent=MyBusyTimeLineToSubCalendarEventDict[MyBusyPeriod];
                        for (int i = 0; i < MyEventCopy.AllEvents.Length; i++)
                        {
                            if (MyEventCopy.AllEvents[i].ID == MySubCalendarEvent.ID)
                            {
                                MyEventCopy.AllEvents[i] = MySubCalendarEvent;
                                break;
                            }
                        }

                    }
                }

                //MyEventCopy=EvaluateTotalTimeLineAndAssignValidTimeSpotsWithReferenceTimeLine(MyEventCopy, MyTimeLine);

                CalendarEvent_EvaluationIndexDict.Add(MyEventCopy, MyTimeLine);

            }

            double HighestValue=0;

            KeyValuePair<CalendarEvent, TimeLine> FinalSuggestion = new System.Collections.Generic.KeyValuePair<CalendarEvent,TimeLine>();
            TimeLine TimeLineUpdated = null;
            Dictionary<string, double> LocationVector = new System.Collections.Generic.Dictionary<string,double>();
            LocationVector.Add("sameElement", 10000000000);

            foreach (KeyValuePair<CalendarEvent, TimeLine> MyCalendarEvent_TimeLine in CalendarEvent_EvaluationIndexDict)
            {
                int RandomIndex = EvaluateRandomNetIndex(MyCalendarEvent_TimeLine.Value);
                RandomIndex = 0;
                LocationVector=BuildDictionaryDistanceEdge(MyCalendarEvent_TimeLine.Value, MyCalendarEvent_TimeLine.Key, LocationVector);
                double ClumpIndex = EvaluateClumpingIndex(MyCalendarEvent_TimeLine.Value, LocationVector);
                ClumpIndex = 1 / ClumpIndex;
                double EvaluationSum = ClumpIndex + RandomIndex;
                if (EvaluationSum < 0)
                {
                    EvaluationSum *= -1;
                }

                if ( EvaluationSum > HighestValue)
                {
                    HighestValue = EvaluationSum;
                    FinalSuggestion = MyCalendarEvent_TimeLine;
                }
            }

            if (FinalSuggestion.Equals(new KeyValuePair<CalendarEvent,TimeLine>()))
            {
                MessageBox.Show("Oh oh J, you'll need to look outside this range...Think of moving other events out of white box space");
            }

            return FinalSuggestion;
        }
开发者ID:jerbio,项目名称:My24HourTimerWPF,代码行数:99,代码来源:MainWindow.xaml.cs.old.cs

示例8: resolveInTo24HourSlots

        List<SubCalendarEvent> resolveInTo24HourSlots(List<SubCalendarEvent> currentListOfSubCalendarElements, TimeLine limitingTimeLine, mTuple<SubCalendarEvent,SubCalendarEvent>edgeElements=null)
        {
            //function takes a full freespot and tries to spread it out into 24 hour sections
            //this is done by intially sending every subcalevenet towards the end of the Timeline after which it takes 24hour chunks and attempts to 
            
            




            
            List<SubCalendarEvent> currentListOfSubCalendarElements_cpy = currentListOfSubCalendarElements.ToList();
            Utility.PinSubEventsToStart(currentListOfSubCalendarElements_cpy, limitingTimeLine);
            
            TimeLine limitingTimeLine_cpy = limitingTimeLine.CreateCopy();

            limitingTimeLine.AddBusySlots(currentListOfSubCalendarElements_cpy.Select(obj => obj.ActiveSlot));
            List<TimeLineWithEdgeElements> AllFreeSpots = limitingTimeLine_cpy.getAllFreeSlotsWithEdges().ToList();
            AllFreeSpots=AllFreeSpots.Where(obj => obj.TimelineSpan.Ticks > 0).OrderBy(obj=>obj.End).ToList();



            for (int i = AllFreeSpots.Count() - 1; AllFreeSpots.Count() > 0; )
            {
                TimeLine eachTimeLine = AllFreeSpots[i];
                List<SubCalendarEvent> reassignedElements = TossEndWards(currentListOfSubCalendarElements, eachTimeLine);//tries to toss any subcalendarevent towards the end
                reassignedElements=reassignedElements.OrderBy(obj => obj.End).ToList();
                Utility.PinSubEventsToEnd(reassignedElements, eachTimeLine);
                
                SubCalendarEvent lastElement;// = reassignedElements.Last();

                currentListOfSubCalendarElements.RemoveAll(obj => reassignedElements.Contains(obj));


                if (reassignedElements.Count > 0)
                {
                    lastElement = reassignedElements.First();
                    limitingTimeLine = new TimeLine(limitingTimeLine.Start, lastElement.Start);
                }
                else 
                {
                    currentListOfSubCalendarElements.OrderBy(obj => obj.End);
                    if (currentListOfSubCalendarElements.Count > 0)//hack alert you need to coscious of coliision scenario
                    {
                        lastElement = currentListOfSubCalendarElements.Last();
                        lastElement.PinToEnd(limitingTimeLine);
                        currentListOfSubCalendarElements.Remove(lastElement);
                        limitingTimeLine = new TimeLine(limitingTimeLine.Start, lastElement.Start);
                    }
                    else
                    {
                        break;
                    }
                    
                    
                }

                Utility.PinSubEventsToStart(currentListOfSubCalendarElements, limitingTimeLine);


                

                
                limitingTimeLine.AddBusySlots(currentListOfSubCalendarElements.Select(obj => obj.ActiveSlot));
                AllFreeSpots = limitingTimeLine.getAllFreeSlotsWithEdges().ToList();
                i = AllFreeSpots.Count() - 1;
                
            }

            TimeSpan TotalDuration = Utility.SumOfActiveDuration(currentListOfSubCalendarElements_cpy);
            double Occupancy = (double)TotalDuration.Ticks / (double)limitingTimeLine_cpy.TimelineSpan.Ticks;

            List<SubCalendarEvent> currentListOfSubCalendarElements_cpy_ref = currentListOfSubCalendarElements_cpy.ToList();
            Dictionary<string, mTuple<SubCalendarEvent, BusyTimeLine>> currentListOfSubCalendarElements_cpy_ref_Dict = currentListOfSubCalendarElements_cpy_ref.ToDictionary(obj => obj.ID, obj => new mTuple<SubCalendarEvent, BusyTimeLine>(obj, obj.ActiveSlot.CreateCopy()));
            TimeLine limitingTimeLine_cpy_cpy_ref = limitingTimeLine_cpy.CreateCopy();
            List<SubCalendarEvent> FullyUpdated = new List<SubCalendarEvent>();

            while(true)
            {
                Tuple<List<SubCalendarEvent>, TimeLine> CollectionUpdated = every24Interval(currentListOfSubCalendarElements_cpy_ref, limitingTimeLine_cpy_cpy_ref, Occupancy, currentListOfSubCalendarElements_cpy_ref_Dict);

                TimeSpan currTotalDuration = Utility.SumOfActiveDuration(CollectionUpdated.Item1);
                double currOccupancy =-8898;
                if(CollectionUpdated.Item2.TimelineSpan.Ticks>0)
                { currOccupancy = (double)currTotalDuration.Ticks / (double)CollectionUpdated.Item2.TimelineSpan.Ticks; }

                if (currOccupancy > Occupancy)
                {
                    ;
                }


                FullyUpdated.AddRange(CollectionUpdated.Item1);

                limitingTimeLine_cpy_cpy_ref = new TimeLine(CollectionUpdated.Item2.End, limitingTimeLine_cpy_cpy_ref.End);
                currentListOfSubCalendarElements_cpy_ref.RemoveAll(obj => FullyUpdated.Contains(obj));
                if ((currentListOfSubCalendarElements_cpy_ref.Count < 1) || (limitingTimeLine_cpy_cpy_ref.TimelineSpan.Ticks <= 0))
                {
                    break;
                }
//.........这里部分代码省略.........
开发者ID:jerbio,项目名称:My24HourTimerWPF,代码行数:101,代码来源:Schedule.cs


注:本文中的My24HourTimerWPF.TimeLine.CreateCopy方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。