public void CreateLogPane() { try { var removeItems = new List <CustomTaskPane>(); // remove non-visible panes foreach (var pane in CustomTaskPanes) { try { if (!pane.Visible) { removeItems.Add(pane); } } catch (Exception) { removeItems.Add(pane); } } foreach (var customTaskPane in removeItems) { CustomTaskPanes.Remove(customTaskPane); } var currWindow = Application.Windows[1]; var visible = false; foreach (var pane in CustomTaskPanes) { if (((Window)pane.Window).Hwnd == currWindow.Hwnd) { visible = true; LogPane = pane; Pane = LogPane.Control as LogPane; break; } } if (!visible) { Pane = new LogPane(); LogPane = CustomTaskPanes.Add(Pane, "TheySay Log", currWindow); } LogPane.Visible = true; } catch (Exception ex) { Debug.WriteLine(ex.Message); } }
private void ThisAddIn_Startup(object sender, EventArgs e) { Pane = new LogPane(); LogBuffer = new LogBuffer(Excel.Default.LogEntries); }