aboutsummaryrefslogtreecommitdiff
path: root/Source/AddIn/RegistryUtil.cs
diff options
context:
space:
mode:
authorSerghei Cebotari <51533848+schebotar@users.noreply.github.com>2021-12-24 17:43:04 +0300
committerGitHub <noreply@github.com>2021-12-24 17:43:04 +0300
commit0525ec1b42d5857b740dd0dae7f6d9baeb7088d1 (patch)
tree5d9c814fd023395d894ce36a9040cf7f7330198c /Source/AddIn/RegistryUtil.cs
parent8e5db1238ad3ed97f51d9f0a9c7de83c00a12983 (diff)
parent20cfbfcca3a779c04aecdca5e4b465651e2be42a (diff)
Merge pull request #8 from schebotar/dev
Dev
Diffstat (limited to 'Source/AddIn/RegistryUtil.cs')
-rw-r--r--Source/AddIn/RegistryUtil.cs76
1 files changed, 76 insertions, 0 deletions
diff --git a/Source/AddIn/RegistryUtil.cs b/Source/AddIn/RegistryUtil.cs
new file mode 100644
index 0000000..40d0ec2
--- /dev/null
+++ b/Source/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;
+ }
+ }
+ }
+ }
+}