forked from TheElixZammuto/moonlight-xbox
-
Notifications
You must be signed in to change notification settings - Fork 0
/
MoonlightWelcome.xaml.cpp
80 lines (67 loc) · 2.71 KB
/
MoonlightWelcome.xaml.cpp
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
//
// 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();
auto navigation = Windows::UI::Core::SystemNavigationManager::GetForCurrentView();
navigation->BackRequested += ref new EventHandler<BackRequestedEventArgs^>(this, &MoonlightWelcome::OnBackRequested);
Windows::UI::ViewManagement::ApplicationView::GetForCurrentView()->SetDesiredBoundsMode(Windows::UI::ViewManagement::ApplicationViewBoundsMode::UseVisible);
}
void moonlight_xbox_dx::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 moonlight_xbox_dx::MoonlightWelcome::GoForward(Platform::Object^ sender, Windows::UI::Xaml::RoutedEventArgs^ e)
{
this->FlipView->SelectedIndex = this->FlipView->SelectedIndex + 1;
}
void moonlight_xbox_dx::MoonlightWelcome::GoBack(Platform::Object^ sender, Windows::UI::Xaml::RoutedEventArgs^ e)
{
this->FlipView->SelectedIndex = this->FlipView->SelectedIndex - 1;
}
void moonlight_xbox_dx::MoonlightWelcome::CloseButton_Click(Platform::Object^ sender, Windows::UI::Xaml::RoutedEventArgs^ e)
{
GetApplicationState()->FirstTime = false;
GetApplicationState()->UpdateFile();
this->Frame->GoBack();
}
void moonlight_xbox_dx::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;
}
}