|
@@ -20,6 +20,11 @@ using ComPDFKit.Tool.Help;
|
|
|
using ComPDFKit.Measure;
|
|
|
using System.Dynamic;
|
|
|
using System.Globalization;
|
|
|
+using ComPDFKitViewer.Layer;
|
|
|
+using ComPDFKitViewer;
|
|
|
+using ComPDFKitViewer.Annot;
|
|
|
+using System.Windows.Annotations;
|
|
|
+using ComPDFKit.Viewer.Annot;
|
|
|
|
|
|
namespace ComPDFKit.Tool
|
|
|
{
|
|
@@ -82,6 +87,7 @@ namespace ComPDFKit.Tool
|
|
|
/// </summary>
|
|
|
private Cursor addImageEditCursor = Cursors.Arrow;
|
|
|
|
|
|
+ public bool SaveEmptyStickyAnnotSave { get; set; } = true;
|
|
|
public void SetActiveCropping(bool isActiveCropping)
|
|
|
{
|
|
|
this.isActiveCropping = isActiveCropping;
|
|
@@ -1419,7 +1425,7 @@ namespace ComPDFKit.Tool
|
|
|
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,
|
|
@@ -1447,11 +1453,26 @@ namespace ComPDFKit.Tool
|
|
|
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 && SaveEmptyStickyAnnotSave == 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.IsCreate = true;
|
|
@@ -1461,9 +1482,43 @@ namespace ComPDFKit.Tool
|
|
|
expandData.AnnotParam = currentParam;
|
|
|
e.Data = expandData;
|
|
|
}
|
|
|
+
|
|
|
}
|
|
|
}
|
|
|
|
|
|
+ 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))
|
|
|
+ {
|
|
|
+ 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)
|