如何在不改变窗口焦点的情况下打破所有
在测试 Windows 窗体 UI 时,我经常想在它运行时修改代码.单击Break All"箭头为我执行此操作,但是 Visual Studio 始终显示 Program.cs 窗口并将焦点设置在 Application.Run() 方法上,这有点使.然而,大多数情况下,我想要编辑的代码就在我面前,而不得不关闭 Program.cs 窗口是一件很烦人的事情,我只是不想这样做.
When testing a Windows Forms UI I shall often want to modify the code whilst it is running. Clicking on the "Break All" arrow does this for me, however Visual Studio always displays the Program.cs window and sets focus on the Application.Run() method, which kinda makes. However most of the time I have the code I want to edit right in front of me and having to close the Program.cs window is an annoyance and something I just don't want to do.
有没有一种简单的方法可以让代码在当前窗口中断?
Is there an easy way to get the code to Break in the current window?
我发现的唯一方法是编写一个小宏来暂停代码,检查是否已创建新窗口,如果已创建,则关闭它.这并不理想,而且相当简陋,但它可以完成工作.然后我刚刚添加了一个名为Break In Place"的工具栏命令,它位于我的调试工具栏中.如果有人感兴趣,宏的代码是:
The only way I've found is to write a little macro that will pause the code, check if a new window has been created and, if so, close it. It's not ideal and it is rather rudimentary but it does the job. I've then just added a Toolbar command called "Break In Place" which sits in my Debug Toolbar. The code for the macro if anyone is interested is:
Option Strict Off
Option Explicit Off
Imports System
Imports EnvDTE
Imports EnvDTE80
Imports EnvDTE90
Imports System.Diagnostics
Public Module Break
Sub BreakInPlace()
Dim activeWindow As EnvDTE.Window
activeWindow = DTE.ActiveWindow
DTE.Debugger.Break(True)
If Not activeWindow Is DTE.ActiveWindow Then
DTE.ActiveWindow.Close(vsSaveChanges.vsSaveChangesNo)
End If
End Sub
End Module
要移回之前的位置,请使用 View->Navigate Backward
(Ctrl + -) - 一次或最多几次.在最新的光标位置上移动速度非常快.
To move back to your previous position use View->Navigate Backward
(Ctrl + -) - once or max few times. It speeds a lot moving over latests cursor positions.
另一方面 View->Navigate Forward
(Ctrl + Shift + -) 让我们移动转发(如名称所示).
On the other hand View->Navigate Forward
(Ctrl + Shift + -) lets move forward (as shown by the name).