Skip to content

Instantly share code, notes, and snippets.

@RickStrahl
Created January 22, 2017 21:52
Show Gist options
  • Save RickStrahl/4de16b3bab37deb698093ac00b624a96 to your computer and use it in GitHub Desktop.
Save RickStrahl/4de16b3bab37deb698093ac00b624a96 to your computer and use it in GitHub Desktop.
Gist Addin OnExecute() code that fires off the Addin's UI.
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