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();
        }
Beispiel #2
0
        public static ThemeSI Parse(string str)
        {
            ThemeSI res = new ThemeSI();

            try
            {
                string s = Helpers.HtmlRemoval.StripExtraCodes(str);

                // Question Delimiter
                string QuestionDelemiter = ". ";
                if (s.Contains("10.")
                    && s.Contains("20.")
                    && s.Contains("30.")
                    && s.Contains("40.")
                    && s.Contains("50."))
                {
                    QuestionDelemiter = "0. ";
                }
                if(!(s.Contains("1"+QuestionDelemiter)
                    && s.Contains("2"+QuestionDelemiter)
                    && s.Contains("3"+QuestionDelemiter)
                    && s.Contains("4"+QuestionDelemiter)
                    && s.Contains("5"+QuestionDelemiter)))
                {
                    return null;
                }

                // URL, DESCR
                string a = Substring(s, "<a ", "</a>", true);
                string url = Substring(a, "href=\"", "\">");
                string descr = Substring(a, "\">", "</a>");

                res.url = url;
                res.description = descr;

                // cut start
                s = s.Substring(s.IndexOf("<strong>Вопрос"));

                // theme name
                string n = Substring(s, "</strong>", " 1" + QuestionDelemiter);
                if (n.Contains("<br>"))
                    n = n.Substring(0, n.IndexOf("<br>"));
                res.name = n;

                //questions
                string qs = Substring(s, n, "div class='collapsible collapsed'>");
                for (int i = 1; i < 6; i++)
                {
                    string q = Substring(qs, i.ToString() + QuestionDelemiter, "<");
                    res.Questions.Add(q);
                }

                // cut start
                s = s.Substring(s.IndexOf("<strong>Ответ:</strong>"));
                s = s.Replace("[Аукцион.]", "");
                s = s.Replace("(Аукцион.)", "");

                // answers
                for (int i = 1; i < 6; i++)
                {
                    string q = Substring(s, i.ToString() + QuestionDelemiter, "<");
                    res.answers.Add(q);
                }

                if (s.Contains("<strong>Источник(и):</strong>"))
                {
                    res.source = Helpers.HtmlRemoval.StripTagsCharArray(Substring(s, "<strong>Источник(и):</strong>", "</p>"));
                }
                if (s.Contains("<strong>Автор:</strong>"))
                {
                    res.source = Helpers.HtmlRemoval.StripTagsCharArray(Substring(s, "<strong>Автор:</strong>", "</p>"));
                }
                if (s.Contains("<strong>Авторы:</strong>"))
                {
                    res.source = Helpers.HtmlRemoval.StripTagsCharArray(Substring(s, "<strong>Авторы:</strong>", "</p>"));
                }
            }
            catch (Exception)
            {
                return null;
            }
            return res;
        }
Beispiel #3
0
        public static ThemeSI Parse(string str)
        {
            ThemeSI res = new ThemeSI();

            try
            {
                string s = Helpers.HtmlRemoval.StripExtraCodes(str);

                // Question Delimiter
                string QuestionDelemiter = ". ";
                if (s.Contains("10.") &&
                    s.Contains("20.") &&
                    s.Contains("30.") &&
                    s.Contains("40.") &&
                    s.Contains("50."))
                {
                    QuestionDelemiter = "0. ";
                }
                if (!(s.Contains("1" + QuestionDelemiter) &&
                      s.Contains("2" + QuestionDelemiter) &&
                      s.Contains("3" + QuestionDelemiter) &&
                      s.Contains("4" + QuestionDelemiter) &&
                      s.Contains("5" + QuestionDelemiter)))
                {
                    return(null);
                }

                // URL, DESCR
                string a     = Substring(s, "<a ", "</a>", true);
                string url   = Substring(a, "href=\"", "\">");
                string descr = Substring(a, "\">", "</a>");

                res.url         = url;
                res.description = descr;

                // cut start
                s = s.Substring(s.IndexOf("<strong>Вопрос"));

                // theme name
                string n = Substring(s, "</strong>", " 1" + QuestionDelemiter);
                if (n.Contains("<br>"))
                {
                    n = n.Substring(0, n.IndexOf("<br>"));
                }
                res.name = n;

                //questions
                string qs = Substring(s, n, "div class='collapsible collapsed'>");
                for (int i = 1; i < 6; i++)
                {
                    string q = Substring(qs, i.ToString() + QuestionDelemiter, "<");
                    res.Questions.Add(q);
                }

                // cut start
                s = s.Substring(s.IndexOf("<strong>Ответ:</strong>"));
                s = s.Replace("[Аукцион.]", "");
                s = s.Replace("(Аукцион.)", "");

                // answers
                for (int i = 1; i < 6; i++)
                {
                    string q = Substring(s, i.ToString() + QuestionDelemiter, "<");
                    res.answers.Add(q);
                }

                if (s.Contains("<strong>Источник(и):</strong>"))
                {
                    res.source = Helpers.HtmlRemoval.StripTagsCharArray(Substring(s, "<strong>Источник(и):</strong>", "</p>"));
                }
                if (s.Contains("<strong>Автор:</strong>"))
                {
                    res.source = Helpers.HtmlRemoval.StripTagsCharArray(Substring(s, "<strong>Автор:</strong>", "</p>"));
                }
                if (s.Contains("<strong>Авторы:</strong>"))
                {
                    res.source = Helpers.HtmlRemoval.StripTagsCharArray(Substring(s, "<strong>Авторы:</strong>", "</p>"));
                }
            }
            catch (Exception)
            {
                return(null);
            }
            return(res);
        }