// // user has clicked on a stop for more info: // private void lstStops_SelectedIndexChanged(object sender, EventArgs e) { // sometimes this event fires, but nothing is selected... if (this.lstStops.SelectedIndex < 0) // so return now in this case: { return; } // // clear GUI in case this fails: // ClearStopUI(); // // now display info about this stop: // try { string stopName = lstStops.SelectedItem.ToString().Replace("'", "''"); // get stops at the selected station BusinessTier.Business bizTier = new BusinessTier.Business(this.txtDatabaseFilename.Text); string stationID = bizTier.GetStationID(lstStations.SelectedItem.ToString().Replace("'", "''")); foreach (string l in bizTier.GetLinesAt(stopName, stationID)) { this.lstLines.Items.Add(l); } // ADA accessible bool ada = bizTier.IsADA(stopName, stationID); if (ada) { txtAccessible.Text = "Yes"; } else { txtAccessible.Text = "No"; } // travel direction this.txtDirection.Text = bizTier.GetDirection(stopName, stationID); // get location BusinessTier.Coordinates c = bizTier.GetCoordinates(stopName, stationID); this.txtLocation.Text = (string.Format(@"{0:0.0000}, {1:0.0000}", c.Latitude, c.Longitude)); } catch (Exception ex) { string msg = string.Format("Error: '{0}'.", ex.Message); MessageBox.Show(msg); } }
// get the coordinates private void listBox1_DoubleClick(object sender, EventArgs e) { //parse the item the user selected string[] words = listBox1.SelectedItem.ToString().Split(':'); // get coordinates BusinessTier.Coordinates coord = bt.getCoordinates(Convert.ToInt32(words[0])); // display coordinates string newMsg = string.Format("({1},{0})", coord.Longitude, coord.Latitude); this.textBox1.Text = newMsg; //Display the location via a pin and center it on the map Pushpin pin = new Pushpin(); pin.Location = new Location(coord.Latitude, coord.Longitude); theMap.map.Children.Add(pin); theMap.map.Center = new Location(coord.Latitude, coord.Longitude); theMap.map.Focus(); elementHost1.Child = theMap; // Add event handler to push pin pin.MouseRightButtonDown += new System.Windows.Input.MouseButtonEventHandler(pin_MouseRightButtonDown); // now get the stops at this station IReadOnlyList <BusinessTier.Stops> lines = bt.getAllStopsbyStationID(Convert.ToInt32(words[0])); IEnumerator <BusinessTier.Stops> lineEn = lines.GetEnumerator(); BusinessTier.Stops curLine; // if listbox contains items. then clear it if (listBox2.Items.Count != 0) { listBox2.Items.Clear(); } // format the content while (lineEn.MoveNext()) { curLine = lineEn.Current; string msg = string.Format(" {0}: {1}", curLine.StopID, curLine.Name); this.listBox2.Items.Add(msg); // once formatted , add it to listbox2 } // total riderships and average per day BusinessTier.Sum_Avg myResult = bt.totalRiders(Convert.ToInt32(words[0])); this.textBox4.Text = Convert.ToString(myResult.Sum); this.textBox5.Text = Convert.ToString(myResult.Average); }