RhSolutions-AddIn/Source/AddIn/RegistryUtil.cs

62 lines
1.8 KiB
C#
Raw Normal View History

2021-12-17 09:07:03 +03:00
using Microsoft.Win32;
2021-12-22 17:07:37 +03:00
using System.IO;
2021-12-17 09:07:03 +03:00
namespace RehauSku
{
static class RegistryUtil
{
2021-12-22 17:07:37 +03:00
private static string _priceListPath;
private static int? _storeResponseOrder;
private static RegistryKey _RootKey { get; set; }
public static void Initialize()
2021-12-17 09:07:03 +03:00
{
2021-12-22 17:07:37 +03:00
_RootKey = Registry.CurrentUser.CreateSubKey(@"SOFTWARE\REHAU\SkuAssist");
_priceListPath = _RootKey.GetValue("PriceListPath") as string;
_storeResponseOrder = _RootKey.GetValue("StoreResponseOrder") as int?;
2021-12-17 09:07:03 +03:00
}
2021-12-22 17:07:37 +03:00
public static bool IsPriceListPathEmpty()
2021-12-17 09:07:03 +03:00
{
2021-12-22 17:07:37 +03:00
return string.IsNullOrEmpty(_priceListPath);
2021-12-22 08:26:54 +03:00
}
2021-12-17 09:07:03 +03:00
2021-12-22 17:07:37 +03:00
public static string PriceListPath
2021-12-22 08:26:54 +03:00
{
get
2021-12-17 09:07:03 +03:00
{
2021-12-22 17:07:37 +03:00
if (IsPriceListPathEmpty() || !File.Exists(_priceListPath))
{
string fileName = FileDialog.GetFilePath();
_priceListPath = fileName;
_RootKey.SetValue("PriceListPath", fileName);
return _priceListPath;
}
2021-12-17 09:07:03 +03:00
2021-12-22 17:07:37 +03:00
else
{
return _priceListPath;
}
}
2021-12-22 08:26:54 +03:00
}
2021-12-17 09:07:03 +03:00
2021-12-22 17:07:37 +03:00
public static ResponseOrder StoreResponseOrder
2021-12-17 09:07:03 +03:00
{
2021-12-22 17:07:37 +03:00
get
{
if (_storeResponseOrder == null)
{
_RootKey.SetValue("StoreResponseOrder", (int)ResponseOrder.Default);
_storeResponseOrder = (int)ResponseOrder.Default;
return (ResponseOrder)_storeResponseOrder.Value;
}
2021-12-22 08:26:54 +03:00
2021-12-22 17:07:37 +03:00
else
{
return (ResponseOrder)_storeResponseOrder.Value;
}
}
2021-12-17 09:07:03 +03:00
}
}
}