From 29d4e593fe745fc48dd138dcc0599a9dce634115 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E5=88=98=E7=A3=8A?= Date: Fri, 6 May 2022 14:52:01 +0800 Subject: [PATCH 1/6] =?UTF-8?q?=E7=BB=86=E8=8A=82=E4=BC=98=E5=8C=96?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- TextLocator/FileInfoItem.xaml.cs | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/TextLocator/FileInfoItem.xaml.cs b/TextLocator/FileInfoItem.xaml.cs index 393f99f..8e65c85 100644 --- a/TextLocator/FileInfoItem.xaml.cs +++ b/TextLocator/FileInfoItem.xaml.cs @@ -67,9 +67,9 @@ namespace TextLocator RichTextBoxUtil.Highlighted(this.FileName, Colors.Red, fileInfo.Keywords); } - string filePath = fileInfo.FilePath.Replace(fileInfo.FileName, ""); + string folderPath = fileInfo.FilePath.Substring(0, fileInfo.FilePath.LastIndexOf("\\")); //fileInfo.FilePath.Replace(fileInfo.FileName, ""); // 文件路径 - this.FileFolder.Text = filePath.Length > 70 ? filePath.Substring(0, 70) + "..." : filePath; + this.FileFolder.Text = folderPath.Length > 70 ? folderPath.Substring(0, 70) + "..." : folderPath; // 获取摘要 RichTextBoxUtil.EmptyData(this.ContentBreviary); -- Gitee From b59e7e435e47631e1aa840fa09167a527b9d3dc1 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E5=88=98=E7=A3=8A?= Date: Fri, 13 May 2022 14:56:07 +0800 Subject: [PATCH 2/6] =?UTF-8?q?=E9=83=A8=E5=88=86=E6=95=B0=E6=8D=AE?= =?UTF-8?q?=E7=BB=91=E5=AE=9A=E6=8A=BD=E7=A6=BB?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- TextLocator/App.xaml.cs | 2 - TextLocator/MainWindow.xaml | 17 +- TextLocator/MainWindow.xaml.cs | 258 ++++++++------------ TextLocator/TextLocator.csproj | 4 + TextLocator/ViewModel/Main/MainModel.cs | 57 +++++ TextLocator/ViewModel/Main/MainViewModel.cs | 149 +++++++++++ TextLocator/ViewModel/NotificationObject.cs | 17 ++ 7 files changed, 342 insertions(+), 162 deletions(-) create mode 100644 TextLocator/ViewModel/Main/MainModel.cs create mode 100644 TextLocator/ViewModel/Main/MainViewModel.cs create mode 100644 TextLocator/ViewModel/NotificationObject.cs diff --git a/TextLocator/App.xaml.cs b/TextLocator/App.xaml.cs index 0879bd0..e248e7b 100644 --- a/TextLocator/App.xaml.cs +++ b/TextLocator/App.xaml.cs @@ -1,8 +1,6 @@ using Hardcodet.Wpf.TaskbarNotification; using log4net; using System; -using System.Diagnostics; -using System.Linq; using System.Runtime.InteropServices; using System.Text; using System.Threading; diff --git a/TextLocator/MainWindow.xaml b/TextLocator/MainWindow.xaml index 0346c0a..426ec50 100644 --- a/TextLocator/MainWindow.xaml +++ b/TextLocator/MainWindow.xaml @@ -7,10 +7,9 @@ xmlns:rubyer="clr-namespace:Rubyer;assembly=Rubyer" mc:Ignorable="d" Title="文本搜索定位器" Width="1600" Height="900" Icon="Resource/App.ico" - DataContext="{Binding RelativeSource={RelativeSource Self}}" WindowStartupLocation="CenterScreen" Loaded="Window_Loaded" Closing="Window_Closing" Activated="Window_Activated"> - + @@ -205,12 +204,18 @@ - + + @@ -814,7 +819,7 @@ - + @@ -830,11 +835,11 @@ - - + diff --git a/TextLocator/MainWindow.xaml.cs b/TextLocator/MainWindow.xaml.cs index e4e4133..8baa55d 100644 --- a/TextLocator/MainWindow.xaml.cs +++ b/TextLocator/MainWindow.xaml.cs @@ -23,13 +23,14 @@ using TextLocator.HotKey; using TextLocator.Index; using TextLocator.Message; using TextLocator.Util; +using TextLocator.ViewModel.Main; namespace TextLocator { /// /// MainWindow.xaml 的交互逻辑 /// - public partial class MainWindow : Window, INotifyPropertyChanged + public partial class MainWindow : Window { private static readonly ILog log = LogManager.GetLogger(System.Reflection.MethodBase.GetCurrentMethod().DeclaringType); @@ -59,6 +60,11 @@ namespace TextLocator /// private WindowState _windowState = WindowState.Normal; + /// + /// 数据模型 + /// + private MainViewModel _viewModel = new MainViewModel(); + #region 热键 /// /// 当前窗口句柄 @@ -70,9 +76,11 @@ namespace TextLocator private Dictionary _hotKeySettings = new Dictionary(); #endregion + public MainWindow() { InitializeComponent(); + this.DataContext = _viewModel; } #region 窗口初始化 @@ -397,7 +405,7 @@ namespace TextLocator } #endregion - #region 搜索 + #region 关键词搜索 /// /// 搜索 /// @@ -433,7 +441,7 @@ namespace TextLocator } /// - /// 回车搜索 + /// 关键词文本框回车搜索 /// /// /// @@ -480,6 +488,78 @@ namespace TextLocator SearchTextBorder.BorderBrush = new SolidColorBrush(this.SearchText.Text.Length > 0 ? Colors.Green : (Color)ColorConverter.ConvertFromString("#2196f3")); } + /// + /// 搜索前 + /// + /// 指定页 + private void BeforeSearch(int page = 1) + { + // 1、---- 搜索信息预处理 + // 还原分页count + if (page != _viewModel.PageIndex) + { + _viewModel.PageIndex = page; + // 设置分页标签总条数 + _viewModel.TotalCount = 0; + } + + // 获取搜索关键词列表 + List keywords = GetSearchTextKeywords(); + if (keywords.Count <= 0) + { + return; + } + + + // 2、---- 预览信息还原 + // 预览区打开文件和文件夹标记清空 + OpenFile.Tag = null; + OpenFolder.Tag = null; + + // 预览文件名清空 + PreviewFileName.Text = ""; + + // 预览文件内容清空 + PreviewFileContent.Document.Blocks.Clear(); + + // 预览文件内容分页标记 + SwitchPreviewContentPage.Tag = 0; + SwitchPreviewContentPage.Visibility = Visibility.Collapsed; + + // 预览图标清空 + PreviewImage.Source = null; + + // 预览文件类型图标清空 + PreviewFileTypeIcon.Source = null; + + // 预览切换标记清空 + SwitchPreview.Tag = null; + + + // 3、---- 生成本次搜索时间戳 + _timestamp = Convert.ToInt64((DateTime.Now - new DateTime(1970, 1, 1, 0, 0, 0, 0)).TotalMilliseconds); + + + // 4、---- 构造搜索条件并保存(保存的搜索条件需要用于数据导出) + _searchParam = new Entity.SearchParam() + { + Keywords = keywords, + FileType = (FileType)SearchFileType.Tag, + SortType = (SortType)SortOptions.SelectedValue, + IsPreciseRetrieval = (bool)PreciseRetrieval.IsChecked, + IsMatchWords = (bool)MatchWords.IsChecked, + SearchRegion = (SearchRegion)SearchScope.SelectedValue, + PageSize = _viewModel.PageSize, + PageIndex = _viewModel.PageIndex + }; + + // 5、---- 搜索 + Search( + _timestamp, + _searchParam + ); + } + /// /// 搜索 /// @@ -531,20 +611,11 @@ namespace TextLocator } // 4、---- 显示预览列表分页信息 - Dispatcher.Invoke(new Action(() => - { - this.PreviewPage.Text = string.Format("0/{0}", SearchResultList.Items.Count); - })); + _viewModel.PreviewPage = string.Format("0/{0}", searchResult.Results.Count); // 5、---- 分页总数 - this.Dispatcher.BeginInvoke(new Action(() => - { - // 如果总条数小于等于分页条数,则不显示分页 - this.PageBar.Total = searchResult.Total > PageSize ? searchResult.Total : 0; - - // 上一个和下一个切换面板是否显示 - this.SwitchPreview.Visibility = searchResult.Total > 0 ? Visibility.Visible : Visibility.Hidden; - })); + _viewModel.TotalCount = searchResult.Total; + _viewModel.PreviewSwitchVisibility = searchResult.Total > 0 ? Visibility.Visible : Visibility.Hidden; } catch (Exception ex) { @@ -556,38 +627,7 @@ namespace TextLocator } #endregion - #region 分页 - /// - /// 当前页 - /// - public int PageNow = 1; - /// - /// 实现INotifyPropertyChanged接口 - /// - public event PropertyChangedEventHandler PropertyChanged; - public void OnPropertyChanged(string propertyName) - { - if (this.PropertyChanged != null) - { - this.PropertyChanged.Invoke(this, new PropertyChangedEventArgs(propertyName)); - } - } - /// - /// 每页显示数量 - /// - public int PageSize - { - // 获取值时将私有字段传出; - get { return AppConst.MRESULT_LIST_PAGE_SIZE; } - set - { - // 赋值时将值传给私有字段 - AppConst.MRESULT_LIST_PAGE_SIZE = value; - // 一旦执行了赋值操作说明其值被修改了,则立马通过INotifyPropertyChanged接口告诉UI(IntValue)被修改了 - OnPropertyChanged("PageSize"); - } - } - + #region 数据分页 // 切换页码 private void PageBar_PageIndexChanged(object sender, RoutedPropertyChangedEventArgs e) { @@ -599,10 +639,12 @@ namespace TextLocator private void PageBar_PageSizeChanged(object sender, RoutedPropertyChangedEventArgs e) { log.Debug($"pageSize : {e.OldValue} => {e.NewValue}"); + + _viewModel.PageSize = e.NewValue; } #endregion - #region 排序 + #region 列表排序 /// /// 排序选中 /// @@ -610,11 +652,11 @@ namespace TextLocator /// private void SortOptions_SelectionChanged(object sender, SelectionChangedEventArgs e) { - BeforeSearch(PageNow); + BeforeSearch(_viewModel.PageIndex); } #endregion - #region 清空 + #region 结果清空 /// /// 清空按钮 /// @@ -686,13 +728,9 @@ namespace TextLocator // -------- 分页标签 // 还原为第一页 - PageNow = 1; + _viewModel.PageIndex = 1; // 设置分页标签总条数 - this.Dispatcher.BeginInvoke(new Action(() => - { - this.PageBar.Total = 0; - this.PageBar.PageIndex = 1; - })); + _viewModel.TotalCount = 0; // -------- 快捷标签 // 隐藏上一个和下一个切换面板 @@ -706,11 +744,11 @@ namespace TextLocator // -------- 状态栏 // 工作状态更新为就绪 - WorkStatus.Text = "就绪"; + _viewModel.WorkStatus = "就绪"; } #endregion - #region 列表 + #region 数据列表 /// /// 列表项被选中事件 /// @@ -726,7 +764,7 @@ namespace TextLocator // 预览切换索引标记 this.SwitchPreview.Tag = SearchResultList.SelectedIndex; // 显示预览分页信息 - this.PreviewPage.Text = String.Format("{0}/{1}", this.SearchResultList.SelectedIndex + 1, SearchResultList.Items.Count); + _viewModel.PreviewPage = String.Format("{0}/{1}", this.SearchResultList.SelectedIndex + 1, SearchResultList.Items.Count); // 手动GC GC.Collect(); @@ -1056,7 +1094,7 @@ namespace TextLocator } // 显示分页信息 - this.PreviewPage.Text = String.Format("{0}/{1}", this.SearchResultList.SelectedIndex + 1, SearchResultList.Items.Count); + _viewModel.PreviewPage = String.Format("{0}/{1}", this.SearchResultList.SelectedIndex + 1, SearchResultList.Items.Count); } /// @@ -1349,27 +1387,13 @@ namespace TextLocator /// 进度,0-100 private void ShowStatus(string text, double percent = AppConst.MAX_PERCENT) { - void refresh() + _viewModel.WorkStatus = text; + if (percent > AppConst.MIN_PERCENT) { - WorkStatus.Text = text; - if (percent > AppConst.MIN_PERCENT) - { - WorkProgress.Value = percent; + _viewModel.WorkProgress = percent; - TaskbarItemInfo.ProgressState = percent < AppConst.MAX_PERCENT ? System.Windows.Shell.TaskbarItemProgressState.Normal : System.Windows.Shell.TaskbarItemProgressState.None; - TaskbarItemInfo.ProgressValue = WorkProgress.Value / WorkProgress.Maximum; - } - } - try - { - refresh(); - } - catch - { - Dispatcher.BeginInvoke(new Action(() => - { - refresh(); - })); + _viewModel.ProgressState = percent < AppConst.MAX_PERCENT ? System.Windows.Shell.TaskbarItemProgressState.Normal : System.Windows.Shell.TaskbarItemProgressState.None; + _viewModel.ProgressValue = _viewModel.WorkProgress / 100; } } #endregion @@ -1576,81 +1600,7 @@ namespace TextLocator return keywords; } - /// - /// 搜索前 - /// - /// 指定页 - private void BeforeSearch(int page = 1) - { - // 1、---- 搜索信息预处理 - // 还原分页count - if (page != PageNow) - { - PageNow = page; - // 设置分页标签总条数 - this.Dispatcher.BeginInvoke(new Action(() => - { - this.PageBar.Total = 0; - this.PageBar.PageIndex = PageNow; - })); - } - - // 获取搜索关键词列表 - List keywords = GetSearchTextKeywords(); - if (keywords.Count <= 0) - { - return; - } - - - // 2、---- 预览信息还原 - // 预览区打开文件和文件夹标记清空 - OpenFile.Tag = null; - OpenFolder.Tag = null; - - // 预览文件名清空 - PreviewFileName.Text = ""; - - // 预览文件内容清空 - PreviewFileContent.Document.Blocks.Clear(); - - // 预览文件内容分页标记 - SwitchPreviewContentPage.Tag = 0; - SwitchPreviewContentPage.Visibility = Visibility.Collapsed; - - // 预览图标清空 - PreviewImage.Source = null; - - // 预览文件类型图标清空 - PreviewFileTypeIcon.Source = null; - - // 预览切换标记清空 - SwitchPreview.Tag = null; - - - // 3、---- 生成本次搜索时间戳 - _timestamp = Convert.ToInt64((DateTime.Now - new DateTime(1970, 1, 1, 0, 0, 0, 0)).TotalMilliseconds); - - - // 4、---- 构造搜索条件并保存(保存的搜索条件需要用于数据导出) - _searchParam = new Entity.SearchParam() - { - Keywords = keywords, - FileType = (FileType)SearchFileType.Tag, - SortType = (SortType)SortOptions.SelectedValue, - IsPreciseRetrieval = (bool) PreciseRetrieval.IsChecked, - IsMatchWords = (bool)MatchWords.IsChecked, - SearchRegion = (SearchRegion)SearchScope.SelectedValue, - PageSize = PageSize, - PageIndex = PageNow - }; - - // 5、---- 搜索 - Search( - _timestamp, - _searchParam - ); - } + #endregion } } diff --git a/TextLocator/TextLocator.csproj b/TextLocator/TextLocator.csproj index fb08412..ef15982 100644 --- a/TextLocator/TextLocator.csproj +++ b/TextLocator/TextLocator.csproj @@ -345,6 +345,9 @@ + + + Designer MSBuild:Compile @@ -485,5 +488,6 @@ + \ No newline at end of file diff --git a/TextLocator/ViewModel/Main/MainModel.cs b/TextLocator/ViewModel/Main/MainModel.cs new file mode 100644 index 0000000..50f80a9 --- /dev/null +++ b/TextLocator/ViewModel/Main/MainModel.cs @@ -0,0 +1,57 @@ +using System.Windows; + +namespace TextLocator.ViewModel.Main +{ + /// + /// 主窗口数据Model + /// + public class MainModel + { + // ================================ 分页 + /// + /// 当前页 + /// + public int PageIndex { get; set; } + + /// + /// 分页条数 + /// + public int PageSize { get; set; } + + /// + /// 结果总条数 + /// + public int TotalCount { get; set; } + + /// + /// 预览分页 + /// + public string PreviewPage { get; set; } + /// + /// 切换预览显示状态 + /// + public Visibility PreviewSwitchVisibility { get; set; } + + // ================================ 工作状态 + /// + /// 工作状态 + /// + public string WorkStatus { get; set; } + + /// + /// 工作进度 + /// + public double WorkProgress { get; set; } + + // ================================ 任务栏图标 + /// + /// 任务栏图标状态 + /// + public System.Windows.Shell.TaskbarItemProgressState ProgressState { get; set; } + + /// + /// 任务栏进度 + /// + public double ProgressValue { get; set; } + } +} diff --git a/TextLocator/ViewModel/Main/MainViewModel.cs b/TextLocator/ViewModel/Main/MainViewModel.cs new file mode 100644 index 0000000..f8d2708 --- /dev/null +++ b/TextLocator/ViewModel/Main/MainViewModel.cs @@ -0,0 +1,149 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; +using System.Windows; +using TextLocator.Core; + +namespace TextLocator.ViewModel.Main +{ + /// + /// MainWindow模型 + /// + public class MainViewModel: NotificationObject + { + private MainModel model; + + public MainViewModel() + { + model = new MainModel() + { + PageIndex = 1, + PageSize = AppConst.MRESULT_LIST_PAGE_SIZE, + TotalCount = 0, + + PreviewPage = "0/0", + PreviewSwitchVisibility = Visibility.Hidden, + + WorkStatus = "就绪", + WorkProgress = 100, + ProgressState = System.Windows.Shell.TaskbarItemProgressState.Normal, + ProgressValue = 100 + }; + } + /// + /// 当前页 + /// + public int PageIndex + { + get { return model.PageIndex; } + set + { + model.PageIndex = value; + RaisePropertyChanged("PageIndex"); + } + } + /// + /// 分页条数 + /// + public int PageSize + { + // 获取值时将私有字段传出; + get { return model.PageSize; } + // 赋值时将值传给私有字段 + set + { + model.PageSize= value; + RaisePropertyChanged("PageSize"); + } + } + /// + /// 结果总条数 + /// + public int TotalCount + { + get { return model.TotalCount; } + set + { + model.TotalCount = value; + RaisePropertyChanged("TotalCount"); + } + } + + /// + /// 预览分页 + /// + public string PreviewPage { + get { return model.PreviewPage; } + set + { + model.PreviewPage = value; + RaisePropertyChanged("PreviewPage"); + } + } + + /// + /// 切换预览显示状态 + /// + public Visibility PreviewSwitchVisibility + { + get { return model.PreviewSwitchVisibility; } + set + { + model.PreviewSwitchVisibility = value; + RaisePropertyChanged("PreviewSwitchVisibility"); + } + } + + /// + /// 工作状态 + /// + public string WorkStatus + { + get { return model.WorkStatus; } + set + { + model.WorkStatus = value; + RaisePropertyChanged("WorkStatus"); + } + } + /// + /// 工作进度 + /// + public double WorkProgress + { + get { return model.WorkProgress; } + set + { + model.WorkProgress = value; + RaisePropertyChanged("WorkProgress"); + } + } + + /// + /// 任务栏图标状态 + /// + public System.Windows.Shell.TaskbarItemProgressState ProgressState + { + get { return model.ProgressState; } + set + { + model.ProgressState = value; + RaisePropertyChanged("ProgressState"); + } + } + /// + /// 任务栏进度 + /// + public double ProgressValue + { + get { return model.ProgressValue; } + set + { + model.ProgressValue = value; + RaisePropertyChanged("ProgressState"); + } + } + } +} diff --git a/TextLocator/ViewModel/NotificationObject.cs b/TextLocator/ViewModel/NotificationObject.cs new file mode 100644 index 0000000..e406a4f --- /dev/null +++ b/TextLocator/ViewModel/NotificationObject.cs @@ -0,0 +1,17 @@ +using System.ComponentModel; + +namespace TextLocator.ViewModel +{ + public abstract class NotificationObject : INotifyPropertyChanged + { + public event PropertyChangedEventHandler PropertyChanged; + /// + /// 发起通知 + /// + /// 属性名 + public void RaisePropertyChanged(string propertyName) + { + PropertyChanged?.Invoke(this, new PropertyChangedEventArgs(propertyName)); + } + } +} -- Gitee From 2d600ca2bac448f50339fe757bb1efafea6cd10c Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E5=88=98=E7=A3=8A?= Date: Fri, 13 May 2022 15:56:41 +0800 Subject: [PATCH 3/6] =?UTF-8?q?1=E3=80=81=E5=88=A0=E9=99=A4=E9=A2=84?= =?UTF-8?q?=E8=A7=88=E7=9B=B8=E5=85=B3=E5=8F=82=E6=95=B0=E4=BC=A0=E9=80=92?= =?UTF-8?q?=E7=BC=93=E5=AD=98Key=202=E3=80=81=E6=90=9C=E7=B4=A2=E7=BB=93?= =?UTF-8?q?=E6=9E=9C=E5=88=97=E8=A1=A8=E5=A2=9E=E5=8A=A0=E8=AF=8D=E9=A2=91?= =?UTF-8?q?=E7=BB=9F=E8=AE=A1=E9=A2=84=E8=A7=88=203=E3=80=81IndexCore?= =?UTF-8?q?=E5=A2=9E=E5=8A=A0GetMatchCountDetails=E6=96=B9=E6=B3=95?= =?UTF-8?q?=EF=BC=88=E8=AF=8D=E9=A2=91=E7=BB=9F=E8=AE=A1=EF=BC=89=204?= =?UTF-8?q?=E3=80=81=E6=96=87=E4=BB=B6=E5=86=85=E5=AE=B9=E9=A2=84=E8=A7=88?= =?UTF-8?q?=E4=BB=8ERichText=E6=94=B9=E4=B8=BAFlowDocumentReader?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- TextLocator/Core/AppConst.cs | 13 - TextLocator/FileInfoItem.xaml | 12 +- TextLocator/FileInfoItem.xaml.cs | 12 +- TextLocator/Index/IndexCore.cs | 89 ++ TextLocator/MainWindow.xaml | 1214 ++++++++++++++------------- TextLocator/MainWindow.xaml.cs | 276 +----- TextLocator/Util/RichTextBoxUtil.cs | 108 ++- 7 files changed, 870 insertions(+), 854 deletions(-) diff --git a/TextLocator/Core/AppConst.cs b/TextLocator/Core/AppConst.cs index 95602e0..9fd81b1 100644 --- a/TextLocator/Core/AppConst.cs +++ b/TextLocator/Core/AppConst.cs @@ -161,19 +161,6 @@ namespace TextLocator.Core /// 区域文件类型 /// public const string AREA_FILE_TYPES_KEY = "AreaFileTypes"; - - /// - /// 预览内容分隔列表 - /// - public const string PREVIEW_CONTENT_SPLIT_LIST_KEY = "PreviewContentSplitList"; - /// - /// 预览内容关键词列表 - /// - public const string PREVIEW_FILE_INFO_KEYWORDS_KEY = "PreviewFileInfoKeywords"; - /// - /// 预览内容是否区分大小写 - /// - public const string PREVIEW_FILE_INFO_MATCH_CASE_KEY = "PreviewFileInfoIsMatchCase"; } } } diff --git a/TextLocator/FileInfoItem.xaml b/TextLocator/FileInfoItem.xaml index 08ed5a3..c34611b 100644 --- a/TextLocator/FileInfoItem.xaml +++ b/TextLocator/FileInfoItem.xaml @@ -16,7 +16,7 @@ - + 配置信息详细报告.doc @@ -36,13 +36,15 @@ - + - - ...电脑型号 X64 兼容 台式电脑 + + ...电脑型号 X64 兼容 台式电脑 操作系统 Windows 10 专业版 64位 ( Version 2004 / DirectX 12 ) - 处理器 AMD Ryzen 9 3900X 12-Core + + 处理器 + AMD Ryzen 9 3900X 12-Core 主板 华硕 PRIME X570-P ( AMD PCI 标准主机 CPU 桥 ) 显卡 Nvidia GeForce RTX 2080 Ti ( 11 GB / 七彩虹 ) 内存 64 GB ( 海盗船 DDR4 3200MHz )... diff --git a/TextLocator/FileInfoItem.xaml.cs b/TextLocator/FileInfoItem.xaml.cs index 8e65c85..4028ebb 100644 --- a/TextLocator/FileInfoItem.xaml.cs +++ b/TextLocator/FileInfoItem.xaml.cs @@ -67,7 +67,7 @@ namespace TextLocator RichTextBoxUtil.Highlighted(this.FileName, Colors.Red, fileInfo.Keywords); } - string folderPath = fileInfo.FilePath.Substring(0, fileInfo.FilePath.LastIndexOf("\\")); //fileInfo.FilePath.Replace(fileInfo.FileName, ""); + string folderPath = fileInfo.FilePath.Substring(0, fileInfo.FilePath.LastIndexOf("\\")); // 文件路径 this.FileFolder.Text = folderPath.Length > 70 ? folderPath.Substring(0, 70) + "..." : folderPath; @@ -85,17 +85,17 @@ namespace TextLocator })); }); - /*// 词频统计 + // 词频统计 Task.Factory.StartNew(() => { - string keywordFrequency = IndexCore.GetKeywordFrequency(fileInfo, searchRegion); + string matchCountDetails = IndexCore.GetMatchCountDetails(fileInfo); this.Dispatcher.BeginInvoke(new Action(() => { - if (!string.IsNullOrWhiteSpace(keywordFrequency)) + if (!string.IsNullOrWhiteSpace(matchCountDetails)) { // 关键词匹配次数 - this.FileTypeIcon.ToolTip = keywordFrequency; + this.FileTypeIcon.ToolTip = matchCountDetails; } })); - });*/ + }); } } } diff --git a/TextLocator/Index/IndexCore.cs b/TextLocator/Index/IndexCore.cs index 6c290e0..7ecabba 100644 --- a/TextLocator/Index/IndexCore.cs +++ b/TextLocator/Index/IndexCore.cs @@ -1013,6 +1013,95 @@ namespace TextLocator.Index } #endregion + #region 关键词词频统计 + /// + /// 获取关键词词频统计 + /// + /// 文件信息 + /// + public static string GetMatchCountDetails(Entity.FileInfo fileInfo) + { + try + { + TaskTime taskTime = TaskTime.StartNew(); + + // 定义词频词典 + Dictionary matchCountDic = new Dictionary(); + // 遍历关键词 + foreach (string keyword in fileInfo.Keywords) + { + // 匹配内容 + int nameMatchCount = 0, contentMatchCount = 0; + // 声明正则 + Regex regex = new Regex(keyword); + + // ---- 匹配文件名 + if (fileInfo.SearchRegion == SearchRegion.文件名和内容 || fileInfo.SearchRegion == SearchRegion.仅文件名) + { + // 匹配文件名 + Match matchName = regex.Match(fileInfo.FileName); + // 文件名匹配成功 + if (matchName.Success) + { + // 获取匹配次数 + nameMatchCount = regex.Matches(fileInfo.FileName).Count; + } + } + + // ---- 匹配文件内容 + if (fileInfo.SearchRegion == SearchRegion.文件名和内容 || fileInfo.SearchRegion == SearchRegion.仅文件内容) + { + // 获取内容(预览内容替换----\d+----) + string content = AppConst.REGEX_CONTENT_PAGE.Replace(fileInfo.Preview, ""); + + // 匹配文件内容 + Match matchContent = regex.Match(content); + // 文件内容匹配成功 + if (matchContent.Success) + { + // 获取匹配次数 + contentMatchCount = regex.Matches(content).Count; + } + } + + // 匹配数量合并 + int count = nameMatchCount + contentMatchCount; + // 匹配次数大于才是有效值 + if (count > 0) + { + matchCountDic[keyword] = count; + } + } + + StringBuilder builder = new StringBuilder(); + // 获取匹配词列表 + List matchCountList = matchCountDic.Keys.ToList(); + for (int k = 0; k < matchCountList.Count; k++) + { + // 词频统计信息 + builder.Append(string.Format("{0}:{1};", matchCountList[k], matchCountDic[matchCountList[k]])); + // 自动换行 && (下标不是0 && 每4次 && 下标不是最大) + if (k > 0 && k % 6 == 0 && k < matchCountList.Count - 1) + { + builder.Append("\r\n"); + } + } + string text = builder.ToString(); + if (text.EndsWith(",")) + { + text = text.Substring(0, text.Length - 1); + } + log.Debug(fileInfo.FileName + " -> 词频统计耗时:" + taskTime.ConsumeTime + " 统计词频:" + text); + return text; + } + catch (Exception ex) + { + log.Error("获取关键词词频统计失败:" + ex.Message, ex); + return null; + } + } + #endregion + #region 任务信息对象 /// /// 任务信息 diff --git a/TextLocator/MainWindow.xaml b/TextLocator/MainWindow.xaml index 426ec50..e60762d 100644 --- a/TextLocator/MainWindow.xaml +++ b/TextLocator/MainWindow.xaml @@ -161,9 +161,15 @@ - - 配置信息详细报告.doc - + + + + 配置 + 信息 + 详细报告.doc + + + @@ -184,7 +190,9 @@ ...电脑型号 X64 兼容 台式电脑 操作系统 Windows 10 专业版 64位 ( Version 2004 / DirectX 12 ) - 处理器 AMD Ryzen 9 3900X 12-Core + + 处理器 + Ryzen 9 3900X 12-Core 主板 华硕 PRIME X570-P ( AMD PCI 标准主机 CPU 桥 ) 显卡 Nvidia GeForce RTX 2080 Ti ( 11 GB / 七彩虹 ) 内存 64 GB ( 海盗船 DDR4 3200MHz )... @@ -239,581 +247,651 @@ - - - - - - - - - - - - - - - + - + - + --------[ 概览 ]---------------------------------------------------------------------------------- + + + + + + 电脑型号 X64 兼容 台式电脑 + 操作系统 Windows 10 专业版 64位 ( Version 2004 / DirectX 12 ) - 电脑型号 X64 兼容 台式电脑 - 操作系统 Windows 10 专业版 64位 ( Version 2004 / DirectX 12 ) - - 处理器 AMD Ryzen 9 3900X 12-Core - 主板 华硕 PRIME X570-P ( AMD PCI 标准主机 CPU 桥 ) - 显卡 Nvidia GeForce RTX 2080 Ti ( 11 GB / 七彩虹 ) - 内存 64 GB ( 海盗船 DDR4 3200MHz ) - 主硬盘 创见 TS256GMTE220S ( 256 GB / 固态硬盘 ) - 显示器 冠捷 AOC2790 U2790B ( 27.2 英寸 ) - 声卡 瑞昱 @ AMD High Definition Audio 控制器 - 网卡 瑞昱 RTL8168/8111/8112 Gigabit Ethernet Controller / 华硕 - --------[ 主板 ]---------------------------------------------------------------------------------- - - 主板型号 华硕 PRIME X570-P - 芯片组 AMD PCI 标准主机 CPU 桥 - 序列号 190652794505186 - 主板版本 Rev X.0x - BIOS American Megatrends Inc. 2204 / BIOS程序发布日期: 06/17/2020 - BIOS的大小 16384 KB - BIOS的序列号 IeiEr3Ul6IOzeS4EAT8EQeiGuD - - 板载设备 视频设备 (启用) - - --------[ 处理器 ]-------------------------------------------------------------------------------- - - 处理器 AMD Ryzen 9 3900X 12-Core - 速度 3.80 GHz (100 MHz x 38.0) - 处理器数量 核心数: 12 / 线程数: 24 - 插槽/插座 AM4 - 一级数据缓存 32 KB, 16-Way, 64 byte lines - 一级代码缓存 32 KB, 16-Way, 64 byte lines - 二级缓存 12 x 512 KB, 8-Way, 64 byte lines - 三级缓存 64 MB, 8-Way, 64 byte lines - 特征 MMX+, SSE, SSE2, SSE3, SSSE3, SSE4A, SSE4.1, HTT, X86-64 - - --------[ 硬盘 ]---------------------------------------------------------------------------------- - - 产品 西数 WDC WD10JPVX-22JC3T0 - 大小 1 TB - 转速 5400 转/分 - 缓存 8 MB - 硬盘已使用 共 1493 次,累计 10617 小时 - 固件 01.01A01 - 接口 SATA III - 数据传输率 600.00 MB/秒 - 特征 S.M.A.R.T, APM, 48-bit LBA, NCQ - - 产品 西数 WDC WD10JPVX-22JC3T0 - 大小 1 TB - 转速 5400 转/分 - 缓存 8 MB - 硬盘已使用 共 238 次,累计 594 小时 - 固件 01.01A01 - 接口 SATA III - 数据传输率 600.00 MB/秒 - 特征 S.M.A.R.T, APM, 48-bit LBA, NCQ - - 产品 希捷 ST2000DM008-2FR102 - 大小 2 TB - 转速 7200 转/分 - 缓存 256 MB - 硬盘已使用 共 430 次,累计 4274 小时 - 固件 0001 - 接口 SATA III - 数据传输率 600.00 MB/秒 - 特征 S.M.A.R.T, APM, 48-bit LBA, NCQ - - 产品 创见 TS256GMTE220S (固态硬盘) - 大小 256 GB - 硬盘已使用 共 286 次,累计 3809 小时 - 固件 S0328C - 接口 NVM Express - 特征 S.M.A.R.T - - 产品 Asgard AN2+ 256NVMe-M.2/80 (固态硬盘) - 大小 256 GB - 硬盘已使用 共 441 次,累计 4271 小时 - 固件 S0614B0G - 接口 NVM Express - 特征 S.M.A.R.T - - --------[ 内存 ]---------------------------------------------------------------------------------- - - DIMM_A1 海盗船 DDR4 3200MHz 16GB - 型号 7F7F9E CM4X16GC3200C16K2E - 厂商 Corsair - 模块位宽: 64 Bits - 模块电压: SSTL 1.2V - - DIMM_A2 海盗船 DDR4 3200MHz 16GB - 型号 7F7F9E CM4X16GC3200C16K2E - 厂商 Corsair - 模块位宽: 64 Bits - 模块电压: SSTL 1.2V - - DIMM_B1 海盗船 DDR4 3200MHz 16GB - 型号 7F7F9E CM4X16GC3200C16K2E - 厂商 Corsair - 模块位宽: 64 Bits - 模块电压: SSTL 1.2V - - DIMM_B2 海盗船 DDR4 3200MHz 16GB - 型号 7F7F9E CM4X16GC3200C16K2E - 厂商 Corsair - 模块位宽: 64 Bits - 模块电压: SSTL 1.2V - - --------[ 显卡 ]---------------------------------------------------------------------------------- - - 主显卡 Nvidia GeForce RTX 2080 Ti - 显存 11 GB - 制造商 七彩虹 - 制造商 Nvidia - 驱动版本 27.21.14.5148 - 驱动日期 20200621 - - --------[ 显示器 ]-------------------------------------------------------------------------------- - - 产品 冠捷 AOC2790 U2790B - 厂商 冠捷 - 固件程序日期 2019 年 38 周 (非显示器制造日期) - 屏幕尺寸 27.2 英寸 (60 厘米 x 34 厘米) - 显示比例 宽屏 16 : 9 - 分辨率 3840 x 2160 32 位真彩色 - Gamma 2.20 - 电源管理 Active-Off - - --------[ 其他设备 ]------------------------------------------------------------------------------ - - - 网卡 瑞昱 RTL8168/8111/8112 Gigabit Ethernet Controller - 制造商 华硕 - - 无线网卡 瑞昱 802.11n NIC - - 声卡 Nvidia GeForce 7800 GTX @ Nvidia High Definition Audio 控制器 - - 声卡 瑞昱 @ AMD High Definition Audio 控制器 - - 键盘 HID 标准键盘 - 键盘 HID 标准键盘 - 键盘 HID 标准键盘 - 鼠标 HID-compliant 鼠标 - - - --------[ PCI设备 ]------------------------------------------------------------------------------- - - 设备 PCI 标准主机 CPU 桥 - 设备ID 1480 - 制造商 AMD - 制造商ID 1022 - 类别 Bridge / PCI to HOST - 子系统制造商 ASUSTeK - 子系统ID 87C01043 - - 设备 IOMMU Device - 设备ID 1481 - 制造商 AMD - 制造商ID 1022 - 类别 System / - 子系统制造商 ASUSTeK - 子系统ID 87C01043 - - 设备 PCI 标准主机 CPU 桥 - 设备ID 1482 - 制造商 AMD - 制造商ID 1022 - 类别 Bridge / PCI to HOST - 子系统ID 00000000 - - 设备 PCI 到 PCI 桥 - 设备ID 1483 - 制造商 AMD - 制造商ID 1022 - 类别 Bridge / PCI to PCI - 子系统ID 00000000 - - 设备 PCI 到 PCI 桥 - 设备ID 1483 - 制造商 AMD - 制造商ID 1022 - 类别 Bridge / PCI to PCI - 子系统ID 00000000 - - 设备 PCI 标准主机 CPU 桥 - 设备ID 1482 - 制造商 AMD - 制造商ID 1022 - 类别 Bridge / PCI to HOST - 子系统ID 00000000 - - 设备 PCI 标准主机 CPU 桥 - 设备ID 1482 - 制造商 AMD - 制造商ID 1022 - 类别 Bridge / PCI to HOST - 子系统ID 00000000 - - 设备 PCI 到 PCI 桥 - 设备ID 1483 - 制造商 AMD - 制造商ID 1022 - 类别 Bridge / PCI to PCI - 子系统ID 00000000 - - 设备 PCI 标准主机 CPU 桥 - 设备ID 1482 - 制造商 AMD - 制造商ID 1022 - 类别 Bridge / PCI to HOST - 子系统ID 00000000 - - 设备 PCI 标准主机 CPU 桥 - 设备ID 1482 - 制造商 AMD - 制造商ID 1022 - 类别 Bridge / PCI to HOST - 子系统ID 00000000 - - 设备 PCI 标准主机 CPU 桥 - 设备ID 1482 - 制造商 AMD - 制造商ID 1022 - 类别 Bridge / PCI to HOST - 子系统ID 00000000 - - 设备 PCI 到 PCI 桥 - 设备ID 1484 - 制造商 AMD - 制造商ID 1022 - 类别 Bridge / PCI to PCI - 子系统ID 00000000 - - 设备 PCI 标准主机 CPU 桥 - 设备ID 1482 - 制造商 AMD - 制造商ID 1022 - 类别 Bridge / PCI to HOST - 子系统ID 00000000 - - 设备 PCI 到 PCI 桥 - 设备ID 1484 - 制造商 AMD - 制造商ID 1022 - 类别 Bridge / PCI to PCI - 子系统ID 00000000 - - 设备 SMBus - 设备ID 790B - 制造商 AMD - 制造商ID 1022 - 类别 Serial / SMBus Controller - 子系统制造商 ASUSTeK - 子系统ID 87C01043 - - 设备 PCI 标准 ISA 桥 - 设备ID 790E - 制造商 AMD - 制造商ID 1022 - 类别 Bridge / PCI to ISA - 子系统制造商 ASUSTeK - 子系统ID 87C01043 - - 设备 PCI 标准主机 CPU 桥 - 设备ID 1440 - 制造商 AMD - 制造商ID 1022 - 类别 Bridge / PCI to HOST - 子系统ID 00000000 - - 设备 PCI 标准主机 CPU 桥 - 设备ID 1441 - 制造商 AMD - 制造商ID 1022 - 类别 Bridge / PCI to HOST - 子系统ID 00000000 - - 设备 PCI 标准主机 CPU 桥 - 设备ID 1442 - 制造商 AMD - 制造商ID 1022 - 类别 Bridge / PCI to HOST - 子系统ID 00000000 - - 设备 PCI 标准主机 CPU 桥 - 设备ID 1443 - 制造商 AMD - 制造商ID 1022 - 类别 Bridge / PCI to HOST - 子系统ID 00000000 - - 设备 PCI 标准主机 CPU 桥 - 设备ID 1444 - 制造商 AMD - 制造商ID 1022 - 类别 Bridge / PCI to HOST - 子系统ID 00000000 - - 设备 PCI 标准主机 CPU 桥 - 设备ID 1445 - 制造商 AMD - 制造商ID 1022 - 类别 Bridge / PCI to HOST - 子系统ID 00000000 - - 设备 PCI 标准主机 CPU 桥 - 设备ID 1446 - 制造商 AMD - 制造商ID 1022 - 类别 Bridge / PCI to HOST - 子系统ID 00000000 - - 设备 PCI 标准主机 CPU 桥 - 设备ID 1447 - 制造商 AMD - 制造商ID 1022 - 类别 Bridge / PCI to HOST - 子系统ID 00000000 - - 设备 标准 NVM Express 控制器 - 设备ID 2262 - 制造商 Silicon Motion - 制造商ID 126F - 类别 Storage / - 子系统制造商 Silicon Motion - 子系统ID 2262126F - - 设备 X570 Chipset - 设备ID 57AD - 制造商 AMD - 制造商ID 1022 - 类别 Bridge / PCI to PCI - 子系统ID 00000000 - - 设备 PCI Express 下游交换机端口 - 设备ID 57A3 - 制造商 AMD - 制造商ID 1022 - 类别 Bridge / PCI to PCI - 子系统ID 00000000 - - 设备 PCI Express 下游交换机端口 - 设备ID 57A3 - 制造商 AMD - 制造商ID 1022 - 类别 Bridge / PCI to PCI - 子系统ID 00000000 - - 设备 PCI Express 下游交换机端口 - 设备ID 57A4 - 制造商 AMD - 制造商ID 1022 - 类别 Bridge / PCI to PCI - 子系统ID 00000000 - - 设备 PCI Express 下游交换机端口 - 设备ID 57A4 - 制造商 AMD - 制造商ID 1022 - 类别 Bridge / PCI to PCI - 子系统ID 00000000 - - 设备 PCI Express 下游交换机端口 - 设备ID 57A4 - 制造商 AMD - 制造商ID 1022 - 类别 Bridge / PCI to PCI - 子系统ID 00000000 - - 设备 标准 NVM Express 控制器 - 设备ID 2263 - 制造商 Silicon Motion - 制造商ID 126F - 类别 Storage / - 子系统制造商 Silicon Motion - 子系统ID 2263126F - - 设备 RTL8168/8111/8112 Gigabit Ethernet Controller - 设备ID 8168 - 制造商 Realtek - 制造商ID 10EC - 类别 Network / Ethernet - 子系统制造商 ASUSTeK - 子系统ID 86771043 - - 设备 PCI - 设备ID 1485 - 制造商 AMD - 制造商ID 1022 - 类别 / - 子系统制造商 ASUSTeK - 子系统ID 87C01043 - - 设备 符合 USB xHCI 的主机控制器 - 设备ID 149C - 制造商 AMD - 制造商ID 1022 - 类别 Serial / USB (UHCI) - 子系统制造商 ASUSTeK - 子系统ID 87C01043 - - 设备 符合 USB xHCI 的主机控制器 - 设备ID 149C - 制造商 AMD - 制造商ID 1022 - 类别 Serial / USB (UHCI) - 子系统制造商 AMD - 子系统ID 148C1022 - - 设备 标准 SATA AHCI 控制器 - 设备ID 7901 - 制造商 AMD - 制造商ID 1022 - 类别 Storage / Serial ATA (AHCI 1.0) - 子系统制造商 AMD - 子系统ID 79011022 - - 设备 标准 SATA AHCI 控制器 - 设备ID 7901 - 制造商 AMD - 制造商ID 1022 - 类别 Storage / Serial ATA (AHCI 1.0) - 子系统制造商 AMD - 子系统ID 79011022 - - 设备 GeForce RTX 2080 Ti - 设备ID 1E04 - 制造商 Nvidia - 制造商ID 10DE - 类别 Display / VGA - 子系统制造商 Colorful - 子系统ID 16507377 - - 设备 High Definition Audio 控制器 - 设备ID 10F7 - 制造商 Nvidia - 制造商ID 10DE - 类别 Multimedia / Hi-definition Audio - 子系统制造商 Colorful - 子系统ID 16507377 - - 设备 USB 3.10 可扩展主机控制器 - 1.10 (Microsoft) - 设备ID 1AD6 - 制造商 Nvidia - 制造商ID 10DE - 类别 Serial / USB (UHCI) - 子系统制造商 Colorful - 子系统ID 16507377 - - 设备 USB Type-C Port Policy Controller - 设备ID 1AD7 - 制造商 Nvidia - 制造商ID 10DE - 类别 Serial / Other - 子系统制造商 Colorful - 子系统ID 16507377 - - 设备 PCI - 设备ID 148A - 制造商 AMD - 制造商ID 1022 - 类别 / - 子系统制造商 ASUSTeK - 子系统ID 87C01043 - - 设备 PCI - 设备ID 1485 - 制造商 AMD - 制造商ID 1022 - 类别 / - 子系统制造商 ASUSTeK - 子系统ID 87C01043 - - 设备 PSP 11.0 Device - 设备ID 1486 - 制造商 AMD - 制造商ID 1022 - 类别 En/Decryption / Other - 子系统制造商 ASUSTeK - 子系统ID 87C01043 - - 设备 符合 USB xHCI 的主机控制器 - 设备ID 149C - 制造商 AMD - 制造商ID 1022 - 类别 Serial / USB (UHCI) - 子系统制造商 ASUSTeK - 子系统ID 87C01043 - - 设备 High Definition Audio 控制器 - 设备ID 1487 - 制造商 AMD - 制造商ID 1022 - 类别 Multimedia / Hi-definition Audio - 子系统制造商 ASUSTeK - 子系统ID 87BB1043 - - --------[ USB设备 ]------------------------------------------------------------------------------- - - 制造商ID 18F8 - 产品ID 1286 - 类别 0 / 0 / 0 - 设备 ? USB GAMING MOUSE - Serial ? - 版本 USB 1.1 - - 制造商ID 0BDA - 产品ID 8179 - 类别 0 / 0 / 0 - 设备 Realtek 802.11n NIC - Serial 00E04C0001 - 版本 USB 2.0 - - 制造商ID 0C45 - 产品ID 6510 - 类别 0 / 0 / 0 - 设备 SONiX USB DEVICE - Serial ? - 版本 USB 2.0 - - 制造商ID 0B05 - 产品ID 18F3 - 类别 0 / 0 / 0 - 设备 AsusTek Computer Inc. AURA LED Controller - Serial 9876543210 - 版本 USB 2.0 - - --------[ 传感器 ]-------------------------------------------------------------------------------- - - 名称 WINBOND NCT6798D - CPU温度 73℃ - CPU核心 74℃ - 主板 36℃ - 显卡 58℃ - 硬盘温度 42℃ - 风扇 1050转 + + 处理器 + AMD Ryzen 9 3900X 12-Core + 主板 华硕 PRIME X570-P ( AMD PCI 标准主机 CPU 桥 ) + 显卡 Nvidia GeForce RTX 2080 Ti ( 11 GB / 七彩虹 ) + 内存 64 GB ( 海盗船 + DDR4 + 3200MHz ) + 主硬盘 创见 TS256GMTE220S ( 256 GB / 固态硬盘 ) + 显示器 冠捷 AOC2790 U2790B ( 27.2 英寸 ) + 声卡 瑞昱 @ AMD High Definition Audio 控制器 + 网卡 瑞昱 RTL8168/8111/8112 Gigabit Ethernet Controller / 华硕 + + + + + --------[ 主板 ]---------------------------------------------------------------------------------- + + + + + + 主板型号 华硕 PRIME X570-P + 芯片组 AMD PCI 标准主机 CPU 桥 + 序列号 190652794505186 + 主板版本 Rev X.0x + BIOS American Megatrends Inc. 2204 / BIOS程序发布日期: 06/17/2020 + BIOS的大小 16384 KB + BIOS的序列号 IeiEr3Ul6IOzeS4EAT8EQeiGuD + + 板载设备 视频设备 (启用) + + + + + --------[ + 处理器 + ]-------------------------------------------------------------------------------- + + + + + 处理器 + AMD Ryzen 9 3900X 12-Core + 速度 3.80 GHz (100 MHz x 38.0) + + 处理器 + 数量 核心数: 12 / 线程数: 24 + 插槽/插座 AM4 + 一级数据缓存 32 KB, 16-Way, 64 byte lines + 一级代码缓存 32 KB, 16-Way, 64 byte lines + 二级缓存 12 x 512 KB, 8-Way, 64 byte lines + 三级缓存 64 MB, 8-Way, 64 byte lines + 特征 MMX+, SSE, SSE2, SSE3, SSSE3, SSE4A, SSE4.1, HTT, X86-64 + + + + + --------[ 硬盘 ]---------------------------------------------------------------------------------- + + + + + 产品 西数 WDC WD10JPVX-22JC3T0 + 大小 1 TB + 转速 5400 转/分 + 缓存 8 MB + 硬盘已使用 共 1493 次,累计 10617 小时 + 固件 01.01A01 + + 接口 + SATA III + 数据传输率 600.00 MB/秒 + 特征 S.M.A.R.T, APM, 48-bit LBA, NCQ + + 产品 西数 WDC WD10JPVX-22JC3T0 + 大小 1 TB + 转速 5400 转/分 + 缓存 8 MB + 硬盘已使用 共 238 次,累计 594 小时 + 固件 01.01A01 + + 接口 + SATA III + 数据传输率 600.00 MB/秒 + 特征 S.M.A.R.T, APM, 48-bit LBA, NCQ + + 产品 希捷 ST2000DM008-2FR102 + 大小 2 TB + 转速 7200 转/分 + 缓存 256 MB + 硬盘已使用 共 430 次,累计 4274 小时 + 固件 0001 + + 接口 + SATA III + 数据传输率 600.00 MB/秒 + 特征 S.M.A.R.T, APM, 48-bit LBA, NCQ + + 产品 创见 TS256GMTE220S (固态硬盘) + 大小 256 GB + 硬盘已使用 共 286 次,累计 3809 小时 + 固件 S0328C + + 接口 + NVM Express + 特征 S.M.A.R.T + + 产品 Asgard AN2+ 256NVMe-M.2/80 (固态硬盘) + 大小 256 GB + 硬盘已使用 共 441 次,累计 4271 小时 + 固件 S0614B0G + + 接口 + NVM Express + 特征 S.M.A.R.T + + + + + --------[ 内存 ]---------------------------------------------------------------------------------- + + + + DIMM_A1 海盗船 + DDR4 + 3200MHz 16GB + 型号 7F7F9E CM4X16GC3200C16K2E + 厂商 Corsair + 模块位宽: 64 Bits + 模块电压: SSTL 1.2V + + DIMM_A2 海盗船 + DDR4 + 3200MHz 16GB + 型号 7F7F9E CM4X16GC3200C16K2E + 厂商 Corsair + 模块位宽: 64 Bits + 模块电压: SSTL 1.2V + + DIMM_B1 海盗船 + DDR4 + 3200MHz 16GB + 型号 7F7F9E CM4X16GC3200C16K2E + 厂商 Corsair + 模块位宽: 64 Bits + 模块电压: SSTL 1.2V + + DIMM_B2 海盗船 + DDR4 + 3200MHz 16GB + 型号 7F7F9E CM4X16GC3200C16K2E + 厂商 Corsair + 模块位宽: 64 Bits + 模块电压: SSTL 1.2V + + --------[ 显卡 ]---------------------------------------------------------------------------------- + + + + + 主显卡 Nvidia GeForce RTX 2080 Ti + 显存 11 GB + 制造商 七彩虹 + 制造商 Nvidia + 驱动版本 27.21.14.5148 + 驱动日期 20200621 + + + + + --------[ 显示器 ]-------------------------------------------------------------------------------- + + + + + 产品 冠捷 AOC2790 U2790B + 厂商 冠捷 + 固件程序日期 2019 年 38 周 (非显示器制造日期) + 屏幕尺寸 27.2 英寸 (60 厘米 x 34 厘米) + 显示比例 宽屏 16 : 9 + 分辨率 3840 x 2160 32 位真彩色 + Gamma 2.20 + 电源管理 Active-Off + + + + + --------[ 其他设备 ]------------------------------------------------------------------------------ + + + + + + 网卡 瑞昱 RTL8168/8111/8112 Gigabit Ethernet Controller + 制造商 华硕 + + 无线网卡 瑞昱 802.11n NIC + + 声卡 Nvidia GeForce 7800 GTX @ Nvidia High Definition Audio 控制器 + + 声卡 瑞昱 @ AMD High Definition Audio 控制器 + + 键盘 HID 标准键盘 + 键盘 HID 标准键盘 + 键盘 HID 标准键盘 + 鼠标 HID-compliant 鼠标 + + + + + + --------[ PCI设备 ]------------------------------------------------------------------------------- + + + + + 设备 PCI 标准主机 CPU 桥 + 设备ID 1480 + 制造商 AMD + 制造商ID 1022 + 类别 Bridge / PCI to HOST + 子系统制造商 ASUSTeK + 子系统ID 87C01043 + + 设备 IOMMU Device + 设备ID 1481 + 制造商 AMD + 制造商ID 1022 + 类别 System / + 子系统制造商 ASUSTeK + 子系统ID 87C01043 + + 设备 PCI 标准主机 CPU 桥 + 设备ID 1482 + 制造商 AMD + 制造商ID 1022 + 类别 Bridge / PCI to HOST + 子系统ID 00000000 + + 设备 PCI 到 PCI 桥 + 设备ID 1483 + 制造商 AMD + 制造商ID 1022 + 类别 Bridge / PCI to PCI + 子系统ID 00000000 + + 设备 PCI 到 PCI 桥 + 设备ID 1483 + 制造商 AMD + 制造商ID 1022 + 类别 Bridge / PCI to PCI + 子系统ID 00000000 + + 设备 PCI 标准主机 CPU 桥 + 设备ID 1482 + 制造商 AMD + 制造商ID 1022 + 类别 Bridge / PCI to HOST + 子系统ID 00000000 + + 设备 PCI 标准主机 CPU 桥 + 设备ID 1482 + 制造商 AMD + 制造商ID 1022 + 类别 Bridge / PCI to HOST + 子系统ID 00000000 + + 设备 PCI 到 PCI 桥 + 设备ID 1483 + 制造商 AMD + 制造商ID 1022 + 类别 Bridge / PCI to PCI + 子系统ID 00000000 + + 设备 PCI 标准主机 CPU 桥 + 设备ID 1482 + 制造商 AMD + 制造商ID 1022 + 类别 Bridge / PCI to HOST + 子系统ID 00000000 + + 设备 PCI 标准主机 CPU 桥 + 设备ID 1482 + 制造商 AMD + 制造商ID 1022 + 类别 Bridge / PCI to HOST + 子系统ID 00000000 + + 设备 PCI 标准主机 CPU 桥 + 设备ID 1482 + 制造商 AMD + 制造商ID 1022 + 类别 Bridge / PCI to HOST + 子系统ID 00000000 + + 设备 PCI 到 PCI 桥 + 设备ID 1484 + 制造商 AMD + 制造商ID 1022 + 类别 Bridge / PCI to PCI + 子系统ID 00000000 + + 设备 PCI 标准主机 CPU 桥 + 设备ID 1482 + 制造商 AMD + 制造商ID 1022 + 类别 Bridge / PCI to HOST + 子系统ID 00000000 + + 设备 PCI 到 PCI 桥 + 设备ID 1484 + 制造商 AMD + 制造商ID 1022 + 类别 Bridge / PCI to PCI + 子系统ID 00000000 + + 设备 SMBus + 设备ID 790B + 制造商 AMD + 制造商ID 1022 + 类别 Serial / SMBus Controller + 子系统制造商 ASUSTeK + 子系统ID 87C01043 + + 设备 PCI 标准 ISA 桥 + 设备ID 790E + 制造商 AMD + 制造商ID 1022 + 类别 Bridge / PCI to ISA + 子系统制造商 ASUSTeK + 子系统ID 87C01043 + + 设备 PCI 标准主机 CPU 桥 + 设备ID 1440 + 制造商 AMD + 制造商ID 1022 + 类别 Bridge / PCI to HOST + 子系统ID 00000000 + + 设备 PCI 标准主机 CPU 桥 + 设备ID 1441 + 制造商 AMD + 制造商ID 1022 + 类别 Bridge / PCI to HOST + 子系统ID 00000000 + + 设备 PCI 标准主机 CPU 桥 + 设备ID 1442 + 制造商 AMD + 制造商ID 1022 + 类别 Bridge / PCI to HOST + 子系统ID 00000000 + + 设备 PCI 标准主机 CPU 桥 + 设备ID 1443 + 制造商 AMD + 制造商ID 1022 + 类别 Bridge / PCI to HOST + 子系统ID 00000000 + + 设备 PCI 标准主机 CPU 桥 + 设备ID 1444 + 制造商 AMD + 制造商ID 1022 + 类别 Bridge / PCI to HOST + 子系统ID 00000000 + + 设备 PCI 标准主机 CPU 桥 + 设备ID 1445 + 制造商 AMD + 制造商ID 1022 + 类别 Bridge / PCI to HOST + 子系统ID 00000000 + + 设备 PCI 标准主机 CPU 桥 + 设备ID 1446 + 制造商 AMD + 制造商ID 1022 + 类别 Bridge / PCI to HOST + 子系统ID 00000000 + + 设备 PCI 标准主机 CPU 桥 + 设备ID 1447 + 制造商 AMD + 制造商ID 1022 + 类别 Bridge / PCI to HOST + 子系统ID 00000000 + + 设备 标准 NVM Express 控制器 + 设备ID 2262 + 制造商 Silicon Motion + 制造商ID 126F + 类别 Storage / + 子系统制造商 Silicon Motion + 子系统ID 2262126F + + 设备 X570 Chipset + 设备ID 57AD + 制造商 AMD + 制造商ID 1022 + 类别 Bridge / PCI to PCI + 子系统ID 00000000 + + 设备 PCI Express 下游交换机端口 + 设备ID 57A3 + 制造商 AMD + 制造商ID 1022 + 类别 Bridge / PCI to PCI + 子系统ID 00000000 + + 设备 PCI Express 下游交换机端口 + 设备ID 57A3 + 制造商 AMD + 制造商ID 1022 + 类别 Bridge / PCI to PCI + 子系统ID 00000000 + + 设备 PCI Express 下游交换机端口 + 设备ID 57A4 + 制造商 AMD + 制造商ID 1022 + 类别 Bridge / PCI to PCI + 子系统ID 00000000 + + 设备 PCI Express 下游交换机端口 + 设备ID 57A4 + 制造商 AMD + 制造商ID 1022 + 类别 Bridge / PCI to PCI + 子系统ID 00000000 + + 设备 PCI Express 下游交换机端口 + 设备ID 57A4 + 制造商 AMD + 制造商ID 1022 + 类别 Bridge / PCI to PCI + 子系统ID 00000000 + + 设备 标准 NVM Express 控制器 + 设备ID 2263 + 制造商 Silicon Motion + 制造商ID 126F + 类别 Storage / + 子系统制造商 Silicon Motion + 子系统ID 2263126F + + 设备 RTL8168/8111/8112 Gigabit Ethernet Controller + 设备ID 8168 + 制造商 Realtek + 制造商ID 10EC + 类别 Network / Ethernet + 子系统制造商 ASUSTeK + 子系统ID 86771043 + + 设备 PCI + 设备ID 1485 + 制造商 AMD + 制造商ID 1022 + 类别 / + 子系统制造商 ASUSTeK + 子系统ID 87C01043 + + 设备 符合 USB xHCI 的主机控制器 + 设备ID 149C + 制造商 AMD + 制造商ID 1022 + 类别 Serial / USB (UHCI) + 子系统制造商 ASUSTeK + 子系统ID 87C01043 + + 设备 符合 USB xHCI 的主机控制器 + 设备ID 149C + 制造商 AMD + 制造商ID 1022 + 类别 Serial / USB (UHCI) + 子系统制造商 AMD + 子系统ID 148C1022 + + 设备 标准 SATA AHCI 控制器 + 设备ID 7901 + 制造商 AMD + 制造商ID 1022 + 类别 Storage / Serial ATA (AHCI 1.0) + 子系统制造商 AMD + 子系统ID 79011022 + + 设备 标准 SATA AHCI 控制器 + 设备ID 7901 + 制造商 AMD + 制造商ID 1022 + 类别 Storage / Serial ATA (AHCI 1.0) + 子系统制造商 AMD + 子系统ID 79011022 + + 设备 GeForce RTX 2080 Ti + 设备ID 1E04 + 制造商 Nvidia + 制造商ID 10DE + 类别 Display / VGA + 子系统制造商 Colorful + 子系统ID 16507377 + + 设备 High Definition Audio 控制器 + 设备ID 10F7 + 制造商 Nvidia + 制造商ID 10DE + 类别 Multimedia / Hi-definition Audio + 子系统制造商 Colorful + 子系统ID 16507377 + + 设备 USB 3.10 可扩展主机控制器 - 1.10 (Microsoft) + 设备ID 1AD6 + 制造商 Nvidia + 制造商ID 10DE + 类别 Serial / USB (UHCI) + 子系统制造商 Colorful + 子系统ID 16507377 + + 设备 USB Type-C Port Policy Controller + 设备ID 1AD7 + 制造商 Nvidia + 制造商ID 10DE + 类别 Serial / Other + 子系统制造商 Colorful + 子系统ID 16507377 + + 设备 PCI + 设备ID 148A + 制造商 AMD + 制造商ID 1022 + 类别 / + 子系统制造商 ASUSTeK + 子系统ID 87C01043 + + 设备 PCI + 设备ID 1485 + 制造商 AMD + 制造商ID 1022 + 类别 / + 子系统制造商 ASUSTeK + 子系统ID 87C01043 + + 设备 PSP 11.0 Device + 设备ID 1486 + 制造商 AMD + 制造商ID 1022 + 类别 En/Decryption / Other + 子系统制造商 ASUSTeK + 子系统ID 87C01043 + + 设备 符合 USB xHCI 的主机控制器 + 设备ID 149C + 制造商 AMD + 制造商ID 1022 + 类别 Serial / USB (UHCI) + 子系统制造商 ASUSTeK + 子系统ID 87C01043 + + 设备 High Definition Audio 控制器 + 设备ID 1487 + 制造商 AMD + 制造商ID 1022 + 类别 Multimedia / Hi-definition Audio + 子系统制造商 ASUSTeK + 子系统ID 87BB1043 + + + + + --------[ USB设备 ]------------------------------------------------------------------------------- + + + + + 制造商ID 18F8 + 产品ID 1286 + 类别 0 / 0 / 0 + 设备 ? USB GAMING MOUSE + Serial ? + 版本 USB 1.1 + + 制造商ID 0BDA + 产品ID 8179 + 类别 0 / 0 / 0 + 设备 Realtek 802.11n NIC + Serial 00E04C0001 + 版本 USB 2.0 + + 制造商ID 0C45 + 产品ID 6510 + 类别 0 / 0 / 0 + 设备 SONiX USB DEVICE + Serial ? + 版本 USB 2.0 + + 制造商ID 0B05 + 产品ID 18F3 + 类别 0 / 0 / 0 + 设备 AsusTek Computer Inc. AURA LED Controller + Serial 9876543210 + 版本 USB 2.0 + + + + + --------[ 传感器 ]-------------------------------------------------------------------------------- + + + + + 名称 WINBOND NCT6798D + CPU温度 73℃ + CPU核心 74℃ + 主板 36℃ + 显卡 58℃ + 硬盘温度 42℃ + 风扇 1050转 + + - + @@ -822,12 +900,6 @@ - - - - - - diff --git a/TextLocator/MainWindow.xaml.cs b/TextLocator/MainWindow.xaml.cs index 8baa55d..8317d37 100644 --- a/TextLocator/MainWindow.xaml.cs +++ b/TextLocator/MainWindow.xaml.cs @@ -47,10 +47,6 @@ namespace TextLocator /// private Entity.SearchParam _searchParam; /// - /// 上次预览区搜索文本 - /// - private string _lastPreviewSearchText; - /// /// 索引构建中 /// private static volatile bool build = false; @@ -520,11 +516,7 @@ namespace TextLocator PreviewFileName.Text = ""; // 预览文件内容清空 - PreviewFileContent.Document.Blocks.Clear(); - - // 预览文件内容分页标记 - SwitchPreviewContentPage.Tag = 0; - SwitchPreviewContentPage.Visibility = Visibility.Collapsed; + PreviewFileContent.Document = null; // 预览图标清空 PreviewImage.Source = null; @@ -701,16 +693,12 @@ namespace TextLocator SearchResultList.Items.Clear(); // -------- 右侧预览区 - // 清空预览搜索框 - PreviewSearchText.Text = ""; - _lastPreviewSearchText = ""; - // 右侧预览区,打开文件和文件夹标记清空 OpenFile.Tag = null; OpenFolder.Tag = null; // 滚动条回滚到最顶端 - PreviewFileContent.ScrollToHome(); + //PreviewFileContent.ScrollToHome(); // 滚动条回滚到最顶端(图片) // PreviewImageScrollViewer.ScrollToHome(); @@ -718,7 +706,7 @@ namespace TextLocator PreviewFileName.Text = ""; // 预览文件内容清空 - PreviewFileContent.Document.Blocks.Clear(); + PreviewFileContent.Document = null; // 预览图片清空 PreviewImage.Source = null; @@ -735,9 +723,6 @@ namespace TextLocator // -------- 快捷标签 // 隐藏上一个和下一个切换面板 this.SwitchPreview.Visibility = Visibility.Collapsed; - // 预览文件内容分页标记 - SwitchPreviewContentPage.Tag = 0; - SwitchPreviewContentPage.Visibility = Visibility.Collapsed; // -------- 搜索参数 _searchParam = null; @@ -776,23 +761,18 @@ namespace TextLocator // 根据文件类型显示图标 PreviewFileTypeIcon.Source = FileUtil.GetFileIcon(fileInfo.FileType); PreviewFileName.Text = fileInfo.FileName; - PreviewFileContent.Document.Blocks.Clear(); + PreviewFileContent.Document = null; // 绑定打开文件和打开路径的Tag OpenFile.Tag = fileInfo.FilePath; OpenFolder.Tag = fileInfo.FilePath.Substring(0, fileInfo.FilePath.LastIndexOf("\\")); - // 滚动条回滚到最顶端 - PreviewFileContent.ScrollToHome(); - // 滚动条回滚到最顶端(图片) - // PreviewImageScrollViewer.ScrollToHome(); - // 图片文件 if (FileType.常用图片 == FileTypeUtil.GetFileType(fileInfo.FilePath)) { PreviewFileContent.Visibility = Visibility.Hidden; PreviewImage.Visibility = Visibility.Visible; - Thread t = new Thread(new ThreadStart(() => + Task.Factory.StartNew(() => { try { @@ -820,38 +800,32 @@ namespace TextLocator } catch { } } - })); - t.Priority = ThreadPriority.AboveNormal; - t.Start(); + }); } else { PreviewImage.Visibility = Visibility.Hidden; PreviewFileContent.Visibility = Visibility.Visible; - // 标记当前页 - SwitchPreviewContentPage.Tag = 0; - // 填充数据 - RichTextBoxUtil.EmptyData(PreviewFileContent); // 文件内容预览 - Thread t = new Thread(() => + Task.Factory.StartNew(() => { try { // 文件内容(预览)FileInfoServiceFactory.GetFileContent(fileInfo.FilePath, true); string content = fileInfo.Preview; - // 内容预览分页 - List previewList = SplitContent(content); - // 缓存预览列表,关键词列表,是否区分大小写 - CacheUtil.Put(AppConst.CacheKey.PREVIEW_CONTENT_SPLIT_LIST_KEY, previewList); - CacheUtil.Put(AppConst.CacheKey.PREVIEW_FILE_INFO_KEYWORDS_KEY, fileInfo.Keywords); Dispatcher.InvokeAsync(() => { - - PreviewRefresh(previewList, 0); - - // 显示或隐藏操作按钮 - SwitchPreviewContentPage.Visibility = previewList.Count > 1 ? Visibility.Visible : Visibility.Collapsed; + // 填充数据 + RichTextBoxUtil.FillingDataFlowDocument(PreviewFileContent, content, new SolidColorBrush(Colors.Black)); + // 默认滚动到第一页 + PreviewFileContent.CanGoToPage(1); + // 关键词高亮 + RichTextBoxUtil.HighlightedFlowDocument( + PreviewFileContent, + Colors.Red, + fileInfo.Keywords + ); }); } catch (Exception ex) @@ -859,82 +833,11 @@ namespace TextLocator log.Error(ex.Message, ex); } }); - t.Priority = ThreadPriority.Highest; - t.Start(); - } - } - - /// - /// 分隔内容 - /// - /// - /// - private List SplitContent(string content) - { - int limit = AppConst.FILE_PREVIEW_LEN_LIMIT; - int lenth = content.Length; - List splitList = new List(); - if (lenth < limit) - { - splitList.Add(content); - } - else - { - int splitLenth = lenth / limit; - for (int i = 0; i < splitLenth; i++) - { - splitList.Add(content.Substring(limit * i, limit)); - } - if (lenth % limit != 0) - { - splitList.Add(content.Substring(limit * splitLenth)); - } } - return splitList; - } - - /// - /// 刷新预览 - /// - /// 预览内容列表 - /// 当前页 - private void PreviewRefresh(List previewList, int page) - { - string preview = previewList[page]; - // 填充数据 - RichTextBoxUtil.FillingData(PreviewFileContent, preview, new SolidColorBrush(Colors.Black)); - - // 显示分页信息 - PreviewContentPage.Text = string.Format("{0}/{1}", page + 1, previewList.Count); - - // 滚动条回滚到最顶端 - PreviewFileContent.ScrollToHome(); - // 滚动条回滚到最顶端(图片) - // PreviewImageScrollViewer.ScrollToHome(); - - // 获取文件名 - string fileName = PreviewFileName.Text; - Task.Factory.StartNew(() => { - int matchCount = IndexCore.GetMatchCount(new Entity.FileInfo() - { - SearchRegion = SearchRegion.文件名和内容, - FileName = fileName, - Preview = preview, - }); - Dispatcher.InvokeAsync(async () => - { - // 关键词高亮 - RichTextBoxUtil.Highlighted( - PreviewFileContent, - Colors.Red, - CacheUtil.Get>(AppConst.CacheKey.PREVIEW_FILE_INFO_KEYWORDS_KEY) - ); - }); - }); } #endregion - #region 界面事件 + #region 功能事件 /// /// 搜索域切换事件 @@ -1096,50 +999,6 @@ namespace TextLocator // 显示分页信息 _viewModel.PreviewPage = String.Format("{0}/{1}", this.SearchResultList.SelectedIndex + 1, SearchResultList.Items.Count); } - - /// - /// 预览内容上一页 - /// - /// - /// - private void BtnLastPage_MouseUp(object sender, MouseButtonEventArgs e) - { - // 获取列表 - List previewList = CacheUtil.Get>(AppConst.CacheKey.PREVIEW_CONTENT_SPLIT_LIST_KEY); - if (previewList != null) - { - // 获取当前页 - int page = (int)SwitchPreviewContentPage.Tag; - if (page > 0) - { - page = page - 1; - SwitchPreviewContentPage.Tag = page; - } - PreviewRefresh(previewList, page); - } - } - - /// - /// 预览内容下一页 - /// - /// - /// - private void BtnNextPage_MouseUp(object sender, MouseButtonEventArgs e) - { - // 获取列表 - List previewList = CacheUtil.Get>(AppConst.CacheKey.PREVIEW_CONTENT_SPLIT_LIST_KEY); - if (previewList != null) - { - // 获取当前页 - int page = (int)SwitchPreviewContentPage.Tag; - if (page < previewList.Count - 1) - { - page = page + 1; - SwitchPreviewContentPage.Tag = page; - } - PreviewRefresh(previewList, page); - } - } #endregion #region 辅助方法 @@ -1441,105 +1300,6 @@ namespace TextLocator } #endregion - #region 预览文本搜索 - /// - /// 预览搜索文本框内容改变 - /// - /// - /// - private void PreviewSearchText_TextChanged(object sender, TextChangedEventArgs e) - { - string text = PreviewSearchText.Text.Trim(); - PreviewCleanButton.Visibility = text.Length > 0 ? Visibility.Visible : Visibility.Hidden; - } - - /// - /// 预览搜索清空按钮 - /// - /// - /// - private void PreviewCleanButton_Click(object sender, RoutedEventArgs e) - { - // 清理上一次的搜索关键词 - if (!string.IsNullOrEmpty(_lastPreviewSearchText)) - { - List keywords = _lastPreviewSearchText.Split(' ').ToList(); - Task.Factory.StartNew(() => - { - Dispatcher.Invoke(new Action(() => - { - // 关键词高亮 - RichTextBoxUtil.Highlighted(PreviewFileContent, Colors.White, keywords, true); - })); - }); - _lastPreviewSearchText = ""; - } - - // 清理文本框 - PreviewSearchText.Text = ""; - } - /// - /// 预览搜索文本搜索按钮 - /// - /// - /// - private void PreviewSearchButton_Click(object sender, RoutedEventArgs e) - { - // 预览搜索关键词高亮 - PreviewSearchTextHighlighted(); - } - - /// - /// 预览搜索关键词高亮 - /// - private void PreviewSearchTextHighlighted() - { - // 搜索关键词 - string text = PreviewSearchText.Text.Trim(); - - // 清理上一次的搜索关键词(上一次搜索关键词不为空 && 和本次搜索关键词不相同才清理) - if (!string.IsNullOrEmpty(_lastPreviewSearchText) && !_lastPreviewSearchText.Equals(text)) - { - List keywords = _lastPreviewSearchText.Split(' ').ToList(); - Task.Factory.StartNew(() => { - Dispatcher.BeginInvoke(new Action(() => - { - // 关键词高亮 - RichTextBoxUtil.Highlighted(PreviewFileContent, Colors.White, keywords, true); - })); - }); - } - - if (!string.IsNullOrEmpty(text)) - { - _lastPreviewSearchText = text; - - List keywords = text.Split(' ').ToList(); - Task.Factory.StartNew(() => { - Dispatcher.BeginInvoke(new Action(() => - { - // 关键词高亮 - RichTextBoxUtil.Highlighted(PreviewFileContent, Colors.DeepSkyBlue, keywords, true); - })); - }); - } - } - - /// - /// 预览搜索文本按键 - /// - /// - /// - private void PreviewSearchText_PreviewKeyUp(object sender, KeyEventArgs e) - { - if (e.Key == Key.Enter) - { - // 预览搜索关键词高亮 - PreviewSearchTextHighlighted(); - } - } - #endregion - #region 其他私有封装 /// /// 获取文本关键词 diff --git a/TextLocator/Util/RichTextBoxUtil.cs b/TextLocator/Util/RichTextBoxUtil.cs index b3c0fec..d9a71d5 100644 --- a/TextLocator/Util/RichTextBoxUtil.cs +++ b/TextLocator/Util/RichTextBoxUtil.cs @@ -32,9 +32,9 @@ namespace TextLocator.Util richTextBox.Document.Blocks.Clear(); // Paragraph 类似于 html 的 P 标签 Paragraph paragraph = new Paragraph(); + paragraph.Foreground = brush; // Run 是一个 Inline 的标签 Run run = new Run(text); - run.Foreground = brush; if (underLine) { run.TextDecorations = TextDecorations.Underline; @@ -43,6 +43,112 @@ namespace TextLocator.Util richTextBox.Document.Blocks.Add(paragraph); } + /// + /// 填充数据 + /// + /// RichTextBox文本对象 + /// 高亮关键词 + /// 高亮颜色画刷 + /// 下划线 + public static void FillingDataFlowDocument(FlowDocumentReader reader, string text, Brush brush, bool underLine = false) + { + // Paragraph 类似于 html 的 P 标签 + Paragraph paragraph = new Paragraph(); + paragraph.FontFamily = new FontFamily("微软雅黑"); + paragraph.FontSize = 13; + paragraph.Foreground = brush; + // Run 是一个 Inline 的标签 + Run run = new Run(text); + if (underLine) + { + run.TextDecorations = TextDecorations.Underline; + } + paragraph.Inlines.Add(run); + reader.Document = new FlowDocument(paragraph); + } + + /// + /// 关键词高亮 + /// + /// UI元素 + /// 颜色值 + /// 关键词 + /// 背景颜色 + public static void HighlightedFlowDocument(FlowDocumentReader reader, Color color, List keywords, bool background = false) + { + if (keywords == null || keywords.Count <= 0) return; + foreach (string keyword in keywords) + { + if (string.IsNullOrEmpty(keyword)) continue; + // 设置文字指针为Document初始位置 + // richBox.Document.FlowDirection + TextPointer position = reader.Document.ContentStart; + while (position != null) + { + // 向前搜索,需要内容为Text + if (position.GetPointerContext(LogicalDirection.Forward) == TextPointerContext.Text) + { + // 拿出Run的Text + string text = position.GetTextInRun(LogicalDirection.Forward); + // 关键词是正则表达式 + if (AppConst.REGEX_SUPPORT_WILDCARDS.IsMatch(keyword)) + { + Regex regex = new Regex(keyword, RegexOptions.IgnoreCase); + Match matches = regex.Match(text); + if (matches.Success) + { + TextPointer start = position.GetPositionAtOffset(matches.Index); + TextPointer end = start.GetPositionAtOffset(matches.Length); + position = SelectaFlowDocument(reader, color, start, end, background); + } + } + else + { + // 可能包含多个keyword,做遍历查找 + int index = text.IndexOf(keyword, 0, StringComparison.CurrentCultureIgnoreCase); + if (index != -1) + { + TextPointer start = position.GetPositionAtOffset(index); + TextPointer end = start.GetPositionAtOffset(keyword.Length); + position = SelectaFlowDocument(reader, color, start, end, background); + } + } + } + // 文字指针向前偏移 + position = position.GetNextContextPosition(LogicalDirection.Forward); + } + } + } + + /// + /// 改变关键字的具体实现 + /// + /// 元素 + /// 颜色 + /// 内容指针开始位置 + /// 内容指针结束位置 + /// + private static TextPointer SelectaFlowDocument(FlowDocumentReader reader, Color color, TextPointer tpStart, TextPointer tpEnd, bool background) + { + TextRange range = reader.Selection; + range.Select(tpStart, tpEnd); + + //高亮选择 + if (background) + { + range.ApplyPropertyValue(TextElement.BackgroundProperty, new SolidColorBrush(color)); + range.ApplyPropertyValue(TextElement.FontWeightProperty, color == Colors.White ? FontWeights.Normal : FontWeights.Bold); + } + else + { + range.ApplyPropertyValue(TextElement.ForegroundProperty, new SolidColorBrush(color)); + range.ApplyPropertyValue(TextElement.FontWeightProperty, FontWeights.Bold); + } + + + return tpEnd.GetNextContextPosition(LogicalDirection.Forward); + } + /// /// 关键词高亮 /// -- Gitee From 3feb7034b0137b64f023613cd3a18180297705d7 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E5=88=98=E7=A3=8A?= Date: Fri, 13 May 2022 17:34:51 +0800 Subject: [PATCH 4/6] =?UTF-8?q?RichTextBoxUtil=E6=94=B9=E4=B8=BAFileConten?= =?UTF-8?q?tUtil=EF=BC=8C=E6=95=B4=E7=90=86=E5=A1=AB=E5=85=85=E5=86=85?= =?UTF-8?q?=E5=AE=B9=E5=92=8C=E9=AB=98=E4=BA=AE=E6=96=B9=E6=B3=95=EF=BC=8C?= =?UTF-8?q?=E8=AF=95=E7=94=A8=E4=B8=8ERichTextBox=E5=92=8CFlowDocumentRead?= =?UTF-8?q?er=E5=AF=B9=E8=B1=A1?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- TextLocator/FileInfoItem.xaml.cs | 10 +- TextLocator/MainWindow.xaml | 18 +-- TextLocator/MainWindow.xaml.cs | 14 +- TextLocator/TextLocator.csproj | 2 +- TextLocator/Util/FileContentUtil.cs | 131 ++++++++++++++++ TextLocator/Util/RichTextBoxUtil.cs | 234 ---------------------------- 6 files changed, 153 insertions(+), 256 deletions(-) create mode 100644 TextLocator/Util/FileContentUtil.cs delete mode 100644 TextLocator/Util/RichTextBoxUtil.cs diff --git a/TextLocator/FileInfoItem.xaml.cs b/TextLocator/FileInfoItem.xaml.cs index 4028ebb..cc0a222 100644 --- a/TextLocator/FileInfoItem.xaml.cs +++ b/TextLocator/FileInfoItem.xaml.cs @@ -61,10 +61,10 @@ namespace TextLocator string fileName = fileInfo.FileName; // 显示文件名称 - RichTextBoxUtil.FillingData(this.FileName, fileName.Length > 55 ? fileName.Substring(0, 55) + "..." : fileName, (Brush)new BrushConverter().ConvertFromString("#1A0DAB"), true); + FileContentUtil.FillFlowDocument(this.FileName, fileName.Length > 55 ? fileName.Substring(0, 55) + "..." : fileName, (Brush)new BrushConverter().ConvertFromString("#1A0DAB"), true); if (searchRegion == Enums.SearchRegion.文件名和内容 || searchRegion == Enums.SearchRegion.仅文件名) { - RichTextBoxUtil.Highlighted(this.FileName, Colors.Red, fileInfo.Keywords); + FileContentUtil.FlowDocumentHighlight(this.FileName, Colors.Red, fileInfo.Keywords); } string folderPath = fileInfo.FilePath.Substring(0, fileInfo.FilePath.LastIndexOf("\\")); @@ -72,15 +72,15 @@ namespace TextLocator this.FileFolder.Text = folderPath.Length > 70 ? folderPath.Substring(0, 70) + "..." : folderPath; // 获取摘要 - RichTextBoxUtil.EmptyData(this.ContentBreviary); + FileContentUtil.EmptyRichTextDocument(this.ContentBreviary); Task.Factory.StartNew(() => { string breviary = IndexCore.GetContentBreviary(fileInfo); this.Dispatcher.BeginInvoke(new Action(() => { - RichTextBoxUtil.FillingData(this.ContentBreviary, breviary, (Brush)new BrushConverter().ConvertFromString("#545454")); + FileContentUtil.FillFlowDocument(this.ContentBreviary, breviary, (Brush)new BrushConverter().ConvertFromString("#545454")); if (searchRegion == Enums.SearchRegion.文件名和内容 || searchRegion == Enums.SearchRegion.仅文件内容) { - RichTextBoxUtil.Highlighted(this.ContentBreviary, Colors.Red, fileInfo.Keywords); + FileContentUtil.FlowDocumentHighlight(this.ContentBreviary, Colors.Red, fileInfo.Keywords); } })); }); diff --git a/TextLocator/MainWindow.xaml b/TextLocator/MainWindow.xaml index e60762d..9118b7e 100644 --- a/TextLocator/MainWindow.xaml +++ b/TextLocator/MainWindow.xaml @@ -163,7 +163,7 @@ - + 配置 信息 详细报告.doc @@ -192,7 +192,7 @@ 处理器 - Ryzen 9 3900X 12-Core + Ryzen 9 3900X 12-Core 主板 华硕 PRIME X570-P ( AMD PCI 标准主机 CPU 桥 ) 显卡 Nvidia GeForce RTX 2080 Ti ( 11 GB / 七彩虹 ) 内存 64 GB ( 海盗船 DDR4 3200MHz )... @@ -253,11 +253,11 @@ - + - --------[ 概览 ]---------------------------------------------------------------------------------- + --------[ 概览 ]-------------------------------------------------------------------------- @@ -282,7 +282,7 @@ - --------[ 主板 ]---------------------------------------------------------------------------------- + --------[ 主板 ]-------------------------------------------------------------------------- @@ -303,7 +303,7 @@ --------[ 处理器 - ]-------------------------------------------------------------------------------- + ]----------------------------------------------------------------------- @@ -324,7 +324,7 @@ - --------[ 硬盘 ]---------------------------------------------------------------------------------- + --------[ 硬盘 ]-------------------------------------------------------------------------- @@ -386,7 +386,7 @@ - --------[ 内存 ]---------------------------------------------------------------------------------- + --------[ 内存 ]-------------------------------------------------------------------------- @@ -426,7 +426,7 @@ - --------[ 显卡 ]---------------------------------------------------------------------------------- + --------[ 显卡 ]-------------------------------------------------------------------------- diff --git a/TextLocator/MainWindow.xaml.cs b/TextLocator/MainWindow.xaml.cs index 8317d37..dcf7f74 100644 --- a/TextLocator/MainWindow.xaml.cs +++ b/TextLocator/MainWindow.xaml.cs @@ -697,11 +697,6 @@ namespace TextLocator OpenFile.Tag = null; OpenFolder.Tag = null; - // 滚动条回滚到最顶端 - //PreviewFileContent.ScrollToHome(); - // 滚动条回滚到最顶端(图片) - // PreviewImageScrollViewer.ScrollToHome(); - // 预览文件名清空 PreviewFileName.Text = ""; @@ -817,11 +812,16 @@ namespace TextLocator Dispatcher.InvokeAsync(() => { // 填充数据 - RichTextBoxUtil.FillingDataFlowDocument(PreviewFileContent, content, new SolidColorBrush(Colors.Black)); + FileContentUtil.FillFlowDocument(PreviewFileContent, content, new SolidColorBrush(Colors.Black)); // 默认滚动到第一页 PreviewFileContent.CanGoToPage(1); + ScrollViewer sourceScrollViewer = PreviewFileContent.Template.FindName("PART_ContentHost", PreviewFileContent) as ScrollViewer; + if (sourceScrollViewer != null) + { + sourceScrollViewer.ScrollToTop(); + } // 关键词高亮 - RichTextBoxUtil.HighlightedFlowDocument( + FileContentUtil.FlowDocumentHighlight( PreviewFileContent, Colors.Red, fileInfo.Keywords diff --git a/TextLocator/TextLocator.csproj b/TextLocator/TextLocator.csproj index ef15982..d9057dd 100644 --- a/TextLocator/TextLocator.csproj +++ b/TextLocator/TextLocator.csproj @@ -344,7 +344,7 @@ - + diff --git a/TextLocator/Util/FileContentUtil.cs b/TextLocator/Util/FileContentUtil.cs new file mode 100644 index 0000000..e0f868a --- /dev/null +++ b/TextLocator/Util/FileContentUtil.cs @@ -0,0 +1,131 @@ +using System; +using System.Collections.Generic; +using System.Text.RegularExpressions; +using System.Windows; +using System.Windows.Controls; +using System.Windows.Documents; +using System.Windows.Media; +using TextLocator.Core; + +namespace TextLocator.Util +{ + public class FileContentUtil + { + #region RichText操作 + /// + /// 清空RichText的Document + /// + /// RichTextBox对象 + public static void EmptyRichTextDocument(RichTextBox richTextBox) + { + richTextBox.Document.Blocks.Clear(); + } + + /// + /// 填充FlowDocument内容 + /// + /// RichTextBox 或 FlowDocumentReader对象 + /// 高亮关键词 + /// 高亮颜色画刷 + /// 下划线 + public static void FillFlowDocument(Control control, string text, Brush brush, bool isUnderLine = false) + { + // Paragraph 类似于 html 的 P 标签 + Paragraph paragraph = new Paragraph(); + paragraph.FontFamily = new FontFamily("微软雅黑"); + paragraph.FontSize = 13; + paragraph.Foreground = brush; + if (isUnderLine) + { + paragraph.TextDecorations = TextDecorations.Underline; + } + // Run 是一个 Inline 的标签 + Run run = new Run(text); + paragraph.Inlines.Add(run); + if (control is RichTextBox) + { + (control as RichTextBox).Document = new FlowDocument(paragraph); + } + else + { + (control as FlowDocumentReader).Document = new FlowDocument(paragraph); + } + } + + /// + /// FlowDocument关键词高亮 + /// + /// RichTextBox 或 FlowDocumentReader对象 + /// 颜色值 + /// 关键词 + /// 背景颜色 + public static void FlowDocumentHighlight(Control control, Color color, List keywords, bool isBackground = false) + { + if (keywords == null || keywords.Count <= 0) return; + foreach (string keyword in keywords) + { + if (string.IsNullOrEmpty(keyword)) continue; + // 设置文字指针为Document初始位置 + TextPointer position; + if (control is RichTextBox) + { + position = (control as RichTextBox).Document.ContentStart; + } + else + { + position = (control as FlowDocumentReader).Document.ContentStart; + } + while (position != null) + { + // 向前搜索,需要内容为Text + if (position.GetPointerContext(LogicalDirection.Forward) == TextPointerContext.Text) + { + // 拿出Run的Text + string text = position.GetTextInRun(LogicalDirection.Forward); + // 关键词匹配查找 + Regex regex = new Regex(keyword, RegexOptions.IgnoreCase); + Match matches = regex.Match(text); + if (matches.Success) + { + TextPointer start = position.GetPositionAtOffset(matches.Index); + TextPointer end = start.GetPositionAtOffset(matches.Length); + position = Selecta(control, color, start, end, isBackground); + } + } + // 文字指针向前偏移 + position = position.GetNextContextPosition(LogicalDirection.Forward); + } + } + } + + /// + /// FlowDocument关键词高亮的具体实现 + /// + /// RichTextBox 或 FlowDocumentReader对象 + /// 颜色 + /// 内容指针开始位置 + /// 内容指针结束位置 + /// + private static TextPointer Selecta(Control control, Color color, TextPointer tpStart, TextPointer tpEnd, bool background) + { + TextRange range; + if (control is RichTextBox) + { + range = (control as RichTextBox).Selection; + } + else + { + range = (control as FlowDocumentReader).Selection; + } + range.Select(tpStart, tpEnd); + + // 内容加粗 + range.ApplyPropertyValue(TextElement.FontWeightProperty, FontWeights.Bold); + // 内容高亮 + range.ApplyPropertyValue(background ? TextElement.BackgroundProperty : TextElement.ForegroundProperty, new SolidColorBrush(color)); + + return tpEnd.GetNextContextPosition(LogicalDirection.Forward); + } + #endregion + } +} diff --git a/TextLocator/Util/RichTextBoxUtil.cs b/TextLocator/Util/RichTextBoxUtil.cs deleted file mode 100644 index d9a71d5..0000000 --- a/TextLocator/Util/RichTextBoxUtil.cs +++ /dev/null @@ -1,234 +0,0 @@ -using System; -using System.Collections.Generic; -using System.Text.RegularExpressions; -using System.Windows; -using System.Windows.Controls; -using System.Windows.Documents; -using System.Windows.Media; -using TextLocator.Core; - -namespace TextLocator.Util -{ - public class RichTextBoxUtil - { - /// - /// 清空数据 - /// - /// RichTextBox文本对象 - public static void EmptyData(RichTextBox richTextBox) - { - richTextBox.Document.Blocks.Clear(); - } - - /// - /// 填充数据 - /// - /// RichTextBox文本对象 - /// 高亮关键词 - /// 高亮颜色画刷 - /// 下划线 - public static void FillingData(RichTextBox richTextBox, string text, Brush brush, bool underLine = false) - { - richTextBox.Document.Blocks.Clear(); - // Paragraph 类似于 html 的 P 标签 - Paragraph paragraph = new Paragraph(); - paragraph.Foreground = brush; - // Run 是一个 Inline 的标签 - Run run = new Run(text); - if (underLine) - { - run.TextDecorations = TextDecorations.Underline; - } - paragraph.Inlines.Add(run); - richTextBox.Document.Blocks.Add(paragraph); - } - - /// - /// 填充数据 - /// - /// RichTextBox文本对象 - /// 高亮关键词 - /// 高亮颜色画刷 - /// 下划线 - public static void FillingDataFlowDocument(FlowDocumentReader reader, string text, Brush brush, bool underLine = false) - { - // Paragraph 类似于 html 的 P 标签 - Paragraph paragraph = new Paragraph(); - paragraph.FontFamily = new FontFamily("微软雅黑"); - paragraph.FontSize = 13; - paragraph.Foreground = brush; - // Run 是一个 Inline 的标签 - Run run = new Run(text); - if (underLine) - { - run.TextDecorations = TextDecorations.Underline; - } - paragraph.Inlines.Add(run); - reader.Document = new FlowDocument(paragraph); - } - - /// - /// 关键词高亮 - /// - /// UI元素 - /// 颜色值 - /// 关键词 - /// 背景颜色 - public static void HighlightedFlowDocument(FlowDocumentReader reader, Color color, List keywords, bool background = false) - { - if (keywords == null || keywords.Count <= 0) return; - foreach (string keyword in keywords) - { - if (string.IsNullOrEmpty(keyword)) continue; - // 设置文字指针为Document初始位置 - // richBox.Document.FlowDirection - TextPointer position = reader.Document.ContentStart; - while (position != null) - { - // 向前搜索,需要内容为Text - if (position.GetPointerContext(LogicalDirection.Forward) == TextPointerContext.Text) - { - // 拿出Run的Text - string text = position.GetTextInRun(LogicalDirection.Forward); - // 关键词是正则表达式 - if (AppConst.REGEX_SUPPORT_WILDCARDS.IsMatch(keyword)) - { - Regex regex = new Regex(keyword, RegexOptions.IgnoreCase); - Match matches = regex.Match(text); - if (matches.Success) - { - TextPointer start = position.GetPositionAtOffset(matches.Index); - TextPointer end = start.GetPositionAtOffset(matches.Length); - position = SelectaFlowDocument(reader, color, start, end, background); - } - } - else - { - // 可能包含多个keyword,做遍历查找 - int index = text.IndexOf(keyword, 0, StringComparison.CurrentCultureIgnoreCase); - if (index != -1) - { - TextPointer start = position.GetPositionAtOffset(index); - TextPointer end = start.GetPositionAtOffset(keyword.Length); - position = SelectaFlowDocument(reader, color, start, end, background); - } - } - } - // 文字指针向前偏移 - position = position.GetNextContextPosition(LogicalDirection.Forward); - } - } - } - - /// - /// 改变关键字的具体实现 - /// - /// 元素 - /// 颜色 - /// 内容指针开始位置 - /// 内容指针结束位置 - /// - private static TextPointer SelectaFlowDocument(FlowDocumentReader reader, Color color, TextPointer tpStart, TextPointer tpEnd, bool background) - { - TextRange range = reader.Selection; - range.Select(tpStart, tpEnd); - - //高亮选择 - if (background) - { - range.ApplyPropertyValue(TextElement.BackgroundProperty, new SolidColorBrush(color)); - range.ApplyPropertyValue(TextElement.FontWeightProperty, color == Colors.White ? FontWeights.Normal : FontWeights.Bold); - } - else - { - range.ApplyPropertyValue(TextElement.ForegroundProperty, new SolidColorBrush(color)); - range.ApplyPropertyValue(TextElement.FontWeightProperty, FontWeights.Bold); - } - - - return tpEnd.GetNextContextPosition(LogicalDirection.Forward); - } - - /// - /// 关键词高亮 - /// - /// UI元素 - /// 颜色值 - /// 关键词 - /// 背景颜色 - public static void Highlighted(RichTextBox richTextBox, Color color, List keywords, bool background = false) - { - if (keywords == null || keywords.Count <= 0) return; - foreach (string keyword in keywords) - { - if (string.IsNullOrEmpty(keyword)) continue; - // 设置文字指针为Document初始位置 - // richBox.Document.FlowDirection - TextPointer position = richTextBox.Document.ContentStart; - while (position != null) - { - // 向前搜索,需要内容为Text - if (position.GetPointerContext(LogicalDirection.Forward) == TextPointerContext.Text) - { - // 拿出Run的Text - string text = position.GetTextInRun(LogicalDirection.Forward); - // 关键词是正则表达式 - if (AppConst.REGEX_SUPPORT_WILDCARDS.IsMatch(keyword)) - { - Regex regex = new Regex(keyword, RegexOptions.IgnoreCase); - Match matches = regex.Match(text); - if (matches.Success) - { - TextPointer start = position.GetPositionAtOffset(matches.Index); - TextPointer end = start.GetPositionAtOffset(matches.Length); - position = Selecta(richTextBox, color, start, end, background); - } - } - else - { - // 可能包含多个keyword,做遍历查找 - int index = text.IndexOf(keyword, 0, StringComparison.CurrentCultureIgnoreCase); - if (index != -1) - { - TextPointer start = position.GetPositionAtOffset(index); - TextPointer end = start.GetPositionAtOffset(keyword.Length); - position = Selecta(richTextBox, color, start, end, background); - } - } - } - // 文字指针向前偏移 - position = position.GetNextContextPosition(LogicalDirection.Forward); - } - } - } - - /// - /// 改变关键字的具体实现 - /// - /// 元素 - /// 颜色 - /// 内容指针开始位置 - /// 内容指针结束位置 - /// - private static TextPointer Selecta(RichTextBox richTextBox, Color color, TextPointer tpStart, TextPointer tpEnd, bool background) - { - TextRange range = richTextBox.Selection; - range.Select(tpStart, tpEnd); - - //高亮选择 - if (background) - { - range.ApplyPropertyValue(TextElement.BackgroundProperty, new SolidColorBrush(color)); - range.ApplyPropertyValue(TextElement.FontWeightProperty, color == Colors.White ? FontWeights.Normal : FontWeights.Bold); - } - else - { - range.ApplyPropertyValue(TextElement.ForegroundProperty, new SolidColorBrush(color)); - range.ApplyPropertyValue(TextElement.FontWeightProperty, FontWeights.Bold); - } - - - return tpEnd.GetNextContextPosition(LogicalDirection.Forward); - } - } -} -- Gitee From 88ef31fff4e0a498449026583ae9ddb4089dcc75 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E5=88=98=E7=A3=8A?= Date: Fri, 13 May 2022 20:00:06 +0800 Subject: [PATCH 5/6] =?UTF-8?q?=E4=BB=A3=E7=A0=81=E6=B8=85=E7=90=86?= =?UTF-8?q?=E5=92=8C=E4=BC=98=E5=8C=96=EF=BC=8Cworkstatus=E8=BF=98?= =?UTF-8?q?=E5=8E=9F=E4=B8=BAinvoke?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- TextLocator/AreaInfoItem.xaml.cs | 4 +- TextLocator/Entity/FileInfo.cs | 5 +- TextLocator/FileInfoItem.xaml.cs | 12 +- TextLocator/Index/IndexCore.cs | 123 ++++++++++---------- TextLocator/MainWindow.xaml | 8 +- TextLocator/MainWindow.xaml.cs | 58 ++++----- TextLocator/Message/MessageCore.cs | 73 ++++++++++-- TextLocator/ViewModel/Main/MainModel.cs | 22 ---- TextLocator/ViewModel/Main/MainViewModel.cs | 57 +-------- 9 files changed, 172 insertions(+), 190 deletions(-) diff --git a/TextLocator/AreaInfoItem.xaml.cs b/TextLocator/AreaInfoItem.xaml.cs index f0f10aa..3be55f4 100644 --- a/TextLocator/AreaInfoItem.xaml.cs +++ b/TextLocator/AreaInfoItem.xaml.cs @@ -22,7 +22,7 @@ namespace TextLocator } catch { - this.Dispatcher.BeginInvoke(new Action(() => + Dispatcher.InvokeAsync(() => { try { @@ -32,7 +32,7 @@ namespace TextLocator { log.Error(ex.Message, ex); } - })); + }); } } diff --git a/TextLocator/Entity/FileInfo.cs b/TextLocator/Entity/FileInfo.cs index 06cc5c7..c1be0b1 100644 --- a/TextLocator/Entity/FileInfo.cs +++ b/TextLocator/Entity/FileInfo.cs @@ -43,10 +43,7 @@ namespace TextLocator.Entity /// private List keywords = new List(); public List Keywords { get => keywords; set => keywords = value; } - /// - /// 词频统计 - /// - public int MatchCount { get; set; } + /// /// 搜索域 /// diff --git a/TextLocator/FileInfoItem.xaml.cs b/TextLocator/FileInfoItem.xaml.cs index cc0a222..986e303 100644 --- a/TextLocator/FileInfoItem.xaml.cs +++ b/TextLocator/FileInfoItem.xaml.cs @@ -31,7 +31,7 @@ namespace TextLocator Refresh(fileInfo, searchRegion); } catch { - this.Dispatcher.BeginInvoke(new Action(() => + Dispatcher.InvokeAsync(() => { try { @@ -41,7 +41,7 @@ namespace TextLocator { log.Error(ex.Message, ex); } - })); + }); } } @@ -75,26 +75,26 @@ namespace TextLocator FileContentUtil.EmptyRichTextDocument(this.ContentBreviary); Task.Factory.StartNew(() => { string breviary = IndexCore.GetContentBreviary(fileInfo); - this.Dispatcher.BeginInvoke(new Action(() => + Dispatcher.InvokeAsync(() => { FileContentUtil.FillFlowDocument(this.ContentBreviary, breviary, (Brush)new BrushConverter().ConvertFromString("#545454")); if (searchRegion == Enums.SearchRegion.文件名和内容 || searchRegion == Enums.SearchRegion.仅文件内容) { FileContentUtil.FlowDocumentHighlight(this.ContentBreviary, Colors.Red, fileInfo.Keywords); } - })); + }); }); // 词频统计 Task.Factory.StartNew(() => { string matchCountDetails = IndexCore.GetMatchCountDetails(fileInfo); - this.Dispatcher.BeginInvoke(new Action(() => { + Dispatcher.InvokeAsync(() => { if (!string.IsNullOrWhiteSpace(matchCountDetails)) { // 关键词匹配次数 this.FileTypeIcon.ToolTip = matchCountDetails; } - })); + }); }); } } diff --git a/TextLocator/Index/IndexCore.cs b/TextLocator/Index/IndexCore.cs index 7ecabba..0ebbfc9 100644 --- a/TextLocator/Index/IndexCore.cs +++ b/TextLocator/Index/IndexCore.cs @@ -828,7 +828,7 @@ namespace TextLocator.Index }; // 词频统计(所有关键词匹配次数) - fileInfo.MatchCount = GetMatchCount(fileInfo); + // fileInfo.MatchCount = GetMatchCount(fileInfo); fileInfos.Add(fileInfo); } @@ -877,65 +877,6 @@ namespace TextLocator.Index } } - /// - /// 获取关键词词频统计 - /// - /// 文件信息 - /// - public static int GetMatchCount(Entity.FileInfo fileInfo) - { - try - { - int totalCount = 0; - // 遍历关键词 - foreach (string keyword in fileInfo.Keywords) - { - // 匹配内容 - int nameMatchCount = 0, contentMatchCount = 0; - // 声明正则 - Regex regex = new Regex(keyword); - - // ---- 匹配文件名 - if (fileInfo.SearchRegion == SearchRegion.文件名和内容 || fileInfo.SearchRegion == SearchRegion.仅文件名) - { - // 匹配文件名 - Match matchName = regex.Match(fileInfo.FileName); - // 文件名匹配成功 - if (matchName.Success) - { - // 获取匹配次数 - nameMatchCount = regex.Matches(fileInfo.FileName).Count; - } - } - - // ---- 匹配文件内容 - if (fileInfo.SearchRegion == SearchRegion.文件名和内容 || fileInfo.SearchRegion == SearchRegion.仅文件内容) - { - // 获取内容(预览内容替换----\d+----) - string content = AppConst.REGEX_CONTENT_PAGE.Replace(fileInfo.Preview, ""); - - // 匹配文件内容 - Match matchContent = regex.Match(content); - // 文件内容匹配成功 - if (matchContent.Success) - { - // 获取匹配次数 - contentMatchCount = regex.Matches(content).Count; - } - } - - // 匹配数量合并 - totalCount = totalCount + nameMatchCount + contentMatchCount; - } - return totalCount; - } - catch (Exception ex) - { - log.Error("获取关键词词频统计失败:" + ex.Message, ex); - return 0; - } - } - /// /// 获取内容缩略 /// @@ -1013,9 +954,67 @@ namespace TextLocator.Index } #endregion - #region 关键词词频统计 + #region 关键词词频统计(商业版) + /// + /// 获取关键词词频统计总数 + /// + /// 文件信息 + /// + public static int GetMatchCount(Entity.FileInfo fileInfo) + { + try + { + int totalCount = 0; + // 遍历关键词 + foreach (string keyword in fileInfo.Keywords) + { + // 匹配内容 + int nameMatchCount = 0, contentMatchCount = 0; + // 声明正则 + Regex regex = new Regex(keyword); + + // ---- 匹配文件名 + if (fileInfo.SearchRegion == SearchRegion.文件名和内容 || fileInfo.SearchRegion == SearchRegion.仅文件名) + { + // 匹配文件名 + Match matchName = regex.Match(fileInfo.FileName); + // 文件名匹配成功 + if (matchName.Success) + { + // 获取匹配次数 + nameMatchCount = regex.Matches(fileInfo.FileName).Count; + } + } + + // ---- 匹配文件内容 + if (fileInfo.SearchRegion == SearchRegion.文件名和内容 || fileInfo.SearchRegion == SearchRegion.仅文件内容) + { + // 获取内容(预览内容替换----\d+----) + string content = AppConst.REGEX_CONTENT_PAGE.Replace(fileInfo.Preview, ""); + + // 匹配文件内容 + Match matchContent = regex.Match(content); + // 文件内容匹配成功 + if (matchContent.Success) + { + // 获取匹配次数 + contentMatchCount = regex.Matches(content).Count; + } + } + + // 匹配数量合并 + totalCount = totalCount + nameMatchCount + contentMatchCount; + } + return totalCount; + } + catch (Exception ex) + { + log.Error("获取关键词词频统计失败:" + ex.Message, ex); + return 0; + } + } /// - /// 获取关键词词频统计 + /// 获取关键词词频统计详情 /// /// 文件信息 /// diff --git a/TextLocator/MainWindow.xaml b/TextLocator/MainWindow.xaml index 9118b7e..d8437ac 100644 --- a/TextLocator/MainWindow.xaml +++ b/TextLocator/MainWindow.xaml @@ -9,7 +9,7 @@ Title="文本搜索定位器" Width="1600" Height="900" Icon="Resource/App.ico" WindowStartupLocation="CenterScreen" Loaded="Window_Loaded" Closing="Window_Closing" Activated="Window_Activated"> - + @@ -907,16 +907,16 @@ - - + - + diff --git a/TextLocator/MainWindow.xaml.cs b/TextLocator/MainWindow.xaml.cs index dcf7f74..c1c19f2 100644 --- a/TextLocator/MainWindow.xaml.cs +++ b/TextLocator/MainWindow.xaml.cs @@ -320,7 +320,7 @@ namespace TextLocator if (string.IsNullOrEmpty(failList)) return true; - var result = await MessageCore.Confirm(string.Format("无法注册下列快捷键:\r\n\r\n{0}是否要改变这些快捷键?", failList), "确认提示", MessageBoxButton.YesNo); + var result = await MessageCore.ShowMessageBox(string.Format("无法注册下列快捷键:\r\n\r\n{0}是否要改变这些快捷键?", failList), "确认提示", MessageBoxButton.YesNo); // 弹出热键设置窗体 var win = HotkeyWindow.CreateInstance(); if (result == MessageBoxResult.Yes) @@ -571,10 +571,10 @@ namespace TextLocator try { // 1、---- 清空搜索结果列表 - Dispatcher.Invoke(new Action(() => + Dispatcher.Invoke(() => { this.SearchResultList.Items.Clear(); - })); + }); // 2、---- 查询列表(参数,消息回调) Entity.SearchResult searchResult = IndexCore.Search(searchParam, ShowStatus); @@ -582,10 +582,7 @@ namespace TextLocator // 验证列表数据 if (null == searchResult || searchResult.Results.Count <= 0) { - this.Dispatcher.BeginInvoke(new Action(() => - { - MessageCore.ShowWarning("没有搜到你想要的内容,请更换搜索条件。"); - })); + MessageCore.ShowWarning("没有搜到你想要的内容,请更换搜索条件。"); return; } @@ -596,10 +593,10 @@ namespace TextLocator { return; } - this.Dispatcher.Invoke(new Action(() => + Dispatcher.Invoke(() => { this.SearchResultList.Items.Add(new FileInfoItem(fileInfo, searchParam.SearchRegion)); - })); + }); } // 4、---- 显示预览列表分页信息 @@ -724,7 +721,7 @@ namespace TextLocator // -------- 状态栏 // 工作状态更新为就绪 - _viewModel.WorkStatus = "就绪"; + ShowStatus("就绪"); } #endregion @@ -778,20 +775,20 @@ namespace TextLocator bi.EndInit(); bi.Freeze(); - Dispatcher.BeginInvoke(new Action(() => + Dispatcher.InvokeAsync(() => { PreviewImage.Source = bi; - })); + }); } catch (Exception ex) { log.Error(ex.Message, ex); try { - Dispatcher.BeginInvoke(new Action(() => + Dispatcher.InvokeAsync(() => { PreviewImage.Source = null; - })); + }); } catch { } } @@ -912,7 +909,7 @@ namespace TextLocator } if (CheckIndexExist(false)) { - var result = await MessageCore.Confirm("确定要重建索引嘛?时间可能比较久哦!", "确认提示"); + var result = await MessageCore.ShowMessageBox("确定要重建索引嘛?时间可能比较久哦!", "确认提示"); if (result == MessageBoxResult.Cancel) { return; @@ -1206,11 +1203,7 @@ namespace TextLocator log.Info(msg); ShowStatus(msg); - Dispatcher.BeginInvoke(new Action(() => - { - MessageCore.ShowSuccess(msg); - })); - + MessageCore.ShowSuccess(msg); // 2.8、-------- 记录文件总数、更新总数、删除总数、错误总数 fileTotalCount = fileTotalCount + allFilePaths.Count; @@ -1246,13 +1239,26 @@ namespace TextLocator /// 进度,0-100 private void ShowStatus(string text, double percent = AppConst.MAX_PERCENT) { - _viewModel.WorkStatus = text; - if (percent > AppConst.MIN_PERCENT) + void Refresh() { - _viewModel.WorkProgress = percent; - - _viewModel.ProgressState = percent < AppConst.MAX_PERCENT ? System.Windows.Shell.TaskbarItemProgressState.Normal : System.Windows.Shell.TaskbarItemProgressState.None; - _viewModel.ProgressValue = _viewModel.WorkProgress / 100; + WorkStatus.Text = text; + TaskbarInfo.ProgressState = percent < AppConst.MAX_PERCENT ? System.Windows.Shell.TaskbarItemProgressState.Normal : System.Windows.Shell.TaskbarItemProgressState.None; + if (percent > AppConst.MIN_PERCENT) + { + WorkProgress.Value = percent; + TaskbarInfo.ProgressValue = percent / 100; + } + } + try + { + Refresh(); + } + catch + { + Dispatcher.InvokeAsync(() => + { + Refresh(); + }); } } #endregion diff --git a/TextLocator/Message/MessageCore.cs b/TextLocator/Message/MessageCore.cs index fac0291..cbdc15d 100644 --- a/TextLocator/Message/MessageCore.cs +++ b/TextLocator/Message/MessageCore.cs @@ -1,5 +1,6 @@ using System.Threading.Tasks; using System.Windows; +using System.Windows.Threading; using TextLocator.Core; namespace TextLocator.Message @@ -16,15 +17,29 @@ namespace TextLocator.Message /// /// Rubyer.MessageBoxR参数containerIdentifier /// - private const string CONFIRM_CONTAINER = "ConfirmContainers"; + private const string MESSAGE_BOX_CONTAINER = "MessageBoxContainers"; /// /// 警告 /// /// public static void ShowWarning(string message) - { - Rubyer.Message.ShowWarning(MESSAGE_CONTAINER, message); + { + void TryShow() + { + Rubyer.Message.ShowWarning(MESSAGE_CONTAINER, message); + } + try + { + TryShow(); + } + catch + { + Dispatcher.CurrentDispatcher.InvokeAsync(() => + { + TryShow(); + }); + } } /// @@ -33,7 +48,21 @@ namespace TextLocator.Message /// public static void ShowSuccess(string message) { - Rubyer.Message.ShowSuccess(MESSAGE_CONTAINER, message); + void TryShow() + { + Rubyer.Message.ShowSuccess(MESSAGE_CONTAINER, message); + } + try + { + TryShow(); + } + catch + { + Dispatcher.CurrentDispatcher.InvokeAsync(() => + { + TryShow(); + }); + } } /// @@ -42,7 +71,21 @@ namespace TextLocator.Message /// public static void ShowError(string message) { - Rubyer.Message.ShowError(MESSAGE_CONTAINER, message); + void TryShow() + { + Rubyer.Message.ShowError(MESSAGE_CONTAINER, message); + } + try + { + TryShow(); + } + catch + { + Dispatcher.CurrentDispatcher.InvokeAsync(() => + { + TryShow(); + }); + } } /// @@ -51,7 +94,21 @@ namespace TextLocator.Message /// public static void ShowInfo(string message) { - Rubyer.Message.ShowInfo(MESSAGE_CONTAINER, message); + void TryShow() + { + Rubyer.Message.ShowInfo(MESSAGE_CONTAINER, message); + } + try + { + TryShow(); + } + catch + { + Dispatcher.CurrentDispatcher.InvokeAsync(() => + { + TryShow(); + }); + } } /// @@ -61,9 +118,9 @@ namespace TextLocator.Message /// /// /// - public static Task Confirm(string message, string title, MessageBoxButton button = MessageBoxButton.OKCancel) + public static Task ShowMessageBox(string message, string title, MessageBoxButton button = MessageBoxButton.OKCancel) { - return Rubyer.MessageBoxR.ConfirmInContainer(CONFIRM_CONTAINER, message, title, button); + return Rubyer.MessageBoxR.ConfirmInContainer(MESSAGE_BOX_CONTAINER, message, title, button); } } } diff --git a/TextLocator/ViewModel/Main/MainModel.cs b/TextLocator/ViewModel/Main/MainModel.cs index 50f80a9..0859022 100644 --- a/TextLocator/ViewModel/Main/MainModel.cs +++ b/TextLocator/ViewModel/Main/MainModel.cs @@ -31,27 +31,5 @@ namespace TextLocator.ViewModel.Main /// 切换预览显示状态 /// public Visibility PreviewSwitchVisibility { get; set; } - - // ================================ 工作状态 - /// - /// 工作状态 - /// - public string WorkStatus { get; set; } - - /// - /// 工作进度 - /// - public double WorkProgress { get; set; } - - // ================================ 任务栏图标 - /// - /// 任务栏图标状态 - /// - public System.Windows.Shell.TaskbarItemProgressState ProgressState { get; set; } - - /// - /// 任务栏进度 - /// - public double ProgressValue { get; set; } } } diff --git a/TextLocator/ViewModel/Main/MainViewModel.cs b/TextLocator/ViewModel/Main/MainViewModel.cs index f8d2708..8df129b 100644 --- a/TextLocator/ViewModel/Main/MainViewModel.cs +++ b/TextLocator/ViewModel/Main/MainViewModel.cs @@ -24,12 +24,7 @@ namespace TextLocator.ViewModel.Main TotalCount = 0, PreviewPage = "0/0", - PreviewSwitchVisibility = Visibility.Hidden, - - WorkStatus = "就绪", - WorkProgress = 100, - ProgressState = System.Windows.Shell.TaskbarItemProgressState.Normal, - ProgressValue = 100 + PreviewSwitchVisibility = Visibility.Hidden }; } /// @@ -95,55 +90,5 @@ namespace TextLocator.ViewModel.Main RaisePropertyChanged("PreviewSwitchVisibility"); } } - - /// - /// 工作状态 - /// - public string WorkStatus - { - get { return model.WorkStatus; } - set - { - model.WorkStatus = value; - RaisePropertyChanged("WorkStatus"); - } - } - /// - /// 工作进度 - /// - public double WorkProgress - { - get { return model.WorkProgress; } - set - { - model.WorkProgress = value; - RaisePropertyChanged("WorkProgress"); - } - } - - /// - /// 任务栏图标状态 - /// - public System.Windows.Shell.TaskbarItemProgressState ProgressState - { - get { return model.ProgressState; } - set - { - model.ProgressState = value; - RaisePropertyChanged("ProgressState"); - } - } - /// - /// 任务栏进度 - /// - public double ProgressValue - { - get { return model.ProgressValue; } - set - { - model.ProgressValue = value; - RaisePropertyChanged("ProgressState"); - } - } } } -- Gitee From d55333418d12214c084d6cac19f70b03ed24a1ff Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E5=88=98=E7=A3=8A?= Date: Fri, 13 May 2022 21:44:27 +0800 Subject: [PATCH 6/6] =?UTF-8?q?1=E3=80=81=E4=BF=AE=E5=A4=8D=E7=B4=A2?= =?UTF-8?q?=E5=BC=95=E6=9B=B4=E6=96=B0=E9=80=BB=E8=BE=91bug=E5=AF=BC?= =?UTF-8?q?=E8=87=B4=E7=9A=84=E9=87=8D=E5=A4=8D=E7=B4=A2=E5=BC=95=202?= =?UTF-8?q?=E3=80=81=E6=9B=B4=E6=96=B0=E6=AD=A3=E5=88=99=E8=A1=A8=E8=BE=BE?= =?UTF-8?q?=E5=BC=8F=E5=88=A4=E6=96=AD=E9=80=BB=E8=BE=91?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- TextLocator/Core/AppConst.cs | 6 ++-- TextLocator/Index/IndexCore.cs | 8 +++--- TextLocator/MainWindow.xaml.cs | 38 +++++++++++--------------- TextLocator/Properties/AssemblyInfo.cs | 4 +-- 4 files changed, 25 insertions(+), 31 deletions(-) diff --git a/TextLocator/Core/AppConst.cs b/TextLocator/Core/AppConst.cs index 9fd81b1..14e97ec 100644 --- a/TextLocator/Core/AppConst.cs +++ b/TextLocator/Core/AppConst.cs @@ -85,15 +85,15 @@ namespace TextLocator.Core /// /// 匹配Lucene.NET内置关键词 /// - public static readonly Regex REGEX_BUILT_IN_SYMBOL = new Regex("AND|OR|NOT|\\&\\&|\\|\\|"); + public static readonly Regex REGEX_BUILT_IN_SYMBOL = new Regex("AND|OR|NOT|\\&\\&|\\|\\||\"|\\~|\\:"); /// /// 匹配支持的通配符 /// - public static readonly Regex REGEX_SUPPORT_WILDCARDS = new Regex("\\+|\\-|\\||\\!|\\(|\\)|\\{|\\}|\\[|\\]|\\^|\"|\\~|\\*|\\?|\\:|\\/"); + public static readonly Regex REGEX_JUDGMENT = new Regex(@"\.|\\w|\\W|\\s|\\S|\\d|\\D|\\b|\\B|\\f|\\n|\\r|\\t|\\v|\^|\$|\*|\?|\+|\-|\{|\}|\[|\]|\(|\)|\\|\||\!"); /// /// 匹配空白和换行 /// - public static readonly Regex REGEX_LINE_BREAKS_AND_WHITESPACE = new Regex(@" |\r\r|\n\n|┄|\. \. \. |\.\.\.|\s"); + public static readonly Regex REGEX_LINE_BREAKS_WHITESPACE = new Regex(@" |\r\r|\n\n|┄|\s"); /// /// 匹配HTML和XML标签 /// diff --git a/TextLocator/Index/IndexCore.cs b/TextLocator/Index/IndexCore.cs index 0ebbfc9..3cc655b 100644 --- a/TextLocator/Index/IndexCore.cs +++ b/TextLocator/Index/IndexCore.cs @@ -573,7 +573,7 @@ namespace TextLocator.Index // 文件标记 string fileMark = MD5Util.GetMD5Hash(filePath); - indexWriters[index].UpdateDocument(new Lucene.Net.Index.Term("FileMark", fileMark), doc); + indexWriters[index].UpdateDocument(new Lucene.Net.Index.Term("Id", fileMark), doc); } catch (Exception ex) { @@ -658,7 +658,7 @@ namespace TextLocator.Index bool hasContent = param.SearchRegion == SearchRegion.文件名和内容 || param.SearchRegion == SearchRegion.仅文件内容; // 3.1、---- 关键词正则 或 标记为正则 - if (AppConst.REGEX_SUPPORT_WILDCARDS.IsMatch(keyword)) + if (AppConst.REGEX_JUDGMENT.IsMatch(keyword)) { keywordType = "正则"; // 文件名搜索 @@ -888,7 +888,7 @@ namespace TextLocator.Index // 获取内容 string content = AppConst.REGEX_CONTENT_PAGE.Replace(fileInfo.Preview, ""); // 缩略信息 - string breviary = AppConst.REGEX_LINE_BREAKS_AND_WHITESPACE.Replace(content, ""); + string breviary = AppConst.REGEX_LINE_BREAKS_WHITESPACE.Replace(content, ""); int min = 0; int max = breviary.Length; @@ -920,7 +920,7 @@ namespace TextLocator.Index { if (string.IsNullOrEmpty(keyword)) continue; // 关键词是正则表达式 - if (AppConst.REGEX_SUPPORT_WILDCARDS.IsMatch(keyword)) + if (AppConst.REGEX_JUDGMENT.IsMatch(keyword)) { Regex regex = new Regex(keyword, RegexOptions.IgnoreCase); Match matches = regex.Match(content); diff --git a/TextLocator/MainWindow.xaml.cs b/TextLocator/MainWindow.xaml.cs index c1c19f2..746d58a 100644 --- a/TextLocator/MainWindow.xaml.cs +++ b/TextLocator/MainWindow.xaml.cs @@ -1314,9 +1314,6 @@ namespace TextLocator private List GetSearchTextKeywords() { string searchText = SearchText.Text.Trim(); - - // 清理特殊字符 - // 申明关键词列表 List keywords = new List(); // 为空直接返回null @@ -1325,7 +1322,7 @@ namespace TextLocator // 精确检索未选中 if (PreciseRetrieval.IsChecked == false) { - // 替换内置关键词 + // 替换内置(AND|OR|NOT|\\&\\&|\\|\\||\"|\\~|\\:)特殊字符 searchText = AppConst.REGEX_BUILT_IN_SYMBOL.Replace(searchText, " "); } @@ -1342,26 +1339,23 @@ namespace TextLocator keywords.Add(keyword); } } + // 精确检索 + else if (PreciseRetrieval.IsChecked == true) + { + keywords.Add(searchText); + } + // 正则表达式 + else if (AppConst.REGEX_JUDGMENT.IsMatch(searchText)) + { + keywords.Add(searchText); + } + // 分词器自动分词 else { - // 精确检索 - if (PreciseRetrieval.IsChecked == true) - { - keywords.Add(searchText); - } - // 通配符 || 内置字符(AND|OR|NOT) - else if (AppConst.REGEX_SUPPORT_WILDCARDS.IsMatch(searchText)) - { - keywords.Add(searchText); - } - // 分词器分词 - else - { - // 分词列表 - List segmentList = AppConst.INDEX_SEGMENTER.CutForSearch(searchText).ToList(); - // 合并关键列表 - keywords = keywords.Union(segmentList).ToList(); - } + // 分词列表 + List segmentList = AppConst.INDEX_SEGMENTER.CutForSearch(searchText).ToList(); + // 合并关键列表 + keywords = keywords.Union(segmentList).ToList(); } return keywords; } diff --git a/TextLocator/Properties/AssemblyInfo.cs b/TextLocator/Properties/AssemblyInfo.cs index 79b42ca..a777f27 100644 --- a/TextLocator/Properties/AssemblyInfo.cs +++ b/TextLocator/Properties/AssemblyInfo.cs @@ -50,9 +50,9 @@ using System.Windows; //通过使用 "*",如下所示: // [assembly: AssemblyVersion("1.0.*")] // 大版本,强制更新最小版本 -[assembly: AssemblyVersion("2.1.18")] +[assembly: AssemblyVersion("2.1.20")] // 小版本,选择更新版本 -[assembly: AssemblyFileVersion("2.1.18.1")] +[assembly: AssemblyFileVersion("2.1.20.1")] // Version minVersion = System.Reflection.Assembly.GetExecutingAssembly().GetName().Version; // Version version = new Version(FileVersionInfo.GetVersionInfo(System.Windows.Forms.Application.ExecutablePath).ProductVersion); -- Gitee