From 2511d1b4440d7c450eb50e1eafdc2ac11b42a5e0 Mon Sep 17 00:00:00 2001 From: Sergey Chebotar Date: Fri, 17 Dec 2021 09:07:03 +0300 Subject: Add RegistryUtil --- Source/AddIn/RegistryUtil.cs | 76 ++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 76 insertions(+) create mode 100644 Source/AddIn/RegistryUtil.cs (limited to 'Source/AddIn/RegistryUtil.cs') diff --git a/Source/AddIn/RegistryUtil.cs b/Source/AddIn/RegistryUtil.cs new file mode 100644 index 0000000..105d5af --- /dev/null +++ b/Source/AddIn/RegistryUtil.cs @@ -0,0 +1,76 @@ +using Microsoft.Win32; + +namespace RehauSku +{ + static class RegistryUtil + { + public static string PriceListPath + { + get + { + _GetRootKey(); + + if (_RootKey == null) + { + return @"D:\Dropbox\Рабочее\Таблица заказов ИС EAE_2021.xlsm"; + } + + else return (string)_RootKey.GetValue("PriceListPath"); + } + + private set + { + _GetRootKey(); + + if (_RootKey == null) + { + RegistryKey PriceListPath = Registry.CurrentUser + .CreateSubKey("SOFTWARE") + .CreateSubKey("REHAU") + .CreateSubKey("SkuAssist"); + } + + _RootKey.SetValue("PriceListPath", value); + } + } + + public static ResponseOrder StoreResponseOrder + { + get + { + _GetRootKey(); + + if (_RootKey == null) + { + return ResponseOrder.Default; + } + + return (ResponseOrder)_RootKey.GetValue("ResponseOrder"); + } + + private set + { + if (_RootKey == null) + { + RegistryKey PriceListPath = Registry.CurrentUser + .CreateSubKey("SOFTWARE") + .CreateSubKey("REHAU") + .CreateSubKey("SkuAssist"); + } + + _RootKey.SetValue("ResponseOrder", value); + } + } + + private static RegistryKey _RootKey { get; set; } + + private static void _GetRootKey() + { + _RootKey = Registry + .CurrentUser + .OpenSubKey("SOFTWARE") + .OpenSubKey("REHAU") + .OpenSubKey("SkuAssist"); + } + } +} -- cgit v1.2.3 From f97d344f39c46b5e2f883765e8859e78007a11b0 Mon Sep 17 00:00:00 2001 From: Sergey Chebotar Date: Wed, 22 Dec 2021 08:26:54 +0300 Subject: Add Registry Util --- Source/AddIn/RegistryUtil.cs | 74 ++++++++++++-------------------------------- 1 file changed, 20 insertions(+), 54 deletions(-) (limited to 'Source/AddIn/RegistryUtil.cs') diff --git a/Source/AddIn/RegistryUtil.cs b/Source/AddIn/RegistryUtil.cs index 105d5af..6ab7682 100644 --- a/Source/AddIn/RegistryUtil.cs +++ b/Source/AddIn/RegistryUtil.cs @@ -6,71 +6,37 @@ namespace RehauSku { public static string PriceListPath { - get - { - _GetRootKey(); - - if (_RootKey == null) - { - return @"D:\Dropbox\Рабочее\Таблица заказов ИС EAE_2021.xlsm"; - } - - else return (string)_RootKey.GetValue("PriceListPath"); - } - - private set - { - _GetRootKey(); - - if (_RootKey == null) - { - RegistryKey PriceListPath = Registry.CurrentUser - .CreateSubKey("SOFTWARE") - .CreateSubKey("REHAU") - .CreateSubKey("SkuAssist"); - } - - _RootKey.SetValue("PriceListPath", value); - } + get => (string)_RootKey.GetValue("PriceListPath"); } public static ResponseOrder StoreResponseOrder { - get - { - _GetRootKey(); - - if (_RootKey == null) - { - return ResponseOrder.Default; - } - - return (ResponseOrder)_RootKey.GetValue("ResponseOrder"); - } + get => (ResponseOrder)_RootKey.GetValue("StoreResponseOrder"); + } - private set + private static RegistryKey _RootKey + { + get { - if (_RootKey == null) - { - RegistryKey PriceListPath = Registry.CurrentUser - .CreateSubKey("SOFTWARE") - .CreateSubKey("REHAU") - .CreateSubKey("SkuAssist"); - } - - _RootKey.SetValue("ResponseOrder", value); + return _OpenRootKey() ?? _CreateRootKey(); } } - private static RegistryKey _RootKey { get; set; } + private static RegistryKey _OpenRootKey() + { + return Registry.CurrentUser + .OpenSubKey(@"SOFTWARE\REHAU\SkuAssist"); + } - private static void _GetRootKey() + private static RegistryKey _CreateRootKey() { - _RootKey = Registry - .CurrentUser - .OpenSubKey("SOFTWARE") - .OpenSubKey("REHAU") - .OpenSubKey("SkuAssist"); + RegistryKey key = Registry.CurrentUser + .CreateSubKey(@"SOFTWARE\REHAU\SkuAssist"); + + key.SetValue("PriceListPath", @"D:\Dropbox\Рабочее\Таблица заказов ИС EAE_2021.xlsm"); + key.SetValue("StoreResponseOrder", 0); + + return key; } } } -- cgit v1.2.3 From ce5597d042062c820288c63b4e571ee77ac23ab0 Mon Sep 17 00:00:00 2001 From: Sergey Chebotar Date: Wed, 22 Dec 2021 17:07:37 +0300 Subject: RegistryUtil and some fixes --- Source/AddIn/RegistryUtil.cs | 57 +++++++++++++++++++++++++++++--------------- 1 file changed, 38 insertions(+), 19 deletions(-) (limited to 'Source/AddIn/RegistryUtil.cs') diff --git a/Source/AddIn/RegistryUtil.cs b/Source/AddIn/RegistryUtil.cs index 6ab7682..19f48b8 100644 --- a/Source/AddIn/RegistryUtil.cs +++ b/Source/AddIn/RegistryUtil.cs @@ -1,42 +1,61 @@ using Microsoft.Win32; +using System.IO; namespace RehauSku { static class RegistryUtil { - public static string PriceListPath + private static string _priceListPath; + private static int? _storeResponseOrder; + private static RegistryKey _RootKey { get; set; } + + public static void Initialize() { - get => (string)_RootKey.GetValue("PriceListPath"); + _RootKey = Registry.CurrentUser.CreateSubKey(@"SOFTWARE\REHAU\SkuAssist"); + _priceListPath = _RootKey.GetValue("PriceListPath") as string; + _storeResponseOrder = _RootKey.GetValue("StoreResponseOrder") as int?; } - public static ResponseOrder StoreResponseOrder + public static bool IsPriceListPathEmpty() { - get => (ResponseOrder)_RootKey.GetValue("StoreResponseOrder"); + return string.IsNullOrEmpty(_priceListPath); } - private static RegistryKey _RootKey + public static string PriceListPath { get { - return _OpenRootKey() ?? _CreateRootKey(); - } - } + if (IsPriceListPathEmpty() || !File.Exists(_priceListPath)) + { + string fileName = FileDialog.GetFilePath(); + _priceListPath = fileName; + _RootKey.SetValue("PriceListPath", fileName); + return _priceListPath; + } - private static RegistryKey _OpenRootKey() - { - return Registry.CurrentUser - .OpenSubKey(@"SOFTWARE\REHAU\SkuAssist"); + else + { + return _priceListPath; + } + } } - private static RegistryKey _CreateRootKey() + public static ResponseOrder StoreResponseOrder { - RegistryKey key = Registry.CurrentUser - .CreateSubKey(@"SOFTWARE\REHAU\SkuAssist"); - - key.SetValue("PriceListPath", @"D:\Dropbox\Рабочее\Таблица заказов ИС EAE_2021.xlsm"); - key.SetValue("StoreResponseOrder", 0); + get + { + if (_storeResponseOrder == null) + { + _RootKey.SetValue("StoreResponseOrder", (int)ResponseOrder.Default); + _storeResponseOrder = (int)ResponseOrder.Default; + return (ResponseOrder)_storeResponseOrder.Value; + } - return key; + else + { + return (ResponseOrder)_storeResponseOrder.Value; + } + } } } } -- cgit v1.2.3 From 0513ac5ad7c7de498b794c27728c2c8ff306f941 Mon Sep 17 00:00:00 2001 From: Sergey Chebotar Date: Thu, 23 Dec 2021 15:31:23 +0300 Subject: Rename to ExportTool --- Source/AddIn/RegistryUtil.cs | 5 +++++ 1 file changed, 5 insertions(+) (limited to 'Source/AddIn/RegistryUtil.cs') diff --git a/Source/AddIn/RegistryUtil.cs b/Source/AddIn/RegistryUtil.cs index 19f48b8..ef1398e 100644 --- a/Source/AddIn/RegistryUtil.cs +++ b/Source/AddIn/RegistryUtil.cs @@ -16,6 +16,11 @@ namespace RehauSku _storeResponseOrder = _RootKey.GetValue("StoreResponseOrder") as int?; } + public static void Uninitialize() + { + _RootKey.Close(); + } + public static bool IsPriceListPathEmpty() { return string.IsNullOrEmpty(_priceListPath); -- cgit v1.2.3 From 24024b5729c1c44bb01cb29813868743d1753e31 Mon Sep 17 00:00:00 2001 From: Sergey Chebotar Date: Fri, 24 Dec 2021 16:22:03 +0300 Subject: MergeTool, MemoryUtil anf stuff --- Source/AddIn/RegistryUtil.cs | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) (limited to 'Source/AddIn/RegistryUtil.cs') diff --git a/Source/AddIn/RegistryUtil.cs b/Source/AddIn/RegistryUtil.cs index ef1398e..3e7c120 100644 --- a/Source/AddIn/RegistryUtil.cs +++ b/Source/AddIn/RegistryUtil.cs @@ -1,5 +1,7 @@ using Microsoft.Win32; using System.IO; +using RehauSku.Forms; +using System.Windows.Forms; namespace RehauSku { @@ -19,6 +21,7 @@ namespace RehauSku public static void Uninitialize() { _RootKey.Close(); + } public static bool IsPriceListPathEmpty() @@ -32,7 +35,8 @@ namespace RehauSku { if (IsPriceListPathEmpty() || !File.Exists(_priceListPath)) { - string fileName = FileDialog.GetFilePath(); + MessageBox.Show("Прайс-лист отсутствует или неверный файл прайс-листа", "Укажите файл прайс-листа", MessageBoxButtons.OK, MessageBoxIcon.Warning); + string fileName = Dialog.GetFilePath(); _priceListPath = fileName; _RootKey.SetValue("PriceListPath", fileName); return _priceListPath; -- cgit v1.2.3 From 20cfbfcca3a779c04aecdca5e4b465651e2be42a Mon Sep 17 00:00:00 2001 From: Sergey Chebotar Date: Fri, 24 Dec 2021 17:42:20 +0300 Subject: New release --- Source/AddIn/RegistryUtil.cs | 6 ++++++ 1 file changed, 6 insertions(+) (limited to 'Source/AddIn/RegistryUtil.cs') diff --git a/Source/AddIn/RegistryUtil.cs b/Source/AddIn/RegistryUtil.cs index 3e7c120..40d0ec2 100644 --- a/Source/AddIn/RegistryUtil.cs +++ b/Source/AddIn/RegistryUtil.cs @@ -47,6 +47,12 @@ namespace RehauSku return _priceListPath; } } + + set + { + _priceListPath = value; + _RootKey.SetValue("PriceListPath", value); + } } public static ResponseOrder StoreResponseOrder -- cgit v1.2.3