Skip to content

Instantly share code, notes, and snippets.

@g33kChris
Last active December 23, 2019 23:03
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save g33kChris/e386d018443d604288c114154e99e416 to your computer and use it in GitHub Desktop.
Save g33kChris/e386d018443d604288c114154e99e416 to your computer and use it in GitHub Desktop.
GameDex Snippets
public async static Task NewLibraryInApp()
{
StorageFolder rootFolder = await Windows.Storage.ApplicationData.Current.LocalFolder.CreateFolderAsync("GameDex", CreationCollisionOption.ReplaceExisting);
await rootFolder.CreateFolderAsync("Media");
if (await StorageHelper.WriteFileAsync("gdex.json", App.GameDexModel, rootFolder))
{
StorageHelper.SetSetting("GameDexLocation", "Local", StorageHelper.StorageStrategies.Roaming);
return true;
}
else
{
return false;
}
}
public async static Task NewLibraryInDocuments()
{
FolderPicker installDirectoryPicker = new FolderPicker();
installDirectoryPicker.ViewMode = PickerViewMode.Thumbnail;
installDirectoryPicker.SuggestedStartLocation = PickerLocationId.DocumentsLibrary;
installDirectoryPicker.FileTypeFilter.Add("*");
installDirectoryPicker.CommitButtonText = "Install Here";
var folderSelection = await installDirectoryPicker.PickSingleFolderAsync();
StorageFolder rootFolder = await folderSelection.CreateFolderAsync("GameDex", CreationCollisionOption.ReplaceExisting);
string path = rootFolder.Path;
await rootFolder.CreateFolderAsync("Media");
if (await StorageHelper.WriteFileAsync("gdex.json", App.GameDexModel, rootFolder))
{
StorageHelper.SetSetting("GameDexLocation", "Documents", StorageHelper.StorageStrategies.Roaming);
StorageHelper.SetSetting("Path", path, StorageHelper.StorageStrategies.Roaming);
return true;
}
else
{
return false;
}
}
public async static Task NewLibraryInSkyDrive()
{
if (await SkyDriveController.InitAuth())
{
await AzureMobileController.Authenticate();
if (await AzureMobileController.AddNewAppModel())
{
//Setup Local Environment to Sync Against
StorageFolder rootFolder = await Windows.Storage.ApplicationData.Current.LocalFolder.CreateFolderAsync("GameDex", CreationCollisionOption.ReplaceExisting);
string path = rootFolder.Path;
await rootFolder.CreateFolderAsync("Media");
if (await SkyDriveController.setupNewSkyDriveEnvironment())
{
StorageHelper.SetSetting("GameDexLocation", "SkyDrive", StorageHelper.StorageStrategies.Roaming);
return true;
}
else
{
return false;
}
}
else
{
return false;
}
}
else
{
return false;
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment