x01.TestViewContent:插件测试

王朝学院·作者佚名  2016-08-28
窄屏简体版  字體: 小  |  中  |  大  |  超大  

开发神器 SharpDevelop 的插件系统,很有学习的必要。

1.首先在 github 上下载源代码,确保编译运行无误。

2.在 AddIns/Misc 下添加 SharpDevelop 插件项目 x01.TestViewContent,然后添加 ICSharpCode.Core 和 ICSharpCode.SharpDevelop 引用,设置这两个引用的 Local Copy 为 false;在项目属性上选编译输出为 “..\..\..\..\AddIns\AddIns\Misc\TestViewContent\”,可参考其他插件。设置 TestViewContent.addin 的文件属性 Local copy 为 Always。

3.添加类 TestViewContent.cs, 内容如下:

[flash=500,400]http://s1.knowsky.com/20160211/iwaewkhpsff14.gif[/flash][flash=500,400]http://s1.knowsky.com/20160211/eoqrnzi0td114.gif[/flash]1/**2* TestViewContent.cs (c) 2015 by x013*/4usingSystem;5usingSystem.Windows.Forms;6usingICSharpCode.SharpDevelop.Gui;78namespacex01.TestViewContent9{10///<summary>11///Description of TestViewContent.12///</summary>13publicclassTestViewContent : AbstractViewContent14{15Control control;1617publicoverrideControl Control {18get{19returncontrol;20}21}2223publicTestViewContent() :base("Test")24{25Panel panel =newPanel();26panel.Dock =DockStyle.Fill;2728TextBox textbox =newTextBox();29textbox.Text ="Hello world!";30textbox.Dock =DockStyle.Fill;31textbox.Multiline =true;32textbox.Height =500;3334panel.Controls.Add(textbox);3536this.control =panel;37}38}39}

TestViewContent

4.添加类 TestCommand.cs,内容如下:

[flash=500,400]http://s1.knowsky.com/20160211/iwaewkhpsff14.gif[/flash][flash=500,400]http://s1.knowsky.com/20160211/eoqrnzi0td114.gif[/flash]1/**2* TestCommand.cs (c) 2015 by x013*/4usingSystem;5usingICSharpCode.SharpDevelop;6usingICSharpCode.SharpDevelop.Gui;78namespacex01.TestViewContent9{10///<summary>11///Description of TestCommand.12///</summary>13publicclassTestCommand : AbstractMenuCommand14{15publicoverridevoidRun()16{17WorkbenchSingleton.Workbench.ShowView(newTestViewContent());18}19}20}

TestCommand

5.修改 TestViewContent.addin 后的内容如下:

1<AddIn name ="x01.TestViewContent"2author ="Administrator"3url =""4description ="TODO: Put description here">56<Runtime>7<Import assembly ="x01.TestViewContent.dll"/>8</Runtime>910<!-- Extend the SharpDevelop AddIn-Tree likethis:11<Path name = ...>12<.../>13</Path>14-->15<Path name="/Workspace/Autostart">16<Class id="TestCommand"17class="x01.TestViewContent.TestCommand"/>18</Path>19</AddIn>

关键部分是 15-18行。

6.编译生成该插件项目。OK!这时,你会惊奇的发现,不需重新编译整个 Solution,直接进入 bin 目录运行 SharpDevelop.exe 时,该插件已然可用。效果图如下:

[flash=500,400]http://s1.knowsky.com/20160211/lxi3bcqj2ek14.png[/flash]

 
 
免责声明:本文为网络用户发布,其观点仅代表作者个人观点,与本站无关,本站仅提供信息存储服务。文中陈述内容未经本站证实,其真实性、完整性、及时性本站不作任何保证或承诺,请读者仅作参考,并请自行核实相关内容。
 
© 2005- 王朝網路 版權所有 導航