|
@@ -24,6 +24,7 @@ using System.Windows.Ink;
|
|
|
using compdfkit_tools.Annotation.PDFAnnotationUI;
|
|
|
using Microsoft.Win32;
|
|
|
using System.Windows.Media;
|
|
|
+using compdfkit_tools.Properties;
|
|
|
|
|
|
namespace compdfkit_tools.PDFControl
|
|
|
{
|
|
@@ -89,7 +90,7 @@ namespace compdfkit_tools.PDFControl
|
|
|
|
|
|
private void PdfViewer_AnnotEditHandler(object sender, List<AnnotEditEvent> e)
|
|
|
{
|
|
|
- if (e != null && e.Count > 0 )
|
|
|
+ if (e != null && e.Count > 0)
|
|
|
{
|
|
|
if (e[0].EditAction == ActionType.Del)
|
|
|
{
|
|
@@ -100,14 +101,14 @@ namespace compdfkit_tools.PDFControl
|
|
|
SetAnnotEventData(null);
|
|
|
}
|
|
|
|
|
|
- if (e[0].EditAction==ActionType.Modify && e[0].EditAnnotArgs!=null && e[0].EditAnnotArgs.EventType==AnnotArgsType.AnnotSticky)
|
|
|
+ if (e[0].EditAction == ActionType.Modify && e[0].EditAnnotArgs != null && e[0].EditAnnotArgs.EventType == AnnotArgsType.AnnotSticky)
|
|
|
{
|
|
|
- CPDFNoteUI tempUI= annotationPanel as CPDFNoteUI;
|
|
|
- if(tempUI==null || tempUI.annotAttribEvent==null)
|
|
|
+ CPDFNoteUI tempUI = annotationPanel as CPDFNoteUI;
|
|
|
+ if (tempUI == null || tempUI.annotAttribEvent == null)
|
|
|
{
|
|
|
tempUI = tempAnnotationPanel as CPDFNoteUI;
|
|
|
}
|
|
|
- if(tempUI== null || tempUI.annotAttribEvent == null)
|
|
|
+ if (tempUI == null || tempUI.annotAttribEvent == null)
|
|
|
{
|
|
|
tempUI = pdfNoteUI;
|
|
|
}
|
|
@@ -130,7 +131,7 @@ namespace compdfkit_tools.PDFControl
|
|
|
if (this.pdfViewer != null)
|
|
|
{
|
|
|
this.pdfViewer.AnnotActiveHandler -= PDFViewer_AnnotActiveHandler;
|
|
|
-
|
|
|
+
|
|
|
}
|
|
|
}
|
|
|
|
|
@@ -300,7 +301,7 @@ namespace compdfkit_tools.PDFControl
|
|
|
case CPDFAnnotationType.Line:
|
|
|
CPDFLineShapeData lineData = pdfAnnotationData as CPDFLineShapeData;
|
|
|
annotHandlerEventArgs = new LineAnnotArgs();
|
|
|
- (annotHandlerEventArgs as LineAnnotArgs).LineColor = lineData.BorderColor;
|
|
|
+ (annotHandlerEventArgs as LineAnnotArgs).LineColor = lineData.BorderColor;
|
|
|
(annotHandlerEventArgs as LineAnnotArgs).LineWidth = lineData.Thickness;
|
|
|
(annotHandlerEventArgs as LineAnnotArgs).Transparency = lineData.Opacity;
|
|
|
(annotHandlerEventArgs as LineAnnotArgs).LineDash = lineData.DashStyle;
|
|
@@ -446,10 +447,22 @@ namespace compdfkit_tools.PDFControl
|
|
|
}
|
|
|
else
|
|
|
{
|
|
|
- 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;
|
|
|
+ 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;
|
|
|
+ }
|
|
|
+
|
|
|
}
|
|
|
Args.Type = stamp.Type;
|
|
|
}
|
|
@@ -470,7 +483,7 @@ namespace compdfkit_tools.PDFControl
|
|
|
{
|
|
|
FreehandAnnotArgs freehandArgs = pdfViewer.ToolManager.CurrentAnnotArgs as FreehandAnnotArgs;
|
|
|
CPDFFreehandData freehandData = e as CPDFFreehandData;
|
|
|
- if(freehandData != null)
|
|
|
+ if (freehandData != null)
|
|
|
{
|
|
|
freehandArgs.InkColor = freehandData.BorderColor;
|
|
|
freehandArgs.LineWidth = freehandData.Thickness;
|
|
@@ -480,7 +493,7 @@ namespace compdfkit_tools.PDFControl
|
|
|
}
|
|
|
}
|
|
|
}
|
|
|
- catch(Exception ex)
|
|
|
+ catch (Exception ex)
|
|
|
{
|
|
|
}
|
|
|
}
|
|
@@ -643,7 +656,7 @@ namespace compdfkit_tools.PDFControl
|
|
|
else
|
|
|
{
|
|
|
this.pdfViewer.SetMouseMode(MouseModes.PanTool);
|
|
|
- }
|
|
|
+ }
|
|
|
ClearAnnotationBar?.Invoke(this, EventArgs.Empty);
|
|
|
ClearPanel();
|
|
|
break;
|
|
@@ -654,7 +667,7 @@ namespace compdfkit_tools.PDFControl
|
|
|
|
|
|
private void PdfFreehandUI_EraseChangeHandler(object sender, double e)
|
|
|
{
|
|
|
- if (pdfViewer != null && eraseArgs!=null)
|
|
|
+ if (pdfViewer != null && eraseArgs != null)
|
|
|
{
|
|
|
eraseArgs.Thickness = e;
|
|
|
}
|
|
@@ -662,17 +675,17 @@ namespace compdfkit_tools.PDFControl
|
|
|
|
|
|
private void PdfFreehandUI_EraseClickHandler(object sender, bool e)
|
|
|
{
|
|
|
- if(pdfViewer!=null)
|
|
|
+ if (pdfViewer != null)
|
|
|
{
|
|
|
CPDFFreehandUI freehandUI = sender as CPDFFreehandUI;
|
|
|
if (e)
|
|
|
{
|
|
|
annotArgs = pdfViewer.ToolManager.CurrentAnnotArgs;
|
|
|
- eraseArgs =new EraseArgs();
|
|
|
+ eraseArgs = new EraseArgs();
|
|
|
eraseArgs.UIBorderColor = Color.FromArgb(0x1A, 0x00, 0x00, 0x00);
|
|
|
eraseArgs.UIFillColor = Color.FromArgb(0x1A, 0x00, 0x00, 0x00);
|
|
|
-
|
|
|
- if(freehandUI!=null)
|
|
|
+
|
|
|
+ if (freehandUI != null)
|
|
|
{
|
|
|
eraseArgs.Thickness = freehandUI.GetEraseThickness();
|
|
|
}
|
|
@@ -680,7 +693,7 @@ namespace compdfkit_tools.PDFControl
|
|
|
{
|
|
|
eraseArgs.Thickness = 1;
|
|
|
}
|
|
|
-
|
|
|
+
|
|
|
disableClean = true;
|
|
|
pdfViewer.SetMouseMode(MouseModes.AnnotCreate);
|
|
|
pdfViewer.SetToolParam(eraseArgs);
|
|
@@ -691,17 +704,17 @@ namespace compdfkit_tools.PDFControl
|
|
|
{
|
|
|
pdfViewer.SetMouseMode(MouseModes.AnnotCreate);
|
|
|
FreehandAnnotArgs freehandAnnotArgs = annotArgs as FreehandAnnotArgs;
|
|
|
- if (freehandAnnotArgs==null)
|
|
|
+ if (freehandAnnotArgs == null)
|
|
|
{
|
|
|
- freehandAnnotArgs=new FreehandAnnotArgs();
|
|
|
+ freehandAnnotArgs = new FreehandAnnotArgs();
|
|
|
|
|
|
freehandAnnotArgs.InkColor = Colors.Red;
|
|
|
freehandAnnotArgs.Transparency = 1;
|
|
|
freehandAnnotArgs.LineWidth = 1;
|
|
|
annotArgs = freehandAnnotArgs;
|
|
|
}
|
|
|
-
|
|
|
- if(freehandUI!=null)
|
|
|
+
|
|
|
+ if (freehandUI != null)
|
|
|
{
|
|
|
freehandUI.PropertyChanged -= CPDFAnnotationControl_PropertyChanged;
|
|
|
Dictionary<AnnotAttrib, object> attribDict = new Dictionary<AnnotAttrib, object>();
|
|
@@ -710,7 +723,7 @@ namespace compdfkit_tools.PDFControl
|
|
|
attribDict[AnnotAttrib.Thickness] = freehandAnnotArgs.LineWidth;
|
|
|
attribDict[AnnotAttrib.NoteText] = freehandAnnotArgs.Content;
|
|
|
|
|
|
- AnnotAttribEvent annotEvent= AnnotAttribEvent.GetAnnotAttribEvent(freehandAnnotArgs, attribDict);
|
|
|
+ AnnotAttribEvent annotEvent = AnnotAttribEvent.GetAnnotAttribEvent(freehandAnnotArgs, attribDict);
|
|
|
freehandUI.SetPresentAnnotAttrib(annotEvent);
|
|
|
freehandUI.PropertyChanged += CPDFAnnotationControl_PropertyChanged;
|
|
|
freehandUI.ClearAnnotAttribEvent();
|
|
@@ -747,7 +760,7 @@ namespace compdfkit_tools.PDFControl
|
|
|
break;
|
|
|
|
|
|
case AnnotArgsType.AnnotFreehand:
|
|
|
- CPDFFreehandUI tempFreehandPanel= new CPDFFreehandUI();
|
|
|
+ CPDFFreehandUI tempFreehandPanel = new CPDFFreehandUI();
|
|
|
tempFreehandPanel.SetPresentAnnotAttrib(annotAttribEvent);
|
|
|
tempFreehandPanel.EraseClickHandler += PdfFreehandUI_EraseClickHandler;
|
|
|
tempFreehandPanel.EraseChangeHandler += PdfFreehandUI_EraseChangeHandler;
|
|
@@ -798,9 +811,9 @@ namespace compdfkit_tools.PDFControl
|
|
|
/// </summary>
|
|
|
private void ShowCurrentAnnotPanel()
|
|
|
{
|
|
|
- if(annotationPanel != null)
|
|
|
+ if (annotationPanel != null)
|
|
|
{
|
|
|
- if(annotationPanel is CPDFFreehandUI)
|
|
|
+ if (annotationPanel is CPDFFreehandUI)
|
|
|
{
|
|
|
(annotationPanel as CPDFFreehandUI)?.SetEraseCheck(false);
|
|
|
}
|
|
@@ -813,11 +826,11 @@ namespace compdfkit_tools.PDFControl
|
|
|
{
|
|
|
EmptyMessage.Visibility = Visibility.Visible;
|
|
|
SetAnnotationPanel(null);
|
|
|
- if (pdfViewer!=null && pdfViewer.ToolManager.CurrentAnnotArgs is EraseArgs)
|
|
|
+ if (pdfViewer != null && pdfViewer.ToolManager.CurrentAnnotArgs is EraseArgs)
|
|
|
{
|
|
|
EmptyMessage.Visibility = Visibility.Collapsed;
|
|
|
}
|
|
|
- }
|
|
|
+ }
|
|
|
}
|
|
|
|
|
|
/// <summary>
|
|
@@ -826,7 +839,7 @@ namespace compdfkit_tools.PDFControl
|
|
|
/// <param name="annotArgsType"></param>
|
|
|
private void ShowTempAnnotPanel(AnnotAttribEvent annotAttribEvent)
|
|
|
{
|
|
|
- if(annotAttribEvent != null)
|
|
|
+ if (annotAttribEvent != null)
|
|
|
{
|
|
|
CreatTempAnnotationPanel(annotAttribEvent);
|
|
|
SetAnnotationPanel(tempAnnotationPanel);
|
|
@@ -837,7 +850,7 @@ namespace compdfkit_tools.PDFControl
|
|
|
}
|
|
|
else
|
|
|
{
|
|
|
- EmptyMessage.Visibility = Visibility.Visible;
|
|
|
+ EmptyMessage.Visibility = Visibility.Visible;
|
|
|
}
|
|
|
}
|
|
|
}
|