是否可以修改 Visual Studio 中的导航栏,或者以其他方式向代码编辑器添加类似的图形元素?
我喜欢 C# 代码中区域提供的分组和可浏览性,但不喜欢维护它们的手动过程(即使自动格式化工具也不是完美的,因为它们需要一段时间才能处理大文件),并且其他开发人员不喜欢它们因此,更好的解决方案是由 IDE 自动完成且无需触及代码。 Visual Studio 已经具有与导航栏类似的功能,可以按字母顺序浏览类和成员,但它不提供按代码元素类型进行分组。我想要做的是让导航栏具有三个部分而不是两个:第一个显示类,第二个显示按字母顺序排序的成员,第三个显示按元素类型嵌套的成员,如区域提供的(例如字段、属性) 、公共方法、事件处理程序等)。我可以通过 Visual Studio SDK 以任何方式访问此导航栏吗?如果没有,我可以向代码编辑器添加类似的图形元素并从头开始构建它吗?另一种方法是在工具窗口中实现我的想法并将其对接,类似于 ReSharper 的文件结构窗口,这不太理想。谢谢!
I like the grouping and browsability that regions provide in C# code but don't like the manual process of maintaining them (even auto-formatting tools are not perfect as they take awhile for large files), and other developers don't like them at all, so a better solution would be one that is done automatically by the IDE and without touching code. Visual Studio already has something along these lines with the Navigation Bar to browse classes and members alphabetically, but it provides no grouping by code element type. What I'd like to do is have the Navigation Bar have three sections instead of two: the first shows classes, the second shows members sorted alphabetically, and the third would show members nested by element type, like regions provide (e.g. Fields, Properties, Public Methods, Event Handlers, etc.). Can I gain access to this Navigation Bar in any way through the Visual Studio SDK, and if not, could I add a similar graphical element to the code editor and build it from scratch? The alternative is implementing my idea in a tool window and docking it, similar to ReSharper's File Structure window, which would be less ideal. Thanks!
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
我不认为您可以根据需要扩展内置导航栏,但在 Visual Studio 2010 中,您可以创建自己的导航栏作为视图边距 IWpfTextViewMargin。在您的实现中,您需要使用 代码模型 API 并将您显示的内容与插入符号移动同步。
I don't think you can extend built-in navigation bar for what you want, but in Visual Studio 2010 you can create your own nav bar as a view margin IWpfTextViewMargin. In your implementation you would need to scan current file for classes and members using the Code Model API and synchronize what you show with the caret movement.