private void StatWebClient_Completed(object sender, OpenReadCompletedEventArgs e)
 {
     using (StreamReader reader = new StreamReader(e.Result))
     {
         string contents = reader.ReadToEnd();
         ObservableCollection<Station> stats = XMLUtils.parseXMLForStat(contents);
         m_selectedStat = stats.First();
         NavigationService.Navigate(new Uri("/StatDetailPage.xaml", UriKind.Relative));
     }
 }
Beispiel #2
0
        public static ObservableCollection<Station> parseXMLForStat(string xmlFile)
        {
            XDocument xdoc = XDocument.Parse(xmlFile);

            var temp_stats = from temp_stat in xdoc.Descendants("stat")
                             select new
                             {
                                 name = temp_stat.Element("name").Value,
                                 xy = temp_stat.Element("xy").Value,
                                 line_names = temp_stat.Element("line_names").Value,
                             };
            ObservableCollection<Station> stats = new ObservableCollection<Station>();
            foreach (var temp_stat in temp_stats)
            {
                Station stat = new Station();
                stat.StationName = temp_stat.name;
                if (temp_stat.xy.Length > 0)
                {
                    string[] xy = temp_stat.xy.Split(',');
                    stat.Longitude = float.Parse(xy[0]);
                    stat.Latitude = float.Parse(xy[1]);
                }              

                ObservableCollection<Line> lines = new ObservableCollection<Line>();
                foreach (string line_name in temp_stat.line_names.Split(';'))
                {
                    Line line = new Line();
                    int index = line_name.IndexOf('(');
                    line.LineName = line_name.Substring(0, index);
                    line.Info = line_name.Substring(index + 1, line_name.LastIndexOf(')') - index - 1);
                    lines.Add(line);
                }
                stat.Lines = lines;
                stats.Add(stat);
            }

            return stats;
        }
        private void llsStats_Tap(object sender, System.Windows.Input.GestureEventArgs e)
        {
            var listSelector = sender as LongListSelector;
            if (listSelector.SelectedItem == null)
                return;
            m_selectedStat = listSelector.SelectedItem as Station;

            NavigationService.Navigate(new Uri("/StatDetailPage.xaml", UriKind.Relative));
        }