Crossplatform App der Caritas (Versuch).
您最多选择25个主题 主题必须以字母或数字开头,可以包含连字符 (-),并且长度不得超过35个字符

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106
  1. using System;
  2. using System.Collections.Generic;
  3. using System.IO;
  4. using System.Linq;
  5. using System.Runtime.InteropServices.WindowsRuntime;
  6. using Windows.ApplicationModel;
  7. using Windows.ApplicationModel.Activation;
  8. using Windows.Foundation;
  9. using Windows.Foundation.Collections;
  10. using Windows.UI.Xaml;
  11. using Windows.UI.Xaml.Controls;
  12. using Windows.UI.Xaml.Controls.Primitives;
  13. using Windows.UI.Xaml.Data;
  14. using Windows.UI.Xaml.Input;
  15. using Windows.UI.Xaml.Media;
  16. using Windows.UI.Xaml.Navigation;
  17. namespace CaritasApp.UWP
  18. {
  19. /// <summary>
  20. /// Provides application-specific behavior to supplement the default Application class.
  21. /// </summary>
  22. sealed partial class App : Application
  23. {
  24. /// <summary>
  25. /// Initializes the singleton application object. This is the first line of authored code
  26. /// executed, and as such is the logical equivalent of main() or WinMain().
  27. /// </summary>
  28. public App()
  29. {
  30. this.InitializeComponent();
  31. this.Suspending += OnSuspending;
  32. }
  33. /// <summary>
  34. /// Invoked when the application is launched normally by the end user. Other entry points
  35. /// will be used such as when the application is launched to open a specific file.
  36. /// </summary>
  37. /// <param name="e">Details about the launch request and process.</param>
  38. protected override void OnLaunched(LaunchActivatedEventArgs e)
  39. {
  40. #if DEBUG
  41. if (System.Diagnostics.Debugger.IsAttached)
  42. {
  43. this.DebugSettings.EnableFrameRateCounter = true;
  44. }
  45. #endif
  46. Frame rootFrame = Window.Current.Content as Frame;
  47. // Do not repeat app initialization when the Window already has content,
  48. // just ensure that the window is active
  49. if (rootFrame == null)
  50. {
  51. // Create a Frame to act as the navigation context and navigate to the first page
  52. rootFrame = new Frame();
  53. rootFrame.NavigationFailed += OnNavigationFailed;
  54. global::Xamarin.Forms.Forms.SetFlags("Shell_UWP_Experimental");
  55. Xamarin.Forms.Forms.Init(e);
  56. if (e.PreviousExecutionState == ApplicationExecutionState.Terminated)
  57. {
  58. //TODO: Load state from previously suspended application
  59. }
  60. // Place the frame in the current Window
  61. Window.Current.Content = rootFrame;
  62. }
  63. if (rootFrame.Content == null)
  64. {
  65. // When the navigation stack isn't restored navigate to the first page,
  66. // configuring the new page by passing required information as a navigation
  67. // parameter
  68. rootFrame.Navigate(typeof(MainPage), e.Arguments);
  69. }
  70. // Ensure the current window is active
  71. Window.Current.Activate();
  72. }
  73. /// <summary>
  74. /// Invoked when Navigation to a certain page fails
  75. /// </summary>
  76. /// <param name="sender">The Frame which failed navigation</param>
  77. /// <param name="e">Details about the navigation failure</param>
  78. void OnNavigationFailed(object sender, NavigationFailedEventArgs e)
  79. {
  80. throw new Exception("Failed to load Page " + e.SourcePageType.FullName);
  81. }
  82. /// <summary>
  83. /// Invoked when application execution is being suspended. Application state is saved
  84. /// without knowing whether the application will be terminated or resumed with the contents
  85. /// of memory still intact.
  86. /// </summary>
  87. /// <param name="sender">The source of the suspend request.</param>
  88. /// <param name="e">Details about the suspend request.</param>
  89. private void OnSuspending(object sender, SuspendingEventArgs e)
  90. {
  91. var deferral = e.SuspendingOperation.GetDeferral();
  92. //TODO: Save application state and stop any background activity
  93. deferral.Complete();
  94. }
  95. }
  96. }