From 98f16212ef35e6cc4bea2a2d6e19b2b4e5c4a7e1 Mon Sep 17 00:00:00 2001 From: Shino Amakusa Date: Sat, 29 Nov 2014 02:42:11 +0000 Subject: [PATCH] --- Tumblr Tool UI/Form1.cs | 53 +++++++++++++++++++++++++++++++++++++++++ 1 file changed, 53 insertions(+) diff --git a/Tumblr Tool UI/Form1.cs b/Tumblr Tool UI/Form1.cs index 6266ad7..747e829 100644 --- a/Tumblr Tool UI/Form1.cs +++ b/Tumblr Tool UI/Form1.cs @@ -37,6 +37,8 @@ public partial class mainForm : Form private TimeSpan ts; private TumblrStats tumblrStats; private string version = "Beta 0.14.1128"; + private processingCodes uiProcessingState = processingCodes.OK; + public mainForm() { InitializeComponent(); @@ -388,6 +390,7 @@ private void crawlUIWorker_AfterDone(object sender, RunWorkerCompletedEventArgs private void crawlUIWorker_DoWork(object sender, DoWorkEventArgs e) { + uiProcessingState = processingCodes.Starting; while (ripper == null) { } @@ -414,23 +417,29 @@ private void crawlUIWorker_DoWork(object sender, DoWorkEventArgs e) { TimeSpan ts = stopWatch.Elapsed; + if (ripper.statusCode == processingCodes.Initializing) { + uiProcessingState = processingCodes.Initializing; this.Invoke((MethodInvoker)delegate { updateStatusText("Initializing ..."); updateWorkStatusText("Initializing ... "); }); } + if (ripper.statusCode == processingCodes.checkingConnection) { + uiProcessingState = processingCodes.checkingConnection; this.Invoke((MethodInvoker)delegate { updateWorkStatusText("Checking for internet connection ..."); }); } + if (ripper.statusCode == processingCodes.connectionOK) { + uiProcessingState = processingCodes.connectionOK; this.Invoke((MethodInvoker)delegate { updateWorkStatusText("Internet Connection found ..."); @@ -439,6 +448,7 @@ private void crawlUIWorker_DoWork(object sender, DoWorkEventArgs e) } if (ripper.statusCode == processingCodes.connectionError) { + uiProcessingState = processingCodes.connectionError; this.Invoke((MethodInvoker)delegate { updateStatusText("Error"); @@ -453,6 +463,7 @@ private void crawlUIWorker_DoWork(object sender, DoWorkEventArgs e) if (ripper.statusCode == processingCodes.gettingBlogInfo) { + uiProcessingState = processingCodes.gettingBlogInfo; this.Invoke((MethodInvoker)delegate { updateWorkStatusText("Getting Blog info ..."); @@ -461,6 +472,7 @@ private void crawlUIWorker_DoWork(object sender, DoWorkEventArgs e) if (ripper.statusCode == processingCodes.blogInfoOK) { + uiProcessingState = processingCodes.blogInfoOK; this.Invoke((MethodInvoker)delegate { lbl_PostCount.Text = "0 / 0"; @@ -473,6 +485,7 @@ private void crawlUIWorker_DoWork(object sender, DoWorkEventArgs e) if (ripper.statusCode == processingCodes.Starting) { + uiProcessingState = processingCodes.Starting; this.Invoke((MethodInvoker)delegate { updateWorkStatusText("Starting crawling Tumblr @ " + txt_TumblrURL.Text + " ... "); @@ -489,6 +502,7 @@ private void crawlUIWorker_DoWork(object sender, DoWorkEventArgs e) } if (ripper.statusCode == processingCodes.Crawling) { + uiProcessingState = processingCodes.Crawling; percent = ripper.percentComplete; if (percent > 100) @@ -514,6 +528,7 @@ private void crawlUIWorker_DoWork(object sender, DoWorkEventArgs e) if (ripper.statusCode == processingCodes.invalidURL) { + uiProcessingState = processingCodes.invalidURL; this.Invoke((MethodInvoker)delegate { updateStatusText("Error"); @@ -534,6 +549,7 @@ private void crawlWorker_AfterDone(object sender, RunWorkerCompletedEventArgs e) { if (ripper.statusCode == processingCodes.Done) { + uiProcessingState = processingCodes.Done; saveFile.blog = ripper.blog; if (!optionsForm.parseOnly) @@ -559,6 +575,12 @@ private void crawlWorker_DoWork(object sender, DoWorkEventArgs e) this.ripper = new ImageRipper(tumblrBlog, txt_SaveLocation.Text, optionsForm.generateLog, optionsForm.parsePhotoSets, optionsForm.parseJPEG, optionsForm.parsePNG, optionsForm.parseGIF, 0); ripper.statusCode = processingCodes.Initializing; + while (uiProcessingState != processingCodes.Initializing) + { + // + } + + ts = stopWatch.Elapsed; // Format and display the TimeSpan value. @@ -567,10 +589,22 @@ private void crawlWorker_DoWork(object sender, DoWorkEventArgs e) ts.Milliseconds / 10); ripper.statusCode = processingCodes.checkingConnection; + + while (uiProcessingState != processingCodes.checkingConnection) + { + // + } + + if (WebHelper.CheckForInternetConnection()) { ripper.statusCode = processingCodes.connectionOK; + while (uiProcessingState != processingCodes.connectionOK) + { + // + } + this.ts = stopWatch.Elapsed; // Format and display the TimeSpan value. @@ -586,10 +620,22 @@ private void crawlWorker_DoWork(object sender, DoWorkEventArgs e) if (ripper.isValidTumblr()) { ripper.statusCode = processingCodes.gettingBlogInfo; + + while (uiProcessingState != processingCodes.gettingBlogInfo) + { + // + } + + if (this.ripper.setBlogInfo()) { ripper.statusCode = processingCodes.blogInfoOK; + while (uiProcessingState != processingCodes.blogInfoOK) + { + // + } + if (saveFile == null && !saveTumblrFile(this.ripper.blog.name)) { ripper.statusCode = processingCodes.saveFileError; @@ -605,6 +651,13 @@ private void crawlWorker_DoWork(object sender, DoWorkEventArgs e) mode = select_Mode.SelectedIndex + 1; }); ripper.statusCode = processingCodes.Starting; + + while (uiProcessingState != processingCodes.Starting) + { + // + } + + tumblrBlog = this.ripper.parseBlogPosts(mode); } }