mirror of
https://github.com/ShareX/ShareX.git
synced 2024-06-29 03:30:43 +12:00
Code refactoring
This commit is contained in:
parent
9cde03c9f3
commit
ce93a032ef
|
@ -120,15 +120,15 @@ private void UpdateControls()
|
||||||
pbStatus.Visible = busy;
|
pbStatus.Visible = busy;
|
||||||
}
|
}
|
||||||
|
|
||||||
private async Task OCR()
|
private async Task OCR(Bitmap bmp)
|
||||||
{
|
{
|
||||||
if (bmpSource != null && !string.IsNullOrEmpty(Options.Language))
|
if (bmp != null && !string.IsNullOrEmpty(Options.Language))
|
||||||
{
|
{
|
||||||
busy = true;
|
busy = true;
|
||||||
txtResult.Text = "";
|
txtResult.Text = "";
|
||||||
UpdateControls();
|
UpdateControls();
|
||||||
|
|
||||||
Result = await OCRHelper.OCR(bmpSource, Options.Language, Options.ScaleFactor);
|
Result = await OCRHelper.OCR(bmp, Options.Language, Options.ScaleFactor);
|
||||||
|
|
||||||
if (Options.AutoCopy && !string.IsNullOrEmpty(Result))
|
if (Options.AutoCopy && !string.IsNullOrEmpty(Result))
|
||||||
{
|
{
|
||||||
|
@ -146,7 +146,7 @@ private async Task OCR()
|
||||||
|
|
||||||
private async void OCRForm_Shown(object sender, EventArgs e)
|
private async void OCRForm_Shown(object sender, EventArgs e)
|
||||||
{
|
{
|
||||||
await OCR();
|
await OCR(bmpSource);
|
||||||
}
|
}
|
||||||
|
|
||||||
private async void btnSelectRegion_Click(object sender, EventArgs e)
|
private async void btnSelectRegion_Click(object sender, EventArgs e)
|
||||||
|
@ -154,12 +154,16 @@ private async void btnSelectRegion_Click(object sender, EventArgs e)
|
||||||
FormWindowState previousState = WindowState;
|
FormWindowState previousState = WindowState;
|
||||||
WindowState = FormWindowState.Minimized;
|
WindowState = FormWindowState.Minimized;
|
||||||
await Task.Delay(250);
|
await Task.Delay(250);
|
||||||
bmpSource?.Dispose();
|
Bitmap regionImage = RegionCaptureTasks.GetRegionImage(new RegionCaptureOptions());
|
||||||
bmpSource = RegionCaptureTasks.GetRegionImage(new RegionCaptureOptions());
|
|
||||||
WindowState = previousState;
|
WindowState = previousState;
|
||||||
await Task.Delay(250);
|
|
||||||
|
|
||||||
await OCR();
|
if (regionImage != null)
|
||||||
|
{
|
||||||
|
bmpSource?.Dispose();
|
||||||
|
bmpSource = regionImage;
|
||||||
|
await Task.Delay(250);
|
||||||
|
await OCR(bmpSource);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private async void cbLanguages_SelectedIndexChanged(object sender, EventArgs e)
|
private async void cbLanguages_SelectedIndexChanged(object sender, EventArgs e)
|
||||||
|
@ -168,7 +172,7 @@ private async void cbLanguages_SelectedIndexChanged(object sender, EventArgs e)
|
||||||
{
|
{
|
||||||
Options.Language = ((OCRLanguage)cbLanguages.SelectedItem).LanguageTag;
|
Options.Language = ((OCRLanguage)cbLanguages.SelectedItem).LanguageTag;
|
||||||
|
|
||||||
await OCR();
|
await OCR(bmpSource);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -178,7 +182,7 @@ private async void nudScaleFactor_ValueChanged(object sender, EventArgs e)
|
||||||
{
|
{
|
||||||
Options.ScaleFactor = (float)nudScaleFactor.Value;
|
Options.ScaleFactor = (float)nudScaleFactor.Value;
|
||||||
|
|
||||||
await OCR();
|
await OCR(bmpSource);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue