Skip to content
This repository has been archived by the owner on Nov 17, 2022. It is now read-only.

Commit

Permalink
文本内容立即刷新,不被请求阻塞
Browse files Browse the repository at this point in the history
  • Loading branch information
NPCDW committed Apr 9, 2022
1 parent c85ca7a commit 4069d06
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 0 deletions.
1 change: 1 addition & 0 deletions WindowsFormsOCR/MainForm.cs
Original file line number Diff line number Diff line change
Expand Up @@ -104,6 +104,7 @@ private void Translate_HotKey_Click(object sender, EventArgs e)
return;
}
form.ocrTextBox.Text = getWordsResult;
Application.DoEvents();
form.translate();
}

Expand Down
6 changes: 6 additions & 0 deletions WindowsFormsOCR/TranslateAndOCRForm.cs
Original file line number Diff line number Diff line change
Expand Up @@ -95,6 +95,7 @@ public void translate(String translateProvideStr = null, String sourceLanguage =
return;
}
translateTextBox.Text = "翻译中,请稍等。。。";
Application.DoEvents();

translateTextBox.Text = TencentCloudHelper.translate(ocrTextBox.Text, sourceLanguage, targetLanguage);
}
Expand All @@ -106,6 +107,7 @@ public void translate(String translateProvideStr = null, String sourceLanguage =
return;
}
translateTextBox.Text = "识别中,请稍等。。。";
Application.DoEvents();

translateTextBox.Text = BaiduAIHelper.translate(ocrTextBox.Text, sourceLanguage, targetLanguage);
}
Expand Down Expand Up @@ -135,6 +137,7 @@ public void ocr(Bitmap bmp, String ocrProvideStr = null, String ocrType = null)
return;
}
ocrTextBox.Text = "识别中,请稍等。。。";
Application.DoEvents();

ocrTextBox.Text = TencentCloudHelper.ocr(bmp, ocrType);
}
Expand All @@ -146,6 +149,7 @@ public void ocr(Bitmap bmp, String ocrProvideStr = null, String ocrType = null)
return;
}
ocrTextBox.Text = "识别中,请稍等。。。";
Application.DoEvents();

ocrTextBox.Text = BaiduCloudHelper.ocr(bmp, ocrType);
}
Expand All @@ -163,6 +167,7 @@ public void screenshotTranslate(Bitmap bmp)
}
ocrTextBox.Text = "识别中,请稍等。。。";
translateTextBox.Text = "翻译中,请稍等。。。";
Application.DoEvents();

Dictionary<String, String> keyValues = TencentCloudHelper.screenshotTranslate(bmp);
ocrTextBox.Text = keyValues["ocrText"];
Expand All @@ -177,6 +182,7 @@ public void screenshotTranslate(Bitmap bmp)
}
ocrTextBox.Text = "识别中,请稍等。。。";
translateTextBox.Text = "翻译中,请稍等。。。";
Application.DoEvents();

Dictionary<String, String> keyValues = BaiduAIHelper.screenshotTranslate(bmp);
ocrTextBox.Text = keyValues["ocrText"];
Expand Down

0 comments on commit 4069d06

Please sign in to comment.