RhSolutions-AddIn/RhSolutions.AddIn/Tools/EventsUtil.cs
2023-05-23 07:55:58 +03:00

66 lines
2.3 KiB
C#

using Microsoft.Office.Interop.Excel;
using RhSolutions.AddIn;
using RhSolutions.Controllers;
using System.Configuration;
#if !NET472
using System.Runtime.Versioning;
#endif
namespace RhSolutions.Tools
{
#if !NET472
[SupportedOSPlatform("windows")]
#endif
internal static class EventsUtil
{
public static void Initialize()
{
RhSolutionsAddIn.Excel.SheetSelectionChange += RefreshExportButton;
RhSolutionsAddIn.Excel.SheetActivate += RefreshConvertButton;
RhSolutionsAddIn.Excel.SheetActivate += RefreshDxfButton;
RhSolutionsAddIn.Excel.SheetActivate += RefreshGuessButton;
RhSolutionsAddIn.Excel.WorkbookActivate += RefreshConvertButton;
RhSolutionsAddIn.Excel.WorkbookActivate += RefreshDxfButton;
RhSolutionsAddIn.Excel.WorkbookActivate += RefreshGuessButton;
RhSolutionsAddIn.Configuration.OnSettingsChange += RefreshSettingTitle;
}
public static void Uninitialize()
{
RhSolutionsAddIn.Excel.SheetSelectionChange -= RefreshExportButton;
RhSolutionsAddIn.Excel.SheetActivate -= RefreshConvertButton;
RhSolutionsAddIn.Excel.SheetActivate -= RefreshDxfButton;
RhSolutionsAddIn.Excel.SheetActivate -= RefreshGuessButton;
RhSolutionsAddIn.Excel.WorkbookActivate -= RefreshConvertButton;
RhSolutionsAddIn.Excel.WorkbookActivate -= RefreshDxfButton;
RhSolutionsAddIn.Excel.WorkbookActivate -= RefreshGuessButton;
RhSolutionsAddIn.Configuration.OnSettingsChange -= RefreshSettingTitle;
}
private static void RefreshConvertButton(object sh)
{
RibbonController.RefreshControl("convert");
}
private static void RefreshDxfButton(object sh)
{
RibbonController.RefreshControl("dxfexport");
}
private static void RefreshExportButton(object sh, Range target)
{
RibbonController.RefreshControl("export");
}
private static void RefreshGuessButton(object sh)
{
RibbonController.RefreshControl("Guessexport");
}
private static void RefreshSettingTitle(object sender, SettingChangingEventArgs e)
{
RibbonController.RefreshControl("setPriceList");
}
}
}