📄 filetemplate.cs
字号:
// FileTemplate.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.Xml;
using System.Collections;
using System.Diagnostics;
using System.Windows.Forms;
using SharpDevelop.Tool.Function;
namespace SharpDevelop.Internal.Templates {
/// <summary>
/// This class defines & holds the new file templates.
/// </summary>
public class FileTemplate
{
public static ArrayList FileTemplates = new ArrayList();
string originator = null;
string created = null;
string lastmodified = null;
string name = null;
string category = null;
string languagename = null;
string description = null;
string icon = null;
ArrayList files = new ArrayList(); // contains FileDescriptionTemplate classes
XmlElement fileoptions = null;
public string Originator {
get {
return originator;
}
}
public string Created {
get {
return created;
}
}
public string LastModified {
get {
return lastmodified;
}
}
public string Name {
get {
return name;
}
}
public string Category {
get {
return category;
}
}
public string LanguageName {
get {
return languagename;
}
}
public string Description {
get {
return description;
}
}
public string Icon {
get {
return icon;
}
}
public XmlElement FileOptions {
get {
return fileoptions;
}
}
public ArrayList Files {
get {
return files;
}
}
public FileTemplate(string filename)
{
XmlDocument doc = new XmlDocument();
doc.Load(filename);
XmlElement config = doc.DocumentElement["TemplateConfiguration"];
originator = doc.DocumentElement.Attributes["Originator"].InnerText;
created = doc.DocumentElement.Attributes["Created"].InnerText;
lastmodified = doc.DocumentElement.Attributes["LastModified"].InnerText;
name = config["Name"].InnerText;
category = config["Category"].InnerText;
languagename = config["LanguageName"].InnerText;
if (config["Description"] != null)
description = config["Description"].InnerText;
if (config["Icon"] != null)
icon = config["Icon"].InnerText;
fileoptions = doc.DocumentElement["FileOptions"];
// load the files
XmlElement files = doc.DocumentElement["TemplateFiles"];
XmlNodeList nodes = files.ChildNodes;
foreach (XmlElement filenode in nodes) {
FileDescriptionTemplate template = new FileDescriptionTemplate(filenode.Attributes["DefaultName"].InnerText + filenode.Attributes["DefaultExtension"].InnerText, filenode.InnerText);
this.files.Add(template);
}
}
static void LoadFileTemplate(string filename)
{
FileTemplates.Add(new FileTemplate(filename));
}
public static void LoadFileTemplates()
{
FileUtility.SearchDirectory(Application.StartupPath + "\\templates\\file", "*.xml", new FileSearchDelegate(LoadFileTemplate));
}
}
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -