-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathMainPage.xaml.cs
144 lines (129 loc) · 5.52 KB
/
MainPage.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
using System;
using System.Collections.Generic;
using System.IO;
using System.Linq;
using System.Runtime.InteropServices.WindowsRuntime;
using Windows.Foundation;
using Windows.Foundation.Collections;
using Windows.UI.Xaml;
using Windows.UI.Xaml.Controls;
using Windows.UI.Xaml.Controls.Primitives;
using Windows.UI.Xaml.Data;
using Windows.UI.Xaml.Input;
using Windows.UI.Xaml.Media;
using Windows.UI.Xaml.Navigation;
using Windows.UI.Popups;
// The Blank Page item template is documented at https://go.microsoft.com/fwlink/?LinkId=402352&clcid=0x409
namespace covid_19_risk_calculator
{
/// <summary>
/// An empty page that can be used on its own or navigated to within a Frame.
/// </summary>
public sealed partial class MainPage : Page
{
int times_pressed = 1;
int number_of_people_for_int;
string temp_no_people;
bool there_are_symptoms = false;
bool high_risk_places = false;
bool medium_risk_places = false;
bool low_risk_places = false;
public MainPage()
{
this.InitializeComponent();
educational_video.Position = TimeSpan.FromSeconds(0);
educational_video.Play();
}
public void video_start(int times_pressed)
{
if (times_pressed % 2 == 0)
educational_video.Pause();
else
educational_video.Play();
}
private void number_of_people_GotFocus(object sender, RoutedEventArgs e)
{
number_of_people.Text = "";
}
private void educational_video_Tapped(object sender, TappedRoutedEventArgs e)
{
times_pressed++;
video_start(times_pressed);
}
private void calculate_risk_button_Tapped(object sender, TappedRoutedEventArgs e)
{
try
{
// Evaluate prevention strategies
if (fully_vaccinated.IsChecked == true)
result.risk_scale -= 10;
if (mask_wore.IsChecked == true)
result.risk_scale -= 5;
if (not_fully_vaccinated.IsChecked == true)
result.risk_scale += 3;
if (no_mask.IsChecked == true)
result.risk_scale += 10;
//Evaluate outdoor or indoor activity
if (outdoor_activity.IsChecked == true)
result.risk_scale += 5;
if (indoor_activity.IsChecked == true)
result.risk_scale += 3;
//Evaluate the number of people
temp_no_people = number_of_people.Text;
number_of_people_for_int = Int32.Parse(temp_no_people);
if (number_of_people_for_int > 5)
{
result.risk_scale += 5;
}
else if (number_of_people_for_int > 10)
{
result.risk_scale += 10;
}
else if (number_of_people_for_int > 20)
{
result.risk_scale += 20;
}
//Evaluate the symptoms
if (fever_chckbox.IsChecked == true || fatigue_chckbox.IsChecked == true || shortness_of_breath_chckbox.IsChecked == true
|| muscle_or_body_aches_chckbox.IsChecked == true || headche_chckbox.IsChecked == true || loss_of_taste_chckbox.IsChecked == true
|| sore_throat_chckbox.IsChecked == true || vomitting_chckbox.IsChecked == true) { there_are_symptoms = true; }
if ((there_are_symptoms && runny_nose_chckbox.IsChecked == true) || (there_are_symptoms))
{
result.risk_scale += 50;
}
if (runny_nose_chckbox.IsChecked == true)
{
result.risk_scale += 15;
}
//Evaluate social distancing
if (social_distancing.IsChecked == true)
{
result.risk_scale -= 5;
}
if (no_social_distancing.IsChecked == true)
{
result.risk_scale += 10;
}
//Evaluate places
if (Hospital.IsChecked == true || religious_place.IsChecked == true || government_building.IsChecked == true || Funeral.IsChecked == true)
{ high_risk_places = true; }
if (Gym.IsChecked == true || Sports.IsChecked == true || restaurant.IsChecked == true || Hotel.IsChecked == true || other_outdoor_place.IsChecked == true)
{ medium_risk_places = true; }
if (School.IsChecked == true || Library.IsChecked == true || other_indoor_place.IsChecked == true) { low_risk_places = true; }
if (high_risk_places) { result.risk_scale += 35; }
if (medium_risk_places) { result.risk_scale += 25; }
if (low_risk_places) { result.risk_scale += 15; }
this.Frame.Navigate(typeof(result));
} catch (Exception ex)
{
var dialog = new MessageDialog("Please fill out all the information except symptoms if you do not experience any symptoms.");
dialog.ShowAsync();
}
}
private void about_us_button_Tapped(object sender, TappedRoutedEventArgs e)
{
var dialog = new MessageDialog("COVID-19 Risk Calculator by Deniz K. Acikbas and Hoang Nguyen. Resources: Nucleus Media, CDC");
dialog.ShowAsync();
}
}
}