예제 #1
0
 public ContestCdt(Contest contest)
 {
     c            = contest;
     CheckCommand = new IDelegateCommand((object obj) =>
     {
         MainWindow.Instance.Dispatcher.InvokeAsync(() =>
         {
             var cs                 = ContestsViewModel.Instance;
             cs.Status              = "checking for problems ...";
             CheckCommand.CanExec   = false;
             bool exception_accured = false;
             try
             {
                 List <Problem> probs = WebReader.ReadProblemsAll(c);
                 var col = ProblemsViewModel.Instance.Problems;
                 col.Clear();
                 for (int i = 0; i < probs.Count; ++i)
                 {
                     col.Add(new ProblemCdt(probs[i], c));
                 }
             }
             catch (Exception e)
             {
                 cs.Status = e.Message;
             }
             CheckCommand.CanExec = true;
             if (!exception_accured)
             {
                 cs.Status = "checking problems finished :)";
                 ProblemsViewModel.Instance.Status = "problems for " + c.Name;
             }
         });
     });
 }
예제 #2
0
 public ContestsViewModel()
 {
     Instance     = this;
     Contests     = new ObservableCollection <ContestCdt>();
     CheckCommand = new IDelegateCommand((obj) =>
     {
         MainWindow.Instance.Dispatcher.InvokeAsync(() =>
         {
             Status                 = "checking contests ...";
             CheckBtnContent        = "checking ...";
             bool exception_occured = false;
             try
             {
                 CheckCommand.CanExec = false;
                 var contests         = WebReader.ReadContestsAll("http://codeforces.com/contests");
                 var collection       = ContestsViewModel.Instance.Contests;
                 collection.Clear();
                 for (int i = 0; i < contests.Count; ++i)
                 {
                     collection.Add(new ContestCdt(contests[i]));
                 }
             }
             catch (Exception e)
             {
                 Status            = e.Message;
                 exception_occured = true;
             }
             if (!exception_occured)
             {
                 Status = "checking contests finished :)";
             }
             CheckBtnContent      = "check !";
             CheckCommand.CanExec = true;
         });
     });
 }