This repository has been archived by the owner on Nov 27, 2020. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 44
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Had to make the package async to publish
- Loading branch information
Showing
4 changed files
with
44 additions
and
24 deletions.
There are no files selected for viewing
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 |
---|---|---|
|
@@ -167,3 +167,4 @@ pip-log.txt | |
# Nuget packages | ||
/packages | ||
/paket-files | ||
/ImageCommentsPackage/Output/ImageComments.vsix |
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,32 @@ | ||
namespace LM.ImageComments.Package | ||
{ | ||
using System.ComponentModel.Design; | ||
using LM.ImageComments.EditorComponent; | ||
using Microsoft.VisualStudio.Shell; | ||
using Task = System.Threading.Tasks.Task; | ||
|
||
internal sealed class ImageCommentsCommand | ||
{ | ||
public static async Task InitializeAsync(AsyncPackage package) | ||
{ | ||
await ThreadHelper.JoinableTaskFactory.SwitchToMainThreadAsync(); | ||
|
||
var mcs = await package.GetServiceAsync((typeof(IMenuCommandService))) as OleMenuCommandService; | ||
|
||
if (null != mcs) | ||
{ | ||
var menuCommandID = new CommandID(GuidList.guidImageCommentsPackageCmdSet, (int)PkgCmdIDList.cmdidToggleImageComments); | ||
|
||
var menuItem = new MenuCommand((s, e) => Execute(package), menuCommandID); | ||
|
||
mcs.AddCommand(menuItem); | ||
} | ||
} | ||
|
||
private static void Execute(AsyncPackage package) | ||
{ | ||
ThreadHelper.ThrowIfNotOnUIThread(); | ||
ImageAdornmentManager.ToggleEnabled(); | ||
} | ||
} | ||
} |
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 |
---|---|---|
@@ -1,46 +1,32 @@ | ||
namespace LM.ImageComments.Package | ||
{ | ||
using System; | ||
using System.ComponentModel.Design; | ||
using System.Diagnostics; | ||
using System.Diagnostics.CodeAnalysis; | ||
using System.Globalization; | ||
using System.Diagnostics.CodeAnalysis; | ||
using System.Globalization; | ||
using System.Runtime.InteropServices; | ||
using LM.ImageComments.EditorComponent; | ||
using System.Threading; | ||
using Microsoft.VisualStudio.Shell; | ||
using Task = System.Threading.Tasks.Task; | ||
|
||
/// <summary> | ||
/// Package containing image comment command | ||
/// </summary> | ||
[PackageRegistration(UseManagedResourcesOnly = true)] | ||
[PackageRegistration(UseManagedResourcesOnly = true, AllowsBackgroundLoading = true)] | ||
[InstalledProductRegistration("#110", "#112", "1.0", IconResourceID = 400)] | ||
[ProvideMenuResource("Menus.ctmenu", 1)] | ||
[Guid(GuidList.guidImageCommentsPackagePkgString)] | ||
[SuppressMessage("StyleCop.CSharp.DocumentationRules", "SA1650:ElementDocumentationMustBeSpelledCorrectly", Justification = "pkgdef, VS and vsixmanifest are valid VS terms")] | ||
public sealed class ImageCommentsPackage : Microsoft.VisualStudio.Shell.Package | ||
public sealed class ImageCommentsPackage : AsyncPackage | ||
{ | ||
#region Package Members | ||
|
||
/// <summary> | ||
/// Creates and registers image comment enable/disable toggle command | ||
/// </summary> | ||
protected override void Initialize() | ||
protected override async Task InitializeAsync(CancellationToken cancellationToken, IProgress<ServiceProgressData> progress) | ||
{ | ||
ThreadHelper.ThrowIfNotOnUIThread(); | ||
|
||
Trace.WriteLine (string.Format(CultureInfo.CurrentCulture, "Entering Initialize() of: {0}", this.ToString())); | ||
base.Initialize(); | ||
|
||
OleMenuCommandService mcs = GetService(typeof(IMenuCommandService)) as OleMenuCommandService; | ||
if ( null != mcs ) | ||
{ | ||
CommandID menuCommandID = new CommandID(GuidList.guidImageCommentsPackageCmdSet, (int)PkgCmdIDList.cmdidToggleImageComments); | ||
MenuCommand menuItem = new MenuCommand( | ||
(sender, args) => { ImageAdornmentManager.ToggleEnabled(); }, | ||
menuCommandID); | ||
mcs.AddCommand( menuItem ); | ||
} | ||
Trace.WriteLine(string.Format(CultureInfo.CurrentCulture, "Entering Initialize() of: {0}", this.ToString())); | ||
await JoinableTaskFactory.SwitchToMainThreadAsync(cancellationToken); | ||
await ImageCommentsCommand.InitializeAsync(this); | ||
} | ||
#endregion | ||
} | ||
} |
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