⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 reflectionsearchpanel.cs

📁 CSharpDevelop:这是一个包含源代码的C#、VB.NET的编辑器。
💻 CS
字号:
//  ReflectionSearchPanel.cs
//  Copyright (C) 2001 Mike Krueger
//
//  This program is free software; you can redistribute it and/or modify
//  it under the terms of the GNU General Public License as published by
//  the Free Software Foundation; either version 2 of the License, or
//  (at your option) any later version.
//
//  This program is distributed in the hope that it will be useful,
//  but WITHOUT ANY WARRANTY; without even the implied warranty of
//  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
//  GNU General Public License for more details.
//
//  You should have received a copy of the GNU General Public License
//  along with this program; if not, write to the Free Software
//  Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA

using System;
using System.Collections;
using System.IO;
using System.Drawing;
using System.Drawing.Printing;
using System.Windows.Forms;
using System.Reflection;
using System.Threading;
using System.Resources;
using System.Reflection.Emit;

using SharpDevelop.Gui.Edit;
using SharpDevelop.Internal.Undo;
using SharpDevelop.Gui.Window;


namespace SharpDevelop.Gui.Edit.Reflection {
	
	public class ReflectionSearchPanel : UserControl
	{
		System.Windows.Forms.Label     searchfor       = new System.Windows.Forms.Label();
		
		TextBox   searchstringbox = new TextBox();
		ListView  itemsfound      = new ListView();
		Button    button = new Button();
		ReflectionTree tree;
		
		public ReflectionSearchPanel(ReflectionTree tree)
		{
			Dock = DockStyle.Fill;
			
			this.tree = tree;
			
			searchfor.Text     = "Search for:";
			searchfor.Location = new Point(0, 4);
			searchfor.Width    = 100;
			searchfor.Height   = 10;
			searchfor.Anchor   = AnchorStyles.Top | AnchorStyles.Left;
			
			searchstringbox.Location = new Point(0, 12 + 5);
			searchstringbox.AcceptsReturn = true;
			searchstringbox.Width    = Width;
			searchstringbox.Height   = 30;
			searchstringbox.Anchor   = AnchorStyles.Top | AnchorStyles.Left | AnchorStyles.Right;
			
			itemsfound.Location = new Point(0, 10 + 30);
			itemsfound.Width    = Width;
			itemsfound.FullRowSelect = true;
			itemsfound.MultiSelect = false;
			itemsfound.Height   = Height - 70;
			itemsfound.Anchor   = AnchorStyles.Top | AnchorStyles.Left | AnchorStyles.Right | AnchorStyles.Bottom;
			itemsfound.View     = View.Details;
			itemsfound.Columns.Add("Type",      100, HorizontalAlignment.Left);
			itemsfound.Columns.Add("Namespace", 150, HorizontalAlignment.Left);
			itemsfound.Columns.Add("Assembly",  100, HorizontalAlignment.Left);
			itemsfound.DoubleClick += new EventHandler(SelectItem);
			itemsfound.SmallImageList = tree.ImageList;
			button.Size = new Size(16,16);
			
			button.Click += new EventHandler(Showtypes);
			Controls.Add(button);
			Controls.Add(searchfor);
			Controls.Add(searchstringbox);
			Controls.Add(itemsfound);
			
		}
		
		void SelectItem(object sender, EventArgs e)
		{
			if (itemsfound.SelectedItems.Count != 1)
				return;
			TypeItem item = (TypeItem)itemsfound.SelectedItems[0];
			tree.GoTo(item.type);
			
		}
		class TypeItem : ListViewItem {
			public Type type;
			public TypeItem(Type type) : base ( new string[] { type.Name, type.Namespace, Path.GetFileName(type.Assembly.CodeBase)})
			{
				this.type = type;
			}
		}
		void Showtypes(object sender, EventArgs e)
		{
			itemsfound.Items.Clear();
			foreach (Assembly asm in tree.Assemblies) {
				Type[] types = asm.GetTypes();
				foreach (Type type in types) {
					if (type.Name.StartsWith(searchstringbox.Text)) {
						itemsfound.Items.Add(new TypeItem(type));
					}
				}
			}
		}
	}
}

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -