/TugberkUg.WLW.HighlightMe/WLWPlugin.cs
C# | 51 lines | 34 code | 17 blank | 0 comment | 2 complexity | 9786a2ea1b2fab2448e98bac98f140f0 MD5 | raw file
- using System;
- using System.Collections.Generic;
- using System.Linq;
- using System.Text;
- using WindowsLive.Writer.Api;
- using System.Windows.Forms;
- using ColorCode;
-
- namespace TugberkUg.WLW.HighlightMe {
-
- [WriterPluginAttribute(
- "ae796c8d-d35a-4e86-9644-1ec5cbeaafc5",
- "HighlightMe For Windows Live Writer By TugberkUg",
- ImagePath = "Images.SyntaxHighlighter.ico",
- PublisherUrl = "http://www.tugberkugurlu.com",
- Description = "Windows Live Writer Plugin For Syntax Highlighting")]
-
- [InsertableContentSourceAttribute("WLW.HighlightMe")]
- public class WLWPlugin : ContentSource {
-
- public override DialogResult CreateContent(IWin32Window dialogOwner, ref string content) {
-
- using (WLWForm wlwform = new WLWForm()) {
-
- DialogResult result = wlwform.ShowDialog();
-
- if (result == DialogResult.OK) {
-
- StringBuilder str = new StringBuilder();
- str.Append("<div class=\"code-wrapper border-shadow-1\">");
-
- string sourceCode = wlwform.ContentText;
-
- string colorizedSourceCode =
- new CodeColorizer().Colorize(sourceCode, Languages.FindById(wlwform.SelectedLanguage));
-
- str.Append(colorizedSourceCode);
-
- str.Append("</div>");
-
- content = str.ToString();
-
- }
-
- return result;
- }
-
- }
-
- }
- }