Skip to content

Commit 2a9db3d

Browse files
committed
add the UI for export page
1 parent 2b07693 commit 2a9db3d

File tree

6 files changed

+99
-48
lines changed

6 files changed

+99
-48
lines changed

ExportPage.xaml

Lines changed: 22 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,8 @@
66
xmlns:ctl="using:VBA10.Controls"
77
xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
88
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
9-
mc:Ignorable="d">
9+
mc:Ignorable="d"
10+
Loaded="Page_Loaded">
1011

1112
<Grid Background="{ThemeResource ApplicationPageBackgroundThemeBrush}">
1213
<Grid.RowDefinitions>
@@ -35,7 +36,7 @@
3536
Margin="0,8,0,0"
3637
/>
3738
<TextBlock TextWrapping="Wrap"
38-
Text="If you import the rom using local storage option, then all save files are stored in the same folder as the rom. You just need to go there and copy them to wherever you need."
39+
Text="If you import the rom using local storage option, then all save files are stored in the same folder as the rom; you just need to go there and copy them to wherever you need. Better yet, if you are on Desktop/Tablet and store the rom in OneDrive folder, all your saves are automatically synced to the cloud."
3940
Margin=" 0, 4, 0, 4" />
4041

4142
<TextBlock Text="OneDrive"
@@ -46,10 +47,25 @@
4647
<TextBlock TextWrapping="Wrap"
4748
Text="If for any reason you cannot access the rom folder, e.g., the rom is stored in the app's private storage, use this option to export save files to OneDrive."
4849
Margin=" 0, 4, 0, 4" />
49-
50-
<TextBlock TextWrapping="Wrap"
51-
Text="This feature will be added in a future release."
52-
Margin=" 0, 4, 0, 4" />
50+
51+
<StackPanel Orientation="Horizontal"
52+
Margin="0,4,0,12">
53+
<Button x:Name="SignInbtn" Content="Sign in"
54+
Click="SignInbtn_Click"
55+
Width="120"
56+
Margin =" 0, 0, 8, 0"/>
57+
58+
<Button x:Name="exportOneDrivebtn" Content="Export"
59+
Click="exportOneDrivebtn_Click"
60+
Width="120"
61+
IsEnabled="False"
62+
Margin =" 0, 0, 0, 0"/>
63+
64+
<!--<Button x:Name="importOneDriveSavebtn" Content="Import Save"
65+
Width="120"
66+
Margin ="0"
67+
Click="importSavbtn_Click"/>-->
68+
</StackPanel>
5369

5470
</StackPanel>
5571
</ScrollViewer>

ExportPage.xaml.cpp

Lines changed: 54 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@
44
//
55
#include "pch.h"
66
#include "ExportPage.xaml.h"
7+
#include "App.xaml.h"
78

89
using namespace VBA10;
910

@@ -18,9 +19,62 @@ using namespace Windows::UI::Xaml::Input;
1819
using namespace Windows::UI::Xaml::Media;
1920
using namespace Windows::UI::Xaml::Navigation;
2021

22+
2123
// The Blank Page item template is documented at http://go.microsoft.com/fwlink/?LinkId=234238
2224

2325
ExportPage::ExportPage()
2426
{
2527
InitializeComponent();
2628
}
29+
30+
31+
32+
33+
34+
void ExportPage::Page_Loaded(Platform::Object^ sender, Windows::UI::Xaml::RoutedEventArgs^ e)
35+
{
36+
//try re-sign in silently because access token expires every 1 hour
37+
if (EmulatorSettings::Current->SignedIn)
38+
{
39+
//live::live_client* LiveClient = new live::live_client();
40+
App::LiveClient->login(L"wl.skydrive_update wl.signin", true)
41+
.then([this](bool isLoggedIn)
42+
{
43+
signin_Completed(isLoggedIn);
44+
});
45+
}
46+
}
47+
48+
void ExportPage::SignInbtn_Click(Platform::Object^ sender, Windows::UI::Xaml::RoutedEventArgs^ e)
49+
{
50+
App::LiveClient->login(L"wl.skydrive_update wl.signin", false)
51+
.then([this](bool isLoggedIn)
52+
{
53+
signin_Completed(isLoggedIn);
54+
55+
});
56+
}
57+
58+
void ExportPage::signin_Completed(bool isLoggedIn)
59+
{
60+
if (isLoggedIn)
61+
{
62+
this->SignInbtn->Content = "Signed in";
63+
this->SignInbtn->IsEnabled = false;
64+
this->exportOneDrivebtn->IsEnabled = true;
65+
EmulatorSettings::Current->SignedIn = true;
66+
}
67+
else
68+
{
69+
this->SignInbtn->Content = "Sign in";
70+
this->SignInbtn->IsEnabled = true;
71+
this->exportOneDrivebtn->IsEnabled = false;
72+
EmulatorSettings::Current->SignedIn = false;
73+
}
74+
}
75+
76+
77+
void ExportPage::exportOneDrivebtn_Click(Platform::Object^ sender, Windows::UI::Xaml::RoutedEventArgs^ e)
78+
{
79+
80+
}

ExportPage.xaml.h

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -17,5 +17,10 @@ namespace VBA10
1717
{
1818
public:
1919
ExportPage();
20+
private:
21+
void exportOneDrivebtn_Click(Platform::Object^ sender, Windows::UI::Xaml::RoutedEventArgs^ e);
22+
void Page_Loaded(Platform::Object^ sender, Windows::UI::Xaml::RoutedEventArgs^ e);
23+
void SignInbtn_Click(Platform::Object^ sender, Windows::UI::Xaml::RoutedEventArgs^ e);
24+
void signin_Completed(bool isLoggedIn);
2025
};
2126
}

