自从SharpDevelop 源码分析的系列文章发出来之后,很多朋友给了不错的评价,在这里先感谢各位朋友的鼓励。另外,评论中有位朋友想看看我在文章中提到的AddInTreeView插件,其实这个是个很简单的小东西,因此单独发在这里了。(好像没有找到那里能上传文件,因此直接贴代码了)

AddinTreeViewCommand.cs
 /**//*
  * Created by SharpDevelop.
  * User: Administrator
  * Date: 2004-10-4
  * Time: 4:12
  * 
  * To change this template use Tools | Options | Coding | Edit Standard Headers.
  */
 using System;
 using System.Windows.Forms;
 using System.CodeDom.Compiler;using ICSharpCode.SharpDevelop.Gui;
 using ICSharpCode.SharpDevelop.Gui.Pads;
 using ICSharpCode.Core.AddIns;
 using ICSharpCode.Core.AddIns.Codons;
 using ICSharpCode.SharpDevelop.Services;namespace Addins.AddinTreeView
 {
     /** <summary>
     /// Description of MyClass.
     /// </summary>
     public class AddinTreeViewCommand: AbstractMenuCommand
     {    
         public override void Run()
         {    
             using (AddinTreeViewContent viewContent = new AddinTreeViewContent() )
             {
                 WorkbenchSingleton.Workbench.ShowView(viewContent);
             }
         }        
     }    public class AddinTreeViewContent: AbstractViewContent
     {
         AddinTreeViewControl viewControl = new AddinTreeViewControl();        public override Control Control 
         {
             get 
             {
                 return viewControl;
             }
         }        public override bool IsDirty 
         {
             get 
             {
                 return false;
             }
             set 
             {
             }
         }        IWorkbenchWindow workbenchWindow;
         public override IWorkbenchWindow WorkbenchWindow 
         {
             get 
             {
                 return workbenchWindow;
             }
             set 
             {
                 workbenchWindow = value;
                 workbenchWindow.Title = "AddInTreeView";
             }
         }        public AddinTreeViewContent()
         {
             TitleName = "AddinTree View";
         }
                 public override bool IsViewOnly 
         {
             get 
             {
                 return true;
             }
         }
         public void SaveFile(){}
         public void Undo(){}
         public void Redo(){}
         public override void Save(){}
         public override void Save(string filename){}
         public override void Load(string filename)
         {
         }        public override string TabPageText 
         { 
             get 
             {
                 return "AddInTree";
             }
         }    }
 } AddinTreeViewControl.cs
 using System;
 using System.Collections;
 using System.ComponentModel;
 using System.Drawing;
 using System.Data;
 using System.Windows.Forms;using ICSharpCode.SharpDevelop.Gui;
 using ICSharpCode.Core.AddIns;
 using ICSharpCode.Core.AddIns.Codons;namespace Addins.AddinTreeView
 {
     /** <summary>
     /// AddinTreeViewControl 的摘要说明。
     /// </summary>
     public class AddinTreeViewControl : System.Windows.Forms.UserControl
     {
         private System.Windows.Forms.ColumnHeader chName;
         private System.Windows.Forms.ListView lvAddin;
         private System.Windows.Forms.ColumnHeader chInfo;
         private System.Windows.Forms.CheckBox cbShowAddinInfo;
         private System.Windows.Forms.Splitter splitter2;
         private System.Windows.Forms.ListView lvDebug;
         private System.Windows.Forms.Splitter splitter1;
         private System.Windows.Forms.TreeView tvAddin;
         private System.Windows.Forms.ColumnHeader chValue;
         /** <summary> 
         /// 必需的设计器变量。
         /// </summary>
         private System.ComponentModel.Container components = null;        public AddinTreeViewControl()
         {
             // 该调用是 Windows.Forms 窗体设计器所必需的。
             InitializeComponent();            // TODO: 在 InitializeComponent 调用后添加任何初始化
             InitAddinTreeView();
         }        /** <summary> 
         /// 清理所有正在使用的资源。
         /// </summary>
         protected override void Dispose( bool disposing )
         {
             if( disposing )
             {
                 if(components != null)
                 {
                     components.Dispose();
                 }
             }
             base.Dispose( disposing );
         }        组件设计器生成的代码#region 组件设计器生成的代码
         /** <summary> 
         /// 设计器支持所需的方法 - 不要使用代码编辑器 
         /// 修改此方法的内容。
         /// </summary>
         private void InitializeComponent()
         {
             this.chName = new System.Windows.Forms.ColumnHeader();
             this.lvAddin = new System.Windows.Forms.ListView();
             this.chValue = new System.Windows.Forms.ColumnHeader();
             this.chInfo = new System.Windows.Forms.ColumnHeader();
             this.cbShowAddinInfo = new System.Windows.Forms.CheckBox();
             this.splitter2 = new System.Windows.Forms.Splitter();
             this.lvDebug = new System.Windows.Forms.ListView();
             this.splitter1 = new System.Windows.Forms.Splitter();
             this.tvAddin = new System.Windows.Forms.TreeView();
             this.SuspendLayout();
             // 
             // chName
             // 
             this.chName.Text = "属性";
             this.chName.Width = 217;
             // 
             // lvAddin
             // 
             this.lvAddin.Columns.AddRange(new System.Windows.Forms.ColumnHeader[] {
                                                                                       this.chName,
                                                                                       this.chValue});
             this.lvAddin.Dock = System.Windows.Forms.DockStyle.Fill;
             this.lvAddin.FullRowSelect = true;
             this.lvAddin.GridLines = true;
             this.lvAddin.HoverSelection = true;
             this.lvAddin.Location = new System.Drawing.Point(443, 24);
             this.lvAddin.MultiSelect = false;
             this.lvAddin.Name = "lvAddin";
             this.lvAddin.Size = new System.Drawing.Size(661, 509);
             this.lvAddin.TabIndex = 13;
             this.lvAddin.View = System.Windows.Forms.View.Details;
             // 
             // chValue
             // 
             this.chValue.Text = "值";
             this.chValue.Width = 668;
             // 
             // chInfo
             // 
             this.chInfo.Text = "Info";
             this.chInfo.Width = 673;
             // 
             // cbShowAddinInfo
             // 
             this.cbShowAddinInfo.Dock = System.Windows.Forms.DockStyle.Top;
             this.cbShowAddinInfo.Location = new System.Drawing.Point(443, 0);
             this.cbShowAddinInfo.Name = "cbShowAddinInfo";
             this.cbShowAddinInfo.Size = new System.Drawing.Size(661, 24);
             this.cbShowAddinInfo.TabIndex = 12;
             this.cbShowAddinInfo.Text = "显示Codon隶属的Addin信息";
             // 
             // splitter2
             // 
             this.splitter2.Dock = System.Windows.Forms.DockStyle.Bottom;
             this.splitter2.Location = new System.Drawing.Point(443, 533);
             this.splitter2.Name = "splitter2";
             this.splitter2.Size = new System.Drawing.Size(661, 3);
             this.splitter2.TabIndex = 11;
             this.splitter2.TabStop = false;
             this.splitter2.Visible = false;
             // 
             // lvDebug
             // 
             this.lvDebug.Columns.AddRange(new System.Windows.Forms.ColumnHeader[] {
                                                                                       this.chInfo});
             this.lvDebug.Dock = System.Windows.Forms.DockStyle.Bottom;
             this.lvDebug.Location = new System.Drawing.Point(443, 536);
             this.lvDebug.Name = "lvDebug";
             this.lvDebug.Size = new System.Drawing.Size(661, 216);
             this.lvDebug.TabIndex = 10;
             this.lvDebug.View = System.Windows.Forms.View.Details;
             this.lvDebug.Visible = false;
             // 
             // splitter1
             // 
             this.splitter1.Location = new System.Drawing.Point(440, 0);
             this.splitter1.Name = "splitter1";
             this.splitter1.Size = new System.Drawing.Size(3, 752);
             this.splitter1.TabIndex = 9;
             this.splitter1.TabStop = false;
             // 
             // tvAddin
             // 
             this.tvAddin.Dock = System.Windows.Forms.DockStyle.Left;
             this.tvAddin.FullRowSelect = true;
             this.tvAddin.HideSelection = false;
             this.tvAddin.ImageIndex = -1;
             this.tvAddin.Location = new System.Drawing.Point(0, 0);
             this.tvAddin.Name = "tvAddin";
             this.tvAddin.SelectedImageIndex = -1;
             this.tvAddin.Size = new System.Drawing.Size(440, 752);
             this.tvAddin.TabIndex = 8;
             this.tvAddin.AfterSelect += new System.Windows.Forms.TreeViewEventHandler(this.tvAddin_AfterSelect);
             // 
             // AddinTreeViewControl
             // 
             this.Controls.Add(this.lvAddin);
             this.Controls.Add(this.cbShowAddinInfo);
             this.Controls.Add(this.splitter2);
             this.Controls.Add(this.lvDebug);
             this.Controls.Add(this.splitter1);
             this.Controls.Add(this.tvAddin);
             this.Name = "AddinTreeViewControl";
             this.Size = new System.Drawing.Size(1104, 752);
             this.ResumeLayout(false);        }
         #endregion         void InitAddinTreeView()
         {
             TreeNode pathNode = tvAddin.Nodes.Add("AddinRoot");
             
             tvAddin.BeginUpdate();
             try
             {
                 foreach ( AddIn addIn in AddInTreeSingleton.AddInTree.AddIns)
                 {
                     foreach ( ICSharpCode.Core.AddIns.AddIn.Extension e in addIn.Extensions)
                     {
                         string [] paths = e.Path.Split('/');
                         pathNode = tvAddin.Nodes[0];
                         
                         for ( int i=0; i<paths.Length; i++)
                         {    
                             bool foundPath = false;
                             
                             if ( paths[i] == "" ) 
                             {
                                 pathNode = tvAddin.Nodes[0];
                                 continue;
                             }                        
                                     
                             for ( int j=0; j<pathNode.Nodes.Count; j++)
                             {
                                 if ( pathNode.Nodes[j].Text == paths[i] )
                                 {
                                     pathNode = pathNode.Nodes[j];
                                     foundPath = true;
                                     break;
                                 }
                             }
                             
                             if ( !foundPath )
                             {
                                 pathNode = pathNode.Nodes.Add( paths[i] );
                                 pathNode.Tag = new ArrayList();
                                 //lvDebug.Items.Add("Add " + e.Path + " ---- " + paths[i]);
                             }
                         }
                         
                         (pathNode.Tag as ArrayList).Add(e);
                     }
                 }
             }
             finally
             {
                 tvAddin.EndUpdate();
             }
         }        void AddInfo(string Name, string Value)
         {
             lvAddin.Items.Add(Name).SubItems.Add(Value);
         }        private void tvAddin_AfterSelect(object sender, System.Windows.Forms.TreeViewEventArgs e)
         {
             lvAddin.Items.Clear();
             
             if ( e.Node.Tag != null )
             {
                 foreach (AddIn.Extension et in (e.Node.Tag as ArrayList))
                 {
                     AddInfo("Extension", et.ToString());                    foreach ( ICodon codon in et.CodonCollection)
                     {
                         AddInfo("  ┏ Codon ID", codon.ID);
                         AddInfo("  ┣ Codon Name", codon.Name);
                         AddInfo("  ┗ Codon Class", codon.Class);
                         
                         if ( cbShowAddinInfo.Checked )
                         {
                             AddInfo("      ┣ Addin Name", codon.AddIn.Name);
                             AddInfo("      ┗ Addin FileName", codon.AddIn.FileName);
                         
                             foreach ( ICSharpCode.Core.AddIns.AddIn.Extension ex in codon.AddIn.Extensions)
                             {
                                 AddInfo("          ┣ Addin Extensions", ex.Path);
                             }
                             AddInfo("          ┗━━━━━━━━━", "");
                         }
                     }
                 }
             }
         }
     }
 }