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

📄 resource.cs

📁 CSharpDevelop:这是一个包含源代码的C#、VB.NET的编辑器。
💻 CS
字号:
// Resource.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.IO;
using System.Windows.Forms;
using System.Collections;
using System.Threading;
using System.Resources;
using System.Drawing;
using System.Diagnostics;
using System.Reflection;
using System.Xml;

namespace SharpDevelop.Tool.Data {
	
	/// <summary>
	/// This Class contains two common ResourceManagers, which are
	/// used in many cases.
	/// </summary>
	public class Resource
	{
		static ResourceManager strings = null;
		static ResourceManager icon    = null;
		
		static Hashtable       localstrings = null;
		static Hashtable       localicons   = null;
		
		static Resource() 
		{
			strings = new ResourceManager("StringResources", Assembly.GetCallingAssembly());
			icon    = new ResourceManager("IconResources",   Assembly.GetCallingAssembly());
			string language  = Option.GetProperty("SharpDevelop.Gui.UILanguage", Thread.CurrentThread.CurrentUICulture.Name).ToString();
				
			localstrings = Load("StringResources", language);
			if (localstrings == null && language.IndexOf('-') > 0)
				localstrings = Load("StringResources", language.Split(new char[] {'-'})[0]);
			
			localicons = Load("IconResources", language);
			if (localicons == null && language.IndexOf('-') > 0)
				localicons = Load("IconResources", language.Split(new char[] {'-'})[0]);
		}
		
		static Hashtable Load(string name, string language)
		{
			string fname = Application.StartupPath + "\\resources\\" + name + "." + language + ".resources";
			if (File.Exists(fname)) {
					Hashtable resources = new Hashtable();
					ResourceReader rr = new ResourceReader(fname);
					foreach (DictionaryEntry entry in rr) {
						resources.Add(entry.Key, entry.Value);
					}
					rr.Close();
					return resources;
			} 
			return null;
		}
		
		public static string GetString(string name)
		{
			if (localstrings != null && localstrings[name] != null)
				return localstrings[name].ToString();
			return strings.GetString(name);
		}
		
		public static Icon GetIcon(string name)
		{
			object iconobj = null;
			if (localicons != null && localicons[name] != null) {
				iconobj = localicons[name];
			} else
				iconobj = icon.GetObject(name);
			
			if (iconobj is Icon)
				return (Icon)iconobj;
			else 
				return Icon.FromHandle(((Bitmap)iconobj).GetHicon());
		}
		
		public static Bitmap GetBitmap(string name)
		{
			if (localicons != null && localicons[name] != null)
				return (Bitmap)localicons[name];
			return (Bitmap)icon.GetObject(name);
		}
		
//		/// <returns>ResourceManager != null</returns>
//		public static ResourceManager Strings {
//			get {
//				Debug.Assert(strings != null, "SharpDevelop.Tool.Data.Resources : ResourceManager strings == null");
//				return strings;
//			}
//		}
//		/// <returns>ResourceManager != null</returns>
//		public static ResourceManager Icon {
//			get {
//				Debug.Assert(icon != null, "SharpDevelop.Tool.Data.Resources : ResourceManager icon   == null");
//				return icon;
//			}
//		}
		
//		public static XmlDocument StringToXmlDocument(string str)
//		{
//			XmlDocument document = new XmlDocument();
//			document.LoadXml(str);
//			return document;
//		}

		
	}
}

⌨️ 快捷键说明

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