public void addGenes(TCEvents g) { genes.Add(g); }
private void DisplayTimetable_Load(object sender, EventArgs e) { string[] days = { "Monday", "Tuesday", "Wednesday", "Thursday", "Friday" }; int i = 1; foreach (string day in days) { Label label = new Label(); label.Text = day; tableLayout.Controls.Add(label, i, 0); i++; } int[] times = { 900, 1000, 1100, 1200, 1300, 1400, 1500, 1600 }; i = 1; foreach (int time in times) { Label label = new Label(); label.Text = Convert.ToString(time); tableLayout.Controls.Add(label, 0, i); i++; } List <TableCell> cells = new List <TableCell>(); TableCell currentCell = new TableCell(); TCEvents currentGene = new TCEvents(); string currentDay = ""; string currentTime = ""; string currentWeek = ""; try { XmlTextReader reader = new XmlTextReader("timetable.xml"); while (reader.Read()) { reader.MoveToContent(); string text = reader.Name.ToString(); if (text == "Name") { currentDay = reader.ReadString(); } else if (text == "Time") { string tempTime = reader.ReadString(); if (currentTime != tempTime) { if (currentTime != "") { cells.Add(currentCell); } currentCell = new TableCell(); currentCell._day = currentDay; currentCell._time = tempTime; } currentTime = tempTime; } else if (text == "WeekName") { currentWeek = reader.ReadString(); } else if (text == "Event") { if (currentGene._courseCode != "") { currentCell.addGenes(currentGene); } currentGene = new TCEvents(); currentGene._week = currentWeek; } else if (text == "Course") { currentGene._courseCode = reader.ReadString(); } else if (text == "Activity") { currentGene._activity = reader.ReadString(); } else if (text == "Room") { currentGene._room = reader.ReadString(); } else if (text == "Group") { currentGene.addGroups(reader.ReadString()); } } // the last cell won't get added cells.Add(currentCell); } catch (Exception exp) { Console.WriteLine(exp); } foreach (TableCell tc in cells) { tableLayout.Controls.Add(populateTable(tc, tc._day, tc._time), getColNum(tc._day), getRowNum(tc._time)); } }
private void DisplayTimetable_Load(object sender, EventArgs e) { string[] days = { "Monday", "Tuesday", "Wednesday", "Thursday", "Friday" }; int i = 1; foreach (string day in days) { Label label = new Label(); label.Text = day; tableLayout.Controls.Add(label, i, 0); i++; } int[] times = { 900, 1000, 1100, 1200, 1300, 1400, 1500, 1600 }; i = 1; foreach (int time in times) { Label label = new Label(); label.Text = Convert.ToString(time); tableLayout.Controls.Add(label, 0, i); i++; } List<TableCell> cells = new List<TableCell>(); TableCell currentCell = new TableCell(); TCEvents currentGene = new TCEvents(); string currentDay = ""; string currentTime = ""; string currentWeek = ""; try { XmlTextReader reader = new XmlTextReader("timetable.xml"); while (reader.Read()) { reader.MoveToContent(); string text = reader.Name.ToString(); if (text == "Name") currentDay = reader.ReadString(); else if (text == "Time") { string tempTime = reader.ReadString(); if (currentTime != tempTime) { if (currentTime != "") cells.Add(currentCell); currentCell = new TableCell(); currentCell._day = currentDay; currentCell._time = tempTime; } currentTime = tempTime; } else if (text == "WeekName") currentWeek = reader.ReadString(); else if (text == "Event") { if (currentGene._courseCode != "") currentCell.addGenes(currentGene); currentGene = new TCEvents(); currentGene._week = currentWeek; } else if (text == "Course") currentGene._courseCode = reader.ReadString(); else if (text == "Activity") currentGene._activity = reader.ReadString(); else if (text == "Room") currentGene._room = reader.ReadString(); else if (text == "Group") currentGene.addGroups(reader.ReadString()); } // the last cell won't get added cells.Add(currentCell); } catch (Exception exp) { Console.WriteLine(exp); } foreach (TableCell tc in cells) { tableLayout.Controls.Add(populateTable(tc, tc._day, tc._time), getColNum(tc._day), getRowNum(tc._time)); } }