zoukankan      html  css  js  c++  java
  • 编写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

  • 相关阅读:
    Ruby单例方法和实例方法
    Silverlight本地化和全球化
    多线程 or 多进程 (转强力推荐)
    循环pthread_create导致虚拟内存上涨
    int在linux上的保存情况
    查看数据流的流程
    查看linux系统版本,内核,CPU,MEM,位数的相关命令(转)
    0/1背包问题
    linux下计算程序运行时间
    夸平台夸字符编码问题
  • 原文地址:https://www.cnblogs.com/chencidi/p/1905921.html
Copyright © 2011-2022 走看看