|
@@ -1,12 +1,130 @@
|
|
|
-using System;
|
|
|
+using ComPDFKitViewer.AnnotEvent;
|
|
|
+using ComPDFKitViewer.PdfViewer;
|
|
|
+using PDF_Office.Model;
|
|
|
+using PDF_Office.Model.AnnotPanel;
|
|
|
+using Prism.Commands;
|
|
|
+using Prism.Mvvm;
|
|
|
+using Prism.Regions;
|
|
|
+using System;
|
|
|
using System.Collections.Generic;
|
|
|
+using System.Collections.ObjectModel;
|
|
|
using System.Linq;
|
|
|
using System.Text;
|
|
|
using System.Threading.Tasks;
|
|
|
+using System.Windows.Media.Imaging;
|
|
|
|
|
|
namespace PDF_Office.ViewModels.PropertyPanel.AnnotPanel
|
|
|
{
|
|
|
- internal class StampAnnotPropertyViewModel
|
|
|
+ internal class StampAnnotPropertyViewModel : BindableBase, INavigationAware
|
|
|
{
|
|
|
+ #region 标准图章相关默认配置(如果需要修改,要留意按顺序一一对应的)
|
|
|
+
|
|
|
+ List<string> Path = new List<string>
|
|
|
+ {
|
|
|
+ "pack://application:,,,/PDF Office;component/Resources/StampIcons/Approved.png",
|
|
|
+ "pack://application:,,,/PDF Office;component/Resources/StampIcons/NotApproved.png",
|
|
|
+ "pack://application:,,,/PDF Office;component/Resources/StampIcons/Completed.png",
|
|
|
+ "pack://application:,,,/PDF Office;component/Resources/StampIcons/Final.png",
|
|
|
+ "pack://application:,,,/PDF Office;component/Resources/StampIcons/Draft.png",
|
|
|
+ "pack://application:,,,/PDF Office;component/Resources/StampIcons/Confidential.png",
|
|
|
+ "pack://application:,,,/PDF Office;component/Resources/StampIcons/ForPublicRelease.png",
|
|
|
+ "pack://application:,,,/PDF Office;component/Resources/StampIcons/NotForPublicRelease.png",
|
|
|
+ "pack://application:,,,/PDF Office;component/Resources/StampIcons/ForComment.png",
|
|
|
+ "pack://application:,,,/PDF Office;component/Resources/StampIcons/Void.png",
|
|
|
+ "pack://application:,,,/PDF Office;component/Resources/StampIcons/PreliminaryResults.png",
|
|
|
+ "pack://application:,,,/PDF Office;component/Resources/StampIcons/InformationOnly.png",
|
|
|
+ "pack://application:,,,/PDF Office;component/Resources/StampIcons/Accepted.png",
|
|
|
+ "pack://application:,,,/PDF Office;component/Resources/StampIcons/Rejected.png",
|
|
|
+ "pack://application:,,,/PDF Office;component/Resources/StampIcons/Witness.png",
|
|
|
+ "pack://application:,,,/PDF Office;component/Resources/StampIcons/InitialHere.png",
|
|
|
+ "pack://application:,,,/PDF Office;component/Resources/StampIcons/SignHere.png",
|
|
|
+ "pack://application:,,,/PDF Office;component/Resources/StampIcons/revised.png",
|
|
|
+ "pack://application:,,,/PDF Office;component/Resources/StampIcons/PrivateMark1.png",
|
|
|
+ "pack://application:,,,/PDF Office;component/Resources/StampIcons/PrivateMark2.png",
|
|
|
+ "pack://application:,,,/PDF Office;component/Resources/StampIcons/PrivateMark3.png",
|
|
|
+ };
|
|
|
+ List<string> StampText = new List<string>
|
|
|
+ {
|
|
|
+ "Approved","NotApproved","Completed","Final","Draft","Confidential","ForPublicRelease","NotForPublicRelease",
|
|
|
+ "ForComment","Void","PreliminaryResults","InformationOnly","Accepted","Rejected","Witness","InitialHere","SignHere",
|
|
|
+ "revised","PrivateMark#1","PrivateMark#2","PrivateMark#3"
|
|
|
+ };
|
|
|
+ List<int> MaxWidth = new List<int>
|
|
|
+ {
|
|
|
+ 218,292,234,130,150,280,386,461,282,121,405,366,30,30,133,133,133,173,30,30,30
|
|
|
+ };
|
|
|
+ List<int> MaxHeight = new List<int>
|
|
|
+ {
|
|
|
+ 66,66,66,66,66,66,66,66,66,66,66,66,30,30,39,39,39,66,30,30,30
|
|
|
+ };
|
|
|
+
|
|
|
+ #endregion
|
|
|
+
|
|
|
+ private CPDFViewer PDFViewer;
|
|
|
+ public ObservableCollection<Stamp> StandardStampList { get; set; }
|
|
|
+ public ObservableCollection<Stamp> DynamicStampList { get; set; }
|
|
|
+ public ObservableCollection<Stamp> CustomStampList { get; set; }
|
|
|
+
|
|
|
+ public StampAnnotPropertyViewModel()
|
|
|
+ {
|
|
|
+ StandardStampList = new ObservableCollection<Stamp>();
|
|
|
+ DynamicStampList = new ObservableCollection<Stamp>();
|
|
|
+ CustomStampList = new ObservableCollection<Stamp>();
|
|
|
+ InitStandardStamp();
|
|
|
+ }
|
|
|
+
|
|
|
+ /// <summary>
|
|
|
+ /// 初始化标准图章相关内容
|
|
|
+ /// </summary>
|
|
|
+ private void InitStandardStamp()
|
|
|
+ {
|
|
|
+ for (int i = 0; i < Path.Count; i++)
|
|
|
+ {
|
|
|
+ Stamp standardStamp = new Stamp();
|
|
|
+ standardStamp.Author = "";
|
|
|
+ standardStamp.Opacity = 1;
|
|
|
+ standardStamp.SourcePath = Path[i];
|
|
|
+ standardStamp.StampText = StampText[i];
|
|
|
+ standardStamp.MaxWidth = MaxWidth[i];
|
|
|
+ standardStamp.MaxHeight = MaxHeight[i];
|
|
|
+ standardStamp.Type = StampType.STANDARD_STAMP;
|
|
|
+ StandardStampList.Add(standardStamp);
|
|
|
+ }
|
|
|
+ }
|
|
|
+ public bool IsNavigationTarget(NavigationContext navigationContext)
|
|
|
+ {
|
|
|
+ return true;
|
|
|
+ }
|
|
|
+
|
|
|
+ public void OnNavigatedFrom(NavigationContext navigationContext)
|
|
|
+ {
|
|
|
+ return;
|
|
|
+ }
|
|
|
+
|
|
|
+ public void OnNavigatedTo(NavigationContext navigationContext)
|
|
|
+ {
|
|
|
+ navigationContext.Parameters.TryGetValue<CPDFViewer>(ParameterNames.PDFViewer, out PDFViewer);
|
|
|
+ if (PDFViewer == null)
|
|
|
+ {
|
|
|
+ return;
|
|
|
+ }
|
|
|
+ }
|
|
|
+ public void SetStandardStamp(Stamp stamp)
|
|
|
+ {
|
|
|
+ StampAnnotArgs Args = new StampAnnotArgs();
|
|
|
+ Args.StampText = stamp.StampText;
|
|
|
+ Args.Author = stamp.Author;
|
|
|
+ Args.Opacity = stamp.Opacity;
|
|
|
+ Args.MaxWidth = stamp.MaxWidth;
|
|
|
+ Args.MaxHeight = stamp.MaxHeight;
|
|
|
+ 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;
|
|
|
+ Args.Type = stamp.Type;
|
|
|
+ PDFViewer.SetMouseMode(MouseModes.AnnotCreate);
|
|
|
+ PDFViewer.SetToolParam(Args);
|
|
|
+ }
|
|
|
}
|
|
|
}
|