private void ThisAddIn_Startup(object sender, EventArgs e) { // Initialize variables _application = Application; _explorers = _application.Explorers; _inspectors = _application.Inspectors; MessageProvider = new MessageProvider(); Windows = new List <OutlookExplorer>(); InspectorWindows = new List <OutlookInspector>(); StorageProvider = new StorageProvider(); Authentication = new OfficeAddInOAuth(MessageProvider); // Wire up event handlers to handle multiple Explorer windows _explorers.NewExplorer += OutlookEvent_Explorers_NewExplorer; // Wire up event handlers to handle multiple Inspector windows _inspectors.NewInspector += OutlookEvent__Inspectors_NewInspector; MessageProvider.ErrorOccurred += MessageProvider_OnErrorOccurred; // Add the ActiveExplorer to Windows var explorer = _application.ActiveExplorer(); var window = new OutlookExplorer(explorer); Windows.Add(window); // Hook up event handlers for window window.Close += WrappedWindow_Close; window.InvalidateControl += WrappedWindow_InvalidateControl; }
private static void OutlookEvent_Explorers_NewExplorer(Outlook.Explorer explorer) { // Check to see if this is a new window we don't already track var existingWindow = FindOutlookExplorer(explorer); // If the collection has a window for this Explorer then return, otherwise we should add it if (existingWindow != null) { return; } var window = new OutlookExplorer(explorer); window.Close += WrappedWindow_Close; window.InvalidateControl += WrappedWindow_InvalidateControl; Windows.Add(window); }