Skip to content

Commit

Permalink
add the UI for export page
Browse files Browse the repository at this point in the history
  • Loading branch information
duchuule committed Aug 5, 2015
1 parent 2b07693 commit 2a9db3d
Show file tree
Hide file tree
Showing 6 changed files with 99 additions and 48 deletions.
28 changes: 22 additions & 6 deletions ExportPage.xaml
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,8 @@
xmlns:ctl="using:VBA10.Controls"
xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
mc:Ignorable="d">
mc:Ignorable="d"
Loaded="Page_Loaded">

<Grid Background="{ThemeResource ApplicationPageBackgroundThemeBrush}">
<Grid.RowDefinitions>
Expand Down Expand Up @@ -35,7 +36,7 @@
Margin="0,8,0,0"
/>
<TextBlock TextWrapping="Wrap"
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."
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."
Margin=" 0, 4, 0, 4" />

<TextBlock Text="OneDrive"
Expand All @@ -46,10 +47,25 @@
<TextBlock TextWrapping="Wrap"
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."
Margin=" 0, 4, 0, 4" />

<TextBlock TextWrapping="Wrap"
Text="This feature will be added in a future release."
Margin=" 0, 4, 0, 4" />

<StackPanel Orientation="Horizontal"
Margin="0,4,0,12">
<Button x:Name="SignInbtn" Content="Sign in"
Click="SignInbtn_Click"
Width="120"
Margin =" 0, 0, 8, 0"/>

<Button x:Name="exportOneDrivebtn" Content="Export"
Click="exportOneDrivebtn_Click"
Width="120"
IsEnabled="False"
Margin =" 0, 0, 0, 0"/>

<!--<Button x:Name="importOneDriveSavebtn" Content="Import Save"
Width="120"
Margin ="0"
Click="importSavbtn_Click"/>-->
</StackPanel>

</StackPanel>
</ScrollViewer>
Expand Down
54 changes: 54 additions & 0 deletions ExportPage.xaml.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@
//
#include "pch.h"
#include "ExportPage.xaml.h"
#include "App.xaml.h"

using namespace VBA10;

Expand All @@ -18,9 +19,62 @@ using namespace Windows::UI::Xaml::Input;
using namespace Windows::UI::Xaml::Media;
using namespace Windows::UI::Xaml::Navigation;


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

ExportPage::ExportPage()
{
InitializeComponent();
}





void ExportPage::Page_Loaded(Platform::Object^ sender, Windows::UI::Xaml::RoutedEventArgs^ e)
{
//try re-sign in silently because access token expires every 1 hour
if (EmulatorSettings::Current->SignedIn)
{
//live::live_client* LiveClient = new live::live_client();
App::LiveClient->login(L"wl.skydrive_update wl.signin", true)
.then([this](bool isLoggedIn)
{
signin_Completed(isLoggedIn);
});
}
}

void ExportPage::SignInbtn_Click(Platform::Object^ sender, Windows::UI::Xaml::RoutedEventArgs^ e)
{
App::LiveClient->login(L"wl.skydrive_update wl.signin", false)
.then([this](bool isLoggedIn)
{
signin_Completed(isLoggedIn);

});
}

void ExportPage::signin_Completed(bool isLoggedIn)
{
if (isLoggedIn)
{
this->SignInbtn->Content = "Signed in";
this->SignInbtn->IsEnabled = false;
this->exportOneDrivebtn->IsEnabled = true;
EmulatorSettings::Current->SignedIn = true;
}
else
{
this->SignInbtn->Content = "Sign in";
this->SignInbtn->IsEnabled = true;
this->exportOneDrivebtn->IsEnabled = false;
EmulatorSettings::Current->SignedIn = false;
}
}


