You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: docs/extensibility/adding-a-submenu-to-a-menu.md
+13-13Lines changed: 13 additions & 13 deletions
Original file line number
Diff line number
Diff line change
@@ -17,21 +17,21 @@ manager: douge
17
17
ms.workload:
18
18
- "vssdk"
19
19
---
20
-
# Adding a Submenu to a Menu
21
-
This walkthrough builds on the demonstration in [Adding a Menu to the Visual Studio Menu Bar](../extensibility/adding-a-menu-to-the-visual-studio-menu-bar.md) by showing how to add a submenu to the **TestMenu** menu.
20
+
# Add a Submenu to a Menu
21
+
This walkthrough builds on the demonstration in [Add a Menu to the Visual Studio Menu Bar](../extensibility/adding-a-menu-to-the-visual-studio-menu-bar.md) by showing how to add a submenu to the **TestMenu** menu.
22
22
23
23
A submenu is a secondary menu that appears in another menu. A submenu can be identified by the arrow that follows its name. Clicking the name causes the submenu and its commands to be displayed.
24
24
25
25
This walkthrough creates a submenu in a menu on the Visual Studio menu bar and puts a new command on the submenu. The walkthrough also implements the new command.
26
26
27
27
## Prerequisites
28
-
Starting in Visual Studio 2015, you do not install the Visual Studio SDK from the download center. It is included as an optional feature in Visual Studio setup. You can also install the VS SDK later on. For more information, see [Installing the Visual Studio SDK](../extensibility/installing-the-visual-studio-sdk.md).
28
+
Starting in Visual Studio 2015, you do not install the Visual Studio SDK from the download center. It is included as an optional feature in Visual Studio setup. You can also install the VS SDK later on. For more information, see [Install the Visual Studio SDK](../extensibility/installing-the-visual-studio-sdk.md).
29
29
30
-
## Adding a Submenu to a Menu
30
+
## Add a Submenu to a Menu
31
31
32
-
1. Follow the steps in [Adding a Menu to the Visual Studio Menu Bar](../extensibility/adding-a-menu-to-the-visual-studio-menu-bar.md) to create the project and menu item. The steps in this walkthrough assume that the name of the VSIX project is `TopLevelMenu`.
32
+
1. Follow the steps in [Add a Menu to the Visual Studio Menu Bar](../extensibility/adding-a-menu-to-the-visual-studio-menu-bar.md) to create the project and menu item. The steps in this walkthrough assume that the name of the VSIX project is `TopLevelMenu`.
33
33
34
-
2. Open TestCommandPackage.vsct. In the `<Symbols>` section, add an `<IDSymbol>` element for the submenu, one for the submenu group, and one for the command, all in the `<GuidSymbol>` node named "guidTopLevelMenuCmdSet." This is the same node that contains the `<IDSymbol>` element for the top-level menu.
34
+
2. Open *TestCommandPackage.vsct*. In the `<Symbols>` section, add an `<IDSymbol>` element for the submenu, one for the submenu group, and one for the command, all in the `<GuidSymbol>` node named "guidTopLevelMenuCmdSet." This is the same node that contains the `<IDSymbol>` element for the top-level menu.
35
35
36
36
```xml
37
37
<IDSymbolname="SubMenu"value="0x1100"/>
@@ -51,7 +51,7 @@ This walkthrough builds on the demonstration in [Adding a Menu to the Visual Stu
51
51
</Menu>
52
52
```
53
53
54
-
The GUID/ID pair of the parent specifies the menu group that was generated in [Adding a Menu to the Visual Studio Menu Bar](../extensibility/adding-a-menu-to-the-visual-studio-menu-bar.md), and is a child of the top-level menu.
54
+
The GUID/ID pair of the parent specifies the menu group that was generated in [Add a Menu to the Visual Studio Menu Bar](../extensibility/adding-a-menu-to-the-visual-studio-menu-bar.md), and is a child of the top-level menu.
55
55
56
56
4. Add the menu group defined in step 2 to the `<Groups>` section and make it a child of the submenu.
57
57
@@ -78,9 +78,9 @@ This walkthrough builds on the demonstration in [Adding a Menu to the Visual Stu
78
78
79
79
7. Click **TestMenu** to see a new submenu named **Sub Menu**. Click **Sub Menu** to open the submenu and see a new command, **Test Sub Command**. Notice that clicking **Test Sub Command** does nothing.
80
80
81
-
## Adding a Command
81
+
## Add a Command
82
82
83
-
1. Open TestCommand.cs and add the following command ID after the existing command ID.
83
+
1. Open *TestCommand.cs* and add the following command ID after the existing command ID.
84
84
85
85
```csharp
86
86
public const int cmdidTestSubCmd = 0x105;
@@ -121,7 +121,7 @@ This walkthrough builds on the demonstration in [Adding a Menu to the Visual Stu
121
121
}
122
122
```
123
123
124
-
3. Add SubItemCallback(). This is the method that is called when the new command in the submenu is clicked.
124
+
3. Add `SubItemCallback()`. This is the method that is called when the new command in the submenu is clicked.
@@ -151,6 +151,6 @@ This walkthrough builds on the demonstration in [Adding a Menu to the Visual Stu
151
151
152
152
5. On the **TestMenu** menu, click **Sub Menu** and then click **Test Sub Command**. A message box should appear and display the text, "Test Command Inside TestCommand.SubItemCallback()".
153
153
154
-
## See Also
155
-
[Adding a Menu to the Visual Studio Menu Bar](../extensibility/adding-a-menu-to-the-visual-studio-menu-bar.md)
156
-
[Commands, Menus, and Toolbars](../extensibility/internals/commands-menus-and-toolbars.md)
154
+
## See also
155
+
[Add a menu to the Visual Studio menu bar](../extensibility/adding-a-menu-to-the-visual-studio-menu-bar.md)
156
+
[Commands, menus, and toolbars](../extensibility/internals/commands-menus-and-toolbars.md)
Copy file name to clipboardExpand all lines: docs/extensibility/adding-a-tool-window.md
+24-24Lines changed: 24 additions & 24 deletions
Original file line number
Diff line number
Diff line change
@@ -15,7 +15,7 @@ manager: douge
15
15
ms.workload:
16
16
- "vssdk"
17
17
---
18
-
# Adding a Tool Window
18
+
# Add a tool window
19
19
In this walkthrough you learn how to create a tool window and integrate it into Visual Studio in the following ways:
20
20
21
21
- Add a control to the tool window.
@@ -29,25 +29,25 @@ In this walkthrough you learn how to create a tool window and integrate it into
29
29
- Set the default position for the tool window.
30
30
31
31
## Prerequisites
32
-
Starting in Visual Studio 2015, you do not install the Visual Studio SDK from the download center. It is included as an optional feature in Visual Studio setup. You can also install the VS SDK later on. For more information, see [Installing the Visual Studio SDK](../extensibility/installing-the-visual-studio-sdk.md).
32
+
Starting in Visual Studio 2015, you do not install the Visual Studio SDK from the download center. It is included as an optional feature in Visual Studio setup. You can also install the VS SDK later on. For more information, see [Install the Visual Studio SDK](../extensibility/installing-the-visual-studio-sdk.md).
33
33
34
-
## Creating a Tool Window
34
+
## Create a tool window
35
35
36
36
1. Create a project named **FirstToolWin** using the VSIX template, and add a custom tool window item template named **FirstToolWindow**.
37
37
38
38
> [!NOTE]
39
-
> For more information about creating an extension with a tool window, see [Creating an Extension with a Tool Window](../extensibility/creating-an-extension-with-a-tool-window.md).
39
+
> For more information about creating an extension with a tool window, see [Create an extension with a tool window](../extensibility/creating-an-extension-with-a-tool-window.md).
40
40
41
-
## Add a Control to the Tool Window
41
+
## Add a control to the tool window
42
42
43
-
1. Remove the default control. Open FirstToolWindowControl.xaml and delete the **Click Me!** button.
43
+
1. Remove the default control. Open *FirstToolWindowControl.xaml* and delete the **Click Me!** button.
44
44
45
45
2. In the **Toolbox**, expand the **All WPF Controls** section and drag the **Media Element** control to the **FirstToolWindowControl** form. Select the control, and in the **Properties** window, name this element **mediaElement1**.
46
46
47
-
## Add a Toolbar to the Tool Window
47
+
## Add a toolbar to the tool window
48
48
By adding a toolbar in the following manner, you guarantee that its gradients and colors are consistent with the rest of the IDE.
49
49
50
-
1. In **Solution Explorer**, open FirstToolWindowPackage.vsct. The .vsct file defines the graphical user interface (GUI) elements in your tool window by using XML.
50
+
1. In **Solution Explorer**, open *FirstToolWindowPackage.vsct*. The *.vsct* file defines the graphical user interface (GUI) elements in your tool window by using XML.
51
51
52
52
2. In the `<Symbols>` section, find the `<GuidSymbol>` node whose `name` attribute is `guidFirstToolWindowPackageCmdSet`. Add the following two `<IDSymbol>` elements to the list of `<IDSymbol>` elements in this node to define a toolbar and a toolbar group.
53
53
@@ -86,7 +86,7 @@ In this walkthrough you learn how to create a tool window and integrate it into
86
86
87
87
By setting the parent GUID and ID to the GUID and ID of the toolbar, you add the group to the toolbar.
88
88
89
-
## Add a Command to the Toolbar
89
+
## Add a command to the toolbar
90
90
Add a command to the toolbar, which is displayed as a button.
91
91
92
92
1. In the `<Symbols>` section, declare the following IDSymbol elements just after the toolbar and toolbar group declarations.
@@ -96,7 +96,7 @@ In this walkthrough you learn how to create a tool window and integrate it into
2. Add a Button element inside the `<Buttons>` section. This element will appear on the toolbar in the tool window, with a Search (magnifying glass) icon.
99
+
2. Add a Button element inside the `<Buttons>` section. This element will appear on the toolbar in the tool window, with a **Search** (magnifying glass) icon.
@@ -109,7 +109,7 @@ In this walkthrough you learn how to create a tool window and integrate it into
109
109
</Button>
110
110
```
111
111
112
-
3. Open FirstToolWindowCommand.cs and add the following lines in the class just after the existing fields.
112
+
3. Open *FirstToolWindowCommand.cs* and add the following lines in the class just after the existing fields.
113
113
114
114
```csharp
115
115
public const string guidFirstToolWindowPackageCmdSet = "00000000-0000-0000-0000-0000"; // get the GUID from the .vsct file
@@ -120,10 +120,10 @@ In this walkthrough you learn how to create a tool window and integrate it into
120
120
121
121
Doing this makes your commands available in code.
122
122
123
-
## Add a MediaPlayer Property to FirstToolWindowControl
123
+
## Add a MediaPlayer property to FirstToolWindowControl
124
124
From the event handlers for the toolbar controls, your code must be able to access the Media Player control, which is a child of the FirstToolWindowControl class.
125
125
126
-
In **Solution Explorer**, right-click FirstToolWindowControl.xaml, click **View Code**, and add the following code to the FirstToolWindowControl Class.
126
+
In **Solution Explorer**, right-click *FirstToolWindowControl.xaml*, click **View Code**, and add the following code to the FirstToolWindowControl class.
127
127
128
128
```csharp
129
129
public System.Windows.Controls.MediaElement MediaPlayer
@@ -132,10 +132,10 @@ public System.Windows.Controls.MediaElement MediaPlayer
132
132
}
133
133
```
134
134
135
-
## Instantiate the Tool Window and Toolbar
135
+
## Instantiate the tool window and toolbar
136
136
Add a toolbar and a menu command that invokes the **Open File** dialog and plays the selected media file.
137
137
138
-
1. Open FirstToolWindow.cs and add the following `using` statements.
138
+
1. Open *FirstToolWindow.cs* and add the following `using` statements.
139
139
140
140
```csharp
141
141
usingSystem.ComponentModel.Design;
@@ -198,7 +198,7 @@ public System.Windows.Controls.MediaElement MediaPlayer
198
198
mcs.AddCommand(menuItem);
199
199
```
200
200
201
-
#### To implement a menu command in the tool window
201
+
### To implement a menu command in the tool window
202
202
203
203
1. IntheFirstToolWindowCommand class, add a ButtonHandler method that invokes the **Open File** dialog. When a file has been selected, it plays the media file.
204
204
@@ -245,10 +245,10 @@ public System.Windows.Controls.MediaElement MediaPlayer
245
245
}
246
246
```
247
247
248
-
## Set the Default Position for the Tool Window
249
-
Next, specifyadefaultlocationintheIDEfor the tool window. Configuration information for the tool window is in the FirstToolWindowPackage.cs file.
248
+
## Set the default position for the tool window
249
+
Next, specifyadefaultlocationintheIDEfor the tool window. Configuration information for the tool window is in the *FirstToolWindowPackage.cs* file.
250
250
251
-
1. In FirstToolWindowPackage.cs, find the <xref:Microsoft.VisualStudio.Shell.ProvideToolWindowAttribute> attribute on the `FirstToolWindowPackage` class, which passes the FirstToolWindow type to the constructor. To specify a default position, you must add more parameters to the constructor following example.
251
+
1. In *FirstToolWindowPackage.cs*, find the <xref:Microsoft.VisualStudio.Shell.ProvideToolWindowAttribute> attribute on the `FirstToolWindowPackage` class, which passes the FirstToolWindow type to the constructor. To specify a default position, you must add more parameters to the constructor following example.
252
252
253
253
```csharp
254
254
[ProvideToolWindow(typeof(FirstToolWindow),
@@ -261,17 +261,17 @@ public System.Windows.Controls.MediaElement MediaPlayer
3. Clickthebutton (ithastheSearchicon) inthetoolwindow. Selectasupportedsoundorvideofile, for example, C:\windows\media\chimes.wav, then press **Open**.
272
+
3. Clickthebutton (ithasthe**Search**icon) inthetoolwindow. Selectasupportedsoundorvideofile, for example, *C:\windows\media\chimes.wav*, then press **Open**.
273
273
274
274
You should hear the chime sound.
275
275
276
-
## See Also
277
-
[Commands, Menus, and Toolbars](../extensibility/internals/commands-menus-and-toolbars.md)
276
+
## See also
277
+
[Commands, menus, and toolbars](../extensibility/internals/commands-menus-and-toolbars.md)
Copy file name to clipboardExpand all lines: docs/extensibility/adding-a-toolbar-to-a-tool-window.md
+12-12Lines changed: 12 additions & 12 deletions
Original file line number
Diff line number
Diff line change
@@ -15,23 +15,23 @@ manager: douge
15
15
ms.workload:
16
16
- "vssdk"
17
17
---
18
-
# Adding a Toolbar to a Tool Window
18
+
# Add a toolbar to a tool window
19
19
This walkthrough shows how to add a toolbar to a tool window.
20
20
21
21
A toolbar is a horizontal or vertical strip that contains buttons bound to commands. The length of a toolbar in a tool window is always the same as the width or height of the tool window, depending on where the toolbar is docked.
22
22
23
23
Unlike toolbars in the IDE, a toolbar in a tool window must be docked and cannot be moved or customized. If the VSPackage is written in umanaged code, the toolbar can be docked on any edge.
24
24
25
-
For more information about how to add a toolbar, see [Adding a Toolbar](../extensibility/adding-a-toolbar.md).
25
+
For more information about how to add a toolbar, see [Adding a toolbar](../extensibility/adding-a-toolbar.md).
26
26
27
27
## Prerequisites
28
28
Starting in Visual Studio 2015, you do not install the Visual Studio SDK from the download center. It is included as an optional feature in Visual Studio setup. You can also install the VS SDK later on. For more information, see [Installing the Visual Studio SDK](../extensibility/installing-the-visual-studio-sdk.md).
29
29
30
-
## Creating a Toolbar for a Tool Window
30
+
## Create a toolbar for a tool window
31
31
32
-
1. Create a VSIX project named `TWToolbar` that has both a menu command named **TWTestCommand** and a tool window named **TestToolWindow**. For more information, see [Creating an Extension with a Menu Command](../extensibility/creating-an-extension-with-a-menu-command.md) and [Creating an Extension with a Tool Window](../extensibility/creating-an-extension-with-a-tool-window.md). You need to add the command item template before adding the tool window template.
32
+
1. Create a VSIX project named `TWToolbar` that has both a menu command named **TWTestCommand** and a tool window named **TestToolWindow**. For more information, see [Create an extension with a menu command](../extensibility/creating-an-extension-with-a-menu-command.md) and [Create an extension with a tool window](../extensibility/creating-an-extension-with-a-tool-window.md). You need to add the command item template before adding the tool window template.
33
33
34
-
2. In TWTestCommandPackage.vsct, look for the Symbols section. In the GuidSymbol node named guidTWTestCommandPackageCmdSet declare a toolbar and a toolbar group, as follows.
34
+
2. In *TWTestCommandPackage.vsct*, look for the Symbols section. In the GuidSymbol node named guidTWTestCommandPackageCmdSet declare a toolbar and a toolbar group, as follows.
35
35
36
36
```xml
37
37
<IDSymbolname="TWToolbar"value="0x1000" />
@@ -52,7 +52,7 @@ This walkthrough shows how to add a toolbar to a tool window.
52
52
</Menus>
53
53
```
54
54
55
-
Toolbars cannot be nested like submenus. Therefore, you do not have to assign a parent. Also, you do not have to set a priority, because the user can move toolbars. Typically, initial placement of a toolbar is defined programmatically, but subsequent changes by the user are persisted.
55
+
Toolbars can't be nested like submenus. Therefore, you don't have to assign a parent. Also, you don't have to set a priority, because the user can move toolbars. Typically, initial placement of a toolbar is defined programmatically, but subsequent changes by the user are persisted.
56
56
57
57
4. In the Groups section, define a group to contain the commands for the toolbar.
58
58
@@ -79,16 +79,16 @@ This walkthrough shows how to add a toolbar to a tool window.
79
79
80
80
Because the new toolbar is not automatically added to the tool window, the toolbar must be added explicitly. This is discussed in the next section.
81
81
82
-
## Adding the Toolbar to the Tool Window
82
+
## Add the toolbar to the tool window
83
83
84
-
1. In TWTestCommandPackageGuids.cs add the following lines.
84
+
1. In *TWTestCommandPackageGuids.cs* add the following lines.
85
85
86
86
```csharp
87
87
public const string guidTWTestCommandPackageCmdSet = "00000000-0000-0000-0000-0000"; // get the GUID from the .vsct file
88
88
public const int TWToolbar = 0x1000;
89
89
```
90
90
91
-
2. In TestToolWindow.cs add the following using statement.
91
+
2. In *TestToolWindow.cs* add the following using statement.
92
92
93
93
```csharp
94
94
using System.ComponentModel.Design;
@@ -100,7 +100,7 @@ This walkthrough shows how to add a toolbar to a tool window.
100
100
this.ToolBar = new CommandID(new Guid(TWTestCommandPackageGuids.guidTWTestCommandPackageCmdSet), TWTestCommandPackageGuids.TWToolbar);
101
101
```
102
102
103
-
## Testing the Toolbar in the Tool Window
103
+
## Test the toolbar in the tool window
104
104
105
105
1. Build the project and start debugging. The Visual Studio experimental instance should appear.
106
106
@@ -110,5 +110,5 @@ This walkthrough shows how to add a toolbar to a tool window.
110
110
111
111
3. On the toolbar, click the icon to display the message **TWTestCommandPackage Inside TWToolbar.TWTestCommand.MenuItemCallback()**.
112
112
113
-
## See Also
114
-
[Adding a Toolbar](../extensibility/adding-a-toolbar.md)
113
+
## See also
114
+
[Add a toolbar](../extensibility/adding-a-toolbar.md)
0 commit comments