public SIGameQuestion() { InitializeComponent(); tb[0] = edtPoints10; tb[1] = edtPoints20; tb[2] = edtPoints30; tb[3] = edtPoints40; tb[4] = edtPoints50; if (GameSI.Instance.Themes.Count == 0) { NavigationService.Navigate(new Uri(@"/MainPage.xaml", UriKind.Relative)); } index = GameSI.Instance.CurrentIndex; q = GameSI.Instance.Themes[index]; edtTheme.Text = "ТЕМА №" + (index + 1).ToString() + ": " + q.name; timer.Interval = TimeSpan.FromSeconds(1); timer.Tick += OnTimerTick; BindQuestion(); }
private void QuestionsDownloadStringCompleted(object sender, DownloadStringCompletedEventArgs e) { if (e.Error != null) { MessageBox.Show("Ошибка подключения к базе вопросов. Проверьте соединение с интернетом."); NavigationService.Navigate(new Uri(@"/MainPage.xaml", UriKind.Relative)); return; } HtmlNode.ElementsFlags.Remove("option"); HtmlDocument doc = new HtmlDocument(); doc.LoadHtml(e.Result); if (!doc.DocumentNode.InnerHtml.Contains("random_question")) { MessageBox.Show("Вопросов не найдено!"); NavigationService.Navigate(new Uri(@"/MainPage.xaml", UriKind.Relative)); return; } var foos = from foo in doc.DocumentNode.SelectNodes("//div[@class='random_question']") select foo; foreach (HtmlNode random_question in foos) { ThemeSI th = GameSI.Parse(random_question.InnerHtml); if (th != null) { GameSI.Instance.Themes.Add(th); } } // stop progress bar ShowProgress = false; ContentPanel.Visibility = System.Windows.Visibility.Visible; // redirect to game NavigationService.Navigate(new Uri(@"/Games/si/SIGameQuestion.xaml", UriKind.Relative)); }