-
Notifications
You must be signed in to change notification settings - Fork 59
Expand file tree
/
Copy pathMoonlightWelcome.xaml.cpp
More file actions
90 lines (77 loc) · 3.16 KB
/
Copy pathMoonlightWelcome.xaml.cpp
File metadata and controls
90 lines (77 loc) · 3.16 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
//
// MoonlightWelcome.xaml.cpp
// Implementazione della classe MoonlightWelcome
//
#include "pch.h"
#include "MoonlightWelcome.xaml.h"
using namespace moonlight_xbox_dx;
using namespace Platform;
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::Media;
using namespace Windows::UI::Xaml::Navigation;
// Il modello di elemento Pagina vuota è documentato all'indirizzo https://go.microsoft.com/fwlink/?LinkId=234238
MoonlightWelcome::MoonlightWelcome()
{
InitializeComponent();
Windows::UI::ViewManagement::ApplicationView::GetForCurrentView()->SetDesiredBoundsMode(Windows::UI::ViewManagement::ApplicationViewBoundsMode::UseVisible);
this->Loaded += ref new Windows::UI::Xaml::RoutedEventHandler(this, &MoonlightWelcome::OnLoaded);
this->Unloaded += ref new Windows::UI::Xaml::RoutedEventHandler(this, &MoonlightWelcome::OnUnloaded);
}
void MoonlightWelcome::OnBackRequested(Platform::Object^ e, Windows::UI::Core::BackRequestedEventArgs^ args)
{
// UWP on Xbox One triggers a back request whenever the B
// button is pressed which can result in the app being
// suspended if unhandled
if (this->FlipView->SelectedIndex > 0) {
args->Handled = true;
this->FlipView->SelectedIndex = this->FlipView->SelectedIndex - 1;
return;
}
if (this->Frame->CanGoBack && !GetApplicationState()->FirstTime) {
this->Frame->GoBack();
args->Handled = true;
return;
}
}
void MoonlightWelcome::GoForward(Platform::Object^ sender, Windows::UI::Xaml::RoutedEventArgs^ e)
{
this->FlipView->SelectedIndex = this->FlipView->SelectedIndex + 1;
}
void MoonlightWelcome::GoBack(Platform::Object^ sender, Windows::UI::Xaml::RoutedEventArgs^ e)
{
this->FlipView->SelectedIndex = this->FlipView->SelectedIndex - 1;
}
void MoonlightWelcome::CloseButton_Click(Platform::Object^ sender, Windows::UI::Xaml::RoutedEventArgs^ e)
{
GetApplicationState()->FirstTime = false;
GetApplicationState()->UpdateFile();
this->Frame->GoBack();
}
void MoonlightWelcome::Page_KeyDown(Platform::Object^ sender, Windows::UI::Xaml::Input::KeyRoutedEventArgs^ e)
{
if (e->OriginalKey != Windows::System::VirtualKey::GamepadA)return;
if (this->FlipView->Items->Size == (this->FlipView->SelectedIndex + 1)) {
GetApplicationState()->FirstTime = false;
GetApplicationState()->UpdateFile();
this->Frame->GoBack();
}
else {
this->FlipView->SelectedIndex = this->FlipView->SelectedIndex + 1;
}
}
void MoonlightWelcome::OnLoaded(Platform::Object^ sender, Windows::UI::Xaml::RoutedEventArgs^ e)
{
auto navigation = Windows::UI::Core::SystemNavigationManager::GetForCurrentView();
m_back_token = navigation->BackRequested += ref new EventHandler<BackRequestedEventArgs^>(this, &MoonlightWelcome::OnBackRequested);
}
void MoonlightWelcome::OnUnloaded(Platform::Object^ sender, Windows::UI::Xaml::RoutedEventArgs^ e)
{
auto navigation = Windows::UI::Core::SystemNavigationManager::GetForCurrentView();
navigation->BackRequested -= m_back_token;
}