ImportPage.xaml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -44,7 +44,7 @@
4444
Margin="0,8,0,0"
4545
/>
4646
<TextBlock TextWrapping="Wrap"
47-
Text="Use this option to import a file already present on your phone or PC. Note: due to a bug in Windows 10, you won't be able to see the content of the folder you are browsing. Just select the folder containing the rom and will be presented with a list of rom to import."
47+
Text="Use this option to import a file already present on your phone or PC. NOTE: due to a bug in Windows 10, you won't be able to see the content of the folder you are browsing. Just select the folder containing the rom and will be presented with a list of rom to import."
4848
Margin=" 0, 4, 0, 4" />
4949

5050
<StackPanel Orientation="Horizontal"
@@ -66,7 +66,7 @@
6666
Margin="0,8,0,0"
6767
/>
6868
<TextBlock TextWrapping="Wrap"
69-
Text="Use this option to import roms and save files through OneDrive. The rom will be copied to the app's private storage."
69+
Text="Use this option to import roms and save files from OneDrive, which will be copied to the app's private storage. NOTE: If you are on Dekstop/Tablet, you should use the Local Storage option and browse to the OneDrive folder, which gives you automatic cloud sync."
7070
Margin=" 0, 4, 0, 4" />
7171

7272

Package.appxmanifest

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
<?xml version="1.0" encoding="utf-8"?>
22
<Package xmlns="http://schemas.microsoft.com/appx/manifest/foundation/windows10" xmlns:mp="http://schemas.microsoft.com/appx/2014/phone/manifest" xmlns:uap="http://schemas.microsoft.com/appx/manifest/uap/windows10" IgnorableNamespaces="uap mp">
3-
<Identity Name="16994Sparksoft.VBA10" Publisher="CN=9289A21E-3389-49E2-A9E0-46AA1289C3CB" Version="1.3.0.0" />
3+
<Identity Name="16994Sparksoft.VBA10" Publisher="CN=9289A21E-3389-49E2-A9E0-46AA1289C3CB" Version="1.4.120.0" />
44
<mp:PhoneIdentity PhoneProductId="2b9558e5-6253-426c-8989-3284f508e743" PhonePublisherId="00000000-0000-0000-0000-000000000000" />
55
<Properties>
66
<DisplayName>VBA10</DisplayName>

live_connect.h

Lines changed: 15 additions & 39 deletions
Original file line numberDiff line numberDiff line change
@@ -133,52 +133,28 @@ namespace VBA10 {
133133
//{});
134134

135135

136-
if (silent)
137-
{
138-
return pplx::create_task(m_authenticator->AuthenticateUserAsync(request_vec, Windows::Security::Authentication::OnlineId::CredentialPromptType::DoNotPrompt))
139-
.then([this](concurrency::task<Windows::Security::Authentication::OnlineId::UserIdentity^> idtask)
140-
{
141-
try
142-
{
143-
auto ident = idtask.get();
144-
if (ident->Tickets->Size > 0)
145-
{
146-
auto ticket = ident->Tickets->GetAt(0);
147136

148-
m_token = std::wstring(ticket->Value->Data());
149-
return true;
150-
}
151-
}
152-
catch (const concurrency::task_canceled &) {}
153-
catch (const std::exception &){}
154-
catch (Platform::Exception ^ex) {}
155-
156-
return false;
157-
});
158-
}
159-
else
137+
return pplx::create_task(m_authenticator->AuthenticateUserAsync(request_vec, (silent)?Windows::Security::Authentication::OnlineId::CredentialPromptType::DoNotPrompt : Windows::Security::Authentication::OnlineId::CredentialPromptType::PromptIfNeeded))
138+
.then([this](concurrency::task<Windows::Security::Authentication::OnlineId::UserIdentity^> idtask)
160139
{
161-
return pplx::create_task(m_authenticator->AuthenticateUserAsync(request_vec, Windows::Security::Authentication::OnlineId::CredentialPromptType::PromptIfNeeded))
162-
.then([this](concurrency::task<Windows::Security::Authentication::OnlineId::UserIdentity^> idtask)
140+
try
163141
{
164-
try
142+
auto ident = idtask.get();
143+
if (ident->Tickets->Size > 0)
165144
{
166-
auto ident = idtask.get();
167-
if (ident->Tickets->Size > 0)
168-
{
169-
auto ticket = ident->Tickets->GetAt(0);
145+
auto ticket = ident->Tickets->GetAt(0);
170146

171-
m_token = std::wstring(ticket->Value->Data());
172-
return true;
173-
}
147+
m_token = std::wstring(ticket->Value->Data());
148+
return true;
174149
}
175-
catch (const concurrency::task_canceled &) {}
176-
catch (const std::exception &) {}
177-
catch (Platform::Exception ^ex) {}
150+
}
151+
catch (const concurrency::task_canceled &) {}
152+
catch (const std::exception &){}
153+
catch (Platform::Exception ^ex) {}
154+
155+
return false;
156+
});
178157

179-
return false;
180-
});
181-
}
182158
}
183159

184160
/// <summary>

0 commit comments

Comments
 (0)