简单的windows live writer代码插件(含源码)

简介: 新建一个类库 添加两个关键引用 using WindowsLive.Writer.Api; using System.Windows.Forms; using System.Web; 第一个引用的dll文件在你安装windows live writer的根目录下 名字叫WindowsLive.

新建一个类库

添加两个关键引用

using WindowsLive.Writer.Api;
using System.Windows.Forms;
using System.Web;

第一个引用的dll文件在你安装windows live writer的根目录下

名字叫WindowsLive.Writer.Api.dll

添加一个类文件,此文件程序用来处理用户插入的代码

    public static class ContentProcessor
    {
        public static string ProcessedContent { get; private set; }
        public static void Process(string originalContent)
        {
            ProcessedContent = (!string.IsNullOrEmpty(originalContent)
                ?string.Format("<fieldset style=\"background-color:#E0EFF6;color:#15428B\"><pre>{0}</pre></div>", HttpUtility.HtmlEncode(originalContent))
                :string.Empty
                );
        }
    }

添加一个windows form窗体,如图:

image

给确定按钮添加的事件为

        private void button1_Click(object sender, EventArgs e)
        {
            ContentProcessor.Process(this.textBox1.Text);
            this.Close();
        }

其中ContentProcessor.Process(this.textBox1.Text);
就是调用的我们上一个类文件中的处理程序

新增一个类文件

    [WriterPlugin("7c371eef-e350-4aae-af28-91613a9137e3", "xland", Description = "insert code plugin", Name = "xland", PublisherUrl = "http://www.cnblogs.com/liulun")]
    [InsertableContentSource("insert code",SidebarText="insert code")]
    public class MyPlugin:ContentSource
    {
        public override DialogResult CreateContent(IWin32Window dialogOwner, ref string content)
        {
            new ProcessForm().ShowDialog();
            content = ContentProcessor.ProcessedContent;
            return (!string.IsNullOrEmpty(content) ? DialogResult.OK : DialogResult.No);
        }
    }

其中7c371eef-e350-4aae-af28-91613a9137e3为一个GUID
其他的一些信息是插件在live writer中的信息
函数中第一句是创建一个窗口(我们刚才制作的窗口)
第二句获取我们输入的数据(处理过后的数据)
第三句让live writer知道有东西要插入。
content变量是live writer中的,所以要用ref修饰

都完成后只要把生成的dll文件放在live writer安装目录下Plugins文件夹内就可以了

此文章就是用这个插件写的

贴个图看下

image

源代码下载:LiveWriterPlugin.rar



另外:
我在我的blog中设置了这样的样式

pre { white-space: pre-wrap; /* css-3 */ white-space: -moz-pre-wrap; /* Mozilla, since 1999 */ white-space: -pre-wrap; /* Opera 4-6 */ white-space: -o-pre-wrap; /* Opera 7 */ }
* html pre { word-wrap: break-word; /* Internet Explorer 5.5+ */ white-space : normal ; /* Internet Explorer 5.5+ */ }

具体设置方法是,进入你的博客园后台》》》选项》》》config》》》通过CSS定制页面
这样设置主要是不让代码太宽,撑破页面

目录
相关文章
|
1月前
|
数据可视化 Python Windows
使用 Python 代码在 windows 控制台打印正弦三角函数
使用 Python 代码在 windows 控制台打印正弦三角函数
18 0
|
6月前
|
JavaScript 前端开发 iOS开发
电脑浏览器原来这样用才能发挥到极致 ——那些好用的插件(Windows Macos 通用)2
电脑浏览器原来这样用才能发挥到极致 ——那些好用的插件(Windows Macos 通用)
75 0
|
6月前
|
Web App开发 iOS开发 开发者
电脑浏览器原来这样用才能发挥到极致 ——那些好用的插件(Windows Macos 通用)1
电脑浏览器原来这样用才能发挥到极致 ——那些好用的插件(Windows Macos 通用)
45 0
|
3月前
|
开发工具 数据安全/隐私保护 C++
windows openssl安装和基本使用(代码演示)
本文主要讲到了openssl的基本使用方法,开发环境为windows,开发工具为VS2019.本文主要是说明openssl如何使用,不介绍任何理论知识,如果有不懂的,请自行百度。个人建议下一个everything查询工具,真的很好用,比window自带的查询快了很多,可以查询自己想要的文件
161 0
windows openssl安装和基本使用(代码演示)
|
9月前
|
Windows
Windows Registry Operation / DTRegistry 插件说明
Windows Registry Operation / DTRegistry 插件说明
62 0
|
5月前
|
Unix Linux C#
使用 ABAP + OLE 消费 Windows DLL 文件里的代码和服务
使用 ABAP + OLE 消费 Windows DLL 文件里的代码和服务
27 0
|
6月前
|
Windows
[UE虚幻引擎] DTCopyFile 插件说明 - 使用蓝图拷贝复制文件 (Windows)
本插件可以在虚幻引擎中使用蓝图对系统的其他文件进行拷贝复制操作。
37 0
|
消息中间件 监控 数据可视化
【时序数据库InfluxDB】Windows环境下配置InfluxDB+数据可视化,以及使用 C#进行简单操作的代码实例
influxDB的官网下载地址 https://portal.influxdata.com/downloads/打开以后,如下图所示,可以选择版本号,以及平台。此处咱们选择windows平台。不过此处没有实际的可以下载的地方,着实比较过分,不过咱们可以另辟蹊径。
628 0
【时序数据库InfluxDB】Windows环境下配置InfluxDB+数据可视化,以及使用 C#进行简单操作的代码实例
|
9月前
|
Windows
windows双开程序代码脚本
windows双开程序代码脚本
|
9月前
|
存储 Shell 开发工具
Windows系统下将代码上传至gitLab或gitHub
Windows系统下将代码上传至gitLab或gitHub