Browse Source

ComPDFKit.Tool(win) - tool层内容编辑快捷键函数名更改

liyuxuan 5 tháng trước cách đây
mục cha
commit
63e67e52a6

+ 89 - 103
Demo/Examples/ComPDFKit.Tool/CPDFViewerTool.TextEdit.cs

@@ -1443,33 +1443,26 @@ namespace ComPDFKit.Tool
             {
             {
                 return false;
                 return false;
             }
             }
-            try
-            {
-                CPDFEditArea editArea = areaObj.cPDFEditArea;
-                CRect cRect = editArea.GetFrame();
-                Rect rect = DataConversionForWPF.CRectConversionForRect(cRect);
-                Rect preRect = rect;
-                rect.X = Math.Min(pdfPage.PageSize.width - rect.Width, rect.X + moveOffset.X);
-                rect.Y = Math.Min(pdfPage.PageSize.height - rect.Height, rect.Y + moveOffset.Y);
-
-                rect.X = Math.Max(rect.X, 0);
-                rect.Y = Math.Max(rect.Y, 0);
-
-                editArea.SetFrame(DataConversionForWPF.RectConversionForCRect(rect));
-                UpdateSelectRect(editArea);
-                if ((int)preRect.Left != (int)rect.Left ||
-                    (int)preRect.Top != (int)rect.Top ||
-                    (int)preRect.Width != (int)rect.Width ||
-                    (int)preRect.Height != (int)rect.Height)
-                {
-                    PDFViewer.UpdateRenderFrame();
-                }
-                return true;
-            }
-            catch (Exception ex)
+            CPDFEditArea editArea = areaObj.cPDFEditArea;
+            CRect cRect = editArea.GetFrame();
+            Rect rect = DataConversionForWPF.CRectConversionForRect(cRect);
+            Rect preRect = rect;
+            rect.X = Math.Min(pdfPage.PageSize.width - rect.Width, rect.X + moveOffset.X);
+            rect.Y = Math.Min(pdfPage.PageSize.height - rect.Height, rect.Y + moveOffset.Y);
+
+            rect.X = Math.Max(rect.X, 0);
+            rect.Y = Math.Max(rect.Y, 0);
+
+            editArea.SetFrame(DataConversionForWPF.RectConversionForCRect(rect));
+            UpdateSelectRect(editArea);
+            if ((int)preRect.Left != (int)rect.Left ||
+                (int)preRect.Top != (int)rect.Top ||
+                (int)preRect.Width != (int)rect.Width ||
+                (int)preRect.Height != (int)rect.Height)
             {
             {
+                PDFViewer.UpdateRenderFrame();
             }
             }
-            return false;
+            return true;
         }
         }
 
 
         public void CropImage(CPDFEditImageArea cPDFEditImageArea)
         public void CropImage(CPDFEditImageArea cPDFEditImageArea)
@@ -1622,7 +1615,7 @@ namespace ComPDFKit.Tool
         /// </summary>
         /// </summary>
         /// <param name="editingLocation">Cursor position.</param>
         /// <param name="editingLocation">Cursor position.</param>
         /// <param name="isSelectRanage"> Whether to select text from the current cursor position till the end of the cursor position.</param>
         /// <param name="isSelectRanage"> Whether to select text from the current cursor position till the end of the cursor position.</param>
