using ComPDFKit.PDFDocument; using ComPDFKitViewer.PdfViewer; using PDF_Master.Helper; using PDF_Master.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_Master.ViewModels.Dialog { public class PropertiesDialogViewModel : BindableBase, IDialogAware { public string Title => ""; public event Action RequestClose; private CPDFDocument Document; private string fileName; /// /// 文件名 /// public string FileName { get { return fileName; } set { SetProperty(ref fileName, value); } } private string fileSize; /// /// 文件大小 /// public string FileSize { get { return fileSize; } set { SetProperty(ref fileSize, value); } } private string title; /// /// 文件标题 /// public string FileTitle { get { return title; } set { SetProperty(ref title, value); } } private string author; /// /// 作者 /// public string Author { get { return author; } set { SetProperty(ref author, value); } } private string filePath; /// /// 文件路径 /// public string FilePath { get { return filePath; } set { SetProperty(ref filePath, value); } } private string version; /// /// 版本 /// public string Version { get { return version; } set { SetProperty(ref version, value); } } private int pageCounr; /// /// 页面大小 /// public int PageCount { get { return pageCounr; } set { SetProperty(ref pageCounr, value); } } private string creator; /// /// 创建软件名 /// 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; /// /// 创建日期 /// public string CreateDate { get { return createDate; } set { SetProperty(ref createDate, value); } } private string modifyDate; /// /// 编辑日期 /// public string ModifyDate { get { return modifyDate; } set { SetProperty(ref modifyDate, value); } } private string isEncrypted; /// /// 是否加密 /// public string IsEncrypted { get { return isEncrypted; } set { SetProperty(ref isEncrypted, value); } } private string isUnlocked; /// /// 是否加锁 /// public string IsUnlocked { get { return isUnlocked; } set { SetProperty(ref isUnlocked, value); } } private string allowCopy; /// /// 允许复制 /// public string AllowCopy { get { return allowCopy; } set { SetProperty(ref allowCopy, value); } } private string allowPrint; /// /// 允许打印 /// public string AllowPrint { get { return allowPrint; } set { SetProperty(ref allowPrint, value); } } public PropertiesDialogViewModel() { } public bool CanCloseDialog() { return true; } public void OnDialogClosed() { RequestClose.Invoke(new DialogResult()); } public void OnDialogOpened(IDialogParameters parameters) { Document = parameters.GetValue(ParameterNames.PDFDocument); var info = Document.GetInfo(); FileName = Document.FileName; FileSize = CommonHelper.GetFileSize(Document.FilePath); FileTitle = info.Title; Author = info.Author; if ((App.mainWindowViewModel.SelectedItem.DataContext as MainContentViewModel).NewFile) { //新建文档不显示临时路径 FilePath = ""; } else { 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; } } }