diff --git a/ComPDFKit for Windows/Examples/Annotations/Annotations.csproj b/ComPDFKit for Windows/Examples/Annotations/Annotations.csproj
index 2f2b190..2245277 100644
--- a/ComPDFKit for Windows/Examples/Annotations/Annotations.csproj
+++ b/ComPDFKit for Windows/Examples/Annotations/Annotations.csproj
@@ -41,11 +41,11 @@
ComPDFKit_Logo.ico
-
- ..\packages\ComPDFKit.NetFramework.2.1.3\lib\ComPDFKit.NET.dll
+
+ ..\packages\ComPDFKit.NetFramework.2.2.0\lib\ComPDFKit.NET.dll
-
- ..\packages\ComPDFKit.NetFramework.2.1.3\lib\ComPDFKit.Viewer.dll
+
+ ..\packages\ComPDFKit.NetFramework.2.2.0\lib\ComPDFKit.Viewer.dll
..\packages\PresentationFramework.Aero2.1.0.1\lib\PresentationFramework.Aero2.dll
@@ -93,7 +93,6 @@
ResXFileCodeGenerator
Resources.Designer.cs
- Designer
@@ -124,11 +123,11 @@
-
+
This project references NuGet package(s) that are missing on this computer. Use NuGet Package Restore to download them. For more information, see http://go.microsoft.com/fwlink/?LinkID=322105. The missing file is {0}.
-
+
\ No newline at end of file
diff --git a/ComPDFKit for Windows/Examples/Annotations/Properties/AssemblyInfo.cs b/ComPDFKit for Windows/Examples/Annotations/Properties/AssemblyInfo.cs
index 114956e..4fdc626 100644
--- a/ComPDFKit for Windows/Examples/Annotations/Properties/AssemblyInfo.cs
+++ b/ComPDFKit for Windows/Examples/Annotations/Properties/AssemblyInfo.cs
@@ -51,5 +51,5 @@
// You can specify all the values or you can default the Build and Revision Numbers
// by using the '*' as shown below:
// [assembly: AssemblyVersion("1.0.*")]
-[assembly: AssemblyVersion("2.1.3.0")]
-[assembly: AssemblyFileVersion("2.1.3.0")]
\ No newline at end of file
+[assembly: AssemblyVersion("2.2.0.0")]
+[assembly: AssemblyFileVersion("2.2.0.0")]
\ No newline at end of file
diff --git a/ComPDFKit for Windows/Examples/Annotations/packages.config b/ComPDFKit for Windows/Examples/Annotations/packages.config
index 5f51c51..ee67883 100644
--- a/ComPDFKit for Windows/Examples/Annotations/packages.config
+++ b/ComPDFKit for Windows/Examples/Annotations/packages.config
@@ -1,5 +1,5 @@
-
+
\ No newline at end of file
diff --git a/ComPDFKit for Windows/Examples/ComPDFKit.Tool/CPDFToolManager.cs b/ComPDFKit for Windows/Examples/ComPDFKit.Tool/CPDFToolManager.cs
index 180bb9b..9eb3f46 100644
--- a/ComPDFKit for Windows/Examples/ComPDFKit.Tool/CPDFToolManager.cs
+++ b/ComPDFKit for Windows/Examples/ComPDFKit.Tool/CPDFToolManager.cs
@@ -20,6 +20,9 @@
using ComPDFKit.Measure;
using System.Dynamic;
using System.Globalization;
+using ComPDFKitViewer.Layer;
+using ComPDFKitViewer;
+using ComPDFKitViewer.Annot;
namespace ComPDFKit.Tool
{
@@ -82,6 +85,7 @@ public class CPDFToolManager
///
private Cursor addImageEditCursor = Cursors.Arrow;
+ public bool SaveEmptyStickyAnnot { get; set; } = true;
public void SetActiveCropping(bool isActiveCropping)
{
this.isActiveCropping = isActiveCropping;
@@ -264,12 +268,12 @@ public bool SetCreateContentEditType(CPDFEditType editType)
createContentEditType = editType;
return true;
}
+
public CPDFEditType GetCreateContentEditType()
{
return createContentEditType;
}
-
public void ClearSelect()
{
/// Clear some UI effects of other modules
@@ -340,13 +344,11 @@ public void SetToolType(ToolType toolType)
break;
}
- if (oldToolType == ToolType.ContentEdit)
+ if (oldToolType == ToolType.ContentEdit || currentToolType == ToolType.ContentEdit)
{
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().UpdateRenderFrame();
}
@@ -468,9 +470,19 @@ private void ViewerTool_SelectedDataChanged(object sender, DrawTool.SelectedAnno
e.Square.Width / e.annotData.CurrentZoom,
e.Square.Height / e.annotData.CurrentZoom
);
+
Rect rect = DpiHelper.StandardRectToPDFRect(rect1);
CRect cRect = new CRect((float)rect.Left, (float)rect.Bottom, (float)rect.Right, (float)rect.Top);
- e.annotData.Annot.SetRect(cRect);
+ if (e.annotData.AnnotType == C_ANNOTATION_TYPE.C_ANNOTATION_STAMP)
+ {
+ CPDFStampAnnotation stampAnnot = e.annotData.Annot as CPDFStampAnnotation;
+ stampAnnot.SetSourceRect(cRect);
+ stampAnnot.AnnotationRotator.SetRotation(-e.rotationAngle);
+ }
+ else
+ {
+ e.annotData.Annot.SetRect(cRect);
+ }
}
switch (e.annotData.AnnotType)
@@ -488,6 +500,10 @@ private void ViewerTool_SelectedDataChanged(object sender, DrawTool.SelectedAnno
if (e.annotData.AnnotType != C_ANNOTATION_TYPE.C_ANNOTATION_SOUND)
{
e.annotData.Annot.UpdateAp();
+ if (e.annotData.Annot is CPDFTextAnnotation)
+ {
+ CommonHelper.UpdateStickyAP(e.annotData.Annot as CPDFTextAnnotation);
+ }
}
break;
}
@@ -530,7 +546,6 @@ private void SaveToMulitChanged(MultiSelectedData e)
CPDFDocument cPDFDocument = viewerTool.GetCPDFViewer().GetDocument();
CPDFPage cPDFPage = cPDFDocument.PageAtIndex(e.PageIndex);
CPDFEditPage cPDFEditPage = cPDFPage.GetEditPage();
- //cPDFEditPage.BeginEdit(CPDFEditType.EditText | CPDFEditType.EditImage);
List cPDFEditAreas = cPDFEditPage.GetEditAreaList(false);
float zoom = (float)viewerTool.PDFViewer.GetZoom();
for (int i = 0; i < e.MultiObjectIndex.Count; i++)
@@ -640,7 +655,6 @@ private void ViewerTool_AnnotEditDataChanged(object sender, SelectedAnnotData e)
List cPoints = new List();
for (int i = 0; i < e.Points.Count; i++)
{
-
Point cPoint = new Point((float)((e.Points[i].X - e.annotData.PaintOffset.X) / e.annotData.CurrentZoom),
(float)((e.Points[i].Y - e.annotData.PaintOffset.Y) / e.annotData.CurrentZoom));
cPoints.Add(cPoint);
@@ -683,27 +697,28 @@ private void ViewerTool_AnnotEditDataChanged(object sender, SelectedAnnotData e)
{
lineMeasure.SetLeadLength(-(float)saveLength);
}
+
if (lineCenterPoint.Y > crossCenterPoint.Y)
{
lineMeasure.SetLeadLength((float)saveLength);
}
+
if (lineCenterPoint.Y == crossCenterPoint.Y)
{
if (lineCenterPoint.X > crossCenterPoint.X)
{
lineMeasure.SetLeadLength(-(float)saveLength);
}
+
if (lineCenterPoint.X < crossCenterPoint.X)
{
lineMeasure.SetLeadLength((float)saveLength);
}
}
- lineMeasure.UpdateAnnotMeasure();
+
annotLine.UpdateAp();
- if (annotLine.IsMeasured())
- {
- PostMeasureInfo(this, annotLine);
- }
+ lineMeasure.UpdateAnnotMeasure();
+ PostMeasureInfo(this, annotLine);
}
else
{
@@ -734,25 +749,24 @@ private void ViewerTool_AnnotEditDataChanged(object sender, SelectedAnnotData e)
(float)((e.Points[i].Y - e.annotData.PaintOffset.Y) / e.annotData.CurrentZoom));
cPoints.Add(DataConversionForWPF.PointConversionForCPoint(DpiHelper.StandardPointToPDFPoint(cPoint)));
}
- CPDFPolygonAnnotation annotLine = (e.annotData.Annot as CPDFPolygonAnnotation);
-
- annotLine.SetPoints(cPoints);
+ CPDFPolygonAnnotation polygonAnnot = (e.annotData.Annot as CPDFPolygonAnnotation);
+ polygonAnnot.SetPoints(cPoints);
double left = cPoints.AsEnumerable().Select(x => x.x).Min();
double right = cPoints.AsEnumerable().Select(x => x.x).Max();
double top = cPoints.AsEnumerable().Select(x => x.y).Min();
double bottom = cPoints.AsEnumerable().Select(x => x.y).Max();
-
- annotLine.SetRect(new CRect(
+ polygonAnnot.SetRect(new CRect(
(float)left,
(float)bottom,
(float)right,
(float)top));
- annotLine.GetAreaMeasure().UpdateAnnotMeasure();
- annotLine.UpdateAp();
- if (annotLine.IsMeasured())
+
+ polygonAnnot.UpdateAp();
+ if (polygonAnnot.IsMeasured())
{
- PostMeasureInfo(this, annotLine);
+ polygonAnnot.GetAreaMeasure().UpdateAnnotMeasure();
+ PostMeasureInfo(this, polygonAnnot);
}
}
break;
@@ -765,26 +779,24 @@ private void ViewerTool_AnnotEditDataChanged(object sender, SelectedAnnotData e)
(float)((e.Points[i].Y - e.annotData.PaintOffset.Y) / e.annotData.CurrentZoom));
cPoints.Add(DataConversionForWPF.PointConversionForCPoint(DpiHelper.StandardPointToPDFPoint(cPoint)));
}
- CPDFPolylineAnnotation annotLine = (e.annotData.Annot as CPDFPolylineAnnotation);
-
- annotLine.SetPoints(cPoints);
+ CPDFPolylineAnnotation polylineAnnot = (e.annotData.Annot as CPDFPolylineAnnotation);
+ polylineAnnot.SetPoints(cPoints);
double left = cPoints.AsEnumerable().Select(x => x.x).Min();
double right = cPoints.AsEnumerable().Select(x => x.x).Max();
double top = cPoints.AsEnumerable().Select(x => x.y).Min();
double bottom = cPoints.AsEnumerable().Select(x => x.y).Max();
-
- annotLine.SetRect(new CRect(
+ polylineAnnot.SetRect(new CRect(
(float)left,
(float)bottom,
(float)right,
(float)top));
- annotLine.GetPerimeterMeasure().UpdateAnnotMeasure();
- annotLine.UpdateAp();
- if (annotLine.IsMeasured())
+ polylineAnnot.UpdateAp();
+ if (polylineAnnot.IsMeasured())
{
- PostMeasureInfo(this, annotLine);
+ polylineAnnot.GetPerimeterMeasure().UpdateAnnotMeasure();
+ PostMeasureInfo(this, polylineAnnot);
}
}
break;
@@ -817,14 +829,7 @@ private void ViewerTool_AnnotEditDataChanged(object sender, SelectedAnnotData e)
annotHistory.CurrentParam = currentParam;
annotHistory.Action = HistoryAction.Update;
viewerTool.GetCPDFViewer().UndoManager.AddHistory(annotHistory);
- if (e.annotData.Annot.IsMeasured())
- {
- viewerTool.GetCPDFViewer().UpdateRenderFrame();
- }
- else
- {
- viewerTool.GetCPDFViewer().UpdateAnnotFrame();
- }
+ viewerTool.GetCPDFViewer().UpdateAnnotFrame();
}
private void ViewerTool_MouseLeftButtonUpHandler(object sender, MouseEventObject e)
@@ -868,11 +873,11 @@ private void ViewerTool_MouseLeftButtonUpHandler(object sender, MouseEventObject
if (e.hitTestType == MouseHitTestType.SelectRect)
{
List list = new List()
- {
- C_ANNOTATION_TYPE.C_ANNOTATION_LINE,
- C_ANNOTATION_TYPE.C_ANNOTATION_POLYLINE,
- C_ANNOTATION_TYPE.C_ANNOTATION_POLYGON,
- };
+ {
+ C_ANNOTATION_TYPE.C_ANNOTATION_LINE,
+ C_ANNOTATION_TYPE.C_ANNOTATION_POLYLINE,
+ C_ANNOTATION_TYPE.C_ANNOTATION_POLYGON,
+ };
if (list.Contains(e.annotType))
{
viewerTool.DrawEndEditAnnot();
@@ -984,7 +989,7 @@ private void ViewerTool_MouseLeftButtonUpHandler(object sender, MouseEventObject
{
if (viewerTool.CanAddTextEdit)
{
- e.IsCreate = viewerTool.DrawEndTest();
+ e.IsCreate = viewerTool.DrawEndTest();
}
}
else
@@ -1093,8 +1098,7 @@ private void SaveCurrentAnnot()
}
}
- #region MouseLeftButtonUpCreateAnnot
-
+ #region MouseLeftButtonUpCreateAnnot
private void CreateAnnotTypeMouseLeftUp(ref MouseEventObject e)
{
//Mersured
@@ -1115,7 +1119,7 @@ private void CreateAnnotTypeMouseLeftUp(ref MouseEventObject e)
}
break;
case C_ANNOTATION_TYPE.C_ANNOTATION_POLYGON:
- if ((cPDFAnnotation as CPDFPolygonAnnotation).IsMeasured())
+ // if ((cPDFAnnotation as CPDFPolygonAnnotation).IsMeasured())
{
DefaultSettingParam defSetting = viewerTool.GetDefaultSettingParam();
if (defSetting.IsCreateSquarePolygonMeasure)
@@ -1143,11 +1147,20 @@ private void CreateAnnotTypeMouseLeftUp(ref MouseEventObject e)
private void SaveCreateAnnotation(ref CPDFAnnotation annotation, ref MouseEventObject e)
{
+
if (annotation == null)
{
return;
}
+ if (!annotation.IsValid())
+ {
+ annotation.RemoveAnnot();
+ annotation = null;
+
+ return;
+ }
+
Point StartPoint = viewerTool.GetStartPoint();
Point EndPoint = viewerTool.GetEndPoint();
List points = viewerTool.GetInkDrawPoints();
@@ -1156,6 +1169,8 @@ private void SaveCreateAnnotation(ref CPDFAnnotation annotation, ref MouseEventO
annotation.SetModifyDate(PDFHelp.GetCurrentPdfTime());
Rect rect = viewerTool.EndDrawAnnot();
+
+
if (annotation != null)
{
switch (annotation.Type)
@@ -1226,14 +1241,14 @@ private void SaveCreateAnnotation(ref CPDFAnnotation annotation, ref MouseEventO
break;
case C_ANNOTATION_TYPE.C_ANNOTATION_POLYGON:
{
+ List cPoints = new List();
+ foreach (Point item in measurepoints)
+ {
+ cPoints.Add(DataConversionForWPF.PointConversionForCPoint(DpiHelper.StandardPointToPDFPoint(item)));
+ }
+ (annotation as CPDFPolygonAnnotation).SetPoints(cPoints);
if ((annotation as CPDFPolygonAnnotation).IsMeasured())
{
- List cPoints = new List();
- foreach (Point item in measurepoints)
- {
- cPoints.Add(DataConversionForWPF.PointConversionForCPoint(DpiHelper.StandardPointToPDFPoint(item)));
- }
- (annotation as CPDFPolygonAnnotation).SetPoints(cPoints);
(annotation as CPDFPolygonAnnotation).GetAreaMeasure().UpdateAnnotMeasure();
PostMeasureInfo(this, annotation);
}
@@ -1271,6 +1286,7 @@ private void SaveCreateAnnotation(ref CPDFAnnotation annotation, ref MouseEventO
{
switch (createAnnotType)
{
+ case C_ANNOTATION_TYPE.C_ANNOTATION_LINK:
case C_ANNOTATION_TYPE.C_ANNOTATION_HIGHLIGHT:
case C_ANNOTATION_TYPE.C_ANNOTATION_UNDERLINE:
case C_ANNOTATION_TYPE.C_ANNOTATION_SQUIGGLY:
@@ -1316,6 +1332,12 @@ private void SaveCreateAnnotation(ref CPDFAnnotation annotation, ref MouseEventO
{
viewerTool.GetCPDFViewer().UpdateAnnotFrame();
}
+ else if (createAnnotType == C_ANNOTATION_TYPE.C_ANNOTATION_HIGHLIGHT && textSelectInfo.PageSelectPointList.Count == 0)
+ {
+ bool isA = annotation.RemoveAnnot();
+ annotation = null;
+ return;
+ }
}
break;
case C_ANNOTATION_TYPE.C_ANNOTATION_STAMP:
@@ -1353,19 +1375,32 @@ private void SaveCreateAnnotation(ref CPDFAnnotation annotation, ref MouseEventO
(mousePoint.Y - pageBound.Y + (cropPoint.Y * viewerTool.GetCPDFViewer().GetZoom())) / viewerTool.GetCPDFViewer().GetZoom(),
stampRect.Width, stampRect.Height)
);
+
+ if (annotation.Page.Rotation % 2 != 0)
+ {
+ PDFRect = RotateRect90(PDFRect);
+ }
+
CRect cStampRect = new CRect((float)PDFRect.Left, (float)PDFRect.Bottom, (float)PDFRect.Right, (float)PDFRect.Top);
- annotation.SetRect(cStampRect);
+ annotation.SetSourceRect(cStampRect);
+ (annotation as CPDFStampAnnotation).AnnotationRotator.SetRotation(annotation.Page.Rotation * 90);
annotation.UpdateAp();
e.IsCreate = true;
e.annotType = C_ANNOTATION_TYPE.C_ANNOTATION_STAMP;
e.Data = GetAnnotExpandObject(annotation);
- StampAnnotHistory freeTextAnnotHistory = new StampAnnotHistory();
- AnnotParam annotParam = ParamConverter.AnnotConverter(viewerTool.GetCPDFViewer().GetDocument(), annotation);
+ StampAnnotHistory stampAnnotHistory = new StampAnnotHistory();
+ StampParam annotParam = ParamConverter.AnnotConverter(viewerTool.GetCPDFViewer().GetDocument(), annotation) as StampParam;
+ if (annotParam.StampType == C_STAMP_TYPE.IMAGE_STAMP)
+ {
+ annotParam.CopyImageAnnot = CPDFAnnotation.CopyAnnot(annotation);
+ }
+
annotParam.AnnotIndex = annotation.Page.GetAnnotCount() - 1;
- freeTextAnnotHistory.CurrentParam = (StampParam)annotParam;
- freeTextAnnotHistory.PDFDoc = viewerTool.GetCPDFViewer().GetDocument();
- viewerTool.GetCPDFViewer().UndoManager.AddHistory(freeTextAnnotHistory);
+ stampAnnotHistory.CurrentParam = annotParam;
+ stampAnnotHistory.PDFDoc = viewerTool.GetCPDFViewer().GetDocument();
+ viewerTool.GetCPDFViewer().UndoManager.AddHistory(stampAnnotHistory);
}
+
viewerTool.GetCPDFViewer().UpdateAnnotFrame();
}
break;
@@ -1419,7 +1454,7 @@ private void SaveCreateAnnotation(ref CPDFAnnotation annotation, ref MouseEventO
annotation = null;
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(
(float)rect.Left,
(float)rect.Bottom,
@@ -1427,13 +1462,23 @@ private void SaveCreateAnnotation(ref CPDFAnnotation annotation, ref MouseEventO
(float)rect.Top);
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);
if (annotHistory == null)
{
return;
}
+
AnnotParam currentParam;
switch (annotation.Type)
{
@@ -1447,10 +1492,25 @@ private void SaveCreateAnnotation(ref CPDFAnnotation annotation, ref MouseEventO
annotHistory.CurrentParam = currentParam;
annotHistory.Action = HistoryAction.Add;
annotHistory.PDFDoc = viewerTool.PDFViewer.GetDocument();
- viewerTool.GetCPDFViewer().UndoManager.AddHistory(annotHistory);
viewerTool.ClearDrawAnnot();
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;
@@ -1461,9 +1521,71 @@ private void SaveCreateAnnotation(ref CPDFAnnotation annotation, ref MouseEventO
expandData.AnnotParam = currentParam;
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)
{
if (rawAnnot == null)
@@ -1921,10 +2043,13 @@ private void ViewerTool_MouseMoveHandler(object sender, MouseEventObject e)
{
cursor = viewerTool.DrawMoveTest(viewerTool.GetLastSelectedRect());
}
+
}
else
{
+
cursor = viewerTool.DrawMoveTest(viewerTool.GetLastSelectedRect());
+
if (multiSelectedRect == null || multiSelectedRect.Children.Count == 0)
{
//Selection of mobile drawing logic
@@ -1933,7 +2058,6 @@ private void ViewerTool_MouseMoveHandler(object sender, MouseEventObject e)
viewerTool.DrawMoveFrameSelect();
}
}
-
}
if (cursor == Cursors.Arrow && createContentEditType == CPDFEditType.EditText)
@@ -1942,12 +2066,12 @@ private void ViewerTool_MouseMoveHandler(object sender, MouseEventObject e)
}
viewerTool.Cursor = cursor;
viewerTool.PDFViewer.Cursor = cursor;
+
}
else
{
Cursor cursor = Cursors.Arrow;
MultiSelectedRect multiSelectedRect = CommonHelper.FindVisualChild(viewerTool.PDFViewer.GetViewForTag(viewerTool.MultiSelectedRectViewTag));
-
if (viewerTool.GetLastSelectedRect() != null)
{
if (editSelected)
@@ -2019,6 +2143,7 @@ private void ViewerTool_MouseLeftButtonDownHandler(object sender, MouseEventObje
viewerTool.EndDrawAnnot();
}
break;
+ case C_ANNOTATION_TYPE.C_ANNOTATION_LINK:
case C_ANNOTATION_TYPE.C_ANNOTATION_REDACT:
if (viewerTool.IsText())
{
@@ -2045,13 +2170,9 @@ private void ViewerTool_MouseLeftButtonDownHandler(object sender, MouseEventObje
{
bool cansave = true;
CPDFPolygonAnnotation PolyAnnotation = (cPDFAnnotation as CPDFPolygonAnnotation);
- PolyAnnotation?.IsMeasured();
if (PolyAnnotation != null)
{
- if (PolyAnnotation.IsMeasured())
- {
- cansave = false;
- }
+ cansave = false;
}
viewerTool.SetIsCanSave(cansave);
}
@@ -2086,17 +2207,19 @@ private void ViewerTool_MouseLeftButtonDownHandler(object sender, MouseEventObje
{
if (!viewerTool.IsCanSave())
{
- viewerTool.SetIsCanSave(true);
+ BaseLayer baseLayer = viewerTool.PDFViewer.GetViewForTag(viewerTool.CreateAnnotTag);
+ bool canSave = (baseLayer as CreateAnnotTool).IsCanSave();
+ viewerTool.SetIsCanSave(canSave);
}
}
break;
}
-
}
else if (currentToolType == ToolType.WidgetEdit)
{
cPDFAnnotation = viewerTool.StartDrawWidget(createWidgetType);
viewerTool.CreateDefaultWidget(cPDFAnnotation, createWidgetType, null);
+ viewerTool?.InvokeWidgetCreated(cPDFAnnotation);
}
else if (currentToolType == ToolType.Pan || currentToolType == ToolType.Viewer)
{
@@ -2151,11 +2274,14 @@ private void ViewerTool_MouseLeftButtonDownHandler(object sender, MouseEventObje
}
else
{
- viewerTool.CleanEditAnnot();
- viewerTool.DrawStartSelectedRect();
- if (currentToolType == ToolType.WidgetEdit)
+ if (currentToolType != ToolType.Viewer)
{
- viewerTool.MoveDrawWidget(true);
+ viewerTool.CleanEditAnnot();
+ viewerTool.DrawStartSelectedRect();
+ if (currentToolType == ToolType.WidgetEdit)
+ {
+ viewerTool.MoveDrawWidget(true);
+ }
}
}
}
@@ -2224,7 +2350,7 @@ private void ViewerTool_MouseLeftButtonDownHandler(object sender, MouseEventObje
EditAreaObject editAreaObject = viewerTool.GetEditAreaObjectForRect(viewerTool.GetLastSelectedRect());
if (pointControlType != PointControlType.None &&
- (editAreaObject.cPDFEditArea.Type == CPDFEditType.EditImage || pointControlType != PointControlType.Body))
+ (editAreaObject.cPDFEditArea.Type != CPDFEditType.EditText || pointControlType != PointControlType.Body))
{
switch (pointControlType)
{
@@ -2240,7 +2366,7 @@ private void ViewerTool_MouseLeftButtonDownHandler(object sender, MouseEventObje
case PointControlType.RightTop:
viewerTool.PDFViewer.Cursor = viewerTool.Cursor = Cursors.SizeNESW;
break;
- case PointControlType.MiddlBottom:
+ case PointControlType.MiddleBottom:
case PointControlType.MiddleTop:
viewerTool.PDFViewer.Cursor = viewerTool.Cursor = Cursors.SizeNS;
break;
@@ -2265,7 +2391,6 @@ private void ViewerTool_MouseLeftButtonDownHandler(object sender, MouseEventObje
MultiSelectedRect multiSelectedRect = CommonHelper.FindVisualChild(viewerTool.PDFViewer.GetViewForTag(viewerTool.MultiSelectedRectViewTag));
if (multiSelectedRect != null && multiSelectedRect.Children.Count > 0)
{
- viewerTool.PDFViewer.UpdateRenderFrame();
return;
}
Point point = Mouse.GetPosition(viewerTool);
@@ -2297,6 +2422,7 @@ private void ViewerTool_MouseLeftButtonDownHandler(object sender, MouseEventObje
default:
break;
}
+
MouseLeftButtonDownHandler?.Invoke(this, e);
}
@@ -2309,5 +2435,19 @@ private void ViewerTool_MouseRightButtonDownHandler(object sender, MouseEventObj
MouseRightButtonDownHandler?.Invoke(sender, e);
}
+
+ private Rect RotateRect90(Rect rect)
+ {
+ double centerX = rect.Left + rect.Width / 2;
+ double centerY = rect.Top + rect.Height / 2;
+
+ double newWidth = rect.Height;
+ double newHeight = rect.Width;
+
+ double newLeft = centerX - newWidth / 2.0;
+ double newTop = centerY - newHeight / 2.0;
+
+ return new Rect(newLeft, newTop, newWidth, newHeight);
+ }
}
}
diff --git a/ComPDFKit for Windows/Examples/ComPDFKit.Tool/CPDFViewerTool.Annot.cs b/ComPDFKit for Windows/Examples/ComPDFKit.Tool/CPDFViewerTool.Annot.cs
index b26d869..a8ae21b 100644
--- a/ComPDFKit for Windows/Examples/ComPDFKit.Tool/CPDFViewerTool.Annot.cs
+++ b/ComPDFKit for Windows/Examples/ComPDFKit.Tool/CPDFViewerTool.Annot.cs
@@ -10,8 +10,6 @@
using System;
using System.Collections.Generic;
using System.Linq;
-using System.Text;
-using System.Threading.Tasks;
using System.Windows.Input;
using System.Windows;
using ComPDFKit.Import;
@@ -20,12 +18,9 @@
using System.Windows.Media;
using static ComPDFKit.PDFAnnotation.CTextAttribute.CFontNameHelper;
using ComPDFKitViewer.Helper;
-using Microsoft.SqlServer.Server;
using ComPDFKit.Tool.Help;
-using System.Xml.Linq;
using ComPDFKit.Tool.SettingParam;
using ComPDFKit.Tool.UndoManger;
-using System.Windows.Controls.Primitives;
using ComPDFKit.Measure;
using System.Dynamic;
@@ -53,13 +48,14 @@ public partial class CPDFViewerTool
BaseAnnot caheMoveAnnot;
BaseAnnot cacheHitTestAnnot;
bool isCacheRedaction = false;
- int createAnnotTag = -1;
int selectedPageIndex = -1;
int selectedAnnotIndex = -1;
bool canSave = true;
bool isHitTestLink = false;
bool isHitTestRedact = false;
+
public event EventHandler MeasureChanged;
+ internal int CreateAnnotTag { get; private set; } = -1;
public void InvokeMeasureChangeEvent(object sender, MeasureEventArgs e)
{
@@ -135,11 +131,15 @@ protected bool AnnotHitTest()
cacheHitTestAnnot = null;
return false;
}
+
cacheHitTestAnnot = baseAnnot;
return true;
}
- cacheHitTestAnnot = baseAnnot;
- return false;
+ else
+ {
+ cacheHitTestAnnot = null;
+ return false;
+ }
}
public void SelectedAnnotForIndex(int pageIndex, int annotIndex)
@@ -166,7 +166,7 @@ private void InsertAnnotView()
CreateAnnotTool createAnnotTool = new CreateAnnotTool(GetMeasureSetting(), GetDefaultDrawParam(), GetDefaultSettingParam());
int annotViewindex = PDFViewer.GetMaxViewIndex();
PDFViewer.InsertView(annotViewindex, createAnnotTool);
- createAnnotTag = createAnnotTool.GetResTag();
+ CreateAnnotTag = createAnnotTool.GetResTag();
createAnnotTool.UpdateAnnotHandler += CreateAnnotTool_UpdateAnnotHandler;
createAnnotTool.CreateFreetextCanceled += CreateAnnotTool_CreateFreetextCanceled;
createAnnotTool.MeasureChanged += CreateAnnotTool_MeasureChanged;
@@ -206,7 +206,7 @@ public void SetAnnotIsProportionalScaling(bool isProportionalScaling)
{
return;
}
- BaseLayer baseLayer = PDFViewer.GetViewForTag(createAnnotTag);
+ BaseLayer baseLayer = PDFViewer.GetViewForTag(CreateAnnotTag);
(baseLayer as CreateAnnotTool).SetIsProportionalScaling(isProportionalScaling);
}
@@ -216,7 +216,7 @@ public double GetMoveLength()
{
return 0;
}
- BaseLayer baseLayer = PDFViewer.GetViewForTag(createAnnotTag);
+ BaseLayer baseLayer = PDFViewer.GetViewForTag(CreateAnnotTag);
return (baseLayer as CreateAnnotTool).GetMoveLength();
}
@@ -228,7 +228,7 @@ public CPDFAnnotation StartDrawAnnot(C_ANNOTATION_TYPE annotType)
}
Point point = Mouse.GetPosition(this);
- BaseLayer baseLayer = PDFViewer.GetViewForTag(createAnnotTag);
+ BaseLayer baseLayer = PDFViewer.GetViewForTag(CreateAnnotTag);
PDFViewer.GetPointPageInfo(point, out int index, out Rect paintRect, out Rect pageBound);
if (index < 0)
{
@@ -240,7 +240,7 @@ public CPDFAnnotation StartDrawAnnot(C_ANNOTATION_TYPE annotType)
{
DefaultSettingParam defaultSettingParam = GetDefaultSettingParam();
StampParam stampParam = defaultSettingParam.StampParamDef;
- stampParam.Rotation = cPDFPage.Rotation;
+ stampParam.PageRotation = cPDFPage.Rotation;
defaultSettingParam.SetAnnotParam(stampParam);
}
Point cropPoint = new Point();
@@ -271,7 +271,7 @@ public void MultipleClick()
return;
}
Point point = Mouse.GetPosition(this);
- BaseLayer baseLayer = PDFViewer.GetViewForTag(createAnnotTag);
+ BaseLayer baseLayer = PDFViewer.GetViewForTag(CreateAnnotTag);
PDFViewer.GetPointPageInfo(point, out int index, out Rect paintRect, out Rect pageBound);
if (index < 0)
{
@@ -309,7 +309,7 @@ public void MoveDrawAnnot()
return;
}
Point point = Mouse.GetPosition(this);
- BaseLayer baseLayer = PDFViewer.GetViewForTag(createAnnotTag);
+ BaseLayer baseLayer = PDFViewer.GetViewForTag(CreateAnnotTag);
(baseLayer as CreateAnnotTool).MoveDraw(point, PDFViewer.GetZoom());
}
@@ -320,8 +320,8 @@ public void CreateTextBox()
return;
}
Point point = Mouse.GetPosition(this);
- BaseLayer baseLayer = PDFViewer.GetViewForTag(createAnnotTag);
- (baseLayer as CreateAnnotTool).CreateTextBox();
+ BaseLayer baseLayer = PDFViewer.GetViewForTag(CreateAnnotTag);
+ (baseLayer as CreateAnnotTool).CreateTextBox();
}
public Rect EndDrawAnnot()
@@ -330,7 +330,7 @@ public Rect EndDrawAnnot()
{
return new Rect();
}
- BaseLayer baseLayer = PDFViewer.GetViewForTag(createAnnotTag);
+ BaseLayer baseLayer = PDFViewer.GetViewForTag(CreateAnnotTag);
return (baseLayer as CreateAnnotTool).EndDraw();
}
@@ -415,7 +415,7 @@ public bool CreateAnnotForSelectText(TextSelectInfo textSelectInfo, C_ANNOTATION
List coreRectList = new List();
foreach (Rect copyRect in pageSelectRectList)
{
- coreRectList.Add(new CRect((float)copyRect.Left, (float)copyRect.Top, (float)copyRect.Right, (float)copyRect.Bottom));
+ coreRectList.Add(new CRect((float)copyRect.Left, (float)copyRect.Bottom, (float)copyRect.Right, (float)copyRect.Top));
}
CreateDefaultAnnot(annotCore, annotType, null);
string markupContent = textSelectInfo.PageSelectText[pageIndex];
@@ -510,6 +510,17 @@ public bool CreateAnnotForSelectText(TextSelectInfo textSelectInfo, C_ANNOTATION
historyGroup.Histories.Add(redactHistory);
}
break;
+ case C_ANNOTATION_TYPE.C_ANNOTATION_LINK:
+ {
+ LinkAnnotHistory linkHistory = new LinkAnnotHistory();
+ AnnotParam annotParam = ParamConverter.AnnotConverter(cPDFDocument, annotCore);
+ linkHistory.Action = HistoryAction.Add;
+ linkHistory.CurrentParam = (LinkParam)annotParam;
+ linkHistory.PDFDoc = cPDFDocument;
+ linkHistory.Action = HistoryAction.Add;
+ historyGroup.Histories.Add(linkHistory);
+ }
+ break;
default:
break;
}
@@ -528,25 +539,25 @@ public bool CreateAnnotForSelectText(TextSelectInfo textSelectInfo, C_ANNOTATION
public Point GetStartPoint()
{
- BaseLayer baseLayer = PDFViewer.GetViewForTag(createAnnotTag);
+ BaseLayer baseLayer = PDFViewer.GetViewForTag(CreateAnnotTag);
return (baseLayer as CreateAnnotTool).GetStartPoint();
}
public Point GetEndPoint()
{
- BaseLayer baseLayer = PDFViewer.GetViewForTag(createAnnotTag);
+ BaseLayer baseLayer = PDFViewer.GetViewForTag(CreateAnnotTag);
return (baseLayer as CreateAnnotTool).GetEndPoint();
}
public List GetInkDrawPoints()
{
- BaseLayer baseLayer = PDFViewer.GetViewForTag(createAnnotTag);
+ BaseLayer baseLayer = PDFViewer.GetViewForTag(CreateAnnotTag);
return (baseLayer as CreateAnnotTool).GetInkDrawPoints();
}
public List GetMeasureDrawPoints()
{
- BaseLayer baseLayer = PDFViewer.GetViewForTag(createAnnotTag);
+ BaseLayer baseLayer = PDFViewer.GetViewForTag(CreateAnnotTag);
return (baseLayer as CreateAnnotTool).GetMeasureDrawPoints();
}
@@ -557,7 +568,7 @@ public Rect GetDrawAnnotMaxRect()
return new Rect();
}
Point point = Mouse.GetPosition(this);
- BaseLayer baseLayer = PDFViewer.GetViewForTag(createAnnotTag);
+ BaseLayer baseLayer = PDFViewer.GetViewForTag(CreateAnnotTag);
return (baseLayer as CreateAnnotTool).GetMaxRect();
}
@@ -568,7 +579,7 @@ public void ClearDrawAnnot()
return;
}
Point point = Mouse.GetPosition(this);
- BaseLayer baseLayer = PDFViewer.GetViewForTag(createAnnotTag);
+ BaseLayer baseLayer = PDFViewer.GetViewForTag(CreateAnnotTag);
(baseLayer as CreateAnnotTool).ClearDraw();
}
@@ -589,7 +600,7 @@ protected void UpdateTextPop()
{
return;
}
- AnnotData annotData = currentAnnot.GetAnnotData();
+ AnnotData annotData = currentAnnot.GetAnnotData();
if (annotData.PaintRect == Rect.Empty)
{
@@ -629,7 +640,7 @@ protected void BuildPopTextUI(BaseAnnot textAnnot)
double Height = DpiHelper.PDFNumToStandardNum(drawRect.height());
textui = new TextBox();
textui.Name = "PdfViewerTextBox";
- textBorder = new Border();
+ textBorder = new DashedBorder();
textBorder.Child = textui;
textBorder.MinWidth = Width * PDFViewer.GetZoom();
textBorder.MinHeight = Height * PDFViewer.GetZoom();
@@ -667,9 +678,22 @@ protected void BuildPopTextUI(BaseAnnot textAnnot)
textBorder.Padding = new Thickness(0);
textBorder.BorderBrush = new SolidColorBrush(borderColor);
- textBorder.BorderThickness = new Thickness(DpiHelper.PDFNumToStandardNum(textWidget.GetBorderWidth() * annotData.CurrentZoom));
+ double rawWidth = textWidget.GetBorderWidth();
+ double drawWidth = DpiHelper.PDFNumToStandardNum(rawWidth * annotData.CurrentZoom);
+ textBorder.BorderThickness = new Thickness(drawWidth);
textui.BorderThickness = new Thickness(0);
textui.Text = textWidget.Content;
+ if (textWidget.BorderStyle != C_BORDER_STYLE.BS_SOLID && textWidget.Dash != null && textWidget.Dash.Length > 0)
+ {
+ //补充保存虚线样式
+ DashedBorder dashBorder = textBorder as DashedBorder;
+ DoubleCollection dashCollection = new DoubleCollection();
+ foreach (float num in textWidget.Dash)
+ {
+ dashCollection.Add(num);
+ }
+ dashBorder?.DrawDashBorder(true, drawWidth, rawWidth, dashCollection);
+ }
string fontName = string.Empty;
string fontFamily = string.Empty;
@@ -783,10 +807,10 @@ protected void BuildPopTextUI(BaseAnnot textAnnot)
viewer.UpdateAnnotFrame();
}
RemovePopTextUI();
- }
+ }
};
- BaseLayer createAnnotTool = PDFViewer?.GetView(createAnnotTag) as CreateAnnotTool;
+ BaseLayer createAnnotTool = PDFViewer?.GetView(CreateAnnotTag) as CreateAnnotTool;
if (createAnnotTool != null)
{
createAnnotTool.Children.Add(textBorder);
@@ -907,7 +931,7 @@ public void RemovePopTextUI()
{
return;
}
- BaseLayer removeLayer = PDFViewer?.GetView(createAnnotTag) as CreateAnnotTool;
+ BaseLayer removeLayer = PDFViewer?.GetView(CreateAnnotTag) as CreateAnnotTool;
removeLayer.Children.Remove(textBorder);
}
diff --git a/ComPDFKit for Windows/Examples/ComPDFKit.Tool/CPDFViewerTool.AnnotEdit.cs b/ComPDFKit for Windows/Examples/ComPDFKit.Tool/CPDFViewerTool.AnnotEdit.cs
index 8a76dec..50afcb0 100644
--- a/ComPDFKit for Windows/Examples/ComPDFKit.Tool/CPDFViewerTool.AnnotEdit.cs
+++ b/ComPDFKit for Windows/Examples/ComPDFKit.Tool/CPDFViewerTool.AnnotEdit.cs
@@ -15,6 +15,7 @@ public partial class CPDFViewerTool
public event EventHandler AnnotEditDataChanging;
public event EventHandler AnnotEditDataChanged;
public event EventHandler