liuaoran 2 лет назад
Родитель
Сommit
9229e2750e

+ 2 - 2
PDF Office/App.xaml.cs

@@ -116,8 +116,8 @@ namespace PDF_Office
             string devKey = "";
             string devSecret = "";
 #if DEBUG
-            devKey = "sTHSivIW4YnZQavIYDLVw4vaFcN5DQTUtRGrVyv5p9aeaHX3GirG/MBxl6Wy9TJbNOwR4CU6LPjHmGe3Po3OtBCPqIRheam9+LomScw3AvoUTHFlG1134e2J4enF43WJQ6PyOnjwZqsG1kUdlBPNztkoPzDAE2pQKgZWf6V2i34=";
-            devSecret = "mG0c3O3Mzeu5dkZJW3gpqq9uA7o7EGQveSC38Q8TK4gQurxTxGuBlGAhs0P1mD3X3bHT+AHfcLiymaqE4DY7kTFHoPs9I3tl5ErS+BHdzHRhrp9sGpqfp0B228KI+IMTu4aGVjtYuk+Uxs/kosIBw1367/WkJ00tM7U7tttD6cfaiHpW8pgW2aur3AxuQIBBLuJD5gcmNxTYW3KA32JLG8alfyXjKFVS3gka9bngvwfZ7GuNXybjKlmz1tnN6iVHpnbSj+xOHhWEperY4HHrSg==";
+            devKey = "ehrnKqkWc1XSEAWyPUt6+95GzCoLEyoKrCbsUuJkCqGmxmP5ozX4bS0R6crHItQVNTFvC5mBZ1M7QjJ6Ekdu4Daj7PM+EDLTBKbFJinK4Ri9E5E2X+a9vF5zSj0TkIscQPVnwj9ikxAFOWGIyybMwQQzwc8a4j1cGOqGXQRDMMY=";
+            devSecret = "mG0c3O3Mzeu5dkZJW3gpqq9uA7o7EGQveSC38Q8TK4gQurxTxGuBlGAhs0P1mD3X3bHT+AHfcLiymaqE4DY7kTFHoPs9I3tl5ErS+BHdzHRhrp9sGpqfp0B228KI+IMTu4aGVjtYuk+Uxs/kosIBw1367/WkJ00tM7U7tttD6ccHhEu996bvBgqf8Sw8OekQKQq13VBewK5AckaDux4W7SGRhCUNWC4MItkr36JnXMD2tiFQYzMG8C66HYmRGSLh";
 #endif
 
             string userKey = "iBPRM/Tz8b6Z1G2GQt52X7hiNCGfVYXztnPjalgrgARvqfKV6lFNH8QeScTzBRYI8GGFpwelfgh790Kd9JmL7V4adI1jCiFHUT2DLT7QucxY5Nkgys2aJItQS482Ck2G2Xf8gNgojxYxRt65o/MEzkj93foj8qIdfHagXsSorSs=";

+ 44 - 0
PDF Office/Helper/Model/DialogNames.cs

@@ -0,0 +1,44 @@
+using System;
+using System.Collections.Generic;
+using System.Linq;
+using System.Text;
+using System.Threading.Tasks;
+
+namespace PDF_Office.Model
+{
+    /// <summary>
+    /// 记录弹窗的名称
+    /// </summary>
+    public static class DialogNames
+    {
+        /// <summary>
+        /// 文档解密弹窗 需要传参PDFDocument对象
+        /// </summary>
+        public static string VerifyPassWordDialog = "PassWordDialog";
+
+        /// <summary>
+        /// 全屏模式弹窗
+        /// </summary>
+        public static string FullScreenDialog = "FullScreenDialog";
+
+        /// <summary>
+        /// 解压缩弹窗
+        /// </summary>
+        public static string CompressDialog = "CompressDialog";
+
+        /// <summary>
+        /// 解压缩弹窗
+        /// </summary>
+        public static string SetPasswordDialog = "SetPasswordDialog";
+
+        /// <summary>
+        /// 解压缩弹窗
+        /// </summary>
+        public static string CheckPasswordDialog = "CheckPasswordDialog";
+
+        /// <summary>
+        /// 解压缩弹窗
+        /// </summary>
+        public static string CancelPasswordDialog = "CancelPasswordDialog";
+    }
+}

+ 21 - 0
PDF Office/Helper/Model/PDFTool/ToolItem.cs

