Browse Source

ComPDFKit.Tool(win)-框选取消逻辑优化,对齐逻辑优化,多选增加刷新渲染逻辑

liyijie 4 months ago
parent
commit
2aa1d909fa

+ 1 - 0
Demo/Examples/ComPDFKit.Tool/CPDFToolManager.cs

@@ -2258,6 +2258,7 @@ namespace ComPDFKit.Tool
                             MultiSelectedRect multiSelectedRect = CommonHelper.FindVisualChild<MultiSelectedRect>(viewerTool.PDFViewer.GetViewForTag(viewerTool.MultiSelectedRectViewTag));
                             if (multiSelectedRect != null && multiSelectedRect.Children.Count > 0)
                             {
+                                viewerTool.PDFViewer.UpdateRenderFrame();
                                 return;
                             }
                             Point point = Mouse.GetPosition(viewerTool);

+ 39 - 6
Demo/Examples/ComPDFKit.Tool/CPDFViewerTool.TextEdit.cs

@@ -273,6 +273,7 @@ namespace ComPDFKit.Tool
                     else
                     {
                         currentEditAreaObject = item.Value;
+                        currentEditAreaObject.ControlType = PointControlType.Body;
                     }
 
                     CaretVisual caretVisual = CommonHelper.FindVisualChild<CaretVisual>(PDFViewer.GetViewForTag(textEditTag));
@@ -2728,18 +2729,34 @@ namespace ComPDFKit.Tool
             CPDFPage cPDFPage = cPDFDocument.PageAtIndex(multiPage);
             CPDFEditPage cPDFEditPage = cPDFPage.GetEditPage();
             cPDFEditPage.BeginEdit(CPDFEditType.EditText | CPDFEditType.EditImage);
-            foreach (SelectedRect item in MultiSelectEditList.Children)
+            foreach (SelectedRect item in MultiSelectEditList.GetMulitSelectList())
             {
                 Rect rect = item.GetRect();
                 rects.Add(rect);
             }
             Dictionary<Rect, Point> rectandpoint = AlignmentsHelp.SetGapDistributeHorizontal(rects, drawRect);
-            foreach (SelectedRect item in MultiSelectEditList.Children)
+            foreach (SelectedRect checkItem in MultiSelectEditList.GetMulitSelectList())
             {
+                SelectedRect item = checkItem;
+                EditAreaObject editAreaObject = GetEditAreaObjectListForRect(item);
+                if (editAreaObject == null)
+                {
+                    if (MultiSelectEditList.GetRelationKey(item, out int checkPage, out int checkEdit))
+                    {
+                        editAreaObject = GetEditAreaObjectListForIndex(checkPage, checkEdit);
+                    }
+                }
+                if (item == null)
+                {
+                    continue;
+                }
                 PDFEditHistory pDFEditHistory = new PDFEditHistory();
                 pDFEditHistory.PageIndex = multiPage;
                 pDFEditHistory.EditPage = cPDFEditPage;
-                EditAreaObject editAreaObject = GetEditAreaObjectListForRect(item);
+                if (editAreaObject == null)
+                {
+                    continue;
+                }
                 EditAreaObject newEditAreaObject = GetSelectedForIndex(multiPage, editAreaObject.EditAreaIndex);
                 Rect rect = item.GetRect();
                 item.SetRect(GetDrawAlignRect(rectandpoint[rect], rect, drawRect), currentZoom);
@@ -2775,18 +2792,34 @@ namespace ComPDFKit.Tool
             CPDFPage cPDFPage = cPDFDocument.PageAtIndex(multiPage);
             CPDFEditPage cPDFEditPage = cPDFPage.GetEditPage();
             cPDFEditPage.BeginEdit(CPDFEditType.EditText | CPDFEditType.EditImage);
-            foreach (SelectedRect item in MultiSelectEditList.Children)
+            foreach (SelectedRect item in MultiSelectEditList.GetMulitSelectList())
             {
                 Rect rect = item.GetRect();
                 rects.Add(rect);
             }
             Dictionary<Rect, Point> rectandpoint = AlignmentsHelp.SetGapDistributeVertical(rects, drawRect);
-            foreach (SelectedRect item in MultiSelectEditList.Children)
+            foreach (SelectedRect checkItem in MultiSelectEditList.GetMulitSelectList())
             {
+                SelectedRect item = checkItem;
+                EditAreaObject editAreaObject = GetEditAreaObjectListForRect(item);
+                if (editAreaObject == null)
+                {
+                    if (MultiSelectEditList.GetRelationKey(item, out int checkPage, out int checkEdit))
+                    {
+                        editAreaObject = GetEditAreaObjectListForIndex(checkPage, checkEdit);
+                    }
+                }
+                if (item == null)
+                {
+                    continue;
+                }
                 PDFEditHistory pDFEditHistory = new PDFEditHistory();
                 pDFEditHistory.PageIndex = multiPage;
                 pDFEditHistory.EditPage = cPDFEditPage;
-                EditAreaObject editAreaObject = GetEditAreaObjectListForRect(item);
+                if (editAreaObject == null)
+                {
+                    continue;
+                }
                 EditAreaObject newEditAreaObject = GetSelectedForIndex(multiPage, editAreaObject.EditAreaIndex);
                 Rect rect = item.GetRect();
                 item.SetRect(GetDrawAlignRect(rectandpoint[rect], rect, drawRect), currentZoom);

+ 2 - 0
Demo/Examples/ComPDFKit.Tool/DrawTool/FrameSelectTool.cs

@@ -208,6 +208,8 @@ namespace ComPDFKit.Tool.DrawTool
                 index = pageIndex;
                 return DpiHelper.StandardRectToPDFRect(StandardRect);
             }
+            isFrameSelect = false;
+            noDraw = false;
             return new Rect();
         }