RhSolutions-AddIn/RhSolutions.AddIn/Services/AddInConfiguration.cs
2023-04-01 15:24:04 +03:00

104 lines
2.3 KiB
C#

using System.Configuration;
using System.IO;
namespace RhSolutions.Services;
public class AddInConfiguration : ApplicationSettingsBase, IAddInConfiguration
{
private Dictionary<string, string> _priceListParameters;
public AddInConfiguration()
{
_priceListParameters = new Dictionary<string, string>()
{
["Amount"] = AmountHeader,
["OldSku"] = OldSkuHeader,
["Sku"] = SkuHeader,
["Group"] = GroupHeader,
["Name"] = NameHeader
};
}
[UserScopedSetting]
[DefaultSettingValue("Кол-во")]
public string AmountHeader
{
get
{
return (string)this[nameof(AmountHeader)];
}
}
[UserScopedSetting]
[DefaultSettingValue("Прежний материал")]
public string OldSkuHeader
{
get
{
return (string)this[nameof(OldSkuHeader)];
}
}
[UserScopedSetting]
[DefaultSettingValue("Актуальный материал")]
public string SkuHeader
{
get
{
return (string)this[nameof(SkuHeader)];
}
}
[UserScopedSetting]
[DefaultSettingValue("Программа")]
public string GroupHeader
{
get
{
return (string)this[nameof(GroupHeader)];
}
}
[UserScopedSetting]
[DefaultSettingValue("Наименование")]
public string NameHeader
{
get
{
return (string)this[nameof(NameHeader)];
}
}
[UserScopedSetting]
public string PriceListPath
{
get
{
return (string)this[nameof(PriceListPath)];
}
set
{
this[nameof(PriceListPath)] = value;
}
}
public event SettingChangingEventHandler OnSettingsChange
{
add
{
base.SettingChanging += value;
}
remove
{
base.SettingChanging -= value;
}
}
public string GetPriceListFileName() => Path.GetFileName(PriceListPath);
public string GetPriceListPath() => PriceListPath;
public void SetPriceListPath(string value) => PriceListPath = value;
public void SaveSettings() => base.Save();
public Dictionary<string, string> GetPriceListParameters() => _priceListParameters;
}