@@ -0,0 +1,21 @@
+using Prism.Mvvm;
+using System;
+using System.Collections.Generic;
+using System.Linq;
+using System.Text;
+using System.Threading.Tasks;
+
+namespace PDF_Office.Model.PDFTool
+{
+    public class ToolItem : BindableBase
+    {
+        public int Id { get; set; }
+        public string Image { get; set; }
+        public string NameInfo { get; set; }
+        public string Name { get; set; }
+        public ToolItem()
+        {
+
+        }
+    }
+}

+ 133 - 0
PDF Office/Helper/Model/PageEdit/PageEditItem.cs

@@ -0,0 +1,133 @@
+using Prism.Commands;
+using Prism.Mvvm;
+using System;
+using System.Collections.Generic;
+using System.Linq;
+using System.Text;
+using System.Threading.Tasks;
+using System.Windows;
+using System.Windows.Media.Imaging;
+
+namespace PDF_Office.Model.PageEdit
+{
+    public class PageEditItem:BindableBase
+    {
+
+        private int pageNumber;
+        /// <summary>
+        /// 页码
+        /// </summary>
+        public int PageNumber
+        {
+            get { return pageNumber; }
+            set
+            {
+                SetProperty(ref pageNumber, value);
+            }
+        }
+
+
+        private string pageSize = "";
+        /// <summary>
+        /// 页面尺寸
+        /// </summary>
+        public string PageSize
+        {
+            get { return pageSize; }
+            set
+            {
+                SetProperty(ref pageSize, value);
+            }
+        }
+
+        private BitmapSource image;
+        /// <summary>
+        /// 页面缩略图
+        /// </summary>
+        public BitmapSource Image
+        {
+            get { return image; }
+            set
+            {
+                SetProperty(ref image, value);
+            }
+        }
+
+        private bool showPageSize = false;
+        /// <summary>
+        /// 是否显示页码尺寸
+        /// </summary>
+        public bool ShowPageSize
+        {
+            get { return showPageSize; }
+            set
+            {
+                SetProperty(ref showPageSize, value);
+            }
+        }
+
+        private bool haveBookMark = false;
+        /// <summary>
+        /// 该页是否有书签标记
+        /// </summary>
+        public bool HaveBookMark
+        {
+            get { return haveBookMark; }
+            set
+            {
+                SetProperty(ref haveBookMark, value);
+            }
+        }
+
+        private Visibility visible = Visibility.Visible;
+        /// <summary>
+        /// 是否显示
+        /// </summary>
+        public Visibility Visible
+        {
+            get { return visible; }
+            set
+            {
+                SetProperty(ref visible, value);
+            }
+        }
+
+        private bool selected = false; 
+        /// <summary>
+        /// 是否选中
+        /// </summary>
+        public bool Selected
+        {
+            get { return selected; }
+            set
+            {
+                SetProperty(ref selected, value);
+            }
+        }
+
+
+        private Size itemSize = new Size(208, 294);
+        /// <summary>
+        /// 控件大小
+        /// 直接修改Listbox 容器的项大小,会导致间距有问题,所有采用动态绑定大小的方式来实现Item大小更新
+        /// </summary>
+        public Size ItemSize
+        {
+            get { return itemSize; }
+            set
+            {
+                SetProperty(ref itemSize, value);
+            }
+        }
+
+        /// <summary>
+        /// 此次打开中是否已经获取图片,避免重复拿图
+        /// </summary>
+        public bool IsGetImage = false;
+
+        /// <summary>
+        /// 是否是竖直的图
+        /// </summary>
+        public bool isVertical = true;
+    }
+}

+ 28 - 0
PDF Office/Helper/Model/ParameterNames.cs

@@ -0,0 +1,28 @@
+using System;
+using System.Collections.Generic;
+using System.Linq;
+using System.Text;
+using System.Threading.Tasks;
+
+namespace PDF_Office.Model
+{
+    /// <summary>
+    /// 记录常用的参数的Key名称,防止String写错
+    /// </summary>
+    public static class ParameterNames
+    {
+        public static string PDFViewer = "PDFViewer";
+
+        public static string FilePath = "FilePath";
+
+        public static string PassWord = "PassWord";
+
+        public static string PDFDocument = "PDFDocument";
+
+        public static string AddTab = "AddTab";
+
+        public static string MainViewModel = "MainViewModel";
+
+        public static string ViewContentViewModel = "ViewContentViewModel";
+    }
+}

