private void uploadGame(string GameFileFinal, BackgroundWorker sendingworker) { // Add new line so that the previous message isn't overwritten sendingworker.ReportProgress(0, new StatusHolder() { txt = "", progress = -1 }); stopWaitHandle.Reset(); GoogleDriveApi.UploadGame(mDriveService, GameFileFinal, mDriveDirectory, onFileUploadProgressChanged, onFileUploaded, sendingworker); stopWaitHandle.WaitOne(); }
// Functionality private Google.Apis.Drive.v2.Data.File createRootFolder() { Google.Apis.Drive.v2.Data.File dir; string folder_id = Ini.read(Ini.KEY_DRIVE_ROOT); if (String.IsNullOrEmpty(folder_id)) { dir = GoogleDriveApi.createDirectory(mDriveService, AppName, AppDescription); Ini.write(Ini.KEY_DRIVE_ROOT, dir.Id); } else { dir = GoogleDriveApi.createDirectory(mDriveService, AppName, AppDescription, folder_id); } return(dir); }
private void loadCredentials(bool user_initiated) { setButtonsToAuthenticationRequired(); btn_authenticate.IsEnabled = false; btn_authenticate.Content = "Connecting ..."; BackgroundWorker workerConnectToGoogleDrive = new BackgroundWorker(); workerConnectToGoogleDrive.DoWork += delegate { mDriveService = GoogleDriveApi.CreateService(); }; workerConnectToGoogleDrive.RunWorkerCompleted += delegate { if (mDriveService == null) { if (user_initiated) { new MaterialDialog("Authentication required", "A connection to your Google Drive is required. \nPlease try again.").ShowDialog(); setButtonsToAuthenticationRequired(); } else { // Clear local credentials and ask the user again for them if (Directory.Exists(GoogleDriveApi.CREDENTIAL_STORE)) { Directory.Delete(GoogleDriveApi.CREDENTIAL_STORE, true); } new MaterialDialog("Authentication required", "Couldn't connect to your Google Drive.\n Try restarting the app.").ShowDialog(); RaiseCloseEvent(); } } else { setButtonsToStandard(); } }; workerConnectToGoogleDrive.RunWorkerAsync(); }