在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());
}
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());
}
相关文章推荐
- 创建MOSS2007自定义字段类型实例
- 推荐:“创建MOSS2007自定义字段类型实例”
- .Net 中的反射(动态创建类型实例) - Part.4
- 创建简单的Window Service 实例
- 创建简单的Window Service 实例
- *函数参数传递类的类型,在函数内部动态创建不同类型的实例
- C#队列泛型基类BaseQueue,访问索引器时自动创建类型实例
- 创建moss自定义字段类型实例
- .Net 中的反射(动态创建类型实例)
- 简单工厂(Factory)-提供一个创建对象实例的功能,而无须关心其具体实现。被创建实例的类型可以是接口、抽象类,也可以是具体的类。
- 类型实例的创建位置、托管对象在托管堆上的结构
- .Net 中的反射(动态创建类型实例) - Part.4
- .Net中的反射(动态创建类型实例) - Part.4
- Spring AOP四种创建通知(拦截器)类型实例
- Spring AOP四种创建通知(拦截器)类型实例
- 推荐:“创建MOSS2007自定义字段类型实例”
- 关于反射中创建类型实例的两种方法
- .Net 中的反射(动态创建类型实例) - Part.4动态创建对象
- .Net 中的反射(动态创建类型实例) - Part.4
- Spring AOP四种创建通知(拦截器)类型实例