void SavePosts() { //Filter the list of posts to be saved FilterPosts(chkMatchRows.Checked); //Start the save thread SavePostThread thread = new SavePostThread(redditCookie2, userAgent, toSave, true); thread.Thread.ProgressChanged += new ProgressChangedEventHandler(SavePosts_ProgressChanged); thread.Thread.RunWorkerCompleted += new RunWorkerCompletedEventHandler(SavePosts_Completed); thread.Start(); }
void SavePosts_Completed(object sender, RunWorkerCompletedEventArgs e) { statusLabel.Text = "DONE SAVING"; //If we need to unsave the posts in the LEFT account if (chkUnsaveAfter.Checked) { SavePostThread thread = new SavePostThread(redditCookie1, userAgent, toSave, false); thread.Thread.ProgressChanged += new ProgressChangedEventHandler(UnSavePosts_ProgressChanged); thread.Thread.RunWorkerCompleted += new RunWorkerCompletedEventHandler(UnSavePosts_Completed); thread.Start(); } else { Console.WriteLine("DONE"); MessageBox.Show("Finished saving " + toSave.Count + " posts."); btnCopyPosts.Enabled = true; btnLoadSaved.Enabled = true; btnUnsave.Enabled = true; toolStripProgressBar1.Value = 100; } }
private void btnUnsave_Click(object sender, EventArgs e) { btnCopyPosts.Enabled = false; btnLoadSaved.Enabled = false; btnUnsave.Enabled = false; //btnExport.Enabled = false; FilterPosts(chkMatchRows.Checked); DialogResult result = MessageBox.Show("This will UNSAVE " + toSave.Count + " posts! Are you sure you want to do this?", "Sure about that?", MessageBoxButtons.YesNo, MessageBoxIcon.Warning); if (result == DialogResult.Yes) { FilterPosts(chkMatchRows.Checked); SavePostThread thread = new SavePostThread(redditCookie1, userAgent, toSave, false); thread.Thread.ProgressChanged += new ProgressChangedEventHandler(UnSavePosts_ProgressChanged); thread.Thread.RunWorkerCompleted += new RunWorkerCompletedEventHandler(UnSavePosts_Completed); thread.Start(); } else if (result == DialogResult.No) { btnCopyPosts.Enabled = true; btnLoadSaved.Enabled = true; btnUnsave.Enabled = true; Console.WriteLine("Unsave Canceled."); } }