diff --git a/TextLocator/App.xaml.cs b/TextLocator/App.xaml.cs
index 229acfd4dec32aae9d5a16ec208fab7d17da80e4..345fbf2406974a636dfa8224ce957ac393114a3c 100644
--- a/TextLocator/App.xaml.cs
+++ b/TextLocator/App.xaml.cs
@@ -25,23 +25,21 @@ namespace TextLocator
try
{
// Word服务
- FileInfoServiceFactory.Register(FileType.Word类型, new WordFileService());
+ FileInfoServiceFactory.Register(FileType.Word文档, new WordFileService());
// Excel服务
- FileInfoServiceFactory.Register(FileType.Excel类型, new ExcelFileService());
+ FileInfoServiceFactory.Register(FileType.Excel表格, new ExcelFileService());
// PowerPoint服务
- FileInfoServiceFactory.Register(FileType.PowerPoint类型, new PowerPointFileService());
+ FileInfoServiceFactory.Register(FileType.PPT演示文稿, new PowerPointFileService());
// PDF服务
- FileInfoServiceFactory.Register(FileType.PDF类型, new PdfFileService());
+ FileInfoServiceFactory.Register(FileType.PDF文档, new PdfFileService());
// HTML或XML服务
- FileInfoServiceFactory.Register(FileType.HTML和XML类型, new XmlFileService());
+ FileInfoServiceFactory.Register(FileType.HTML和XML, new XmlFileService());
// 常用图片服务
FileInfoServiceFactory.Register(FileType.常用图片, new NoTextFileService());
// 程序员服务
FileInfoServiceFactory.Register(FileType.代码文件, new DevelopFileService());
// 纯文本服务
- FileInfoServiceFactory.Register(FileType.纯文本, new TxtFileService());
- // 其他类型服务
- FileInfoServiceFactory.Register(FileType.其他类型, new NoTextFileService());
+ FileInfoServiceFactory.Register(FileType.文本文件, new TxtFileService());
}
catch (Exception ex)
{
diff --git a/TextLocator/Enums/FileType.cs b/TextLocator/Enums/FileType.cs
index 73ed1eb5ffcc62d3a05f04cd535a5f66c874e4b7..fa7bf2de87cd75fdd9cba7d53d711fc14c6d5de6 100644
--- a/TextLocator/Enums/FileType.cs
+++ b/TextLocator/Enums/FileType.cs
@@ -11,27 +11,27 @@ namespace TextLocator.Enums
/// Word
///
[Description("doc,docx")]
- Word类型,
+ Word文档,
///
/// Excel
///
[Description("xls,xlsx")]
- Excel类型,
+ Excel表格,
///
/// PowerPoint
///
[Description("ppt,pptx")]
- PowerPoint类型,
+ PPT演示文稿,
///
/// PDF
///
[Description("pdf")]
- PDF类型,
+ PDF文档,
///
/// XML和html
///
[Description("html,xml")]
- HTML和XML类型,
+ HTML和XML,
///
/// 常用图片
///
@@ -46,11 +46,6 @@ namespace TextLocator.Enums
/// 纯文本
///
[Description("txt")]
- 纯文本,
- ///
- /// 其他类型
- ///
- [Description()]
- 其他类型
+ 文本文件
}
}
diff --git a/TextLocator/MainWindow.xaml b/TextLocator/MainWindow.xaml
index 044f8bb704d05d8be8e7a47a0655c29844986ee7..54a11eb2c446413f698297fe5d8b0b39e1e3890b 100644
--- a/TextLocator/MainWindow.xaml
+++ b/TextLocator/MainWindow.xaml
@@ -71,15 +71,27 @@
-
+
-
+
+
+
+
+
+
+
+
+
+
+
+
+
-
-
+
+
-
+
diff --git a/TextLocator/MainWindow.xaml.cs b/TextLocator/MainWindow.xaml.cs
index b56e94e34f3ca9ccc53a463ff33a2092062f2412..97143fc88933b0f1de7389649246655a78be9491 100644
--- a/TextLocator/MainWindow.xaml.cs
+++ b/TextLocator/MainWindow.xaml.cs
@@ -7,6 +7,7 @@ using System.Linq;
using System.Threading;
using System.Threading.Tasks;
using System.Windows;
+using System.Windows.Controls;
using System.Windows.Input;
using System.Windows.Media;
using System.Windows.Media.Imaging;
@@ -70,25 +71,26 @@ namespace TextLocator
// 文件类型筛选下拉框数据初始化
this.FileTypeFilter.Items.Clear();
this.FileTypeFilter.Items.Add("全部");
-
- // 文件类型名字
- string fileTypeNames = "";
+ this.FileTypeNames.Children.Clear();
// 获取文件类型枚举,遍历并加入下拉列表
- foreach (string fileTypeName in FileTypeUtil.GetFileTypeNames())
+ foreach (FileType fileType in Enum.GetValues(typeof(FileType)))
{
- this.FileTypeFilter.Items.Add(fileTypeName);
- fileTypeNames += fileTypeName + ",";
+ this.FileTypeFilter.Items.Add(fileType.ToString());
+
+ // 标签
+ Button ft = new Button()
+ {
+ Content = fileType.ToString(),
+ Height = 25,
+ Margin = new Thickness(this.FileTypeNames.Children.Count == 0 ? 0 : 2, 0, 0, 0),
+ ToolTip = fileType.GetDescription(),
+ Background = Brushes.Gray
+ };
+ this.FileTypeNames.Children.Add(ft);
}
// 默认选中全部
this.FileTypeFilter.SelectedIndex = 0;
-
-
- // 初始化文件后缀
- // 去掉最后的逗号
- fileTypeNames = fileTypeNames.Substring(0, fileTypeNames.Length - 1);
- this.FileTypeNames.Text = fileTypeNames;
- this.FileTypeNames.ToolTip = FileTypeUtil.GetFileTypeExts();
}
///
diff --git a/TextLocator/Util/FileTypeUtil.cs b/TextLocator/Util/FileTypeUtil.cs
index 3a065f13c1c8039e7804b1926ed609f2235717ed..03e2c9bce58ffd64f23612879cdefe25140922a4 100644
--- a/TextLocator/Util/FileTypeUtil.cs
+++ b/TextLocator/Util/FileTypeUtil.cs
@@ -22,7 +22,7 @@ namespace TextLocator.Util
public static FileType GetFileType(string filePath)
{
// 默认为其他类型文件
- FileType fileType = FileType.其他类型;
+ FileType fileType = FileType.文本文件;
// 判断文件路径
if (string.IsNullOrEmpty(filePath))
@@ -54,26 +54,6 @@ namespace TextLocator.Util
return fileType;
}
- ///
- /// 获取文件类型列表(Word类型,Excel类型...)
- ///
- ///
- public static List GetFileTypeNames()
- {
- List fileTypes = new List();
- // 遍历文件类型,根据后缀查找文件类型
- foreach (FileType ft in Enum.GetValues(typeof(FileType)))
- {
- // 获取描述
- string fileTypeName = ft.ToString();
- if (!fileTypeName.Equals("其他类型"))
- {
- fileTypes.Add(fileTypeName);
- }
- }
- return fileTypes;
- }
-
///
/// 文件类型后缀列表(ext1,ext2...)
///
diff --git a/TextLocator/Util/FileUtil.cs b/TextLocator/Util/FileUtil.cs
index 03003aae1ae030d70d6f8b6a0b4a66d39ba54714..b419d3351e6677cd8044775929f1e3194b6eda0e 100644
--- a/TextLocator/Util/FileUtil.cs
+++ b/TextLocator/Util/FileUtil.cs
@@ -29,19 +29,19 @@ namespace TextLocator.Util
Bitmap bitmap = null;
switch (fileType)
{
- case FileType.Word类型:
+ case FileType.Word文档:
bitmap = Properties.Resources.word;
break;
- case FileType.Excel类型:
+ case FileType.Excel表格:
bitmap = Properties.Resources.excel;
break;
- case FileType.PowerPoint类型:
+ case FileType.PPT演示文稿:
bitmap = Properties.Resources.ppt;
break;
- case FileType.PDF类型:
+ case FileType.PDF文档:
bitmap = Properties.Resources.pdf;
break;
- case FileType.HTML和XML类型:
+ case FileType.HTML和XML:
bitmap = Properties.Resources.html;
break;
case FileType.常用图片:
@@ -50,7 +50,7 @@ namespace TextLocator.Util
case FileType.代码文件:
bitmap = Properties.Resources.code;
break;
- case FileType.纯文本:
+ case FileType.文本文件:
bitmap = Properties.Resources.txt;
break;
default: