RhSolutions-AddIn/RhSolutions.AddIn/Services/AddInConfiguration.cs
2023-04-20 09:37:07 +03:00

115 lines
2.6 KiB
C#

using System.Configuration;
using System.IO;
namespace RhSolutions.Services;
public class AddInConfiguration : ApplicationSettingsBase, IAddInConfiguration
{
private readonly Dictionary<string, string> _priceListHeaders;
public AddInConfiguration()
{
_priceListHeaders = new Dictionary<string, string>()
{
["Amount"] = AmountHeader,
["OldSku"] = OldSkuHeader,
["Sku"] = SkuHeader,
["ProductLine"] = ProductLineHeader,
["Name"] = NameHeader,
["Measure"] = MeasureHeader
};
}
[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 ProductLineHeader
{
get
{
return (string)this[nameof(ProductLineHeader)];
}
}
[UserScopedSetting]
[DefaultSettingValue("Наименование")]
public string NameHeader
{
get
{
return (string)this[nameof(NameHeader)];
}
}
[UserScopedSetting]
[DefaultSettingValue("Ед. изм.")]
public string MeasureHeader
{
get
{
return (string)this[nameof(MeasureHeader)];
}
}
[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> GetPriceListHeaders() => _priceListHeaders;
}