123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263 |
- 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<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;
- }
- }
- }
|