private void SelectSourceLocation(LinePositionSpan span)
        {
            ThreadHelper.ThrowIfNotOnUIThread();
            var hostService = _visualStudioServices.GetHostEnvironmentService();
            var selection   = hostService.ActiveDocument.Selection as TextSelection;

            if (selection == null)
            {
                return;
            }

            selection.MoveTo(span.Start.Line + 1, span.Start.Character + 1, Extend: false);
            selection.MoveTo(span.End.Line + 1, span.End.Character + 1, Extend: true);
        }
예제 #2
0
        private async Task <Window> GetMainWindowAsync()
        {
            var hostEnvironmentService = _visualStudioServices.GetHostEnvironmentService();

            await ThreadHelper.JoinableTaskFactory.SwitchToMainThreadAsync();

            var parentWindowHandle = new IntPtr(hostEnvironmentService.MainWindow.HWnd);
            var hwndSource         = HwndSource.FromHwnd(parentWindowHandle);
            var window             = (Window)hwndSource?.RootVisual;

            if (window == null)
            {
                throw new Exception("Could not get main window.");
            }

            return(window);
        }