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

38 lines
754 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;
internal class OcrTool : Tool
{
public Application Application { get; set; }
2024-11-09 22:34:58 +03:00
private IOcrClient client = RhSolutionsAddIn.ServiceProvider.GetService<IOcrClient>();
public OcrTool(ReaderFactory readerFactory, WriterFactory writerFactory) : base(readerFactory, writerFactory)
{
}
2024-11-06 23:43:00 +03:00
2024-11-09 22:34:58 +03:00
public override 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
}
}