Exemple #1
0
        public void bDisplay_Click(object sender, RoutedEventArgs e)
        {
            try
            {
                int random = randomizer.Next(displayName.Count());
                if (!string.IsNullOrEmpty(displayName[random]))
                {
                    lDisplayName.Content = displayName[random];
                    displayName.RemoveAt(random);

                    var numberOfStudentsLeft = displayName.Count();
                    if (numberOfStudentsLeft == 0)
                    {
                        MessageBox.Show("All students have participated, click ok to close.", "Completed", MessageBoxButton.OK);
                        System.Windows.Application.Current.Shutdown();
                    }
                }
            }
            catch (ArgumentOutOfRangeException)
            {
                MessageBox.Show("No students found. They need to be added.", "No students found", MessageBoxButton.OK);
                var setClassSize = new ClassSize();
                setClassSize.Show();
            }
            catch (Exception)
            {
                MessageBox.Show("Please contact support at [email protected]", "Unknown Error", MessageBoxButton.OK);
                System.Windows.Application.Current.Shutdown();
            }
        }
        private void bAddNamesHere_Click(object sender, RoutedEventArgs e)
        {
            File.Create(link + @"Names.txt");
            var setClassSize = new ClassSize();

            setClassSize.Show();
            Hide();
        }
      private int setClassSize()
      {
          try
          {
              int.TryParse(tbxSize.Text, out numberOfStudents);
              var x = new AddNames();
              x.Show();
              Hide();
          }
          catch (FormatException)
          {
              MessageBox.Show("You must use numbers.", "Format Exception", MessageBoxButton.OK);
              Close();
              var tryAgain = new ClassSize();
              tryAgain.Show();
          }


          return(numberOfStudents);
      }