Вы находитесь на странице: 1из 8

Visual

Studio
:
: 22.10.2012

,
Visual Studio -
IDE . IDE UI
.

Visual Studio
.
.
.
UI ,
IDE, , , ,
.
- PVS-Studio IDE UI
( ) Visual
Studio ,
,
.


IDE , ( )
IDE, Command Window Immediate
Window, devenv.exe /command
.
-
, File.
Keyboard, Environment Options. Tools ->
Customize -> Commands ,
(,
), , .
, .
File -> New -> File,
, Command Window:
>File.NewFile Mytext /t:"General\Text File"

/e:"Source Code (text) Editor"


:



(^)
, /case (/c)
/word (/w) /cw

command,
:
devenv.exe /command "MyGroup.MyCommandName arg1 arg2"
alias:
>alias MyAlias File.NewFile MyFile
, IDE - PVS-Studio,
/command, , ,
. ,
PVS-Studio.exe
, , ..
,
stdout/strerr. ,
(,
MSBuild, NMake GNU Make) C/C++ .

,
( ) .
PVS-Studio.exe,

, ,
, .
PVS-Studio
, (..
) - Visual Studio
/command, , PVS-Studio.CheckSolution. ,
Visual C++
(vcproj/vcxproj).
Visual Studio /command,
.
UI , ,
/. , Visual Studio UI
. , ,

Microsoft MSBuild, Visual
Studio.

Visual Studio /command


(, Windows). ,
PVS-Studio
Microsoft Team Foundation, , ..
Team Foundation Windows .
,
, . Visual Studio
, . ,
Visual Studio ,
.
LocalSystem, Team Foundation. , Visual
Studio /command,
. ,
. , Visual Studio
LocalSystem psexec PSTools.

VSPackage. Vsct .
IDE VSPackage
(Visual Studio Command Table, vsct ).
XML, VSCT- cto (command table output). CTO
- IDE. VCST
IDE . VSCT
Visual Studio 2005, IDE CTC
(command table compiler) , .
vsct CommandID,
, .
( ),
..
VSCT . CommandTable
- Commands,
, , , .. Commands
Package , .
- Symbols VSCT
. - KeyBindings
.
<CommandTable"http://schemas.microsoft.com/VisualStudio/2005-1018/CommandTable">
<Extern href="stdidcmd.h"/>
<Extern href="vsshlids.h"/>
<Commands>
<Groups>
...
</Groups>

<Bitmaps>
...
</Bitmaps>
</Commands>
<Commands package="guidMyPackage">
<Menus>
...
</Menus>
<Buttons>
...
</Buttons>
</Commands>
<KeyBindings>
<KeyBinding guid="guidMyPackage" id="cmdidMyCommand1"
editor="guidVSStd97" key1="221" mod1="Alt" />
</KeyBindings>
<Symbols>
<GuidSymbol name="guidMyPackage" value="{B837A59E-5BF0-4190-B8FCFDC35BE5C342}" />
<GuidSymbol name="guidMyPackageCmdSet" value="{CC8B1E36-FE6B-48C1B9A9-2CC0EAB4E71F}">
<IDSymbol name="cmdidMyCommand1" value="0x0101" />
</GuidSymbol>
</Symbols>
</CommandTable>

Buttons IDE ,
.
<Button guid="guidMyPackageCmdSet" id="cmdidMyCommand1"
priority="0x0102" type="Button">
<Parent guid="guidMyPackageCmdSet" id="MyTopLevelMenuGroup" />
<Icon guid="guidMyPackageCmdSet" id="bmpMyCommand1" />
<CommandFlag>Pict</CommandFlag>
<CommandFlag>TextOnly</CommandFlag>
<CommandFlag>IconAndText</CommandFlag>
<CommandFlag>DefaultDisabled</CommandFlag>
<Strings>
<ButtonText>My &amp;Command 1</ButtonText>
</Strings>
</Button>

Menus UI ,
Groups. , Menu,
.
<Menu guid=" guidMyPackageCmdSet" id="SubMenu1" priority="0x0000"
type="Menu">

<Parent guid="guidMyPackageCmdSet" id="MyTopLevelMenuGroup"/>


<Strings>
<ButtonText>Sub Menu 1</ButtonText>
</Strings>
</Menu>
<Menu guid="guidMyPackageCmdSet" id="MyToolBar1" priority="0x0010"
type="Toolbar">
</Menu>

