adjust test for new attach behavior introduced in upstream check-in a02da71f
[sqlcipher.git] / vsixtest / App.xaml.cpp
blobc90604a83030924f440c42f4493d7b3f7e38d256
1 //
2 // App.xaml.cpp
3 // Implementation of the App class.
4 //
6 #include "pch.h"
7 #include "MainPage.xaml.h"
9 using namespace vsixtest;
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 /// <summary>
26 /// Initializes the singleton application object. This is the first line of authored code
27 /// executed, and as such is the logical equivalent of main() or WinMain().
28 /// </summary>
29 App::App()
31 InitializeComponent();
32 Suspending += ref new SuspendingEventHandler(this, &App::OnSuspending);
35 /// <summary>
36 /// Invoked when the application is launched normally by the end user. Other entry points
37 /// will be used such as when the application is launched to open a specific file.
38 /// </summary>
39 /// <param name="e">Details about the launch request and process.</param>
40 void App::OnLaunched(Windows::ApplicationModel::Activation::LaunchActivatedEventArgs^ e)
43 #if _DEBUG
44 // Show graphics profiling information while debugging.
45 if (IsDebuggerPresent())
47 // Display the current frame rate counters
48 DebugSettings->EnableFrameRateCounter = true;
50 #endif
52 auto rootFrame = dynamic_cast<Frame^>(Window::Current->Content);
54 // Do not repeat app initialization when the Window already has content,
55 // just ensure that the window is active
56 if (rootFrame == nullptr)
58 // Create a Frame to act as the navigation context and associate it with
59 // a SuspensionManager key
60 rootFrame = ref new Frame();
62 rootFrame->NavigationFailed += ref new Windows::UI::Xaml::Navigation::NavigationFailedEventHandler(this, &App::OnNavigationFailed);
64 if (e->PreviousExecutionState == ApplicationExecutionState::Terminated)
66 // TODO: Restore the saved session state only when appropriate, scheduling the
67 // final launch steps after the restore is complete
71 if (rootFrame->Content == nullptr)
73 // When the navigation stack isn't restored navigate to the first page,
74 // configuring the new page by passing required information as a navigation
75 // parameter
76 rootFrame->Navigate(TypeName(MainPage::typeid), e->Arguments);
78 // Place the frame in the current Window
79 Window::Current->Content = rootFrame;
80 // Ensure the current window is active
81 Window::Current->Activate();
83 else
85 if (rootFrame->Content == nullptr)
87 // When the navigation stack isn't restored navigate to the first page,
88 // configuring the new page by passing required information as a navigation
89 // parameter
90 rootFrame->Navigate(TypeName(MainPage::typeid), e->Arguments);
92 // Ensure the current window is active
93 Window::Current->Activate();
97 /// <summary>
98 /// Invoked when application execution is being suspended. Application state is saved
99 /// without knowing whether the application will be terminated or resumed with the contents
100 /// of memory still intact.
101 /// </summary>
102 /// <param name="sender">The source of the suspend request.</param>
103 /// <param name="e">Details about the suspend request.</param>
104 void App::OnSuspending(Object^ sender, SuspendingEventArgs^ e)
106 (void) sender; // Unused parameter
107 (void) e; // Unused parameter
109 //TODO: Save application state and stop any background activity
112 /// <summary>
113 /// Invoked when Navigation to a certain page fails
114 /// </summary>
115 /// <param name="sender">The Frame which failed navigation</param>
116 /// <param name="e">Details about the navigation failure</param>
117 void App::OnNavigationFailed(Platform::Object ^sender, Windows::UI::Xaml::Navigation::NavigationFailedEventArgs ^e)
119 throw ref new FailureException("Failed to load Page " + e->SourcePageType.Name);