3 // Implementation of the App class.
7 #include "MainPage.xaml.h"
9 using namespace TestShell
;
11 using namespace Platform
;
12 using namespace Windows::ApplicationModel
;
13 using namespace Windows::ApplicationModel::Activation
;
14 using namespace Windows::Foundation
;
15 using namespace Windows::Foundation::Collections
;
16 using namespace Windows::UI::Xaml
;
17 using namespace Windows::UI::Xaml::Controls
;
18 using namespace Windows::UI::Xaml::Controls::Primitives
;
19 using namespace Windows::UI::Xaml::Data
;
20 using namespace Windows::UI::Xaml::Input
;
21 using namespace Windows::UI::Xaml::Interop
;
22 using namespace Windows::UI::Xaml::Media
;
23 using namespace Windows::UI::Xaml::Navigation
;
25 // The Blank Application template is documented at http://go.microsoft.com/fwlink/?LinkId=234227
28 /// Initializes the singleton application object. This is the first line of authored code
29 /// executed, and as such is the logical equivalent of main() or WinMain().
33 InitializeComponent();
34 Suspending
+= ref
new SuspendingEventHandler(this, &App::OnSuspending
);
38 /// Invoked when the application is launched normally by the end user. Other entry points
39 /// will be used when the application is launched to open a specific file, to display
40 /// search results, and so forth.
42 /// <param name="pArgs">Details about the launch request and process.</param>
43 void App::OnLaunched(Windows::ApplicationModel::Activation::LaunchActivatedEventArgs
^ pArgs
)
45 // Do not repeat app initialization when already running, just ensure that
46 // the window is active
47 if (pArgs
->PreviousExecutionState
== ApplicationExecutionState::Running
)
49 Window::Current
->Activate();
53 if (pArgs
->PreviousExecutionState
== ApplicationExecutionState::Terminated
)
55 //TODO: Load state from previously suspended application
58 // Create a Frame to act navigation context and navigate to the first page
59 auto rootFrame
= ref
new Frame();
60 if (!rootFrame
->Navigate(TypeName(MainPage::typeid)))
62 throw ref
new FailureException("Failed to create initial page");
65 // Place the frame in the current Window and ensure that it is active
66 Window::Current
->Content
= rootFrame
;
67 Window::Current
->Activate();
71 /// Invoked when application execution is being suspended. Application state is saved
72 /// without knowing whether the application will be terminated or resumed with the contents
73 /// of memory still intact.
75 /// <param name="sender">The source of the suspend request.</param>
76 /// <param name="e">Details about the suspend request.</param>
77 void App::OnSuspending(Object
^ sender
, SuspendingEventArgs
^ e
)
79 (void) sender
; // Unused parameter
80 (void) e
; // Unused parameter
82 //TODO: Save application state and stop any background activity