3
// Implementation of the App class.
7
#include "MainPage.xaml.h"
9
using namespace PhoneTutorial;
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::Media::Animation;
24
using namespace Windows::UI::Xaml::Navigation;
26
// The Blank Application template is documented at http://go.microsoft.com/fwlink/?LinkID=391641
29
/// Initializes the singleton application object. This is the first line of authored code
30
/// executed, and as such is the logical equivalent of main() or WinMain().
34
InitializeComponent();
35
Suspending += ref new SuspendingEventHandler(this, &App::OnSuspending);
39
/// Invoked when the application is launched normally by the end user. Other entry points
40
/// will be used when the application is launched to open a specific file, to display
41
/// search results, and so forth.
43
/// <param name="e">Details about the launch request and process.</param>
44
void App::OnLaunched(LaunchActivatedEventArgs^ e)
47
if (IsDebuggerPresent())
49
DebugSettings->EnableFrameRateCounter = true;
53
auto rootFrame = dynamic_cast<Frame^>(Window::Current->Content);
55
// Do not repeat app initialization when the Window already has content,
56
// just ensure that the window is active.
57
if (rootFrame == nullptr)
59
// Create a Frame to act as the navigation context and associate it with
60
// a SuspensionManager key
61
rootFrame = ref new Frame();
63
// TODO: Change this value to a cache size that is appropriate for your application.
64
rootFrame->CacheSize = 1;
66
if (e->PreviousExecutionState == ApplicationExecutionState::Terminated)
68
// TODO: Restore the saved session state only when appropriate, scheduling the
69
// final launch steps after the restore is complete.
72
// Place the frame in the current Window
73
Window::Current->Content = rootFrame;
76
if (rootFrame->Content == nullptr)
78
// Removes the turnstile navigation for startup.
79
if (rootFrame->ContentTransitions != nullptr)
81
_transitions = ref new TransitionCollection();
82
for (auto transition : rootFrame->ContentTransitions)
84
_transitions->Append(transition);
88
rootFrame->ContentTransitions = nullptr;
89
_firstNavigatedToken = rootFrame->Navigated += ref new NavigatedEventHandler(this, &App::RootFrame_FirstNavigated);
91
// When the navigation stack isn't restored navigate to the first page,
92
// configuring the new page by passing required information as a navigation
94
if (!rootFrame->Navigate(MainPage::typeid, e->Arguments))
96
throw ref new FailureException("Failed to create initial page");
100
// Ensure the current window is active
101
Window::Current->Activate();
105
/// Restores the content transitions after the app has launched.
107
void App::RootFrame_FirstNavigated(Object^ sender, NavigationEventArgs^ e)
109
auto rootFrame = safe_cast<Frame^>(sender);
111
TransitionCollection^ newTransitions;
112
if (_transitions == nullptr)
114
newTransitions = ref new TransitionCollection();
115
newTransitions->Append(ref new NavigationThemeTransition());
119
newTransitions = _transitions;
122
rootFrame->ContentTransitions = newTransitions;
123
rootFrame->Navigated -= _firstNavigatedToken;
127
/// Invoked when application execution is being suspended. Application state is saved
128
/// without knowing whether the application will be terminated or resumed with the contents
129
/// of memory still intact.
131
void App::OnSuspending(Object^ sender, SuspendingEventArgs^ e)
133
(void) sender; // Unused parameter
134
(void) e; // Unused parameter
136
// TODO: Save application state and stop any background activity
b'\\ No newline at end of file'