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

49 lines
1.5 KiB
C#
Raw Normal View History

2023-11-12 16:31:26 +03:00
using RhSolutions.Controllers;
2023-04-06 08:29:39 +03:00
#if !NET472
using System.Runtime.Versioning;
#endif
2022-02-05 12:59:16 +03:00
2023-11-12 16:31:26 +03:00
namespace RhSolutions.Tools;
2023-04-06 08:29:39 +03:00
#if !NET472
2023-11-12 16:31:26 +03:00
[SupportedOSPlatform("windows")]
2023-04-06 08:29:39 +03:00
#endif
2023-11-12 16:31:26 +03:00
internal static class EventsUtil
{
public static void Initialize()
2022-02-05 12:59:16 +03:00
{
2023-11-12 16:31:26 +03:00
RhSolutionsAddIn.Excel.SheetSelectionChange += RefreshExportButton;
RhSolutionsAddIn.Excel.SheetActivate += RefreshButtons;
RhSolutionsAddIn.Excel.WorkbookActivate += RefreshButtons;
RhSolutionsAddIn.Configuration.OnSettingsChange += RefreshSettingTitle;
}
2022-02-05 12:59:16 +03:00
2023-11-12 16:31:26 +03:00
public static void Uninitialize()
{
RhSolutionsAddIn.Excel.SheetSelectionChange -= RefreshExportButton;
RhSolutionsAddIn.Excel.SheetActivate -= RefreshButtons;
RhSolutionsAddIn.Excel.WorkbookActivate -= RefreshButtons;
RhSolutionsAddIn.Configuration.OnSettingsChange -= RefreshSettingTitle;
}
2022-02-05 12:59:16 +03:00
2023-11-12 16:31:26 +03:00
private static void RefreshButtons(object sh)
{
RibbonController.UpdateWorkbookValidation();
RibbonController.RefreshControl("convert");
RibbonController.RefreshControl("dxfexport");
RibbonController.RefreshControl("guess");
RibbonController.RefreshControl("fillsleeves");
RibbonController.RefreshControl("fillcouplings");
}
2023-04-07 08:10:51 +03:00
2023-11-12 16:31:26 +03:00
private static void RefreshExportButton(object sh, Range target)
{
RibbonController.RefreshControl("export");
}
2023-03-28 07:25:10 +03:00
2023-11-12 16:31:26 +03:00
private static void RefreshSettingTitle()
{
RibbonController.RefreshControl("setPriceList");
2022-02-05 12:59:16 +03:00
}
}