aboutsummaryrefslogtreecommitdiff
path: root/src/Services/EventsUtil.cs
blob: bb371252adf13c5a766716edcc789ae8de37e169 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
using Microsoft.Office.Interop.Excel;
using RhSolutions.AddIn;
using RhSolutions.Controllers;

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;
        }

        public static void Uninitialize()
        {
            Excel.SheetSelectionChange -= RefreshExportButton;
            Excel.SheetActivate -= RefreshConvertButton;
            Excel.WorkbookActivate -= RefreshConvertButton;
        }

        private static void RefreshConvertButton(object sh)
        {
            RibbonController.RefreshControl("convert");
        }

        private static void RefreshExportButton(object sh, Range target)
        {
            RibbonController.RefreshControl("export");
        }
    }
}