|
@@ -1,5 +1,8 @@
|
|
|
-using compdfkit_tools.Data;
|
|
|
+using ComPDFKit.Import;
|
|
|
+using compdfkit_tools.Data;
|
|
|
using compdfkit_tools.Properties;
|
|
|
+using ComPDFKitViewer.AnnotEvent;
|
|
|
+using ComPDFKitViewer.PdfViewer;
|
|
|
using System;
|
|
|
using System.Collections.Generic;
|
|
|
using System.Collections.ObjectModel;
|
|
@@ -24,11 +27,18 @@ namespace compdfkit_tools.Annotation.PDFAnnotationPanel.PDFAnnotationUI
|
|
|
{
|
|
|
public event EventHandler<CPDFAnnotationData> PropertyChanged;
|
|
|
public ObservableCollection<CPDFSignatureData> SignatureList { get; set; }
|
|
|
+ private WidgetSignArgs widgetSignArgs;
|
|
|
+ private CPDFViewer pdfViewer;
|
|
|
+
|
|
|
public CPDFSignatureUI()
|
|
|
{
|
|
|
InitializeComponent();
|
|
|
}
|
|
|
-
|
|
|
+ public void SetFormProperty(WidgetArgs Args, CPDFViewer cPDFViewer)
|
|
|
+ {
|
|
|
+ widgetSignArgs = (WidgetSignArgs)Args;
|
|
|
+ pdfViewer = cPDFViewer;
|
|
|
+ }
|
|
|
private void UserControl_Loaded(object sender, RoutedEventArgs e)
|
|
|
{
|
|
|
SignatureList = new ObservableCollection<CPDFSignatureData>();
|
|
@@ -59,7 +69,39 @@ namespace compdfkit_tools.Annotation.PDFAnnotationPanel.PDFAnnotationUI
|
|
|
|
|
|
private void Signature_PreviewMouseLeftButtonDown(object sender, MouseButtonEventArgs e)
|
|
|
{
|
|
|
- PropertyChanged?.Invoke(this, (sender as ListBoxItem).DataContext as CPDFSignatureData);
|
|
|
+ if (widgetSignArgs == null || pdfViewer == null)
|
|
|
+ {
|
|
|
+ PropertyChanged?.Invoke(this, (sender as ListBoxItem).DataContext as CPDFSignatureData);
|
|
|
+ }
|
|
|
+ else
|
|
|
+ {
|
|
|
+ FillForm(((sender as ListBoxItem).DataContext as CPDFSignatureData).SourcePath);
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+ private void FillForm(string ImagePath)
|
|
|
+ {
|
|
|
+ if (!string.IsNullOrEmpty(ImagePath))
|
|
|
+ {
|
|
|
+ using (FileStream fileData = File.OpenRead(ImagePath))
|
|
|
+ {
|
|
|
+ BitmapFrame frame = null;
|
|
|
+ BitmapDecoder decoder = BitmapDecoder.Create(fileData, BitmapCreateOptions.None, BitmapCacheOption.Default);
|
|
|
+ if (decoder != null && decoder.Frames.Count > 0)
|
|
|
+ {
|
|
|
+ frame = decoder.Frames[0];
|
|
|
+ }
|
|
|
+ if (frame != null)
|
|
|
+ {
|
|
|
+ byte[] ImageArray = new byte[frame.PixelWidth * frame.PixelHeight * 4];
|
|
|
+ int ImageWidth = frame.PixelWidth;
|
|
|
+ int ImageHeight = frame.PixelHeight;
|
|
|
+ frame.CopyPixels(ImageArray, frame.PixelWidth * 4, 0);
|
|
|
+ widgetSignArgs?.UpdateApWithImage(ImageArray, ImageWidth, ImageHeight, C_Scale_Type.fitCenter, 0);
|
|
|
+ pdfViewer?.ReloadVisibleAnnots();
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
}
|
|
|
|
|
|
private void CreateSignature_Click(object sender, RoutedEventArgs e)
|
|
@@ -101,14 +143,14 @@ namespace compdfkit_tools.Annotation.PDFAnnotationPanel.PDFAnnotationUI
|
|
|
{
|
|
|
CPDFDeleteDialog cPDFDeleteDialog = new CPDFDeleteDialog("Warning", "Are you sure to delete?");
|
|
|
cPDFDeleteDialog.Owner = Window.GetWindow(this);
|
|
|
- cPDFDeleteDialog.WindowStartupLocation= WindowStartupLocation.CenterOwner;
|
|
|
+ cPDFDeleteDialog.WindowStartupLocation = WindowStartupLocation.CenterOwner;
|
|
|
cPDFDeleteDialog.ShowDialog();
|
|
|
if (!cPDFDeleteDialog.IsDelete)
|
|
|
{
|
|
|
return;
|
|
|
}
|
|
|
|
|
|
- if (data.SourcePath!=null)
|
|
|
+ if (data.SourcePath != null)
|
|
|
{
|
|
|
try
|
|
|
{
|
|
@@ -136,5 +178,11 @@ namespace compdfkit_tools.Annotation.PDFAnnotationPanel.PDFAnnotationUI
|
|
|
}
|
|
|
}
|
|
|
}
|
|
|
+
|
|
|
+ private void UserControl_Unloaded(object sender, RoutedEventArgs e)
|
|
|
+ {
|
|
|
+ widgetSignArgs = null;
|
|
|
+ pdfViewer = null;
|
|
|
+ }
|
|
|
}
|
|
|
}
|