|
@@ -13,8 +13,6 @@ using ComPDFKitViewer.Helper;
|
|
using ComPDFKitViewer.Layer;
|
|
using ComPDFKitViewer.Layer;
|
|
using System;
|
|
using System;
|
|
using System.Collections.Generic;
|
|
using System.Collections.Generic;
|
|
-using System.Diagnostics;
|
|
|
|
-using System.Net;
|
|
|
|
using System.Text;
|
|
using System.Text;
|
|
using System.Threading;
|
|
using System.Threading;
|
|
using System.Threading.Tasks;
|
|
using System.Threading.Tasks;
|
|
@@ -78,19 +76,19 @@ namespace ComPDFKit.Tool
|
|
/// Expend the area for taking pictures to avoid the edge of the picture not being completely covered due to accuracy
|
|
/// Expend the area for taking pictures to avoid the edge of the picture not being completely covered due to accuracy
|
|
/// </summary>
|
|
/// </summary>
|
|
private double editPadding = 5;
|
|
private double editPadding = 5;
|
|
- Point pointtest;
|
|
|
|
- int pageindex;
|
|
|
|
|
|
+ private Point pointtest;
|
|
|
|
+ private int pageindex;
|
|
private SelectedRect lastSelectedRect = null;
|
|
private SelectedRect lastSelectedRect = null;
|
|
private SelectedRect lastHoverRect = null;
|
|
private SelectedRect lastHoverRect = null;
|
|
private int cropIndex = -1;
|
|
private int cropIndex = -1;
|
|
private int textEditTag = -1;
|
|
private int textEditTag = -1;
|
|
private double currentZoom;
|
|
private double currentZoom;
|
|
private EditAreaObject currentEditAreaObject = null;
|
|
private EditAreaObject currentEditAreaObject = null;
|
|
- int selectedEditPageIndex = -1;
|
|
|
|
- bool drawCaret = true;
|
|
|
|
- int selectedEditAreaIndex = -1;
|
|
|
|
- bool selectAllCharsForLine = false;
|
|
|
|
- private CPoint RawHitPos { get; set; }
|
|
|
|
|
|
+ private int selectedEditPageIndex = -1;
|
|
|
|
+ private bool drawCaret = true;
|
|
|
|
+ private int selectedEditAreaIndex = -1;
|
|
|
|
+ private bool selectAllCharsForLine = false;
|
|
|
|
+ private CPoint rawHitPos;
|
|
private CPDFEditType contentEditType = CPDFEditType.EditText | CPDFEditType.EditImage;
|
|
private CPDFEditType contentEditType = CPDFEditType.EditText | CPDFEditType.EditImage;
|
|
|
|
|
|
/// <summary>
|
|
/// <summary>
|
|
@@ -677,7 +675,7 @@ namespace ComPDFKit.Tool
|
|
|
|
|
|
Point clickPoint = new Point((point.X - editObject.PageBound.X) / currentZoom, (point.Y - editObject.PageBound.Y) / currentZoom);
|
|
Point clickPoint = new Point((point.X - editObject.PageBound.X) / currentZoom, (point.Y - editObject.PageBound.Y) / currentZoom);
|
|
Point rawPoint= DpiHelper.StandardPointToPDFPoint(clickPoint);
|
|
Point rawPoint= DpiHelper.StandardPointToPDFPoint(clickPoint);
|
|
- RawHitPos = new CPoint((float)rawPoint.X, (float)rawPoint.Y);
|
|
|
|
|
|
+ rawHitPos = new CPoint((float)rawPoint.X, (float)rawPoint.Y);
|
|
}
|
|
}
|
|
else
|
|
else
|
|
{
|
|
{
|
|
@@ -1151,30 +1149,32 @@ namespace ComPDFKit.Tool
|
|
DrawCaretVisualArea(textArea);
|
|
DrawCaretVisualArea(textArea);
|
|
}
|
|
}
|
|
|
|
|
|
- public void UpdateRender(Rect OldRect, CPDFEditArea NewTextArea)
|
|
|
|
|
|
+ public void UpdateRender(Rect oldRect, CPDFEditArea newTextArea)
|
|
{
|
|
{
|
|
if (currentEditAreaObject == null)
|
|
if (currentEditAreaObject == null)
|
|
{
|
|
{
|
|
return;
|
|
return;
|
|
}
|
|
}
|
|
- if (NewTextArea == null)
|
|
|
|
|
|
+
|
|
|
|
+ if (newTextArea == null)
|
|
{
|
|
{
|
|
return;
|
|
return;
|
|
}
|
|
}
|
|
|
|
+
|
|
Dictionary<int, Rect> keyValuePairs = new Dictionary<int, Rect>();
|
|
Dictionary<int, Rect> keyValuePairs = new Dictionary<int, Rect>();
|
|
- Rect NewRect = DataConversionForWPF.CRectConversionForRect(NewTextArea.GetFrame());
|
|
|
|
|
|
+ Rect NewRect = DataConversionForWPF.CRectConversionForRect(newTextArea.GetFrame());
|
|
|
|
|
|
// Calculate the rectangle
|
|
// Calculate the rectangle
|
|
- OldRect.Union(NewRect);
|
|
|
|
- OldRect.X = OldRect.X - editPadding;
|
|
|
|
- OldRect.Y = OldRect.Y - editPadding;
|
|
|
|
- OldRect.Width = OldRect.Width + editPadding * 2;
|
|
|
|
- OldRect.Height = OldRect.Height + editPadding * 2;
|
|
|
|
|
|
+ oldRect.Union(NewRect);
|
|
|
|
+ oldRect.X = oldRect.X - editPadding;
|
|
|
|
+ oldRect.Y = oldRect.Y - editPadding;
|
|
|
|
+ oldRect.Width = oldRect.Width + editPadding * 2;
|
|
|
|
+ oldRect.Height = oldRect.Height + editPadding * 2;
|
|
|
|
|
|
var e = editArea.GetEnumerator();
|
|
var e = editArea.GetEnumerator();
|
|
while (e.MoveNext())
|
|
while (e.MoveNext())
|
|
{
|
|
{
|
|
- if (e.Current.Value.cPDFEditArea.Equals(NewTextArea))
|
|
|
|
|
|
+ if (e.Current.Value.cPDFEditArea.Equals(newTextArea))
|
|
{
|
|
{
|
|
currentEditAreaObject = e.Current.Value;
|
|
currentEditAreaObject = e.Current.Value;
|
|
}
|
|
}
|
|
@@ -1184,19 +1184,18 @@ namespace ComPDFKit.Tool
|
|
Rect paintRect = currentEditAreaObject.PaintRect;
|
|
Rect paintRect = currentEditAreaObject.PaintRect;
|
|
Rect zoomPDFPaintRect = new Rect((paintRect.X - currentEditAreaObject.PageBound.X) / currentZoom, (paintRect.Y - currentEditAreaObject.PageBound.Y) / currentZoom, paintRect.Width / currentZoom, paintRect.Height / currentZoom);
|
|
Rect zoomPDFPaintRect = new Rect((paintRect.X - currentEditAreaObject.PageBound.X) / currentZoom, (paintRect.Y - currentEditAreaObject.PageBound.Y) / currentZoom, paintRect.Width / currentZoom, paintRect.Height / currentZoom);
|
|
paintRect = DpiHelper.StandardRectToPDFRect(zoomPDFPaintRect);
|
|
paintRect = DpiHelper.StandardRectToPDFRect(zoomPDFPaintRect);
|
|
- OldRect.Intersect(paintRect);
|
|
|
|
|
|
+ oldRect.Intersect(paintRect);
|
|
|
|
|
|
- keyValuePairs.Add(currentEditAreaObject.PageIndex, OldRect);
|
|
|
|
|
|
+ keyValuePairs.Add(currentEditAreaObject.PageIndex, oldRect);
|
|
DrawUpdateText(keyValuePairs, currentEditAreaObject.PageBound);
|
|
DrawUpdateText(keyValuePairs, currentEditAreaObject.PageBound);
|
|
- UpdateSelectRect(NewTextArea);
|
|
|
|
- if (NewTextArea.Type == CPDFEditType.EditText)
|
|
|
|
|
|
+ UpdateSelectRect(newTextArea);
|
|
|
|
+ if (newTextArea.Type == CPDFEditType.EditText)
|
|
{
|
|
{
|
|
- DrawCaretVisualArea(NewTextArea as CPDFEditTextArea);
|
|
|
|
|
|
+ DrawCaretVisualArea(newTextArea as CPDFEditTextArea);
|
|
}
|
|
}
|
|
- return;
|
|
|
|
}
|
|
}
|
|
|
|
|
|
- public void DrawTest(Rect MaxRect, int index)
|
|
|
|
|
|
+ public void DrawTest(Rect maxRect, int index)
|
|
{
|
|
{
|
|
SelectedRect selectedRect = new SelectedRect(GetDefaultDrawParam(), SelectedType.PDFEdit);
|
|
SelectedRect selectedRect = new SelectedRect(GetDefaultDrawParam(), SelectedType.PDFEdit);
|
|
selectedRect.SetDrawMoveType(DrawMoveType.kReferenceLine);
|
|
selectedRect.SetDrawMoveType(DrawMoveType.kReferenceLine);
|
|
@@ -1207,7 +1206,7 @@ namespace ComPDFKit.Tool
|
|
pointtest = Mouse.GetPosition(this);
|
|
pointtest = Mouse.GetPosition(this);
|
|
selectedRect.SetIgnorePointsAll();
|
|
selectedRect.SetIgnorePointsAll();
|
|
selectedRect.SetRect(new Rect(pointtest.X, pointtest.Y, 0, 0), currentZoom);
|
|
selectedRect.SetRect(new Rect(pointtest.X, pointtest.Y, 0, 0), currentZoom);
|
|
- selectedRect.SetMaxRect(MaxRect);
|
|
|
|
|
|
+ selectedRect.SetMaxRect(maxRect);
|
|
selectedRect.Draw();
|
|
selectedRect.Draw();
|
|
pageindex = index;
|
|
pageindex = index;
|
|
}
|
|
}
|
|
@@ -1310,7 +1309,7 @@ namespace ComPDFKit.Tool
|
|
return cursor;
|
|
return cursor;
|
|
}
|
|
}
|
|
|
|
|
|
- private Cursor GetCursors(PointControlType controlType, bool IsImage)
|
|
|
|
|
|
+ private Cursor GetCursors(PointControlType controlType, bool isImage)
|
|
{
|
|
{
|
|
switch (controlType)
|
|
switch (controlType)
|
|
{
|
|
{
|
|
@@ -1331,7 +1330,7 @@ namespace ComPDFKit.Tool
|
|
return Cursors.SizeNS;
|
|
return Cursors.SizeNS;
|
|
|
|
|
|
case PointControlType.Body:
|
|
case PointControlType.Body:
|
|
- if (IsImage)
|
|
|
|
|
|
+ if (isImage)
|
|
{
|
|
{
|
|
return Cursors.SizeAll;
|
|
return Cursors.SizeAll;
|
|
}
|
|
}
|
|
@@ -1519,16 +1518,16 @@ namespace ComPDFKit.Tool
|
|
/// <summary>
|
|
/// <summary>
|
|
/// Select text
|
|
/// Select text
|
|
/// </summary>
|
|
/// </summary>
|
|
- private void SelectText(CPDFEditTextArea textArea, Point StartPoint, Point EndPoint)
|
|
|
|
|
|
+ private void SelectText(CPDFEditTextArea textArea, Point startPoint, Point endPoint)
|
|
{
|
|
{
|
|
- Point zoomStartPoint = new Point(StartPoint.X / currentZoom, StartPoint.Y / currentZoom);
|
|
|
|
- Point zoomEndPoint = new Point(EndPoint.X / currentZoom, EndPoint.Y / currentZoom);
|
|
|
|
- Point startPoint = DpiHelper.StandardPointToPDFPoint(zoomStartPoint);
|
|
|
|
- Point endPoint = DpiHelper.StandardPointToPDFPoint(zoomEndPoint);
|
|
|
|
|
|
+ Point zoomStartPoint = new Point(startPoint.X / currentZoom, startPoint.Y / currentZoom);
|
|
|
|
+ Point zoomEndPoint = new Point(endPoint.X / currentZoom, endPoint.Y / currentZoom);
|
|
|
|
+ Point start_point = DpiHelper.StandardPointToPDFPoint(zoomStartPoint);
|
|
|
|
+ Point end_point = DpiHelper.StandardPointToPDFPoint(zoomEndPoint);
|
|
textArea.ClearSelectChars();
|
|
textArea.ClearSelectChars();
|
|
textArea.GetSelectChars(
|
|
textArea.GetSelectChars(
|
|
- DataConversionForWPF.PointConversionForCPoint(startPoint),
|
|
|
|
- DataConversionForWPF.PointConversionForCPoint(endPoint)
|
|
|
|
|
|
+ DataConversionForWPF.PointConversionForCPoint(start_point),
|
|
|
|
+ DataConversionForWPF.PointConversionForCPoint(end_point)
|
|
);
|
|
);
|
|
|
|
|
|
CaretVisual caretVisual = CommonHelper.FindVisualChild<CaretVisual>(PDFViewer.GetViewForTag(textEditTag));
|
|
CaretVisual caretVisual = CommonHelper.FindVisualChild<CaretVisual>(PDFViewer.GetViewForTag(textEditTag));
|
|
@@ -1539,6 +1538,7 @@ namespace ComPDFKit.Tool
|
|
DataConversionForWPF.CRectConversionForRect(item)
|
|
DataConversionForWPF.CRectConversionForRect(item)
|
|
);
|
|
);
|
|
}
|
|
}
|
|
|
|
+
|
|
caretVisual.SetSelectRect(SelectLineRects);
|
|
caretVisual.SetSelectRect(SelectLineRects);
|
|
caretVisual.Draw(true);
|
|
caretVisual.Draw(true);
|
|
}
|
|
}
|
|
@@ -1547,7 +1547,7 @@ namespace ComPDFKit.Tool
|
|
/// Draw the cursor to the specified text block position immediately
|
|
/// Draw the cursor to the specified text block position immediately
|
|
/// </summary>
|
|
/// </summary>
|
|
/// <param name="textArea"></param>
|
|
/// <param name="textArea"></param>
|
|
- private void DrawCaretVisualArea(CPDFEditTextArea textArea, bool DrawCaret = true)
|
|
|
|
|
|
+ private void DrawCaretVisualArea(CPDFEditTextArea textArea, bool drawCaret = true)
|
|
{
|
|
{
|
|
if (textArea == null)
|
|
if (textArea == null)
|
|
{
|
|
{
|
|
@@ -1556,7 +1556,7 @@ namespace ComPDFKit.Tool
|
|
CPoint cursorCPoint = new CPoint(0, 0);
|
|
CPoint cursorCPoint = new CPoint(0, 0);
|
|
CPoint highCpoint = new CPoint(0, 0);
|
|
CPoint highCpoint = new CPoint(0, 0);
|
|
textArea.GetTextCursorPoints(ref cursorCPoint, ref highCpoint);
|
|
textArea.GetTextCursorPoints(ref cursorCPoint, ref highCpoint);
|
|
- RawHitPos = cursorCPoint;
|
|
|
|
|
|
+ rawHitPos = cursorCPoint;
|
|
CaretVisual caretVisual = CommonHelper.FindVisualChild<CaretVisual>(PDFViewer.GetViewForTag(textEditTag));
|
|
CaretVisual caretVisual = CommonHelper.FindVisualChild<CaretVisual>(PDFViewer.GetViewForTag(textEditTag));
|
|
|
|
|
|
Point cursorPoint = DataConversionForWPF.CPointConversionForPoint(cursorCPoint);
|
|
Point cursorPoint = DataConversionForWPF.CPointConversionForPoint(cursorCPoint);
|
|
@@ -1582,8 +1582,8 @@ namespace ComPDFKit.Tool
|
|
}
|
|
}
|
|
else
|
|
else
|
|
{
|
|
{
|
|
- caretVisual.Draw(true, DrawCaret);
|
|
|
|
- if (DrawCaret)
|
|
|
|
|
|
+ caretVisual.Draw(true, drawCaret);
|
|
|
|
+ if (drawCaret)
|
|
{
|
|
{
|
|
Point HeightPoint = caretVisual.GetCaretHighPoint();
|
|
Point HeightPoint = caretVisual.GetCaretHighPoint();
|
|
Point caretPos = new Point(
|
|
Point caretPos = new Point(
|
|
@@ -1674,7 +1674,7 @@ namespace ComPDFKit.Tool
|
|
|
|
|
|
Rect caretRect = new Rect(new Point(cursorPoint.x, cursorPoint.y), new Point(pointHigh.x, pointHigh.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 endPoint = DpiHelper.PDFPointToStandardPoint(new Point(caretRect.Left, (caretRect.Top + caretRect.Bottom) / 2));
|
|
- Point startPoint = DpiHelper.PDFPointToStandardPoint(new Point(RawHitPos.x, RawHitPos.y));
|
|
|
|
|
|
+ Point startPoint = DpiHelper.PDFPointToStandardPoint(new Point(rawHitPos.x, rawHitPos.y));
|
|
|
|
|
|
startPoint.X = startPoint.X * currentZoom;
|
|
startPoint.X = startPoint.X * currentZoom;
|
|
startPoint.Y = startPoint.Y * currentZoom;
|
|
startPoint.Y = startPoint.Y * currentZoom;
|
|
@@ -1690,7 +1690,7 @@ namespace ComPDFKit.Tool
|
|
else
|
|
else
|
|
{
|
|
{
|
|
DrawCaretVisualArea(currentEditAreaObject.cPDFEditArea as CPDFEditTextArea);
|
|
DrawCaretVisualArea(currentEditAreaObject.cPDFEditArea as CPDFEditTextArea);
|
|
- RawHitPos = cursorPoint;
|
|
|
|
|
|
+ rawHitPos = cursorPoint;
|
|
}
|
|
}
|
|
|
|
|
|
Point caretPoint = new Point(endPoint.X + areaObj.PageBound.Left, endPoint.Y + areaObj.PageBound.Top);
|
|
Point caretPoint = new Point(endPoint.X + areaObj.PageBound.Left, endPoint.Y + areaObj.PageBound.Top);
|