RhSolutions-AddIn/RhSolutions.AddIn/Tools/OcrTool.cs

36 lines
599 B
C#
Raw Normal View History

using System.Threading.Tasks;
2024-11-08 09:03:47 +03:00
using SnippingTool;
2024-11-09 22:34:58 +03:00
using OcrClient.Services;
2024-11-06 23:43:00 +03:00
namespace RhSolutions.Tools;
2024-11-09 22:59:46 +03:00
internal class OcrTool : ITool
2024-11-06 23:43:00 +03:00
{
2024-11-09 22:34:58 +03:00
private IOcrClient client = RhSolutionsAddIn.ServiceProvider.GetService<IOcrClient>();
2024-11-09 22:59:46 +03:00
public void Execute()
{
2024-11-09 22:34:58 +03:00
try
{
RhSolutionsAddIn.Excel.Visible = false;
Task.Run(async delegate
{
await Task.Delay(250);
}).Wait();
string shot = Snipper.SnipBase64();
var result = client.ProcessImage(shot);
}
catch (Exception)
{
throw;
}
finally
{
2024-11-09 22:34:58 +03:00
RhSolutionsAddIn.Excel.Visible = true;
}
2024-11-06 23:43:00 +03:00
}
2024-11-09 22:59:46 +03:00
public void Dispose()
{
}
2024-11-06 23:43:00 +03:00
}