3
// Implementation of the App class.
6
// Copyright (c) Microsoft Open Technologies, Inc.
7
// All rights reserved.
9
// (3 - clause BSD License)
11
// Redistribution and use in source and binary forms, with or without modification, are permitted provided that
12
// the following conditions are met:
14
// 1. Redistributions of source code must retain the above copyright notice, this list of conditions and the
15
// following disclaimer.
16
// 2. Redistributions in binary form must reproduce the above copyright notice, this list of conditions and the
17
// following disclaimer in the documentation and/or other materials provided with the distribution.
18
// 3. Neither the name of the copyright holder nor the names of its contributors may be used to endorse or
19
// promote products derived from this software without specific prior written permission.
21
// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED
22
// WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A
23
// PARTICULAR PURPOSE ARE DISCLAIMED.IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY
24
// DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES(INCLUDING, BUT NOT LIMITED TO,
25
// PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
26
// HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT(INCLUDING
27
// NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
28
// POSSIBILITY OF SUCH DAMAGE.
31
#include "MainPage.xaml.h"
34
using namespace video_capture_xaml;
36
using namespace Platform;
37
using namespace Windows::ApplicationModel;
38
using namespace Windows::ApplicationModel::Activation;
39
using namespace Windows::Foundation;
40
using namespace Windows::Foundation::Collections;
41
using namespace Windows::UI::Xaml::Media::Animation;
42
using namespace Windows::UI::Xaml;
43
using namespace Windows::UI::Xaml::Controls;
44
using namespace Windows::UI::Xaml::Controls::Primitives;
45
using namespace Windows::UI::Xaml::Data;
46
using namespace Windows::UI::Xaml::Input;
47
using namespace Windows::UI::Xaml::Interop;
48
using namespace Windows::UI::Xaml::Media;
49
using namespace Windows::UI::Xaml::Navigation;
51
// The Blank Application template is documented at http://go.microsoft.com/fwlink/?LinkId=234227
54
/// Initializes the singleton application object. This is the first line of authored code
55
/// executed, and as such is the logical equivalent of main() or WinMain().
59
InitializeComponent();
60
Suspending += ref new SuspendingEventHandler(this, &App::OnSuspending);
61
Resuming += ref new Windows::Foundation::EventHandler<Platform::Object ^>(this, &video_capture_xaml::App::OnResuming);
65
/// Invoked when the application is launched normally by the end user. Other entry points
66
/// will be used when the application is launched to open a specific file, to display
67
/// search results, and so forth.
69
/// <param name="e">Details about the launch request and process.</param>
70
void App::OnLaunched(LaunchActivatedEventArgs^ e)
73
if (IsDebuggerPresent())
75
DebugSettings->EnableFrameRateCounter = true;
79
auto rootFrame = dynamic_cast<Frame^>(Window::Current->Content);
81
// Do not repeat app initialization when the Window already has content,
82
// just ensure that the window is active.
83
if (rootFrame == nullptr)
85
// Create a Frame to act as the navigation context and associate it with
86
// a SuspensionManager key
87
rootFrame = ref new Frame();
89
// TODO: Change this value to a cache size that is appropriate for your application.
90
rootFrame->CacheSize = 1;
92
if (e->PreviousExecutionState == ApplicationExecutionState::Terminated)
94
// TODO: Restore the saved session state only when appropriate, scheduling the
95
// final launch steps after the restore is complete.
98
// Place the frame in the current Window
99
Window::Current->Content = rootFrame;
102
if (rootFrame->Content == nullptr)
104
#if WINAPI_FAMILY==WINAPI_FAMILY_PHONE_APP
105
// Removes the turnstile navigation for startup.
106
if (rootFrame->ContentTransitions != nullptr)
108
_transitions = ref new TransitionCollection();
109
for (auto transition : rootFrame->ContentTransitions)
111
_transitions->Append(transition);
115
rootFrame->ContentTransitions = nullptr;
116
_firstNavigatedToken = rootFrame->Navigated += ref new NavigatedEventHandler(this, &App::RootFrame_FirstNavigated);
119
// When the navigation stack isn't restored navigate to the first page,
120
// configuring the new page by passing required information as a navigation
122
if (!rootFrame->Navigate(MainPage::typeid, e->Arguments))
124
throw ref new FailureException("Failed to create initial page");
128
// Ensure the current window is active
129
Window::Current->Activate();
132
#if WINAPI_FAMILY==WINAPI_FAMILY_PHONE_APP
134
/// Restores the content transitions after the app has launched.
136
void App::RootFrame_FirstNavigated(Object^ sender, NavigationEventArgs^ e)
138
auto rootFrame = safe_cast<Frame^>(sender);
140
TransitionCollection^ newTransitions;
141
if (_transitions == nullptr)
143
newTransitions = ref new TransitionCollection();
144
newTransitions->Append(ref new NavigationThemeTransition());
148
newTransitions = _transitions;
151
rootFrame->ContentTransitions = newTransitions;
153
rootFrame->Navigated -= _firstNavigatedToken;
158
/// Invoked when application execution is being suspended. Application state is saved
159
/// without knowing whether the application will be terminated or resumed with the contents
160
/// of memory still intact.
162
void App::OnSuspending(Object^ sender, SuspendingEventArgs^ e)
164
(void) sender; // Unused parameter
165
(void) e; // Unused parameter
167
// TODO: Save application state and stop any background activity
170
void video_capture_xaml::App::OnResuming(Platform::Object ^sender, Platform::Object ^args)
172
// throw ref new Platform::NotImplementedException();
b'\\ No newline at end of file'