-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #1 from andeart/develop
Case-conversion commands added. Other VSIX project polish added.
- Loading branch information
Showing
26 changed files
with
6,951 additions
and
44 deletions.
There are no files selected for viewing
98 changes: 98 additions & 0 deletions
98
JsonButlerIde/JsonButlerIde/Commands/ConvertCamelCaseCommand.cs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,98 @@ | ||
using System; | ||
using System.ComponentModel.Design; | ||
using System.Windows.Forms; | ||
using Andeart.CaseConversion; | ||
using Andeart.JsonButlerIde.Forms; | ||
using Andeart.JsonButlerIde.Utilities; | ||
using Microsoft.VisualStudio.Shell; | ||
using Microsoft.VisualStudio.TextManager.Interop; | ||
|
||
|
||
|
||
namespace Andeart.JsonButlerIde.Commands | ||
{ | ||
|
||
/// <summary> | ||
/// Command handler | ||
/// </summary> | ||
internal sealed class ConvertCamelCaseCommand | ||
{ | ||
/// <summary> | ||
/// Command ID. | ||
/// </summary> | ||
public const int CommandId = 4130; | ||
|
||
/// <summary> | ||
/// Command menu group (command set GUID). | ||
/// </summary> | ||
public static readonly Guid CommandSet = new Guid ("21aaa842-876e-414f-9e9d-b81fb8d21749"); | ||
|
||
/// <summary> | ||
/// VS Package that provides this command, not null. | ||
/// </summary> | ||
private readonly Package _package; | ||
|
||
/// <summary> | ||
/// Gets the instance of the command. | ||
/// </summary> | ||
public static ConvertCamelCaseCommand Instance { get; private set; } | ||
|
||
/// <summary> | ||
/// Gets the service provider from the owner package. | ||
/// </summary> | ||
private IServiceProvider ServiceProvider => _package; | ||
|
||
/// <summary> | ||
/// Initializes a new instance of the <see cref="ConvertCamelCaseCommand"/> class. | ||
/// Adds our command handlers for menu (commands must exist in the command table file) | ||
/// </summary> | ||
/// <param name="package">Owner package, not null.</param> | ||
private ConvertCamelCaseCommand (Package package) | ||
{ | ||
_package = package ?? throw new ArgumentNullException (nameof(package)); | ||
if (!(ServiceProvider.GetService (typeof(IMenuCommandService)) is OleMenuCommandService commandService)) | ||
{ | ||
throw new ArgumentNullException (nameof(commandService)); | ||
} | ||
|
||
CommandID menuCommandId = new CommandID (CommandSet, CommandId); | ||
MenuCommand menuItem = new MenuCommand (Execute, menuCommandId); | ||
commandService.AddCommand (menuItem); | ||
} | ||
|
||
/// <summary> | ||
/// Initializes the singleton instance of the command. | ||
/// </summary> | ||
/// <param name="package">Owner package, not null.</param> | ||
public static void Initialize (Package package) | ||
{ | ||
// Verify the current thread is the UI thread - the call to AddCommand in ConvertCamelCaseCommand's constructor requires | ||
// the UI thread. | ||
ThreadHelper.ThrowIfNotOnUIThread (); | ||
|
||
Instance = new ConvertCamelCaseCommand (package); | ||
} | ||
|
||
/// <summary> | ||
/// This function is the callback used to execute the command when the menu item is clicked. | ||
/// See the constructor to see how the menu item is associated with this function using | ||
/// OleMenuCommandService service and MenuCommand class. | ||
/// </summary> | ||
/// <param name="sender">Event sender.</param> | ||
/// <param name="args">Event args.</param> | ||
private void Execute (object sender, EventArgs args) | ||
{ | ||
ThreadHelper.ThrowIfNotOnUIThread (); | ||
|
||
object service = ServiceProvider.GetService (typeof(SVsTextManager)); | ||
IVsTextManager2 textManager = service as IVsTextManager2; | ||
string highlightedText = EditorUtilities.GetHighlightedText (textManager); | ||
|
||
string convertedText = highlightedText.ToCamelCase (); | ||
Clipboard.SetText (convertedText); | ||
AlertWindow alertWindow = new AlertWindow (); | ||
alertWindow.ShowDialogWithMessage ("Converted text copied to clipboard."); | ||
} | ||
} | ||
|
||
} |
98 changes: 98 additions & 0 deletions
98
JsonButlerIde/JsonButlerIde/Commands/ConvertLowerSnakeCaseCommand.cs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,98 @@ | ||
using System; | ||
using System.ComponentModel.Design; | ||
using System.Windows.Forms; | ||
using Andeart.CaseConversion; | ||
using Andeart.JsonButlerIde.Forms; | ||
using Andeart.JsonButlerIde.Utilities; | ||
using Microsoft.VisualStudio.Shell; | ||
using Microsoft.VisualStudio.TextManager.Interop; | ||
|
||
|
||
|
||
namespace Andeart.JsonButlerIde.Commands | ||
{ | ||
|
||
/// <summary> | ||
/// Command handler | ||
/// </summary> | ||
internal sealed class ConvertLowerSnakeCaseCommand | ||
{ | ||
/// <summary> | ||
/// Command ID. | ||
/// </summary> | ||
public const int CommandId = 4131; | ||
|
||
/// <summary> | ||
/// Command menu group (command set GUID). | ||
/// </summary> | ||
public static readonly Guid CommandSet = new Guid ("21aaa842-876e-414f-9e9d-b81fb8d21749"); | ||
|
||
/// <summary> | ||
/// VS Package that provides this command, not null. | ||
/// </summary> | ||
private readonly Package _package; | ||
|
||
/// <summary> | ||
/// Gets the instance of the command. | ||
/// </summary> | ||
public static ConvertLowerSnakeCaseCommand Instance { get; private set; } | ||
|
||
/// <summary> | ||
/// Gets the service provider from the owner package. | ||
/// </summary> | ||
private IServiceProvider ServiceProvider => _package; | ||
|
||
/// <summary> | ||
/// Initializes a new instance of the <see cref="ConvertLowerSnakeCaseCommand"/> class. | ||
/// Adds our command handlers for menu (commands must exist in the command table file) | ||
/// </summary> | ||
/// <param name="package">Owner package, not null.</param> | ||
private ConvertLowerSnakeCaseCommand (Package package) | ||
{ | ||
_package = package ?? throw new ArgumentNullException (nameof(package)); | ||
if (!(ServiceProvider.GetService (typeof(IMenuCommandService)) is OleMenuCommandService commandService)) | ||
{ | ||
throw new ArgumentNullException (nameof(commandService)); | ||
} | ||
|
||
CommandID menuCommandId = new CommandID (CommandSet, CommandId); | ||
MenuCommand menuItem = new MenuCommand (Execute, menuCommandId); | ||
commandService.AddCommand (menuItem); | ||
} | ||
|
||
/// <summary> | ||
/// Initializes the singleton instance of the command. | ||
/// </summary> | ||
/// <param name="package">Owner package, not null.</param> | ||
public static void Initialize (Package package) | ||
{ | ||
// Verify the current thread is the UI thread - the call to AddCommand in ConvertLowerSnakeCaseCommand's constructor requires | ||
// the UI thread. | ||
ThreadHelper.ThrowIfNotOnUIThread (); | ||
|
||
Instance = new ConvertLowerSnakeCaseCommand (package); | ||
} | ||
|
||
/// <summary> | ||
/// This function is the callback used to execute the command when the menu item is clicked. | ||
/// See the constructor to see how the menu item is associated with this function using | ||
/// OleMenuCommandService service and MenuCommand class. | ||
/// </summary> | ||
/// <param name="sender">Event sender.</param> | ||
/// <param name="args">Event args.</param> | ||
private void Execute (object sender, EventArgs args) | ||
{ | ||
ThreadHelper.ThrowIfNotOnUIThread (); | ||
|
||
object service = ServiceProvider.GetService (typeof(SVsTextManager)); | ||
IVsTextManager2 textManager = service as IVsTextManager2; | ||
string highlightedText = EditorUtilities.GetHighlightedText (textManager); | ||
|
||
string convertedText = highlightedText.ToLowerSnakeCase (); | ||
Clipboard.SetText (convertedText); | ||
AlertWindow alertWindow = new AlertWindow (); | ||
alertWindow.ShowDialogWithMessage ("Converted text copied to clipboard."); | ||
} | ||
} | ||
|
||
} |
98 changes: 98 additions & 0 deletions
98
JsonButlerIde/JsonButlerIde/Commands/ConvertPascalCaseCommand.cs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,98 @@ | ||
using System; | ||
using System.ComponentModel.Design; | ||
using System.Windows.Forms; | ||
using Andeart.CaseConversion; | ||
using Andeart.JsonButlerIde.Forms; | ||
using Andeart.JsonButlerIde.Utilities; | ||
using Microsoft.VisualStudio.Shell; | ||
using Microsoft.VisualStudio.TextManager.Interop; | ||
|
||
|
||
|
||
namespace Andeart.JsonButlerIde.Commands | ||
{ | ||
|
||
/// <summary> | ||
/// Command handler | ||
/// </summary> | ||
internal sealed class ConvertPascalCaseCommand | ||
{ | ||
/// <summary> | ||
/// Command ID. | ||
/// </summary> | ||
public const int CommandId = 4132; | ||
|
||
/// <summary> | ||
/// Command menu group (command set GUID). | ||
/// </summary> | ||
public static readonly Guid CommandSet = new Guid ("21aaa842-876e-414f-9e9d-b81fb8d21749"); | ||
|
||
/// <summary> | ||
/// VS Package that provides this command, not null. | ||
/// </summary> | ||
private readonly Package _package; | ||
|
||
/// <summary> | ||
/// Gets the instance of the command. | ||
/// </summary> | ||
public static ConvertPascalCaseCommand Instance { get; private set; } | ||
|
||
/// <summary> | ||
/// Gets the service provider from the owner package. | ||
/// </summary> | ||
private IServiceProvider ServiceProvider => _package; | ||
|
||
/// <summary> | ||
/// Initializes a new instance of the <see cref="ConvertPascalCaseCommand"/> class. | ||
/// Adds our command handlers for menu (commands must exist in the command table file) | ||
/// </summary> | ||
/// <param name="package">Owner package, not null.</param> | ||
private ConvertPascalCaseCommand (Package package) | ||
{ | ||
_package = package ?? throw new ArgumentNullException (nameof(package)); | ||
if (!(ServiceProvider.GetService (typeof(IMenuCommandService)) is OleMenuCommandService commandService)) | ||
{ | ||
throw new ArgumentNullException (nameof(commandService)); | ||
} | ||
|
||
CommandID menuCommandId = new CommandID (CommandSet, CommandId); | ||
MenuCommand menuItem = new MenuCommand (Execute, menuCommandId); | ||
commandService.AddCommand (menuItem); | ||
} | ||
|
||
/// <summary> | ||
/// Initializes the singleton instance of the command. | ||
/// </summary> | ||
/// <param name="package">Owner package, not null.</param> | ||
public static void Initialize (Package package) | ||
{ | ||
// Verify the current thread is the UI thread - the call to AddCommand in ConvertPascalCaseCommand's constructor requires | ||
// the UI thread. | ||
ThreadHelper.ThrowIfNotOnUIThread (); | ||
|
||
Instance = new ConvertPascalCaseCommand (package); | ||
} | ||
|
||
/// <summary> | ||
/// This function is the callback used to execute the command when the menu item is clicked. | ||
/// See the constructor to see how the menu item is associated with this function using | ||
/// OleMenuCommandService service and MenuCommand class. | ||
/// </summary> | ||
/// <param name="sender">Event sender.</param> | ||
/// <param name="args">Event args.</param> | ||
private void Execute (object sender, EventArgs args) | ||
{ | ||
ThreadHelper.ThrowIfNotOnUIThread (); | ||
|
||
object service = ServiceProvider.GetService (typeof(SVsTextManager)); | ||
IVsTextManager2 textManager = service as IVsTextManager2; | ||
string highlightedText = EditorUtilities.GetHighlightedText (textManager); | ||
|
||
string convertedText = highlightedText.ToPascalCase (); | ||
Clipboard.SetText (convertedText); | ||
AlertWindow alertWindow = new AlertWindow (); | ||
alertWindow.ShowDialogWithMessage ("Converted text copied to clipboard."); | ||
} | ||
} | ||
|
||
} |
96 changes: 96 additions & 0 deletions
96
JsonButlerIde/JsonButlerIde/Commands/ConvertUnderscoreCamelCaseCommand.cs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,96 @@ | ||
using System; | ||
using System.ComponentModel.Design; | ||
using System.Windows.Forms; | ||
using Andeart.CaseConversion; | ||
using Andeart.JsonButlerIde.Forms; | ||
using Andeart.JsonButlerIde.Utilities; | ||
using Microsoft.VisualStudio.Shell; | ||
using Microsoft.VisualStudio.TextManager.Interop; | ||
|
||
|
||
|
||
namespace Andeart.JsonButlerIde.Commands | ||
{ | ||
|
||
/// <summary> | ||
/// Command handler | ||
/// </summary> | ||
internal sealed class ConvertUnderscoreCamelCaseCommand | ||
{ | ||
/// <summary> | ||
/// Command ID. | ||
/// </summary> | ||
public const int CommandId = 4133; | ||
|
||
/// <summary> | ||
/// Command menu group (command set GUID). | ||
/// </summary> | ||
public static readonly Guid CommandSet = new Guid ("21aaa842-876e-414f-9e9d-b81fb8d21749"); | ||
|
||
/// <summary> | ||
/// VS Package that provides this command, not null. | ||
/// </summary> | ||
private readonly Package _package; | ||
|
||
/// <summary> | ||
/// Gets the instance of the command. | ||
/// </summary> | ||
public static ConvertUnderscoreCamelCaseCommand Instance { get; private set; } | ||
|
||
/// <summary> | ||
/// Gets the service provider from the owner package. | ||
/// </summary> | ||
private IServiceProvider ServiceProvider => _package; | ||
|
||
/// <summary> | ||
/// Initializes a new instance of the <see cref="ConvertUnderscoreCamelCaseCommand"/> class. | ||
/// Adds our command handlers for menu (commands must exist in the command table file) | ||
/// </summary> | ||
/// <param name="package">Owner package, not null.</param> | ||
private ConvertUnderscoreCamelCaseCommand (Package package) | ||
{ | ||
_package = package ?? throw new ArgumentNullException (nameof(package)); | ||
if (!(ServiceProvider.GetService (typeof(IMenuCommandService)) is OleMenuCommandService commandService)) | ||
{ | ||
throw new ArgumentNullException (nameof(commandService)); | ||
} | ||
|
||
CommandID menuCommandId = new CommandID (CommandSet, CommandId); | ||
MenuCommand menuItem = new MenuCommand (Execute, menuCommandId); | ||
commandService.AddCommand (menuItem); | ||
} | ||
|
||
/// <summary> | ||
/// Initializes the singleton instance of the command. | ||
/// </summary> | ||
/// <param name="package">Owner package, not null.</param> | ||
public static void Initialize (Package package) | ||
{ | ||
// Verify the current thread is the UI thread - the call to AddCommand in ConvertUnderscoreCamelCase's constructor requires | ||
// the UI thread. | ||
ThreadHelper.ThrowIfNotOnUIThread (); | ||
|
||
Instance = new ConvertUnderscoreCamelCaseCommand (package); | ||
} | ||
|
||
/// <summary> | ||
/// This function is the callback used to execute the command when the menu item is clicked. | ||
/// See the constructor to see how the menu item is associated with this function using | ||
/// OleMenuCommandService service and MenuCommand class. | ||
/// </summary> | ||
/// <param name="sender">Event sender.</param> | ||
/// <param name="args">Event args.</param> | ||
private void Execute (object sender, EventArgs args) | ||
{ | ||
object service = ServiceProvider.GetService (typeof(SVsTextManager)); | ||
IVsTextManager2 textManager = service as IVsTextManager2; | ||
string highlightedText = EditorUtilities.GetHighlightedText (textManager); | ||
|
||
string convertedText = highlightedText.ToUnderscoreCamelCase (); | ||
Clipboard.SetText (convertedText); | ||
AlertWindow alertWindow = new AlertWindow (); | ||
alertWindow.ShowDialogWithMessage ("Converted text copied to clipboard."); | ||
} | ||
} | ||
|
||
} |
Oops, something went wrong.