Compare commits
No commits in common. "d0c5ed5e1ac82668de8851de713928c4334e7881" and "a065c4c6990e959742faa1bf8bb7ef960146978b" have entirely different histories.
d0c5ed5e1a
...
a065c4c699
@ -32,9 +32,6 @@ public class RibbonController : ExcelRibbon
|
|||||||
<group id='exportTab' label='Экспорт'>
|
<group id='exportTab' label='Экспорт'>
|
||||||
<button id='dxfexport' getEnabled='GetDxfEnabled' label='DXF' size='large' image='DXF' onAction='OnToolPressed'/>
|
<button id='dxfexport' getEnabled='GetDxfEnabled' label='DXF' size='large' image='DXF' onAction='OnToolPressed'/>
|
||||||
</group>
|
</group>
|
||||||
<group id='importTab' label='OCR'>
|
|
||||||
<button id='ocr' label='Распознать таблицу' size='large' imageMso='TableInsert' onAction='OnToolPressed'/>
|
|
||||||
</group>
|
|
||||||
<group id='settings' getLabel='GetVersionLabel'>
|
<group id='settings' getLabel='GetVersionLabel'>
|
||||||
<button id='setPriceList' getLabel='GetPriceListPathLabel' size='large' image='RhSolutions' onAction='OnSetPricePressed'/>
|
<button id='setPriceList' getLabel='GetPriceListPathLabel' size='large' image='RhSolutions' onAction='OnSetPricePressed'/>
|
||||||
</group>
|
</group>
|
||||||
|
@ -23,7 +23,6 @@
|
|||||||
<Reference Path="System.Runtime.CompilerServices.Unsafe.dll" Pack="true" />
|
<Reference Path="System.Runtime.CompilerServices.Unsafe.dll" Pack="true" />
|
||||||
<Reference Path="System.Threading.Tasks.Extensions.dll" Pack="true" />
|
<Reference Path="System.Threading.Tasks.Extensions.dll" Pack="true" />
|
||||||
<Reference Path="System.ValueTuple.dll" Pack="true" />
|
<Reference Path="System.ValueTuple.dll" Pack="true" />
|
||||||
<Reference Path="SnippingTool.dll" Pack="true" />
|
|
||||||
<Image Name='RhSolutions' Path='Images\RhSolutions.png' Pack='true' />
|
<Image Name='RhSolutions' Path='Images\RhSolutions.png' Pack='true' />
|
||||||
<Image Name='DXF' Path='Images\DXF.png' Pack='true' />
|
<Image Name='DXF' Path='Images\DXF.png' Pack='true' />
|
||||||
<Image Name='Sleeve' Path='Images\Sleeve.png' Pack='true' />
|
<Image Name='Sleeve' Path='Images\Sleeve.png' Pack='true' />
|
||||||
|
@ -26,7 +26,6 @@
|
|||||||
</ItemGroup>
|
</ItemGroup>
|
||||||
<ItemGroup>
|
<ItemGroup>
|
||||||
<ProjectReference Include="..\RhSolutions.ProductSku\RhSolutions.ProductSku.csproj" />
|
<ProjectReference Include="..\RhSolutions.ProductSku\RhSolutions.ProductSku.csproj" />
|
||||||
<ProjectReference Include="..\SnippingTool\SnippingTool.csproj" />
|
|
||||||
</ItemGroup>
|
</ItemGroup>
|
||||||
<ItemGroup>
|
<ItemGroup>
|
||||||
<None Update="Images\Coupling.png">
|
<None Update="Images\Coupling.png">
|
||||||
|
@ -1,25 +0,0 @@
|
|||||||
using System.Threading.Tasks;
|
|
||||||
using SnippingTool;
|
|
||||||
|
|
||||||
namespace RhSolutions.Tools;
|
|
||||||
|
|
||||||
internal class OcrTool : Tool
|
|
||||||
{
|
|
||||||
public Application Application { get; set; }
|
|
||||||
public OcrTool(ReaderFactory readerFactory, WriterFactory writerFactory, Application application) : base(readerFactory, writerFactory)
|
|
||||||
{
|
|
||||||
Application = application;
|
|
||||||
}
|
|
||||||
|
|
||||||
public override void Execute()
|
|
||||||
{
|
|
||||||
Application.Visible = false;
|
|
||||||
Task.Run(async delegate
|
|
||||||
{
|
|
||||||
await Task.Delay(100);
|
|
||||||
}).Wait();
|
|
||||||
|
|
||||||
string shot = Snipper.SnipBase64();
|
|
||||||
Application.Visible = true;
|
|
||||||
}
|
|
||||||
}
|
|
@ -5,7 +5,6 @@ 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)
|
||||||
{
|
{
|
||||||
@ -18,7 +17,6 @@ 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, application),
|
|
||||||
_ => throw new Exception($"Неизвестный инструмент {toolName}"),
|
_ => throw new Exception($"Неизвестный инструмент {toolName}"),
|
||||||
};
|
};
|
||||||
return tool;
|
return tool;
|
||||||
|
@ -9,8 +9,6 @@ Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "RhSolutions.Tests", "RhSolu
|
|||||||
EndProject
|
EndProject
|
||||||
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "RhSolutions.ProductSku", "RhSolutions.ProductSku\RhSolutions.ProductSku.csproj", "{59CD05D0-71E0-4027-968A-8BE89A6FDCEF}"
|
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "RhSolutions.ProductSku", "RhSolutions.ProductSku\RhSolutions.ProductSku.csproj", "{59CD05D0-71E0-4027-968A-8BE89A6FDCEF}"
|
||||||
EndProject
|
EndProject
|
||||||
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "SnippingTool", "SnippingTool\SnippingTool.csproj", "{DDB517C7-DF61-4C26-B691-956D0E5906C3}"
|
|
||||||
EndProject
|
|
||||||
Global
|
Global
|
||||||
GlobalSection(SolutionConfigurationPlatforms) = preSolution
|
GlobalSection(SolutionConfigurationPlatforms) = preSolution
|
||||||
Debug|Any CPU = Debug|Any CPU
|
Debug|Any CPU = Debug|Any CPU
|
||||||
@ -29,10 +27,6 @@ Global
|
|||||||
{59CD05D0-71E0-4027-968A-8BE89A6FDCEF}.Debug|Any CPU.Build.0 = Debug|Any CPU
|
{59CD05D0-71E0-4027-968A-8BE89A6FDCEF}.Debug|Any CPU.Build.0 = Debug|Any CPU
|
||||||
{59CD05D0-71E0-4027-968A-8BE89A6FDCEF}.Release|Any CPU.ActiveCfg = Release|Any CPU
|
{59CD05D0-71E0-4027-968A-8BE89A6FDCEF}.Release|Any CPU.ActiveCfg = Release|Any CPU
|
||||||
{59CD05D0-71E0-4027-968A-8BE89A6FDCEF}.Release|Any CPU.Build.0 = Release|Any CPU
|
{59CD05D0-71E0-4027-968A-8BE89A6FDCEF}.Release|Any CPU.Build.0 = Release|Any CPU
|
||||||
{DDB517C7-DF61-4C26-B691-956D0E5906C3}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
|
|
||||||
{DDB517C7-DF61-4C26-B691-956D0E5906C3}.Debug|Any CPU.Build.0 = Debug|Any CPU
|
|
||||||
{DDB517C7-DF61-4C26-B691-956D0E5906C3}.Release|Any CPU.ActiveCfg = Release|Any CPU
|
|
||||||
{DDB517C7-DF61-4C26-B691-956D0E5906C3}.Release|Any CPU.Build.0 = Release|Any CPU
|
|
||||||
EndGlobalSection
|
EndGlobalSection
|
||||||
GlobalSection(SolutionProperties) = preSolution
|
GlobalSection(SolutionProperties) = preSolution
|
||||||
HideSolutionNode = FALSE
|
HideSolutionNode = FALSE
|
||||||
|
@ -1,101 +0,0 @@
|
|||||||
using System.Drawing.Imaging;
|
|
||||||
|
|
||||||
namespace SnippingTool;
|
|
||||||
|
|
||||||
public partial class Snipper : Form
|
|
||||||
{
|
|
||||||
public static Image? Snip()
|
|
||||||
{
|
|
||||||
var rc = Screen.PrimaryScreen.Bounds;
|
|
||||||
using Bitmap bmp = new Bitmap(rc.Width, rc.Height, System.Drawing.Imaging.PixelFormat.Format32bppPArgb);
|
|
||||||
using Graphics gr = Graphics.FromImage(bmp);
|
|
||||||
gr.CopyFromScreen(0, 0, 0, 0, bmp.Size);
|
|
||||||
using var snipper = new Snipper(bmp);
|
|
||||||
|
|
||||||
return snipper.ShowDialog() == DialogResult.OK ? snipper.Image : null;
|
|
||||||
}
|
|
||||||
|
|
||||||
public static string? SnipBase64()
|
|
||||||
{
|
|
||||||
var shot = Snip();
|
|
||||||
if (shot != null)
|
|
||||||
{
|
|
||||||
using MemoryStream ms = new();
|
|
||||||
shot.Save(ms, ImageFormat.Png);
|
|
||||||
byte[] imageBytes = ms.ToArray();
|
|
||||||
return Convert.ToBase64String(imageBytes);
|
|
||||||
}
|
|
||||||
return null;
|
|
||||||
}
|
|
||||||
|
|
||||||
public Snipper(Image screenShot)
|
|
||||||
{
|
|
||||||
InitializeComponent();
|
|
||||||
BackgroundImage = screenShot;
|
|
||||||
ShowInTaskbar = false;
|
|
||||||
FormBorderStyle = FormBorderStyle.None;
|
|
||||||
WindowState = FormWindowState.Maximized;
|
|
||||||
DoubleBuffered = true;
|
|
||||||
}
|
|
||||||
public Image? Image { get; set; }
|
|
||||||
|
|
||||||
private Rectangle rcSelect = new Rectangle();
|
|
||||||
private Point pntStart;
|
|
||||||
|
|
||||||
protected override void OnMouseDown(MouseEventArgs e)
|
|
||||||
{
|
|
||||||
if (e.Button != MouseButtons.Left)
|
|
||||||
{
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
pntStart = e.Location;
|
|
||||||
rcSelect = new Rectangle(e.Location, new Size(0, 0));
|
|
||||||
Invalidate();
|
|
||||||
}
|
|
||||||
protected override void OnMouseMove(MouseEventArgs e)
|
|
||||||
{
|
|
||||||
if (e.Button != MouseButtons.Left)
|
|
||||||
{
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
int x1 = Math.Min(e.X, pntStart.X);
|
|
||||||
int y1 = Math.Min(e.Y, pntStart.Y);
|
|
||||||
int x2 = Math.Max(e.X, pntStart.X);
|
|
||||||
int y2 = Math.Max(e.Y, pntStart.Y);
|
|
||||||
rcSelect = new Rectangle(x1, y1, x2 - x1, y2 - y1);
|
|
||||||
Invalidate();
|
|
||||||
}
|
|
||||||
protected override void OnMouseUp(MouseEventArgs e)
|
|
||||||
{
|
|
||||||
if (rcSelect.Width <= 0 || rcSelect.Height <= 0)
|
|
||||||
{
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
Image = new Bitmap(rcSelect.Width, rcSelect.Height);
|
|
||||||
using Graphics gr = Graphics.FromImage(Image);
|
|
||||||
gr.DrawImage(BackgroundImage, new Rectangle(0, 0, Image.Width, Image.Height),
|
|
||||||
rcSelect, GraphicsUnit.Pixel);
|
|
||||||
DialogResult = DialogResult.OK;
|
|
||||||
}
|
|
||||||
protected override void OnPaint(PaintEventArgs e)
|
|
||||||
{
|
|
||||||
using Brush br = new SolidBrush(Color.FromArgb(120, Color.White));
|
|
||||||
int x1 = rcSelect.X; int x2 = rcSelect.X + rcSelect.Width;
|
|
||||||
int y1 = rcSelect.Y; int y2 = rcSelect.Y + rcSelect.Height;
|
|
||||||
e.Graphics.FillRectangle(br, new Rectangle(0, 0, x1, Height));
|
|
||||||
e.Graphics.FillRectangle(br, new Rectangle(x2, 0, Width - x2, Height));
|
|
||||||
e.Graphics.FillRectangle(br, new Rectangle(x1, 0, x2 - x1, y1));
|
|
||||||
e.Graphics.FillRectangle(br, new Rectangle(x1, y2, x2 - x1, Height - y2));
|
|
||||||
|
|
||||||
using Pen pen = new Pen(Color.Red, 3);
|
|
||||||
e.Graphics.DrawRectangle(pen, rcSelect);
|
|
||||||
}
|
|
||||||
protected override bool ProcessCmdKey(ref Message msg, Keys keyData)
|
|
||||||
{
|
|
||||||
if (keyData == Keys.Escape)
|
|
||||||
{
|
|
||||||
DialogResult = DialogResult.Cancel;
|
|
||||||
}
|
|
||||||
return base.ProcessCmdKey(ref msg, keyData);
|
|
||||||
}
|
|
||||||
}
|
|
38
SnippingTool/SnippingTool.Designer.cs
generated
38
SnippingTool/SnippingTool.Designer.cs
generated
@ -1,38 +0,0 @@
|
|||||||
namespace SnippingTool;
|
|
||||||
|
|
||||||
partial class Snipper
|
|
||||||
{
|
|
||||||
/// <summary>
|
|
||||||
/// Required designer variable.
|
|
||||||
/// </summary>
|
|
||||||
private System.ComponentModel.IContainer components = null;
|
|
||||||
|
|
||||||
/// <summary>
|
|
||||||
/// Clean up any resources being used.
|
|
||||||
/// </summary>
|
|
||||||
/// <param name="disposing">true if managed resources should be disposed; otherwise, false.</param>
|
|
||||||
protected override void Dispose(bool disposing)
|
|
||||||
{
|
|
||||||
if (disposing && (components != null))
|
|
||||||
{
|
|
||||||
components.Dispose();
|
|
||||||
}
|
|
||||||
base.Dispose(disposing);
|
|
||||||
}
|
|
||||||
|
|
||||||
#region Windows Form Designer generated code
|
|
||||||
|
|
||||||
/// <summary>
|
|
||||||
/// Required method for Designer support - do not modify
|
|
||||||
/// the contents of this method with the code editor.
|
|
||||||
/// </summary>
|
|
||||||
private void InitializeComponent()
|
|
||||||
{
|
|
||||||
this.components = new System.ComponentModel.Container();
|
|
||||||
this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font;
|
|
||||||
this.ClientSize = new System.Drawing.Size(800, 450);
|
|
||||||
this.Text = "Form1";
|
|
||||||
}
|
|
||||||
|
|
||||||
#endregion
|
|
||||||
}
|
|
@ -1,12 +0,0 @@
|
|||||||
<Project Sdk="Microsoft.NET.Sdk">
|
|
||||||
|
|
||||||
<PropertyGroup>
|
|
||||||
<OutputType>Library</OutputType>
|
|
||||||
<LangVersion>10</LangVersion>
|
|
||||||
<TargetFrameworks>net472;net6.0-windows</TargetFrameworks>
|
|
||||||
<Nullable>enable</Nullable>
|
|
||||||
<UseWindowsForms>true</UseWindowsForms>
|
|
||||||
<ImplicitUsings>enable</ImplicitUsings>
|
|
||||||
</PropertyGroup>
|
|
||||||
|
|
||||||
</Project>
|
|
Loading…
x
Reference in New Issue
Block a user