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

📄 module.cs

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

namespace SharpDevelop.Internal.Modules {
	
	public class Module
	{
		string name        = null;
		string version     = null;
		string author      = null;
		string copyright   = null;
		string url         = null;
		string description = null;
		string language    = null;
		
		string[] extensions = null;
		
		ISdDisplayModule  displaymodule  = null;
		ISdLanguageModule languagemodule = null;
		
		Bitmap    projecticon = null;
		Hashtable fileicons   = new Hashtable();
		Hashtable icons       = new Hashtable();
		
		public string Name {
			get {
				return name; 
			}
		}
		public string Version {
			get {
				return version;
			}
		}
		public string Author {
			get {
				return author;
			}
		}
		public string Copyright {
			get {
				return copyright;
			}
		}
		public string Url {
			get {
				return url;
			}
		}
		public string Description {
			get {
				return description; 
			}
		}
		public string Language {
			get {
				return language; 
			}
		}
		public string[] Extensions {
			get {
				return extensions;
			}
		}
		public ISdDisplayModule DisplayModule {
			get {
				return displaymodule;
			}
		}
		public ISdLanguageModule LanguageModule {
			get {
				return languagemodule;
			}
		}
		
		public Hashtable Icons {
			get {
				return icons;
			}
		}
		public Hashtable FileIcons {
			get {
				return fileicons;
			}
		}
		public Bitmap ProjectIcon {
			get {
				return projecticon;
			}
		}
		
		Bitmap LoadIcon(string path, string locationname)
		{
			if (File.Exists(path + locationname)) {
				return new Bitmap(path + locationname);
			} else {
				string[] location = locationname.Split(new char[] {':'});
				Assembly assembly  = Assembly.LoadFrom(path + location[0]);
				ResourceManager resources = new ResourceManager(location[1], assembly);
				return (Bitmap)resources.GetObject(location[2]);
			}
		}
		
		public Module(string filename)
		{      
			string path     = Path.GetDirectoryName(filename) + "\\";
			XmlDocument doc = new XmlDocument(); 
			doc.Load(filename);
			
			XmlElement moduledescription = doc.DocumentElement["Module"];
			
			name        = moduledescription.Attributes["Name"].InnerText;
			version     = moduledescription.Attributes["Version"].InnerText;
			
			extensions  = moduledescription["Extensions"].InnerText.Split(new char[] {'|'});
			for (int i = 0; i < extensions.Length; ++i) 
				extensions[i] = extensions[i].ToUpper();
			
			language    = moduledescription["Language"].InnerText;
			author      = moduledescription["Author"].InnerText;
			copyright   = moduledescription["Copyright"].InnerText;
			url         = moduledescription["Url"].InnerText;
			description = moduledescription["Description"].InnerText;
			
			if (doc.DocumentElement["LanguageModule"] != null) {
				Assembly assembly  = Assembly.LoadFrom(path + doc.DocumentElement["LanguageModule"].Attributes["Assembly"].InnerText);
				languagemodule = (ISdLanguageModule)assembly.CreateInstance(doc.DocumentElement["LanguageModule"].Attributes["Class"].InnerText);
				if (languagemodule == null)
					throw new Exception("Can't create instance of LanguageModule for " + language + " (" + filename + ")");
			}
			
			if (doc.DocumentElement["DisplayModule"] != null) {
				Assembly assembly  = Assembly.LoadFrom(path + doc.DocumentElement["DisplayModule"].Attributes["Assembly"].InnerText);
				displaymodule = (ISdDisplayModule)assembly.CreateInstance(doc.DocumentElement["DisplayModule"].Attributes["Class"].InnerText);
				if (displaymodule == null)
					throw new Exception("Can't create instance of DisplayModule for " + language + " (" + filename + ")");
			}
			
			if (doc.DocumentElement["Icons"] != null) {
				XmlNodeList nodes = doc.DocumentElement["Icons"].ChildNodes;
				foreach (XmlElement iconnode in nodes) {
					switch (iconnode.Name) {
						case "ProjectIcon":
							projecticon = LoadIcon(path, iconnode.Attributes["Location"].InnerText);
							break;
						case "FileIcon":
							fileicons[iconnode.Attributes["Extension"].InnerText] = LoadIcon(path, iconnode.Attributes["Location"].InnerText);
							break;
						case "Icon":
							icons[iconnode.Attributes["Name"].InnerText] = LoadIcon(path, iconnode.Attributes["Location"].InnerText);
							break;
					}
				}
			}
		}
	}
}

⌨️ 快捷键说明

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