📄 fileutility.cs
字号:
// FSTypeUtility.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.Runtime.InteropServices;
using System.Collections;
using System.Drawing;
using System.Reflection;
using System.Resources;
using System.Diagnostics;
using System.Windows.Forms;
using SharpDevelop.Internal.Modules;
using SharpDevelop.Tool.Data;
namespace SharpDevelop.Tool.Function {
public delegate void FileSearchDelegate(string filename);
public class FileUtility
{
static ImageList imagelist = new ImageList();
static Hashtable hashtable = new Hashtable();
public static string MakeRelative(string what, string path)
{
if (what.Length >= path.Length && what.Substring(0, path.Length) == path)
what = what.Substring(path.Length);
return what;
}
public static string MakeAbsolute(string what, string path)
{
if (what.Length > 0 && what[0] == '\\')
return path + what;
return what;
}
public static void SearchDirectory(string directory, string filemask, FileSearchDelegate fs)
{
string[] file = Directory.GetFiles(directory, filemask);
foreach (string f in file)
fs(f);
string[] dir = Directory.GetDirectories(directory);
foreach (string d in dir)
SearchDirectory(d, filemask, fs);
}
public static ImageList ImageList {
get {
return imagelist;
}
}
static int offset = 0;
static int initalsize = 0;
public static int GetImageIndexFor(string filename)
{
string extension = Path.GetExtension(filename).ToUpper();
if (hashtable[extension] == null) {
return 0;
}
return (int)hashtable[extension];
}
public static Bitmap GetBitmap(string name)
{
if (Resource.GetBitmap("Icons.16x16." + name) != null)
return Resource.GetBitmap("Icons.16x16." + name);
if (Resource.GetBitmap("Icons.32x32." + name) != null)
return Resource.GetBitmap("Icons.32x32." + name);
if (Resource.GetBitmap(name) != null)
return Resource.GetBitmap(name);
foreach (SharpDevelop.Internal.Modules.Module info in ModuleManager.Modules) {
if (info.Icons[name] != null) {
return (Bitmap)info.Icons[name];
}
}
return Resource.GetBitmap("Icons.16x16.MiscFiles");
}
public static void LoadImageList()
{
imagelist = new ImageList();
initalsize = imagelist.Images.Count;
imagelist.Images.Add(Resource.GetBitmap("Icons.16x16.MiscFiles"));
// hashtable[".RESOURCES"] = imagelist.Images.Count;
// hashtable[".RESX"] = imagelist.Images.Count;
// imagelist.Images.Add(Resource.GetBitmap("Icons.16x16.ResourceFileIcon"));
hashtable[".PRJX"] = imagelist.Images.Count;
imagelist.Images.Add(Resource.GetBitmap("Icons.16x16.SolutionIcon"));
offset = imagelist.Images.Count;
foreach (SharpDevelop.Internal.Modules.Module info in ModuleManager.Modules) {
foreach (DictionaryEntry entry in info.FileIcons) {
string name = entry.Key.ToString();
hashtable[name.ToUpper()] = imagelist.Images.Count;
imagelist.Images.Add((Bitmap)entry.Value);
++offset;
}
}
}
public static void DisposeImageList()
{
imagelist.Dispose();
}
}
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -