您的位置:首页 > 运维架构 > Shell

在vspackage中创建同一类型的toolwindow的多个实例

2016-11-18 17:36 211 查看
1、[ProvideToolWindow(typeof(XXXToolWindow),MultiInstances=true)]

2、在显示Toolwindow是方法中,实现如下逻辑:

 

 private void ShowXXXToolWindow(object sender, EventArgs e)

        {

            // Get the instance number 0 of this tool window.

            //This window is single instance so this instance is actually the only one.

            // The last flag is set to true so that if the tool window does not exists it will be created.

            int nToolWndowId = 0;

            while (true)

            {

                ToolWindowPane window = this.FindToolWindow(typeof(XXXToolWindow), nToolWndowId, false);             

                if (window == null)

                {

                    break;

                }           

                else

                {

                    nToolWndowId++;

                }

            }

            //创建新的ToolWindow

            ToolWindowPane newWindow = this.FindToolWindow(typeof(XXXToolWindow), nToolWndowId, true);

     

            if ((null == newWindow) || (null == newWindow.Frame))

            {

                throw new NotSupportedException(Resources.CanNotCreateWindow);

            }

            IVsWindowFrame newWindowFrame = (IVsWindowFrame)newWindow.Frame;

            Microsoft.VisualStudio.ErrorHandler.ThrowOnFailure(newWindowFrame.Show());

        }          

 

 
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签:  visual studio shell