private async void MainForm_Load(object sender, EventArgs e) { if (!string.IsNullOrEmpty(Properties.Settings.Default.AccessToken)) { Client = new DropboxClient(Properties.Settings.Default.AccessToken); if (await Client.CheckConnection()) { EnableUI(false); // get current account FullAccount currentAccount = await Client.Users.GetCurrentAccount(); // display account name and id connectionStatusLabel.Text = string.Format("Connected as {0} ({1})", currentAccount.Name.DisplayName, currentAccount.AccountId); // get space usage SpaceUsage usage = await Client.Users.GetSpaceUsage(); spaceUsageLabel.Text = string.Format("{0:0.00}% used ({1:n} of {2:n} GiB)", (float)usage.Used / (float)usage.Allocation.Allocated * 100f, usage.Used / 1073741824f, usage.Allocation.Allocated / 1073741824f); // refresh tree view await RefreshTreeView(); EnableUI(true); } else { MessageBox.Show("Unable to connect to Dropbox. Please try connecting again."); } } else { Client = new DropboxClient(appId, appSecret); } Client.Files.DownloadFileProgressChanged += Files_DownloadFileProgressChanged; Client.Files.UploadFileProgressChanged += Files_UploadFileProgressChanged; }
private async void MainForm_Load(object sender, EventArgs e) { if (!string.IsNullOrEmpty(Properties.Settings.Default.AccessToken)) { Client = new DropboxClient(Properties.Settings.Default.AccessToken); if (await Client.CheckConnection()) { EnableUI(false); // get current account FullAccount currentAccount = await Client.Users.GetCurrentAccount(); // display account name and id connectionStatusLabel.Text = string.Format("Connected as {0} ({1})", currentAccount.Name.DisplayName, currentAccount.AccountId); // get space usage SpaceUsage usage = await Client.Users.GetSpaceUsage(); spaceUsageLabel.Text = string.Format("{0:0.00}% used ({1:n} of {2:n} GiB)", (float)usage.Used / (float)usage.Allocation.Allocated * 100f, usage.Used / 1073741824f, usage.Allocation.Allocated / 1073741824f); // refresh tree view await RefreshTreeView(); EnableUI(true); } else { MessageBox.Show("Unable to connect to Dropbox. Please try connecting again."); } } else { Client = new DropboxClient(appId, appSecret); } Client.Files.DownloadFileProgressChanged += Files_DownloadFileProgressChanged; Client.Files.UploadFileProgressChanged += Files_UploadFileProgressChanged; }