/// <summary> /// (Re-)builds the cache /// </summary> /// <param name="sender">Event sender</param> /// <param name="e">Event arguments</param> private void BuildCacheToolStripMenuItem_Click(object sender, EventArgs e) { if (Cache.Images == null || Cache.Images.Length == 0 || MessageBox.Show("Your cache is not empty. Only rebuild the cache if you uploaded or deleted images outside of this application. This process invokes a lot of API requests which can get you blocked if you do it too often.\r\nAre you sure you want to rescan it?", "Reset Cache", MessageBoxButtons.YesNo, MessageBoxIcon.Information, MessageBoxDefaultButton.Button2) == DialogResult.Yes) { using (frmCacheBuilder fCache = new frmCacheBuilder(S)) { fCache.ShowDialog(); InitPages(); } } }
/// <summary> /// Authorizes the application using OAuth2 /// </summary> /// <param name="sender">Event sender</param> /// <param name="e">Event arguments</param> private void AuthorizeToolStripMenuItem_Click(object sender, EventArgs e) { if (S.Token.Expires < DateTime.UtcNow || MessageBox.Show($"This app is already authorized until {S.Token.Expires.ToShortDateString()} and connected to your account. Reauthorization will erase the cache.\r\nContinue?", "Authorization", MessageBoxButtons.YesNo, MessageBoxIcon.Information, MessageBoxDefaultButton.Button2) == DialogResult.Yes) { using (frmAuth fAuth = new frmAuth(S)) { if (fAuth.ShowDialog() == DialogResult.OK) { Cache.ClearThumbnails(); Cache.ClearImages(); using (frmCacheBuilder fCache = new frmCacheBuilder(S)) { fCache.ShowDialog(); } I = new Imgur(S); InitPages(); } else { MessageBox.Show("Unable to authorize your client. Your current authorization will be kept. Please try again", "Authorization Error", MessageBoxButtons.OK, MessageBoxIcon.Error); } } } }