Skip to content

Commit 9889f5a

Browse files
committed
Allow opening multiple instances of *Watch windows (max 10).
1 parent 1ba4904 commit 9889f5a

File tree

5 files changed

+32
-36
lines changed

5 files changed

+32
-36
lines changed

Visual_Studio_2017/GraphicalDebugging/GeometryWatchCommand.cs

Lines changed: 1 addition & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -95,17 +95,7 @@ public static void Initialize(GraphicalWatchPackage package)
9595
/// <param name="e">The event args.</param>
9696
private void ShowToolWindow(object sender, EventArgs e)
9797
{
98-
// Get the instance number 0 of this tool window. This window is single instance so this instance
99-
// is actually the only one.
100-
// The last flag is set to true so that if the tool window does not exists it will be created.
101-
ToolWindowPane window = this.package.FindToolWindow(typeof(GeometryWatch), 0, true);
102-
if ((null == window) || (null == window.Frame))
103-
{
104-
throw new NotSupportedException("Cannot create tool window");
105-
}
106-
107-
IVsWindowFrame windowFrame = (IVsWindowFrame)window.Frame;
108-
Microsoft.VisualStudio.ErrorHandler.ThrowOnFailure(windowFrame.Show());
98+
Util.ShowWindow<GeometryWatch>(this.package, "Geometry Watch");
10999
}
110100
}
111101
}

Visual_Studio_2017/GraphicalDebugging/GraphicalWatchCommand.cs

Lines changed: 1 addition & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -95,17 +95,7 @@ public static void Initialize(GraphicalWatchPackage package)
9595
/// <param name="e">The event args.</param>
9696
private void ShowToolWindow(object sender, EventArgs e)
9797
{
98-
// Get the instance number 0 of this tool window. This window is single instance so this instance
99-
// is actually the only one.
100-
// The last flag is set to true so that if the tool window does not exists it will be created.
101-
ToolWindowPane window = this.package.FindToolWindow(typeof(GraphicalWatch), 0, true);
102-
if ((null == window) || (null == window.Frame))
103-
{
104-
throw new NotSupportedException("Cannot create tool window");
105-
}
106-
107-
IVsWindowFrame windowFrame = (IVsWindowFrame)window.Frame;
108-
Microsoft.VisualStudio.ErrorHandler.ThrowOnFailure(windowFrame.Show());
98+
Util.ShowWindow<GraphicalWatch>(this.package, "Graphical Watch");
10999
}
110100
}
111101
}

Visual_Studio_2017/GraphicalDebugging/GraphicalWatchPackage.cs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -35,9 +35,9 @@ namespace GraphicalDebugging
3535
[ProvideMenuResource("Menus.ctmenu", 1)]
3636
[Guid(GraphicalWatchPackage.PackageGuidString)]
3737
[SuppressMessage("StyleCop.CSharp.DocumentationRules", "SA1650:ElementDocumentationMustBeSpelledCorrectly", Justification = "pkgdef, VS and vsixmanifest are valid VS terms")]
38-
[ProvideToolWindow(typeof(GeometryWatch))]
39-
[ProvideToolWindow(typeof(GraphicalWatch))]
40-
[ProvideToolWindow(typeof(PlotWatch))]
38+
[ProvideToolWindow(typeof(GeometryWatch), MultiInstances = true)]
39+
[ProvideToolWindow(typeof(GraphicalWatch), MultiInstances = true)]
40+
[ProvideToolWindow(typeof(PlotWatch), MultiInstances = true)]
4141
[ProvideOptionPage(typeof(GeneralOptionPage), "Graphical Debugging", "General", 0, 0, true)]
4242
[ProvideOptionPage(typeof(GeometryWatchOptionPage), "Graphical Debugging", "Geometry Watch", 0, 0, true)]
4343
[ProvideOptionPage(typeof(GraphicalWatchOptionPage), "Graphical Debugging", "Graphical Watch", 0, 0, true)]

Visual_Studio_2017/GraphicalDebugging/PlotWatchCommand.cs

Lines changed: 1 addition & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -95,17 +95,7 @@ public static void Initialize(GraphicalWatchPackage package)
9595
/// <param name="e">The event args.</param>
9696
private void ShowToolWindow(object sender, EventArgs e)
9797
{
98-
// Get the instance number 0 of this tool window. This window is single instance so this instance
99-
// is actually the only one.
100-
// The last flag is set to true so that if the tool window does not exists it will be created.
101-
ToolWindowPane window = this.package.FindToolWindow(typeof(PlotWatch), 0, true);
102-
if ((null == window) || (null == window.Frame))
103-
{
104-
throw new NotSupportedException("Cannot create tool window");
105-
}
106-
107-
IVsWindowFrame windowFrame = (IVsWindowFrame)window.Frame;
108-
Microsoft.VisualStudio.ErrorHandler.ThrowOnFailure(windowFrame.Show());
98+
Util.ShowWindow<PlotWatch>(this.package, "Plot Watch");
10999
}
110100
}
111101
}

Visual_Studio_2017/GraphicalDebugging/Util.cs

Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -174,6 +174,32 @@ public static bool Tparams(string type, out string param1, out string param2)
174174
return true;
175175
}
176176

177+
public static void ShowWindow<WatchWindow>(Package package, string name)
178+
where WatchWindow : ToolWindowPane
179+
{
180+
for (int i = 0; i < 10; ++i)
181+
{
182+
ToolWindowPane window = package.FindToolWindow(typeof(WatchWindow), i, false);
183+
if (window == null)
184+
{
185+
window = package.FindToolWindow(typeof(WatchWindow), i, true);
186+
if ((null == window) || (null == window.Frame))
187+
{
188+
throw new NotSupportedException("Cannot create " + name + " window");
189+
}
190+
191+
/*if (i > 0)
192+
{
193+
window.Caption = window.Caption + ' ' + (i + 1);
194+
}*/
195+
196+
IVsWindowFrame windowFrame = (IVsWindowFrame)window.Frame;
197+
Microsoft.VisualStudio.ErrorHandler.ThrowOnFailure(windowFrame.Show());
198+
break;
199+
}
200+
}
201+
}
202+
177203
public static T GetDialogPage<T>()
178204
where T : DialogPage
179205
{

0 commit comments

Comments
 (0)