-        public void JumpEditingLoction(CEditingLocation editingLocation, bool isSelectRanage)
+        public void GoToEditingLoction(CEditingLocation editingLocation, bool isSelectRanage)
         {
         {
             EditAreaObject areaObj = currentEditAreaObject;
             EditAreaObject areaObj = currentEditAreaObject;
 
 
@@ -1637,97 +1630,90 @@ namespace ComPDFKit.Tool
 
 
             CPDFEditTextArea textArea = areaObj.cPDFEditArea as CPDFEditTextArea;
             CPDFEditTextArea textArea = areaObj.cPDFEditArea as CPDFEditTextArea;
 
 
-            try
+            switch (editingLocation)
             {
             {
-                switch (editingLocation)
-                {
-                    case CEditingLocation.CEditingLocationLineBegin:
-                        textArea.GetLineBeginCharPlace();
-                        break;
-                    case CEditingLocation.CEditingLoadTypeLineEnd:
-                        textArea.GetLineEndCharPlace();
-                        break;
-                    case CEditingLocation.CEditingLoadTypeSectionBegin:
-                        textArea.GetSectionBeginCharPlace();
-                        break;
-                    case CEditingLocation.CEditingLoadTypeSectionEnd:
-                        textArea.GetSectionEndCharPlace();
-                        break;
-                    case CEditingLocation.CEditingLoadTypePreWord:
-                        textArea.GetPreWordCharPlace();
-                        break;
-                    case CEditingLocation.CEditingLoadTypeNextWord:
-                        textArea.GetNextWordCharPlace();
-                        break;
-                    case CEditingLocation.CEditingLoadTypePreCharPlace:
-                        textArea.GetPrevCharPlace();
-                        break;
-                    case CEditingLocation.CEditingLoadTypeNextCharPlace:
-                        textArea.GetNextCharPlace();
-                        break;
-                    case CEditingLocation.CEditingLoadTypeUpCharPlace:
-                        textArea.GetUpCharPlace();
-                        break;
-                    case CEditingLocation.CEditingLoadTypeDownCharPlace:
-                        textArea.GetDownCharPlace();
-                        break;
-                    default:
-                        return;
-                }
+                case CEditingLocation.CEditingLocationLineBegin:
+                    textArea.GetLineBeginCharPlace();
+                    break;
+                case CEditingLocation.CEditingLoadTypeLineEnd:
+                    textArea.GetLineEndCharPlace();
+                    break;
+                case CEditingLocation.CEditingLoadTypeSectionBegin:
+                    textArea.GetSectionBeginCharPlace();
+                    break;
+                case CEditingLocation.CEditingLoadTypeSectionEnd:
+                    textArea.GetSectionEndCharPlace();
+                    break;
+                case CEditingLocation.CEditingLoadTypePreWord:
+                    textArea.GetPreWordCharPlace();
+                    break;
+                case CEditingLocation.CEditingLoadTypeNextWord:
+                    textArea.GetNextWordCharPlace();
+                    break;
+                case CEditingLocation.CEditingLoadTypePreCharPlace:
+                    textArea.GetPrevCharPlace();
+                    break;
+                case CEditingLocation.CEditingLoadTypeNextCharPlace:
+                    textArea.GetNextCharPlace();
+                    break;
+                case CEditingLocation.CEditingLoadTypeUpCharPlace:
+                    textArea.GetUpCharPlace();
+                    break;
+                case CEditingLocation.CEditingLoadTypeDownCharPlace:
+                    textArea.GetDownCharPlace();
+                    break;
+                default:
+                    return;
+            }
 
 
-                CPoint cursorPoint = new CPoint(-1, -1);
-                CPoint pointHigh = new CPoint(0, 0);
+            CPoint cursorPoint = new CPoint(-1, -1);
+            CPoint pointHigh = new CPoint(0, 0);
 
 
-                textArea.GetTextCursorPoints(ref cursorPoint, ref pointHigh);
-                textArea.ClearSelectChars();
+            textArea.GetTextCursorPoints(ref cursorPoint, ref pointHigh);
+            textArea.ClearSelectChars();
 
 
-                Rect caretRect = new Rect(new Point(cursorPoint.x, cursorPoint.y), new Point(pointHigh.x, pointHigh.y));
-                Point endPoint = DpiHelper.PDFPointToStandardPoint(new Point(caretRect.Left, (caretRect.Top + caretRect.Bottom) / 2));
-                Point startPoint = DpiHelper.PDFPointToStandardPoint(new Point(RawHitPos.x, RawHitPos.y));
+            Rect caretRect = new Rect(new Point(cursorPoint.x, cursorPoint.y), new Point(pointHigh.x, pointHigh.y));
+            Point endPoint = DpiHelper.PDFPointToStandardPoint(new Point(caretRect.Left, (caretRect.Top + caretRect.Bottom) / 2));
+            Point startPoint = DpiHelper.PDFPointToStandardPoint(new Point(RawHitPos.x, RawHitPos.y));
 
 
-                startPoint.X = startPoint.X * currentZoom;
-                startPoint.Y = startPoint.Y * currentZoom;
+            startPoint.X = startPoint.X * currentZoom;
+            startPoint.Y = startPoint.Y * currentZoom;
 
 
-                endPoint.X = endPoint.X * currentZoom;
-                endPoint.Y = endPoint.Y * currentZoom;
+            endPoint.X = endPoint.X * currentZoom;
+            endPoint.Y = endPoint.Y * currentZoom;
 
 
-                if (isSelectRanage)
-                {
-                    SelectText(textArea, startPoint, endPoint);
-                    CleanDraw();
-                }
-                else
-                {
-                    DrawCaretVisualArea(currentEditAreaObject.cPDFEditArea as CPDFEditTextArea);
-                    RawHitPos = cursorPoint;
-                }
+            if (isSelectRanage)
+            {
+                SelectText(textArea, startPoint, endPoint);
+                CleanDraw();
+            }
+            else
+            {
+                DrawCaretVisualArea(currentEditAreaObject.cPDFEditArea as CPDFEditTextArea);
+                RawHitPos = cursorPoint;
+            }
 
 
-                Point caretPoint = new Point(endPoint.X + areaObj.PageBound.Left, endPoint.Y + areaObj.PageBound.Top);
-                int direction = 1;
-                if (caretPoint.X < 0 || caretPoint.X > PDFViewer.ViewportWidth)
+            Point caretPoint = new Point(endPoint.X + areaObj.PageBound.Left, endPoint.Y + areaObj.PageBound.Top);
+            int direction = 1;
+            if (caretPoint.X < 0 || caretPoint.X > PDFViewer.ViewportWidth)
+            {
+                if (caretPoint.X < 0)
                 {
                 {
-                    if (caretPoint.X < 0)
-                    {
-                        direction = -1;
-                    }
-                    double horizontal = PDFViewer.HorizontalOffset + PDFViewer.ViewportWidth / 2 * direction;
-                    PDFViewer.SetHorizontalOffset(horizontal);
+                    direction = -1;
                 }
                 }
-                if (caretPoint.Y < 0 || caretPoint.Y > PDFViewer.ViewportHeight)
+                double horizontal = PDFViewer.HorizontalOffset + PDFViewer.ViewportWidth / 2 * direction;
+                PDFViewer.SetHorizontalOffset(horizontal);
+            }
+            if (caretPoint.Y < 0 || caretPoint.Y > PDFViewer.ViewportHeight)
+            {
+                if (caretPoint.Y < 0)
                 {
                 {
-                    if (caretPoint.Y < 0)
-                    {
-                        direction = -1;
-                    }
-                    double vertical = PDFViewer.VerticalOffset + PDFViewer.ViewportHeight / 2 * direction;
-                    PDFViewer.SetVerticalOffset(vertical);
+                    direction = -1;
                 }
                 }
-
+                double vertical = PDFViewer.VerticalOffset + PDFViewer.ViewportHeight / 2 * direction;
+                PDFViewer.SetVerticalOffset(vertical);
             }
             }
-            catch (Exception ex) 
-            {
 
 
-            }
         }
         }
     }
     }
 }
 }