ソースを参照

ComPDFKit.Tool(win) - 优化内容编辑Path对象多选卡顿问题(待完善)

TangJinZhou 2 週間 前
コミット
777f78acc7

+ 21 - 5
Demo/Examples/ComPDFKit.Tool/CPDFViewerTool.TextEdit.cs

@@ -399,6 +399,8 @@ namespace ComPDFKit.Tool
             operateChildrenIndex = -1;
             CaretVisual caretVisual = new CaretVisual(GetDefaultDrawParam());
             customizeLayer.Children.Add(caretVisual);
+
+            MultiSelectedRect multiSelectedRect = CommonHelper.FindVisualChild<MultiSelectedRect>(PDFViewer.GetViewForTag(MultiSelectedRectViewTag));
             foreach (RenderData item in currentRenderFrame.GetRenderDatas())
             {
                 if (item.CPDFEditPageObj == null)
@@ -464,7 +466,20 @@ namespace ComPDFKit.Tool
                     selectedRect.SetRect(editAreaRect, currentZoom);
                     selectedRect.SetMaxRect(item.PageBound);
                     selectedRect.SetIgnorePointsAll();
-                    selectedRect.Draw();
+                    if ((editArea is CPDFEditPathArea))
+                    {
+                        if (multiSelectedRect.selectedRects.Count==0)
+                        {
+                            selectedRect.Draw();
+                        }
+
+                        selectedRect.IsPath = true;
+                    }
+                    else
+                    {
+                        selectedRect.Draw();
+                    }
+
                     EditAreaObject editAreaObject = new EditAreaObject();
                     editAreaObject.ControlType = PointControlType.None;
                     editAreaObject.cPDFEditArea = editArea;
@@ -2325,7 +2340,7 @@ namespace ComPDFKit.Tool
                         {
                             if ((contentEditType & CPDFEditType.EditImage) != CPDFEditType.EditImage)
                                 continue;
-                            
+
                             editAreaRect = DataConversionForWPF.CRectConversionForRect((editArea as CPDFEditImageArea).GetClipRect());
                         }
                         else if (editArea.Type == CPDFEditType.EditText)
@@ -2339,14 +2354,14 @@ namespace ComPDFKit.Tool
                         {
                             if ((contentEditType & CPDFEditType.EditPath) != CPDFEditType.EditPath)
                                 continue;
-                            
+
                             editAreaRect = DataConversionForWPF.CRectConversionForRect((editArea as CPDFEditPathArea).GetClipRect());
                         }
 
                         if (rectFrameSelect.IntersectsWith(editAreaRect))
                         {
                             SelectedRect editAreaSelectedRect = GetSelectedRectForEditAreaObject(editArea);
-                            if(editAreaSelectedRect == null && editArea is CPDFEditPathArea)
+                            if (editAreaSelectedRect == null && editArea is CPDFEditPathArea)
                             {
                                 cachePathList.Add(editArea as CPDFEditPathArea);
 
@@ -2379,6 +2394,7 @@ namespace ComPDFKit.Tool
 
                                 this.editArea.Add(editAreaSelectedRect, editAreaObjects);
                             }
+
                             SelectedRect selectedRect = new SelectedRect(GetDefaultDrawParam(), SelectedType.PDFEdit);
                             selectedRect.SetEditPen(editPen, editHoverPen);
                             multiSelectedRect.SetSelectedType(SelectedType.PDFEdit);
@@ -2418,7 +2434,7 @@ namespace ComPDFKit.Tool
 
                             multiSelectedRect.SetRect(editAreaSelectedRect.GetRect());
                             multiSelectedRect.SetMaxRect(editAreaSelectedRect.GetMaxRect());
-                            multiSelectedRect.Draw();
+                            //multiSelectedRect.Draw();
                         }
                     }
                 }

+ 3 - 12
Demo/Examples/ComPDFKit.Tool/DrawTool/MultiSelectedRect.cs

@@ -1,15 +1,9 @@
 using ComPDFKit.Tool.SettingParam;
-using ComPDFKitViewer;
 using System;
 using System.Collections.Generic;
-using System.Linq;
-using System.Reflection;
-using System.Text;
-using System.Threading.Tasks;
 using System.Windows;
 using System.Windows.Controls;
 using System.Windows.Media;
-using static ComPDFKit.Tool.Help.ImportWin32;
 
 namespace ComPDFKit.Tool.DrawTool
 {
@@ -20,7 +14,6 @@ namespace ComPDFKit.Tool.DrawTool
         Alone
     }
 
-
     public class MultiSelectedRect : DrawingVisual
     {
         /// <summary>
@@ -178,7 +171,7 @@ namespace ComPDFKit.Tool.DrawTool
         /// <summary>
         /// Array passed from outside for multiple selection
         /// </summary>
-        protected List<SelectedRect> selectedRects = new List<SelectedRect>();
+        internal List<SelectedRect> selectedRects = new List<SelectedRect>();
         protected Dictionary<SelectedRect,KeyValuePair<int,int>> RelationDict=new Dictionary<SelectedRect, KeyValuePair<int, int>>();
 
         protected bool isHover = false;
@@ -357,7 +350,6 @@ namespace ComPDFKit.Tool.DrawTool
             return (float)(drawRect.Height - drawDefaultRect.Height);
         }
 
-
         public void Draw()
         {
             switch (currentDrawType)
@@ -373,9 +365,9 @@ namespace ComPDFKit.Tool.DrawTool
                             SolidColorBrush solidColorBrush = drawParam.SPDFEditMultiRectFillBrush;
                             Pen pen = drawParam.SPDFEditMultiRectLinePen;
                             GetBrushAndPen(ref solidColorBrush, ref pen);
-                            if (selectedRects.Count >= 1)
+                            foreach (SelectedRect item in selectedRects)
                             {
-                                foreach (SelectedRect item in selectedRects)
+                                if (!item.IsPath)
                                 {
                                     Rect rect = item.GetRect();
                                     rect.X -= rectPadding;
@@ -435,7 +427,6 @@ namespace ComPDFKit.Tool.DrawTool
                             drawDC?.Close();
                             drawDC = null;
                         }
-
                     });
                     break;
                 case MulitiDrawMoveType.Alone:

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

@@ -156,6 +156,8 @@ namespace ComPDFKit.Tool.DrawTool
 
         protected Rect rotateRect = new Rect();
 
+        public bool IsPath { get; set; } = false;
+
         #endregion
 
         #region Functions