|
@@ -163,24 +163,32 @@ namespace PDF_Office.ViewModels.PropertyPanel.AnnotPanel
|
|
ShowDialogCommand = new DelegateCommand(ShowDialog);
|
|
ShowDialogCommand = new DelegateCommand(ShowDialog);
|
|
InitStandardStamp();
|
|
InitStandardStamp();
|
|
UpDataDynamicStampList();
|
|
UpDataDynamicStampList();
|
|
|
|
+ LoadSettings();
|
|
}
|
|
}
|
|
|
|
|
|
|
|
+ /// <summary>
|
|
|
|
+ /// 加载缓存的自定义图章
|
|
|
|
+ /// </summary>
|
|
private void LoadSettings()
|
|
private void LoadSettings()
|
|
{
|
|
{
|
|
PDFSettings.CustomStampList stamps = Settings.Default.CustomStampList;
|
|
PDFSettings.CustomStampList stamps = Settings.Default.CustomStampList;
|
|
- for (int i = 0; i < stamps.Count; i++)
|
|
|
|
|
|
+ if (stamps != null)
|
|
{
|
|
{
|
|
- 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);
|
|
|
|
|
|
+ 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.TextSharp = stamps[i].TextSharp;
|
|
|
|
+ customStamp.TextColor = stamps[i].TextColor;
|
|
|
|
+ CustomStampList.Add(customStamp);
|
|
|
|
+ }
|
|
}
|
|
}
|
|
}
|
|
}
|
|
|
|
|
|
@@ -231,8 +239,17 @@ namespace PDF_Office.ViewModels.PropertyPanel.AnnotPanel
|
|
Args.StampText = stamp.StampText;
|
|
Args.StampText = stamp.StampText;
|
|
Args.Author = stamp.Author;
|
|
Args.Author = stamp.Author;
|
|
Args.Opacity = stamp.Opacity;
|
|
Args.Opacity = stamp.Opacity;
|
|
- Args.MaxWidth = stamp.MaxWidth;
|
|
|
|
- Args.MaxHeight = stamp.MaxHeight;
|
|
|
|
|
|
+ if (stamp.Type == StampType.IMAGE_STAMP)
|
|
|
|
+ {
|
|
|
|
+
|
|
|
|
+ Args.ImageWidth = stamp.MaxWidth;
|
|
|
|
+ Args.ImageHeight = stamp.MaxHeight;
|
|
|
|
+ }
|
|
|
|
+ else
|
|
|
|
+ {
|
|
|
|
+ Args.MaxWidth = stamp.MaxWidth;
|
|
|
|
+ Args.MaxHeight = stamp.MaxHeight;
|
|
|
|
+ }
|
|
Args.StampTextDate = stamp.StampTextDate;
|
|
Args.StampTextDate = stamp.StampTextDate;
|
|
Args.TextColor = stamp.TextColor;
|
|
Args.TextColor = stamp.TextColor;
|
|
Args.TextSharp = stamp.TextSharp;
|
|
Args.TextSharp = stamp.TextSharp;
|
|
@@ -331,6 +348,9 @@ namespace PDF_Office.ViewModels.PropertyPanel.AnnotPanel
|
|
}
|
|
}
|
|
}
|
|
}
|
|
|
|
|
|
|
|
+ /// <summary>
|
|
|
|
+ /// 导出图章
|
|
|
|
+ /// </summary>
|
|
public void SaveToPath(string FileType, Stamp Item)
|
|
public void SaveToPath(string FileType, Stamp Item)
|
|
{
|
|
{
|
|
SaveFileDialog saveFileDialog = new SaveFileDialog();
|
|
SaveFileDialog saveFileDialog = new SaveFileDialog();
|
|
@@ -351,25 +371,49 @@ namespace PDF_Office.ViewModels.PropertyPanel.AnnotPanel
|
|
encoder = new PngBitmapEncoder();
|
|
encoder = new PngBitmapEncoder();
|
|
}
|
|
}
|
|
encoder.Frames.Add(BitmapFrame.Create(new Uri(Item.SourcePath)));
|
|
encoder.Frames.Add(BitmapFrame.Create(new Uri(Item.SourcePath)));
|
|
-
|
|
|
|
- if (FileType.ToUpper() != "PDF")
|
|
|
|
|
|
+ string path = saveFileDialog.FileName;
|
|
|
|
+ switch (FileType.ToUpper())
|
|
{
|
|
{
|
|
- 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 + "\"");
|
|
|
|
|
|
+ case "PDF":
|
|
|
|
+ CPDFDocument newDoc = CPDFDocument.CreateDocument();
|
|
|
|
+ BitmapFrame frame = BitmapFrame.Create(new Uri(Item.SourcePath));
|
|
|
|
+ byte[] imageData = new byte[frame.PixelWidth * frame.PixelHeight * 4];
|
|
|
|
+ frame.CopyPixels(imageData, frame.PixelWidth * 4, 0);
|
|
|
|
+ newDoc.InsertPage(0, frame.PixelWidth, frame.PixelHeight, imageData, CPDFDocumentImageMode.CPDFDocumentImageModeScaleToFill);
|
|
|
|
+ newDoc.WriteToFilePath(path);
|
|
|
|
+ break;
|
|
|
|
+ case "PNG":
|
|
|
|
+ using (FileStream stream = new FileStream(path, FileMode.Create))
|
|
|
|
+ {
|
|
|
|
+ encoder.Save(stream);
|
|
|
|
+ }
|
|
|
|
+ break;
|
|
|
|
+ default:
|
|
|
|
+ break;
|
|
}
|
|
}
|
|
- else
|
|
|
|
- {
|
|
|
|
|
|
+ System.Diagnostics.Process.Start("explorer", "/select,\"" + path + "\"");
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ public void DeleteStamp(Stamp stamp)
|
|
|
|
+ {
|
|
|
|
+ int index = CustomStampList.IndexOf(stamp);
|
|
|
|
+ App.CachePath.AddToDeleteFiles(stamp.SourcePath);
|
|
|
|
+ CustomStampList.RemoveAt(index);
|
|
|
|
+ PDFSettings.CustomStampList stamps = Settings.Default.CustomStampList;
|
|
|
|
+ stamps.RemoveAt(index);
|
|
|
|
+ Settings.Default.Save();
|
|
|
|
+ }
|
|
|
|
|
|
|
|
+ public void DeleteAll()
|
|
|
|
+ {
|
|
|
|
+ foreach (Stamp item in CustomStampList)
|
|
|
|
+ {
|
|
|
|
+ App.CachePath.AddToDeleteFiles(item.SourcePath);
|
|
}
|
|
}
|
|
|
|
+ CustomStampList.Clear();
|
|
|
|
+ PDFSettings.CustomStampList stamps = Settings.Default.CustomStampList;
|
|
|
|
+ stamps.Clear();
|
|
|
|
+ Settings.Default.Save();
|
|
}
|
|
}
|
|
private void ShowDialog()
|
|
private void ShowDialog()
|
|
{
|
|
{
|
|
@@ -434,6 +478,9 @@ namespace PDF_Office.ViewModels.PropertyPanel.AnnotPanel
|
|
}
|
|
}
|
|
}
|
|
}
|
|
|
|
|
|
|
|
+ /// <summary>
|
|
|
|
+ /// 创建自定义图章,并且保存到APP缓存
|
|
|
|
+ /// </summary>
|
|
private void CreateCustomStamp(CustomCreateDialogViewModel viewModel)
|
|
private void CreateCustomStamp(CustomCreateDialogViewModel viewModel)
|
|
{
|
|
{
|
|
Stamp stamp = new Stamp();
|
|
Stamp stamp = new Stamp();
|
|
@@ -441,13 +488,32 @@ namespace PDF_Office.ViewModels.PropertyPanel.AnnotPanel
|
|
stamp.Opacity = 1;
|
|
stamp.Opacity = 1;
|
|
stamp.SourcePath = viewModel.SaveToPath;
|
|
stamp.SourcePath = viewModel.SaveToPath;
|
|
stamp.StampText = viewModel.StampText;
|
|
stamp.StampText = viewModel.StampText;
|
|
- stamp.MaxWidth = (int)DpiHelpers.GetDpiUnrelatedNum(viewModel.StampWidth/ 72D * DpiHelpers.Dpi);
|
|
|
|
|
|
+ stamp.MaxWidth = (int)DpiHelpers.GetDpiUnrelatedNum(viewModel.StampWidth / 72D * DpiHelpers.Dpi);
|
|
stamp.MaxHeight = (int)DpiHelpers.GetDpiUnrelatedNum(viewModel.StampHeight / 72D * DpiHelpers.Dpi);
|
|
stamp.MaxHeight = (int)DpiHelpers.GetDpiUnrelatedNum(viewModel.StampHeight / 72D * DpiHelpers.Dpi);
|
|
stamp.StampTextDate = viewModel.StampTextDate;
|
|
stamp.StampTextDate = viewModel.StampTextDate;
|
|
stamp.Type = viewModel.Type;
|
|
stamp.Type = viewModel.Type;
|
|
stamp.TextColor = (TextStampColor)(int)viewModel.Color;
|
|
stamp.TextColor = (TextStampColor)(int)viewModel.Color;
|
|
stamp.TextSharp = (TextStampSharp)(int)viewModel.Shape;
|
|
stamp.TextSharp = (TextStampSharp)(int)viewModel.Shape;
|
|
CustomStampList.Add(stamp);
|
|
CustomStampList.Add(stamp);
|
|
|
|
+
|
|
|
|
+ PDFSettings.CustomStampList stamps = Settings.Default.CustomStampList;
|
|
|
|
+ if (stamps == null)
|
|
|
|
+ {
|
|
|
|
+ stamps = Settings.Default.CustomStampList = new PDFSettings.CustomStampList();
|
|
|
|
+ }
|
|
|
|
+ PDFSettings.StampAnnote annote = new PDFSettings.StampAnnote();
|
|
|
|
+ Stamp customStamp = new Stamp();
|
|
|
|
+ annote.Author = stamp.Author;
|
|
|
|
+ annote.StampText = stamp.StampText;
|
|
|
|
+ annote.StampTextDate = stamp.StampTextDate;
|
|
|
|
+ annote.ImageWidth = stamp.MaxWidth;
|
|
|
|
+ annote.ImageHeight = stamp.MaxHeight;
|
|
|
|
+ annote.SourcePath = stamp.SourcePath;
|
|
|
|
+ annote.Type = stamp.Type;
|
|
|
|
+ annote.TextSharp = stamp.TextSharp;
|
|
|
|
+ annote.TextColor = stamp.TextColor;
|
|
|
|
+ stamps.Add(annote);
|
|
|
|
+ Settings.Default.Save();
|
|
}
|
|
}
|
|
}
|
|
}
|
|
}
|
|
}
|