using ComPDFKit.PDFDocument;
using ComPDFKitViewer.PdfViewer;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows;
using System.Windows.Controls;
using System.Windows.Data;
using System.Windows.Documents;
using System.Windows.Input;
using System.Windows.Media;
using System.Windows.Media.Imaging;
using System.Windows.Navigation;
using System.Windows.Shapes;
namespace compdfkit_tools.PDFControl
{
///
/// PDFSecurityInfoControl.xaml 的交互逻辑
///
public partial class CPDFSecurityInfoControl : UserControl
{
private string T_Allowed = "allowed";
private string T_NotAllowed = "not allowed";
public CPDFViewer pdfViewer;
public void InitWithPDFViewer(CPDFViewer pdfViewer)
{
this.pdfViewer = pdfViewer;
InitializeSecurityInfo(pdfViewer.Document);
}
public CPDFSecurityInfoControl()
{
InitializeComponent();
}
///
/// Pass in a boolean value and return the corresponding text.
///
///
///
private string GetStringFromBool(bool isTrue)
{
if (isTrue)
{
return T_Allowed;
}
else
{
return T_NotAllowed;
}
}
private void InitializeSecurityInfo(CPDFDocument pdfDocument)
{
CPDFPermissionsInfo Permissions = pdfDocument.GetPermissionsInfo();
AllowsPrintingTextBlock.Text = GetStringFromBool(Permissions.AllowsPrinting);
AllowsCopyingTextBlock.Text = GetStringFromBool(Permissions.AllowsCopying);
AllowsDocumentChangesTextBlock.Text = GetStringFromBool(Permissions.AllowsDocumentChanges);
AllowsDocumentAssemblyTextBlock.Text = GetStringFromBool(Permissions.AllowsDocumentAssembly);
AllowsCommentingTextBlock.Text = GetStringFromBool(Permissions.AllowsCommenting);
AllowsFormFieldEntryTextBlock.Text = GetStringFromBool(Permissions.AllowsFormFieldEntry);
}
}
}