コード例 #1
0
        private void InitializeOlympiadListView()
        {
            bool colorflag = false;

            OlympiadList.Clear();
            foreach (var olympiad in Olympiads)
            {
                var listViewItem = new ListViewItem
                {
                    Content = new TextBlock {
                        Text = olympiad.Name, TextWrapping = TextWrapping.WrapWholeWords
                    },
                    Background = colorflag ? new SolidColorBrush(Colors.LightBlue) : new SolidColorBrush(Colors.Azure),
                    Tag        = olympiad
                };

                colorflag            = !colorflag;
                listViewItem.Tapped += ListView_Tapped;

                OlympiadList.Add(listViewItem);
            }

            CurrentOlympiad = OlympiadList.First().Tag as Olympiad;
            Bindings.Update();
        }
コード例 #2
0
        private void ParseOlympiads(HtmlDocument doc, int year)
        {
            // Desine sperare qui hic intras

            var nodes = doc.DocumentNode.SelectNodes("//table[@class='mainTableInfo']/tbody/tr");

            // TODO: save all current olympiad's profiles to a list
            // and then use Olympiad.AddProfiles instead of Olympiad.AddProfile due to perfomance

            foreach (var node in nodes)
            {
                var cols                 = node.ChildNodes;
                int profileNameIndex     = 1;
                int profileSubjectsIndex = 3;
                int profileLevelIndex    = 5;

                // Current row is primary
                if (cols.Count == 11)
                {
                    var name = cols[3].InnerText.Trim();

                    string link = null;
                    try
                    {
                        link = cols[3].FirstChild.Attributes["href"].Value.Trim();
                    }
                    catch
                    {
                        link = "";
                    }

                    profileNameIndex     = 5;
                    profileSubjectsIndex = 7;
                    profileLevelIndex    = 9;

                    var olympiad = new Olympiad(name, link, year);
                    olympiads.Add(olympiad);
                }

                var profile = new Profile(
                    new Tuple <string, string, int> (
                        cols[profileNameIndex].InnerText,
                        cols[profileSubjectsIndex].InnerText,
                        int.Parse(cols[profileLevelIndex].InnerText)
                        ));
                olympiads.Last().AddProfile(profile);
            }
        }
コード例 #3
0
        private void ListView_Tapped(object sender, TappedRoutedEventArgs e)
        {
            CurrentOlympiad = (sender as ListViewItem)?.Tag as Olympiad;

            Bindings.Update();
        }