分享
 
 
 

SharpDevelop的AddInTree View 插件

王朝other·作者佚名  2006-01-09
窄屏简体版  字體: |||超大  

自从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(" ┗━━━━━━━━━", "");

}

}

}

}

}

}

}

 
 
 
免责声明:本文为网络用户发布,其观点仅代表作者个人观点,与本站无关,本站仅提供信息存储服务。文中陈述内容未经本站证实,其真实性、完整性、及时性本站不作任何保证或承诺,请读者仅作参考,并请自行核实相关内容。
2023年上半年GDP全球前十五强
 百态   2023-10-24
美众议院议长启动对拜登的弹劾调查
 百态   2023-09-13
上海、济南、武汉等多地出现不明坠落物
 探索   2023-09-06
印度或要将国名改为“巴拉特”
 百态   2023-09-06
男子为女友送行,买票不登机被捕
 百态   2023-08-20
手机地震预警功能怎么开?
 干货   2023-08-06
女子4年卖2套房花700多万做美容:不但没变美脸,面部还出现变形
 百态   2023-08-04
住户一楼被水淹 还冲来8头猪
 百态   2023-07-31
女子体内爬出大量瓜子状活虫
 百态   2023-07-25
地球连续35年收到神秘规律性信号,网友:不要回答!
 探索   2023-07-21
全球镓价格本周大涨27%
 探索   2023-07-09
钱都流向了那些不缺钱的人,苦都留给了能吃苦的人
 探索   2023-07-02
倩女手游刀客魅者强控制(强混乱强眩晕强睡眠)和对应控制抗性的关系
 百态   2020-08-20
美国5月9日最新疫情:美国确诊人数突破131万
 百态   2020-05-09
荷兰政府宣布将集体辞职
 干货   2020-04-30
倩女幽魂手游师徒任务情义春秋猜成语答案逍遥观:鹏程万里
 干货   2019-11-12
倩女幽魂手游师徒任务情义春秋猜成语答案神机营:射石饮羽
 干货   2019-11-12
倩女幽魂手游师徒任务情义春秋猜成语答案昆仑山:拔刀相助
 干货   2019-11-12
倩女幽魂手游师徒任务情义春秋猜成语答案天工阁:鬼斧神工
 干货   2019-11-12
倩女幽魂手游师徒任务情义春秋猜成语答案丝路古道:单枪匹马
 干货   2019-11-12
倩女幽魂手游师徒任务情义春秋猜成语答案镇郊荒野:与虎谋皮
 干货   2019-11-12
倩女幽魂手游师徒任务情义春秋猜成语答案镇郊荒野:李代桃僵
 干货   2019-11-12
倩女幽魂手游师徒任务情义春秋猜成语答案镇郊荒野:指鹿为马
 干货   2019-11-12
倩女幽魂手游师徒任务情义春秋猜成语答案金陵:小鸟依人
 干货   2019-11-12
倩女幽魂手游师徒任务情义春秋猜成语答案金陵:千金买邻
 干货   2019-11-12
 
推荐阅读
 
 
 
>>返回首頁<<
 
靜靜地坐在廢墟上,四周的荒凉一望無際,忽然覺得,淒涼也很美
© 2005- 王朝網路 版權所有