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

51 lines
1.6 KiB
C#
Raw Normal View History

2022-02-05 12:59:16 +03:00
using Microsoft.Office.Interop.Excel;
2022-12-20 12:41:46 +03:00
using RhSolutions.AddIn;
2022-12-20 12:27:47 +03:00
using RhSolutions.Controllers;
2023-03-28 07:25:10 +03:00
using System.Configuration;
2023-04-06 08:29:39 +03:00
#if !NET472
using System.Runtime.Versioning;
#endif
2022-02-05 12:59:16 +03:00
2023-04-06 08:29:39 +03:00
namespace RhSolutions.Tools
2022-02-05 12:59:16 +03:00
{
2023-04-06 08:29:39 +03:00
#if !NET472
[SupportedOSPlatform("windows")]
#endif
2022-02-05 12:59:16 +03:00
internal static class EventsUtil
{
public static void Initialize()
{
2023-03-28 07:55:45 +03:00
RhSolutionsAddIn.Excel.SheetSelectionChange += RefreshExportButton;
2023-05-27 08:50:30 +03:00
RhSolutionsAddIn.Excel.SheetActivate += RefreshButtons;
RhSolutionsAddIn.Excel.WorkbookActivate += RefreshButtons;
2023-03-28 07:25:10 +03:00
RhSolutionsAddIn.Configuration.OnSettingsChange += RefreshSettingTitle;
2022-02-05 12:59:16 +03:00
}
public static void Uninitialize()
{
2023-03-28 07:55:45 +03:00
RhSolutionsAddIn.Excel.SheetSelectionChange -= RefreshExportButton;
2023-05-27 08:50:30 +03:00
RhSolutionsAddIn.Excel.SheetActivate -= RefreshButtons;
RhSolutionsAddIn.Excel.WorkbookActivate -= RefreshButtons;
2023-03-28 07:25:10 +03:00
RhSolutionsAddIn.Configuration.OnSettingsChange -= RefreshSettingTitle;
2022-02-05 12:59:16 +03:00
}
2023-05-27 08:50:30 +03:00
private static void RefreshButtons(object sh)
2022-02-05 12:59:16 +03:00
{
2023-05-27 08:50:30 +03:00
RibbonController.UpdateWorkbookValidation();
2022-12-20 12:27:47 +03:00
RibbonController.RefreshControl("convert");
2023-04-07 08:10:51 +03:00
RibbonController.RefreshControl("dxfexport");
2023-06-20 09:50:03 +03:00
RibbonController.RefreshControl("guess");
2023-04-07 08:10:51 +03:00
}
2022-02-05 12:59:16 +03:00
private static void RefreshExportButton(object sh, Range target)
{
2022-12-20 12:27:47 +03:00
RibbonController.RefreshControl("export");
2022-02-05 12:59:16 +03:00
}
2023-03-28 07:25:10 +03:00
private static void RefreshSettingTitle(object sender, SettingChangingEventArgs e)
{
RibbonController.RefreshControl("setPriceList");
}
2022-02-05 12:59:16 +03:00
}
}