public void AddTime(string time) { int hours = 0, minutes = 0, seconds = 0; TimeSpan addedTime, totTime; var words = time.Split(':'); hours = Convert.ToInt32(words[0]); minutes = Convert.ToInt32(words[1]); seconds = Convert.ToInt32(words[2]); addedTime = new TimeSpan(hours, minutes, seconds); words = TotalTime.Split(':'); hours = Convert.ToInt32(words[0]); minutes = Convert.ToInt32(words[1]); seconds = Convert.ToInt32(words[2]); totTime = new TimeSpan(hours, minutes, seconds); totalTime = (totTime + addedTime).ToString(); }
private async void ResultForm_Load(object sender, EventArgs e) { pictureBox2.Visible = false; label1.MaximumSize = new Size(this.Width - leftIndent, this.Height); label2.MaximumSize = new Size(this.Width - leftIndent, this.Height); label3.MaximumSize = new Size(this.Width - leftIndent, this.Height); var result = String.Empty; if (Surrender.HasValue && Surrender.Value) { label3.Text = string.Format(WinMessage, UserProfile.RivalName); label1.Visible = false; label2.Text = SurrenderMassage; result = "Won"; } else if (RivalExited.HasValue && RivalExited.Value) { label3.Text = string.Format(WinMessage, UserProfile.RivalName); label1.Visible = false; label2.Text = RivalExitedMessage; result = "Won"; } else if (TimeOver.HasValue && TimeOver.Value == true) { label3.Text = TimeOverMessage; label2.Visible = false; label1.Visible = false; } else { var userTime = TotalTime.Split(':'); var userMinutes = Convert.ToInt32(userTime[0]); var userSeconds = Convert.ToInt32(userTime[1]); var userTotalSeconds = userMinutes * 60 + userSeconds; var rivalTime = RivalTotalTime.Split(':'); var rivalMinutes = Convert.ToInt32(rivalTime[0]); var rivalSeconds = Convert.ToInt32(rivalTime[1]); var rivalTotalSeconds = rivalMinutes * 60 + rivalSeconds; label1.Text = string.Format(UserTemplateMessage, TotalTime, TotalPoints); label2.Text = string.Format(RivalTemplateMessage, RivalTotalTime, RivalTotalPoints); if (TotalPoints > RivalTotalPoints || (TotalPoints == RivalTotalPoints && userTotalSeconds < rivalTotalSeconds)) { label3.Text = string.Format(WinMessage, UserProfile.RivalName); result = "Won"; } else if (TotalPoints == RivalTotalPoints && userTotalSeconds == rivalTotalSeconds) { label3.Text = string.Format(DrawMessage, UserProfile.RivalName); result = "Draw"; } else { label3.Text = string.Format(LoseMessage, UserProfile.RivalName); result = "Lost"; } } await gameSessionService.AddResultToGameSessionUser(UserProfile.GamaSessionId, UserProfile.Id, result); }