public void PrintRoute(int idDb, string departure, string arrival, bool home) { if (_clearAlerts) { ClearRoutes(); _clearAlerts = false; } string departureTime = null; string arrivalTime = null; string id = null; string message = null; XmlNodeList routes = _data.SelectNodes("ReisMogelijkheden/ReisMogelijkheid"); if (routes != null) { foreach (XmlNode optimaleRoute in routes) { if (optimaleRoute["Optimaal"].InnerXml.Equals("true") && _i == 0) { _i++; departureTime = optimaleRoute["ActueleVertrekTijd"]?.InnerText; arrivalTime = optimaleRoute["ActueleAankomstTijd"]?.InnerText; if (optimaleRoute["Melding"] != null) { var alerts = optimaleRoute.SelectNodes("Melding"); if (alerts != null) { foreach (XmlNode alert in alerts) { id = alert["Id"]?.InnerText; message = alert["Text"]?.InnerText; } } } } } _i = 0; } //Print header if not null if (departure != null && arrival != null && !home) { // Print the header Label headerLabel = new Label { Location = new Point(15, _startY), Size = new Size(400, 18), Font = new Font("Open Sans", 9, FontStyle.Bold), Text = @"Station " + departure + @" ➜ Station " + arrival }; _headerList.Add(headerLabel); _main.tabOnTime.Controls.Add(headerLabel); _startY += 20; } //Print header if not null if (departure != null && arrival != null && home) { // Print the header Label headerLabel = new Label { Location = new Point(15, _startY), Size = new Size(400, 18), Font = new Font("Open Sans", 9, FontStyle.Bold), Text = @"Station " + arrival + @" ➜ Station " + departure }; _headerList.Add(headerLabel); _main.tabOnTime.Controls.Add(headerLabel); _startY += 20; } if (id != null) { // Print alert label Label alertLabel = new Label { Location = new Point(15, _startY), Size = new Size(200, 18), Font = new Font("Open Sans", 9, FontStyle.Bold), ForeColor = Color.DarkOrange, Cursor = Cursors.Hand, Text = message }; alertLabel.Click += (s, e) => { Alerts alert = new Alerts(_main); MessageBox.Show(alert.FindAlert(id)); }; alertLabel.MouseEnter += (s, e) => { alertLabel.ForeColor = Color.Black; }; alertLabel.MouseLeave += (s, e) => { alertLabel.ForeColor = Color.DarkOrange; }; _alertList.Add(alertLabel); _main.tabOnTime.Controls.Add(alertLabel); _startY += 20; } // Print the transportType string departureDate = DateTime.Parse(departureTime).ToString("dd-MMMM-yyyy"); Label leaveAndArrivaLabel = new Label { Location = new Point(15, _startY), Size = new Size(600, 18), Font = new Font("Open Sans", 9), Text = @"Vertrek morgen " + departureDate + @" om " + departureTime?.Substring(11, 5) + @" aankomst om " + arrivalTime?.Substring(11, 5) }; _main.tabOnTime.Controls.Add(leaveAndArrivaLabel); //Add labels to the lists _leaveAndArrivaList.Add(leaveAndArrivaLabel); _startY += 20; Label removeLabel = new Label { Location = new Point(15, _startY), Size = new Size(50, 18), Font = new Font("Open Sans", 9), ForeColor = Color.FromArgb(0, 154, 224), Cursor = Cursors.Hand, Text = @"Verwijderen" }; removeLabel.Click += (s, e) => { Database remove = new Database(); DialogResult dialogResult = MessageBox.Show(@"Verwijderen?", @"Route verwijderen", MessageBoxButtons.YesNo); if (dialogResult == DialogResult.Yes) { remove.Remove(idDb); } }; removeLabel.MouseEnter += (s, e) => { removeLabel.ForeColor = Color.Black; }; removeLabel.MouseLeave += (s, e) => { removeLabel.ForeColor = Color.FromArgb(0, 154, 224); }; //Add labels to the lists _removeList.Add(removeLabel); _main.tabOnTime.Controls.Add(removeLabel); _startY += 40; }
public void PrintTravelOption(string station, string time, string trackNr, string carrier, string transportType, string id, string message) { if (_clearInfo) { ClearInfo(); _clearInfo = false; } //Set StationNames _main.stationNamesLBL.Text = _main.boxDepartue.Text + @" ➜ " + _main.boxArrival.Text; if (id != null) { // Print alert label Label alertLabel = new Label { Location = new Point(232, _headerY), Size = new Size(200, 18), Font = new Font("Open Sans", 9, FontStyle.Bold), ForeColor = Color.DarkOrange, Cursor = Cursors.Hand, Text = message }; alertLabel.Click += (s, e) => { Alerts alert = new Alerts(_main); MessageBox.Show(alert.FindAlert(id)); }; alertLabel.MouseEnter += (s, e) => { alertLabel.ForeColor = Color.Black; }; alertLabel.MouseLeave += (s, e) => { alertLabel.ForeColor = Color.DarkOrange; }; _alertList.Add(alertLabel); _main.tabTravelInfo.Controls.Add(alertLabel); _headerY += 20; _infoY += 20; } //Print header if not null if (carrier != null && transportType != null) { // Print the transportType Label transportTypeLabel = new Label { Location = new Point(232, _headerY), Size = new Size(80, 18), Font = new Font("Open Sans", 9, FontStyle.Bold), Text = transportType.Substring(0, 1).ToUpper() + transportType.Substring(1) }; _main.tabTravelInfo.Controls.Add(transportTypeLabel); //Print carrier Label carrierLabel = new Label { Location = new Point(464, _headerY), Size = new Size(80, 18), Font = new Font("Open Sans", 9, FontStyle.Bold), Text = carrier }; _main.tabTravelInfo.Controls.Add(carrierLabel); //Add labels to the list _transportTypeList.Add(transportTypeLabel); _carrierList.Add(carrierLabel); _headerY += 60; //Adds more space for the headers if (_counterHeader == 1) { _infoY += 20; _counterHeader = 0; } _counterHeader++; } // Print the time Label timeLabel = new Label { Location = new Point(232, _infoY), Size = new Size(50, 13), Font = new Font("Open Sans", 9), Text = time.Substring(11, 5) }; _main.tabTravelInfo.Controls.Add(timeLabel); // Print the station Label stationLabel = new Label { Location = new Point(298, _infoY), Size = new Size(150, 13), Font = new Font("Open Sans", 9), Text = @"Station " + station, Cursor = Cursors.Hand }; stationLabel.Click += (s, e) => { Departure departure = new Departure(_main); departure.GetDepartures(station); _main.tabTravelInfo.Visible = false; _main.tabActualDeparture.Show(); }; stationLabel.MouseEnter += (s, e) => { stationLabel.ForeColor = Color.FromArgb(0, 154, 224); }; stationLabel.MouseLeave += (s, e) => { stationLabel.ForeColor = Color.Black; }; _main.tabTravelInfo.Controls.Add(stationLabel); //Print the track number Label trackNrLabel = new Label { Location = new Point(464, _infoY), Size = new Size(100, 13), Font = new Font("Open Sans", 9), Text = @"Spoor " + trackNr }; _main.tabTravelInfo.Controls.Add(trackNrLabel); //add space between labels _infoY += 20; //Add labels to the lists _timeList.Add(timeLabel); _stationList.Add(stationLabel); _trackNrList.Add(trackNrLabel); }