不在资源视图中时隐藏属性/工具箱窗格? [英] Hide Properties/Toolbox Pane when not in Resource View?

查看:146
本文介绍了不在资源视图中时隐藏属性/工具箱窗格?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

每次在Visual Studio(2005)中查看表单或对话框时,属性和工具箱窗格都会显示在屏幕的右侧。这很好,因为它们对于操作对话框很有用。

Every time I view a form or dialog in Visual Studio (2005) the Properties and Toolbox panes show up on the right side of my screen. That's good to have because they are useful for manipulating dialogs.

然而,一旦我切换回源代码,这些窗格就会妨碍...有没有办法让它们自动消失?

However once I switch back to source code these panes just get in the way... is there a way to get them to go away automatically?

推荐答案

我最近在VS2010中使用显示和隐藏工具面板的宏做了一些事情当在asp.net MVC3视图中从代码来回切换到设计视图时。我认为它可以很容易地适应你的情况。

I've done something recently in VS2010 using a macro that shows and hides the Tools panel when switching back and forth from code to design view in asp.net MVC3 views. It could be easily adapted to do the same for your situation I think.

这是在 EnvironmentEvents 类文件中在预生成内容之后的VS Macro IDE中。

This goes in the EnvironmentEvents class file in in the VS Macro IDE after the pre-generated content.

<System.ContextStaticAttribute()> Public WithEvents CommandEvents As EnvDTE.CommandEvents


  Public Sub DTEEvents_OnMacrosRuntimeReset() Handles _
  DTEEvents.OnMacrosRuntimeReset
        CommandEvents = DTE.Events.CommandEvents
    End Sub

    Private Sub DTEEvents_OnStartupComplete() Handles _
        DTEEvents.OnStartupComplete
        CommandEvents = DTE.Events.CommandEvents
    End Sub

    Public Sub CommandEvents_AfterExecute( _
    ByVal Guid As String, _
    ByVal ID As Integer, _
    ByVal CustomIn As Object, _
    ByVal CustomOut As Object) _
    Handles CommandEvents.AfterExecute

        If DTE.Commands.Item(Guid, ID).Name = "View.ViewDesigner" Then
            DTE.ExecuteCommand("View.Toolbox")
        End If

        If DTE.Commands.Item(Guid, ID).Name = "View.ViewMarkup" Then
            DTE.Windows.Item(Constants.vsWindowKindToolbox).Close()
        End If

    End Sub

使用事件的guid而不是if语句可能更好地优化它。当您使用热键切换视图以及视图菜单时,它可以工作,但不能使用上下文菜单。

It could probably be better optimized using the guids of the event rather than the if statements. It works when you use the hot keys for switching views as well as the view menu, but not the context menu.

这篇关于不在资源视图中时隐藏属性/工具箱窗格?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