Skip to content
Permalink
Browse files

Keybindings for all VS IDE Commands

  • Loading branch information...
apobekiaris committed May 8, 2017
1 parent 485399e commit cbc5df538e43d240be47415de8c1bc1b74cfb9aa
Showing with 248 additions and 202 deletions.
  1. +0 −2 License.txt
  2. +16 −0 Xpand.Plugins/Xpand.VSIX/Commands/AddXpandReferencesCommand.cs
  3. +12 −7 Xpand.Plugins/Xpand.VSIX/Commands/BuildSelectionCommand.cs
  4. +21 −75 Xpand.Plugins/Xpand.VSIX/Commands/Commands.cs
  5. +16 −4 Xpand.Plugins/Xpand.VSIX/Commands/DouplicateLineCommand.cs
  6. +13 −4 Xpand.Plugins/Xpand.VSIX/Commands/DropDataBaseCommand.cs
  7. +25 −12 Xpand.Plugins/Xpand.VSIX/Commands/{EasyTest.cs → EasyTestCommand.cs}
  8. +12 −3 Xpand.Plugins/Xpand.VSIX/Commands/{IISExpress.cs → KillIISExpressCommand.cs}
  9. +8 −5 Xpand.Plugins/Xpand.VSIX/Commands/LoadProjectFromReferenceCommand.cs
  10. +5 −3 Xpand.Plugins/Xpand.VSIX/Commands/ProjectConverterCommand.cs
  11. +18 −0 Xpand.Plugins/Xpand.VSIX/Commands/ShowModelsWindowCommand.cs
  12. +33 −0 Xpand.Plugins/Xpand.VSIX/Commands/VSCommand.cs
  13. +7 −3 Xpand.Plugins/Xpand.VSIX/Commands/XAFErrorExplorerCommand.cs
  14. +2 −2 Xpand.Plugins/Xpand.VSIX/Extensions/ShellExtensions.cs
  15. +1 −14 Xpand.Plugins/Xpand.VSIX/ModelEditor/ModelToolWindow.cs
  16. +8 −1 Xpand.Plugins/Xpand.VSIX/Options/OptionClass.cs
  17. +2 −3 Xpand.Plugins/Xpand.VSIX/Options/OptionsControl.cs
  18. +17 −46 Xpand.Plugins/Xpand.VSIX/Options/OptionsControl.designer.cs
  19. +5 −1 Xpand.Plugins/Xpand.VSIX/VSPackage/VSPackage.cs
  20. +14 −12 Xpand.Plugins/Xpand.VSIX/VSPackage/VSPackage.vsct
  21. +2 −0 Xpand.Plugins/Xpand.VSIX/VSPackage/VSPackage1.cs
  22. +1 −1 Xpand.Plugins/Xpand.VSIX/Wizard/SolutionWizard.cs
  23. +10 −4 Xpand.Plugins/Xpand.VSIX/Xpand.VSIX.csproj
@@ -34,5 +34,3 @@ A "contributor" is any person that distributes its contribution under this licen
(E) The software is licensed "as-is." You bear the risk of using it. The contributors give no express warranties, guarantees or conditions. You may have additional consumer rights under your local laws which this license cannot change. To the extent permitted under your local laws, the contributors exclude the implied warranties of merchantability, fitness for a particular purpose and non-infringement.


3rd party libraries
1) Algorithmia Library written by Frans Bouma
@@ -0,0 +1,16 @@
using System.ComponentModel.Design;
using Xpand.VSIX.Extensions;
using Xpand.VSIX.VSPackage;
using Xpand.VSIX.Wizard;

namespace Xpand.VSIX.Commands{
public class AddXpandReferencesCommand:VSCommand{
private AddXpandReferencesCommand() : base((sender, args) => SolutionWizard.Show(),new CommandID(PackageGuids.guidVSXpandPackageCmdSet,PackageIds.cmdidAddXpandReference)){
this.ActiveForDXSolution();
}

public static void Init(){
new AddXpandReferencesCommand();
}
}
}
@@ -1,16 +1,21 @@
using System;
using System.ComponentModel.Design;
using Xpand.VSIX.Extensions;
using Xpand.VSIX.VSPackage;

