blob: ad772473293bbdb7c0146ce81993488354214cba (
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
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
|
using ExcelDna.Integration;
using ExcelDna.IntelliSense;
using ExcelDna.Registration;
using Microsoft.Office.Interop.Excel;
using System.Net.Http;
using System.Runtime.Caching;
namespace RehauSku
{
enum ResponseOrder
{
Default,
Relevance,
Name,
Price,
Series
}
class AddIn : IExcelAddIn
{
public static HttpClient httpClient;
public static MemoryCache memoryCache;
public static Application Excel;
public void AutoOpen()
{
httpClient = new HttpClient();
memoryCache = new MemoryCache("RehauSku");
RegisterFunctions();
IntelliSenseServer.Install();
RegistryUtil.Initialize();
Excel = (Application)ExcelDnaUtil.Application;
AddEvents();
}
private void AddEvents()
{
Excel.SheetSelectionChange += RefreshExportButton;
Excel.SheetActivate += RefreshConvertButton;
Excel.WorkbookActivate += RefreshConvertButton;
}
private void RefreshConvertButton(object sh)
{
Interface.RibbonController.RefreshControl("convertPrice");
}
private void RefreshExportButton(object sh, Range target)
{
Interface.RibbonController.RefreshControl("exportToPrice");
}
public void AutoClose()
{
IntelliSenseServer.Uninstall();
RegistryUtil.Uninitialize();
memoryCache.Dispose();
}
void RegisterFunctions()
{
ExcelRegistration.GetExcelFunctions()
.ProcessAsyncRegistrations(nativeAsyncIfAvailable: false)
.RegisterFunctions();
}
}
}
|