Skip to content
This repository was archived by the owner on Apr 29, 2024. It is now read-only.

Commit 17d15d4

Browse files
committed
Fixes #595
1 parent 251de71 commit 17d15d4

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

44 files changed

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

0 commit comments

Comments
 (0)