From dbaa8b111a5d869159db7e58b14c026806265874 Mon Sep 17 00:00:00 2001 From: Serghei Cebotari Date: Wed, 6 Nov 2024 23:43:00 +0300 Subject: Add snipping tool --- RhSolutions.AddIn/AddIn/RhSolutionsAddIn.cs | 106 ++++----- RhSolutions.AddIn/Controllers/RibbonController.cs | 249 +++++++++++----------- RhSolutions.AddIn/RhSolutions-AddIn.dna | 1 + RhSolutions.AddIn/RhSolutions.AddIn.csproj | 1 + RhSolutions.AddIn/Tools/OcrTool.cs | 22 ++ RhSolutions.AddIn/Tools/Tool.cs | 32 +-- RhSolutions.AddIn/Tools/ToolFactory.cs | 37 ++-- RhSolutions.sln | 6 + SnippingTool/SnippingTool.Designer.cs | 38 ++++ SnippingTool/SnippingTool.cs | 86 ++++++++ SnippingTool/SnippingTool.csproj | 12 ++ 11 files changed, 380 insertions(+), 210 deletions(-) create mode 100644 RhSolutions.AddIn/Tools/OcrTool.cs create mode 100644 SnippingTool/SnippingTool.Designer.cs create mode 100644 SnippingTool/SnippingTool.cs create mode 100644 SnippingTool/SnippingTool.csproj diff --git a/RhSolutions.AddIn/AddIn/RhSolutionsAddIn.cs b/RhSolutions.AddIn/AddIn/RhSolutionsAddIn.cs index 983c0e6..1666df4 100644 --- a/RhSolutions.AddIn/AddIn/RhSolutionsAddIn.cs +++ b/RhSolutions.AddIn/AddIn/RhSolutionsAddIn.cs @@ -4,57 +4,57 @@ namespace RhSolutions.AddIn; public sealed class RhSolutionsAddIn : IExcelAddIn { - public static Application Excel { get; private set; } - public static ServiceProvider ServiceProvider { get; private set; } - public static IAddInConfiguration Configuration { get; private set; } - - public void AutoOpen() - { - IServiceCollection Services = new ServiceCollection(); - - Services.AddHttpClient() - .AddMemoryCache() - .AddSingleton((Application)ExcelDnaUtil.Application) - .AddSingleton() - .AddSingleton() - .AddSingleton() - .AddTransient(); - - Services.AddSingleton(); - Services.AddTransient() - .AddTransient(s => s.GetService()); - Services.AddTransient() - .AddTransient(s => s.GetService()); - Services.AddTransient() - .AddTransient(s => s.GetService()); - - Services.AddSingleton(); - Services.AddTransient() - .AddTransient(s => s.GetService()); - Services.AddTransient() - .AddTransient(s => s.GetService()); - - Services.AddSingleton(); - Services.AddTransient() - .AddTransient(s => s.GetService()); - Services.AddTransient() - .AddTransient(s => s.GetService()); - - Services.AddSingleton(); - - ServiceProvider = Services.BuildServiceProvider(); - Configuration = ServiceProvider.GetService(); - Excel = ServiceProvider.GetService(); - - EventsUtil.Initialize(); - - ServicePointManager.SecurityProtocol = - SecurityProtocolType.Tls12; - ServicePointManager.DefaultConnectionLimit = 50; - } - - public void AutoClose() - { - EventsUtil.Uninitialize(); - } + public static Application Excel { get; private set; } + public static ServiceProvider ServiceProvider { get; private set; } + public static IAddInConfiguration Configuration { get; private set; } + + public void AutoOpen() + { + IServiceCollection Services = new ServiceCollection(); + + Services.AddHttpClient() + .AddMemoryCache() + .AddSingleton((Application)ExcelDnaUtil.Application) + .AddSingleton() + .AddSingleton() + .AddSingleton() + .AddTransient(); + + Services.AddSingleton(); + Services.AddTransient() + .AddTransient(s => s.GetService()); + Services.AddTransient() + .AddTransient(s => s.GetService()); + Services.AddTransient() + .AddTransient(s => s.GetService()); + + Services.AddSingleton(); + Services.AddTransient() + .AddTransient(s => s.GetService()); + Services.AddTransient() + .AddTransient(s => s.GetService()); + + Services.AddSingleton(); + Services.AddTransient() + .AddTransient(s => s.GetService()); + Services.AddTransient() + .AddTransient(s => s.GetService()); + + Services.AddSingleton(); + + ServiceProvider = Services.BuildServiceProvider(); + Configuration = ServiceProvider.GetService(); + Excel = ServiceProvider.GetService(); + + EventsUtil.Initialize(); + + ServicePointManager.SecurityProtocol = + SecurityProtocolType.Tls12; + ServicePointManager.DefaultConnectionLimit = 50; + } + + public void AutoClose() + { + EventsUtil.Uninitialize(); + } } diff --git a/RhSolutions.AddIn/Controllers/RibbonController.cs b/RhSolutions.AddIn/Controllers/RibbonController.cs index aecdc02..9123940 100644 --- a/RhSolutions.AddIn/Controllers/RibbonController.cs +++ b/RhSolutions.AddIn/Controllers/RibbonController.cs @@ -9,127 +9,130 @@ namespace RhSolutions.Controllers; [ComVisible(true)] public class RibbonController : ExcelRibbon { - private static IRibbonUI ribbonUi; - private static bool _workbookIsValid; - - public override string GetCustomUI(string RibbonID) - { - return @" - - - - - -