編寫Windows Live Writer高亮外掛程式 簡單外掛程式開發(三)

來源:互聯網
上載者:User
為什麼要這麼做

 

怎麼樣做

1 在VS2005中建立類庫程式。

2添加 WindowsLive.Writer.Api.dll程式集引用(位於LiveWriter程式集目錄下)

右鍵->添加引用

 

選擇WindowsLive.Writer.Api.dll (位於Live Writer目錄下)

要讓人家來自動調用你,你就得引用,到這一步基本工作算是做完了。

 

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;        }    }}

 

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"

產生外掛程式成功,開啟LiverWriter看看外掛程式是否成功添加了呀,點一下試試,是不是插入Hello Plugins了呀

更多連結

編寫Windows Live Writer高亮外掛程式  目錄

相關文章

聯繫我們

該頁面正文內容均來源於網絡整理,並不代表阿里雲官方的觀點,該頁面所提到的產品和服務也與阿里云無關,如果該頁面內容對您造成了困擾,歡迎寫郵件給我們,收到郵件我們將在5個工作日內處理。

如果您發現本社區中有涉嫌抄襲的內容,歡迎發送郵件至: info-contact@alibabacloud.com 進行舉報並提供相關證據,工作人員會在 5 個工作天內聯絡您,一經查實,本站將立刻刪除涉嫌侵權內容。

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.