-
Notifications
You must be signed in to change notification settings - Fork 3
Expand file tree
/
Copy pathArrayVisualizerToolWindow.cs
More file actions
69 lines (61 loc) · 2.87 KB
/
Copy pathArrayVisualizerToolWindow.cs
File metadata and controls
69 lines (61 loc) · 2.87 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
using System.Runtime.InteropServices;
using Microsoft.VisualStudio.Shell;
namespace ArrayVisualizerExt
{
/// <summary>
/// This class implements the tool window exposed by this package and hosts a user control.
///
/// In Visual Studio tool windows are composed of a frame (implemented by the shell) and a pane,
/// usually implemented by the package implementer.
///
/// This class derives from the ToolWindowPane class provided from the MPF in order to use its
/// implementation of the IVsUIElementPane interface.
/// </summary>
[Guid("c0023666-5bf2-4e35-8732-6490c0736f6b")]
public class ArrayVisualizerToolWindow : ToolWindowPane
{
readonly ArrayVisualizerToolControl _arrayVisualizerToolControl;
/// <summary>
/// Standard constructor for the tool window.
/// </summary>
public ArrayVisualizerToolWindow() :
base(null)
{
// Set the window title reading it from the resources.
Caption = Resources.ToolWindowTitle;
// Set the image that will appear on the tab of the window frame
// when docked with an other window
// The resource ID correspond to the one defined in the resx file
// while the Index is the offset in the bitmap strip. Each image in
// the strip being 16x16.
BitmapResourceID = 301;
BitmapIndex = 1;
// This is the user control hosted by the tool window; Note that, even if this class implements IDisposable,
// we are not calling Dispose on this object. This is because ToolWindowPane calls Dispose on
// the object returned by the Content property.
_arrayVisualizerToolControl = new ArrayVisualizerToolControl();
base.Content = _arrayVisualizerToolControl;
}
public override void OnToolWindowCreated()
{
ThreadHelper.ThrowIfNotOnUIThread();
EnvDTE.DTE dte = (EnvDTE.DTE) GetService(typeof(EnvDTE.DTE));
EnvDTE80.Events2 events = (EnvDTE80.Events2) dte.Events;
var windowVisibility = events.get_WindowVisibilityEvents();
windowVisibility.WindowShowing += WindowVisibility_WindowShowing;
windowVisibility.WindowHiding += WindowVisibility_WindowHiding;
}
void WindowVisibility_WindowHiding(EnvDTE.Window window)
{
ThreadHelper.ThrowIfNotOnUIThread();
if (window.Kind == "Tool" && window.Caption == Resources.ToolWindowTitle)
_arrayVisualizerToolControl.ToolDeactivated();
}
void WindowVisibility_WindowShowing(EnvDTE.Window window)
{
ThreadHelper.ThrowIfNotOnUIThread();
if (window.Kind == "Tool" && window.Caption == Resources.ToolWindowTitle)
_arrayVisualizerToolControl.ToolActivated();
}
}
}