/// <summary> /// /// </summary> /// <param name="sender"></param> /// <param name="e"></param> private void ExportButton_Click(object sender, EventArgs e) { if (Datastore.Transactions.TransactionHistory.Count == 0) { MessageBox.Show("There are no transactions to export"); return; } var result = MessageBox.Show("Exporting transactions to Dropbox will clear all transactions in YNABcompanion. Are you sure you want to proceed?", "", MessageBoxButton.OKCancel); if (result == MessageBoxResult.Cancel) { return; } ProgressBar.Visibility = Visibility.Visible; ProgressBar.IsIndeterminate = true; if (!DropboxHelper.IsSetup()) { DropboxHelper.Setup(this, delegate { ExportButton_Click(sender, e); }); } else { bool success = true; Task.Run(async() => { int i = 0; Dictionary <String, String> csvStrings = GetCsvStrings(); foreach (KeyValuePair <String, String> pair in csvStrings) { success = await DropboxHelper.ExportTextFile("YNABcompanion", pair.Key + ".csv", pair.Value, delegate { ExportCompleted(new List <String>(csvStrings.Keys)); }, ++i == csvStrings.Count); if (!success) { Deployment.Current.Dispatcher.BeginInvoke(() => { MessageBox.Show("You cannot export transactions without network connectivity."); ProgressBar.IsIndeterminate = false; ProgressBar.Visibility = Visibility.Collapsed; }); break; } } }); } }