PageRenderTime 34ms CodeModel.GetById 8ms RepoModel.GetById 1ms app.codeStats 0ms

/TugberkUg.WLW.HighlightMe/WLWPlugin.cs

#
C# | 51 lines | 34 code | 17 blank | 0 comment | 2 complexity | 9786a2ea1b2fab2448e98bac98f140f0 MD5 | raw file
  1. using System;
  2. using System.Collections.Generic;
  3. using System.Linq;
  4. using System.Text;
  5. using WindowsLive.Writer.Api;
  6. using System.Windows.Forms;
  7. using ColorCode;
  8. namespace TugberkUg.WLW.HighlightMe {
  9. [WriterPluginAttribute(
  10. "ae796c8d-d35a-4e86-9644-1ec5cbeaafc5",
  11. "HighlightMe For Windows Live Writer By TugberkUg",
  12. ImagePath = "Images.SyntaxHighlighter.ico",
  13. PublisherUrl = "http://www.tugberkugurlu.com",
  14. Description = "Windows Live Writer Plugin For Syntax Highlighting")]
  15. [InsertableContentSourceAttribute("WLW.HighlightMe")]
  16. public class WLWPlugin : ContentSource {
  17. public override DialogResult CreateContent(IWin32Window dialogOwner, ref string content) {
  18. using (WLWForm wlwform = new WLWForm()) {
  19. DialogResult result = wlwform.ShowDialog();
  20. if (result == DialogResult.OK) {
  21. StringBuilder str = new StringBuilder();
  22. str.Append("<div class=\"code-wrapper border-shadow-1\">");
  23. string sourceCode = wlwform.ContentText;
  24. string colorizedSourceCode =
  25. new CodeColorizer().Colorize(sourceCode, Languages.FindById(wlwform.SelectedLanguage));
  26. str.Append(colorizedSourceCode);
  27. str.Append("</div>");
  28. content = str.ToString();
  29. }
  30. return result;
  31. }
  32. }
  33. }
  34. }