// Gives a tripOptionsCell back.
        public static TripOptionsCell GetCellDetails(string departureTime, string destinationTime, string nameTransport
                                                     , string totalTime, string transferCount, List <Node> shortestPath)
        {
            TripOptionsCell c = new TripOptionsCell(departureTime, destinationTime, nameTransport, totalTime, transferCount, shortestPath);

            return(c);
        }
Beispiel #2
0
        // Fills the flowcontrol with the usercontrol called "tripOptionsCell" and gives the needed data to tripOptionsCell.
        private void FillTripOptions(TripOptionsCell[] listItems)
        {
            for (int i = 0; i < listItems.Count(); i++)
            {
                listItems[i] = new TripOptionsCell(this);
                listItems[i].departureTime   = tripOptions[i].startTime.ToShortTimeString();
                listItems[i].destinationTime = tripOptions[i].endTime.ToShortTimeString();
                listItems[i].nameTransport   = "Train";
                TimeSpan span      = tripOptions[i].endTime.Subtract(tripOptions[i].startTime);
                DateTime timeAdded = tripOptions[i].startTime.AddHours(span.Hours).AddMinutes(span.Minutes).AddDays(span.Days);

                if (timeAdded.Day > tripOptions[i].startTime.Day)
                {
                    // If it takes 1 or more days change LBL size, height and span format.
                    if (span.Days == 1)
                    {
                        listItems[i].totaltimeLBL.Location = new Point(260, listItems[i].totaltimeLBL.Location.Y);
                        listItems[i].totaltimeLBL.Size     = new Size(70, listItems[i].totaltimeLBL.Height);
                        listItems[i].clockIcon.Location    = new Point(listItems[i].totaltimeLBL.Location.X - 23, listItems[i].clockIcon.Location.Y);
                        listItems[i].totalTime             = span.ToString(@"dd").TrimStart(' ', 'd', 'h', 'm', 's', '0') + "d " + span.ToString(@"hh").TrimStart(' ', 'd', 'h', 'm', 's') + "h " + span.ToString(@"mm").TrimStart(' ', 'd', 'h', 'm', 's') + "m";
                        listItems[i].destinationTime       = tripOptions[i].endTime.ToShortTimeString() + " next day";
                    }
                    else if (span.Days > 1)
                    {
                        listItems[i].totaltimeLBL.Location = new Point(260, listItems[i].totaltimeLBL.Location.Y);
                        listItems[i].totaltimeLBL.Size     = new Size(70, listItems[i].totaltimeLBL.Height);
                        listItems[i].clockIcon.Location    = new Point(listItems[i].totaltimeLBL.Location.X - 23, listItems[i].clockIcon.Location.Y);
                        listItems[i].totalTime             = span.ToString(@"dd").TrimStart(' ', 'd', 'h', 'm', 's', '0') + "d " + span.ToString(@"hh").TrimStart(' ', 'd', 'h', 'm', 's') + "h " + span.ToString(@"mm").TrimStart(' ', 'd', 'h', 'm', 's') + "m";
                        listItems[i].destinationTime       = tripOptions[i].endTime.ToShortTimeString() + " " + span.Days + " days later";
                    }
                    else
                    {
                        listItems[i].destinationTime = tripOptions[i].endTime.ToShortTimeString() + " next day";
                        listItems[i].totalTime       = span.ToString(@"hh").TrimStart(' ', 'd', 'h', 'm', 's') + "h " + span.ToString(@"mm").TrimStart(' ', 'd', 'h', 'm', 's') + "m";
                    }
                }
                else
                {
                    listItems[i].totalTime = span.ToString(@"hh").TrimStart(' ', 'd', 'h', 'm', 's') + "h " + span.ToString(@"mm").TrimStart(' ', 'd', 'h', 'm', 's') + "m";
                }


                listItems[i].shortestPath = tripOptions[i].shortestPath;

                if (tripOptionsFlowControl.Controls.Count < 0)
                {
                    ClearFlowControl(tripOptionsFlowControl);
                }
                else
                {
                    tripOptionsFlowControl.Controls.Add(listItems[i]);
                }
            }
        }