-
Notifications
You must be signed in to change notification settings - Fork 0
/
scoreWindow.xaml.cs
153 lines (130 loc) · 4.18 KB
/
scoreWindow.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
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
using System;
using System.Collections.Generic;
using System.Linq;
using System.Media;
using System.Reflection;
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.Shapes;
using System.Windows.Threading;
using System.Xml.Linq;
namespace math_game
{
/// <summary>
/// Interaction logic for scoreWindow.xaml
/// </summary>
public partial class scoreWindow : Window
{
#region Attributes
/// <summary>
/// Holds the players information
/// </summary>
private User _player;
/// <summary>
/// Stores the background music that plays
/// </summary>
private SoundPlayer bgm_scoreWindow;
/// <summary>
/// Holds the errorHandler class
/// </summary>
public errorHandler errorHandler;
#endregion
#region Methods
/// <summary>
/// Holds the User class that gets passed in
/// </summary>
public User Player
{
get
{
try
{
return _player;
}
catch (Exception ex)
{
throw new Exception(MethodInfo.GetCurrentMethod().DeclaringType.Name + " . " +
MethodInfo.GetCurrentMethod().Name + "->" + ex.Message);
}
}
set
{
try
{
_player = value;
}
catch (Exception ex)
{
throw new Exception(MethodInfo.GetCurrentMethod().DeclaringType.Name + " . " +
MethodInfo.GetCurrentMethod().Name + "->" + ex.Message);
}
}
}
/// <summary>
/// Displays the information from the User object
/// </summary>
/// <exception cref="Exception">Throws the information about the method to the higher level methods </exception>
private void showStats()
{
try
{
lbl_playerName.Content = "Name: " + _player.Name;
lbl_playerAge.Content = "Age: " + _player.Age;
lbl_correctAns.Content = "Correct Answers: " + _player.correct;
lbl_incorrectAns.Content = "Incorrect Answers: " + _player.wrong;
lbl_time.Content = "Total Time: " + _player.TotalTime.ToString("ss") + " seconds";
}
catch (Exception ex)
{
throw new Exception(MethodInfo.GetCurrentMethod().DeclaringType.Name + " . " +
MethodInfo.GetCurrentMethod().Name + "->" + ex.Message);
}
}
#endregion
public scoreWindow()
{
InitializeComponent();
}
/// <summary>
/// Class showStats and starts the music when the screen is active
/// </summary>
/// <param name="sender"></param>
/// <param name="e"></param>
private void onOpen(object sender, EventArgs e)
{
try
{
showStats();
bgm_scoreWindow = new SoundPlayer("bgm_scoreWindow.wav");
bgm_scoreWindow.Play();
}
catch (Exception ex)
{
errorHandler.logError(MethodInfo.GetCurrentMethod().DeclaringType.Name, MethodInfo.GetCurrentMethod().Name, ex.Message);
}
}
/// <summary>
/// When the screen becomes background windows music stops playing
/// </summary>
/// <param name="sender"></param>
/// <param name="e"></param>
private void on_deactivate(object sender, EventArgs e)
{
try
{
bgm_scoreWindow.Stop();
}
catch (Exception ex)
{
errorHandler.logError(MethodInfo.GetCurrentMethod().DeclaringType.Name, MethodInfo.GetCurrentMethod().Name, ex.Message);
}
}
}
}