Browse Source

ComPDFKit.Tool(win) - 修复内容编辑Path对象Rect太小无法选中的问题

TangJinZhou 3 months ago
parent
commit
eb5964bc1a
1 changed files with 9 additions and 10 deletions
  1. 9 10
      Demo/Examples/ComPDFKit.Tool/CPDFViewerTool.TextEdit.cs

+ 9 - 10
Demo/Examples/ComPDFKit.Tool/CPDFViewerTool.TextEdit.cs

@@ -237,11 +237,6 @@ namespace ComPDFKit.Tool
             selectedEditPageIndex = pageIndex;
             selectedEditAreaIndex = editAreaIndex;
             this.drawCaret = drawCaret;
-            //if ((pageIndex < 0 || editAreaIndex < 0) && cachePathList.Count != 0)
-            //{
-            //    cachePathList.Clear();
-            //    cachePathList = new List<CPDFEditPathArea>();
-            //}
         }
 
         /// <summary>
@@ -822,6 +817,12 @@ namespace ComPDFKit.Tool
                     CPDFEditPathArea pathArea = editArea as CPDFEditPathArea;
                     Rect rect = DataConversionForWPF.CRectConversionForRect(pathArea.GetClipRect());
                     rect = DpiHelper.PDFRectToStandardRect(rect);
+                    if(rect.Width <=1)
+                        rect.Width += 1;
+
+                    if (rect.Height <= 1)
+                        rect.Height += 1;
+
                     if (rect.Contains(pagePoint))
                     {
                         if (cachePathList.Contains(pathArea) == false)
@@ -848,7 +849,6 @@ namespace ComPDFKit.Tool
             SetPastePoint(new Point(-1, -1));
             SelectedEditAreaForIndex(-1, -1);
             Point point = Mouse.GetPosition(this);
-            //GetDrawPathList(point);
             CaretVisual caretVisual = CommonHelper.FindVisualChild<CaretVisual>(PDFViewer.GetViewForTag(textEditTag));
 
             EditAreaObject editAreaObject = null;
@@ -1047,10 +1047,6 @@ namespace ComPDFKit.Tool
                 {
                     lastSelectedRect = null;
                 }
-
-                //cachePathList.Clear();
-                //cachePathList = new List<CPDFEditPathArea>();
-                //GetDrawPathList(point);
             }
 
             if(editAreaList.Count == 0)
@@ -1552,6 +1548,9 @@ namespace ComPDFKit.Tool
             editHistory.EditPage = currentEditAreaObject.cPDFEditPage;
             editHistory.PageIndex = currentEditAreaObject.PageIndex;
             CPDFEditTextArea textArea = currentEditAreaObject.cPDFEditArea as CPDFEditTextArea;
+            if (textArea == null)
+                return;
+
             Rect OldRect = DataConversionForWPF.CRectConversionForRect(textArea.GetFrame());
             GroupHistory groupHistory = new GroupHistory();
             if (content == "\b")