-
-
Notifications
You must be signed in to change notification settings - Fork 30
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
+ Transform markdown document command
- Loading branch information
Showing
12 changed files
with
7,125 additions
and
1 deletion.
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
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
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
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
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,36 @@ | ||
using System; | ||
using System.Windows; | ||
using Microsoft.VisualStudio.Shell; | ||
|
||
namespace Codist.Commands | ||
{ | ||
/// <summary>A command which performs XSLT on the active code document window.</summary> | ||
internal static class TransformDocumentCommand | ||
{ | ||
public static void Initialize() { | ||
if (CodistPackage.VsVersion.Major < 17) { | ||
return; | ||
} | ||
Command.TransformDocument.Register(Execute, (s, args) => { | ||
ThreadHelper.ThrowIfNotOnUIThread(); | ||
((OleMenuCommand)s).Visible = TextEditorHelper.GetActiveWpfDocumentView()?.TextBuffer.LikeContentType("markdown") == true; | ||
}); | ||
} | ||
|
||
static void Execute(object sender, EventArgs e) { | ||
ThreadHelper.ThrowIfNotOnUIThread(); | ||
var doc = CodistPackage.DTE.ActiveDocument; | ||
if (doc == null) { | ||
return; | ||
} | ||
var docWindow = TextEditorHelper.GetActiveWpfDocumentView(); | ||
if (docWindow == null) { | ||
return; | ||
} | ||
new TransformDocumentWindow(VsShellHelper.GetActiveProjectInSolutionExplorer(), docWindow.TextSnapshot, doc.FullName) { | ||
Owner = Application.Current.MainWindow, | ||
WindowStartupLocation = WindowStartupLocation.CenterOwner | ||
}.ShowDialog(); | ||
} | ||
} | ||
} |
Oops, something went wrong.