Example #1
0
File: Compare.cs Project: TSP5/TSP5
 public Compare(User user, User cowMan, main parent)
 {
     this.user = user;
     this.cowMan = cowMan;
     this.parent = parent;
     InitializeComponent();
     showUpdate();
 }
Example #2
0
File: main.cs Project: TSP5/TSP5
 private void button3_Click_1(object sender, EventArgs e)
 {
     User tmp = getUser();
     if (user == null)
         user = tmp;
     this.panel_Login.SendToBack();
     Compare cp = new Compare(tmp, null, this);
     cp.MdiParent = this;
     cp.Show();
 }
Example #3
0
 private User getCowMan()
 {
     User cowMan = new User();
     this.Enabled = false;
     if (radioButton1.Checked == true)
     {
         cowMan = webService.GetUser(textBox5.Text, progressBar1);
         if (cowMan == null)
         {
             MessageBox.Show("No such cowMan.");
             this.Enabled = true;
             return null;
         }
     }
     else if (radioButton2.Checked == true)
     {
         int Rank;
         try
         {
             Rank = Convert.ToInt32(textBox2.Text);
         }
         catch (Exception)
         {
             MessageBox.Show("Number required.");
             this.Enabled = true;
             return null;
         }
         cowMan = webService.GetUser(webService.GetUserNameByRank(Rank), progressBar1);
         if (cowMan == null)
         {
             MessageBox.Show("No such cowMan.");
             this.Enabled = true;
             return null;
         }
     }
     else if (radioButton3.Checked == true)
     {
         Random random = new Random();
         int rank = random.Next(99);
         rank += 1;
         cowMan = webService.GetUser(webService.GetUserNameByRank(rank), progressBar1);
         while (cowMan.Submissions / cowMan.ProblemsSolved > 20)
         {
             rank = random.Next(99);
             rank += 1;
             cowMan = webService.GetUser(webService.GetUserNameByRank(rank), progressBar1);
         }
     }
     cowMan.Solve = webService.GetAccepted(cowMan.Name, progressBar1);
     this.Enabled = true;
     return cowMan;
 }
Example #4
0
File: main.cs Project: TSP5/TSP5
 private void 登录ToolStripMenuItem_Click(object sender, EventArgs e)
 {
     user = null;
     panel_Login.BringToFront();
 }
Example #5
0
 //根据账号获取用户信息
 public User GetUser(String name, ProgressBar progressBar)
 {
     progressBar.Value = 0;
     Application.DoEvents();
     User user = new User();
     user.Name = name;
     String url = "http://acm.hdu.edu.cn/userstatus.php?user="******"gb2312");
     String Page = this.GetWebContent(url, encode);
     if (Page.Contains("No such user."))
     {
         return null;
     }
     int head, foot;
     head = Page.IndexOf("<td>Rank</td>");
     Page.Remove(0, head);
     foot = Page.IndexOf("</tr>", head);
     head += 30;
     foot -= 5;
     user.Rank = System.Int32.Parse(Page.Substring(head, foot - head));
     head = Page.IndexOf("<td>Problems Submitted</td>", foot);
     foot = Page.IndexOf("</tr>", head);
     head += 44;
     foot -= 5;
     user.ProblemsSubmitted = System.Int32.Parse(Page.Substring(head, foot - head));
     head = Page.IndexOf("<td>Problems Solved</td>", foot);
     foot = Page.IndexOf("</tr>", head);
     head += 41;
     foot -= 5;
     user.ProblemsSolved = System.Int32.Parse(Page.Substring(head, foot - head));
     head = Page.IndexOf("<td>Submissions</td>", foot);
     foot = Page.IndexOf("</tr>", head);
     head += 37;
     foot -= 5;
     user.Submissions = System.Int32.Parse(Page.Substring(head, foot - head));
     head = Page.IndexOf("<td>Accepted</td>", foot);
     foot = Page.IndexOf("</tr>", head);
     head += 34;
     foot -= 5;
     user.Accepted = System.Int32.Parse(Page.Substring(head, foot - head));
     progressBar.Maximum = 50 + user.Accepted;
     Application.DoEvents();
     progressBar.Value += 50;
     Application.DoEvents();
     return user;
 }
Example #6
0
 internal void setlabel4Name(User user)
 {
     this.user = user;
     label4.Text = user.Name;
 }