Explorar o código

搜索-搜索选中框,高亮

zhuyi hai 1 ano
pai
achega
7ab2d8746e

+ 3 - 1
PDF Office/Model/BOTA/SearchItem.cs

@@ -1,4 +1,5 @@
-using Prism.Mvvm;
+using ComPDFKitViewer.PdfViewer;
+using Prism.Mvvm;
 using System;
 using System.Collections.Generic;
 using System.Linq;
@@ -17,6 +18,7 @@ namespace PDF_Office.Model.BOTA
         public string SearchWord { get; set; }
         public Rect TextRect { get; set; }
         public int PageRotate { get; set; }
+        public TextSearchItem SearchItem { get; set; }
 
 
         private Visibility itemVisibility;

+ 8 - 17
PDF Office/ViewModels/BOTA/SearchContentViewModel.cs

@@ -136,15 +136,8 @@ namespace PDF_Office.ViewModels.BOTA
                 List<TextSearchItem> pageTextList = new List<TextSearchItem>();
                 foreach (var item in SearchItemList)
                 {
-                    TextSearchItem textSearchItem = new TextSearchItem()
-                    {
-                        PageIndex = item.TextProperty.PageIndex,
-                        TextRect = item.TextProperty.TextRect,
-                        TextContent = item.TextProperty.TextContent,
-                        PageRotate = item.TextProperty.PageRotate
-                    };
-                    textSearchItem.PaintBrush = new SolidColorBrush(Color.FromArgb(0x99, 0xFF, 0xF7, 0x00));
-                    pageTextList.Add(textSearchItem);
+                    item.TextProperty.SearchItem.PaintBrush = new SolidColorBrush(Color.FromArgb(0x99, 0xFF, 0xF7, 0x00));
+                    pageTextList.Add(item.TextProperty.SearchItem);
                 }
                 PDFViewer.SetPageSelectText(pageTextList);
             });
@@ -166,6 +159,7 @@ namespace PDF_Office.ViewModels.BOTA
                         addItem.TextProperty.SearchWord = CurrentSearchText;
                         addItem.TextProperty.HighLightColor = Color.FromArgb(0x99, 0xFF, 0xF7, 0x00);
                         addItem.TextProperty.PageRotate = item.PageRotate;
+                        addItem.TextProperty.SearchItem = item;
                         SearchItemList.Add(addItem);
                     }
                 }
@@ -276,14 +270,11 @@ namespace PDF_Office.ViewModels.BOTA
                 if (currentItem != null && PDFViewer != null)
                 {
                     List<TextSearchItem> pageTextList = new List<TextSearchItem>();
-                    pageTextList.Add(new TextSearchItem()
-                    {
-                        PageIndex = currentItem.TextProperty.PageIndex,
-                        TextRect = currentItem.TextProperty.TextRect,
-                        TextContent = currentItem.TextProperty.TextContent,
-                        PageRotate = currentItem.TextProperty.PageRotate
-                    });
-                    PDFViewer.SetPageSelectText(pageTextList, new SolidColorBrush(Color.FromArgb(0x99, 0xFF, 0xF7, 0x00)));
+                    currentItem.TextProperty.SearchItem.BorderBrush = new SolidColorBrush(Color.FromArgb(0xFF, 0x17, 0x70, 0xF4));
+                    currentItem.TextProperty.SearchItem.Padding = 3;
+                    currentItem.TextProperty.SearchItem.BorderThickness = 1;
+                    pageTextList.Add(currentItem.TextProperty.SearchItem);
+                    PDFViewer.HighLightSearchText(pageTextList);
                 }
             }
         }

+ 1 - 0
PDF Office/Views/BOTA/SearchContent.xaml

@@ -401,6 +401,7 @@
         <Grid Grid.Row="2">
             <ListView
                 Name="SearchResultList"
+                LostFocus="SearchResultList_LostFocus"
                 BorderThickness="0"
                 ItemContainerStyle="{StaticResource ListViewItemGraySelectStyle}"
                 ItemsSource="{Binding SearchItemList}"

+ 5 - 0
PDF Office/Views/BOTA/SearchContent.xaml.cs

@@ -175,5 +175,10 @@ namespace PDF_Office.Views.BOTA
                 e.Handled = true;
             }
         }
+
+        private void SearchResultList_LostFocus(object sender, RoutedEventArgs e)
+        {
+            SearchResultList.SelectedIndex = -1;
+        }
     }
 }