aboutsummaryrefslogtreecommitdiff
path: root/Source/AddIn/RegistryUtil.cs
diff options
context:
space:
mode:
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;
+ }
+ }
+ }
+ }
+}