|
@@ -3,8 +3,10 @@ using ComPDFKit.PDFDocument;
|
|
|
using ComPDFKit.PDFPage;
|
|
|
using ComPDFKitViewer.AnnotEvent;
|
|
|
using ComPDFKitViewer.PdfViewer;
|
|
|
+using Microsoft.Win32;
|
|
|
using PDF_Office.Model;
|
|
|
using PDF_Office.Model.AnnotPanel;
|
|
|
+using PDF_Office.Properties;
|
|
|
using Prism.Commands;
|
|
|
using Prism.Mvvm;
|
|
|
using Prism.Regions;
|
|
@@ -12,6 +14,7 @@ using Prism.Services.Dialogs;
|
|
|
using System;
|
|
|
using System.Collections.Generic;
|
|
|
using System.Collections.ObjectModel;
|
|
|
+using System.IO;
|
|
|
using System.Linq;
|
|
|
using System.Text;
|
|
|
using System.Threading.Tasks;
|
|
@@ -158,10 +161,25 @@ namespace PDF_Office.ViewModels.PropertyPanel.AnnotPanel
|
|
|
ShowDialogCommand = new DelegateCommand(ShowDialog);
|
|
|
InitStandardStamp();
|
|
|
UpDataDynamicStampList();
|
|
|
- //CPDFDocument doc = CPDFDocument.CreateDocument();
|
|
|
- //bool tt= doc.InsertPage(0, 300, 500, Path[0]);
|
|
|
- //doc.WriteToFilePath("D:\\fafdas.pdf");
|
|
|
- //doc.Release();
|
|
|
+ }
|
|
|
+
|
|
|
+ private void LoadSettings()
|
|
|
+ {
|
|
|
+ PDFSettings.CustomStampList stamps = Settings.Default.CustomStampList;
|
|
|
+ for (int i = 0; i < stamps.Count; i++)
|
|
|
+ {
|
|
|
+ Stamp customStamp = new Stamp();
|
|
|
+ customStamp.Opacity = 1;
|
|
|
+ customStamp.Author = stamps[i].Author;
|
|
|
+ customStamp.StampText = stamps[i].StampText;
|
|
|
+ customStamp.StampTextDate = stamps[i].StampTextDate;
|
|
|
+ customStamp.MaxWidth = stamps[i].ImageWidth;
|
|
|
+ customStamp.MaxHeight = stamps[i].ImageHeight;
|
|
|
+ customStamp.SourcePath = stamps[i].SourcePath;
|
|
|
+ customStamp.Type = stamps[i].Type;
|
|
|
+ customStamp.TextColor = stamps[i].TextColor;
|
|
|
+ CustomStampList.Add(customStamp);
|
|
|
+ }
|
|
|
}
|
|
|
|
|
|
/// <summary>
|
|
@@ -308,6 +326,46 @@ namespace PDF_Office.ViewModels.PropertyPanel.AnnotPanel
|
|
|
}
|
|
|
}
|
|
|
|
|
|
+ public void SaveToPath(string FileType, Stamp Item)
|
|
|
+ {
|
|
|
+ SaveFileDialog saveFileDialog = new SaveFileDialog();
|
|
|
+ saveFileDialog.Title = "保存" + FileType + "文件";
|
|
|
+ saveFileDialog.Filter = "(*)|*." + FileType;
|
|
|
+
|
|
|
+ if (saveFileDialog.ShowDialog() == false)
|
|
|
+ {
|
|
|
+ return;
|
|
|
+ }
|
|
|
+ BitmapEncoder encoder;
|
|
|
+ if (FileType.ToUpper() == "JPG")
|
|
|
+ {
|
|
|
+ encoder = new JpegBitmapEncoder();
|
|
|
+ }
|
|
|
+ else
|
|
|
+ {
|
|
|
+ encoder = new PngBitmapEncoder();
|
|
|
+ }
|
|
|
+ encoder.Frames.Add(BitmapFrame.Create(new Uri(Item.SourcePath)));
|
|
|
+
|
|
|
+ if (FileType.ToUpper() != "PDF")
|
|
|
+ {
|
|
|
+ string path = saveFileDialog.FileName;
|
|
|
+ using (FileStream stream = new FileStream(path, FileMode.Create))
|
|
|
+ {
|
|
|
+ encoder.Save(stream);
|
|
|
+ }
|
|
|
+
|
|
|
+ CPDFDocument doc = CPDFDocument.CreateDocument();
|
|
|
+ bool tt = doc.InsertPage(0, 300, 500, path);
|
|
|
+ doc.WriteToFilePath("C:\\Users\\93131\\Desktop\\test\\cache\\fafdas.pdf");
|
|
|
+ doc.Release();
|
|
|
+ System.Diagnostics.Process.Start("explorer", "/select,\"" + path + "\"");
|
|
|
+ }
|
|
|
+ else
|
|
|
+ {
|
|
|
+
|
|
|
+ }
|
|
|
+ }
|
|
|
private void ShowDialog()
|
|
|
{
|
|
|
switch (TabControlSelectedIndex)
|
|
@@ -362,6 +420,7 @@ namespace PDF_Office.ViewModels.PropertyPanel.AnnotPanel
|
|
|
CustomCreateDialogViewModel CustomVM = e.Parameters.GetValue<CustomCreateDialogViewModel>(ParameterNames.DataModel);
|
|
|
if (CustomVM != null)
|
|
|
{
|
|
|
+ CreateCustomStamp(CustomVM);
|
|
|
}
|
|
|
});
|
|
|
if (!result)
|
|
@@ -369,5 +428,19 @@ namespace PDF_Office.ViewModels.PropertyPanel.AnnotPanel
|
|
|
return;
|
|
|
}
|
|
|
}
|
|
|
+
|
|
|
+ private void CreateCustomStamp(CustomCreateDialogViewModel viewModel)
|
|
|
+ {
|
|
|
+ Stamp stamp = new Stamp();
|
|
|
+ stamp.Author = "";
|
|
|
+ stamp.Opacity = 1;
|
|
|
+ stamp.SourcePath = viewModel.SaveToPath;
|
|
|
+ stamp.StampText = viewModel.StampText;
|
|
|
+ stamp.MaxWidth = viewModel.ImageSource.PixelWidth;
|
|
|
+ stamp.MaxHeight = viewModel.ImageSource.PixelHeight;
|
|
|
+ stamp.StampTextDate = viewModel.StampTextDate;
|
|
|
+ stamp.Type = viewModel.Type;
|
|
|
+ CustomStampList.Add(stamp);
|
|
|
+ }
|
|
|
}
|
|
|
}
|