-
Notifications
You must be signed in to change notification settings - Fork 0
/
EnterName.xaml.cs
61 lines (54 loc) · 1.78 KB
/
EnterName.xaml.cs
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
/// FILE : EnterName.xaml.cs
/// PROJECT : RDA4
/// PROGRAMMER : Elizabeth deVries
/// FIRST VERSION : 2021-12-09
/// DESCRIPTION : This is the first screen of the RDA4 quiz game. It takes the user's name and does not start the game
/// : until a name is entered. The name can be any characters as long as it is not blank.
///
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows;
using System.Windows.Controls;
using System.Windows.Data;
using System.Windows.Documents;
using System.Windows.Input;
using System.Windows.Media;
using System.Windows.Media.Imaging;
using System.Windows.Navigation;
using System.Windows.Shapes;
namespace SQLQuiz
{
/// <summary>
/// Interaction logic for EnterName.xaml
/// </summary>
public partial class EnterName : Page
{
public EnterName()
{
InitializeComponent();
}
private void submitName_Click(object sender, RoutedEventArgs e)
{
// see if the name is empty after being trimmed of whitespace
string name = nameField.Text;
name = name.Trim();
// if yes, send name to data layer and play game
if (name != "")
{
// insert player
DatabaseConnector playerInsert = new DatabaseConnector();
Player newPlayer = playerInsert.InsertPlayer(name);
// go to play game
this.NavigationService.Navigate(new PlayGame(newPlayer));
}
// if not, warn user
else
{
MessageBox.Show("Sorry, you must enter a user name to continue!");
}
}
}
}