RhSolutions-AddIn/RhSolutions.AddIn/Tools/EventsUtil.cs

49 lines
1.5 KiB
C#

using RhSolutions.Controllers;
#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 += RefreshButtons;
RhSolutionsAddIn.Excel.WorkbookActivate += RefreshButtons;
RhSolutionsAddIn.Configuration.OnSettingsChange += RefreshSettingTitle;
}
public static void Uninitialize()
{
RhSolutionsAddIn.Excel.SheetSelectionChange -= RefreshExportButton;
RhSolutionsAddIn.Excel.SheetActivate -= RefreshButtons;
RhSolutionsAddIn.Excel.WorkbookActivate -= RefreshButtons;
RhSolutionsAddIn.Configuration.OnSettingsChange -= RefreshSettingTitle;
}
private static void RefreshButtons(object sh)
{
RibbonController.UpdateWorkbookValidation();
RibbonController.RefreshControl("convert");
RibbonController.RefreshControl("dxfexport");
RibbonController.RefreshControl("guess");
RibbonController.RefreshControl("fillsleeves");
RibbonController.RefreshControl("fillcouplings");
}
private static void RefreshExportButton(object sh, Range target)
{
RibbonController.RefreshControl("export");
}
private static void RefreshSettingTitle()
{
RibbonController.RefreshControl("setPriceList");
}
}