|
@@ -17,6 +17,8 @@ using ComPDFKit.PDFAnnotation;
|
|
|
using ComPDFKit.Tool;
|
|
|
using ComPDFKit.Tool.Help;
|
|
|
using ComPDFKit.Tool.SettingParam;
|
|
|
+using ComPDFKit.Import;
|
|
|
+using ComPDFKitViewer.BaseObject;
|
|
|
|
|
|
namespace Compdfkit_Tools.PDFControl
|
|
|
{
|
|
@@ -68,13 +70,14 @@ namespace Compdfkit_Tools.PDFControl
|
|
|
{
|
|
|
if (this.pdfViewerControl != null)
|
|
|
{
|
|
|
- //this.pdfViewerControl.AnnotActiveHandler -= PDFViewer_AnnotActiveHandler;
|
|
|
+ pdfViewerControl.PDFToolManager.MouseLeftButtonDownHandler += PDFToolManager_MouseLeftButtonDownHandler; ;
|
|
|
//this.pdfViewerControl.AnnotActiveHandler += PDFViewer_AnnotActiveHandler;
|
|
|
//this.pdfViewerControl.AnnotEditHandler -= PdfViewer_AnnotEditHandler;
|
|
|
//this.pdfViewerControl.AnnotEditHandler += PdfViewer_AnnotEditHandler;
|
|
|
}
|
|
|
}
|
|
|
|
|
|
+
|
|
|
//private void PdfViewer_AnnotEditHandler(object sender, List<AnnotEditEvent> e)
|
|
|
//{
|
|
|
// if (e != null && e.Count > 0)
|
|
@@ -218,6 +221,7 @@ namespace Compdfkit_Tools.PDFControl
|
|
|
(annotHandlerEventArgs as HighlightParam).Content = highlightData.Note;
|
|
|
(annotHandlerEventArgs as HighlightParam).Author = highlightData.Author;
|
|
|
(annotHandlerEventArgs as HighlightParam).Locked = highlightData.IsLocked;
|
|
|
+ pdfViewerControl.PDFToolManager.SetCreateAnnotType(C_ANNOTATION_TYPE.C_ANNOTATION_HIGHLIGHT);
|
|
|
}
|
|
|
break;
|
|
|
|
|
@@ -231,6 +235,7 @@ namespace Compdfkit_Tools.PDFControl
|
|
|
(annotHandlerEventArgs as UnderlineParam).Author = underlineData.Author;
|
|
|
(annotHandlerEventArgs as UnderlineParam).Content = underlineData.Note;
|
|
|
(annotHandlerEventArgs as UnderlineParam).Locked = underlineData.IsLocked;
|
|
|
+ pdfViewerControl.PDFToolManager.SetCreateAnnotType(C_ANNOTATION_TYPE.C_ANNOTATION_UNDERLINE);
|
|
|
}
|
|
|
break;
|
|
|
|
|
@@ -240,10 +245,11 @@ namespace Compdfkit_Tools.PDFControl
|
|
|
annotHandlerEventArgs = new StrikeoutParam();
|
|
|
byte[] Color = new byte[] { strikeoutData.Color.R, strikeoutData.Color.G, strikeoutData.Color.B };
|
|
|
(annotHandlerEventArgs as StrikeoutParam).StrikeoutColor = Color;
|
|
|
- (annotHandlerEventArgs as StrikeoutParam).Transparency = (int)(strikeoutData.Opacity * 255);
|
|
|
+ (annotHandlerEventArgs as StrikeoutParam).Transparency = (int)(strikeoutData.Opacity * 255);
|
|
|
(annotHandlerEventArgs as StrikeoutParam).Locked = strikeoutData.IsLocked;
|
|
|
(annotHandlerEventArgs as StrikeoutParam).Author = strikeoutData.Author;
|
|
|
(annotHandlerEventArgs as StrikeoutParam).Content = strikeoutData.Note;
|
|
|
+ pdfViewerControl.PDFToolManager.SetCreateAnnotType(C_ANNOTATION_TYPE.C_ANNOTATION_STRIKEOUT);
|
|
|
}
|
|
|
break;
|
|
|
|
|
@@ -257,6 +263,7 @@ namespace Compdfkit_Tools.PDFControl
|
|
|
(annotHandlerEventArgs as SquigglyParam).Locked = squigglyData.IsLocked;
|
|
|
(annotHandlerEventArgs as SquigglyParam).Author = squigglyData.Author;
|
|
|
(annotHandlerEventArgs as SquigglyParam).Content = squigglyData.Note;
|
|
|
+ pdfViewerControl.PDFToolManager.SetCreateAnnotType(C_ANNOTATION_TYPE.C_ANNOTATION_SQUIGGLY);
|
|
|
}
|
|
|
break;
|
|
|
|
|
@@ -276,6 +283,7 @@ namespace Compdfkit_Tools.PDFControl
|
|
|
|
|
|
(annotHandlerEventArgs as SquareParam).Author = squareData.Author;
|
|
|
(annotHandlerEventArgs as SquareParam).Content = squareData.Note;
|
|
|
+ pdfViewerControl.PDFToolManager.SetCreateAnnotType(C_ANNOTATION_TYPE.C_ANNOTATION_SQUARE);
|
|
|
}
|
|
|
break;
|
|
|
|
|
@@ -294,6 +302,8 @@ namespace Compdfkit_Tools.PDFControl
|
|
|
(annotHandlerEventArgs as CircleParam).BorderStyle = BorderStyle;
|
|
|
(annotHandlerEventArgs as CircleParam).Author = cicleData.Author;
|
|
|
(annotHandlerEventArgs as CircleParam).Content = cicleData.Note;
|
|
|
+
|
|
|
+ pdfViewerControl.PDFToolManager.SetCreateAnnotType(C_ANNOTATION_TYPE.C_ANNOTATION_CIRCLE);
|
|
|
}
|
|
|
break;
|
|
|
|
|
@@ -313,6 +323,7 @@ namespace Compdfkit_Tools.PDFControl
|
|
|
(annotHandlerEventArgs as LineParam).TailLineType = lineData.LineType.TailLineType;
|
|
|
(annotHandlerEventArgs as LineParam).Author = lineData.Author;
|
|
|
(annotHandlerEventArgs as LineParam).Content = lineData.Note;
|
|
|
+ pdfViewerControl.PDFToolManager.SetCreateAnnotType(C_ANNOTATION_TYPE.C_ANNOTATION_LINE);
|
|
|
}
|
|
|
break;
|
|
|
|
|
@@ -325,6 +336,7 @@ namespace Compdfkit_Tools.PDFControl
|
|
|
(annotHandlerEventArgs as StickyNoteParam).Content = noteData.Note;
|
|
|
(annotHandlerEventArgs as StickyNoteParam).Transparency = 1;
|
|
|
(annotHandlerEventArgs as StickyNoteParam).Author = noteData.Author;
|
|
|
+ pdfViewerControl.PDFToolManager.SetCreateAnnotType(C_ANNOTATION_TYPE.C_ANNOTATION_TEXT);
|
|
|
}
|
|
|
break;
|
|
|
|
|
@@ -338,6 +350,7 @@ namespace Compdfkit_Tools.PDFControl
|
|
|
(annotHandlerEventArgs as InkParam).Transparency = (int)(freehandData.Opacity * 255);
|
|
|
(annotHandlerEventArgs as InkParam).Content = freehandData.Note;
|
|
|
(annotHandlerEventArgs as InkParam).Author = freehandData.Author;
|
|
|
+ pdfViewerControl.PDFToolManager.SetCreateAnnotType(C_ANNOTATION_TYPE.C_ANNOTATION_INK);
|
|
|
}
|
|
|
break;
|
|
|
|
|
@@ -349,7 +362,7 @@ namespace Compdfkit_Tools.PDFControl
|
|
|
(annotHandlerEventArgs as FreeTextParam).FontName = freeTextData.FontFamily.ToString();
|
|
|
|
|
|
byte[] FontColor = new byte[] { freeTextData.BorderColor.R, freeTextData.BorderColor.G, freeTextData.BorderColor.B };
|
|
|
- (annotHandlerEventArgs as FreeTextParam).FontColor =FontColor;
|
|
|
+ (annotHandlerEventArgs as FreeTextParam).FontColor = FontColor;
|
|
|
(annotHandlerEventArgs as FreeTextParam).IsBold = freeTextData.IsBold;
|
|
|
(annotHandlerEventArgs as FreeTextParam).IsItalic = freeTextData.IsItalic;
|
|
|
(annotHandlerEventArgs as FreeTextParam).FontSize = freeTextData.FontSize;
|
|
@@ -369,25 +382,29 @@ namespace Compdfkit_Tools.PDFControl
|
|
|
}
|
|
|
(annotHandlerEventArgs as FreeTextParam).Content = freeTextData.Note;
|
|
|
(annotHandlerEventArgs as FreeTextParam).Author = freeTextData.Author;
|
|
|
+ pdfViewerControl.PDFToolManager.SetCreateAnnotType(C_ANNOTATION_TYPE.C_ANNOTATION_FREETEXT);
|
|
|
}
|
|
|
break;
|
|
|
|
|
|
case CPDFAnnotationType.Stamp:
|
|
|
{
|
|
|
- annotHandlerEventArgs = new StampParam();
|
|
|
+ StampParam stampParam = new StampParam();
|
|
|
CPDFStampData stampData = pdfAnnotationData as CPDFStampData;
|
|
|
- SetStamp(ref annotHandlerEventArgs, stampData);
|
|
|
+ SetStamp(ref stampParam, stampData);
|
|
|
+ annotHandlerEventArgs = stampParam;
|
|
|
+ pdfViewerControl.PDFToolManager.SetCreateAnnotType(C_ANNOTATION_TYPE.C_ANNOTATION_STAMP);
|
|
|
}
|
|
|
break;
|
|
|
case CPDFAnnotationType.Signature:
|
|
|
- annotHandlerEventArgs = new SignatureParam();
|
|
|
+ AnnotParam signatureParam = new AnnotParam();
|
|
|
CPDFSignatureData SignatureData = pdfAnnotationData as CPDFSignatureData;
|
|
|
- SetSignature(ref SignatureAnnot, SignatureData);
|
|
|
+ SetSignature(ref signatureParam, SignatureData);
|
|
|
+ annotHandlerEventArgs = signatureParam;
|
|
|
break;
|
|
|
case CPDFAnnotationType.Link:
|
|
|
if (annotHandlerEventArgs != null)
|
|
|
{
|
|
|
- pdfViewerControl.SetToolParam(annotHandlerEventArgs);
|
|
|
+ pdfViewerControl.PDFToolManager.SetCreateAnnotType(C_ANNOTATION_TYPE.C_ANNOTATION_LINK);
|
|
|
}
|
|
|
break;
|
|
|
case CPDFAnnotationType.Unknow:
|
|
@@ -397,25 +414,70 @@ namespace Compdfkit_Tools.PDFControl
|
|
|
break;
|
|
|
}
|
|
|
pdfViewerControl.PDFToolManager.SetToolType(ToolType.CreateAnnot);
|
|
|
- DefaultSettingParam defaultSettingParam= pdfViewerControl.PDFViewTool.GetDefaultSettingParam();
|
|
|
+ DefaultSettingParam defaultSettingParam = pdfViewerControl.PDFViewTool.GetDefaultSettingParam();
|
|
|
|
|
|
}
|
|
|
|
|
|
- public void SetSignature(ref StampAnnotArgs Args, CPDFSignatureData stamp)
|
|
|
+ public void SetSignature(ref AnnotParam annotParam, CPDFSignatureData stamp)
|
|
|
{
|
|
|
switch (stamp.Type)
|
|
|
{
|
|
|
case SignatureType.TextType:
|
|
|
case SignatureType.ImageType:
|
|
|
{
|
|
|
- Args.Opacity = 1;
|
|
|
- Args.Type = StampType.IMAGE_STAMP;
|
|
|
- Args.ImagePath = stamp.SourcePath;
|
|
|
+ annotParam = new StampParam();
|
|
|
+
|
|
|
+ (annotParam as StampParam).Transparency = 1;
|
|
|
+ (annotParam as StampParam).StampType = C_STAMP_TYPE.IMAGE_STAMP;
|
|
|
+ if (!string.IsNullOrEmpty(stamp.SourcePath))
|
|
|
+ {
|
|
|
+ BitmapImage image = new BitmapImage(new Uri(stamp.SourcePath));
|
|
|
+ PngBitmapEncoder encoder = new PngBitmapEncoder();
|
|
|
+ encoder.Frames.Add(BitmapFrame.Create(image));
|
|
|
+ MemoryStream memoryStream = new MemoryStream();
|
|
|
+ encoder.Save(memoryStream);
|
|
|
+ (annotParam as StampParam).ImageStream = memoryStream;
|
|
|
+ }
|
|
|
+
|
|
|
+ pdfViewerControl.PDFToolManager.SetCreateAnnotType(C_ANNOTATION_TYPE.C_ANNOTATION_STAMP);
|
|
|
}
|
|
|
break;
|
|
|
case SignatureType.Drawing:
|
|
|
{
|
|
|
- Args.SetInkData(GetPoints(stamp.DrawingPath), stamp.inkThickness, stamp.inkColor);
|
|
|
+ annotParam = new InkParam();
|
|
|
+
|
|
|
+ List<List<Point>> RawPointList = GetPoints(stamp.DrawingPath);
|
|
|
+ List<CPoint> linqList = new List<CPoint>();
|
|
|
+
|
|
|
+ if (RawPointList != null && RawPointList.Count > 0)
|
|
|
+ {
|
|
|
+ List<List<CPoint>> inkPath = new List<List<CPoint>>();
|
|
|
+ foreach (List<Point> inkPoints in RawPointList)
|
|
|
+ {
|
|
|
+ List<CPoint> ink = new List<CPoint>();
|
|
|
+ foreach (Point point in inkPoints)
|
|
|
+ {
|
|
|
+ ink.Add(new CPoint((float)point.X, (float)point.Y));
|
|
|
+ linqList.Add(new CPoint((float)point.X, (float)point.Y));
|
|
|
+ }
|
|
|
+
|
|
|
+ if (ink.Count > 0)
|
|
|
+ {
|
|
|
+ inkPath.Add(ink);
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+ if (inkPath.Count > 0)
|
|
|
+ {
|
|
|
+ (annotParam as InkParam).InkPath = inkPath;
|
|
|
+ }
|
|
|
+ }
|
|
|
+ (annotParam as InkParam).Thickness = stamp.inkThickness;
|
|
|
+
|
|
|
+ byte[] InkColor = new byte[] { stamp.inkColor.R, stamp.inkColor.G, stamp.inkColor.B };
|
|
|
+ (annotParam as InkParam).InkColor = InkColor;
|
|
|
+
|
|
|
+ pdfViewerControl.PDFToolManager.SetCreateAnnotType(C_ANNOTATION_TYPE.C_ANNOTATION_INK);
|
|
|
}
|
|
|
break;
|
|
|
default:
|
|
@@ -452,46 +514,25 @@ namespace Compdfkit_Tools.PDFControl
|
|
|
stampParam.StampText = stamp.StampText;
|
|
|
stampParam.Author = stamp.Author;
|
|
|
stampParam.Transparency = (int)(stamp.Opacity * 255);
|
|
|
- if (stamp.Type == C_STAMP_TYPE.IMAGE_STAMP)
|
|
|
- {
|
|
|
-
|
|
|
- stampParam.ImageWidth = stamp.MaxWidth;
|
|
|
- stampParam.ImageHeight = stamp.MaxHeight;
|
|
|
- }
|
|
|
- else
|
|
|
- {
|
|
|
- stampParam.MaxWidth = stamp.MaxWidth;
|
|
|
- stampParam.MaxHeight = stamp.MaxHeight;
|
|
|
- }
|
|
|
- stampParam.StampTextDate = stamp.StampTextDate;
|
|
|
- stampParam.TextColor = stamp.TextColor;
|
|
|
- stampParam.TextSharp = stamp.TextSharp;
|
|
|
+ stampParam.DateText = stamp.StampTextDate;
|
|
|
+ stampParam.TextStampColor = stamp.TextColor;
|
|
|
+ stampParam.TextStampShape = stamp.TextSharp;
|
|
|
if (!string.IsNullOrEmpty(stamp.SourcePath))
|
|
|
{
|
|
|
BitmapImage image = new BitmapImage(new Uri(stamp.SourcePath));
|
|
|
- Args.ImageArray = new byte[image.PixelWidth * image.PixelHeight * 4];
|
|
|
- image.CopyPixels(Args.ImageArray, image.PixelWidth * 4, 0);
|
|
|
- Args.ImageHeight = image.PixelHeight;
|
|
|
- Args.ImageWidth = image.PixelWidth;
|
|
|
+ PngBitmapEncoder encoder = new PngBitmapEncoder();
|
|
|
+ encoder.Frames.Add(BitmapFrame.Create(image));
|
|
|
+ MemoryStream memoryStream = new MemoryStream();
|
|
|
+ encoder.Save(memoryStream);
|
|
|
+ stampParam.ImageStream = memoryStream;
|
|
|
}
|
|
|
else
|
|
|
{
|
|
|
- try
|
|
|
- {
|
|
|
- Args.ImageArray = new byte[stamp.ImageSource.PixelWidth * stamp.ImageSource.PixelHeight * 4];
|
|
|
- stamp.ImageSource.CopyPixels(Args.ImageArray, stamp.ImageSource.PixelWidth * 4, 0);
|
|
|
- Args.ImageHeight = stamp.ImageSource.PixelHeight;
|
|
|
- Args.ImageWidth = stamp.ImageSource.PixelWidth;
|
|
|
- }
|
|
|
- catch
|
|
|
- {
|
|
|
- var i = pdfStampUI.CustomStampList.IndexOf(stamp);
|
|
|
- Settings.Default.CustomStampList.RemoveAt(i);
|
|
|
- Settings.Default.Save();
|
|
|
- pdfStampUI.LoadSettings();
|
|
|
- return;
|
|
|
- }
|
|
|
-
|
|
|
+ var i = pdfStampUI.CustomStampList.IndexOf(stamp);
|
|
|
+ Settings.Default.CustomStampList.RemoveAt(i);
|
|
|
+ Settings.Default.Save();
|
|
|
+ pdfStampUI.LoadSettings();
|
|
|
+ return;
|
|
|
}
|
|
|
stampParam.StampType = stamp.Type;
|
|
|
}
|
|
@@ -505,19 +546,6 @@ namespace Compdfkit_Tools.PDFControl
|
|
|
private void CPDFAnnotationControl_PropertyChanged(object sender, CPDFAnnotationData e)
|
|
|
{
|
|
|
SetAnnotationProperty(e);
|
|
|
- if (pdfViewerControl != null && pdfViewerControl.PDFToolManager.GetToolType() == ToolType.CreateAnnot && pdfViewerControl.PDFToolManager.GetAnnotType() ==C_ANNOTATION_TYPE.C_ANNOTATION_INK)
|
|
|
- {
|
|
|
- FreehandAnnotArgs freehandArgs = pdfViewerControl.ToolManager.CurrentAnnotArgs as FreehandAnnotArgs;
|
|
|
- CPDFFreehandData freehandData = e as CPDFFreehandData;
|
|
|
- if (freehandData != null)
|
|
|
- {
|
|
|
- freehandArgs.InkColor = freehandData.BorderColor;
|
|
|
- freehandArgs.LineWidth = freehandData.Thickness;
|
|
|
- freehandArgs.Transparency = freehandData.Opacity;
|
|
|
- freehandArgs.Content = freehandData.Note;
|
|
|
- freehandArgs.Author = freehandData.Author;
|
|
|
- }
|
|
|
- }
|
|
|
}
|
|
|
|
|
|
public void InitAnnotationPanel(CPDFAnnotationType annotationType)
|
|
@@ -630,50 +658,50 @@ namespace Compdfkit_Tools.PDFControl
|
|
|
{
|
|
|
pdfLinkUI = new CPDFLinkUI();
|
|
|
}
|
|
|
- LinkAnnotArgs linkAnnotArgs = new LinkAnnotArgs();
|
|
|
- if (this.pdfViewerControl != null && this.pdfViewerControl.Document != null)
|
|
|
+ InkParam linkAnnotArgs = new InkParam();
|
|
|
+ if (this.pdfViewerControl != null&& pdfViewerControl.PDFViewTool!=null && pdfViewerControl.PDFViewTool.GetCPDFViewer().GetDocument() != null)
|
|
|
{
|
|
|
- this.pdfViewerControl.SetMouseMode(MouseModes.AnnotCreate);
|
|
|
- pdfViewerControl.SetToolParam(linkAnnotArgs);
|
|
|
- pdfLinkUI.InitLinkAnnotArgs(linkAnnotArgs, pdfViewerControl.Document.PageCount);
|
|
|
+ pdfViewerControl.PDFToolManager.SetToolType(ToolType.CreateAnnot);
|
|
|
+ pdfViewerControl.PDFToolManager.SetCreateAnnotType(C_ANNOTATION_TYPE.C_ANNOTATION_LINK);
|
|
|
+ pdfLinkUI.InitLinkAnnotArgs(linkAnnotArgs, pdfViewerControl.PDFViewTool.GetCPDFViewer().GetDocument().PageCount);
|
|
|
}
|
|
|
annotationPanel = pdfLinkUI;
|
|
|
break;
|
|
|
case CPDFAnnotationType.Audio:
|
|
|
- SoundAnnotArgs soundArgs = new SoundAnnotArgs();
|
|
|
- OpenFileDialog openAudioDialog = new OpenFileDialog();
|
|
|
- openAudioDialog.Filter = "Wave Files(*.wav)|*.wav|All Files(*.*;)|*.*;";
|
|
|
- if (openAudioDialog.ShowDialog() == true)
|
|
|
- {
|
|
|
- soundArgs.SoundFilePath = openAudioDialog.FileName;
|
|
|
- this.pdfViewerControl.SetMouseMode(MouseModes.AnnotCreate);
|
|
|
- pdfViewerControl.SetToolParam(soundArgs);
|
|
|
- }
|
|
|
- else
|
|
|
- {
|
|
|
- this.pdfViewerControl.SetMouseMode(MouseModes.PanTool);
|
|
|
- ClearAnnotationBar?.Invoke(this, EventArgs.Empty);
|
|
|
- }
|
|
|
+ //SoundAnnotArgs soundArgs = new SoundAnnotArgs();
|
|
|
+ //OpenFileDialog openAudioDialog = new OpenFileDialog();
|
|
|
+ //openAudioDialog.Filter = "Wave Files(*.wav)|*.wav|All Files(*.*;)|*.*;";
|
|
|
+ //if (openAudioDialog.ShowDialog() == true)
|
|
|
+ //{
|
|
|
+ // soundArgs.SoundFilePath = openAudioDialog.FileName;
|
|
|
+ // this.pdfViewerControl.SetMouseMode(MouseModes.AnnotCreate);
|
|
|
+ // pdfViewerControl.SetToolParam(soundArgs);
|
|
|
+ //}
|
|
|
+ //else
|
|
|
+ //{
|
|
|
+ // this.pdfViewerControl.SetMouseMode(MouseModes.PanTool);
|
|
|
+ // ClearAnnotationBar?.Invoke(this, EventArgs.Empty);
|
|
|
+ //}
|
|
|
ClearPanel();
|
|
|
break;
|
|
|
case CPDFAnnotationType.Image:
|
|
|
- StampAnnotArgs stampArgs = new StampAnnotArgs();
|
|
|
- stampArgs.Opacity = 1;
|
|
|
- stampArgs.Type = StampType.IMAGE_STAMP;
|
|
|
- OpenFileDialog openFileDialog = new OpenFileDialog();
|
|
|
- openFileDialog.Filter = "Image Files(*.jpg;*.jpeg;*.png;*.bmp)|*.jpg;*.jpeg;*.png;*.bmp;";
|
|
|
- if (openFileDialog.ShowDialog() == true)
|
|
|
- {
|
|
|
- stampArgs.ImagePath = openFileDialog.FileName;
|
|
|
-
|
|
|
- this.pdfViewerControl?.SetMouseMode(MouseModes.AnnotCreate);
|
|
|
- this.pdfViewerControl?.SetToolParam(stampArgs);
|
|
|
- }
|
|
|
- else
|
|
|
- {
|
|
|
- this.pdfViewerControl.SetMouseMode(MouseModes.PanTool);
|
|
|
- }
|
|
|
- ClearAnnotationBar?.Invoke(this, EventArgs.Empty);
|
|
|
+ //StampAnnotArgs stampArgs = new StampAnnotArgs();
|
|
|
+ //stampArgs.Opacity = 1;
|
|
|
+ //stampArgs.Type = StampType.IMAGE_STAMP;
|
|
|
+ //OpenFileDialog openFileDialog = new OpenFileDialog();
|
|
|
+ //openFileDialog.Filter = "Image Files(*.jpg;*.jpeg;*.png;*.bmp)|*.jpg;*.jpeg;*.png;*.bmp;";
|
|
|
+ //if (openFileDialog.ShowDialog() == true)
|
|
|
+ //{
|
|
|
+ // stampArgs.ImagePath = openFileDialog.FileName;
|
|
|
+
|
|
|
+ // this.pdfViewerControl?.SetMouseMode(MouseModes.AnnotCreate);
|
|
|
+ // this.pdfViewerControl?.SetToolParam(stampArgs);
|
|
|
+ //}
|
|
|
+ //else
|
|
|
+ //{
|
|
|
+ // this.pdfViewerControl.SetMouseMode(MouseModes.PanTool);
|
|
|
+ //}
|
|
|
+ //ClearAnnotationBar?.Invoke(this, EventArgs.Empty);
|
|
|
ClearPanel();
|
|
|
break;
|
|
|
default:
|
|
@@ -749,29 +777,48 @@ namespace Compdfkit_Tools.PDFControl
|
|
|
}
|
|
|
}
|
|
|
|
|
|
- public void CreatTempAnnotationPanel(AnnotAttribEvent annotAttribEvent)
|
|
|
+ public void CreatTempAnnotationPanel(BaseAnnot baseAnnot)
|
|
|
{
|
|
|
- AnnotArgsType annotArgsType = annotAttribEvent.GetAnnotTypes();
|
|
|
- switch (annotArgsType)
|
|
|
+ switch (baseAnnot.CurrentType)
|
|
|
{
|
|
|
- case AnnotArgsType.AnnotHighlight:
|
|
|
- case AnnotArgsType.AnnotUnderline:
|
|
|
- case AnnotArgsType.AnnotStrikeout:
|
|
|
- case AnnotArgsType.AnnotSquiggly:
|
|
|
+ case C_ANNOTATION_TYPE.C_ANNOTATION_HIGHLIGHT:
|
|
|
+ tempAnnotationPanel = new CPDFMarkupUI();
|
|
|
+ (tempAnnotationPanel as CPDFMarkupUI).InitWithAnnotationType(CPDFAnnotationType.Highlight);
|
|
|
+ (tempAnnotationPanel as CPDFMarkupUI).SetPresentAnnotAttrib(annotAttribEvent);
|
|
|
+ break;
|
|
|
+ case C_ANNOTATION_TYPE.C_ANNOTATION_UNDERLINE:
|
|
|
+ tempAnnotationPanel = new CPDFMarkupUI();
|
|
|
+ (tempAnnotationPanel as CPDFMarkupUI).InitWithAnnotationType(CPDFAnnotationType.Underline);
|
|
|
+ (tempAnnotationPanel as CPDFMarkupUI).SetPresentAnnotAttrib(annotAttribEvent);
|
|
|
+ break;
|
|
|
+ case C_ANNOTATION_TYPE.C_ANNOTATION_STRIKEOUT:
|
|
|
+ tempAnnotationPanel = new CPDFMarkupUI();
|
|
|
+ (tempAnnotationPanel as CPDFMarkupUI).InitWithAnnotationType(CPDFAnnotationType.Strikeout);
|
|
|
+ (tempAnnotationPanel as CPDFMarkupUI).SetPresentAnnotAttrib(annotAttribEvent);
|
|
|
+ break;
|
|
|
+ case C_ANNOTATION_TYPE.C_ANNOTATION_SQUIGGLY:
|
|
|
tempAnnotationPanel = new CPDFMarkupUI();
|
|
|
- (tempAnnotationPanel as CPDFMarkupUI).InitWithAnnotationType(CPDFAnnotationDictionary.GetAnnotArgsTypeFromAnnotationType[annotArgsType]);
|
|
|
+ (tempAnnotationPanel as CPDFMarkupUI).InitWithAnnotationType(CPDFAnnotationType.Squiggly);
|
|
|
(tempAnnotationPanel as CPDFMarkupUI).SetPresentAnnotAttrib(annotAttribEvent);
|
|
|
break;
|
|
|
|
|
|
- case AnnotArgsType.AnnotSquare:
|
|
|
- case AnnotArgsType.AnnotCircle:
|
|
|
- case AnnotArgsType.AnnotLine:
|
|
|
+ case C_ANNOTATION_TYPE.C_ANNOTATION_SQUARE:
|
|
|
tempAnnotationPanel = new CPDFShapeUI();
|
|
|
- (tempAnnotationPanel as CPDFShapeUI).InitWithAnnotationType(CPDFAnnotationDictionary.GetAnnotArgsTypeFromAnnotationType[annotArgsType]);
|
|
|
+ (tempAnnotationPanel as CPDFShapeUI).InitWithAnnotationType(CPDFAnnotationType.Square);
|
|
|
+ (tempAnnotationPanel as CPDFShapeUI).SetPresentAnnotAttrib(annotAttribEvent);
|
|
|
+ break;
|
|
|
+ case C_ANNOTATION_TYPE.C_ANNOTATION_CIRCLE:
|
|
|
+ tempAnnotationPanel = new CPDFShapeUI();
|
|
|
+ (tempAnnotationPanel as CPDFShapeUI).InitWithAnnotationType(CPDFAnnotationType.Circle);
|
|
|
+ (tempAnnotationPanel as CPDFShapeUI).SetPresentAnnotAttrib(annotAttribEvent);
|
|
|
+ break;
|
|
|
+ case C_ANNOTATION_TYPE.C_ANNOTATION_LINE:
|
|
|
+ tempAnnotationPanel = new CPDFShapeUI();
|
|
|
+ (tempAnnotationPanel as CPDFShapeUI).InitWithAnnotationType(CPDFAnnotationType.Line);
|
|
|
(tempAnnotationPanel as CPDFShapeUI).SetPresentAnnotAttrib(annotAttribEvent);
|
|
|
break;
|
|
|
|
|
|
- case AnnotArgsType.AnnotFreehand:
|
|
|
+ case C_ANNOTATION_TYPE.C_ANNOTATION_INK:
|
|
|
CPDFFreehandUI tempFreehandPanel = new CPDFFreehandUI();
|
|
|
tempFreehandPanel.SetPresentAnnotAttrib(annotAttribEvent);
|
|
|
tempFreehandPanel.EraseClickHandler += PdfFreehandUI_EraseClickHandler;
|
|
@@ -779,25 +826,25 @@ namespace Compdfkit_Tools.PDFControl
|
|
|
tempAnnotationPanel = tempFreehandPanel;
|
|
|
break;
|
|
|
|
|
|
- case AnnotArgsType.AnnotFreeText:
|
|
|
+ case C_ANNOTATION_TYPE.C_ANNOTATION_FREETEXT:
|
|
|
tempAnnotationPanel = new CPDFFreeTextUI();
|
|
|
(tempAnnotationPanel as CPDFFreeTextUI).SetPresentAnnotAttrib(annotAttribEvent);
|
|
|
break;
|
|
|
|
|
|
- case AnnotArgsType.AnnotSticky:
|
|
|
+ case C_ANNOTATION_TYPE.C_ANNOTATION_TEXT:
|
|
|
tempAnnotationPanel = new CPDFNoteUI();
|
|
|
(tempAnnotationPanel as CPDFNoteUI).SetPresentAnnotAttrib(annotAttribEvent);
|
|
|
break;
|
|
|
|
|
|
- case AnnotArgsType.AnnotStamp:
|
|
|
+ case C_ANNOTATION_TYPE.C_ANNOTATION_STAMP:
|
|
|
tempAnnotationPanel = new CPDFTempStampUI();
|
|
|
(tempAnnotationPanel as CPDFTempStampUI).SetPresentAnnotAttrib(annotAttribEvent);
|
|
|
break;
|
|
|
- case AnnotArgsType.AnnotLink:
|
|
|
+ case C_ANNOTATION_TYPE.C_ANNOTATION_LINK:
|
|
|
tempAnnotationPanel = new CPDFLinkUI();
|
|
|
(tempAnnotationPanel as CPDFLinkUI).SetPresentAnnotAttrib(annotAttribEvent, pdfViewerControl.Document.PageCount);
|
|
|
break;
|
|
|
- case AnnotArgsType.AnnotSound:
|
|
|
+ case C_ANNOTATION_TYPE.C_ANNOTATION_SOUND:
|
|
|
tempAnnotationPanel = null;
|
|
|
break;
|
|
|
default:
|
|
@@ -807,7 +854,7 @@ namespace Compdfkit_Tools.PDFControl
|
|
|
|
|
|
public void LoadAnnotationPanel(CPDFAnnotationType annotationType)
|
|
|
{
|
|
|
- this.pdfViewerControl.SetMouseMode(MouseModes.PanTool);
|
|
|
+ this.pdfViewerControl.PDFToolManager.SetToolType(ToolType.Pan);
|
|
|
currentAnnotationType = annotationType;
|
|
|
annotationPanel = GetAnnotationPanel();
|
|
|
InitAnnotationPanel(annotationType);
|
|
@@ -831,18 +878,19 @@ namespace Compdfkit_Tools.PDFControl
|
|
|
{
|
|
|
EmptyMessage.Visibility = Visibility.Visible;
|
|
|
SetAnnotationPanel(null);
|
|
|
- if (pdfViewerControl != null && pdfViewerControl.ToolManager.CurrentAnnotArgs is EraseArgs)
|
|
|
+ if (pdfViewerControl != null)
|
|
|
{
|
|
|
EmptyMessage.Visibility = Visibility.Collapsed;
|
|
|
}
|
|
|
}
|
|
|
}
|
|
|
|
|
|
- private void ShowTempAnnotPanel(AnnotAttribEvent annotAttribEvent)
|
|
|
+ private void ShowTempAnnotPanel()
|
|
|
{
|
|
|
- if (annotAttribEvent != null)
|
|
|
+ BaseAnnot baseAnnot = pdfViewerControl.PDFToolManager.GetCacheHitTestAnnot();
|
|
|
+ if (baseAnnot != null)
|
|
|
{
|
|
|
- CreatTempAnnotationPanel(annotAttribEvent);
|
|
|
+ CreatTempAnnotationPanel(baseAnnot);
|
|
|
SetAnnotationPanel(tempAnnotationPanel);
|
|
|
ExpandPanel();
|
|
|
if (tempAnnotationPanel != null)
|
|
@@ -856,9 +904,9 @@ namespace Compdfkit_Tools.PDFControl
|
|
|
}
|
|
|
}
|
|
|
|
|
|
- private void PDFViewer_AnnotActiveHandler(object sender, AnnotAttribEvent e)
|
|
|
+ private void PDFToolManager_MouseLeftButtonDownHandler(object sender, MouseEventObject e)
|
|
|
{
|
|
|
- SetAnnotEventData(e);
|
|
|
+ SetAnnotEventData();
|
|
|
}
|
|
|
|
|
|
public void ClearPanel()
|
|
@@ -868,25 +916,24 @@ namespace Compdfkit_Tools.PDFControl
|
|
|
EmptyMessage.Visibility = Visibility.Visible;
|
|
|
}
|
|
|
|
|
|
- public void SetAnnotEventData(AnnotAttribEvent newData)
|
|
|
+ public void SetAnnotEventData()
|
|
|
{
|
|
|
- if (newData != null)
|
|
|
+ if (pdfViewerControl.PDFToolManager != null)
|
|
|
{
|
|
|
- if (newData.IsAnnotCreateReset && isTempPanel)
|
|
|
+ if (pdfViewerControl.PDFToolManager.GetCacheHitTestAnnot()==null && isTempPanel)
|
|
|
{
|
|
|
ShowCurrentAnnotPanel();
|
|
|
isTempPanel = false;
|
|
|
}
|
|
|
- else if (!newData.IsAnnotCreateReset)
|
|
|
+ else if (pdfViewerControl.PDFToolManager.GetCacheHitTestAnnot() != null)
|
|
|
{
|
|
|
- AnnotArgsType annotArgsType = newData.GetAnnotTypes();
|
|
|
- ShowTempAnnotPanel(newData);
|
|
|
+ ShowTempAnnotPanel();
|
|
|
isTempPanel = true;
|
|
|
}
|
|
|
}
|
|
|
else
|
|
|
{
|
|
|
- if (pdfViewerControl != null && pdfViewerControl.MouseMode == MouseModes.AnnotCreate)
|
|
|
+ if (pdfViewerControl != null && pdfViewerControl.PDFToolManager.GetToolType() == ToolType.CreateAnnot)
|
|
|
{
|
|
|
ShowCurrentAnnotPanel();
|
|
|
isTempPanel = false;
|