PageRenderTime 29ms CodeModel.GetById 15ms RepoModel.GetById 0ms app.codeStats 0ms

/Samples/Controls/Marquee/Silverlight/Marquee-Silverlight/App.xaml.cs

https://bitbucket.org/suhas_28/sharpfellows.toolkit
C# | 68 lines | 52 code | 9 blank | 7 comment | 1 complexity | 6ef83d08d91e65cffe8cb414e72799ab MD5 | raw file
  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;
  12. namespace Marquee_Silverlight
  13. {
  14. public partial class App : Application
  15. {
  16. public App()
  17. {
  18. this.Startup += this.Application_Startup;
  19. this.Exit += this.Application_Exit;
  20. this.UnhandledException += this.Application_UnhandledException;
  21. InitializeComponent();
  22. }
  23. private void Application_Startup(object sender, StartupEventArgs e)
  24. {
  25. this.RootVisual = new NewsView();
  26. }
  27. private void Application_Exit(object sender, EventArgs e)
  28. {
  29. }
  30. private void Application_UnhandledException(object sender, ApplicationUnhandledExceptionEventArgs e)
  31. {
  32. // If the app is running outside of the debugger then report the exception using
  33. // the browser's exception mechanism. On IE this will display it a yellow alert
  34. // icon in the status bar and Firefox will display a script error.
  35. if (!System.Diagnostics.Debugger.IsAttached)
  36. {
  37. // NOTE: This will allow the application to continue running after an exception has been thrown
  38. // but not handled.
  39. // For production applications this error handling should be replaced with something that will
  40. // report the error to the website and stop the application.
  41. e.Handled = true;
  42. Deployment.Current.Dispatcher.BeginInvoke(delegate { ReportErrorToDOM(e); });
  43. }
  44. }
  45. private void ReportErrorToDOM(ApplicationUnhandledExceptionEventArgs e)
  46. {
  47. try
  48. {
  49. string errorMsg = e.ExceptionObject.Message + e.ExceptionObject.StackTrace;
  50. errorMsg = errorMsg.Replace('"', '\'').Replace("\r\n", @"\n");
  51. System.Windows.Browser.HtmlPage.Window.Eval("throw new Error(\"Unhandled Error in Silverlight Application " + errorMsg + "\");");
  52. }
  53. catch (Exception)
  54. {
  55. }
  56. }
  57. }
  58. }