private void Button_Clicked_1(object sender, EventArgs e) { if (events.Count == 0) { DisplayAlert("Προσοχή", "Πρέπει να προσθέσεις μια ημερομηνία", "ΟΚ"); return; } var lesson = new LessonWithMultipleTimes(events, isFixedSwitch.IsToggled) { Name = lessonName.Text }; //lesson.Name = lessonName.Text; if (isFixedSwitch.IsToggled) { MainPage.fixedEvents.Add(lesson); } else { MainPage.NotFixedEvents.Add(lesson); } SelectedStringChanged(sender, e); PopupNavigation.Instance.PopAsync(true); }
public void Test() { var mandatoryEvents = new List <Event>(); var optionalEvents = new List <LessonWithMultipleTimes>(); var mathima_a = new List <Event>(); var m_a_a = new Event { Id = 1, IsFixed = false, Day = DayOfWeek.Monday, }; m_a_a.SetTime(13, 00, 14, 00); mathima_a.Add(m_a_a); var m_a_b = new Event { Id = 2, IsFixed = false, Day = DayOfWeek.Monday, }; m_a_b.SetTime(15, 00, 16, 00); mathima_a.Add(m_a_b); var m_a_c = new Event { Id = 3, IsFixed = false, Day = DayOfWeek.Tuesday, }; m_a_c.SetTime(15, 00, 16, 00); mathima_a.Add(m_a_c); var mathima_b_events = new List <Event>(); var m_b_a = new Event { Id = 4, IsFixed = false, Day = DayOfWeek.Wednesday, }; m_b_a.SetTime(15, 00, 16, 00); mathima_b_events.Add(m_b_a); var m_b_b = new Event { Id = 5, IsFixed = false, Day = DayOfWeek.Wednesday, }; m_b_b.SetTime(19, 00, 20, 00); mathima_b_events.Add(m_b_b); var mandatoryA = new Event { Id = 6, IsFixed = true, Day = DayOfWeek.Wednesday, }; mandatoryA.SetTime(17, 00, 18, 00); mandatoryEvents.Add(mandatoryA); var m_a = new LessonWithMultipleTimes(mathima_a, false); var m_b = new LessonWithMultipleTimes(mathima_b_events, false); optionalEvents.Add(m_a); optionalEvents.Add(m_b); var tuple = new ApplicationLogic().Logic(mandatoryEvents, optionalEvents, 20); var times = tuple.Item1; var memory = tuple.Item2; }
static void Main(string[] args) { int idCounter = 0; //provides the id var mandatoryEvents = new List <Event>(); var optionalEvents = new List <LessonWithMultipleTimes>(); //format: Mon 1000-1200 double roundtriptime = 0; Console.WriteLine("Enter how much time to go to the university and back (in minutes)"); var ii = Console.ReadLine(); while (!double.TryParse(ii, out roundtriptime)) { Console.WriteLine("Error, try again"); ii = Console.ReadLine(); } Console.WriteLine("Enter the fixed lessons in the format: Name,Day 1000-1200,Day 1400-1600"); Console.WriteLine("To go to the non fixed, type \"c\""); var input = Console.ReadLine(); while (input != "exit" && input != "c") { List <Event> evTemp = ConsoleHelpers.ParseData(input, true, ref idCounter); mandatoryEvents.AddRange(evTemp); input = Console.ReadLine(); } if (input == "c") { Console.WriteLine("Please type the non fixed in the same format. When done type \"done\" "); input = Console.ReadLine(); while (input != "done") { List <Event> evTemp = ConsoleHelpers.ParseData(input, false, ref idCounter); LessonWithMultipleTimes lesson = new LessonWithMultipleTimes(evTemp, false); optionalEvents.Add(lesson); input = Console.ReadLine(); } } var tuple = new ApplicationLogic().Logic(mandatoryEvents, optionalEvents, roundtriptime); var times = tuple.Item1; var combinations = tuple.Item2; TimeCalculate min = times.OrderBy(x => x.Time).First(); List <int> idsToAdd = combinations[min.MemoryId]; List <Event> toDisplay = mandatoryEvents.ToList(); //arxika vale ola ta fixed events List <Event> allOptionalEvents = new List <Event>(); foreach (var lesson in optionalEvents) { allOptionalEvents.AddRange(lesson.Times); } foreach (var id in idsToAdd) { toDisplay.Add(allOptionalEvents.First(x => x.Id == id)); } toDisplay = toDisplay .OrderBy(x => ((int)x.Day + 6) % 7) .ThenBy(x => x.startTime) .ToList(); Console.WriteLine("To teliko programma einai:"); foreach (var ev in toDisplay) { Console.WriteLine("Day " + ev.Day + " Mathima: " + ev.Name + " Start: " + ev.startTime.Hour + ":" + ev.startTime.Minute + " Finish: " + ev.finishTime.Hour + ":" + ev.finishTime.Minute); } }