RhSolutions-AddIn/RhSolutions.AddIn/Services/EventsUtil.cs
2023-03-28 07:25:10 +03:00

44 lines
1.4 KiB
C#

using Microsoft.Office.Interop.Excel;
using RhSolutions.AddIn;
using RhSolutions.Controllers;
using System.Configuration;
namespace RhSolutions.Services
{
internal static class EventsUtil
{
private static readonly Application Excel = RhSolutionsAddIn.Excel;
public static void Initialize()
{
Excel.SheetSelectionChange += RefreshExportButton;
Excel.SheetActivate += RefreshConvertButton;
Excel.WorkbookActivate += RefreshConvertButton;
RhSolutionsAddIn.Configuration.OnSettingsChange += RefreshSettingTitle;
}
public static void Uninitialize()
{
Excel.SheetSelectionChange -= RefreshExportButton;
Excel.SheetActivate -= RefreshConvertButton;
Excel.WorkbookActivate -= RefreshConvertButton;
RhSolutionsAddIn.Configuration.OnSettingsChange -= RefreshSettingTitle;
}
private static void RefreshConvertButton(object sh)
{
RibbonController.RefreshControl("convert");
}
private static void RefreshExportButton(object sh, Range target)
{
RibbonController.RefreshControl("export");
}
private static void RefreshSettingTitle(object sender, SettingChangingEventArgs e)
{
RibbonController.RefreshControl("setPriceList");
}
}
}