/
Settings.xaml.cs
171 lines (154 loc) · 6.82 KB
/
Settings.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
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
//-----------------------------------------------------------------------
// <copyright file="Settings.xaml.cs" company="Brave Location">
// Copyright (c) Brave Location Ltd. All rights reserved.
// </copyright>
//-----------------------------------------------------------------------
namespace Com.BraveLocation.BedsideClock
{
using System;
using System.Collections.Generic;
using System.IO;
using System.Linq;
using System.Net;
using System.Reflection;
using System.Windows;
using System.Windows.Controls;
using System.Windows.Documents;
using System.Windows.Input;
using System.Windows.Media;
using System.Windows.Media.Animation;
using System.Windows.Shapes;
using Microsoft.Phone.Controls;
using Microsoft.Phone.Tasks;
/// <summary>
/// Settings page
/// </summary>
public partial class Settings : PhoneApplicationPage
{
/// <summary>
/// User settings
/// </summary>
private UserSettings userSettings = new UserSettings();
/// <summary>
/// Initializes a new instance of the Settings class
/// </summary>
public Settings()
{
this.InitializeComponent();
this.DimmedSwitch.IsChecked = this.userSettings.Dimmed;
this.DimmedSwitch.Checked += new EventHandler<RoutedEventArgs>(this.DimmedSwitch_Changed);
this.DimmedSwitch.Unchecked += new EventHandler<RoutedEventArgs>(this.DimmedSwitch_Changed);
this.LocationSwitch.IsChecked = this.userSettings.ShowLocation;
this.LocationSwitch.Checked += new EventHandler<RoutedEventArgs>(this.LocationSwitch_Changed);
this.LocationSwitch.Unchecked += new EventHandler<RoutedEventArgs>(this.LocationSwitch_Changed);
this.WeatherSwitch.IsChecked = this.userSettings.ShowWeather;
this.WeatherSwitch.Checked += new EventHandler<RoutedEventArgs>(this.WeatherSwitch_Changed);
this.WeatherSwitch.Unchecked += new EventHandler<RoutedEventArgs>(this.WeatherSwitch_Changed);
this.MoonSwitch.IsChecked = this.userSettings.ShowMoon;
this.MoonSwitch.Checked += new EventHandler<RoutedEventArgs>(this.MoonSwitch_Changed);
this.MoonSwitch.Unchecked += new EventHandler<RoutedEventArgs>(this.MoonSwitch_Changed);
}
/// <summary>
/// Overrides the default back button behavior to ensure new settings are picked up
/// </summary>
/// <param name="e">Event arguments</param>
protected override void OnBackKeyPress(System.ComponentModel.CancelEventArgs e)
{
// Force a navigation reload of the main screen, to ensure new settings are picked up
NavigationService.Navigate(new Uri("/MainPage.xaml", UriKind.Relative));
e.Cancel = true; // Cancels the default behavior.
}
/// <summary>
/// Event handler of click on the feedback button
/// </summary>
/// <param name="sender">Object sender</param>
/// <param name="e">Event arguments</param>
private void FeedbackButton_Click(object sender, RoutedEventArgs e)
{
EmailComposeTask task = new EmailComposeTask();
task.To = "feedback@BraveLocation.com";
task.Subject = "Bedside Clock Feedback";
task.Show();
}
/// <summary>
/// Event handler for click on about button
/// </summary>
/// <param name="sender">Object sender</param>
/// <param name="e">Event arguments</param>
private void AboutButton_Click(object sender, RoutedEventArgs e)
{
WebBrowserTask task = new WebBrowserTask();
task.Uri = new Uri("http://www.BraveLocation.com");
task.Show();
}
/// <summary>
/// Event handler for click on privacy button
/// </summary>
/// <param name="sender">Object sender</param>
/// <param name="e">Event arguments</param>
private void PrivacyButton_Click(object sender, RoutedEventArgs e)
{
WebBrowserTask task = new WebBrowserTask();
task.Uri = new Uri("http://info.yahoo.com/privacy/us/yahoo/devel/details.html");
task.Show();
}
/// <summary>
/// Event handler for click on Yahoo Weather button
/// </summary>
/// <param name="sender">Object sender</param>
/// <param name="e">Event arguments</param>
private void YahooWeatherButton_Click(object sender, RoutedEventArgs e)
{
WebBrowserTask task = new WebBrowserTask();
task.Uri = new Uri("http://weather.yahoo.com");
task.Show();
}
/// <summary>
/// Event handler for click on "Elliot" button
/// </summary>
/// <param name="sender">Object sender</param>
/// <param name="e">Event arguments</param>
private void ElliottButton_Click(object sender, RoutedEventArgs e)
{
WebBrowserTask task = new WebBrowserTask();
task.Uri = new Uri("http://www.gavinelliott.co.uk/2010/04/free-weather-icons/");
task.Show();
}
/// <summary>
/// Event handler for when location switch changes
/// </summary>
/// <param name="sender">Object sender</param>
/// <param name="e">Event arguments</param>
private void LocationSwitch_Changed(object sender, RoutedEventArgs e)
{
this.userSettings.ShowLocation = this.LocationSwitch.IsChecked.Value;
}
/// <summary>
/// Event handler for when weather switch changes
/// </summary>
/// <param name="sender">Object sender</param>
/// <param name="e">Event arguments</param>
private void WeatherSwitch_Changed(object sender, RoutedEventArgs e)
{
this.userSettings.ShowWeather = this.WeatherSwitch.IsChecked.Value;
}
/// <summary>
/// Event handler for when moon switch changes
/// </summary>
/// <param name="sender">Object sender</param>
/// <param name="e">Event arguments</param>
private void MoonSwitch_Changed(object sender, RoutedEventArgs e)
{
this.userSettings.ShowMoon = this.MoonSwitch.IsChecked.Value;
}
/// <summary>
/// Event handler for when dimmed switch changes
/// </summary>
/// <param name="sender">Object sender</param>
/// <param name="e">Event arguments</param>
private void DimmedSwitch_Changed(object sender, RoutedEventArgs e)
{
this.userSettings.Dimmed = this.DimmedSwitch.IsChecked.Value;
}
}
}