Created
January 22, 2017 21:52
-
-
Save RickStrahl/4de16b3bab37deb698093ac00b624a96 to your computer and use it in GitHub Desktop.
Gist Addin OnExecute() code that fires off the Addin's UI.
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
public override void OnExecute(object sender) | |
{ | |
var editor = GetMarkdownEditor(); | |
if (editor == null) | |
return; | |
var gist = new GistItem() | |
{ | |
code = editor.AceEditor.getselection(false), | |
language = "cs" | |
}; | |
var form = new PasteCodeAsGitWindow(this); | |
form.Owner = Model.Window; | |
form.Gist = gist; | |
form.ShowDialog(); | |
if (form.Cancelled) | |
return; | |
if (!string.IsNullOrEmpty(gist.embedUrl)) | |
editor.SetSelectionAndFocus($"<script src=\"{gist.embedUrl}\"></script>\r\n"); | |
Model.Window.ShowStatus("Gist embedded", 5000); | |
Model.Window.SetStatusIcon(FontAwesomeIcon.GithubAlt, Colors.Green); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment