/// <summary> /// Handles the AfterExecute event once a query has been executed /// </summary> /// <param name="Guid">The GUID.</param> /// <param name="ID">The ID.</param> /// <param name="CustomIn">The custom in.</param> /// <param name="CustomOut">The custom out.</param> private void QueryExecute_AfterExecute(string Guid, int ID, object CustomIn, object CustomOut) { if (this.DisplayTransactionLog) { string database = ServiceCache.ScriptFactory.CurrentlyActiveWndConnectionInfo.UIConnectionInfo.AdvancedOptions["DATABASE"]; string connectionString = ConnectionManager.GetConnectionString(ServiceCache.ScriptFactory.CurrentlyActiveWndConnectionInfo.UIConnectionInfo); // Get all window pointers for the app List <IntPtr> pointers = GetChildWindows(ServiceCache.MainShellWindow.Handle); // Get the active doc window Window w = dte.ActiveDocument.Windows.Item(1); if (w.Document != null) { foreach (IntPtr ptr in pointers) { // Try and match the windows based on the caption if (w.Caption.StartsWith(GetText(ptr))) { // Enumerate through the window pointers to find the tab control foreach (IntPtr controlPtr in GetChildWindows(ptr)) { if (ClassName(controlPtr).StartsWith("WindowsForms10.SysTabControl32.app.0.")) { TabControl tabControl = (TabControl)Control.FromHandle(controlPtr); TransactionLogTabPage transactionLogTabPage = new TransactionLogTabPage(); transactionLogTabPage.SetTransactionLogData(LogMonitor.StopMonitoring(database, startLsn, connectionString)); tabControl.TabPages.Add(transactionLogTabPage); transactionLogTabPage.PageClicked += delegate(object sender, PageEventArgs args) { PageViewerContainer c = this.windowManager.CreatePageViewerWindow(connectionString, args.RowId); c.PageViewerWindow.SetLogData((sender as TransactionLogTabPage).LogContents); }; return; } } } } } } }
/// <summary> /// Creates a page viewer window with a given connection string and page address /// </summary> /// <param name="connectionString">The connection string.</param> /// <param name="pageAddress">The page address.</param> /// <returns></returns> public PageViewerContainer CreatePageViewerWindow(string connectionString, RowIdentifier rowIdentifier) { Guid id = Guid.NewGuid(); Windows2 windows2 = applicationObject.Windows as Windows2; if (windows2 != null) { object controlObject = null; Assembly asm = Assembly.GetExecutingAssembly(); Window toolWindow = windows2.CreateToolWindow2(this.addInInstance, asm.Location, "InternalsViewer.SSMSAddIn.PageViewerContainer", "Page Viewer " + rowIdentifier.PageAddress.ToString(), "{" + id.ToString() + "}", ref controlObject); // Make the window a tabbed document toolWindow.Linkable = false; toolWindow.IsFloating = false; PageViewerContainer pageViewerContainer = (controlObject as PageViewerContainer); pageViewerContainer.Window = toolWindow; pageViewerContainer.WindowManager = this; pageViewerContainer.PageViewerWindow.LoadPage(connectionString, rowIdentifier); toolWindow.Visible = true; pageViewerContainer.PageViewerWindow.SetSlot(rowIdentifier.SlotId); return(pageViewerContainer); } else { return(null); } }