This topic has not yet been rated - Rate this topic

Commands Interface

Contains all of the commands, in the form of Command objects, in the environment.

Namespace: EnvDTE
Assembly: EnvDTE (in envdte.dll)

[GuidAttribute("E6B96CAC-B8C7-40AE-B705-5C81878C4A9E")] 
public interface Commands : IEnumerable
/** @attribute GuidAttribute("E6B96CAC-B8C7-40AE-B705-5C81878C4A9E") */ 
public interface Commands extends IEnumerable
GuidAttribute("E6B96CAC-B8C7-40AE-B705-5C81878C4A9E") 
public interface Commands extends IEnumerable
Imports Microsoft.VisualStudio.CommandBars
Sub CommandsExample()
   ' Before running, you must add a reference to the Office 
   ' typelib to gain access to the CommandBar object.
   Dim cmds As Commands
   Dim cmdobj As Command
   Dim customin, customout As Object
   Dim cmdbarobj As CommandBar
   Dim colAddins As AddIns

   ' Set references.
   colAddins = DTE.AddIns()
   cmds = DTE.Commands
   cmdobj = cmds.Item("File.NewFile")

   ' Execute the File.NewFile command.
   cmds.Raise(cmdobj.Guid, cmdobj.ID, customin, customout)

   ' Create a toolbar and add the File.NewFile command to it.
   cmdobj = cmds.Item("File.NewFile")
   cmdbarobj = cmds.AddCommandBar("Mycmdbar", _
     vsCommandBarType.vsCommandBarTypeToolbar)
   cmdobj.AddControl(cmdbarobj)
   ' Show the command bar and its button.
   cmdbarobj.Visible = True
End Sub
Did you find this helpful?
(1500 characters remaining)
Community Content Add
Annotations FAQ
DTE don't show Methodes

// Add a row for each keyboard shortcut
//EnvDTE80.DTE2.Commands
Commands cmds;
Command cmdobj;
cmds = DTE.Commands;
foreach (Command c in cmds) {

...

}


how can I get it: "cmds = DTE.Commands;" Commands not exists in DTE ?

TRY THIS:

public void ListShortcutsInHTML(){

//Declare a StreamWriter
System.IO.StreamWriter sw ;
sw = new StreamWriter("c:\\demo\\Shortcuts.html");

//Write the beginning HTML
WriteHTMLStart(sw);

// Add a row for each keyboard shortcut
//EnvDTE80.DTE2.Commands

try
{
Commands cmds;
EnvDTE.DTE mydte;
mydte = (EnvDTE.DTE)System.Runtime.InteropServices.Marshal.GetActiveObject("VisualStudio.DTE.8.0");
cmds = mydte.Commands;
foreach (Command c in cmds)
{

if (c.Name != "")
{

System.Array bindings = (Array) c.Bindings;
//bindings.Initialize();
//bindings = (System.Array)c.Bindings;
for (int i = 0; i < bindings.Length - 1; i++)
{
sw.WriteLine("<tr>");
sw.WriteLine("<td>" + c.Name + "</td>");
sw.WriteLine("<td>" + "bindings[i].value" + "</td>");
sw.WriteLine("</tr>");
}//Next i

}
}//Next
} //try
catch (Exception ex)
{
Console.WriteLine(ex.Message);
}
}

Advertisement