Hide application window on OcrTool press
This commit is contained in:
parent
dbaa8b111a
commit
1511dafa93
@ -2,21 +2,33 @@
|
|||||||
using System.Runtime.Versioning;
|
using System.Runtime.Versioning;
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
using System.Threading.Tasks;
|
||||||
|
|
||||||
namespace RhSolutions.Tools;
|
namespace RhSolutions.Tools;
|
||||||
|
|
||||||
internal class OcrTool : Tool
|
internal class OcrTool : Tool
|
||||||
{
|
{
|
||||||
public OcrTool(ReaderFactory readerFactory, WriterFactory writerFactory) : base(readerFactory, writerFactory)
|
public Application Application { get; set; }
|
||||||
|
public OcrTool(ReaderFactory readerFactory, WriterFactory writerFactory, Application application) : base(readerFactory, writerFactory)
|
||||||
{
|
{
|
||||||
|
Application = application;
|
||||||
}
|
}
|
||||||
|
|
||||||
public override void Execute()
|
public override void Execute()
|
||||||
{
|
{
|
||||||
|
Application.Visible = false;
|
||||||
|
Task.Run(async delegate
|
||||||
|
{
|
||||||
|
await Task.Delay(100);
|
||||||
|
}).Wait();
|
||||||
|
|
||||||
var bmp = SnippingTool.SnippingTool.Snip();
|
var bmp = SnippingTool.SnippingTool.Snip();
|
||||||
if (bmp != null)
|
if (bmp != null)
|
||||||
{
|
{
|
||||||
// Do something with the bitmap
|
// Do something with the bitmap
|
||||||
//...
|
//...
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Application.Visible = true;
|
||||||
}
|
}
|
||||||
}
|
}
|
@ -5,6 +5,7 @@ internal class ToolFactory
|
|||||||
static ReaderFactory readerFactory = RhSolutionsAddIn.ServiceProvider.GetService<ReaderFactory>();
|
static ReaderFactory readerFactory = RhSolutionsAddIn.ServiceProvider.GetService<ReaderFactory>();
|
||||||
static WriterFactory writerFactory = RhSolutionsAddIn.ServiceProvider.GetService<WriterFactory>();
|
static WriterFactory writerFactory = RhSolutionsAddIn.ServiceProvider.GetService<WriterFactory>();
|
||||||
static FittingsCalculatorFactory fittingsCalculatorFactory = RhSolutionsAddIn.ServiceProvider.GetService<FittingsCalculatorFactory>();
|
static FittingsCalculatorFactory fittingsCalculatorFactory = RhSolutionsAddIn.ServiceProvider.GetService<FittingsCalculatorFactory>();
|
||||||
|
static Application application = RhSolutionsAddIn.ServiceProvider.GetService<Application>();
|
||||||
|
|
||||||
public Tool GetTool(string toolName)
|
public Tool GetTool(string toolName)
|
||||||
{
|
{
|
||||||
@ -17,7 +18,7 @@ internal class ToolFactory
|
|||||||
"guess" => new GuessTool(readerFactory, writerFactory),
|
"guess" => new GuessTool(readerFactory, writerFactory),
|
||||||
"fillsleeves" => new FittingsTool(readerFactory, writerFactory, fittingsCalculatorFactory, "Sleeves"),
|
"fillsleeves" => new FittingsTool(readerFactory, writerFactory, fittingsCalculatorFactory, "Sleeves"),
|
||||||
"fillcouplings" => new FittingsTool(readerFactory, writerFactory, fittingsCalculatorFactory, "Couplings"),
|
"fillcouplings" => new FittingsTool(readerFactory, writerFactory, fittingsCalculatorFactory, "Couplings"),
|
||||||
"ocr" => new OcrTool(readerFactory, writerFactory),
|
"ocr" => new OcrTool(readerFactory, writerFactory, application),
|
||||||
_ => throw new Exception($"Неизвестный инструмент {toolName}"),
|
_ => throw new Exception($"Неизвестный инструмент {toolName}"),
|
||||||
};
|
};
|
||||||
return tool;
|
return tool;
|
||||||
|
Loading…
Reference in New Issue
Block a user