VSX - 设置要停靠的 ToolWindowPanes 初始位置
我正在创建一个公开工具窗口的 Visual Studio 包,并尝试确保在包首次加载时将其显示停靠在主 Visual Studio 窗口的左边缘。
[ProvideToolWindow(typeof(MyToolWindow), Orientation = ToolWindowOrientation.Left,
Style=VsDockStyle.Linked, Window=EnvDTE.Constants.vsWindowKindLinkedWindowFrame)])]
[ProvideToolWindowVisibility(typeof(MyToolWindow), VSConstants.UICONTEXT.NoSolution_string)]
public class MyPackage : Package
{
...
我已经尝试了上述的许多变体,但我设法实现的最好的是将窗口停靠在底部 - 即使如此,它仍然继续重新-每次重新加载包时都会停靠,而不是保留用户窗口位置。
如何指定我的窗口窗格最初显示为停靠在主窗口的左侧?
I'm creating a Visual Studio package that exposes a tool window and I'm trying to make sure that it is displayed docked to the left edge of the main Visual Studio window when the package first loads.
[ProvideToolWindow(typeof(MyToolWindow), Orientation = ToolWindowOrientation.Left,
Style=VsDockStyle.Linked, Window=EnvDTE.Constants.vsWindowKindLinkedWindowFrame)])]
[ProvideToolWindowVisibility(typeof(MyToolWindow), VSConstants.UICONTEXT.NoSolution_string)]
public class MyPackage : Package
{
...
I've tried many variations of the above, but the best I've managed to achieve is having the window docked to the bottom - and even then it keeps on re-docking every time the package is re-loaded rather than persisting the user window position.
How can I specify that my window pane be initially shown docked to the left of the main window?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(4)
支持将项目设置为 VsDockStyle.Tabbed,因此您可以挂接到 Toolbox 工具窗口。但我猜你已经想到了这一点,但它不适合你的情况。
虽然这不是一个很好的解决方案,但您可以尝试此解决方法。
使用所需的方向和窗口设置 ProvideToolWindow,但将样式设置为“浮动”,因为不支持“链接”(http://msdn.microsoft.com/en-us/library/microsoft.visualstudio.shell.vsdockstyle。 ASPX):
在运行时,如果发现工具窗口处于浮动状态,请将其停靠:
正如我在备注中指出的 - 这似乎仅适用于 VS2010(不适用于 VS2008)。
希望它能有所帮助,尽管它很hacky。
Setting up items as VsDockStyle.Tabbed is supported, so you could hook onto the Toolbox tool window. But I'm guessing you already thought of that and it doesn't fit your situation.
Although not a pretty solution, you could try this workaround.
Setup the ProvideToolWindow with the Orientation and Window you want, but set the Style to Float since Linked is not supported (http://msdn.microsoft.com/en-us/library/microsoft.visualstudio.shell.vsdockstyle.aspx):
At run time, dock the tool window if you find it in a floating state:
As I noted in the remarks - this only seems to work for VS2010 (not VS2008).
Hope it helps, hacky as it is.
如果您希望它默认与其他窗口(如输出窗口、错误列表、查找结果等)停靠在底部,您可以这样做:
方向似乎没有什么区别,但它总是看起来出现在左侧。但对我来说已经足够近了。
If you want it docked at the bottom by default with the other windows like the Output Window, Error List, Find Results, etc. you can do it like this:
The orientation doesn't seem to make a difference, though, it always seems to appear on the left. But close enough for me.
我不知道这是否有效,但您可以尝试一下:
我在注册表中查找了线索,解决方案资源管理器工具窗口的停靠位置以及
发现 Window 参数包含“DocumentWell”,
因此您可以尝试以下操作:
或者
希望这会有所帮助,
托马斯。
I don't know if this works, but you can give it a try:
I looked in the registry for a clue, to where the SolutionExplorer toolwindow is docked and
found that the Window parameter contains "DocumentWell"
So you can try this:
or
Hope this helps,
Thomas.
这在 Visual Studio 2015 上运行良好。在虚拟机上测试。
但是,有一个限制:工具窗口仅在 IDE 首次启动您的扩展时才会停靠。使用虚拟机进行测试很容易,因为您只需恢复以前的状态即可。我猜想写入了一些注册表值,并且 Visual Studio 下次会记住工具窗口的先前位置,而不是使用上面刚刚指定的默认值。
如果有人愿意,我想他们可以比较注册表的前后版本并找到这些设置值并在下次/按需手动重置它们。
This works fine on Visual Studio 2015. Tested on a virtual machine.
However, there is a limitation: The tool window only gets docked for the very first time the IDE starts with your extension. It's easy to test with a virtual machine, as you just restore a previous state. I guess some registry value is written and Visual Studio rather remembers the previous position of your tool window next time rather than using the defaults you've just specified above.
If someone wants, I guess they could compare before/after versions of the registry and find these set values and reset them manually next time/on demand.