mirror of
https://github.com/ShareX/ShareX.git
synced 2024-07-04 14:11:38 +12:00
Fix OCR async issue
This commit is contained in:
parent
7baeb193c6
commit
c802383311
|
@ -358,6 +358,8 @@ public static void InvokeSafe(this Control control, Action action)
|
||||||
}
|
}
|
||||||
|
|
||||||
public static void ForceActivate(this Form form)
|
public static void ForceActivate(this Form form)
|
||||||
|
{
|
||||||
|
if (!form.IsDisposed)
|
||||||
{
|
{
|
||||||
if (!form.Visible)
|
if (!form.Visible)
|
||||||
{
|
{
|
||||||
|
@ -372,6 +374,7 @@ public static void ForceActivate(this Form form)
|
||||||
form.BringToFront();
|
form.BringToFront();
|
||||||
form.Activate();
|
form.Activate();
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
public static int WeekOfYear(this DateTime dateTime)
|
public static int WeekOfYear(this DateTime dateTime)
|
||||||
{
|
{
|
||||||
|
|
|
@ -1470,7 +1470,7 @@ private void tsmiTextCapture_Click(object sender, EventArgs e)
|
||||||
|
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
TaskHelpers.OCRImage().RunSynchronously();
|
_ = TaskHelpers.OCRImage();
|
||||||
}
|
}
|
||||||
catch (Exception ex)
|
catch (Exception ex)
|
||||||
{
|
{
|
||||||
|
@ -1842,9 +1842,16 @@ private void tsmiTrayLastRegion_Click(object sender, EventArgs e)
|
||||||
new CaptureLastRegion().Capture();
|
new CaptureLastRegion().Capture();
|
||||||
}
|
}
|
||||||
|
|
||||||
private void tsmiTrayTextCapture_Click(object sender, EventArgs e)
|
private async void tsmiTrayTextCapture_Click(object sender, EventArgs e)
|
||||||
{
|
{
|
||||||
TaskHelpers.OCRImage().RunSynchronously();
|
try
|
||||||
|
{
|
||||||
|
await TaskHelpers.OCRImage();
|
||||||
|
}
|
||||||
|
catch (Exception ex)
|
||||||
|
{
|
||||||
|
DebugHelper.WriteException(ex);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private void tsmiTrayToggleHotkeys_Click(object sender, EventArgs e)
|
private void tsmiTrayToggleHotkeys_Click(object sender, EventArgs e)
|
||||||
|
@ -2094,9 +2101,9 @@ private void tsmiShowQRCode_Click(object sender, EventArgs e)
|
||||||
uim.ShowQRCode();
|
uim.ShowQRCode();
|
||||||
}
|
}
|
||||||
|
|
||||||
private void tsmiOCRImage_Click(object sender, EventArgs e)
|
private async void tsmiOCRImage_Click(object sender, EventArgs e)
|
||||||
{
|
{
|
||||||
uim.OCRImage();
|
await uim.OCRImage();
|
||||||
}
|
}
|
||||||
|
|
||||||
private void tsmiCombineImages_Click(object sender, EventArgs e)
|
private void tsmiCombineImages_Click(object sender, EventArgs e)
|
||||||
|
|
|
@ -134,7 +134,7 @@ public static void ExecuteJob(TaskSettings taskSettings, HotkeyType job, CLIComm
|
||||||
OpenWebpageCapture(safeTaskSettings);
|
OpenWebpageCapture(safeTaskSettings);
|
||||||
break;
|
break;
|
||||||
case HotkeyType.TextCapture:
|
case HotkeyType.TextCapture:
|
||||||
OCRImage(safeTaskSettings).RunSynchronously();
|
_ = OCRImage(safeTaskSettings);
|
||||||
break;
|
break;
|
||||||
case HotkeyType.AutoCapture:
|
case HotkeyType.AutoCapture:
|
||||||
OpenAutoCapture(safeTaskSettings);
|
OpenAutoCapture(safeTaskSettings);
|
||||||
|
@ -1144,7 +1144,7 @@ public static async Task OCRImage(string filePath, TaskSettings taskSettings = n
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public static async Task OCRImage(Stream stream, string fileName, string filePath = null, TaskSettings taskSettings = null)
|
private static async Task OCRImage(Stream stream, string fileName, string filePath = null, TaskSettings taskSettings = null)
|
||||||
{
|
{
|
||||||
if (stream != null)
|
if (stream != null)
|
||||||
{
|
{
|
||||||
|
|
|
@ -30,6 +30,7 @@
|
||||||
using System.Collections.Generic;
|
using System.Collections.Generic;
|
||||||
using System.IO;
|
using System.IO;
|
||||||
using System.Linq;
|
using System.Linq;
|
||||||
|
using System.Threading.Tasks;
|
||||||
using System.Windows.Forms;
|
using System.Windows.Forms;
|
||||||
|
|
||||||
namespace ShareX
|
namespace ShareX
|
||||||
|
@ -362,9 +363,9 @@ public void ShowQRCode()
|
||||||
if (IsItemSelected && SelectedItem.IsURLExist) new QRCodeForm(SelectedItem.Info.Result.URL).Show();
|
if (IsItemSelected && SelectedItem.IsURLExist) new QRCodeForm(SelectedItem.Info.Result.URL).Show();
|
||||||
}
|
}
|
||||||
|
|
||||||
public void OCRImage()
|
public async Task OCRImage()
|
||||||
{
|
{
|
||||||
if (IsItemSelected && SelectedItem.IsImageFile) TaskHelpers.OCRImage(SelectedItem.Info.FilePath).RunSynchronously();
|
if (IsItemSelected && SelectedItem.IsImageFile) await TaskHelpers.OCRImage(SelectedItem.Info.FilePath);
|
||||||
}
|
}
|
||||||
|
|
||||||
public void CombineImages()
|
public void CombineImages()
|
||||||
|
|
|
@ -1007,9 +1007,9 @@ private bool DownloadFromURL(bool upload)
|
||||||
|
|
||||||
private void DoOCR()
|
private void DoOCR()
|
||||||
{
|
{
|
||||||
if (Data != null && Info.DataType == EDataType.Image)
|
if (Image != null && Info.DataType == EDataType.Image)
|
||||||
{
|
{
|
||||||
TaskHelpers.OCRImage(Data, Info.FileName, Info.FilePath, Info.TaskSettings).RunSynchronously();
|
_ = TaskHelpers.OCRImage(Image, Info.TaskSettings);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue