|
@@ -20,9 +20,12 @@ using ComPDFKit.Tool.Help;
|
|
using ComPDFKit.Measure;
|
|
using ComPDFKit.Measure;
|
|
using System.Dynamic;
|
|
using System.Dynamic;
|
|
using System.Globalization;
|
|
using System.Globalization;
|
|
-using System.Windows.Controls;
|
|
|
|
|
|
+using ComPDFKitViewer.Layer;
|
|
using ComPDFKitViewer;
|
|
using ComPDFKitViewer;
|
|
-using System.Reflection;
|
|
|
|
|
|
+using ComPDFKitViewer.Annot;
|
|
|
|
+using System.Windows.Annotations;
|
|
|
|
+using ComPDFKit.Viewer.Annot;
|
|
|
|
+using System.Windows.Controls;
|
|
using ComPDFKit.PDFDocument.Action;
|
|
using ComPDFKit.PDFDocument.Action;
|
|
|
|
|
|
namespace ComPDFKit.Tool
|
|
namespace ComPDFKit.Tool
|
|
@@ -74,6 +77,24 @@ namespace ComPDFKit.Tool
|
|
/// </summary>
|
|
/// </summary>
|
|
private string createImagePath = string.Empty;
|
|
private string createImagePath = string.Empty;
|
|
|
|
|
|
|
|
+ private bool isActiveCropping = true;
|
|
|
|
+
|
|
|
|
+ /// <summary>
|
|
|
|
+ /// add TextEdit Cursor
|
|
|
|
+ /// </summary>
|
|
|
|
+ private Cursor addTextEditCursor = Cursors.IBeam;
|
|
|
|
+
|
|
|
|
+ /// <summary>
|
|
|
|
+ /// add ImageEdit Cursor
|
|
|
|
+ /// </summary>
|
|
|
|
+ private Cursor addImageEditCursor = Cursors.Arrow;
|
|
|
|
+
|
|
|
|
+ public bool SaveEmptyStickyAnnot { get; set; } = true;
|
|
|
|
+ public void SetActiveCropping(bool isActiveCropping)
|
|
|
|
+ {
|
|
|
|
+ this.isActiveCropping = isActiveCropping;
|
|
|
|
+ }
|
|
|
|
+
|
|
public CPDFToolManager(CPDFViewerTool cPDFTool) : base()
|
|
public CPDFToolManager(CPDFViewerTool cPDFTool) : base()
|
|
{
|
|
{
|
|
viewerTool = cPDFTool;
|
|
viewerTool = cPDFTool;
|
|
@@ -326,19 +347,17 @@ namespace ComPDFKit.Tool
|
|
default:
|
|
default:
|
|
break;
|
|
break;
|
|
}
|
|
}
|
|
|
|
+
|
|
if (oldToolType == ToolType.ContentEdit)
|
|
if (oldToolType == ToolType.ContentEdit)
|
|
{
|
|
{
|
|
- viewerTool.GetCPDFViewer().GetDocument().ReleasePages();
|
|
|
|
-
|
|
|
|
- viewerTool.GetCPDFViewer().UndoManager.RemoveRedoHistoryForType(typeof(PDFEditHistory));
|
|
|
|
- viewerTool.GetCPDFViewer().UndoManager.RemoveUndoHistoryForType(typeof(PDFEditHistory));
|
|
|
|
|
|
+ viewerTool.GetCPDFViewer().GetDocument()?.ReleasePages();
|
|
|
|
+ //Undo delete logic
|
|
|
|
+ viewerTool.GetCPDFViewer().UndoManager.ClearHistory();
|
|
|
|
+ // viewerTool.GetCPDFViewer().UndoManager.RemoveRedoHistoryForType(typeof(PDFEditHistory));
|
|
|
|
+ //viewerTool.GetCPDFViewer().UndoManager.RemoveUndoHistoryForType(typeof(PDFEditHistory));
|
|
viewerTool.GetCPDFViewer().UpdateVirtualNodes();
|
|
viewerTool.GetCPDFViewer().UpdateVirtualNodes();
|
|
viewerTool.GetCPDFViewer().UpdateRenderFrame();
|
|
viewerTool.GetCPDFViewer().UpdateRenderFrame();
|
|
}
|
|
}
|
|
- else
|
|
|
|
- {
|
|
|
|
- viewerTool.GetCPDFViewer().UpdateRenderFrame();
|
|
|
|
- }
|
|
|
|
}
|
|
}
|
|
|
|
|
|
public CPDFEditArea GetSelectedEditAreaObject(ref int pageIndex)
|
|
public CPDFEditArea GetSelectedEditAreaObject(ref int pageIndex)
|
|
@@ -355,6 +374,37 @@ namespace ComPDFKit.Tool
|
|
return editAreaObject?.cPDFEditArea;
|
|
return editAreaObject?.cPDFEditArea;
|
|
}
|
|
}
|
|
|
|
|
|
|
|
+ /// <summary>
|
|
|
|
+ /// Get the index of the multi choice comment list
|
|
|
|
+ /// </summary>
|
|
|
|
+ /// <param name="pageIndexs"></param>
|
|
|
|
+ /// <returns></returns>
|
|
|
|
+ public List<CPDFEditArea> GetSelectedEditAreaListObject(ref List<int> pageIndexs)
|
|
|
|
+ {
|
|
|
|
+ List<CPDFEditArea> editAreaObjectlist = new List<CPDFEditArea>();
|
|
|
|
+ MultiSelectedRect multiSelectedRect = CommonHelper.FindVisualChild<MultiSelectedRect>(viewerTool.PDFViewer.GetViewForTag(viewerTool.MultiSelectedRectViewTag));
|
|
|
|
+ if (multiSelectedRect != null && multiSelectedRect.Children.Count > 0)
|
|
|
|
+ {
|
|
|
|
+ foreach (SelectedRect selectedRect in multiSelectedRect.Children)
|
|
|
|
+ {
|
|
|
|
+ EditAreaObject editAreaObject = viewerTool.GetEditAreaObjectListForRect(selectedRect);
|
|
|
|
+ if (editAreaObject == null)
|
|
|
|
+ {
|
|
|
|
+ //pageIndexs.Add(-1);
|
|
|
|
+ }
|
|
|
|
+ else
|
|
|
|
+ {
|
|
|
|
+ if (!editAreaObjectlist.Contains(editAreaObject?.cPDFEditArea))
|
|
|
|
+ {
|
|
|
|
+ pageIndexs.Add(editAreaObject.PageIndex);
|
|
|
|
+ editAreaObjectlist.Add(editAreaObject?.cPDFEditArea);
|
|
|
|
+ }
|
|
|
|
+ }
|
|
|
|
+ }
|
|
|
|
+ }
|
|
|
|
+ return editAreaObjectlist;
|
|
|
|
+ }
|
|
|
|
+
|
|
public CPDFAnnotation GetCPDFAnnotation()
|
|
public CPDFAnnotation GetCPDFAnnotation()
|
|
{
|
|
{
|
|
return cPDFAnnotation;
|
|
return cPDFAnnotation;
|
|
@@ -435,20 +485,24 @@ namespace ComPDFKit.Tool
|
|
{
|
|
{
|
|
case C_ANNOTATION_TYPE.C_ANNOTATION_WIDGET:
|
|
case C_ANNOTATION_TYPE.C_ANNOTATION_WIDGET:
|
|
{
|
|
{
|
|
- currentParam = ParamConverter.WidgetConverter(viewerTool.GetCPDFViewer().GetDocument(), e.annotData.Annot);
|
|
|
|
- (e.annotData.Annot as CPDFWidget).UpdateFormAp();
|
|
|
|
- break;
|
|
|
|
|
|
+ currentParam = ParamConverter.WidgetConverter(viewerTool.GetCPDFViewer().GetDocument(), e.annotData.Annot);
|
|
|
|
+ (e.annotData.Annot as CPDFWidget).UpdateFormAp();
|
|
|
|
+ break;
|
|
}
|
|
}
|
|
|
|
|
|
default:
|
|
default:
|
|
{
|
|
{
|
|
- currentParam = ParamConverter.AnnotConverter(viewerTool.GetCPDFViewer().GetDocument(), e.annotData.Annot);
|
|
|
|
|
|
+ currentParam = ParamConverter.AnnotConverter(viewerTool.GetCPDFViewer().GetDocument(), e.annotData.Annot);
|
|
if (e.annotData.AnnotType != C_ANNOTATION_TYPE.C_ANNOTATION_SOUND)
|
|
if (e.annotData.AnnotType != C_ANNOTATION_TYPE.C_ANNOTATION_SOUND)
|
|
{
|
|
{
|
|
- e.annotData.Annot.UpdateAp();
|
|
|
|
|
|
+ e.annotData.Annot.UpdateAp();
|
|
|
|
+ if(e.annotData.Annot is CPDFTextAnnotation)
|
|
|
|
+ {
|
|
|
|
+ CommonHelper.UpdateStickyAP(e.annotData.Annot as CPDFTextAnnotation);
|
|
|
|
+ }
|
|
}
|
|
}
|
|
- break;
|
|
|
|
- }
|
|
|
|
|
|
+ break;
|
|
|
|
+ }
|
|
}
|
|
}
|
|
|
|
|
|
annotHistory.PreviousParam = previousParam;
|
|
annotHistory.PreviousParam = previousParam;
|
|
@@ -456,7 +510,7 @@ namespace ComPDFKit.Tool
|
|
annotHistory.CurrentParam = currentParam;
|
|
annotHistory.CurrentParam = currentParam;
|
|
annotHistory.Action = HistoryAction.Update;
|
|
annotHistory.Action = HistoryAction.Update;
|
|
viewerTool.GetCPDFViewer().UndoManager.AddHistory(annotHistory);
|
|
viewerTool.GetCPDFViewer().UndoManager.AddHistory(annotHistory);
|
|
- viewerTool.GetCPDFViewer().UpdateRenderFrame();
|
|
|
|
|
|
+ viewerTool.GetCPDFViewer().UpdateAnnotFrame();
|
|
AnnotDefaultEditedHandler?.Invoke(this, e);
|
|
AnnotDefaultEditedHandler?.Invoke(this, e);
|
|
}
|
|
}
|
|
|
|
|
|
@@ -488,8 +542,9 @@ namespace ComPDFKit.Tool
|
|
CPDFDocument cPDFDocument = viewerTool.GetCPDFViewer().GetDocument();
|
|
CPDFDocument cPDFDocument = viewerTool.GetCPDFViewer().GetDocument();
|
|
CPDFPage cPDFPage = cPDFDocument.PageAtIndex(e.PageIndex);
|
|
CPDFPage cPDFPage = cPDFDocument.PageAtIndex(e.PageIndex);
|
|
CPDFEditPage cPDFEditPage = cPDFPage.GetEditPage();
|
|
CPDFEditPage cPDFEditPage = cPDFPage.GetEditPage();
|
|
- cPDFEditPage.BeginEdit(CPDFEditType.EditText | CPDFEditType.EditImage);
|
|
|
|
- List<CPDFEditArea> cPDFEditAreas = cPDFEditPage.GetEditAreaList(true);
|
|
|
|
|
|
+ //cPDFEditPage.BeginEdit(CPDFEditType.EditText | CPDFEditType.EditImage);
|
|
|
|
+ List<CPDFEditArea> cPDFEditAreas = cPDFEditPage.GetEditAreaList(false);
|
|
|
|
+ float zoom = (float)viewerTool.PDFViewer.GetZoom();
|
|
for (int i = 0; i < e.MultiObjectIndex.Count; i++)
|
|
for (int i = 0; i < e.MultiObjectIndex.Count; i++)
|
|
{
|
|
{
|
|
if (e.MultiObjectIndex[i] < cPDFEditAreas.Count)
|
|
if (e.MultiObjectIndex[i] < cPDFEditAreas.Count)
|
|
@@ -498,20 +553,66 @@ namespace ComPDFKit.Tool
|
|
pDFEditHistory.PageIndex = e.PageIndex;
|
|
pDFEditHistory.PageIndex = e.PageIndex;
|
|
pDFEditHistory.EditPage = cPDFEditPage;
|
|
pDFEditHistory.EditPage = cPDFEditPage;
|
|
CRect cRect = cPDFEditAreas[e.MultiObjectIndex[i]].GetFrame();
|
|
CRect cRect = cPDFEditAreas[e.MultiObjectIndex[i]].GetFrame();
|
|
|
|
+ if (cPDFEditAreas[e.MultiObjectIndex[i]].Type == CPDFEditType.EditImage)
|
|
|
|
+ {
|
|
|
|
+ cRect = (cPDFEditAreas[e.MultiObjectIndex[i]] as CPDFEditImageArea).GetClipRect();
|
|
|
|
+ }
|
|
Point point = DpiHelper.StandardPointToPDFPoint(e.MoveOffset);
|
|
Point point = DpiHelper.StandardPointToPDFPoint(e.MoveOffset);
|
|
- cRect.left += (float)point.X;
|
|
|
|
- cRect.right += (float)point.X;
|
|
|
|
- cRect.top += (float)point.Y;
|
|
|
|
- cRect.bottom += (float)point.Y;
|
|
|
|
|
|
+ point.X = point.X / zoom;
|
|
|
|
+ point.Y = point.Y / zoom;
|
|
|
|
+ if (point.X != 0 && point.Y != 0 && e.ZoomX == 1 && e.ZoomY == 1)
|
|
|
|
+ {
|
|
|
|
+ cRect.left += (float)point.X;
|
|
|
|
+ cRect.right += (float)point.X;
|
|
|
|
+ cRect.top += (float)point.Y;
|
|
|
|
+ cRect.bottom += (float)point.Y;
|
|
|
|
+ }
|
|
|
|
+ else
|
|
|
|
+ {
|
|
|
|
+ //Mobile scaling ratio logic
|
|
|
|
+ if ((float)point.X == 0)
|
|
|
|
+ {
|
|
|
|
+ cRect.left += (float)point.X;
|
|
|
|
+ cRect.right = cRect.left + (cRect.right - cRect.left) + (float)DpiHelper.StandardNumToPDFNum(e.ChangeX) / zoom;
|
|
|
|
+ }
|
|
|
|
+ else
|
|
|
|
+ {
|
|
|
|
+ cRect.left += (float)point.X;
|
|
|
|
+ if (e.ZoomX == 1)
|
|
|
|
+ {
|
|
|
|
+ cRect.right += (float)point.X;
|
|
|
|
+ }
|
|
|
|
+ }
|
|
|
|
+ if ((float)point.Y == 0)
|
|
|
|
+ {
|
|
|
|
+ cRect.top += (float)point.Y;
|
|
|
|
+ cRect.bottom = cRect.top + (cRect.bottom - cRect.top) + (float)DpiHelper.StandardNumToPDFNum(e.ChangeY) / zoom;
|
|
|
|
+ }
|
|
|
|
+ else
|
|
|
|
+ {
|
|
|
|
|
|
- cRect.right = cRect.right * e.ZoomX;
|
|
|
|
- cRect.bottom = cRect.bottom * e.ZoomY;
|
|
|
|
|
|
+ cRect.top += (float)point.Y;
|
|
|
|
+ if (e.ZoomY == 1)
|
|
|
|
+ {
|
|
|
|
+ cRect.bottom += (float)point.Y;
|
|
|
|
+ }
|
|
|
|
+ }
|
|
|
|
+ }
|
|
|
|
+ //Original Logic
|
|
|
|
+ //cRect.left += (float)point.X;
|
|
|
|
+ //cRect.right += (float)point.X;
|
|
|
|
+ //cRect.top += (float)point.Y;
|
|
|
|
+ //cRect.bottom += (float)point.Y;
|
|
|
|
+
|
|
|
|
+ //cRect.right = cRect.right* e.ZoomX;
|
|
|
|
+ //cRect.bottom = cRect.bottom * e.ZoomY;
|
|
cPDFEditAreas[e.MultiObjectIndex[i]].SetFrame(cRect);
|
|
cPDFEditAreas[e.MultiObjectIndex[i]].SetFrame(cRect);
|
|
groupHistory.Histories.Add(pDFEditHistory);
|
|
groupHistory.Histories.Add(pDFEditHistory);
|
|
}
|
|
}
|
|
}
|
|
}
|
|
|
|
+ //Add end edit
|
|
|
|
+ cPDFEditPage.EndEdit();
|
|
viewerTool.GetCPDFViewer().UndoManager.AddHistory(groupHistory);
|
|
viewerTool.GetCPDFViewer().UndoManager.AddHistory(groupHistory);
|
|
-
|
|
|
|
viewerTool.GetCPDFViewer().UpdateRenderFrame();
|
|
viewerTool.GetCPDFViewer().UpdateRenderFrame();
|
|
}
|
|
}
|
|
|
|
|
|
@@ -546,7 +647,7 @@ namespace ComPDFKit.Tool
|
|
switch (e.annotData.AnnotType)
|
|
switch (e.annotData.AnnotType)
|
|
{
|
|
{
|
|
case C_ANNOTATION_TYPE.C_ANNOTATION_LINE:
|
|
case C_ANNOTATION_TYPE.C_ANNOTATION_LINE:
|
|
- if ((e.annotData.Annot as CPDFLineAnnotation).IsMersured())
|
|
|
|
|
|
+ if ((e.annotData.Annot as CPDFLineAnnotation).IsMeasured())
|
|
{
|
|
{
|
|
List<Point> cPoints = new List<Point>();
|
|
List<Point> cPoints = new List<Point>();
|
|
for (int i = 0; i < e.Points.Count; i++)
|
|
for (int i = 0; i < e.Points.Count; i++)
|
|
@@ -611,7 +712,7 @@ namespace ComPDFKit.Tool
|
|
}
|
|
}
|
|
lineMeasure.UpdateAnnotMeasure();
|
|
lineMeasure.UpdateAnnotMeasure();
|
|
annotLine.UpdateAp();
|
|
annotLine.UpdateAp();
|
|
- if (annotLine.IsMersured())
|
|
|
|
|
|
+ if (annotLine.IsMeasured())
|
|
{
|
|
{
|
|
PostMeasureInfo(this, annotLine);
|
|
PostMeasureInfo(this, annotLine);
|
|
}
|
|
}
|
|
@@ -661,7 +762,7 @@ namespace ComPDFKit.Tool
|
|
(float)top));
|
|
(float)top));
|
|
annotLine.GetAreaMeasure().UpdateAnnotMeasure();
|
|
annotLine.GetAreaMeasure().UpdateAnnotMeasure();
|
|
annotLine.UpdateAp();
|
|
annotLine.UpdateAp();
|
|
- if (annotLine.IsMersured())
|
|
|
|
|
|
+ if (annotLine.IsMeasured())
|
|
{
|
|
{
|
|
PostMeasureInfo(this, annotLine);
|
|
PostMeasureInfo(this, annotLine);
|
|
}
|
|
}
|
|
@@ -693,7 +794,7 @@ namespace ComPDFKit.Tool
|
|
|
|
|
|
annotLine.GetPerimeterMeasure().UpdateAnnotMeasure();
|
|
annotLine.GetPerimeterMeasure().UpdateAnnotMeasure();
|
|
annotLine.UpdateAp();
|
|
annotLine.UpdateAp();
|
|
- if (annotLine.IsMersured())
|
|
|
|
|
|
+ if (annotLine.IsMeasured())
|
|
{
|
|
{
|
|
PostMeasureInfo(this, annotLine);
|
|
PostMeasureInfo(this, annotLine);
|
|
}
|
|
}
|
|
@@ -728,7 +829,14 @@ namespace ComPDFKit.Tool
|
|
annotHistory.CurrentParam = currentParam;
|
|
annotHistory.CurrentParam = currentParam;
|
|
annotHistory.Action = HistoryAction.Update;
|
|
annotHistory.Action = HistoryAction.Update;
|
|
viewerTool.GetCPDFViewer().UndoManager.AddHistory(annotHistory);
|
|
viewerTool.GetCPDFViewer().UndoManager.AddHistory(annotHistory);
|
|
- viewerTool.GetCPDFViewer().UpdateRenderFrame();
|
|
|
|
|
|
+ if (e.annotData.Annot.IsMeasured())
|
|
|
|
+ {
|
|
|
|
+ viewerTool.GetCPDFViewer().UpdateRenderFrame();
|
|
|
|
+ }
|
|
|
|
+ else
|
|
|
|
+ {
|
|
|
|
+ viewerTool.GetCPDFViewer().UpdateAnnotFrame();
|
|
|
|
+ }
|
|
}
|
|
}
|
|
|
|
|
|
private void ViewerTool_MouseLeftButtonUpHandler(object sender, MouseEventObject e)
|
|
private void ViewerTool_MouseLeftButtonUpHandler(object sender, MouseEventObject e)
|
|
@@ -739,7 +847,7 @@ namespace ComPDFKit.Tool
|
|
viewerTool.DrawEndSelectedMultiRect();
|
|
viewerTool.DrawEndSelectedMultiRect();
|
|
viewerTool.DrawEndPageSelectedRect();
|
|
viewerTool.DrawEndPageSelectedRect();
|
|
if (currentToolType != ToolType.SelectedPage &&
|
|
if (currentToolType != ToolType.SelectedPage &&
|
|
- viewerTool.IsCanSave()&&
|
|
|
|
|
|
+ viewerTool.IsCanSave() &&
|
|
cPDFAnnotation?.Type != C_ANNOTATION_TYPE.C_ANNOTATION_FREETEXT)
|
|
cPDFAnnotation?.Type != C_ANNOTATION_TYPE.C_ANNOTATION_FREETEXT)
|
|
{
|
|
{
|
|
viewerTool.PDFViewer.EnableZoom(true);
|
|
viewerTool.PDFViewer.EnableZoom(true);
|
|
@@ -752,9 +860,9 @@ namespace ComPDFKit.Tool
|
|
{
|
|
{
|
|
viewerTool.PDFViewer.Cursor = viewerTool.Cursor = Cursors.IBeam;
|
|
viewerTool.PDFViewer.Cursor = viewerTool.Cursor = Cursors.IBeam;
|
|
}
|
|
}
|
|
- else if(currentToolType == ToolType.ContentEdit)
|
|
|
|
|
|
+ else if (currentToolType == ToolType.ContentEdit)
|
|
{
|
|
{
|
|
- if(createContentEditType == CPDFEditType.EditText)
|
|
|
|
|
|
+ if (createContentEditType == CPDFEditType.EditText)
|
|
viewerTool.PDFViewer.Cursor = viewerTool.Cursor = Cursors.IBeam;
|
|
viewerTool.PDFViewer.Cursor = viewerTool.Cursor = Cursors.IBeam;
|
|
else
|
|
else
|
|
viewerTool.PDFViewer.Cursor = viewerTool.Cursor = viewerTool.DrawMoveTest(viewerTool.GetLastSelectedRect());
|
|
viewerTool.PDFViewer.Cursor = viewerTool.Cursor = viewerTool.DrawMoveTest(viewerTool.GetLastSelectedRect());
|
|
@@ -763,7 +871,7 @@ namespace ComPDFKit.Tool
|
|
{
|
|
{
|
|
viewerTool.PDFViewer.Cursor = viewerTool.Cursor = Cursors.Arrow;
|
|
viewerTool.PDFViewer.Cursor = viewerTool.Cursor = Cursors.Arrow;
|
|
}
|
|
}
|
|
-
|
|
|
|
|
|
+
|
|
if (currentToolType == ToolType.Customize)
|
|
if (currentToolType == ToolType.Customize)
|
|
{
|
|
{
|
|
viewerTool.CleanCustomizeTool();
|
|
viewerTool.CleanCustomizeTool();
|
|
@@ -811,7 +919,7 @@ namespace ComPDFKit.Tool
|
|
annotHistory.CurrentParam = annotParam;
|
|
annotHistory.CurrentParam = annotParam;
|
|
annotHistory.PDFDoc = cPDFDocument;
|
|
annotHistory.PDFDoc = cPDFDocument;
|
|
viewerTool.GetCPDFViewer().UndoManager.AddHistory(annotHistory);
|
|
viewerTool.GetCPDFViewer().UndoManager.AddHistory(annotHistory);
|
|
- viewerTool.GetCPDFViewer().UpdateRenderFrame();
|
|
|
|
|
|
+ viewerTool.GetCPDFViewer().UpdateAnnotFrame();
|
|
e.annotType = cPDFAnnotation.Type;
|
|
e.annotType = cPDFAnnotation.Type;
|
|
e.IsCreate = true;
|
|
e.IsCreate = true;
|
|
dynamic expandData = new ExpandoObject();
|
|
dynamic expandData = new ExpandoObject();
|
|
@@ -827,7 +935,21 @@ namespace ComPDFKit.Tool
|
|
{
|
|
{
|
|
if (viewerTool.GetLastSelectedRect() != null)
|
|
if (viewerTool.GetLastSelectedRect() != null)
|
|
{
|
|
{
|
|
- viewerTool.DrawEndTextEdit(viewerTool.GetLastSelectedRect());
|
|
|
|
|
|
+ //Crop Save Processing
|
|
|
|
+ if (!viewerTool.GetIsCropMode())
|
|
|
|
+ {
|
|
|
|
+ viewerTool.DrawEndTextEdit(viewerTool.GetLastSelectedRect());
|
|
|
|
+ }
|
|
|
|
+ else
|
|
|
|
+ {
|
|
|
|
+ if (isActiveCropping)
|
|
|
|
+ {
|
|
|
|
+ CropSelectRect();
|
|
|
|
+ viewerTool.SetClipThickness();
|
|
|
|
+ }
|
|
|
|
+ //Originally saved cropping logic
|
|
|
|
+ }
|
|
|
|
+
|
|
editSelected = false;
|
|
editSelected = false;
|
|
}
|
|
}
|
|
else
|
|
else
|
|
@@ -872,10 +994,17 @@ namespace ComPDFKit.Tool
|
|
}
|
|
}
|
|
else if (createContentEditType == CPDFEditType.EditText)
|
|
else if (createContentEditType == CPDFEditType.EditText)
|
|
{
|
|
{
|
|
- e.IsCreate = viewerTool.DrawEndTest();
|
|
|
|
|
|
+ if (viewerTool.CanAddTextEdit)
|
|
|
|
+ {
|
|
|
|
+ e.IsCreate = viewerTool.DrawEndTest();
|
|
|
|
+ }
|
|
}
|
|
}
|
|
else
|
|
else
|
|
{
|
|
{
|
|
|
|
+ //Draw a box to select multiple boxes
|
|
|
|
+ Rect rectFrameSelect = viewerTool.DrawEndFrameSelect();
|
|
|
|
+ viewerTool.FrameSelectAddRect(rectFrameSelect);
|
|
|
|
+
|
|
e.IsCreate = true;
|
|
e.IsCreate = true;
|
|
}
|
|
}
|
|
}
|
|
}
|
|
@@ -898,6 +1027,25 @@ namespace ComPDFKit.Tool
|
|
}
|
|
}
|
|
}
|
|
}
|
|
|
|
|
|
|
|
+ /// <summary>
|
|
|
|
+ /// Create cropping logic
|
|
|
|
+ /// </summary>
|
|
|
|
+ public void CropSelectRect()
|
|
|
|
+ {
|
|
|
|
+ if (viewerTool.GetLastSelectedRect() != null)
|
|
|
|
+ {
|
|
|
|
+ if (viewerTool.GetIsCropMode())
|
|
|
|
+ {
|
|
|
|
+ viewerTool.DrawEndTextEdit(viewerTool.GetLastSelectedRect());
|
|
|
|
+ }
|
|
|
|
+ }
|
|
|
|
+ viewerTool.DrawEndSelectText();
|
|
|
|
+ if (viewerTool.IsCanSave())
|
|
|
|
+ {
|
|
|
|
+ cPDFAnnotation = null;
|
|
|
|
+ }
|
|
|
|
+ }
|
|
|
|
+
|
|
private void SaveCurrentAnnot()
|
|
private void SaveCurrentAnnot()
|
|
{
|
|
{
|
|
viewerTool.SetIsCanSave(true);
|
|
viewerTool.SetIsCanSave(true);
|
|
@@ -932,7 +1080,7 @@ namespace ComPDFKit.Tool
|
|
annotHistory.CurrentParam = annotParam;
|
|
annotHistory.CurrentParam = annotParam;
|
|
annotHistory.PDFDoc = cPDFDocument;
|
|
annotHistory.PDFDoc = cPDFDocument;
|
|
viewerTool.GetCPDFViewer().UndoManager.AddHistory(annotHistory);
|
|
viewerTool.GetCPDFViewer().UndoManager.AddHistory(annotHistory);
|
|
- viewerTool.GetCPDFViewer().UpdateRenderFrame();
|
|
|
|
|
|
+ viewerTool.GetCPDFViewer().UpdateAnnotFrame();
|
|
e.annotType = cPDFAnnotation.Type;
|
|
e.annotType = cPDFAnnotation.Type;
|
|
e.IsCreate = true;
|
|
e.IsCreate = true;
|
|
dynamic expandData = new ExpandoObject();
|
|
dynamic expandData = new ExpandoObject();
|
|
@@ -968,7 +1116,7 @@ namespace ComPDFKit.Tool
|
|
{
|
|
{
|
|
case C_ANNOTATION_TYPE.C_ANNOTATION_LINE:
|
|
case C_ANNOTATION_TYPE.C_ANNOTATION_LINE:
|
|
{
|
|
{
|
|
- if ((cPDFAnnotation as CPDFLineAnnotation).IsMersured())
|
|
|
|
|
|
+ if ((cPDFAnnotation as CPDFLineAnnotation).IsMeasured())
|
|
{
|
|
{
|
|
MeasureSetting measureSetting = viewerTool.GetMeasureSetting();
|
|
MeasureSetting measureSetting = viewerTool.GetMeasureSetting();
|
|
if (viewerTool.GetMoveLength() > measureSetting.MoveDetectionLength)
|
|
if (viewerTool.GetMoveLength() > measureSetting.MoveDetectionLength)
|
|
@@ -979,7 +1127,7 @@ namespace ComPDFKit.Tool
|
|
}
|
|
}
|
|
break;
|
|
break;
|
|
case C_ANNOTATION_TYPE.C_ANNOTATION_POLYGON:
|
|
case C_ANNOTATION_TYPE.C_ANNOTATION_POLYGON:
|
|
- if ((cPDFAnnotation as CPDFPolygonAnnotation).IsMersured())
|
|
|
|
|
|
+ if ((cPDFAnnotation as CPDFPolygonAnnotation).IsMeasured())
|
|
{
|
|
{
|
|
DefaultSettingParam defSetting = viewerTool.GetDefaultSettingParam();
|
|
DefaultSettingParam defSetting = viewerTool.GetDefaultSettingParam();
|
|
if (defSetting.IsCreateSquarePolygonMeasure)
|
|
if (defSetting.IsCreateSquarePolygonMeasure)
|
|
@@ -1061,7 +1209,7 @@ namespace ComPDFKit.Tool
|
|
e.IsCreate = true;
|
|
e.IsCreate = true;
|
|
e.annotType = C_ANNOTATION_TYPE.C_ANNOTATION_INK;
|
|
e.annotType = C_ANNOTATION_TYPE.C_ANNOTATION_INK;
|
|
e.Data = GetAnnotExpandObject(annotation);
|
|
e.Data = GetAnnotExpandObject(annotation);
|
|
- if (e.mouseButtonEventArgs!=null)
|
|
|
|
|
|
+ if (e.mouseButtonEventArgs != null)
|
|
{
|
|
{
|
|
MouseLeftButtonUpHandler?.Invoke(this, e);
|
|
MouseLeftButtonUpHandler?.Invoke(this, e);
|
|
}
|
|
}
|
|
@@ -1078,7 +1226,7 @@ namespace ComPDFKit.Tool
|
|
return;
|
|
return;
|
|
case C_ANNOTATION_TYPE.C_ANNOTATION_LINE:
|
|
case C_ANNOTATION_TYPE.C_ANNOTATION_LINE:
|
|
{
|
|
{
|
|
- if ((annotation as CPDFLineAnnotation).IsMersured())
|
|
|
|
|
|
+ if ((annotation as CPDFLineAnnotation).IsMeasured())
|
|
{
|
|
{
|
|
if (measurepoints.Count > 1)
|
|
if (measurepoints.Count > 1)
|
|
{
|
|
{
|
|
@@ -1122,31 +1270,52 @@ namespace ComPDFKit.Tool
|
|
break;
|
|
break;
|
|
case C_ANNOTATION_TYPE.C_ANNOTATION_POLYGON:
|
|
case C_ANNOTATION_TYPE.C_ANNOTATION_POLYGON:
|
|
{
|
|
{
|
|
- if ((annotation as CPDFPolygonAnnotation).IsMersured())
|
|
|
|
|
|
+ if (measurepoints.Count >= 3)
|
|
{
|
|
{
|
|
- List<CPoint> cPoints = new List<CPoint>();
|
|
|
|
- foreach (Point item in measurepoints)
|
|
|
|
|
|
+ if ((annotation as CPDFPolygonAnnotation).IsMeasured())
|
|
{
|
|
{
|
|
- cPoints.Add(DataConversionForWPF.PointConversionForCPoint(DpiHelper.StandardPointToPDFPoint(item)));
|
|
|
|
- }
|
|
|
|
|
|
+ List<CPoint> cPoints = new List<CPoint>();
|
|
|
|
+ foreach (Point item in measurepoints)
|
|
|
|
+ {
|
|
|
|
+ cPoints.Add(DataConversionForWPF.PointConversionForCPoint(DpiHelper.StandardPointToPDFPoint(item)));
|
|
|
|
+ }
|
|
(annotation as CPDFPolygonAnnotation).SetPoints(cPoints);
|
|
(annotation as CPDFPolygonAnnotation).SetPoints(cPoints);
|
|
- (annotation as CPDFPolygonAnnotation).GetAreaMeasure().UpdateAnnotMeasure();
|
|
|
|
- PostMeasureInfo(this, annotation);
|
|
|
|
|
|
+ (annotation as CPDFPolygonAnnotation).GetAreaMeasure().UpdateAnnotMeasure();
|
|
|
|
+ PostMeasureInfo(this, annotation);
|
|
|
|
+ }
|
|
|
|
+ }
|
|
|
|
+ else
|
|
|
|
+ {
|
|
|
|
+ annotation.RemoveAnnot();
|
|
|
|
+ annotation = null;
|
|
|
|
+ viewerTool.ClearDrawAnnot();
|
|
|
|
+ return;
|
|
}
|
|
}
|
|
|
|
+
|
|
}
|
|
}
|
|
break;
|
|
break;
|
|
case C_ANNOTATION_TYPE.C_ANNOTATION_POLYLINE:
|
|
case C_ANNOTATION_TYPE.C_ANNOTATION_POLYLINE:
|
|
{
|
|
{
|
|
- if ((annotation as CPDFPolylineAnnotation).IsMersured())
|
|
|
|
|
|
+ if(measurepoints.Count>=3)
|
|
{
|
|
{
|
|
- List<CPoint> cPoints = new List<CPoint>();
|
|
|
|
- foreach (Point item in measurepoints)
|
|
|
|
|
|
+ if ((annotation as CPDFPolylineAnnotation).IsMeasured())
|
|
{
|
|
{
|
|
- cPoints.Add(DataConversionForWPF.PointConversionForCPoint(DpiHelper.StandardPointToPDFPoint(item)));
|
|
|
|
|
|
+ List<CPoint> cPoints = new List<CPoint>();
|
|
|
|
+ foreach (Point item in measurepoints)
|
|
|
|
+ {
|
|
|
|
+ cPoints.Add(DataConversionForWPF.PointConversionForCPoint(DpiHelper.StandardPointToPDFPoint(item)));
|
|
|
|
+ }
|
|
|
|
+ (annotation as CPDFPolylineAnnotation).SetPoints(cPoints);
|
|
|
|
+ (annotation as CPDFPolylineAnnotation).GetPerimeterMeasure().UpdateAnnotMeasure();
|
|
|
|
+ PostMeasureInfo(this, annotation);
|
|
}
|
|
}
|
|
- (annotation as CPDFPolylineAnnotation).SetPoints(cPoints);
|
|
|
|
- (annotation as CPDFPolylineAnnotation).GetPerimeterMeasure().UpdateAnnotMeasure();
|
|
|
|
- PostMeasureInfo(this, annotation);
|
|
|
|
|
|
+ }
|
|
|
|
+ else
|
|
|
|
+ {
|
|
|
|
+ annotation.RemoveAnnot();
|
|
|
|
+ annotation = null;
|
|
|
|
+ viewerTool.ClearDrawAnnot();
|
|
|
|
+ return;
|
|
}
|
|
}
|
|
}
|
|
}
|
|
break;
|
|
break;
|
|
@@ -1167,6 +1336,7 @@ namespace ComPDFKit.Tool
|
|
{
|
|
{
|
|
switch (createAnnotType)
|
|
switch (createAnnotType)
|
|
{
|
|
{
|
|
|
|
+ case C_ANNOTATION_TYPE.C_ANNOTATION_LINK:
|
|
case C_ANNOTATION_TYPE.C_ANNOTATION_HIGHLIGHT:
|
|
case C_ANNOTATION_TYPE.C_ANNOTATION_HIGHLIGHT:
|
|
case C_ANNOTATION_TYPE.C_ANNOTATION_UNDERLINE:
|
|
case C_ANNOTATION_TYPE.C_ANNOTATION_UNDERLINE:
|
|
case C_ANNOTATION_TYPE.C_ANNOTATION_SQUIGGLY:
|
|
case C_ANNOTATION_TYPE.C_ANNOTATION_SQUIGGLY:
|
|
@@ -1208,7 +1378,7 @@ namespace ComPDFKit.Tool
|
|
}
|
|
}
|
|
}
|
|
}
|
|
|
|
|
|
- if(createAnnotType == C_ANNOTATION_TYPE.C_ANNOTATION_REDACT && textSelectInfo.PageSelectPointList.Count ==0)
|
|
|
|
|
|
+ if (createAnnotType == C_ANNOTATION_TYPE.C_ANNOTATION_REDACT && textSelectInfo.PageSelectPointList.Count == 0)
|
|
{
|
|
{
|
|
viewerTool.GetCPDFViewer().UpdateAnnotFrame();
|
|
viewerTool.GetCPDFViewer().UpdateAnnotFrame();
|
|
}
|
|
}
|
|
@@ -1328,7 +1498,7 @@ namespace ComPDFKit.Tool
|
|
annotation = null;
|
|
annotation = null;
|
|
return;
|
|
return;
|
|
}
|
|
}
|
|
- //CRect cRect = new CRect((float)rect.Left + annotation.GetBorderWidth(), (float)rect.Bottom - annotation.GetBorderWidth(), (float)rect.Right - annotation.GetBorderWidth(), (float)rect.Top + annotation.GetBorderWidth());
|
|
|
|
|
|
+
|
|
CRect cRect = new CRect(
|
|
CRect cRect = new CRect(
|
|
(float)rect.Left,
|
|
(float)rect.Left,
|
|
(float)rect.Bottom,
|
|
(float)rect.Bottom,
|
|
@@ -1336,7 +1506,16 @@ namespace ComPDFKit.Tool
|
|
(float)rect.Top);
|
|
(float)rect.Top);
|
|
|
|
|
|
annotation.SetRect(cRect);
|
|
annotation.SetRect(cRect);
|
|
- annotation.UpdateAp();
|
|
|
|
|
|
+ SaveSharpAnnotBoundText(annotation);
|
|
|
|
+ if (annotation.Type!=C_ANNOTATION_TYPE.C_ANNOTATION_TEXT)
|
|
|
|
+ {
|
|
|
|
+ annotation.UpdateAp();
|
|
|
|
+ }
|
|
|
|
+ else
|
|
|
|
+ {
|
|
|
|
+ CommonHelper.UpdateStickyAP(annotation as CPDFTextAnnotation);
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
|
|
AnnotHistory annotHistory = ParamConverter.CreateHistory(annotation);
|
|
AnnotHistory annotHistory = ParamConverter.CreateHistory(annotation);
|
|
if (annotHistory == null)
|
|
if (annotHistory == null)
|
|
@@ -1356,10 +1535,25 @@ namespace ComPDFKit.Tool
|
|
annotHistory.CurrentParam = currentParam;
|
|
annotHistory.CurrentParam = currentParam;
|
|
annotHistory.Action = HistoryAction.Add;
|
|
annotHistory.Action = HistoryAction.Add;
|
|
annotHistory.PDFDoc = viewerTool.PDFViewer.GetDocument();
|
|
annotHistory.PDFDoc = viewerTool.PDFViewer.GetDocument();
|
|
- viewerTool.GetCPDFViewer().UndoManager.AddHistory(annotHistory);
|
|
|
|
|
|
|
|
viewerTool.ClearDrawAnnot();
|
|
viewerTool.ClearDrawAnnot();
|
|
- viewerTool.GetCPDFViewer().UpdateRenderFrame();
|
|
|
|
|
|
+ viewerTool.GetCPDFViewer().UpdateAnnotFrame();
|
|
|
|
+ viewerTool.GetCPDFViewer().UndoManager.AddHistory(annotHistory);
|
|
|
|
+
|
|
|
|
+ if (annotation.Type == C_ANNOTATION_TYPE.C_ANNOTATION_TEXT && SaveEmptyStickyAnnot == false)
|
|
|
|
+ {
|
|
|
|
+ BaseLayer baseLayer1 = viewerTool.GetCPDFViewer().GetViewForTag(viewerTool.GetCPDFViewer().GetAnnotViewTag());
|
|
|
|
+ int checkPageIndex = currentParam.PageIndex;
|
|
|
|
+ int checkAnnotIndex = currentParam.AnnotIndex;
|
|
|
|
+ BaseAnnot selectAnnot = (baseLayer1 as AnnotLayer).GetSelectedAnnot(ref checkPageIndex, ref checkAnnotIndex);
|
|
|
|
+ if (selectAnnot != null)
|
|
|
|
+ {
|
|
|
|
+ StickyNoteAnnot stickyAnnot = selectAnnot as StickyNoteAnnot;
|
|
|
|
+ StickyNoteAnnot.StickyPopupClosed -= StickyAnnot_StickyPopupClosed;
|
|
|
|
+ StickyNoteAnnot.StickyPopupClosed += StickyAnnot_StickyPopupClosed;
|
|
|
|
+ stickyAnnot.PopStickyNote();
|
|
|
|
+ }
|
|
|
|
+ }
|
|
{
|
|
{
|
|
e.annotType = annotation.Type;
|
|
e.annotType = annotation.Type;
|
|
e.IsCreate = true;
|
|
e.IsCreate = true;
|
|
@@ -1369,9 +1563,71 @@ namespace ComPDFKit.Tool
|
|
expandData.AnnotParam = currentParam;
|
|
expandData.AnnotParam = currentParam;
|
|
e.Data = expandData;
|
|
e.Data = expandData;
|
|
}
|
|
}
|
|
|
|
+
|
|
}
|
|
}
|
|
}
|
|
}
|
|
|
|
|
|
|
|
+ private void SaveSharpAnnotBoundText(CPDFAnnotation boundAnnot)
|
|
|
|
+ {
|
|
|
|
+ if (boundAnnot == null || boundAnnot.Page == null || boundAnnot.Page.IsValid() == false)
|
|
|
|
+ {
|
|
|
|
+ return;
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ if (boundAnnot.Type != C_ANNOTATION_TYPE.C_ANNOTATION_CIRCLE && boundAnnot.Type != C_ANNOTATION_TYPE.C_ANNOTATION_SQUARE)
|
|
|
|
+ {
|
|
|
|
+ return;
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ CPDFTextPage textPage= boundAnnot.Page.GetTextPage();
|
|
|
|
+ if (textPage == null || textPage.IsValid()==false)
|
|
|
|
+ {
|
|
|
|
+ return;
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ string boundText = textPage.GetBoundedText(boundAnnot.GetRect());
|
|
|
|
+ if(string.IsNullOrEmpty(boundText)==false)
|
|
|
|
+ {
|
|
|
|
+ boundAnnot.SetContent(boundText);
|
|
|
|
+ }
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ private void StickyAnnot_StickyPopupClosed(object sender, EventArgs e)
|
|
|
|
+ {
|
|
|
|
+ StickyNoteAnnot.StickyPopupClosed -= StickyAnnot_StickyPopupClosed;
|
|
|
|
+ StickyNoteAnnot stickyAnnot = sender as StickyNoteAnnot;
|
|
|
|
+ if (stickyAnnot == null)
|
|
|
|
+ {
|
|
|
|
+ return;
|
|
|
|
+ }
|
|
|
|
+ AnnotData annotData = stickyAnnot.GetAnnotData();
|
|
|
|
+ AnnotParam currentParam = ParamConverter.AnnotConverter(viewerTool.GetCPDFViewer().GetDocument(), annotData.Annot);
|
|
|
|
+ AnnotHistory annotHistory = ParamConverter.CreateHistory(annotData.Annot);
|
|
|
|
+ string content = annotData.Annot.GetContent();
|
|
|
|
+ if (string.IsNullOrEmpty(content))
|
|
|
|
+ {
|
|
|
|
+ if (annotData.Annot.RemoveAnnot())
|
|
|
|
+ {
|
|
|
|
+ viewerTool.ClearDrawAnnot();
|
|
|
|
+ viewerTool.GetCPDFViewer().UpdateAnnotFrame();
|
|
|
|
+ viewerTool.SelectedAnnotForIndex(-1, -1);
|
|
|
|
+ annotHistory.CurrentParam = currentParam;
|
|
|
|
+ annotHistory.Action = HistoryAction.Remove;
|
|
|
|
+ annotHistory.PDFDoc = viewerTool.PDFViewer.GetDocument();
|
|
|
|
+ viewerTool.GetCPDFViewer().UndoManager.AddHistory(annotHistory);
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ return;
|
|
|
|
+ }
|
|
|
|
+ AnnotParam previousParam = ParamConverter.AnnotConverter(viewerTool.GetCPDFViewer().GetDocument(), annotData.Annot);
|
|
|
|
+ previousParam.Content = string.Empty;
|
|
|
|
+ annotHistory.PreviousParam = previousParam;
|
|
|
|
+ annotHistory.CurrentParam = currentParam;
|
|
|
|
+ annotHistory.Action = HistoryAction.Update;
|
|
|
|
+ annotHistory.PDFDoc = viewerTool.PDFViewer.GetDocument();
|
|
|
|
+ viewerTool.GetCPDFViewer().UndoManager.AddHistory(annotHistory);
|
|
|
|
+ }
|
|
|
|
+
|
|
internal void PostMeasureInfo(object sender, CPDFAnnotation rawAnnot)
|
|
internal void PostMeasureInfo(object sender, CPDFAnnotation rawAnnot)
|
|
{
|
|
{
|
|
if (rawAnnot == null)
|
|
if (rawAnnot == null)
|
|
@@ -1383,7 +1639,7 @@ namespace ComPDFKit.Tool
|
|
if (rawAnnot.Type == C_ANNOTATION_TYPE.C_ANNOTATION_LINE)
|
|
if (rawAnnot.Type == C_ANNOTATION_TYPE.C_ANNOTATION_LINE)
|
|
{
|
|
{
|
|
CPDFLineAnnotation lineAnnot = rawAnnot as CPDFLineAnnotation;
|
|
CPDFLineAnnotation lineAnnot = rawAnnot as CPDFLineAnnotation;
|
|
- if (lineAnnot.IsMersured() && lineAnnot.Points != null && lineAnnot.Points.Count() == 2)
|
|
|
|
|
|
+ if (lineAnnot.IsMeasured() && lineAnnot.Points != null && lineAnnot.Points.Count() == 2)
|
|
{
|
|
{
|
|
CPDFDistanceMeasure lineMeasure = lineAnnot.GetDistanceMeasure();
|
|
CPDFDistanceMeasure lineMeasure = lineAnnot.GetDistanceMeasure();
|
|
CPDFMeasureInfo measureInfo = lineMeasure.MeasureInfo;
|
|
CPDFMeasureInfo measureInfo = lineMeasure.MeasureInfo;
|
|
@@ -1416,7 +1672,7 @@ namespace ComPDFKit.Tool
|
|
if (rawAnnot.Type == C_ANNOTATION_TYPE.C_ANNOTATION_POLYLINE)
|
|
if (rawAnnot.Type == C_ANNOTATION_TYPE.C_ANNOTATION_POLYLINE)
|
|
{
|
|
{
|
|
CPDFPolylineAnnotation polylineAnnot = rawAnnot as CPDFPolylineAnnotation;
|
|
CPDFPolylineAnnotation polylineAnnot = rawAnnot as CPDFPolylineAnnotation;
|
|
- if (polylineAnnot.IsMersured() && polylineAnnot.Points != null && polylineAnnot.Points.Count() >= 2)
|
|
|
|
|
|
+ if (polylineAnnot.IsMeasured() && polylineAnnot.Points != null && polylineAnnot.Points.Count() >= 2)
|
|
{
|
|
{
|
|
double totalInch = 0;
|
|
double totalInch = 0;
|
|
for (int i = 0; i < polylineAnnot.Points.Count - 1; i++)
|
|
for (int i = 0; i < polylineAnnot.Points.Count - 1; i++)
|
|
@@ -1456,7 +1712,7 @@ namespace ComPDFKit.Tool
|
|
if (rawAnnot.Type == C_ANNOTATION_TYPE.C_ANNOTATION_POLYGON)
|
|
if (rawAnnot.Type == C_ANNOTATION_TYPE.C_ANNOTATION_POLYGON)
|
|
{
|
|
{
|
|
CPDFPolygonAnnotation polygonAnnot = rawAnnot as CPDFPolygonAnnotation;
|
|
CPDFPolygonAnnotation polygonAnnot = rawAnnot as CPDFPolygonAnnotation;
|
|
- if (polygonAnnot.IsMersured() && polygonAnnot.Points != null && polygonAnnot.Points.Count() >= 2)
|
|
|
|
|
|
+ if (polygonAnnot.IsMeasured() && polygonAnnot.Points != null && polygonAnnot.Points.Count() >= 2)
|
|
{
|
|
{
|
|
double totalInch = 0;
|
|
double totalInch = 0;
|
|
for (int i = 0; i < polygonAnnot.Points.Count - 1; i++)
|
|
for (int i = 0; i < polygonAnnot.Points.Count - 1; i++)
|
|
@@ -1667,7 +1923,7 @@ namespace ComPDFKit.Tool
|
|
}
|
|
}
|
|
}
|
|
}
|
|
viewerTool.ClearDrawAnnot();
|
|
viewerTool.ClearDrawAnnot();
|
|
- viewerTool.GetCPDFViewer().UpdateRenderFrame();
|
|
|
|
|
|
+ viewerTool.GetCPDFViewer().UpdateAnnotFrame();
|
|
InkAnnotHistory inkAnnotHistory = new InkAnnotHistory();
|
|
InkAnnotHistory inkAnnotHistory = new InkAnnotHistory();
|
|
AnnotParam annotParam = ParamConverter.AnnotConverter(viewerTool.PDFViewer.GetDocument(), cPDFAnnotation);
|
|
AnnotParam annotParam = ParamConverter.AnnotConverter(viewerTool.PDFViewer.GetDocument(), cPDFAnnotation);
|
|
annotParam.AnnotIndex = cPDFAnnotation.Page.GetAnnotCount() - 1;
|
|
annotParam.AnnotIndex = cPDFAnnotation.Page.GetAnnotCount() - 1;
|
|
@@ -1679,6 +1935,26 @@ namespace ComPDFKit.Tool
|
|
|
|
|
|
#endregion
|
|
#endregion
|
|
|
|
|
|
|
|
+ /// <summary>
|
|
|
|
+ /// Set mouse pattern when creating content editing
|
|
|
|
+ /// </summary>
|
|
|
|
+ /// <param name="AddTextEditCursor">add text</param>
|
|
|
|
+ /// <param name="AddImageEditCursor">add image</param>
|
|
|
|
+ public void SetAddContentEditCursor(Cursor AddTextEditCursor, Cursor AddImageEditCursor)
|
|
|
|
+ {
|
|
|
|
+ if (AddTextEditCursor == null)
|
|
|
|
+ {
|
|
|
|
+ AddTextEditCursor = Cursors.IBeam;
|
|
|
|
+ }
|
|
|
|
+ if (AddImageEditCursor == null)
|
|
|
|
+ {
|
|
|
|
+ AddImageEditCursor = Cursors.Arrow;
|
|
|
|
+ }
|
|
|
|
+ this.addTextEditCursor = AddTextEditCursor;
|
|
|
|
+ this.addImageEditCursor = AddImageEditCursor;
|
|
|
|
+
|
|
|
|
+ }
|
|
|
|
+
|
|
private void ViewerTool_MouseMoveHandler(object sender, MouseEventObject e)
|
|
private void ViewerTool_MouseMoveHandler(object sender, MouseEventObject e)
|
|
{
|
|
{
|
|
if (viewerTool == null)
|
|
if (viewerTool == null)
|
|
@@ -1733,7 +2009,7 @@ namespace ComPDFKit.Tool
|
|
if (currentToolType == ToolType.CreateAnnot)
|
|
if (currentToolType == ToolType.CreateAnnot)
|
|
{
|
|
{
|
|
if (!viewerTool.PDFViewer.GetIsShowStampMouse())
|
|
if (!viewerTool.PDFViewer.GetIsShowStampMouse())
|
|
- {
|
|
|
|
|
|
+ {
|
|
// Annotation drawing only occurs if the mouse is not set to stamp/data application mode.// Annotation drawing only occurs if the mouse is not set to stamp/data application mode.
|
|
// Annotation drawing only occurs if the mouse is not set to stamp/data application mode.// Annotation drawing only occurs if the mouse is not set to stamp/data application mode.
|
|
viewerTool.MoveDrawAnnot();
|
|
viewerTool.MoveDrawAnnot();
|
|
}
|
|
}
|
|
@@ -1793,12 +2069,14 @@ namespace ComPDFKit.Tool
|
|
if (createContentEditType != CPDFEditType.EditImage)
|
|
if (createContentEditType != CPDFEditType.EditImage)
|
|
{
|
|
{
|
|
Cursor cursor = Cursors.Arrow;
|
|
Cursor cursor = Cursors.Arrow;
|
|
|
|
+ MultiSelectedRect multiSelectedRect = CommonHelper.FindVisualChild<MultiSelectedRect>(viewerTool.PDFViewer.GetViewForTag(viewerTool.MultiSelectedRectViewTag));
|
|
|
|
+
|
|
if (viewerTool.GetLastSelectedRect() != null)
|
|
if (viewerTool.GetLastSelectedRect() != null)
|
|
{
|
|
{
|
|
if (editSelected)
|
|
if (editSelected)
|
|
{
|
|
{
|
|
viewerTool.DrawMoveTextEdit(viewerTool.GetLastSelectedRect(), clickEditSelected);
|
|
viewerTool.DrawMoveTextEdit(viewerTool.GetLastSelectedRect(), clickEditSelected);
|
|
- if(clickEditSelected)
|
|
|
|
|
|
+ if (clickEditSelected)
|
|
cursor = Cursors.IBeam;
|
|
cursor = Cursors.IBeam;
|
|
else
|
|
else
|
|
cursor = viewerTool.DrawMoveTest(viewerTool.GetLastSelectedRect());
|
|
cursor = viewerTool.DrawMoveTest(viewerTool.GetLastSelectedRect());
|
|
@@ -1810,19 +2088,60 @@ namespace ComPDFKit.Tool
|
|
}
|
|
}
|
|
else
|
|
else
|
|
{
|
|
{
|
|
- viewerTool.HideDrawSelectedMultiRect();
|
|
|
|
cursor = viewerTool.DrawMoveTest(viewerTool.GetLastSelectedRect());
|
|
cursor = viewerTool.DrawMoveTest(viewerTool.GetLastSelectedRect());
|
|
|
|
+ if (multiSelectedRect == null || multiSelectedRect.Children.Count == 0)
|
|
|
|
+ {
|
|
|
|
+ //Selection of mobile drawing logic
|
|
|
|
+ if (e.mouseButtonEventArgs.LeftButton == MouseButtonState.Pressed && createContentEditType == CPDFEditType.None)
|
|
|
|
+ {
|
|
|
|
+ viewerTool.DrawMoveFrameSelect();
|
|
|
|
+ }
|
|
|
|
+ }
|
|
|
|
+
|
|
}
|
|
}
|
|
|
|
|
|
if (cursor == Cursors.Arrow && createContentEditType == CPDFEditType.EditText)
|
|
if (cursor == Cursors.Arrow && createContentEditType == CPDFEditType.EditText)
|
|
{
|
|
{
|
|
- cursor = Cursors.IBeam;
|
|
|
|
|
|
+ cursor = addTextEditCursor;
|
|
}
|
|
}
|
|
viewerTool.Cursor = cursor;
|
|
viewerTool.Cursor = cursor;
|
|
viewerTool.PDFViewer.Cursor = cursor;
|
|
viewerTool.PDFViewer.Cursor = cursor;
|
|
}
|
|
}
|
|
else
|
|
else
|
|
{
|
|
{
|
|
|
|
+ Cursor cursor = Cursors.Arrow;
|
|
|
|
+ MultiSelectedRect multiSelectedRect = CommonHelper.FindVisualChild<MultiSelectedRect>(viewerTool.PDFViewer.GetViewForTag(viewerTool.MultiSelectedRectViewTag));
|
|
|
|
+
|
|
|
|
+ if (viewerTool.GetLastSelectedRect() != null)
|
|
|
|
+ {
|
|
|
|
+ if (editSelected)
|
|
|
|
+ {
|
|
|
|
+ viewerTool.DrawMoveTextEdit(viewerTool.GetLastSelectedRect(), clickEditSelected);
|
|
|
|
+ if (clickEditSelected)
|
|
|
|
+ cursor = Cursors.IBeam;
|
|
|
|
+ else
|
|
|
|
+ cursor = viewerTool.DrawMoveTest(viewerTool.GetLastSelectedRect());
|
|
|
|
+ }
|
|
|
|
+ else
|
|
|
|
+ {
|
|
|
|
+ cursor = viewerTool.DrawMoveTest(viewerTool.GetLastSelectedRect());
|
|
|
|
+ }
|
|
|
|
+ }
|
|
|
|
+ else
|
|
|
|
+ {
|
|
|
|
+ cursor = viewerTool.DrawMoveTest(viewerTool.GetLastSelectedRect());
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ if (cursor == Cursors.Arrow && createContentEditType == CPDFEditType.EditText)
|
|
|
|
+ {
|
|
|
|
+ cursor = Cursors.IBeam;
|
|
|
|
+ }
|
|
|
|
+ if (cursor == Cursors.Arrow && createContentEditType == CPDFEditType.EditImage)
|
|
|
|
+ {
|
|
|
|
+ cursor = addImageEditCursor;
|
|
|
|
+ }
|
|
|
|
+ viewerTool.Cursor = cursor;
|
|
|
|
+ viewerTool.PDFViewer.Cursor = cursor;
|
|
//viewerTool.Cursor = Cursors.None;
|
|
//viewerTool.Cursor = Cursors.None;
|
|
//viewerTool.PDFViewer.Cursor = Cursors.None;
|
|
//viewerTool.PDFViewer.Cursor = Cursors.None;
|
|
}
|
|
}
|
|
@@ -1882,6 +2201,7 @@ namespace ComPDFKit.Tool
|
|
viewerTool.EndDrawAnnot();
|
|
viewerTool.EndDrawAnnot();
|
|
}
|
|
}
|
|
break;
|
|
break;
|
|
|
|
+ case C_ANNOTATION_TYPE.C_ANNOTATION_LINK:
|
|
case C_ANNOTATION_TYPE.C_ANNOTATION_REDACT:
|
|
case C_ANNOTATION_TYPE.C_ANNOTATION_REDACT:
|
|
if (viewerTool.IsText())
|
|
if (viewerTool.IsText())
|
|
{
|
|
{
|
|
@@ -1896,7 +2216,7 @@ namespace ComPDFKit.Tool
|
|
CPDFLineAnnotation LineAnnotation = (cPDFAnnotation as CPDFLineAnnotation);
|
|
CPDFLineAnnotation LineAnnotation = (cPDFAnnotation as CPDFLineAnnotation);
|
|
if (LineAnnotation != null)
|
|
if (LineAnnotation != null)
|
|
{
|
|
{
|
|
- if (LineAnnotation.IsMersured())
|
|
|
|
|
|
+ if (LineAnnotation.IsMeasured())
|
|
{
|
|
{
|
|
cansave = false;
|
|
cansave = false;
|
|
}
|
|
}
|
|
@@ -1908,10 +2228,10 @@ namespace ComPDFKit.Tool
|
|
{
|
|
{
|
|
bool cansave = true;
|
|
bool cansave = true;
|
|
CPDFPolygonAnnotation PolyAnnotation = (cPDFAnnotation as CPDFPolygonAnnotation);
|
|
CPDFPolygonAnnotation PolyAnnotation = (cPDFAnnotation as CPDFPolygonAnnotation);
|
|
- PolyAnnotation?.IsMersured();
|
|
|
|
|
|
+ PolyAnnotation?.IsMeasured();
|
|
if (PolyAnnotation != null)
|
|
if (PolyAnnotation != null)
|
|
{
|
|
{
|
|
- if (PolyAnnotation.IsMersured())
|
|
|
|
|
|
+ if (PolyAnnotation.IsMeasured())
|
|
{
|
|
{
|
|
cansave = false;
|
|
cansave = false;
|
|
}
|
|
}
|
|
@@ -1923,10 +2243,10 @@ namespace ComPDFKit.Tool
|
|
{
|
|
{
|
|
bool cansave = true;
|
|
bool cansave = true;
|
|
CPDFPolylineAnnotation PolyAnnotation = (cPDFAnnotation as CPDFPolylineAnnotation);
|
|
CPDFPolylineAnnotation PolyAnnotation = (cPDFAnnotation as CPDFPolylineAnnotation);
|
|
- PolyAnnotation?.IsMersured();
|
|
|
|
|
|
+ PolyAnnotation?.IsMeasured();
|
|
if (PolyAnnotation != null)
|
|
if (PolyAnnotation != null)
|
|
{
|
|
{
|
|
- if (PolyAnnotation.IsMersured())
|
|
|
|
|
|
+ if (PolyAnnotation.IsMeasured())
|
|
{
|
|
{
|
|
cansave = false;
|
|
cansave = false;
|
|
}
|
|
}
|
|
@@ -1941,7 +2261,7 @@ namespace ComPDFKit.Tool
|
|
else
|
|
else
|
|
{
|
|
{
|
|
viewerTool.MultipleClick();
|
|
viewerTool.MultipleClick();
|
|
- e.IsDrawing=true;
|
|
|
|
|
|
+ e.IsDrawing = true;
|
|
}
|
|
}
|
|
break;
|
|
break;
|
|
case 2:
|
|
case 2:
|
|
@@ -1960,6 +2280,7 @@ namespace ComPDFKit.Tool
|
|
{
|
|
{
|
|
cPDFAnnotation = viewerTool.StartDrawWidget(createWidgetType);
|
|
cPDFAnnotation = viewerTool.StartDrawWidget(createWidgetType);
|
|
viewerTool.CreateDefaultWidget(cPDFAnnotation, createWidgetType, null);
|
|
viewerTool.CreateDefaultWidget(cPDFAnnotation, createWidgetType, null);
|
|
|
|
+ viewerTool?.InvokeWidgetCreated(cPDFAnnotation);
|
|
}
|
|
}
|
|
else if (currentToolType == ToolType.Pan || currentToolType == ToolType.Viewer)
|
|
else if (currentToolType == ToolType.Pan || currentToolType == ToolType.Viewer)
|
|
{
|
|
{
|
|
@@ -2007,7 +2328,7 @@ namespace ComPDFKit.Tool
|
|
if (list.Contains(e.annotType))
|
|
if (list.Contains(e.annotType))
|
|
{
|
|
{
|
|
viewerTool.CleanSelectedRect();
|
|
viewerTool.CleanSelectedRect();
|
|
- if (!e.IsMersured||!list.Contains(createAnnotType))
|
|
|
|
|
|
+ if (!e.IsMersured || !list.Contains(createAnnotType))
|
|
{
|
|
{
|
|
viewerTool.StartDrawEditAnnot();
|
|
viewerTool.StartDrawEditAnnot();
|
|
}
|
|
}
|
|
@@ -2045,6 +2366,15 @@ namespace ComPDFKit.Tool
|
|
clickEditSelected = true;
|
|
clickEditSelected = true;
|
|
switch ((e.mouseButtonEventArgs as MouseButtonEventArgs).ClickCount)
|
|
switch ((e.mouseButtonEventArgs as MouseButtonEventArgs).ClickCount)
|
|
{
|
|
{
|
|
|
|
+ case 1:
|
|
|
|
+ if (viewerTool.GetIsCropMode())
|
|
|
|
+ {
|
|
|
|
+ //Preconditions for determining crop acquisition points
|
|
|
|
+ viewerTool.HandleTextSelectClick(viewerTool.GetLastSelectedRect(), true);
|
|
|
|
+ clickEditSelected = false;
|
|
|
|
+ MouseLeftButtonDownHandler?.Invoke(this, e);
|
|
|
|
+ }
|
|
|
|
+ break;
|
|
case 2:
|
|
case 2:
|
|
viewerTool.HandleTextSelectClick(viewerTool.GetLastSelectedRect(), true);
|
|
viewerTool.HandleTextSelectClick(viewerTool.GetLastSelectedRect(), true);
|
|
clickEditSelected = false;
|
|
clickEditSelected = false;
|
|
@@ -2063,8 +2393,19 @@ namespace ComPDFKit.Tool
|
|
viewerTool.HideDrawSelectedMultiRect();
|
|
viewerTool.HideDrawSelectedMultiRect();
|
|
if (viewerTool.GetLastSelectedRect() != null)
|
|
if (viewerTool.GetLastSelectedRect() != null)
|
|
{
|
|
{
|
|
|
|
+ viewerTool.DrawEndFrameSelect();
|
|
Point point = Mouse.GetPosition(viewerTool);
|
|
Point point = Mouse.GetPosition(viewerTool);
|
|
- PointControlType pointControlType = viewerTool.GetLastSelectedRect().GetHitControlIndex(point);
|
|
|
|
|
|
+ PointControlType pointControlType = PointControlType.None;
|
|
|
|
+ if (viewerTool.GetIsCropMode())
|
|
|
|
+ {
|
|
|
|
+ //Crop acquisition point judgment
|
|
|
|
+ pointControlType = viewerTool.GetLastSelectedRect().GetHitCropControlIndex(point);
|
|
|
|
+ }
|
|
|
|
+ else
|
|
|
|
+ {
|
|
|
|
+ pointControlType = viewerTool.GetLastSelectedRect().GetHitControlIndex(point);
|
|
|
|
+ }
|
|
|
|
+
|
|
EditAreaObject editAreaObject = viewerTool.GetEditAreaObjectForRect(viewerTool.GetLastSelectedRect());
|
|
EditAreaObject editAreaObject = viewerTool.GetEditAreaObjectForRect(viewerTool.GetLastSelectedRect());
|
|
if (pointControlType != PointControlType.None &&
|
|
if (pointControlType != PointControlType.None &&
|
|
(editAreaObject.cPDFEditArea.Type == CPDFEditType.EditImage || pointControlType != PointControlType.Body))
|
|
(editAreaObject.cPDFEditArea.Type == CPDFEditType.EditImage || pointControlType != PointControlType.Body))
|
|
@@ -2094,12 +2435,23 @@ namespace ComPDFKit.Tool
|
|
default:
|
|
default:
|
|
break;
|
|
break;
|
|
}
|
|
}
|
|
- viewerTool.DrawStartTextEdit(viewerTool.GetLastSelectedRect());
|
|
|
|
|
|
+ if (e.mouseButtonEventArgs.LeftButton == MouseButtonState.Pressed)
|
|
|
|
+ {
|
|
|
|
+ viewerTool.DrawStartTextEdit(viewerTool.GetLastSelectedRect(), editAreaObject);
|
|
|
|
+ }
|
|
|
|
+
|
|
clickEditSelected = false;
|
|
clickEditSelected = false;
|
|
}
|
|
}
|
|
}
|
|
}
|
|
else
|
|
else
|
|
{
|
|
{
|
|
|
|
+ //If it is multiple selection, do not create a new input box
|
|
|
|
+ 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);
|
|
Point point = Mouse.GetPosition(viewerTool);
|
|
viewerTool.GetCPDFViewer().GetPointPageInfo(point, out int index, out Rect paintRect, out Rect pageBound);
|
|
viewerTool.GetCPDFViewer().GetPointPageInfo(point, out int index, out Rect paintRect, out Rect pageBound);
|
|
if (index < 0)
|
|
if (index < 0)
|
|
@@ -2109,7 +2461,18 @@ namespace ComPDFKit.Tool
|
|
}
|
|
}
|
|
if (createContentEditType == CPDFEditType.EditText)
|
|
if (createContentEditType == CPDFEditType.EditText)
|
|
{
|
|
{
|
|
- viewerTool.DrawTest(pageBound, index);
|
|
|
|
|
|
+ if (viewerTool.CanAddTextEdit)
|
|
|
|
+ {
|
|
|
|
+ viewerTool.DrawTest(pageBound, index);
|
|
|
|
+ }
|
|
|
|
+ }
|
|
|
|
+ if (createContentEditType == CPDFEditType.None)
|
|
|
|
+ {
|
|
|
|
+ viewerTool.DrawFrameSelect();
|
|
|
|
+ }
|
|
|
|
+ else
|
|
|
|
+ {
|
|
|
|
+ viewerTool.DrawEndFrameSelect();
|
|
}
|
|
}
|
|
clickEditSelected = false;
|
|
clickEditSelected = false;
|
|
}
|
|
}
|