123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159 |
-
- #include "pch.h"
- #include "MainPage.xaml.h"
- using namespace SDLPal;
- using namespace Platform;
- using namespace Windows::ApplicationModel;
- using namespace Windows::ApplicationModel::Activation;
- using namespace Windows::Foundation;
- using namespace Windows::Foundation::Collections;
- using namespace Windows::UI::Xaml;
- using namespace Windows::UI::Xaml::Controls;
- using namespace Windows::UI::Xaml::Controls::Primitives;
- using namespace Windows::UI::Xaml::Data;
- using namespace Windows::UI::Xaml::Input;
- using namespace Windows::UI::Xaml::Interop;
- using namespace Windows::UI::Xaml::Media;
- using namespace Windows::UI::Xaml::Media::Animation;
- using namespace Windows::UI::Xaml::Navigation;
- App::App()
- {
- InitializeComponent();
- Suspending += ref new SuspendingEventHandler(this, &App::OnSuspending);
- }
- void App::OnLaunched(LaunchActivatedEventArgs^ e)
- {
- #if _DEBUG
- if (IsDebuggerPresent())
- {
- DebugSettings->EnableFrameRateCounter = true;
- }
- #endif
- auto rootFrame = dynamic_cast<Frame^>(Window::Current->Content);
-
-
- if (rootFrame == nullptr)
- {
-
-
- rootFrame = ref new Frame();
-
- rootFrame->CacheSize = 1;
-
- rootFrame->Language = Windows::Globalization::ApplicationLanguages::Languages->GetAt(0);
- if (e->PreviousExecutionState == ApplicationExecutionState::Terminated)
- {
-
-
- }
-
- Window::Current->Content = rootFrame;
- }
- if (rootFrame->Content == nullptr)
- {
-
- if (rootFrame->ContentTransitions != nullptr)
- {
- _transitions = ref new TransitionCollection();
- for (auto transition : rootFrame->ContentTransitions)
- {
- _transitions->Append(transition);
- }
- }
- rootFrame->ContentTransitions = nullptr;
- _firstNavigatedToken = rootFrame->Navigated += ref new NavigatedEventHandler(this, &App::RootFrame_FirstNavigated);
-
-
-
- if (!rootFrame->Navigate(MainPage::typeid, e->Arguments))
- {
- throw ref new FailureException("Failed to create initial page");
- }
- }
-
- Window::Current->Activate();
- }
- void App::RootFrame_FirstNavigated(Object^ sender, NavigationEventArgs^ e)
- {
- auto rootFrame = safe_cast<Frame^>(sender);
- TransitionCollection^ newTransitions;
- if (_transitions == nullptr)
- {
- newTransitions = ref new TransitionCollection();
- newTransitions->Append(ref new NavigationThemeTransition());
- }
- else
- {
- newTransitions = _transitions;
- }
- rootFrame->ContentTransitions = newTransitions;
- rootFrame->Navigated -= _firstNavigatedToken;
- }
- void SDLPal::App::OnActivated(Windows::ApplicationModel::Activation::IActivatedEventArgs ^ args)
- {
- switch (args->Kind)
- {
- case ActivationKind::PickFolderContinuation:
- {
- static_cast<SDLPal::MainPage^>(Page)->SetPath(safe_cast<IFolderPickerContinuationEventArgs^>(args)->Folder);
- break;
- }
- case ActivationKind::PickFileContinuation:
- {
- auto files = safe_cast<IFileOpenPickerContinuationEventArgs^>(args)->Files;
- if (files->Size > 0) static_cast<SDLPal::MainPage^>(Page)->SetFile(files->GetAt(0));
- break;
- }
- }
- Application::OnActivated(args);
- }
- void App::OnSuspending(Object^ sender, SuspendingEventArgs^ e)
- {
- (void) sender;
- (void) e;
-
- }
|