• 编写Windows Live Writer插件(1)


    1 在VS2005中新建类库程序。

    image

    2添加 WindowsLive.Writer.Api.dll程序集引用(位于LiveWriter程序集目录下)

    右键->添加引用

    image

    选择WindowsLive.Writer.Api.dll (位于Live Writer目录下)

    image

    要让人家来自动调用你,你就得引用,到这一步基本工作算是做完了。

    3  添加类LiveWriterAdapter 继承于 ContentSource

    LiveWriterAdapter 完成代码

    using System;
    using System.Collections.Generic;
    using System.Text;
    using WindowsLive.Writer.Api;
    using System.Windows.Forms;

    namespace CodemarksFramework.LiveWriter.Plugins
    {
        [WriterPlugin("CA5ACC8E-5007-4df8-B110-DD6420C4CD4F", "插件代码块",
        PublisherUrl = "http://www.cnblogs.com/yaoshiyou/",
        ImagePath = "image.incode.bmp",
        Description = "插入代码块")]
        [InsertableContentSource("插入代码块")]

        public class LiveWriterAdapter : ContentSource
        {
            /// <summary>
            /// 重写的CreateContent方法
            /// </summary>
            /// <param name="dialogOwner"></param>
            /// <param name="content">返回给主机的内容</param>
            /// <returns>DialogResult.Ok </returns>
            public override DialogResult CreateContent(IWin32Window dialogOwner, ref string content)
            {
                content = "hello plugin";
                return DialogResult.OK;//DialogResult.No
            }
        }
    }

    4 方法解读

            /// <summary>
            /// 重写的CreateContent方法
            /// </summary>
            /// <param name="dialogOwner"></param>
            /// <param name="content">返回给主机的内容</param>
            /// <returns>DialogResult.Ok </returns>
            public override DialogResult CreateContent(IWin32Window dialogOwner, ref string content)
            {
                content = "hello plugin";
                return DialogResult.OK;
            }

    到这一步,我们的简单插件算是完成了。

    4 添加生成事件命令行方便调试

    Window程序我们可以调式,插件程序怎么调试呢,只有主机才能调用,修改应用属性,项目生成完成后将生成的dll程序copy到插件目录。(C:\Program Files\Windows Live\Writer\Plugins为Writer的插件目录)

    XCOPY /D /Y /R "$(TargetPath)" "C:\Program Files\Windows Live\Writer\Plugins"

    image

    生成插件成功,打开LiverWriter看看插件是否成功添加了呀,点一下试试,是不是插入Hello Plugins了呀

    image

    转:http://yangminhua.spaces.live.com/blog/cns!8809D78D1A132663!425.entry

  • 相关阅读:
    常用类型转换
    配置相关的一些辅助类
    Java Class与反射相关的一些工具类
    一些中文相关的操作方法
    提供一些对象有效性校验的方法
    编码相关的封装类
    数组相关的工具类
    提供Web相关的个工具类
    URL相关的工具类
    经纬度相关的一些操作
  • 原文地址:https://www.cnblogs.com/chencidi/p/1905921.html
Copyright © 2020-2023  润新知