diff options
author | Serghei Cebotari <51533848+schebotar@users.noreply.github.com> | 2021-12-26 19:37:46 +0300 |
---|---|---|
committer | GitHub <noreply@github.com> | 2021-12-26 19:37:46 +0300 |
commit | fc870d19555cc77b0e08912b4dab21d496b2321f (patch) | |
tree | ac8b9aa1e883a85339a594b2797ab319cca73c4e /src/AddIn/RegistryUtil.cs | |
parent | 0525ec1b42d5857b740dd0dae7f6d9baeb7088d1 (diff) | |
parent | 54fc3320e7d64d7903b4d091fe0d5c15df01fd78 (diff) |
Merge pull request #9 from schebotar/dev
Move to /src
Diffstat (limited to 'src/AddIn/RegistryUtil.cs')
-rw-r--r-- | src/AddIn/RegistryUtil.cs | 76 |
1 files changed, 76 insertions, 0 deletions
diff --git a/src/AddIn/RegistryUtil.cs b/src/AddIn/RegistryUtil.cs new file mode 100644 index 0000000..40d0ec2 --- /dev/null +++ b/src/AddIn/RegistryUtil.cs @@ -0,0 +1,76 @@ +using Microsoft.Win32; +using System.IO; +using RehauSku.Forms; +using System.Windows.Forms; + +namespace RehauSku +{ + static class RegistryUtil + { + 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?; + } + + public static void Uninitialize() + { + _RootKey.Close(); + + } + + public static bool IsPriceListPathEmpty() + { + return string.IsNullOrEmpty(_priceListPath); + } + + public static string PriceListPath + { + get + { + if (IsPriceListPathEmpty() || !File.Exists(_priceListPath)) + { + MessageBox.Show("Прайс-лист отсутствует или неверный файл прайс-листа", "Укажите файл прайс-листа", MessageBoxButtons.OK, MessageBoxIcon.Warning); + string fileName = Dialog.GetFilePath(); + _priceListPath = fileName; + _RootKey.SetValue("PriceListPath", fileName); + return _priceListPath; + } + + else + { + return _priceListPath; + } + } + + set + { + _priceListPath = value; + _RootKey.SetValue("PriceListPath", value); + } + } + + public static ResponseOrder StoreResponseOrder + { + get + { + if (_storeResponseOrder == null) + { + _RootKey.SetValue("StoreResponseOrder", (int)ResponseOrder.Default); + _storeResponseOrder = (int)ResponseOrder.Default; + return (ResponseOrder)_storeResponseOrder.Value; + } + + else + { + return (ResponseOrder)_storeResponseOrder.Value; + } + } + } + } +} |