Groups .
<Group guid="guidMyPackageCmdSet" id="MySubGroup1" priority="0x0020">
<Parent guid="guidMyPackageCmdSet" id="MyGroup1" />
</Group>
vsct MSBuild VSPackage
VSCT csproj ( SDK
VSPackage vsct ):
<ItemGroup>
<VSCTCompile Include="TopLevelMenu.vsct">
<ResourceName>Menus.ctmenu</ResourceName>
</VSCTCompile>
</ItemGroup>
ProvideMenuResource
Package:
[ProvideMenuResource("Menus.ctmenu", 1)]
...
public sealed class MyPackage : Package

, VSCT ,
, IMenuCommandService.
GetService Package:
OleMenuCommandService MCS = GetService(typeof(IMenuCommandService)) as
OleMenuCommandService;
(
vsct ):
EventHandler eh = new EventHandler(CMDHandler);
CommandID menuCommandID = new CommandID(guidCommand1CmdSet, id);
//ID and GUID should be the same as in the VCST file
OleMenuCommand menuItem = new OleMenuCommand(eh, menuCommandID);
menuItem.ParametersDescription = "$";
MCS.AddCommand(menuItem);


EventArgs OleMenuCmdEventArgs:
void CMDHandler(object sender, EventArgs e)
{
OleMenuCmdEventArgs eventArgs = (OleMenuCmdEventArgs)e;
if (eventArgs.InValue != null)
param = eventArgs.InValue.ToString();
...
}

EnvDTE.DTE.
EnvDTE.DTE
(, , ) dte.Commands
dte.ExecuteCommand.
, IDE
, VSCT, VSPackage,
- Visual Studio Add-In.
DTE ,
DTE.Commands. Commands.AddNamedCommand
IDE ( Add-In ):
dte.Commands.AddNamedCommand(add_in, "MyCommand", "My Command",
"My Tooltip", true);

IDE
, .
Add-In
( ,
Visual Studio). OnConnection Add-In
( ),
, UI IDE.
public void OnConnection(object application,
ext_ConnectMode connectMode,
object addInInst, ref Array custom)
{
switch(connectMode)
{
case ext_ConnectMode.ext_cm_UISetup:
...
break;
...
}
}

EnvDTE.Command IDE.
.
VSPackage, Add-In .
EnvDTE.Command MyCommand1
" " :
EnvDTE.Command MyCommand1 =
MyPackage.DTE.Commands.Item("MyGroup.MyCommand1", -1);
MyCommand1.Bindings = new object[1] { "Global::Alt+1" };
MyGroup.MyCommand1
Keyboard, Environment.
, Visual Studio IDE.
Commands.AddCommandBar UI ,
, , ,
.
CommandBar MyToolbar = dte.Commands.AddCommandBar("MyToolbar1",
vsCommandBarType.vsCommandBarTypeToolbar) as CommandBar;
CommandBar MyMenu = dte.Commands.AddCommandBar("MyMenu1",
vsCommandBarType.vsCommandBarTypeMenu) as CommandBar;
CommandBarButton MyButton1 = MyCommand1.AddControl(MyToolbar) as
CommandBarButton;
MyButton1.Caption = "My Command 1";
IDE Delete
Command/ CommandBar:
MyCommand1.Delete();
Add-In
, .. IDE,
OnDisconnect
. ,
/ , , ,
DTE , .
Add-Inn DTE
, EnvDTE.
( , )
ExecuteCommand.
MyCommand1:
MyPackage.DTE.ExecuteCommand("MyGroup.MyCommand1", args);
Add-In
IDTCommandTarget Exec:
public void Exec(string commandName,
vsCommandExecOption executeOption, ref object varIn,

ref object varOut, ref bool handled)


{
handled = false;
if(executeOption ==
vsCommandExecOption.vsCommandExecOptionDoDefault)
{
if(commandName == "MyAddin1.Connect.MyCommand1")
{
...
handled = true;
return;
}
}
}


1.
2.
3.
4.
5.
6.

MSDN. Visual Studio Commands and Switches.


MSDN. Visual Studio Command Table (.Vsct) Files.
MSDN. Designing XML Command Table (.Vsct) Files.
MSDN. Walkthrough: Adding a Toolbar to the IDE.
MSDN. How VSPackages Add User Interface Elements to the IDE.
MZ-Tools. HOWTO: Adding buttons, commandbars and toolbars to Visual Studio .NET from an
add-in.
7. MSDN. How to: Create Toolbars for Tool Windows.


0. .
1. , Microsoft Visual Studio
2005/2008/2010/2012.
2. Visual Studio. EnvDTE.
3. Visual Studio.
4. Visual Studio.
5. Visual Studio.
6. Visual C++.

Вам также может понравиться