|
@@ -0,0 +1,263 @@
|
|
|
|
+using ComPDFKit.PDFDocument;
|
|
|
|
+using ComPDFKitViewer.PdfViewer;
|
|
|
|
+using PDF_Office.Helper;
|
|
|
|
+using PDF_Office.Model;
|
|
|
|
+using Prism.Mvvm;
|
|
|
|
+using Prism.Services.Dialogs;
|
|
|
|
+using System;
|
|
|
|
+using System.Collections.Generic;
|
|
|
|
+using System.Linq;
|
|
|
|
+using System.Text;
|
|
|
|
+using System.Text.RegularExpressions;
|
|
|
|
+using System.Threading.Tasks;
|
|
|
|
+
|
|
|
|
+namespace PDF_Office.ViewModels.Dialog
|
|
|
|
+{
|
|
|
|
+ public class PropertiesDialogViewModel : BindableBase, IDialogAware
|
|
|
|
+ {
|
|
|
|
+ public string Title => "";
|
|
|
|
+
|
|
|
|
+ public event Action<IDialogResult> RequestClose;
|
|
|
|
+
|
|
|
|
+ private CPDFDocument Document;
|
|
|
|
+
|
|
|
|
+ private string fileName;
|
|
|
|
+ /// <summary>
|
|
|
|
+ /// 文件名
|
|
|
|
+ /// </summary>
|
|
|
|
+ public string FileName
|
|
|
|
+ {
|
|
|
|
+ get { return fileName; }
|
|
|
|
+ set
|
|
|
|
+ {
|
|
|
|
+ SetProperty(ref fileName, value);
|
|
|
|
+ }
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ private string fileSize;
|
|
|
|
+ /// <summary>
|
|
|
|
+ /// 文件大小
|
|
|
|
+ /// </summary>
|
|
|
|
+ public string FileSize
|
|
|
|
+ {
|
|
|
|
+ get { return fileSize; }
|
|
|
|
+ set
|
|
|
|
+ {
|
|
|
|
+ SetProperty(ref fileSize, value);
|
|
|
|
+ }
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ private string title;
|
|
|
|
+ /// <summary>
|
|
|
|
+ /// 文件标题
|
|
|
|
+ /// </summary>
|
|
|
|
+ public string FileTitle
|
|
|
|
+ {
|
|
|
|
+ get { return title; }
|
|
|
|
+ set
|
|
|
|
+ {
|
|
|
|
+ SetProperty(ref title, value);
|
|
|
|
+ }
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ private string author;
|
|
|
|
+ /// <summary>
|
|
|
|
+ /// 作者
|
|
|
|
+ /// </summary>
|
|
|
|
+ public string Author
|
|
|
|
+ {
|
|
|
|
+ get { return author; }
|
|
|
|
+ set
|
|
|
|
+ {
|
|
|
|
+ SetProperty(ref author, value);
|
|
|
|
+ }
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ private string filePath;
|
|
|
|
+ /// <summary>
|
|
|
|
+ /// 文件路径
|
|
|
|
+ /// </summary>
|
|
|
|
+ public string FilePath
|
|
|
|
+ {
|
|
|
|
+ get { return filePath; }
|
|
|
|
+ set
|
|
|
|
+ {
|
|
|
|
+ SetProperty(ref filePath, value);
|
|
|
|
+ }
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ private string version;
|
|
|
|
+ /// <summary>
|
|
|
|
+ /// 版本
|
|
|
|
+ /// </summary>
|
|
|
|
+ public string Version
|
|
|
|
+ {
|
|
|
|
+ get { return version; }
|
|
|
|
+ set
|
|
|
|
+ {
|
|
|
|
+ SetProperty(ref version, value);
|
|
|
|
+ }
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ private int pageCounr;
|
|
|
|
+ /// <summary>
|
|
|
|
+ /// 页面大小
|
|
|
|
+ /// </summary>
|
|
|
|
+ public int PageCount
|
|
|
|
+ {
|
|
|
|
+ get { return pageCounr; }
|
|
|
|
+ set
|
|
|
|
+ {
|
|
|
|
+ SetProperty(ref pageCounr, value);
|
|
|
|
+ }
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ private string creator;
|
|
|
|
+ /// <summary>
|
|
|
|
+ /// 创建软件名
|
|
|
|
+ /// </summary>
|
|
|
|
+ public string Creator
|
|
|
|
+ {
|
|
|
|
+ get { return creator; }
|
|
|
|
+ set
|
|
|
|
+ {
|
|
|
|
+ SetProperty(ref creator, value);
|
|
|
|
+ }
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ private string productor;
|
|
|
|
+
|
|
|
|
+ public string Productor
|
|
|
|
+ {
|
|
|
|
+ get { return productor; }
|
|
|
|
+ set
|
|
|
|
+ {
|
|
|
|
+ SetProperty(ref productor, value);
|
|
|
|
+ }
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ private string createDate;
|
|
|
|
+ /// <summary>
|
|
|
|
+ /// 创建日期
|
|
|
|
+ /// </summary>
|
|
|
|
+ public string CreateDate
|
|
|
|
+ {
|
|
|
|
+ get { return createDate; }
|
|
|
|
+ set
|
|
|
|
+ {
|
|
|
|
+ SetProperty(ref createDate, value);
|
|
|
|
+ }
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ private string modifyDate;
|
|
|
|
+ /// <summary>
|
|
|
|
+ /// 编辑日期
|
|
|
|
+ /// </summary>
|
|
|
|
+ public string ModifyDate
|
|
|
|
+ {
|
|
|
|
+ get { return modifyDate; }
|
|
|
|
+ set
|
|
|
|
+ {
|
|
|
|
+ SetProperty(ref modifyDate, value);
|
|
|
|
+ }
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+
|
|
|
|
+ private string isEncrypted;
|
|
|
|
+ /// <summary>
|
|
|
|
+ /// 是否加密
|
|
|
|
+ /// </summary>
|
|
|
|
+ public string IsEncrypted
|
|
|
|
+ {
|
|
|
|
+ get { return isEncrypted; }
|
|
|
|
+ set
|
|
|
|
+ {
|
|
|
|
+ SetProperty(ref isEncrypted, value);
|
|
|
|
+ }
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ private string isUnlocked;
|
|
|
|
+ /// <summary>
|
|
|
|
+ /// 是否加锁
|
|
|
|
+ /// </summary>
|
|
|
|
+ public string IsUnlocked
|
|
|
|
+ {
|
|
|
|
+ get { return isUnlocked; }
|
|
|
|
+ set
|
|
|
|
+ {
|
|
|
|
+ SetProperty(ref isUnlocked, value);
|
|
|
|
+ }
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ private string allowCopy;
|
|
|
|
+ /// <summary>
|
|
|
|
+ /// 允许复制
|
|
|
|
+ /// </summary>
|
|
|
|
+ public string AllowCopy
|
|
|
|
+ {
|
|
|
|
+ get { return allowCopy; }
|
|
|
|
+ set
|
|
|
|
+ {
|
|
|
|
+ SetProperty(ref allowCopy, value);
|
|
|
|
+ }
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ private string allowPrint;
|
|
|
|
+ /// <summary>
|
|
|
|
+ /// 允许打印
|
|
|
|
+ /// </summary>
|
|
|
|
+ public string AllowPrint
|
|
|
|
+ {
|
|
|
|
+ get { return allowPrint; }
|
|
|
|
+ set
|
|
|
|
+ {
|
|
|
|
+ SetProperty(ref allowPrint, value);
|
|
|
|
+ }
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+
|
|
|
|
+ public PropertiesDialogViewModel()
|
|
|
|
+ {
|
|
|
|
+
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ public bool CanCloseDialog()
|
|
|
|
+ {
|
|
|
|
+ return true;
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ public void OnDialogClosed()
|
|
|
|
+ {
|
|
|
|
+
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ public void OnDialogOpened(IDialogParameters parameters)
|
|
|
|
+ {
|
|
|
|
+ Document = parameters.GetValue<CPDFDocument>(ParameterNames.PDFDocument);
|
|
|
|
+
|
|
|
|
+ var info = Document.GetInfo();
|
|
|
|
+ FileName = Document.FileName;
|
|
|
|
+ FileSize = CommonHelper.GetFileSize(Document.FilePath);
|
|
|
|
+ FileTitle = info.Title;
|
|
|
|
+ Author = info.Author;
|
|
|
|
+ FilePath = Document.FilePath;
|
|
|
|
+ Version = info.Version;
|
|
|
|
+ PageCount = Document.PageCount;
|
|
|
|
+ Creator = info.Creator;
|
|
|
|
+ Productor = info.Producer;
|
|
|
|
+ CreateDate = CommonHelper.GetDate(info.CreationDate);
|
|
|
|
+ ModifyDate = CommonHelper.GetDate(info.ModificationDate);
|
|
|
|
+
|
|
|
|
+ string yes = "Yes";
|
|
|
|
+ string no = "No";
|
|
|
|
+
|
|
|
|
+ IsEncrypted = Document.IsEncrypted ? yes : no;
|
|
|
|
+ IsUnlocked = Document.IsLocked ? no : yes;
|
|
|
|
+
|
|
|
|
+ var permissions = Document.GetPermissionsInfo();
|
|
|
|
+
|
|
|
|
+ AllowCopy = permissions.AllowsCopying? yes : no;
|
|
|
|
+ AllowPrint = permissions.AllowsPrinting ? yes : no;
|
|
|
|
+ }
|
|
|
|
+ }
|
|
|
|
+}
|