using ComPDFKit.PDFDocument;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace PDF_Office.Model.Dialog.ToolsDialogs.SaftyDialogs
{
    public class SetPasswordDialogModel
    {
        public bool CanOpen { get; set; }

        public bool CanEdit { get; set; }

        public static string PasswordForOpen { get; set; }

        public static string PasswordForEdit { get; set; }

        public enum PrintMod
        {
            None,
            LowDpi,
            HighDpi
        }

        public enum ChangeMod
        {
            None,
            ChangePage,
            FormAndSignature,
            AnnotAndFormAndSignature,
            ExceptAbstrat
        }

        ///<returns>
        ///生成带有指定权限的CPDFPermissionsInfo对象
        ///</returns>
        public CPDFPermissionsInfo CreatePermissionsInfo(PrintMod printMod, ChangeMod changeMod)
        {
            CPDFPermissionsInfo permissionsInfo = new CPDFPermissionsInfo();
            switch (printMod)
            {
                case PrintMod.None:
                    permissionsInfo.AllowsPrinting = false;
                    permissionsInfo.AllowsHighQualityPrinting = false;
                    break;
                case PrintMod.LowDpi:
                    permissionsInfo.AllowsPrinting = true;
                    permissionsInfo.AllowsHighQualityPrinting = false;
                    break;
                case PrintMod.HighDpi:
                    permissionsInfo.AllowsHighQualityPrinting = true;
                    permissionsInfo.AllowsPrinting = true;
                    break;
                default:
                    break;
            }
            switch (changeMod)
            {
                case ChangeMod.None:
                    permissionsInfo.AllowsCopying = false;
                    permissionsInfo.AllowsDocumentAssembly = false;
                    permissionsInfo.AllowsCommenting = false;
                    permissionsInfo.AllowsDocumentChanges = false;
                    permissionsInfo.AllowsFormFieldEntry = false;
                    break;
                case ChangeMod.ChangePage:
                    permissionsInfo.AllowsCopying = false;
                    permissionsInfo.AllowsDocumentAssembly = true;
                    permissionsInfo.AllowsCommenting = false;
                    permissionsInfo.AllowsDocumentChanges = false;
                    permissionsInfo.AllowsFormFieldEntry = false;
                    break;
                case ChangeMod.FormAndSignature:
                    permissionsInfo.AllowsCopying = false;
                    permissionsInfo.AllowsDocumentAssembly = false;
                    permissionsInfo.AllowsCommenting = false;
                    permissionsInfo.AllowsDocumentChanges = false;
                    permissionsInfo.AllowsFormFieldEntry = true;
                    break;
                case ChangeMod.AnnotAndFormAndSignature:
                    permissionsInfo.AllowsCopying = false;
                    permissionsInfo.AllowsDocumentAssembly = false;
                    permissionsInfo.AllowsCommenting = true;
                    permissionsInfo.AllowsDocumentChanges = false;
                    permissionsInfo.AllowsFormFieldEntry = true;
                    break;
                case ChangeMod.ExceptAbstrat:
                    permissionsInfo.AllowsCopying = true;
                    permissionsInfo.AllowsDocumentAssembly = true;
                    permissionsInfo.AllowsCommenting = true;
                    permissionsInfo.AllowsDocumentChanges = false;
                    permissionsInfo.AllowsFormFieldEntry = true;
                    break;
            }
            return permissionsInfo;
        }
    }
}
