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

📄 resourceclipboardhandler.cs

📁 CSharpDevelop:这是一个包含源代码的C#、VB.NET的编辑器。
💻 CS
字号:
// ResourceClipboardHandler.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.Windows.Forms;

using SharpDevelop.Gui.Edit;
	
namespace ResEdit {
	
	class ResourceClipboardHandler : ISdClipboardHandable
	{
		ResourceEdit resourceedit;
		
		public ResourceClipboardHandler(ResourceEdit resourceedit)
		{
			this.resourceedit = resourceedit;
		}
		
		public void Cut(object sender, EventArgs e)
		{
			if (resourceedit.WriteProtected || resourceedit.SelectedItems.Count < 1) 
				return;
			
			Hashtable tmphash = new Hashtable();
			foreach (ListViewItem item in resourceedit.SelectedItems) {
				tmphash.Add(item.Text, resourceedit.Resources[item.Text]);
				resourceedit.Resources.Remove(item.Text);
			}
			resourceedit.InitializeListView();
			Clipboard.SetDataObject(tmphash);
		}
		
		public void Copy(object sender, EventArgs e)
		{
			if (resourceedit.SelectedItems.Count < 1) 
				return;
			
			Hashtable tmphash = new Hashtable();
			foreach (ListViewItem item in resourceedit.SelectedItems) 
				tmphash.Add(item.Text, ((ICloneable)resourceedit.Resources[item.Text]).Clone()); // copy a clone to clipboard
			
			Clipboard.SetDataObject(tmphash);
		}
		
		public void Paste(object sender, EventArgs e)
		{
			if (resourceedit.WriteProtected)
				return;
			IDataObject dob = Clipboard.GetDataObject();
			if (dob.GetDataPresent(typeof(Hashtable).FullName)) {
				Hashtable tmphash = (Hashtable)dob.GetData(typeof(Hashtable));
				foreach (DictionaryEntry entry in tmphash) {
					if (!resourceedit.Resources.ContainsKey(entry.Key)) {
						resourceedit.Resources.Add(entry.Key, ((ICloneable)entry.Value).Clone()); // paste a clone in resources
					}
				}
				resourceedit.InitializeListView();
			}
		}
		
		public void Delete(object sender, EventArgs e)
		{
			if (resourceedit.WriteProtected)
				return;
			foreach (ListViewItem item in resourceedit.SelectedItems)
				if (item.Text != null) {
					resourceedit.Resources.Remove(item.Text);
				}
			resourceedit.InitializeListView();
		}
		
		public void SelectAll(object sender, EventArgs e)
		{/* TODO TODO
			foreach (ListViewItem i in Items)
				SelectedItems.Add(i);*/
		}
	}
}

⌨️ 快捷键说明

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