+ 16 - 0
PDF Office/Helper/Model/RegionNames.cs

@@ -0,0 +1,16 @@
+using System;
+using System.Collections.Generic;
+using System.Linq;
+using System.Text;
+using System.Threading.Tasks;
+
+namespace PDF_Office.Model
+{
+    public static class RegionNames
+    {
+        /// <summary>
+        /// 最外层的Region名称
+        /// </summary>
+        public static string MainRegion = "MainRegion";
+    }
+}

+ 88 - 0
PDF Office/Helper/PasswordBoxHelper.cs

@@ -0,0 +1,88 @@
+using System.Windows;
+using System.Windows.Controls;
+
+namespace PDF_Office.Helper
+{
+    public class PasswordBoxHelper
+    {
+        public static readonly DependencyProperty PasswordProperty = DependencyProperty.RegisterAttached(
+            "UserPassword", typeof(string), typeof(PasswordBoxHelper), new PropertyMetadata(string.Empty, OnPasswordPropertyChanged));
+
+        private static void OnPasswordPropertyChanged(DependencyObject d, DependencyPropertyChangedEventArgs e)
+        {
+            PasswordBox passwordBox = d as PasswordBox;
+            passwordBox.PasswordChanged -= PasswordChanged;
+            if (!GetIsUpdating(passwordBox))
+            {
+                /*从Password往控件方向更新绑定值*/
+                passwordBox.Password = e.NewValue.ToString();
+            }
+
+            passwordBox.PasswordChanged += PasswordChanged;
+        }
+
+        public static void SetPassword(DependencyObject element, string value)
+        {
+            element.SetValue(PasswordProperty, value);
+        }
+
+        public static string GetPassword(DependencyObject element)
+        {
+            return (string)element.GetValue(PasswordProperty);
+        }
+
+        public static readonly DependencyProperty AttachProperty = DependencyProperty.RegisterAttached(
+            "Attach", typeof(bool), typeof(PasswordBoxHelper), new PropertyMetadata(false, Attach));
+
+        private static void Attach(DependencyObject d, DependencyPropertyChangedEventArgs e)
+        {
+            if (!(d is PasswordBox passwordBox))
+            {
+                return;
+            }
+
+            if ((bool)e.OldValue)
+            {
+                passwordBox.PasswordChanged -= PasswordChanged;
+            }
+
+            if ((bool)e.NewValue)
+            {
+                /*当控件的值发生变化的时候,更新Password的值*/
+                passwordBox.PasswordChanged += PasswordChanged;
+            }
+        }
+
+        private static void PasswordChanged(object sender, RoutedEventArgs e)
+        {
+            PasswordBox passwordBox = sender as PasswordBox;
+            /*IsUpdating的作用类似一把互斥锁,因涉及到双向绑定更新*/
+            SetIsUpdating(passwordBox, true);
+            SetPassword(passwordBox, passwordBox.Password);
+            SetIsUpdating(passwordBox, false);
+        }
+
+        public static void SetAttach(DependencyObject element, bool value)
+        {
+            element.SetValue(AttachProperty, value);
+        }
+
+        public static bool GetAttach(DependencyObject element)
+        {
+            return (bool)element.GetValue(AttachProperty);
+        }
+
+        public static readonly DependencyProperty IsUpdatingProperty = DependencyProperty.RegisterAttached(
+            "IsUpdating", typeof(bool), typeof(PasswordBoxHelper), new PropertyMetadata(default(bool)));
+
+        public static void SetIsUpdating(DependencyObject element, bool value)
+        {
+            element.SetValue(IsUpdatingProperty, value);
+        }
+
+        public static bool GetIsUpdating(DependencyObject element)
+        {
+            return (bool)element.GetValue(IsUpdatingProperty);
+        }
+    }
+}

+ 97 - 0
PDF Office/Model/Dialog/ToolsDialogs/SaftyDialogs/SetPasswordDialogModel.cs

@@ -0,0 +1,97 @@
+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 CanOpenPassword { get; set; }
+
+        public static string CanEditPassword { get; set; }
+
+        public enum PrintMod
+        {
+            None,
+            LowDpi,
+            HighDpi
+        }
+
+        public enum ChangeMod
+        {
+            None,
+            ChangePage,
+            FormAndSignature,
+            AnnotAndFormAndSignature,
+            ExceptAbstrat
+        }
+
+        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;
+        }
+    }
+}