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