|
0
|
1 |
using System; |
|
|
2 |
using System.Collections.Generic; |
|
|
3 |
using System.Linq; |
|
|
4 |
using System.Net; |
|
|
5 |
using System.Windows; |
|
|
6 |
using System.Windows.Controls; |
|
|
7 |
using System.Windows.Documents; |
|
|
8 |
using System.Windows.Input; |
|
|
9 |
using System.Windows.Media; |
|
|
10 |
using System.Windows.Media.Animation; |
|
|
11 |
using System.Windows.Shapes; |
|
4
|
12 |
using System.Threading; |
|
|
13 |
using System.Globalization; |
|
6
|
14 |
using System.Resources; |
|
|
15 |
using Iri.Modernisation.BaseMVVM.Commands; |
|
0
|
16 |
namespace Iri.Modernisation |
|
|
17 |
{ |
|
|
18 |
public partial class App : Application |
|
|
19 |
{ |
|
|
20 |
|
|
|
21 |
public App() |
|
|
22 |
{ |
|
|
23 |
this.Startup += this.Application_Startup; |
|
|
24 |
this.Exit += this.Application_Exit; |
|
|
25 |
this.UnhandledException += this.Application_UnhandledException; |
|
6
|
26 |
Commands.FlipView.Executed += new EventHandler<SLExtensions.Input.ExecutedEventArgs>(FlipView_Executed); |
|
|
27 |
InitializeComponent(); |
|
|
28 |
} |
|
0
|
29 |
|
|
6
|
30 |
void FlipView_Executed(object sender, SLExtensions.Input.ExecutedEventArgs e) |
|
|
31 |
{ |
|
|
32 |
CultureInfo culture = new CultureInfo("en-US"); |
|
|
33 |
Thread.CurrentThread.CurrentCulture = culture; |
|
|
34 |
Thread.CurrentThread.CurrentUICulture = culture; |
|
|
35 |
|
|
|
36 |
this.RootVisual = new MainPage(); |
|
0
|
37 |
} |
|
|
38 |
|
|
|
39 |
private void Application_Startup(object sender, StartupEventArgs e) |
|
|
40 |
{ |
|
6
|
41 |
//CultureInfo culture = new CultureInfo("en-US"); |
|
|
42 |
//Thread.CurrentThread.CurrentCulture = culture; |
|
|
43 |
//Thread.CurrentThread.CurrentUICulture = culture; |
|
|
44 |
|
|
0
|
45 |
this.RootVisual = new MainPage(); |
|
6
|
46 |
|
|
0
|
47 |
} |
|
|
48 |
|
|
|
49 |
private void Application_Exit(object sender, EventArgs e) |
|
|
50 |
{ |
|
|
51 |
|
|
|
52 |
} |
|
|
53 |
private void Application_UnhandledException(object sender, ApplicationUnhandledExceptionEventArgs e) |
|
|
54 |
{ |
|
|
55 |
// If the app is running outside of the debugger then report the exception using |
|
|
56 |
// the browser's exception mechanism. On IE this will display it a yellow alert |
|
|
57 |
// icon in the status bar and Firefox will display a script error. |
|
|
58 |
if (!System.Diagnostics.Debugger.IsAttached) |
|
|
59 |
{ |
|
|
60 |
|
|
|
61 |
// NOTE: This will allow the application to continue running after an exception has been thrown |
|
|
62 |
// but not handled. |
|
|
63 |
// For production applications this error handling should be replaced with something that will |
|
|
64 |
// report the error to the website and stop the application. |
|
|
65 |
e.Handled = true; |
|
|
66 |
Deployment.Current.Dispatcher.BeginInvoke(delegate { ReportErrorToDOM(e); }); |
|
|
67 |
} |
|
|
68 |
} |
|
|
69 |
private void ReportErrorToDOM(ApplicationUnhandledExceptionEventArgs e) |
|
|
70 |
{ |
|
|
71 |
try |
|
|
72 |
{ |
|
|
73 |
string errorMsg = e.ExceptionObject.Message + e.ExceptionObject.StackTrace; |
|
|
74 |
errorMsg = errorMsg.Replace('"', '\'').Replace("\r\n", @"\n"); |
|
|
75 |
|
|
|
76 |
System.Windows.Browser.HtmlPage.Window.Eval("throw new Error(\"Unhandled Error in Silverlight Application " + errorMsg + "\");"); |
|
|
77 |
} |
|
|
78 |
catch (Exception) |
|
|
79 |
{ |
|
|
80 |
} |
|
|
81 |
} |
|
|
82 |
} |
|
|
83 |
} |