From 846547d6d905e0dbee73cd9c62760ea43bb88134 Mon Sep 17 00:00:00 2001 From: Sergey Chebotar Date: Sun, 9 Jan 2022 15:47:54 +0300 Subject: Add SaveAs Dialog after export --- src/AddIn/AddIn.cs | 3 +++ src/AddIn/RegistryUtil.cs | 44 ++++++++++++++++++++++---------------------- 2 files changed, 25 insertions(+), 22 deletions(-) (limited to 'src/AddIn') diff --git a/src/AddIn/AddIn.cs b/src/AddIn/AddIn.cs index 67cdcc8..93d8aec 100644 --- a/src/AddIn/AddIn.cs +++ b/src/AddIn/AddIn.cs @@ -1,6 +1,7 @@ using ExcelDna.Integration; using ExcelDna.IntelliSense; using ExcelDna.Registration; +using Microsoft.Office.Interop.Excel; using System.Net.Http; using System.Runtime.Caching; @@ -20,6 +21,7 @@ namespace RehauSku { public static HttpClient httpClient; public static MemoryCache memoryCache; + public static Application Excel; public void AutoOpen() { @@ -28,6 +30,7 @@ namespace RehauSku RegisterFunctions(); IntelliSenseServer.Install(); RegistryUtil.Initialize(); + Excel = (Application)ExcelDnaUtil.Application; } public void AutoClose() diff --git a/src/AddIn/RegistryUtil.cs b/src/AddIn/RegistryUtil.cs index 40d0ec2..ceee2fe 100644 --- a/src/AddIn/RegistryUtil.cs +++ b/src/AddIn/RegistryUtil.cs @@ -2,56 +2,56 @@ using System.IO; using RehauSku.Forms; using System.Windows.Forms; +using ExcelDna.Integration; namespace RehauSku { static class RegistryUtil { - private static string _priceListPath; - private static int? _storeResponseOrder; - private static RegistryKey _RootKey { get; set; } + private static string priceListPath; + private static int? storeResponseOrder; + private static RegistryKey RootKey { get; set; } public static void Initialize() { - _RootKey = Registry.CurrentUser.CreateSubKey(@"SOFTWARE\REHAU\SkuAssist"); - _priceListPath = _RootKey.GetValue("PriceListPath") as string; - _storeResponseOrder = _RootKey.GetValue("StoreResponseOrder") as int?; + RootKey = Registry.CurrentUser.CreateSubKey(@"SOFTWARE\REHAU\SkuAssist"); + priceListPath = RootKey.GetValue("PriceListPath") as string; + storeResponseOrder = RootKey.GetValue("StoreResponseOrder") as int?; } public static void Uninitialize() { - _RootKey.Close(); - + RootKey.Close(); } public static bool IsPriceListPathEmpty() { - return string.IsNullOrEmpty(_priceListPath); + return string.IsNullOrEmpty(priceListPath); } public static string PriceListPath { get { - if (IsPriceListPathEmpty() || !File.Exists(_priceListPath)) + if (IsPriceListPathEmpty() || !File.Exists(priceListPath)) { - MessageBox.Show("Прайс-лист отсутствует или неверный файл прайс-листа", "Укажите файл прайс-листа", MessageBoxButtons.OK, MessageBoxIcon.Warning); + //MessageBox.Show("Прайс-лист отсутствует или неверный файл прайс-листа", "Укажите файл прайс-листа", MessageBoxButtons.OK, MessageBoxIcon.Warning); string fileName = Dialog.GetFilePath(); - _priceListPath = fileName; - _RootKey.SetValue("PriceListPath", fileName); - return _priceListPath; + priceListPath = fileName; + RootKey.SetValue("PriceListPath", fileName); + return priceListPath; } else { - return _priceListPath; + return priceListPath; } } set { - _priceListPath = value; - _RootKey.SetValue("PriceListPath", value); + priceListPath = value; + RootKey.SetValue("PriceListPath", value); } } @@ -59,16 +59,16 @@ namespace RehauSku { get { - if (_storeResponseOrder == null) + if (storeResponseOrder == null) { - _RootKey.SetValue("StoreResponseOrder", (int)ResponseOrder.Default); - _storeResponseOrder = (int)ResponseOrder.Default; - return (ResponseOrder)_storeResponseOrder.Value; + RootKey.SetValue("StoreResponseOrder", (int)ResponseOrder.Default); + storeResponseOrder = (int)ResponseOrder.Default; + return (ResponseOrder)storeResponseOrder.Value; } else { - return (ResponseOrder)_storeResponseOrder.Value; + return (ResponseOrder)storeResponseOrder.Value; } } } -- cgit v1.2.3