public static List <Problem> ReadProblemsAll(Contest contest)
        {
            List <Problem> problems = new List <Problem>();
            string         page     = string.Empty;

            using (WebClient wc = new WebClient())
            {
                wc.Init();
                Console.WriteLine(contest.Url + "/problems");
                page = wc.DownloadString(contest.Url + "/problems");
            }
            List <string> titles  = page.ParseHtml(@"<div class=""title"">", @"</div>");
            List <string> inputs  = page.ParseHtml(@"<div class=""title"">Input</div><pre>", "</pre>");
            List <string> outputs = page.ParseHtml(@"<div class=""title"">Output</div><pre>", "</pre>");

            for (int i = 0, j = 0; i < titles.Count && j < inputs.Count;)
            {
                Problem problem = new Problem();
                problem.Name = titles[i].Trim();
                while (++i < titles.Count && (titles[i] == "Input" || titles[i] == "Output"))
                {
                    if (titles[i] == "Input")
                    {
                        TestCase tc = new TestCase();
                        tc.Input  = inputs[j].Replace(@"<br />", @"\n");
                        tc.Output = outputs[j].Replace(@"<br />", @"\n");
                        problem.TestCases.Add(tc);

                        ++j;
                    }
                }
                problems.Add(problem);
            }

            return(problems);
        }
        public ProblemCdt(Problem problem, Contest contest)
        {
            p = problem;
            c = contest;

            GenerateCommand = new IDelegateCommand((obj) =>
            {
                var app  = Connect.applicationObject;
                var ps   = ProblemsViewModel.Instance;
                var proj = app.GetActiveProject();
                if (proj == null)
                {
                    string msg = "first open a project please !";
                    if (ps.Status.Contains(msg))
                    {
                        ps.Status = ps.Status + "!";
                    }
                    else
                    {
                        ps.Status = msg;
                    }
                    return;
                }
                string folder = System.IO.Path.GetDirectoryName(proj.FullName);
                folder        = System.IO.Path.Combine(folder, c.Name.SafePath());
                if (!Directory.Exists(folder))
                {
                    Directory.CreateDirectory(folder);
                }

                foreach (ProjectItem pi in proj.ProjectItems)
                {
                    if (pi.Name == p.Name.SafePath())
                    {
                        pi.Remove();
                    }
                }

                string cpp      = System.IO.Path.Combine(folder, p.Name.SafePath() + ".cpp");
                StreamWriter sw = new StreamWriter(cpp, false);
                WriteTemplate(sw);
                sw.Close();

                proj.ProjectItems.AddFromFile(cpp).Open();
            });

            ShowInBrowser = new IDelegateCommand((obj) =>
            {
                bool exception_accured = false;
                string browser         = string.Empty;
                try
                {
                    browser = "chrome";
                    System.Diagnostics.Process.Start(new System.Diagnostics.ProcessStartInfo("chrome.exe", c.Url + "/problem/" + p.Name.First()));
                }
                catch (Exception e)
                {
                    ProblemsViewModel.Instance.Status = e.Message;
                    try{
                        browser = "ie";
                        System.Diagnostics.Process.Start(new System.Diagnostics.ProcessStartInfo("explorer.exe", c.Url + "/problem/" + p.Name.First()));
                    }catch (Exception e2) {
                        ProblemsViewModel.Instance.Status = e2.Message;
                        exception_accured = true;
                    }
                }
                if (!exception_accured)
                {
                    ProblemsViewModel.Instance.Status = p.Name + " launched in " + browser + " .";
                }
            });
        }