Ver código fonte

搜索 - 优化搜索部分效果(后续仍需要优化,拖拽页面顺序后可能需要重新搜索)

ZhouJieSheng 1 ano atrás
pai
commit
b1c4a38667
1 arquivos alterados com 19 adições e 4 exclusões
  1. 19 4
      PDF Office/ViewModels/BOTA/SearchContentViewModel.cs

+ 19 - 4
PDF Office/ViewModels/BOTA/SearchContentViewModel.cs

@@ -191,7 +191,7 @@ namespace PDF_Master.ViewModels.BOTA
 
             if (CaseInsensitive)
             {
-                textSearch.SearchText(Text, C_Search_Options.Search_Case_Insensitive,viewContentViewModel.PassWord);
+                textSearch.SearchText(Text, C_Search_Options.Search_Case_Insensitive, viewContentViewModel.PassWord);
             }
             else
             {
@@ -284,7 +284,7 @@ namespace PDF_Master.ViewModels.BOTA
                             pageTextList.Add((currentItem[i] as SearchItem).TextProperty.SearchItem);
                         }
                     }
-                    if (currentItem.Count>0)
+                    if (currentItem.Count > 0)
                     {
                         PDFViewer.HighLightSearchText(pageTextList);
                     }
@@ -302,7 +302,7 @@ namespace PDF_Master.ViewModels.BOTA
 
         public void CleaSelect()
         {
-            PDFViewer.ClearPageHighLightText(new SolidColorBrush( Color.FromArgb(0x99, 0xFF, 0xF7, 0x00)));
+            PDFViewer.ClearPageHighLightText(new SolidColorBrush(Color.FromArgb(0x99, 0xFF, 0xF7, 0x00)));
         }
 
         public bool IsNavigationTarget(NavigationContext navigationContext)
@@ -312,6 +312,11 @@ namespace PDF_Master.ViewModels.BOTA
 
         public void OnNavigatedFrom(NavigationContext navigationContext)
         {
+            //切换到缩略图等模块时,需要清空搜索结果显示
+            if (SearchItemList.Count>0)
+            {
+                PDFViewer.ClearPageSelectText();
+            }
             return;
         }
 
@@ -325,7 +330,17 @@ namespace PDF_Master.ViewModels.BOTA
                 //是否使用同一个Document对象,如果传入文件路径,中间层则会自动再创建一个Document对象
                 textSearch.UsePassedDoc = true;
             }
-        
+            //如果之前已经有搜索结果,切换到搜索时,需要恢复高亮显示
+            if (SearchItemList.Count > 0)
+            {
+                List<TextSearchItem> pageTextList = new List<TextSearchItem>();
+                foreach (var item in SearchItemList)
+                {
+                    item.TextProperty.SearchItem.PaintBrush = new SolidColorBrush(Color.FromArgb(0x99, 0xFF, 0xF7, 0x00));
+                    pageTextList.Add(item.TextProperty.SearchItem);
+                }
+                PDFViewer.SetPageSelectText(pageTextList);
+            }
         }
     }
 }