RhSolutions-AddIn/RhSolutions.AddIn/Services/AddInConfiguration.cs

43 lines
1.3 KiB
C#
Raw Normal View History

2023-11-12 16:31:26 +03:00
using Microsoft.Win32;
2023-03-28 07:25:10 +03:00
using System.IO;
2023-04-01 15:24:04 +03:00
namespace RhSolutions.Services;
2023-11-12 16:31:26 +03:00
public class AddInConfiguration : IAddInConfiguration
2023-03-28 07:25:10 +03:00
{
2023-11-12 16:31:26 +03:00
private RegistryKey _rootKey;
private string _priceListPath;
private Dictionary<string, string> _priceListHeaders;
public event IAddInConfiguration.SettingsHandler OnSettingsChange;
2023-04-01 15:24:04 +03:00
2023-04-20 09:37:07 +03:00
public AddInConfiguration()
2023-04-01 15:24:04 +03:00
{
2023-11-12 16:31:26 +03:00
_rootKey = Registry.CurrentUser.CreateSubKey(@"SOFTWARE\RhSolutions\RhSolutions-AddIn");
_priceListPath = (string)_rootKey.GetValue("PriceListPath");
_priceListHeaders = new()
2023-04-01 15:24:04 +03:00
{
2023-11-12 16:31:26 +03:00
["Amount"] = "Кол-во",
["OldSku"] = "Прежний материал",
["Sku"] = "Актуальный материал",
["ProductLine"] = "Программа",
["Name"] = "Наименование",
["Measure"] = "Ед. изм."
2023-04-01 15:24:04 +03:00
};
}
2023-11-12 16:31:26 +03:00
public string GetPriceListFileName() => Path.GetFileName(_priceListPath);
public Dictionary<string, string> GetPriceListHeaders() => _priceListHeaders;
public string GetPriceListPath() => _priceListPath;
2023-04-20 07:18:16 +03:00
2023-11-12 16:31:26 +03:00
public void SaveSettings()
2023-04-01 15:24:04 +03:00
{
2023-11-12 16:31:26 +03:00
_rootKey.SetValue("PriceListPath", _priceListPath);
OnSettingsChange.Invoke();
2023-03-28 07:25:10 +03:00
}
2023-04-01 15:24:04 +03:00
2023-11-12 16:31:26 +03:00
public void SetPriceListPath(string value)
2023-04-01 15:24:04 +03:00
{
2023-11-12 16:31:26 +03:00
_priceListPath = value;
2023-04-01 15:24:04 +03:00
}
2023-11-12 16:31:26 +03:00
}