void ExportPage::exportOneDrivebtn_Click(Platform::Object^ sender, Windows::UI::Xaml::RoutedEventArgs^ e)
{

}
5 changes: 5 additions & 0 deletions ExportPage.xaml.h
Original file line number Diff line number Diff line change
Expand Up @@ -17,5 +17,10 @@ namespace VBA10
{
public:
ExportPage();
private:
void exportOneDrivebtn_Click(Platform::Object^ sender, Windows::UI::Xaml::RoutedEventArgs^ e);
void Page_Loaded(Platform::Object^ sender, Windows::UI::Xaml::RoutedEventArgs^ e);
void SignInbtn_Click(Platform::Object^ sender, Windows::UI::Xaml::RoutedEventArgs^ e);
void signin_Completed(bool isLoggedIn);
};
}
4 changes: 2 additions & 2 deletions ImportPage.xaml
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@
Margin="0,8,0,0"
/>
<TextBlock TextWrapping="Wrap"
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."
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."
Margin=" 0, 4, 0, 4" />

<StackPanel Orientation="Horizontal"
Expand All @@ -66,7 +66,7 @@
Margin="0,8,0,0"
/>
<TextBlock TextWrapping="Wrap"
Text="Use this option to import roms and save files through OneDrive. The rom will be copied to the app's private storage."
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."
Margin=" 0, 4, 0, 4" />


Expand Down
2 changes: 1 addition & 1 deletion Package.appxmanifest
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
<?xml version="1.0" encoding="utf-8"?>
<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">
<Identity Name="16994Sparksoft.VBA10" Publisher="CN=9289A21E-3389-49E2-A9E0-46AA1289C3CB" Version="1.3.0.0" />
<Identity Name="16994Sparksoft.VBA10" Publisher="CN=9289A21E-3389-49E2-A9E0-46AA1289C3CB" Version="1.4.120.0" />
<mp:PhoneIdentity PhoneProductId="2b9558e5-6253-426c-8989-3284f508e743" PhonePublisherId="00000000-0000-0000-0000-000000000000" />
<Properties>
<DisplayName>VBA10</DisplayName>
Expand Down
54 changes: 15 additions & 39 deletions live_connect.h
Original file line number Diff line number Diff line change
Expand Up @@ -133,52 +133,28 @@ namespace VBA10 {
//{});


if (silent)
{
return pplx::create_task(m_authenticator->AuthenticateUserAsync(request_vec, Windows::Security::Authentication::OnlineId::CredentialPromptType::DoNotPrompt))
.then([this](concurrency::task<Windows::Security::Authentication::OnlineId::UserIdentity^> idtask)
{
try
{
auto ident = idtask.get();
if (ident->Tickets->Size > 0)
{
auto ticket = ident->Tickets->GetAt(0);

m_token = std::wstring(ticket->Value->Data());
return true;
}
}
catch (const concurrency::task_canceled &) {}
catch (const std::exception &){}
catch (Platform::Exception ^ex) {}

return false;
});
}
else
return pplx::create_task(m_authenticator->AuthenticateUserAsync(request_vec, (silent)?Windows::Security::Authentication::OnlineId::CredentialPromptType::DoNotPrompt : Windows::Security::Authentication::OnlineId::CredentialPromptType::PromptIfNeeded))
.then([this](concurrency::task<Windows::Security::Authentication::OnlineId::UserIdentity^> idtask)
{
return pplx::create_task(m_authenticator->AuthenticateUserAsync(request_vec, Windows::Security::Authentication::OnlineId::CredentialPromptType::PromptIfNeeded))
.then([this](concurrency::task<Windows::Security::Authentication::OnlineId::UserIdentity^> idtask)
try
{
try
auto ident = idtask.get();
if (ident->Tickets->Size > 0)
{
auto ident = idtask.get();
if (ident->Tickets->Size > 0)
{
auto ticket = ident->Tickets->GetAt(0);
auto ticket = ident->Tickets->GetAt(0);

m_token = std::wstring(ticket->Value->Data());
return true;
}
m_token = std::wstring(ticket->Value->Data());
return true;
}
catch (const concurrency::task_canceled &) {}
catch (const std::exception &) {}
catch (Platform::Exception ^ex) {}
}
catch (const concurrency::task_canceled &) {}
catch (const std::exception &){}
catch (Platform::Exception ^ex) {}

return false;
});

return false;
});
}
}

/// <summary>
Expand Down

0 comments on commit 2a9db3d

Please sign in to comment.