zoukankan      html  css  js  c++  java
  • x01.TestViewContent: 插件测试

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

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

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

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

     1 /**
     2  * TestViewContent.cs (c) 2015 by x01
     3  */
     4 using System;
     5 using System.Windows.Forms;
     6 using ICSharpCode.SharpDevelop.Gui;
     7 
     8 namespace x01.TestViewContent
     9 {
    10     /// <summary>
    11     /// Description of TestViewContent.
    12     /// </summary>
    13     public class TestViewContent : AbstractViewContent
    14     {
    15         Control control;        
    16         
    17         public override Control Control {
    18             get {
    19                 return control;
    20             }
    21         }
    22         
    23         public TestViewContent() : base("Test")
    24         {
    25             Panel panel = new Panel();
    26             panel.Dock = DockStyle.Fill;
    27             
    28             TextBox textbox = new TextBox();
    29             textbox.Text = "Hello world!";
    30             textbox.Dock = DockStyle.Fill;
    31             textbox.Multiline = true;
    32             textbox.Height = 500;
    33             
    34             panel.Controls.Add(textbox);
    35             
    36             this.control = panel;
    37         }
    38     }
    39 }
    TestViewContent

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

     1 /**
     2  * TestCommand.cs (c) 2015 by x01
     3  */
     4 using System;
     5 using ICSharpCode.SharpDevelop;
     6 using ICSharpCode.SharpDevelop.Gui;
     7 
     8 namespace x01.TestViewContent
     9 {
    10     /// <summary>
    11     /// Description of TestCommand.
    12     /// </summary>
    13     public class TestCommand : AbstractMenuCommand
    14     {
    15         public override void Run()
    16         {
    17             WorkbenchSingleton.Workbench.ShowView(new TestViewContent());
    18         }
    19     }
    20 }
    TestCommand

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

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

    关键部分是 15-18行。

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

  • 相关阅读:
    poj 3280 Cheapest Palindrome(区间DP)
    POJ 2392 Space Elevator(多重背包)
    HDU 1285 定比赛名次(拓扑排序)
    HDU 2680 Choose the best route(最短路)
    hdu 2899 Strange fuction (三分)
    HDU 4540 威威猫系列故事――打地鼠(DP)
    HDU 3485 Count 101(递推)
    POJ 1315 Don't Get Rooked(dfs)
    脱离eclipse,手动写一个servlet
    解析xml,几种方式
  • 原文地址:https://www.cnblogs.com/china_x01/p/4958137.html
Copyright © 2011-2022 走看看