namespace Xpand.VSIX.Commands{
public class BuildSelectionCommand : IDTE2Provider{
public static void Build(object sender, EventArgs e){
new BuildSelectionCommand().Build();
public class BuildSelectionCommand : VSCommand{
private BuildSelectionCommand() : base((sender, args) =>Build() , new CommandID(PackageGuids.guidVSXpandPackageCmdSet,PackageIds.cmdidBuildSelection)){
this.EnableForSolution();
BindCommand("Global::Ctrl+Alt+Enter");
}

private void Build(){
var dte2 = this.DTE2();
public static void Init(){
new BuildSelectionCommand();
}

private static void Build(){
if (FindInSolutionCommand.Find())
dte2.ExecuteCommand("Build.BuildSelection");
DteExtensions.DTE.ExecuteCommand("Build.BuildSelection");
}
}
}
@@ -1,65 +1,32 @@
using System;
using System.Collections.Generic;
using System.ComponentModel.Design;
using System.Collections.Generic;
using System.Linq;
using System.Runtime.InteropServices;
using EnvDTE;
using EnvDTE90;
using Microsoft.VisualStudio.CommandBars;
using Microsoft.VisualStudio.Shell;
using Microsoft.VisualStudio.TextManager.Interop;
using Xpand.VSIX.Extensions;
using Xpand.VSIX.ModelEditor;
using Xpand.VSIX.Options;
using Xpand.VSIX.VSPackage;
using Xpand.VSIX.Wizard;
using Task = System.Threading.Tasks.Task;

namespace Xpand.VSIX.Commands {
internal sealed class Commands {
private readonly Package _package;

private Commands(Package package) {
if (package == null) throw new ArgumentNullException(nameof(package));

_package = package;

var commandService = ServiceProvider.GetService(typeof(IMenuCommandService)) as OleMenuCommandService;
if (commandService != null){
InitEasyTest(commandService);
commandService.AddCommand(new DropDataBaseCommand());
commandService.AddCommand(new LoadProjectFromReferenceCommand());
commandService.AddCommand(new LoadProjectFromReferenceCommand(PackageIds.cmdidLoadProjectFromreferenceTool));
commandService.AddCommand(new ProjectConverterCommand());
SetSpecificVersion();
commandService.AddCommand(new XAFErrorExplorerCommand());
DisableExceptions();


var menuItem = new OleMenuCommand(ModelToolWindow.Show,new CommandID(PackageGuids.guidVSXpandPackageCmdSet, PackageIds.cmdidShowMEToolbox));
menuItem.EnableForDXSolution();
commandService.AddCommand(menuItem);

menuItem = new OleMenuCommand(IISExpress.KillIISExpress, new CommandID(PackageGuids.guidVSXpandPackageCmdSet, PackageIds.cmdidKillIISExpress));
commandService.AddCommand(menuItem);

menuItem = new OleMenuCommand(OptionsPage.Show, new CommandID(PackageGuids.guidVSXpandPackageCmdSet, PackageIds.cmdidOptions));
commandService.AddCommand(menuItem);

menuItem = new OleMenuCommand(SolutionWizard.Show, new CommandID(PackageGuids.guidVSXpandPackageCmdSet, PackageIds.cmdidAddXpandReference));
menuItem.ActiveForDXSolution();
commandService.AddCommand(menuItem);

menuItem = new OleMenuCommand(BuildSelectionCommand.Build, new CommandID(PackageGuids.guidVSXpandPackageCmdSet, PackageIds.cmdidBuildSelection));
menuItem.EnableForSolution();
commandService.AddCommand(menuItem);
menuItem = new OleMenuCommand((sender, args) => FindInSolutionCommand.Find(), new CommandID(PackageGuids.guidVSXpandPackageCmdSet, PackageIds.cmdidFindInSolution));
menuItem.EnableForSolution();
commandService.AddCommand(menuItem);
menuItem = new OleMenuCommand((sender, args) => DuplicateLineCommand.DuplicateLine((IVsTextManager) ServiceProvider.GetService(typeof(SVsTextManager))), new CommandID(PackageGuids.guidVSXpandPackageCmdSet, PackageIds.cmdidDouplicateLine));
menuItem.EnableForActiveFile();
commandService.AddCommand(menuItem);
}
private Commands() {
InitEasyTest();
DropDataBaseCommand.Init();
LoadProjectFromReferenceCommand.Init();
ProjectConverterCommand.Init();
SetSpecificVersion();
XAFErrorExplorerCommand.Init();
DisableExceptions();
ShowModelsWindowCommand.Init();
KillIISExpressCommand.Init();
AddXpandReferencesCommand.Init();
BuildSelectionCommand.Init();
FindInSolutionCommand.Init();
DuplicateLineCommand.Init();
NavigatePreviousWordCommand.Init();
NavigateNextWordCommand.Init();
}

private static void DisableExceptions(){
@@ -100,7 +67,7 @@ internal sealed class Commands {
}
}

private static void InitEasyTest(OleMenuCommandService commandService){
private static void InitEasyTest(){
var easyTestToolBar =
((CommandBars) DteExtensions.DTE.CommandBars).Cast<CommandBar>().FirstOrDefault(bar => bar.Name == "EasyTest");
var commandBarControl =
@@ -116,34 +83,13 @@ internal sealed class Commands {
commandBarControl.TooltipText = commandBarControl.Caption;
commandBarControl.Caption = "R";
}
var menuCommandID = new CommandID(PackageGuids.guidVSXpandPackageCmdSet, PackageIds.cmdidDebugEasyTest);
var menuItem = new OleMenuCommand((sender, args) => new EasyTest().RunTest(true), menuCommandID);
menuItem.EnableForDXSolution().EnableForActiveFile(".ets", ".inc");
commandService.AddCommand(menuItem);

menuCommandID = new CommandID(PackageGuids.guidVSXpandPackageCmdSet, PackageIds.cmdidRunEasyTest);
menuItem = new OleMenuCommand((sender, args) => new EasyTest().RunTest(false), menuCommandID);
menuItem.EnableForDXSolution().EnableForActiveFile(".ets", ".inc");
commandService.AddCommand(menuItem);
EasyTestCommand.Init();
}


/// <summary>
/// Gets the instance of the command.
/// </summary>
public static Commands Instance { get; private set; }

/// <summary>
/// Gets the service provider from the owner package.
/// </summary>
private IServiceProvider ServiceProvider => _package;

/// <summary>
/// Initializes the singleton instance of the command.
/// </summary>
/// <param name="package">Owner package, not null.</param>
public static void Initialize(Package package) {
Instance = new Commands(package);
public static void Initialize() {
Instance = new Commands();
}
}
}
@@ -1,9 +1,23 @@
using System;
using System.ComponentModel.Design;
using Microsoft.VisualStudio.TextManager.Interop;
using Xpand.VSIX.Extensions;
using Xpand.VSIX.VSPackage;

namespace Xpand.VSIX.Commands{
public class DuplicateLineCommand {
public static void DuplicateLine(IVsTextManager vsTextManager) {
public class DuplicateLineCommand:VSCommand {
private DuplicateLineCommand(IVsTextManager vsTextManager) : base((sender, args) => DuplicateLine(vsTextManager),
new CommandID(PackageGuids.guidVSXpandPackageCmdSet, PackageIds.cmdidDouplicateLine)){
BindCommand("Text Editor::Ctrl+D");
this.EnableForActiveFile();
}

public static void Init(){
var vsTextManager = VSPackage.VSPackage.Instance.GetService(typeof(SVsTextManager));
new DuplicateLineCommand((IVsTextManager) vsTextManager);
}

static void DuplicateLine(IVsTextManager vsTextManager) {
if (vsTextManager==null)
return;
IVsTextView ppView;
@@ -63,7 +77,5 @@ public class DuplicateLineCommand {
ppView.SetSelection(anchorLine, anchorCol, endLine, endCol);
}
}


}
}
@@ -8,21 +8,30 @@
using DevExpress.DXCore.Controls.Xpo.DB.Helpers;
using EnvDTE;
using EnvDTE80;
using Microsoft.VisualStudio.Shell;
using Xpand.VSIX.Extensions;
using Xpand.VSIX.Options;
using Xpand.VSIX.VSPackage;
using Task = System.Threading.Tasks.Task;

namespace Xpand.VSIX.Commands {
public class DropDataBaseCommand:OleMenuCommand {
public class DropDataBaseCommand:VSCommand {
private static readonly DTE2 _dte=DteExtensions.DTE;

public DropDataBaseCommand():base((sender, args) => Drop(), new CommandID(PackageGuids.guidVSXpandPackageCmdSet, PackageIds.cmdidDropDatabase)){
this.EnableForConfigFile();
private DropDataBaseCommand():base((sender, args) => Drop(), new CommandID(PackageGuids.guidVSXpandPackageCmdSet, PackageIds.cmdidDropDatabase)){
this.EnableForSolution();
BindCommand("Global::Ctrl+Shift+Alt+D");
}

public static void Init(){
new DropDataBaseCommand();
}

static void Drop() {
var activeDocument = DteExtensions.DTE.ActiveDocument;
string[] fileNames={"app.config","web.config"};
if (!(activeDocument != null && (fileNames.Any(s => activeDocument.FullName.EndsWith(s)) || fileNames.Length == 0)))
throw new NotSupportedException("Active document's project does not contain a config file");

_dte.InitOutputCalls("Dropdatabase");
Task.Factory.StartNew(() => {
var startUpProject = _dte.Solution.FindStartUpProject();
@@ -1,4 +1,5 @@
using System;
using System.ComponentModel.Design;
using System.Diagnostics;
using System.IO;
using System.Linq;
@@ -9,22 +10,36 @@
using EnvDTE80;
using Xpand.VSIX.Extensions;
using Xpand.VSIX.Options;
using Xpand.VSIX.VSPackage;
using Task = System.Threading.Tasks.Task;

namespace Xpand.VSIX.Commands{
class LastBuildStatusArgs : EventArgs {
public class LastBuildStatusArgs : EventArgs {
public bool Successed { get; set; }
}

class EasyTest {
private readonly DTE2 _dte=DteExtensions.DTE;
public event EventHandler<LastBuildStatusArgs> QueryLastBuildStatus;
public void RunTest(bool debug) {
public class EasyTestCommand:VSCommand {
private EasyTestCommand(EventHandler invokeHandler, CommandID commandID) : base(invokeHandler, commandID){
this.EnableForDXSolution().EnableForActiveFile(".ets", ".inc");
}

public static void Init(){
var runEasyTest = new EasyTestCommand((sender, args) => RunTest(false),new CommandID(PackageGuids.guidVSXpandPackageCmdSet,PackageIds.cmdidRunEasyTest));
runEasyTest.BindCommand("Text Editor::Alt+T");
var debugEasyTest = new EasyTestCommand((sender, args) => RunTest(false),new CommandID(PackageGuids.guidVSXpandPackageCmdSet,PackageIds.cmdidDebugEasyTest));
debugEasyTest.BindCommand("Text Editor::Alt+D");
}

private static readonly DTE2 _dte=DteExtensions.DTE;

public static event EventHandler<LastBuildStatusArgs> QueryLastBuildStatus;

public static void RunTest(bool debug) {
_dte.InitOutputCalls("RunTest");
Task.Factory.StartNew(() => RunTestCore(debug),CancellationToken.None,TaskCreationOptions.None,TaskScheduler.Current);
}

private void RunTestCore(bool debug) {
private static void RunTestCore(bool debug) {
var lastBuildStatusArgs = new LastBuildStatusArgs();
OnQueryLastBuildStatus(lastBuildStatusArgs);
try {
@@ -71,7 +86,7 @@ class EasyTest {
}
}

private string WriteToOutput(bool debug, string activeFileName){
private static string WriteToOutput(bool debug, string activeFileName){
string debugSwitch = null;
if (debug){
debugSwitch = " -d:" + ((TextSelection) _dte.ActiveDocument.Selection).CurrentLine;
@@ -83,7 +98,7 @@ class EasyTest {
return debugSwitch;
}

private string GetTestExecutorPath() {
private static string GetTestExecutorPath() {

var testExecutorPath = OptionClass.Instance.TestExecutorPath;
if (string.IsNullOrWhiteSpace(testExecutorPath)) {
@@ -94,10 +109,8 @@ class EasyTest {
return testExecutorPath;
}

protected virtual void OnQueryLastBuildStatus(LastBuildStatusArgs e) {
var handler = QueryLastBuildStatus;
handler?.Invoke(this, e);
protected static void OnQueryLastBuildStatus(LastBuildStatusArgs e){
QueryLastBuildStatus?.Invoke(null, e);
}

}
}
@@ -1,11 +1,20 @@
using System;
using System.ComponentModel.Design;
using System.Diagnostics;
using System.Linq;
using Xpand.VSIX.Extensions;
using Xpand.VSIX.VSPackage;

namespace Xpand.VSIX.Commands{
public class IISExpress{
public static void KillIISExpress(object sender, EventArgs eventArgs){
public class KillIISExpressCommand:VSCommand{
private KillIISExpressCommand() : base((sender, args) => Kill(), new CommandID(PackageGuids.guidVSXpandPackageCmdSet, PackageIds.cmdidKillIISExpress)) {
BindCommand("Global::Ctrl+Alt+Shift+I");
}

public static void Init(){
new KillIISExpressCommand();
}

public static void Kill(){
var processes = Process.GetProcessesByName("IISExpress");
if (!processes.Any())
DteExtensions.DTE.WriteToOutput("IISEXpress is not running");
@@ -6,21 +6,25 @@
using System.Threading.Tasks;
using EnvDTE;
using EnvDTE80;
using Microsoft.VisualStudio.Shell;
using Mono.Cecil;
using Xpand.VSIX.Extensions;
using Xpand.VSIX.Options;
using Xpand.VSIX.VSPackage;
using Task = System.Threading.Tasks.Task;

namespace Xpand.VSIX.Commands {
public class LoadProjectFromReferenceCommand:OleMenuCommand{
public LoadProjectFromReferenceCommand(int commandId= PackageIds.cmdidLoadProjectFromreference) :base((sender, args) => LoadProjects(), new CommandID(PackageGuids.guidVSXpandPackageCmdSet, commandId)) {
public class LoadProjectFromReferenceCommand:VSCommand{
private LoadProjectFromReferenceCommand(int commandId) :base((sender, args) => LoadProjects(), new CommandID(PackageGuids.guidVSXpandPackageCmdSet, commandId)) {
this.EnableForAssemblyReferenceSelection();
}
private static readonly DTE2 _dte = DteExtensions.DTE;

public static void Init(){
var loadProjectFromReferenceCommand = new LoadProjectFromReferenceCommand(PackageIds.cmdidLoadProjectFromreference);
loadProjectFromReferenceCommand.BindCommand("Solution Explorer::Ctrl+Alt+Shift+L");
new LoadProjectFromReferenceCommand(PackageIds.cmdidLoadProjectFromreferenceTool);
}

private static readonly DTE2 _dte = DteExtensions.DTE;
private static void SkipBuild(Project project) {
var solutionConfigurations = _dte.Solution.SolutionBuild.SolutionConfigurations.Cast<SolutionConfiguration>();
var solutionContexts = solutionConfigurations.SelectMany(
@@ -29,7 +33,6 @@ public class LoadProjectFromReferenceCommand:OleMenuCommand{
foreach (var solutionContext in solutionContexts) {
solutionContext.ShouldBuild = false;
}

}

private static void ChangeActiveConfiguration(Project project) {

0 comments on commit cbc5df5

Please sign in to comment.
You can’t perform that action at this time.