public static void TimerCompleted(object stateInfo) { // get its owner class UserTimer timer = (UserTimer)stateInfo; // we want to check to see if we want to stop the timer if (timer.CancelTimer == true) { // stop this timer timer.CooldownTimer.Dispose(); // remove this from the cooldownlist _CooldownList.Remove(timer); Console.WriteLine("Timer stopped. Found player"); } else if (timer.CooldownEnding <= DateTime.Now) { // nobody attacked the player // stop this timer timer.CooldownTimer.Dispose(); // remove this from the cooldownlist _CooldownList.Remove(timer); // here, do stuff that you would need to do to cancel the deul Console.WriteLine("Timer stopped. Player not found."); Database.AddCoins(p1, 10); Bot.SendTextMessageAsync(dieid, "Nobody joined your game. Refunded your coins."); p1 = 0; } }
public frmQuestion3b() { InitializeComponent(); // This will tell the system that this form has been completed. Globalvariables.CompletedQuestionsB[2] = true; Globalvariables.form += 1; //Start Timers UserTimer.Start(); DragcheckTimer.Start(); ErrorClock.Start(); lblTime.Text = "Timer : " + Convert.ToString(Globalvariables.timer); // This will make a smoother transition between forms. switch (Globalvariables.Character) { case 1: { pictureCharacter.Image = Properties.Resources.CharacterPlaceholder; // Displays 1st image pictureCharacter.SizeMode = PictureBoxSizeMode.Zoom; } break; case 2: { pictureCharacter.Image = Properties.Resources.CharacterPlaceholder2; // 2nd image pictureCharacter.SizeMode = PictureBoxSizeMode.Zoom; } break; case 3: { pictureCharacter.Image = Properties.Resources.NeilArmstrong; // 3rd image pictureCharacter.SizeMode = PictureBoxSizeMode.Zoom; } break; case 4: { pictureCharacter.Image = Properties.Resources.Predator2; // 4th image pictureCharacter.SizeMode = PictureBoxSizeMode.Zoom; } break; } // Display player name lblPlayerName.Text = Globalvariables.username; // Display player score lblScore.Text = Convert.ToString(Globalvariables.points); // Allow drop for the image boxes pbDropMars.AllowDrop = true; pbDropVenus.AllowDrop = true; pbDropNeptune.AllowDrop = true; pbDropJupiter.AllowDrop = true; pbDropUranus.AllowDrop = true; }
private static void RefreshTimer(User user) { if (user != null) { UserTimer u = LoggedInUsers.FirstOrDefault(ut => ut.user.Username == user.Username); if (u != null) { u.timer = 0; } } }
private void UserTimer_Elapsed(object sender, ElapsedEventArgs e) { //shows timer message in blue color Console.ForegroundColor = ConsoleColor.Blue; //stops timer UserTimer.Stop(); //lets user know timer has finished Console.WriteLine("\nDing! Your timer has ended."); }
public frmQuestion7b() { InitializeComponent(); // Start timer UserTimer.Start(); lblTime.Text = "Timer : " + Convert.ToString(Globalvariables.timer); // This will make a smoother transition between forms. // This code should tell the systme that this form has been used. Globalvariables.CompletedQuestionsB [6] = true; Globalvariables.form += 1; // This will check to see which character image the user has selected, and then display it within this form. switch (Globalvariables.Character) { case 1: { pictureCharacter.Image = Properties.Resources.CharacterPlaceholder; // Displays 1st image pictureCharacter.SizeMode = PictureBoxSizeMode.Zoom; } break; case 2: { pictureCharacter.Image = Properties.Resources.CharacterPlaceholder2; // 2nd image pictureCharacter.SizeMode = PictureBoxSizeMode.Zoom; } break; case 3: { pictureCharacter.Image = Properties.Resources.NeilArmstrong; // 3rd image pictureCharacter.SizeMode = PictureBoxSizeMode.Zoom; } break; case 4: { pictureCharacter.Image = Properties.Resources.Predator2; // 4th image pictureCharacter.SizeMode = PictureBoxSizeMode.Zoom; } break; } // Display player name lblPlayerName.Text = Globalvariables.username; // Display player score lblScore.Text = Convert.ToString(Globalvariables.points); }
public frmQuestion2b() { InitializeComponent(); // This tells the system that this form has been used Globalvariables.CompletedQuestionsB[1] = true; Globalvariables.form += 1; // start timers AnswerCheck.Start(); UserTimer.Start(); ErrorTimer.Start(); lblTime.Text = "Timer : " + Convert.ToString(Globalvariables.timer); // This will make a smoother transition between forms. switch (Globalvariables.Character) { case 1: { pictureCharacter.Image = Properties.Resources.CharacterPlaceholder; // Displays 1st image pictureCharacter.SizeMode = PictureBoxSizeMode.Zoom; } break; case 2: { pictureCharacter.Image = Properties.Resources.CharacterPlaceholder2; // 2nd image pictureCharacter.SizeMode = PictureBoxSizeMode.Zoom; } break; case 3: { pictureCharacter.Image = Properties.Resources.NeilArmstrong; // 3rd image pictureCharacter.SizeMode = PictureBoxSizeMode.Zoom; } break; case 4: { pictureCharacter.Image = Properties.Resources.Predator2; // 4th image pictureCharacter.SizeMode = PictureBoxSizeMode.Zoom; } break; } // Display player name lblPlayerName.Text = Globalvariables.username; // Display player score lblScore.Text = Convert.ToString(Globalvariables.points); }
public frmQuestion3i() { InitializeComponent(); // Tell the system that this form has been used Globalvariables.CompletedQuestionsI[2] = true; Globalvariables.form += 1; // Start timer UserTimer.Start(); lblTime.Text = "Timer : " + Convert.ToString(Globalvariables.timer); // This will make a smoother transition between forms. // Display different character images if (Globalvariables.Character == 1) { pictureCharacter.Image = Properties.Resources.CharacterPlaceholder; // Displays 1st image pictureCharacter.SizeMode = PictureBoxSizeMode.Zoom; } if (Globalvariables.Character == 2) { pictureCharacter.Image = Properties.Resources.CharacterPlaceholder2; // 2nd image pictureCharacter.SizeMode = PictureBoxSizeMode.Zoom; } if (Globalvariables.Character == 3) { pictureCharacter.Image = Properties.Resources.NeilArmstrong; // 3rd image pictureCharacter.SizeMode = PictureBoxSizeMode.Zoom; } if (Globalvariables.Character == 4) { pictureCharacter.Image = Properties.Resources.Predator2; // 4th image pictureCharacter.SizeMode = PictureBoxSizeMode.Zoom; } // Displays player score lblScore.Text = Convert.ToString(Globalvariables.points); // Displays player name lblPlayerName.Text = Globalvariables.username; // Help for this question txtAnswe1.Text = "F"; txtAnswer2.Text = "A"; txtAnswer3.Text = "H"; }
public IActionResult Save(UserTimer entity) { //Validation for UserTimer if (!ModelState.IsValid || entity == null) { return(BadRequest()); } //Calculate total seconds if it is empty if (entity.TotalSeconds == 0 && entity.FinishDate.HasValue) { entity.TotalSeconds = (int)entity.FinishDate.Value.Subtract(entity.StartDate).TotalSeconds; } //Save to DB _context.UserTimers.Add(entity); _context.SaveChanges(); return(Ok(entity)); }
public frmQuestion5i() { InitializeComponent(); // Tell the system that this form has been used Globalvariables.CompletedQuestionsI[4] = true; Globalvariables.form += 1; //Start Timer UserTimer.Start(); Error.Start(); DragcheckTimer.Start(); lblTime.Text = "Timer : " + Convert.ToString(Globalvariables.timer); // This will make a smoother transition between forms. // This will check to see which character image the user has selected, and then display it within this form. switch (Globalvariables.Character) { case 1: { pictureCharacter.Image = Properties.Resources.CharacterPlaceholder; // Displays 1st image pictureCharacter.SizeMode = PictureBoxSizeMode.Zoom; } break; case 2: { pictureCharacter.Image = Properties.Resources.CharacterPlaceholder2; // 2nd image pictureCharacter.SizeMode = PictureBoxSizeMode.Zoom; } break; case 3: { pictureCharacter.Image = Properties.Resources.NeilArmstrong; // 3rd image pictureCharacter.SizeMode = PictureBoxSizeMode.Zoom; } break; case 4: { pictureCharacter.Image = Properties.Resources.Predator2; // 4th image pictureCharacter.SizeMode = PictureBoxSizeMode.Zoom; } break; } // Display player name lblPlayerName.Text = Globalvariables.username; // Display player score lblScore.Text = Convert.ToString(Globalvariables.points); //Enable dropping pbDropMercury.AllowDrop = true; pbDropVenus.AllowDrop = true; pbDropEarth.AllowDrop = true; pbDropMars.AllowDrop = true; pbDropJupiter.AllowDrop = true; pbDropSaturn.AllowDrop = true; pbDropUranus.AllowDrop = true; pbDropNeptune.AllowDrop = true; pbDropPluto.AllowDrop = true; }