Jelajahi Sumber

Merge branch 'dev' into practice

# Conflicts:
#	PDF Office/App.xaml.cs
#	PDF Office/PDF Office.csproj
liyijie 2 tahun lalu
induk
melakukan
87fb14e731
86 mengubah file dengan 5327 tambahan dan 497 penghapusan
  1. 9 1
      PDF Office/App.config
  2. 15 10
      PDF Office/App.xaml.cs
  3. TEMPAT SAMPAH
      PDF Office/ComPDFKit.Desk.dll
  4. TEMPAT SAMPAH
      PDF Office/ComPDFKit.Viewer.dll
  5. 1 1
      PDF Office/CustomControl/PageTurningPreview.xaml.cs
  6. 198 0
      PDF Office/Helper/ConverterHelper.cs
  7. 48 0
      PDF Office/Helper/SDKLisenceHelper.cs
  8. 53 0
      PDF Office/Model/CloudDrive/CloudDriveItem.cs
  9. 94 0
      PDF Office/Model/CloudDrive/CloudFiles.cs
  10. 7 1
      PDF Office/Model/Dialog/HomePageToolsDialogs/HomePageBatchProcessing/HomePageBatchProcessingDialogModel.cs
  11. 1 1
      PDF Office/Model/Dialog/HomePageToolsDialogs/HomePageBatchProcessing/HomePageCompressDialogModel.cs
  12. 89 89
      PDF Office/Model/DialogNames.cs
  13. 2 0
      PDF Office/Model/ParameterNames.cs
  14. 105 16
      PDF Office/PDF Office.csproj
  15. 13 1
      PDF Office/Properties/Resources.Designer.cs
  16. 4 0
      PDF Office/Properties/Resources.resx
  17. TEMPAT SAMPAH
      PDF Office/Resources/ToolBarIcon/MyTools/Arrow.png
  18. TEMPAT SAMPAH
      PDF Office/Resources/ToolBarIcon/MyTools/Bookmark.png
  19. TEMPAT SAMPAH
      PDF Office/Resources/ToolBarIcon/MyTools/Circle.png
  20. TEMPAT SAMPAH
      PDF Office/Resources/ToolBarIcon/MyTools/Freehande.png
  21. TEMPAT SAMPAH
      PDF Office/Resources/ToolBarIcon/MyTools/Freehande2.png
  22. TEMPAT SAMPAH
      PDF Office/Resources/ToolBarIcon/MyTools/Hand.png
  23. TEMPAT SAMPAH
      PDF Office/Resources/ToolBarIcon/MyTools/Highlight.png
  24. TEMPAT SAMPAH
      PDF Office/Resources/ToolBarIcon/MyTools/Hyperlink.png
  25. TEMPAT SAMPAH
      PDF Office/Resources/ToolBarIcon/MyTools/Image.png
  26. TEMPAT SAMPAH
      PDF Office/Resources/ToolBarIcon/MyTools/Line.png
  27. TEMPAT SAMPAH
      PDF Office/Resources/ToolBarIcon/MyTools/Note.png
  28. TEMPAT SAMPAH
      PDF Office/Resources/ToolBarIcon/MyTools/Point.png
  29. TEMPAT SAMPAH
      PDF Office/Resources/ToolBarIcon/MyTools/Rectangle.png
  30. TEMPAT SAMPAH
      PDF Office/Resources/ToolBarIcon/MyTools/Selecttool.png
  31. TEMPAT SAMPAH
      PDF Office/Resources/ToolBarIcon/MyTools/Stamp.png
  32. TEMPAT SAMPAH
      PDF Office/Resources/ToolBarIcon/MyTools/Textbox.png
  33. TEMPAT SAMPAH
      PDF Office/Resources/ToolBarIcon/MyTools/wavyline2.png
  34. 11 0
      PDF Office/SDKLisence.xml
  35. 36 1
      PDF Office/Styles/CustomBtnStyle.xaml
  36. 1 0
      PDF Office/Styles/WindowsStyle.xaml
  37. 77 3
      PDF Office/ViewModels/BOTA/BOTAContentViewModel.cs
  38. 55 13
      PDF Office/ViewModels/Dialog/HomePageToolsDialogs/HomePageBatchProcessing/HomePageBatchProcessingDialogViewModel.cs
  39. 283 10
      PDF Office/ViewModels/Dialog/HomePageToolsDialogs/HomePageBatchProcessing/HomePageCompressDialogViewModel.cs
  40. 404 10
      PDF Office/ViewModels/Dialog/HomePageToolsDialogs/HomePageBatchProcessing/HomePageSetPasswordDialogViewModel.cs
  41. 71 22
      PDF Office/ViewModels/Dialog/HomePageToolsDialogs/HomePagePictureToPDFDialogViewModel.cs
  42. 23 4
      PDF Office/ViewModels/HomeContentViewModel.cs
  43. 0 16
      PDF Office/ViewModels/HomePageSetPasswordDialogViewModel.cs
  44. 52 0
      PDF Office/ViewModels/HomePanel/CloudDrive/CloudDriveContentViewModel.cs
  45. 107 0
      PDF Office/ViewModels/HomePanel/CloudDrive/CloudDriveManager.cs
  46. 92 0
      PDF Office/ViewModels/HomePanel/CloudDrive/CloudDriveType/DropbBoxManager.cs
  47. 274 0
      PDF Office/ViewModels/HomePanel/CloudDrive/CloudDriveType/DropbBoxUserItem.cs
  48. 102 0
      PDF Office/ViewModels/HomePanel/CloudDrive/CloudDriveType/GoogleDriveManager.cs
  49. 386 0
      PDF Office/ViewModels/HomePanel/CloudDrive/CloudDriveType/GoogleDriveUserItem.cs
  50. 136 0
      PDF Office/ViewModels/HomePanel/CloudDrive/CloudFilesContentViewModel.cs
  51. 30 1
      PDF Office/ViewModels/HomePanel/HomeCloudContentViewModel.cs
  52. 20 9
      PDF Office/ViewModels/HomePanel/HomeGuidContentViewModel.cs
  53. 253 14
      PDF Office/ViewModels/MainContentViewModel.cs
  54. 16 0
      PDF Office/ViewModels/Tools/ConverterBarContentViewModel.cs
  55. 314 26
      PDF Office/ViewModels/ViewContentViewModel.cs
  56. 92 6
      PDF Office/Views/Dialog/HomePageToolsDialogs/HomePageBatchProcessing/HomePageBatchProcessingDialog.xaml
  57. 208 2
      PDF Office/Views/Dialog/HomePageToolsDialogs/HomePageBatchProcessing/HomePageBatchProcessingDialog.xaml.cs
  58. 13 12
      PDF Office/Views/Dialog/HomePageToolsDialogs/HomePageBatchProcessing/HomePageCompressDialog.xaml
  59. 17 12
      PDF Office/Views/Dialog/HomePageToolsDialogs/HomePageBatchProcessing/HomePageCompressDialog.xaml.cs
  60. 18 14
      PDF Office/Views/Dialog/HomePageToolsDialogs/HomePageBatchProcessing/HomePageSetPasswordDialog.xaml
  61. 27 17
      PDF Office/Views/Dialog/HomePageToolsDialogs/HomePageBatchProcessing/HomePageSetPasswordDialog.xaml.cs
  62. 2 2
      PDF Office/Views/Dialog/HomePageToolsDialogs/HomePagePictureToPDFDialog.xaml
  63. 6 1
      PDF Office/Views/Dialog/HomePageToolsDialogs/HomePagePrinter/HomePagePrinterDialog.xaml
  64. 14 5
      PDF Office/Views/Dialog/PageEditDialogs/InsertDialog.xaml
  65. 41 18
      PDF Office/Views/Dialog/ToolsDialogs/CompressDialogs/SplitDialog.xaml
  66. 0 37
      PDF Office/Views/HomePanel/CloudDocs/CloudDiskContent.xaml
  67. 0 36
      PDF Office/Views/HomePanel/CloudDocs/CloudDiskContent.xaml.cs
  68. 0 44
      PDF Office/Views/HomePanel/CloudDocs/CloudFilesContent.xaml
  69. 0 37
      PDF Office/Views/HomePanel/CloudDocs/CloudFilesContent.xaml.cs
  70. 56 0
      PDF Office/Views/HomePanel/CloudDrive/CloudDriveContent.xaml
  71. 86 0
      PDF Office/Views/HomePanel/CloudDrive/CloudDriveContent.xaml.cs
  72. 109 0
      PDF Office/Views/HomePanel/CloudDrive/CloudFilesContent.xaml
  73. 175 0
      PDF Office/Views/HomePanel/CloudDrive/CloudFilesContent.xaml.cs
  74. 10 3
      PDF Office/Views/HomePanel/HomeCloudContent.xaml
  75. 3 1
      PDF Office/Views/HomePanel/HomeCloudContent.xaml.cs
  76. 43 1
      PDF Office/Views/PageEdit/PageEditContent.xaml
  77. 700 0
      PDF Office/Views/PageEdit/PageEditContent.xaml.cs
  78. 139 0
      PDF Office/Views/Tools/AnnotToolContent.xaml
  79. 61 0
      PDF Office/Views/Tools/AnnotToolContent.xaml.cs
  80. 92 0
      PDF Office/Views/Tools/ConverterBarContent.xaml
  81. 15 0
      PDF Office/Views/Tools/ConverterBarContent.xaml.cs
  82. 1 0
      PDF Office/credentials.json
  83. 9 0
      PDF Office/index.html
  84. 8 0
      PDF Office/packages.config
  85. TEMPAT SAMPAH
      PDF Office/x64/ComPDFKit.dll
  86. TEMPAT SAMPAH
      PDF Office/x86/ComPDFKit.dll

+ 9 - 1
PDF Office/App.config

@@ -1,8 +1,16 @@
-<?xml version="1.0" encoding="utf-8" ?>
+<?xml version="1.0" encoding="utf-8"?>
 <configuration>
     <configSections>
     </configSections>
     <startup> 
         <supportedRuntime version="v4.0" sku=".NETFramework,Version=v4.6.2" />
     </startup>
+  <runtime>
+    <assemblyBinding xmlns="urn:schemas-microsoft-com:asm.v1">
+      <dependentAssembly>
+        <assemblyIdentity name="Newtonsoft.Json" publicKeyToken="30ad4fe6b2a6aeed" culture="neutral" />
+        <bindingRedirect oldVersion="0.0.0.0-13.0.0.0" newVersion="13.0.0.0" />
+      </dependentAssembly>
+    </assemblyBinding>
+  </runtime>
 </configuration>

+ 15 - 10
PDF Office/App.xaml.cs

@@ -31,6 +31,7 @@ using PDF_Office.Views.Dialog.HomePageToolsDialogs ;
 using PDF_Office.Views.Dialog.HomePageToolsDialogs.HomePagePrinter;
 using PDF_Office.Views.Dialog.HomePageToolsDialogs.HomePageBatchProcessing;
 using PDF_Office.Model.Dialog.HomePageToolsDialogs.HomePageBatchProcessing;
+using PDF_Office.Helper;
 
 namespace PDF_Office
 {
@@ -142,6 +143,10 @@ namespace PDF_Office
             base.ConfigureRegionAdapterMappings(regionAdapterMappings);
         }
 
+        /// <summary>
+        /// 验证SDK和转档库密钥
+        /// </summary>
+        /// <returns></returns>
         private static bool LicenseVerify()
         {
             bool result = false;
@@ -152,30 +157,30 @@ namespace PDF_Office
                     return false;
             }
             catch{ }
+            SDKLisenceHelper sdkhelper = new SDKLisenceHelper();
             string devKey = "";
             string devSecret = "";
 #if DEBUG
             devKey = "sTHSivIW4YnZQavIYDLVw4vaFcN5DQTUtRGrVyv5p9aeaHX3GirG/MBxl6Wy9TJbNOwR4CU6LPjHmGe3Po3OtBCPqIRheam9+LomScw3AvoUTHFlG1134e2J4enF43WJQ6PyOnjwZqsG1kUdlBPNztkoPzDAE2pQKgZWf6V2i34=";
             devSecret = "mG0c3O3Mzeu5dkZJW3gpqq9uA7o7EGQveSC38Q8TK4gQurxTxGuBlGAhs0P1mD3X3bHT+AHfcLiymaqE4DY7kTFHoPs9I3tl5ErS+BHdzHRhrp9sGpqfp0B228KI+IMTu4aGVjtYuk+Uxs/kosIBw1367/WkJ00tM7U7tttD6cfaiHpW8pgW2aur3AxuQIBBLuJD5gcmNxTYW3KA32JLG8alfyXjKFVS3gka9bngvwfZ7GuNXybjKlmz1tnN6iVHpnbSj+xOHhWEperY4HHrSg==";
+            devKey = sdkhelper.DevKey;
+            devSecret = sdkhelper.DevSecret;
 #endif
-
-            string userKey = "iBPRM/Tz8b6Z1G2GQt52X7hiNCGfVYXztnPjalgrgARvqfKV6lFNH8QeScTzBRYI8GGFpwelfgh790Kd9JmL7V4adI1jCiFHUT2DLT7QucxY5Nkgys2aJItQS482Ck2G2Xf8gNgojxYxRt65o/MEzkj93foj8qIdfHagXsSorSs=";
-            string userSecret = "mG0c3O3Mzeu5dkZJW3gpqq9uA7o7EGQveSC38Q8TK4ivEHOmPIqbfhpDnKKj+7Ymj2rXQvfZRmke06HMV+3tt064G64WjPW8+EbGCNZaAh1hrp9sGpqfp0B228KI+IMTu4aGVjtYuk+Uxs/kosIBw1FKJi6HYB+DuugQyaqI2prfej861QnJrU4s2T/npZK/";
+            string userKey = sdkhelper.UserKey; 
+            string userSecret = sdkhelper.UserSecret; 
 
             try
             {
-                CPDFSDKVerifier.LicenseErrorCode verifyResult = CPDFSDKVerifier.LicenseVerify(devKey, devSecret, userKey, userSecret);
+                CPDFSDKVerifier.LicenseErrorCode verifyResult = CPDFSDKVerifier.LicenseVerify(devKey, devSecret);
                 if (verifyResult != CPDFSDKVerifier.LicenseErrorCode.LICENSE_ERR_SUCCESS)
                     return false;
             }
             catch{ }
 
-
-
-            string ConverterDevKey = "mDDCTNY5rV2+FUj2JESUBruJ0643Tv7rNuxACu6g3L/0guIw1r8zZB+o3aw3rs4rrOThmxBXpEDcItvyGx096mF/3Ixg7aD6QZk5HvBEScIPerdM3KnhgwMwCjE0DYOSMCRwAhbA2xjXfXgT5VVo7JZroKOGQB5Qmf2kLl5nQuU=";
-            string ConverterDevSecret = "mG0c3O3Mzeu5dkZJW3gpqq9uA7o7EGQveSC38Q8TK4g3S5AixMY+3TX1FpQaugG9sTsnCq4QxIEDzyAI3s3dWjNe3wDsMrmFq51HtjPa2tSFAoV6NtcUJC8skonXVk7kMv7C2jvq4o0q6sQtN3jR42k0n/LkN5UfbQ5Lfel4OfZrk7dh2/DUR87Ps4vBX1hrYkwcNWVMyYvggPV2rTFvfawopGIC034QzjthmhwwX90=";
-            string ConverterUserkey = "WLUHzXhndQKyrTJVzvZ+dvPXDQDZeJpcSvklX3GJwRX4+urd8eQskYgbeCf0NXLZ/qJkS/k10x+qGad34i4v5rI/ASFIx901c/Nw5C0YJMH7X87dib141tdAmSmQhnKLO5TBi4FiAidboyvnLFLrYGMmS2kLQOXFPwPj5zQUv5A=";
-            string ConverterUserSecret = "mG0c3O3Mzeu5dkZJW3gpqq9uA7o7EGQveSC38Q8TK4iK16EcneqBPRe2eKQLuJXpA79IONX9GVI/Ap3uWzMcNWaitc2UB6gDeexJXFPVaXOFAoV6NtcUJC8skonXVk7k/oKTJGcYKLPGdXenrzHolQ==";
+            string ConverterDevKey = sdkhelper.ConverterDevKey;
+            string ConverterDevSecret = sdkhelper.ConverterDevSecret; 
+            string ConverterUserkey = sdkhelper.ConverterUserkey; 
+            string ConverterUserSecret = sdkhelper.ConverterUserSecret;
 
             try
             {

TEMPAT SAMPAH
PDF Office/ComPDFKit.Desk.dll


TEMPAT SAMPAH
PDF Office/ComPDFKit.Viewer.dll


+ 1 - 1
PDF Office/CustomControl/PageTurningPreview.xaml.cs

@@ -32,7 +32,7 @@ namespace PDF_Office.CustomControl
 
         public async Task RenderBitmap(CPDFDocument doc)
         {
-            CPDFPage page = new CPDFPage(doc, int.Parse(this.CurrentPage.Text) - 1, true);
+            CPDFPage page = doc.PageAtIndex( int.Parse(this.CurrentPage.Text) - 1);
             byte[] bmp_data = new byte[(int)page.PageSize.Width * (int)page.PageSize.Height * 4];
             await Task.Run(delegate
             {

+ 198 - 0
PDF Office/Helper/ConverterHelper.cs

@@ -0,0 +1,198 @@
+using System;
+using System.Collections.Generic;
+using System.Linq;
+using System.Text;
+using System.Threading.Tasks;
+using ComPDFKit_Conversion.Converter;
+using System.Diagnostics;
+using System.IO;
+
+namespace PDF_Office.Helper
+{
+    public static class ConverterHelper
+    {
+        public static CPDFConverterWord wordConverter = null;
+        public static CPDFConverterExcel excelConverter = null;
+        public static CPDFConverterPPT pptConverter = null;
+        public static CPDFConverterTxt txtConverter = null;
+        public static CPDFConverterTable tableConverter = null;
+        public static CPDFConverterCsv csvConverter = null;
+        public static async Task<bool> WordConvert(string inputpath, string outputpath, OnProgress getProgress, List<int> pageIndexLists, string pawssword)
+        {
+            bool result = false;
+            try
+            {
+                int[] pageArray = pageIndexLists.ToArray();
+                wordConverter = new CPDFConverterWord(inputpath, pawssword);
+                string outputFolder = outputpath;
+                string outputFileName = Path.GetFileNameWithoutExtension(inputpath);
+                ConvertError error = ConvertError.ERR_UNKNOWN;
+
+                string filename = GetFileNameAddSuffix(outputFolder, outputFileName, ".docx");
+
+                result = await Task.Run(() => wordConverter.Convert(outputFolder, ref filename, pageArray, ref error, getProgress));
+            }
+            catch (Exception ex)
+            {
+
+            }
+            return result;
+        }
+
+        public static async Task<bool> PPTConvert(string inputpath, string outputpath, OnProgress getProgress, List<int> pageIndexLists, string pawssword)
+        {
+            bool result = false;
+            try
+            {
+                int[] pageArray = pageIndexLists.ToArray();
+
+                pptConverter = new CPDFConverterPPT(inputpath, pawssword);
+                string outputFolder = outputpath;
+                string outputFileName = Path.GetFileNameWithoutExtension(inputpath);
+                ConvertError error = ConvertError.ERR_UNKNOWN;
+
+                string filename = GetFileNameAddSuffix(outputFolder, outputFileName, ".ppt");
+
+                result = await Task.Run(() => pptConverter.Convert(outputFolder, ref outputFileName, pageArray, ref error, getProgress));
+
+            }
+            catch (Exception ex)
+            {
+
+            }
+            return result;
+        }
+
+        public static async Task<bool> ExcelConvert(string inputpath, string outputpath, OnProgress getProgress, List<int> pageIndexLists, string pawssword)
+        {
+            bool result = false;
+            try
+            {
+                int[] pageArray = pageIndexLists.ToArray();
+
+                excelConverter = new CPDFConverterExcel(inputpath, pawssword);
+                string outputFolder = outputpath;
+                string outputFileName = Path.GetFileNameWithoutExtension(inputpath);
+                ConvertError error = ConvertError.ERR_UNKNOWN;
+                string filename = GetFileNameAddSuffix(outputFolder, outputFileName, ".xlsx");
+
+                result = await Task.Run(() => excelConverter.Convert(outputFolder, ref outputFileName, pageArray, ref error, getProgress));
+
+            }
+            catch (Exception ex)
+            {
+
+            }
+            return result;
+        }
+
+        public static async Task<bool> TableConvert(string inputpath, string outputpath, OnProgress getProgress, List<int> pageIndexLists, string pawssword)
+        {
+            bool result = false;
+            try
+            {
+                int[] pageArray = pageIndexLists.ToArray();
+                tableConverter = new CPDFConverterTable(inputpath, pawssword);
+                string outputFolder = outputpath;
+                string outputFileName = Path.GetFileNameWithoutExtension(inputpath);
+                ConvertError error = ConvertError.ERR_UNKNOWN;
+                string filename = GetFileNameAddSuffix(outputFolder, outputFileName, ".xlsx");
+                result = await Task.Run(() => tableConverter.Convert(outputFolder, ref outputFileName, pageArray, ref error, getProgress));
+
+            }
+            catch (Exception ex)
+            {
+
+            }
+            return result;
+        }
+
+        public static async Task<bool> CSVConvert(string inputpath, string outputpath, OnProgress getProgress, List<int> pageIndexLists, string pawssword)
+        {
+            bool result = false;
+            try
+            {
+                int[] pageArray = pageIndexLists.ToArray();
+
+                csvConverter = new CPDFConverterCsv(inputpath, pawssword);
+                string outputFolder = outputpath;
+                string outputFileName = Path.GetFileNameWithoutExtension(inputpath);
+                ConvertError error = ConvertError.ERR_UNKNOWN;
+                string filename = GetFileNameAddSuffix(outputFolder, outputFileName, ".csv");
+
+                result = await Task.Run(() => csvConverter.Convert(outputFolder, ref outputFileName, pageArray, ref error, getProgress));
+
+            }
+            catch (Exception ex)
+            {
+
+            }
+            return result;
+        }
+
+        public static async Task<bool> TxtConvert(string inputpath, string outputpath, OnProgress getProgress, List<int> pageIndexLists, string pawssword)
+        {
+            bool result = false;
+            try
+            {
+                int[] pageArray = pageIndexLists.ToArray();
+
+                txtConverter = new CPDFConverterTxt(inputpath, pawssword);
+                string outputFolder = outputpath;
+                string outputFileName = Path.GetFileNameWithoutExtension(inputpath);
+                ConvertError error = ConvertError.ERR_UNKNOWN;
+                result = await Task.Run(() => txtConverter.Convert(outputFolder, ref outputFileName, pageArray, ref error, getProgress));
+
+            }
+            catch (Exception ex)
+            {
+
+            }
+            return result;
+        }
+        public static void Clear()
+        {
+            if (wordConverter != null)
+            {
+                wordConverter.Cancel();
+            }
+            if (excelConverter != null)
+            {
+                excelConverter.Cancel();
+            }
+            if (pptConverter != null)
+            {
+                pptConverter.Cancel();
+            }
+            if (txtConverter != null)
+            {
+                txtConverter.Cancel();
+            }
+            if (tableConverter != null)
+            {
+                tableConverter.Cancel();
+            }
+            if (csvConverter != null)
+            {
+                csvConverter.Cancel();
+            }
+            Console.WriteLine("killed");
+        }
+        private static void StartFile(string path)
+        {
+            //Process.Start(path);
+        }
+        public static string GetFileNameAddSuffix(string path, string filename, string suffix)
+        {
+            int i = 1;
+            string outname = filename;
+            while (File.Exists(path + @"\" + outname + suffix))
+            {
+                outname = filename + $"({i.ToString()})";
+                i++;
+            }
+            return outname;
+        }
+
+    }
+}

+ 48 - 0
PDF Office/Helper/SDKLisenceHelper.cs

@@ -0,0 +1,48 @@
+using System;
+using System.Collections.Generic;
+using System.IO;
+using System.Linq;
+using System.Reflection;
+using System.Text;
+using System.Threading.Tasks;
+using System.Xml;
+
+namespace PDF_Office.Helper
+{
+    public  class SDKLisenceHelper
+    {
+        /// <summary>
+        /// 从XML文件读取sdk密钥信息
+        /// </summary>
+        public SDKLisenceHelper()
+        {
+            string xmlPath = "SDKLisence";
+            Assembly assembly = Assembly.GetExecutingAssembly();
+            var stream =  (string)Properties.Resources.ResourceManager.GetObject(xmlPath);
+            XmlDocument xmlDoc = new XmlDocument();
+            xmlDoc.LoadXml(stream);
+            var node = xmlDoc.SelectSingleNode("Lisences");
+            if (node != null)
+            {
+                DevKey = node.Attributes["devKey"].Value.ToString();
+                DevSecret = node.Attributes["devSecret"].Value.ToString();
+                UserKey = node.Attributes["userKey"].Value.ToString();
+                UserSecret = node.Attributes["userSecret"].Value.ToString();
+                ConverterDevKey = node.Attributes["ConverterDevKey"].Value.ToString();
+                ConverterDevSecret = node.Attributes["ConverterDevSecret"].Value.ToString();
+                ConverterUserkey = node.Attributes["ConverterUserkey"].Value.ToString();
+                ConverterUserSecret = node.Attributes["ConverterUserSecret"].Value.ToString();
+            }
+        }
+
+        public string DevKey{ get; set; }
+
+        public string DevSecret { get; set; }
+        public string UserKey { get; set; }
+        public string UserSecret { get; set; }
+        public string ConverterDevKey { get; set; }
+        public string ConverterDevSecret { get; set; }
+        public string ConverterUserkey { get; set; }
+        public string ConverterUserSecret{ get; set; }
+    }
+}

+ 53 - 0
PDF Office/Model/CloudDrive/CloudDriveItem.cs

@@ -0,0 +1,53 @@
+using Google.Apis.Auth.OAuth2;
+using System;
+using System.Collections.Generic;
+using System.Linq;
+using System.Text;
+using System.Threading.Tasks;
+
+namespace PDF_Office.Model.CloudDrive
+{
+    //云盘信息
+    public enum CloudType
+    {
+        Box,
+        DropBox,
+        GoogleDrive,
+        OneDrive
+    }
+
+
+    public class CloudBoxItem
+    {
+        public CloudType CloudDiskType { get; set; }
+        public List<UserCredential> UserCredentials { get; set; }
+        public string UsersInfoPath { get; set; }
+        public int Id { get; set; }
+        public string DriveName { get; private set; }
+        public CloudBoxItem(CloudType cloudDiskType)
+        {
+            CloudDiskType = cloudDiskType;
+            GetName(CloudDiskType);
+        }
+
+        private void GetName(CloudType cloudDiskType)
+        {
+            switch (cloudDiskType)
+            {
+                case CloudType.Box:
+                    DriveName = "Box";
+                    break;
+                case CloudType.DropBox:
+                    DriveName = "DropBox";
+                    break;
+                case CloudType.GoogleDrive:
+                    DriveName = "Google Drive";
+                    break;
+                case CloudType.OneDrive:
+                    DriveName = "OneDrive";
+                    break;
+
+            }
+        }
+    }
+}

+ 94 - 0
PDF Office/Model/CloudDrive/CloudFiles.cs

@@ -0,0 +1,94 @@
+using Google.Apis.Auth.OAuth2;
+using Google.Apis.Drive.v3;
+using System;
+using System.Collections.Generic;
+using System.Collections.ObjectModel;
+using System.Linq;
+using System.Text;
+using System.Threading.Tasks;
+
+namespace PDF_Office.Model.CloudDrive
+{
+    public class Cloud
+    {
+        public static ObservableCollection<UserBaseItem> CloudLists = new ObservableCollection<UserBaseItem>();
+
+        public static List<CloudBoxItem> InitCloudBoxs()
+        {
+            List<CloudBoxItem> CloudeDrives = new List<CloudBoxItem>();
+
+            var cloudDriveItem = new CloudBoxItem(CloudType.Box);
+            CloudeDrives.Add(cloudDriveItem);
+
+            cloudDriveItem = new CloudBoxItem(CloudType.DropBox);
+            CloudeDrives.Add(cloudDriveItem);
+
+            cloudDriveItem = new CloudBoxItem(CloudType.GoogleDrive);
+            CloudeDrives.Add(cloudDriveItem);
+
+            cloudDriveItem = new CloudBoxItem(CloudType.OneDrive);
+            CloudeDrives.Add(cloudDriveItem);
+
+            return CloudeDrives;
+        }
+    }
+
+    #region 公有云盘
+
+    /// <summary>
+    /// 用户信息
+    /// </summary>
+    public class UserInfo
+    {
+
+        public string Name { get; set; }
+        public int Id { get; set; }
+
+        public string UserAccount { get; set; }
+    }
+
+    /// <summary>
+    /// 用户云盘
+    /// </summary>
+    public class UserBaseItem
+    {
+        public UserInfo userInfo { get; set; }
+        public CloudType cloudType { get; set; }
+    }
+
+    #endregion
+
+    #region GooglrDrive
+
+    /// <summary>
+    /// 谷歌云盘的文件
+    /// </summary>
+    public class GoogleDriveFiles
+    {
+        public string Id { get; set; }
+        public string Name { get; set; }
+        public long? Size { get; set; }
+        public long? Version { get; set; }
+        public DateTime? CreatedTime { get; set; }
+    }
+
+    #endregion
+
+
+    #region GooglrDrive
+
+    /// <summary>
+    /// 谷歌云盘的文件
+    /// </summary>
+    public class DropbBoxFiles
+    {
+        public string Id { get; set; }
+        public string Name { get; set; }
+        public long? Size { get; set; }
+        public DateTime? CreatedTime { get; set; }
+    }
+
+    #endregion
+
+
+}

+ 7 - 1
PDF Office/Model/Dialog/HomePageToolsDialogs/HomePageBatchProcessing/HomePageBatchProcessingDialogModel.cs

@@ -6,7 +6,13 @@ using System.Threading.Tasks;
 
 namespace PDF_Office.Model.Dialog.HomePageToolsDialogs.HomePageBatchProcessing
 {
-    internal class HomePageBatchProcessingDialogModel
+    public class HomePageBatchProcessingDialogModel
     {
+        public static int BatchProcessingIndex = 0;
+
+        public static List<string> FilePaths=new List<string>();
+        // "HomePageShiftingDialog","HomePageCompressDialog" , "HomePageSetPasswordDialog", "HomePageWatermarkDialog", "HomePageBackgroundDialog", "HomePageHeaderFooterDialog", "HomePageBatesDialog", "HomePageDeleteSafetySettintgsDialog"
+        public static List<string> GetBatchProcessing = new List<string> { "HomePageShiftingDialog", "HomePageCompressDialog", "HomePageSetPasswordDialog", "HomePageWatermarkDialog", "HomePageBackgroundDialog", "HomePageHeaderFooterDialog", "HomePageBatesDialog", "HomePageDeleteSafetySettintgsDialog" };
+
     }
 }

+ 1 - 1
PDF Office/Model/Dialog/HomePageToolsDialogs/HomePageBatchProcessing/HomePageCompressDialogModel.cs

@@ -17,6 +17,6 @@ namespace PDF_Office.Model.Dialog.HomePageToolsDialogs.HomePageBatchProcessing
             StatusMicro = 10
         }
 
-        public EnumQualityLevel CompressQuality { get; set; }
+        public EnumQualityLevel CompressQuality { get; set; } = EnumQualityLevel.StatusLittle;
     }
 }

+ 89 - 89
PDF Office/Model/DialogNames.cs

@@ -1,99 +1,99 @@
-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 DeleteSafetySettingsDialog = "DeleteSafetySettingsDialog";
-
-        /// <summary>
-        /// 进度条
-        /// </summary>
-        public static string CompressProgressBarDialog = "CompressProgressBarDialog"; 
-        /// <summary>
-        /// 页面编辑- 提取弹窗
-        /// </summary>
-        public static string ExtractDialog = "ExtractDialog";
-
-        /// <summary>
-        /// 页面编辑-拆分弹窗
-        /// </summary>
-        public static string SplitDialog = "SplitDialog";
-
-        /// <summary>
-        /// 页面编辑-插入弹窗
-        /// </summary>
-        public static string InsertDialog = "InsertDialog";
-
-        ///<summary>
-        ///主页工具-提取弹窗
-        /// </summary>
-        public static string HomePageExtractDialog = "HomePageExtractDialog";
-
-        ///<summary>
-        ///主页工具-插入弹窗
-        /// </summary
-        public static string HomePageInsertDialog = "HomePageInsertDialog";
-
-        ///<summary>
-        ///主页工具-拆分弹窗
-        /// </summary>
-        public static string HomePageSplitDialog = "HomePageSplitDialog";
-
-        ///<summary>
-        ///主页工具-打印弹窗
-        /// </summary>
+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 DeleteSafetySettingsDialog = "DeleteSafetySettingsDialog";
+
+        /// <summary>
+        /// 进度条
+        /// </summary>
+        public static string CompressProgressBarDialog = "CompressProgressBarDialog"; 
+        /// <summary>
+        /// 页面编辑- 提取弹窗
+        /// </summary>
+        public static string ExtractDialog = "ExtractDialog";
+
+        /// <summary>
+        /// 页面编辑-拆分弹窗
+        /// </summary>
+        public static string SplitDialog = "SplitDialog";
+
+        /// <summary>
+        /// 页面编辑-插入弹窗
+        /// </summary>
+        public static string InsertDialog = "InsertDialog";
+
+        ///<summary>
+        ///主页工具-提取弹窗
+        /// </summary>
+        public static string HomePageExtractDialog = "HomePageExtractDialog";
+
+        ///<summary>
+        ///主页工具-插入弹窗
+        /// </summary
+        public static string HomePageInsertDialog = "HomePageInsertDialog";
+
+        ///<summary>
+        ///主页工具-拆分弹窗
+        /// </summary>
+        public static string HomePageSplitDialog = "HomePageSplitDialog";
+
+        ///<summary>
+        ///主页工具-打印弹窗
+        /// </summary>
         public static string HomePagePrinterDialog = "HomePagePrinterDialog";
 
-        ///<summary>
-        ///打印弹窗-打印页面设置
-        /// </summary>
+        ///<summary>
+        ///打印弹窗-打印页面设置
+        /// </summary>
         public static string HomePagePrinterPageSetDialog = "HomePagePrinterPageSetDialog";
 
-        ///<summary>
-        ///主页工具-图片转PDF弹窗
+        ///<summary>
+        ///主页工具-图片转PDF弹窗
         /// </summary>
         public static string HomePagePictureToPDFDialog = "HomePagePictureToPDFDialog";
 
-        ///<summary>
-        ///主页工具-PDF批量工具
+        ///<summary>
+        ///主页工具-PDF批量工具
         /// </summary>
         public static string HomePageBatchProcessingDialog ="HomePageBatchProcessingDialog";
 
-    }
-}
+    }
+}

+ 2 - 0
PDF Office/Model/ParameterNames.cs

@@ -32,6 +32,8 @@ namespace PDF_Office.Model
 
         public static string InsertType_Custom = "Insert_Custom";
 
+        public static string BatchProcessing_Name = "BatchProcessing_Name";
+
         /// <summary>
         /// 用于弹窗传参的数据模型
         /// </summary>

+ 105 - 16
PDF Office/PDF Office.csproj

@@ -64,9 +64,30 @@
       <SpecificVersion>False</SpecificVersion>
       <HintPath>.\Dragablz.dll</HintPath>
     </Reference>
+    <Reference Include="Dropbox.Api, Version=6.33.0.0, Culture=neutral, PublicKeyToken=310f0e82fbb45d01, processorArchitecture=MSIL">
+      <HintPath>packages\Dropbox.Api.6.33.0\lib\netstandard2.0\Dropbox.Api.dll</HintPath>
+    </Reference>
     <Reference Include="DryIoc, Version=4.7.7.0, Culture=neutral, PublicKeyToken=dfbf2bd50fcf7768, processorArchitecture=MSIL">
       <HintPath>packages\DryIoc.dll.4.7.7\lib\net45\DryIoc.dll</HintPath>
     </Reference>
+    <Reference Include="Google.Apis, Version=1.57.0.0, Culture=neutral, PublicKeyToken=4b01fa6e34db77ab, processorArchitecture=MSIL">
+      <HintPath>packages\Google.Apis.1.57.0\lib\net45\Google.Apis.dll</HintPath>
+    </Reference>
+    <Reference Include="Google.Apis.Auth, Version=1.57.0.0, Culture=neutral, PublicKeyToken=4b01fa6e34db77ab, processorArchitecture=MSIL">
+      <HintPath>packages\Google.Apis.Auth.1.57.0\lib\net461\Google.Apis.Auth.dll</HintPath>
+    </Reference>
+    <Reference Include="Google.Apis.Auth.PlatformServices, Version=1.57.0.0, Culture=neutral, PublicKeyToken=4b01fa6e34db77ab, processorArchitecture=MSIL">
+      <HintPath>packages\Google.Apis.Auth.1.57.0\lib\net461\Google.Apis.Auth.PlatformServices.dll</HintPath>
+    </Reference>
+    <Reference Include="Google.Apis.Core, Version=1.57.0.0, Culture=neutral, PublicKeyToken=4b01fa6e34db77ab, processorArchitecture=MSIL">
+      <HintPath>packages\Google.Apis.Core.1.57.0\lib\net45\Google.Apis.Core.dll</HintPath>
+    </Reference>
+    <Reference Include="Google.Apis.Drive.v3, Version=1.57.0.2859, Culture=neutral, PublicKeyToken=4b01fa6e34db77ab, processorArchitecture=MSIL">
+      <HintPath>packages\Google.Apis.Drive.v3.1.57.0.2859\lib\net45\Google.Apis.Drive.v3.dll</HintPath>
+    </Reference>
+    <Reference Include="Google.Apis.PlatformServices, Version=1.57.0.0, Culture=neutral, PublicKeyToken=4b01fa6e34db77ab, processorArchitecture=MSIL">
+      <HintPath>packages\Google.Apis.1.57.0\lib\net45\Google.Apis.PlatformServices.dll</HintPath>
+    </Reference>
     <Reference Include="Microsoft.AppCenter, Version=0.0.0.0, Culture=neutral, PublicKeyToken=8a600e2fee7ba272, processorArchitecture=MSIL">
       <HintPath>packages\Microsoft.AppCenter.4.5.0\lib\net461\Microsoft.AppCenter.dll</HintPath>
     </Reference>
@@ -76,12 +97,27 @@
     <Reference Include="Microsoft.AppCenter.Crashes, Version=0.0.0.0, Culture=neutral, PublicKeyToken=8a600e2fee7ba272, processorArchitecture=MSIL">
       <HintPath>packages\Microsoft.AppCenter.Crashes.4.5.0\lib\net461\Microsoft.AppCenter.Crashes.dll</HintPath>
     </Reference>
+    <Reference Include="Microsoft.Office.Interop.Excel, Version=15.0.0.0, Culture=neutral, PublicKeyToken=71e9bce111e9429c, processorArchitecture=MSIL">
+      <HintPath>packages\Microsoft.Office.Interop.Excel.15.0.4795.1001\lib\net20\Microsoft.Office.Interop.Excel.dll</HintPath>
+      <EmbedInteropTypes>True</EmbedInteropTypes>
+    </Reference>
+    <Reference Include="Microsoft.Office.Interop.PowerPoint, Version=15.0.0.0, Culture=neutral, PublicKeyToken=71e9bce111e9429c, processorArchitecture=MSIL">
+      <HintPath>packages\Microsoft.Office.Interop.PowerPoint.15.0.4420.1018\lib\net20\Microsoft.Office.Interop.PowerPoint.dll</HintPath>
+      <EmbedInteropTypes>True</EmbedInteropTypes>
+    </Reference>
+    <Reference Include="Microsoft.Office.Interop.Word, Version=15.0.0.0, Culture=neutral, PublicKeyToken=71e9bce111e9429c, processorArchitecture=MSIL">
+      <HintPath>packages\Microsoft.Office.Interop.Word.15.0.4797.1004\lib\net20\Microsoft.Office.Interop.Word.dll</HintPath>
+      <EmbedInteropTypes>True</EmbedInteropTypes>
+    </Reference>
     <Reference Include="Microsoft.Xaml.Behaviors, Version=1.1.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a, processorArchitecture=MSIL">
       <HintPath>packages\Microsoft.Xaml.Behaviors.Wpf.1.1.31\lib\net45\Microsoft.Xaml.Behaviors.dll</HintPath>
     </Reference>
     <Reference Include="Newtonsoft.Json, Version=13.0.0.0, Culture=neutral, PublicKeyToken=30ad4fe6b2a6aeed, processorArchitecture=MSIL">
       <HintPath>packages\Newtonsoft.Json.13.0.1\lib\net45\Newtonsoft.Json.dll</HintPath>
     </Reference>
+    <Reference Include="office, Version=15.0.0.0, Culture=neutral, PublicKeyToken=71e9bce111e9429c">
+      <EmbedInteropTypes>True</EmbedInteropTypes>
+    </Reference>
     <Reference Include="Prism, Version=8.1.97.5141, Culture=neutral, PublicKeyToken=40ee6c3a2184dc59, processorArchitecture=MSIL">
       <HintPath>packages\Prism.Core.8.1.97\lib\net461\Prism.dll</HintPath>
     </Reference>
@@ -174,11 +210,15 @@
     <Compile Include="DataConvert\UnVisivleConvert.cs" />
     <Compile Include="EventAggregators\PageEditNotifyEvent.cs" />
     <Compile Include="EventAggregators\PageEditRefreshEvent.cs" />
+    <Compile Include="Helper\ConverterHelper.cs" />
     <Compile Include="Helper\HomePageEditHelper.cs" />
     <Compile Include="Helper\PasswordBoxHelper.cs" />
     <Compile Include="Helper\PictureConverter.cs" />
+    <Compile Include="Helper\SDKLisenceHelper.cs" />
     <Compile Include="Helper\SettingHelper.cs" />
     <Compile Include="Helper\ToolMethod.cs" />
+    <Compile Include="Model\CloudDrive\CloudDriveItem.cs" />
+    <Compile Include="Model\CloudDrive\CloudFiles.cs" />
     <Compile Include="Model\DialogNames.cs" />
     <Compile Include="CustomControl\SystemControl\InterTabClient.cs" />
     <Compile Include="CustomControl\LoadingControl.xaml.cs">
@@ -208,8 +248,14 @@
     <Compile Include="EventAggregators\OpenFileEvent.cs" />
     <Compile Include="Helper\CommomEvent.cs" />
     <Compile Include="Helper\CommonHelper.cs" />
+    <Compile Include="Properties\Resources.Designer.cs">
+      <DependentUpon>Resources.resx</DependentUpon>
+      <DesignTime>True</DesignTime>
+      <AutoGen>True</AutoGen>
+    </Compile>
     <Compile Include="ViewModels\BOTA\BOTAContentViewModel.cs" />
     <Compile Include="ViewModels\BottomToolContentViewModel.cs" />
+    <Compile Include="ViewModels\Tools\ConverterBarContentViewModel.cs" />
     <Compile Include="ViewModels\Dialog\ExtractDialogViewModel.cs" />
     <Compile Include="ViewModels\Dialog\FullScreenWindowViewModel.cs" />
     <Compile Include="ViewModels\Dialog\HomePageToolsDialogs\HomePageBatchProcessing\HomePageBatchProcessingDialogViewModel.cs" />
@@ -231,8 +277,14 @@
     <Compile Include="ViewModels\Dialog\ToolsDialogs\SaftyDialogs\CheckPasswordDialogViewModel.cs" />
     <Compile Include="ViewModels\Dialog\ToolsDialogs\SaftyDialogs\SetPasswordDialogViewModel.cs" />
     <Compile Include="ViewModels\Dialog\VerifyPassWordDialogViewModel.cs" />
+    <Compile Include="ViewModels\HomePanel\CloudDrive\CloudDriveContentViewModel.cs" />
+    <Compile Include="ViewModels\HomePanel\CloudDrive\CloudDriveManager.cs" />
+    <Compile Include="ViewModels\HomePanel\CloudDrive\CloudFilesContentViewModel.cs" />
+    <Compile Include="ViewModels\HomePanel\CloudDrive\CloudDriveType\DropbBoxManager.cs" />
+    <Compile Include="ViewModels\HomePanel\CloudDrive\CloudDriveType\DropbBoxUserItem.cs" />
+    <Compile Include="ViewModels\HomePanel\CloudDrive\CloudDriveType\GoogleDriveManager.cs" />
+    <Compile Include="ViewModels\HomePanel\CloudDrive\CloudDriveType\GoogleDriveUserItem.cs" />
     <Compile Include="ViewModels\Dialog\HomePageToolsDialogs\HomePagePictureToPDFDialogViewModel.cs" />
-    <Compile Include="ViewModels\HomePageSetPasswordDialogViewModel.cs" />
     <Compile Include="ViewModels\HomePanel\HomeCloudContentViewModel.cs" />
     <Compile Include="ViewModels\HomePanel\HomeGuidContentViewModel.cs" />
     <Compile Include="ViewModels\HomePanel\HomeToolsContentViewModel.cs" />
@@ -316,10 +368,10 @@
     <Compile Include="Views\Dialog\VerifyPassWordDialog.xaml.cs">
       <DependentUpon>VerifyPassWordDialog.xaml</DependentUpon>
     </Compile>
-    <Compile Include="Views\HomePanel\CloudDocs\CloudDiskContent.xaml.cs">
-      <DependentUpon>CloudDiskContent.xaml</DependentUpon>
+    <Compile Include="Views\HomePanel\CloudDrive\CloudDriveContent.xaml.cs">
+      <DependentUpon>CloudDriveContent.xaml</DependentUpon>
     </Compile>
-    <Compile Include="Views\HomePanel\CloudDocs\CloudFilesContent.xaml.cs">
+    <Compile Include="Views\HomePanel\CloudDrive\CloudFilesContent.xaml.cs">
       <DependentUpon>CloudFilesContent.xaml</DependentUpon>
     </Compile>
     <Compile Include="Views\HomePanel\HomeCloudContent.xaml.cs">
@@ -359,6 +411,12 @@
     <Compile Include="Views\PageEdit\PageEditContent.xaml.cs">
       <DependentUpon>PageEditContent.xaml</DependentUpon>
     </Compile>
+    <Compile Include="Views\Tools\AnnotToolContent.xaml.cs">
+      <DependentUpon>AnnotToolContent.xaml</DependentUpon>
+    </Compile>
+    <Compile Include="Views\Tools\ConverterBarContent.xaml.cs">
+      <DependentUpon>ConverterBarContent.xaml</DependentUpon>
+    </Compile>
     <Compile Include="Views\Tools\ToolsBarContent.xaml.cs">
       <DependentUpon>ToolsBarContent.xaml</DependentUpon>
     </Compile>
@@ -533,11 +591,11 @@
       <Generator>MSBuild:Compile</Generator>
       <SubType>Designer</SubType>
     </Page>
-    <Page Include="Views\HomePanel\CloudDocs\CloudDiskContent.xaml">
+    <Page Include="Views\HomePanel\CloudDrive\CloudDriveContent.xaml">
       <SubType>Designer</SubType>
       <Generator>MSBuild:Compile</Generator>
     </Page>
-    <Page Include="Views\HomePanel\CloudDocs\CloudFilesContent.xaml">
+    <Page Include="Views\HomePanel\CloudDrive\CloudFilesContent.xaml">
       <Generator>MSBuild:Compile</Generator>
       <SubType>Designer</SubType>
     </Page>
@@ -607,6 +665,14 @@
       <Generator>MSBuild:Compile</Generator>
       <SubType>Designer</SubType>
     </Page>
+    <Page Include="Views\Tools\AnnotToolContent.xaml">
+      <SubType>Designer</SubType>
+      <Generator>MSBuild:Compile</Generator>
+    </Page>
+    <Page Include="Views\Tools\ConverterBarContent.xaml">
+      <SubType>Designer</SubType>
+      <Generator>MSBuild:Compile</Generator>
+    </Page>
     <Page Include="Views\Tools\ToolsBarContent.xaml">
       <SubType>Designer</SubType>
       <Generator>MSBuild:Compile</Generator>
@@ -620,20 +686,14 @@
     <Compile Include="Properties\AssemblyInfo.cs">
       <SubType>Code</SubType>
     </Compile>
-    <Compile Include="Properties\Resources.Designer.cs">
-      <AutoGen>True</AutoGen>
-      <DesignTime>True</DesignTime>
-      <DependentUpon>Resources.resx</DependentUpon>
-    </Compile>
     <Compile Include="Properties\Settings.Designer.cs">
       <AutoGen>True</AutoGen>
       <DependentUpon>Settings.settings</DependentUpon>
       <DesignTimeSharedInput>True</DesignTimeSharedInput>
     </Compile>
-    <EmbeddedResource Include="Properties\Resources.resx">
-      <Generator>ResXFileCodeGenerator</Generator>
-      <LastGenOutput>Resources.Designer.cs</LastGenOutput>
-    </EmbeddedResource>
+    <None Include="credentials.json">
+      <CopyToOutputDirectory>Always</CopyToOutputDirectory>
+    </None>
     <None Include="packages.config" />
     <None Include="Properties\Settings.settings">
       <Generator>SettingsSingleFileGenerator</Generator>
@@ -644,7 +704,9 @@
     <None Include="App.config" />
   </ItemGroup>
   <ItemGroup>
-    <Folder Include="Views\Dialog\Convertor\" />
+    <Folder Include="Model\Dialog\ConverterDialogs\" />
+    <Folder Include="ViewModels\Dialog\ConverterDialogs\" />
+    <Folder Include="Views\Dialog\ConverterDialogs\" />
     <Folder Include="Views\Edit\" />
     <Folder Include="Views\FillAndSign\" />
     <Folder Include="Views\Forms\" />
@@ -684,6 +746,27 @@
     <Resource Include="Resources\PromotionIcon\Windows.png" />
     <Resource Include="Resources\FilesType\ic_propertybar_file_pdf_lock.png" />
     <Resource Include="Resources\FilesType\ic_propertybar_file_png_Large.png" />
+    <Resource Include="SDKLisence.xml" />
+    <Content Include="index.html">
+      <CopyToOutputDirectory>Always</CopyToOutputDirectory>
+    </Content>
+    <Resource Include="Resources\ToolBarIcon\MyTools\Arrow.png" />
+    <Resource Include="Resources\ToolBarIcon\MyTools\Bookmark.png" />
+    <Resource Include="Resources\ToolBarIcon\MyTools\Circle.png" />
+    <Resource Include="Resources\ToolBarIcon\MyTools\Freehande.png" />
+    <Resource Include="Resources\ToolBarIcon\MyTools\Freehande2.png" />
+    <Resource Include="Resources\ToolBarIcon\MyTools\Hand.png" />
+    <Resource Include="Resources\ToolBarIcon\MyTools\Highlight.png" />
+    <Resource Include="Resources\ToolBarIcon\MyTools\Hyperlink.png" />
+    <Resource Include="Resources\ToolBarIcon\MyTools\Image.png" />
+    <Resource Include="Resources\ToolBarIcon\MyTools\Line.png" />
+    <Resource Include="Resources\ToolBarIcon\MyTools\Note.png" />
+    <Resource Include="Resources\ToolBarIcon\MyTools\Point.png" />
+    <Resource Include="Resources\ToolBarIcon\MyTools\Rectangle.png" />
+    <Resource Include="Resources\ToolBarIcon\MyTools\Selecttool.png" />
+    <Resource Include="Resources\ToolBarIcon\MyTools\Stamp.png" />
+    <Resource Include="Resources\ToolBarIcon\MyTools\Textbox.png" />
+    <Resource Include="Resources\ToolBarIcon\MyTools\wavyline2.png" />
     <Content Include="SystemService\PreviewHandler.dll">
       <CopyToOutputDirectory>Always</CopyToOutputDirectory>
     </Content>
@@ -754,6 +837,12 @@
       <Name>PDFSettings</Name>
     </ProjectReference>
   </ItemGroup>
+  <ItemGroup>
+    <EmbeddedResource Include="Properties\Resources.resx">
+      <Generator>ResXFileCodeGenerator</Generator>
+      <LastGenOutput>Resources.Designer.cs</LastGenOutput>
+    </EmbeddedResource>
+  </ItemGroup>
   <Import Project="$(MSBuildToolsPath)\Microsoft.CSharp.targets" />
   <Target Name="EnsureNuGetPackageBuildImports" BeforeTargets="PrepareForBuild">
     <PropertyGroup>

+ 13 - 1
PDF Office/Properties/Resources.Designer.cs

@@ -19,7 +19,7 @@ namespace PDF_Office.Properties {
     // 类通过类似于 ResGen 或 Visual Studio 的工具自动生成的。
     // 若要添加或移除成员,请编辑 .ResX 文件,然后重新运行 ResGen
     // (以 /str 作为命令选项),或重新生成 VS 项目。
-    [global::System.CodeDom.Compiler.GeneratedCodeAttribute("System.Resources.Tools.StronglyTypedResourceBuilder", "17.0.0.0")]
+    [global::System.CodeDom.Compiler.GeneratedCodeAttribute("System.Resources.Tools.StronglyTypedResourceBuilder", "16.0.0.0")]
     [global::System.Diagnostics.DebuggerNonUserCodeAttribute()]
     [global::System.Runtime.CompilerServices.CompilerGeneratedAttribute()]
     internal class Resources {
@@ -68,5 +68,17 @@ namespace PDF_Office.Properties {
                 return ResourceManager.GetString("OpenDialogFilter", resourceCulture);
             }
         }
+        
+        /// <summary>
+        ///   查找类似 &lt;xml version=&quot;1.0&quot; encoding = &quot;UTF-8&quot; stantdalone=&quot;yes&quot;&gt;
+        ///	&lt;Lisences
+        ///		devKey = &quot;tmqcblSkvVZeNj9k4nMA88G6g1kw4yYH+tPiqK+T91CaGM9urgNlT1+kXiTyv0W1bTQNObS51WgQpfJNl1inRVDKBB3wznw2o7vtKjOKKDNbV7R1ply0PhDKVkKYV040vpAdaT8GZEfllftNlts99uGhscqGvmCLBKmgTsq0HFo=&quot;
+        ///		devSecret=&quot;mG0c3O3Mzeu5dkZJW3gpqq9uA7o7EGQveSC38Q8TK4iccr16WMBclnQACarlyblNMFa171moVHNuaoPG9eUt/RDYPB4dH12/mo6Nb7CMnoDUShGRobCLus9Vl3Sb80EZvGI/sVnm7Ju0Mhj+L/faMDDsKeheIw8v1IwmcZT3yU2l9MwkobWvR2DRybgSkLGYbFAv+VbVAICHE/17JjUpTkFo+FpaETldwAVsTVNm77oq2xRRte [字符串的其余部分被截断]&quot;; 的本地化字符串。
+        /// </summary>
+        internal static string SDKLisence {
+            get {
+                return ResourceManager.GetString("SDKLisence", resourceCulture);
+            }
+        }
     }
 }

+ 4 - 0
PDF Office/Properties/Resources.resx

@@ -120,4 +120,8 @@
   <data name="OpenDialogFilter" xml:space="preserve">
     <value>PDF Files (*.pdf)|*.pdf</value>
   </data>
+  <assembly alias="System.Windows.Forms" name="System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089" />
+  <data name="SDKLisence" type="System.Resources.ResXFileRef, System.Windows.Forms">
+    <value>..\SDKLisence.xml;System.String, mscorlib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089;gb2312</value>
+  </data>
 </root>

TEMPAT SAMPAH
PDF Office/Resources/ToolBarIcon/MyTools/Arrow.png


TEMPAT SAMPAH
PDF Office/Resources/ToolBarIcon/MyTools/Bookmark.png


TEMPAT SAMPAH
PDF Office/Resources/ToolBarIcon/MyTools/Circle.png


TEMPAT SAMPAH
PDF Office/Resources/ToolBarIcon/MyTools/Freehande.png


TEMPAT SAMPAH
PDF Office/Resources/ToolBarIcon/MyTools/Freehande2.png


TEMPAT SAMPAH
PDF Office/Resources/ToolBarIcon/MyTools/Hand.png


TEMPAT SAMPAH
PDF Office/Resources/ToolBarIcon/MyTools/Highlight.png


TEMPAT SAMPAH
PDF Office/Resources/ToolBarIcon/MyTools/Hyperlink.png


TEMPAT SAMPAH
PDF Office/Resources/ToolBarIcon/MyTools/Image.png


TEMPAT SAMPAH
PDF Office/Resources/ToolBarIcon/MyTools/Line.png


TEMPAT SAMPAH
PDF Office/Resources/ToolBarIcon/MyTools/Note.png


TEMPAT SAMPAH
PDF Office/Resources/ToolBarIcon/MyTools/Point.png


TEMPAT SAMPAH
PDF Office/Resources/ToolBarIcon/MyTools/Rectangle.png


TEMPAT SAMPAH
PDF Office/Resources/ToolBarIcon/MyTools/Selecttool.png


TEMPAT SAMPAH
PDF Office/Resources/ToolBarIcon/MyTools/Stamp.png


TEMPAT SAMPAH
PDF Office/Resources/ToolBarIcon/MyTools/Textbox.png


TEMPAT SAMPAH
PDF Office/Resources/ToolBarIcon/MyTools/wavyline2.png


+ 11 - 0
PDF Office/SDKLisence.xml

@@ -0,0 +1,11 @@
+<Lisences
+	devKey = "sTHSivIW4YnZQavIYDLVw4vaFcN5DQTUtRGrVyv5p9aeaHX3GirG/MBxl6Wy9TJbNOwR4CU6LPjHmGe3Po3OtBCPqIRheam9+LomScw3AvoUTHFlG1134e2J4enF43WJQ6PyOnjwZqsG1kUdlBPNztkoPzDAE2pQKgZWf6V2i34="
+            devSecret = "mG0c3O3Mzeu5dkZJW3gpqq9uA7o7EGQveSC38Q8TK4gQurxTxGuBlGAhs0P1mD3X3bHT+AHfcLiymaqE4DY7kTFHoPs9I3tl5ErS+BHdzHRhrp9sGpqfp0B228KI+IMTu4aGVjtYuk+Uxs/kosIBw1367/WkJ00tM7U7tttD6cfaiHpW8pgW2aur3AxuQIBBLuJD5gcmNxTYW3KA32JLG8alfyXjKFVS3gka9bngvwfZ7GuNXybjKlmz1tnN6iVHpnbSj+xOHhWEperY4HHrSg=="
+	userKey = "iBPRM/Tz8b6Z1G2GQt52X7hiNCGfVYXztnPjalgrgARvqfKV6lFNH8QeScTzBRYI8GGFpwelfgh790Kd9JmL7V4adI1jCiFHUT2DLT7QucxY5Nkgys2aJItQS482Ck2G2Xf8gNgojxYxRt65o/MEzkj93foj8qIdfHagXsSorSs="
+	userSecret="mG0c3O3Mzeu5dkZJW3gpqq9uA7o7EGQveSC38Q8TK4ivEHOmPIqbfhpDnKKj+7Ymj2rXQvfZRmke06HMV+3tt064G64WjPW8+EbGCNZaAh1hrp9sGpqfp0B228KI+IMTu4aGVjtYuk+Uxs/kosIBw1FKJi6HYB+DuugQyaqI2prfej861QnJrU4s2T/npZK/"
+	ConverterDevKey="mDDCTNY5rV2+FUj2JESUBruJ0643Tv7rNuxACu6g3L/0guIw1r8zZB+o3aw3rs4rrOThmxBXpEDcItvyGx096mF/3Ixg7aD6QZk5HvBEScIPerdM3KnhgwMwCjE0DYOSMCRwAhbA2xjXfXgT5VVo7JZroKOGQB5Qmf2kLl5nQuU="
+	ConverterDevSecret="mG0c3O3Mzeu5dkZJW3gpqq9uA7o7EGQveSC38Q8TK4g3S5AixMY+3TX1FpQaugG9sTsnCq4QxIEDzyAI3s3dWjNe3wDsMrmFq51HtjPa2tSFAoV6NtcUJC8skonXVk7kMv7C2jvq4o0q6sQtN3jR42k0n/LkN5UfbQ5Lfel4OfZrk7dh2/DUR87Ps4vBX1hrYkwcNWVMyYvggPV2rTFvfawopGIC034QzjthmhwwX90="
+	ConverterUserkey=" WLUHzXhndQKyrTJVzvZ+dvPXDQDZeJpcSvklX3GJwRX4+urd8eQskYgbeCf0NXLZ/qJkS/k10x+qGad34i4v5rI/ASFIx901c/Nw5C0YJMH7X87dib141tdAmSmQhnKLO5TBi4FiAidboyvnLFLrYGMmS2kLQOXFPwPj5zQUv5A="
+	ConverterUserSecret="mG0c3O3Mzeu5dkZJW3gpqq9uA7o7EGQveSC38Q8TK4iK16EcneqBPRe2eKQLuJXpA79IONX9GVI/Ap3uWzMcNWaitc2UB6gDeexJXFPVaXOFAoV6NtcUJC8skonXVk7k/oKTJGcYKLPGdXenrzHolQ=="
+	>
+</Lisences>

+ 36 - 1
PDF Office/Styles/CustomBtnStyle.xaml

@@ -221,4 +221,39 @@
             </Setter.Value>
         </Setter>
     </Style>
-</ResourceDictionary>
+
+
+    <Style x:Key="HomePageCompressBtn" TargetType="Button">
+        <Setter Property="Background" Value="White"/>
+        <Setter Property="BorderBrush" Value="White"/>
+        <Setter Property="HorizontalAlignment" Value="Center"/>
+
+        <Setter Property="Template">
+            <Setter.Value>
+                <ControlTemplate TargetType="{x:Type Button}">
+                    <Border x:Name="border" BorderBrush="White" BorderThickness="1,1,1,1" Background="{TemplateBinding Background}" SnapsToDevicePixels="true" >
+                        <ContentPresenter x:Name="contentPresenter" Focusable="False" HorizontalAlignment="{TemplateBinding HorizontalContentAlignment}" Margin="{TemplateBinding Padding}" RecognizesAccessKey="True" SnapsToDevicePixels="{TemplateBinding SnapsToDevicePixels}" VerticalAlignment="{TemplateBinding VerticalContentAlignment}"/>
+                    </Border>
+                    <ControlTemplate.Triggers>
+                        <Trigger Property="IsMouseOver" Value="true">
+                            <Setter Property="Background" TargetName="border" Value="#1A000000"/>
+                            <Setter Property="BorderBrush" TargetName="border" Value= "AntiqueWhite"/>
+                        </Trigger>
+                        <Trigger Property="IsPressed" Value="true">
+                            <Setter Property="Background" TargetName="border" Value="#26000000"/>
+                            <Setter Property="BorderBrush" TargetName="border" Value= "WhiteSmoke"/>
+                        </Trigger>
+                        <Trigger Property="IsEnabled" Value="false">
+                            <Setter Property="Background" TargetName="border" Value="White"/>
+                            <Setter Property="BorderBrush" TargetName="border" Value="White"/>
+                            <Setter Property="TextElement.Foreground" TargetName="contentPresenter" Value="Black"/>
+                            <Setter Property="Opacity" TargetName="contentPresenter" Value="1"/>
+                        </Trigger>
+                    </ControlTemplate.Triggers>
+                </ControlTemplate>
+            </Setter.Value>
+        </Setter>
+    </Style>
+</ResourceDictionary>
+    
+    

+ 1 - 0
PDF Office/Styles/WindowsStyle.xaml

@@ -11,6 +11,7 @@
                     GlassFrameThickness="-1"
                     ResizeBorderThickness="5"
                     UseAeroCaptionButtons="False" />
+                <!--  GlassFrameThickness="-1" win11上显示异常  -->
             </Setter.Value>
         </Setter>
         <Setter Property="Template">

+ 77 - 3
PDF Office/ViewModels/BOTA/BOTAContentViewModel.cs

@@ -5,19 +5,84 @@ using System.Collections.Generic;
 using System.Linq;
 using System.Text;
 using System.Threading.Tasks;
+using ComPDFKitViewer.PdfViewer;
+using PDF_Office.Model;
+using Prism.Commands;
+using System.Windows.Controls;
 
 namespace PDF_Office.ViewModels.BOTA
 {
     public class BOTAContentViewModel:BindableBase, INavigationAware
     {
 
-        public BOTAContentViewModel()
+        private CPDFViewer pdfViewer { get; set; }
+
+        private IRegionManager regions { get; set; }
+
+        private ViewContentViewModel viewContentViewModel { get; set; }
+
+        private Dictionary<string, string> viewNameByTabItem { get; set; }
+
+        private string botaContentRegionName;
+
+        public string BOTAContentRegionNmae
         {
+            get { return botaContentRegionName; }
+            set
+            {
+                SetProperty(ref botaContentRegionName, value);
+            }
+        }
 
+        public DelegateCommand<object> TabControlSelectionChangedCommand { get; set; }
+
+        public BOTAContentViewModel(IRegionManager regionManager)
+        {
+            regions = regionManager;
+            
+            BOTAContentRegionNmae = Guid.NewGuid().ToString();
+
+            InitDictionartViewNameByTabItem();
         }
 
-        #region Navigate
 
+        private void TabControlSelectionChangedEvent(object e)
+        {
+            var args = e as SelectionChangedEventArgs;
+            if (args != null)
+            {
+                EnterSelectedBar((args.AddedItems[0] as TabItem).Name);
+            }
+        }
+
+        /// <summary>
+        /// 初始化名称-视图字典
+        /// </summary>
+        private void InitDictionartViewNameByTabItem()
+        {
+            viewNameByTabItem = new Dictionary<string, string>();
+            //绑定tabitem名字和对应的View控件名称
+            viewNameByTabItem.Add("TabItemThumbnail","");
+            viewNameByTabItem.Add("TabItemOutLine", "");
+            viewNameByTabItem.Add("TabItemBookMark", "");
+            viewNameByTabItem.Add("TabItemAnnotation", "");
+            viewNameByTabItem.Add("TabItemSearch", "");
+            viewNameByTabItem.Add("TabItemForm", "");
+            viewNameByTabItem.Add("TabItemSign", "");
+        }
+
+        /// <summary>
+        /// 导航至目标TabItem
+        /// </summary>
+        /// <param name="currentBar"></param>
+        private void EnterSelectedBar(string currentBar)
+        {
+            NavigationParameters param = new NavigationParameters();
+            param.Add(ParameterNames.PDFViewer, pdfViewer);
+            regions.RequestNavigate(BOTAContentRegionNmae, viewNameByTabItem[currentBar], param);
+        }
+
+        #region Navigate
         public bool IsNavigationTarget(NavigationContext navigationContext)
         {
             return true;
@@ -30,7 +95,16 @@ namespace PDF_Office.ViewModels.BOTA
 
         public void OnNavigatedTo(NavigationContext navigationContext)
         {
-            
+            var contentViewModel = navigationContext.Parameters[ParameterNames.ViewContentViewModel] as ViewContentViewModel;
+            if (contentViewModel != null)
+            {
+                viewContentViewModel = contentViewModel;
+            }
+            var pdfview = navigationContext.Parameters[ParameterNames.PDFViewer] as CPDFViewer;
+            if (pdfview != null)
+            {
+                pdfViewer = pdfview;
+            }
         }
         #endregion
     }

+ 55 - 13
PDF Office/ViewModels/Dialog/HomePageToolsDialogs/HomePageBatchProcessing/HomePageBatchProcessingDialogViewModel.cs

@@ -1,4 +1,8 @@
-using Prism.Commands;
+using ComPDFKitViewer.PdfViewer;
+using Microsoft.Office.Interop.Word;
+using PDF_Office.Model;
+using PDF_Office.Model.Dialog.HomePageToolsDialogs.HomePageBatchProcessing;
+using Prism.Commands;
 using Prism.Mvvm;
 using Prism.Regions;
 using Prism.Services.Dialogs;
@@ -6,34 +10,54 @@ using System;
 using System.Collections.Generic;
 using System.Drawing;
 using System.Linq;
+using System.Windows;
 using System.Windows.Controls;
 
 namespace PDF_Office.ViewModels.Dialog.HomePageToolsDialogs.HomePageBatchProcessing
 {
-    public class HomePageBatchProcessingDialogViewModel : BindableBase, IDialogAware
+    public class HomePageBatchProcessingDialogViewModel : BindableBase, IDialogAware, INavigationAware
     {
-        public IRegionManager BatchProcessingRegion;
-
-        public string BatchProcessingRegionName { get; set; }
+        private List<string> fileNames;
 
-        public List<string> GetBatchProcessing = new List<string> { "HomePageSetPasswordDialog", "HomePageCompressDialog" };
+        public IRegionManager BatchProcessingRegion;
 
-        private string batchProcessingSelectedIndex = "0";
-        public string BatchProcessingSelectedIndex
+        private string batchProcessingRegionName;
+        public string BatchProcessingRegionName
         {
-            get { return batchProcessingSelectedIndex; }
+            get
+            {
+                return batchProcessingRegionName;
+            }
             set
             {
-                SetProperty(ref batchProcessingSelectedIndex, value);
+                SetProperty(ref batchProcessingRegionName, value);
             }
         }
 
+        private Visibility batchProcessingVisible = Visibility.Collapsed;
+        public Visibility BatchProcessingVisible
+        {
+            get { return batchProcessingVisible; }
+            set { SetProperty(ref batchProcessingVisible, value); }
+        }
+        public DelegateCommand<string> DelegateChangeBatchProcessingCommand { get; set; }
+
         public HomePageBatchProcessingDialogViewModel(IRegionManager regionManager)
         {
             BatchProcessingRegion = regionManager;
             BatchProcessingRegionName = Guid.NewGuid().ToString();
+            DelegateChangeBatchProcessingCommand= new DelegateCommand<string>(ChangeBatchProcessing);
         }
 
+        public void ChangeBatchProcessing(string index) {
+            if (index =="1"||index=="2") { 
+            NavigationParameters param = new NavigationParameters();
+            param.Add(ParameterNames.FilePath, HomePageBatchProcessingDialogModel.FilePaths);
+            BatchProcessingVisible = Visibility.Collapsed;
+            BatchProcessingRegion.RequestNavigate(BatchProcessingRegionName, HomePageBatchProcessingDialogModel.GetBatchProcessing[int.Parse(index)], param);
+            BatchProcessingVisible = Visibility.Visible;
+            }
+        }
 
         public string Title => "PDF批量工具";
 
@@ -51,10 +75,28 @@ namespace PDF_Office.ViewModels.Dialog.HomePageToolsDialogs.HomePageBatchProcess
 
         public void OnDialogOpened(IDialogParameters parameters)
         {
-            BatchProcessingRegion.RequestNavigate(BatchProcessingRegionName, GetBatchProcessing[0]);
-            BatchProcessingRegion.RequestNavigate(BatchProcessingRegionName, GetBatchProcessing[1]);
-            BatchProcessingSelectedIndex = "0";
+            string batchprocessingname = "";
+            string[] filepath = null;
+            parameters.TryGetValue<string>(ParameterNames.BatchProcessing_Name, out batchprocessingname);
+            parameters.TryGetValue<string[]>(ParameterNames.FilePath, out filepath);
+            if (batchprocessingname != null || filepath != null) {
+                fileNames = filepath.ToList();
+                ChangeBatchProcessing(batchprocessingname);
+            }
+        }
+
+        public void OnNavigatedTo(NavigationContext navigationContext)
+        {
+            
+        }
 
+        public bool IsNavigationTarget(NavigationContext navigationContext)
+        {
+            return true;
+        }
+
+        public void OnNavigatedFrom(NavigationContext navigationContext)
+        {
         }
     }
 }

+ 283 - 10
PDF Office/ViewModels/Dialog/HomePageToolsDialogs/HomePageBatchProcessing/HomePageCompressDialogViewModel.cs

@@ -1,30 +1,76 @@
-using Prism.Commands;
+using ComPDFKit.PDFDocument;
+using PDF_Office.CustomControl;
+using PDF_Office.Model;
+using PDF_Office.Model.Dialog.HomePageToolsDialogs.HomePageBatchProcessing;
+using Prism.Commands;
 using Prism.Mvvm;
 using Prism.Regions;
 using Prism.Services.Dialogs;
 using System;
 using System.Collections.Generic;
 using System.Data;
+using System.IO;
 using System.Linq;
 using System.Windows;
+using System.Windows.Forms;
+using DataTable = System.Data.DataTable;
+using DialogResult = Prism.Services.Dialogs.DialogResult;
+using Task = System.Threading.Tasks.Task;
 
 namespace PDF_Office.ViewModels.Dialog.HomePageToolsDialogs.HomePageBatchProcessing
 {
     public class HomePageCompressDialogViewModel : BindableBase, INavigationAware
     {
-        public HomePageCompressDialogViewModel()
+        private List<string> fileNames;
+
+        private CPDFDocument tempDocument;
+
+        public List<int> fileNamesView = new List<int>();
+
+        private int fileNamesIndex = 0;
+
+        private IntPtr compressingIntpr = IntPtr.Zero;
+
+        private CPDFDocument.GetPageIndexDelegate indexDelegate = null;
+
+        HomePageCompressDialogModel homePageCompressDialogModel=new HomePageCompressDialogModel();
+
+        private DataTable pdfDataTable = new DataTable();
+        public DataTable PDFDataTable
         {
+            get { return pdfDataTable; }
+            set
+            {
+                SetProperty(ref pdfDataTable, value);
+            }
+        }
 
+        private string compressGridIsEnabled="True";
+        public string CompressGridIsEnabled
+        {
+            get
+            {
+                return compressGridIsEnabled;
+            }
+            set
+            {
+                SetProperty(ref compressGridIsEnabled, value);
+            }
         }
-        private DataTable imagesDataTable = new DataTable();
-        public DataTable ImagesDataTable
+
+        private string setCompressGridIsEnabled = "True";
+        public string SetCompressGridIsEnabled
         {
-            get { return imagesDataTable; }
+            get
+            {
+                return setCompressGridIsEnabled;
+            }
             set
             {
-                SetProperty(ref imagesDataTable, value);
+                SetProperty(ref setCompressGridIsEnabled, value);
             }
         }
+
         private string removeIsEnable = "False";
         public string RemoveIsEnable
         {
@@ -56,21 +102,248 @@ namespace PDF_Office.ViewModels.Dialog.HomePageToolsDialogs.HomePageBatchProcess
 
             }
         }
+        public DelegateCommand ADDPDFCommand { get; set; }
 
+        public DelegateCommand RemovePDFFileCommand { get; set; }
 
-        public bool IsNavigationTarget(NavigationContext navigationContext)
+        public DelegateCommand ADDPDFFilesCommand { get; set; }
+
+        public DelegateCommand CompressCommand { get; set; }
+
+        public DelegateCommand<string> RadioButtonCommand{ get; set; }
+
+        public HomePageCompressDialogViewModel()
         {
-            return true;
+            PDFDataTable.Columns.Add("FileName");
+            PDFDataTable.Columns.Add("FileSize");
+            PDFDataTable.Columns.Add("FileState");
+            ADDPDFCommand = new DelegateCommand(addpicture);
+            ADDPDFFilesCommand = new DelegateCommand(addpicturefiles);
+            RemovePDFFileCommand = new DelegateCommand(removepdffile);
+            CompressCommand = new DelegateCommand(compress);
+            RadioButtonCommand = new DelegateCommand<string>(RadioButton);
         }
 
-        public void OnNavigatedFrom(NavigationContext navigationContext)
+        private void RadioButton(string sender) {
+            if (sender != "") {
+
+                switch (sender) {
+                    case "LargeQualityRadioBtn":
+                        homePageCompressDialogModel.CompressQuality = HomePageCompressDialogModel.EnumQualityLevel.StatusLarge;
+                        break;
+                    case "StandardQualityRadioBtn":
+                        homePageCompressDialogModel.CompressQuality = HomePageCompressDialogModel.EnumQualityLevel.StatusStandard;
+                        break;
+                    case "LittleQualityRadioBtn":
+                        homePageCompressDialogModel.CompressQuality = HomePageCompressDialogModel.EnumQualityLevel.StatusLittle;
+                        break;
+                    case "MicroQualityRadioBtn":
+                        homePageCompressDialogModel.CompressQuality = HomePageCompressDialogModel.EnumQualityLevel.StatusMicro;
+                        break;
+                        default:
+                        homePageCompressDialogModel.CompressQuality = HomePageCompressDialogModel.EnumQualityLevel.StatusDefault;
+                        break;
+
+                }
+            }
+
+        }
+
+        private int GetIndex(int pageindex)
         {
+            PDFDataTable.Rows[fileNamesIndex]["FileState"]="已经压缩"+pageindex.ToString()+"页";
+            return 0;
         }
 
-        public void OnNavigatedTo(NavigationContext navigationContext)
+        private async void compress() {
+            CompressGridIsEnabled = "False";
+            //GC.KeepAlive(indexDelegate);
+            fileNamesIndex = 0;
+            foreach (var filename in fileNames)
+            {
+                CPDFDocument document = CPDFDocument.InitWithFilePath(filename);
+                if (document == null) {
+                    PDFDataTable.Rows[fileNamesIndex]["FileState"] = "文件出错";
+                    continue;
+                }
+                FileInfo fileinfo = new FileInfo(filename);
+                string file_size = (((float)fileinfo.Length) / 1024).ToString() + " K";
+                indexDelegate += GetIndex;
+                compressingIntpr = document.CompressFile_Init(((float)homePageCompressDialogModel.CompressQuality), indexDelegate);
+                tempDocument = document;
+                await Task.Run<bool>(() => { return document.CompressFile_Start(compressingIntpr, filename+"compress.pdf"); });
+                PDFDataTable.Rows[fileNamesIndex]["FileState"] = "完成";
+                fileNamesIndex++;
+                document.Release();
+            }
+            CompressGridIsEnabled = "True";
+            MessageBoxEx.Show("已完成");
+            SetCompressGridIsEnabled = "False";
+            AddFileVisibility = Visibility.Visible;
+            fileNames.Clear();
+            HomePageBatchProcessingDialogModel.FilePaths.Clear();
+        }
+
+        /// <summary>
+        /// 添加PDF文件
+        /// </summary>
+        private void addpicture()
+        {
+            System.Windows.Forms.OpenFileDialog dlg = new System.Windows.Forms.OpenFileDialog();
+            dlg.Multiselect = true;
+            dlg.Filter = "PDF|*.pdf;*.PDF;";
+            if (dlg.ShowDialog() == System.Windows.Forms.DialogResult.OK)
+            {
+                fileNames.AddRange(dlg.FileNames.ToList());
+                RemoveExcess(ref fileNames);
+                SetCompressGridIsEnabled = "True";
+                AddFileVisibility = Visibility.Collapsed;
+                updateListview("待确定");
+            }
+        }
+
+        /// <summary>
+        /// 删除重复的文件
+        /// </summary>
+        public void RemoveExcess(ref List<string> Filenames)
+        {
+            List<string> filenames = new List<string>();
+            foreach (var fileName in Filenames)
+            {
+                if (!filenames.Contains(fileName))
+                {
+                    filenames.Add(fileName);
+                }
+            }
+            Filenames.Clear();
+            Filenames = filenames;
+        }
+
+        /// <summary>
+        /// 添加PDF文件夹
+        /// </summary>
+        private void addpicturefiles()
         {
+            FolderBrowserDialog dialog = new FolderBrowserDialog();
+            dialog.Description = "请选择文件路径";
+            if (dialog.ShowDialog() == System.Windows.Forms.DialogResult.OK)
+            {
+
+                string foldPath = dialog.SelectedPath;
+                var apps = System.IO.Directory.GetFiles(foldPath);
+                foreach (string app in apps)
+                {
+                    var fi = new FileInfo(app);
+                    if (fi.Extension == ".pdf" || fi.Extension == ".PDF")
+                    {
+                        fileNames.Add(app);
+                    }
+                }
+                RemoveExcess(ref fileNames);
+                updateListview("待确定");
+                SetCompressGridIsEnabled = "True";
+                AddFileVisibility = Visibility.Collapsed;
+            }
             
         }
+        /// <summary>
+        /// 更新listview显示
+        /// state 状态显示字符串
+        /// </summary>
+        public void updateListview(string state)
+        {
+            DataTable pdfdatatable = new DataTable();
+            pdfdatatable.Columns.Add("FileName");
+            pdfdatatable.Columns.Add("FileSize");
+            pdfdatatable.Columns.Add("FileState");
+            foreach (var fileName in fileNames)
+            {
+                string file_all = fileName;
+                FileInfo f = new FileInfo(file_all);
+                string file_size = (((float)f.Length) / 1024).ToString() + " K";
+                pdfdatatable.Rows.Add(f.Name, file_size, state);
+            }
+            PDFDataTable = pdfdatatable;
+            HomePageBatchProcessingDialogModel.FilePaths = fileNames;
+
+        }
+        /// <summary>
+        /// 逆序int类型集合
+        /// </summary>
+        public void Reverseorder(ref List<int> Numbers)
+        {
+            Numbers = Numbers.OrderBy(a => a).ToList();
+            Numbers.Reverse();
+        }
+
+        /// <summary>
+        /// 打开文件PDF
+        /// </summary>
+        public void openfiledialog()
+        {
+
+            foreach (int filenamesview in fileNamesView)
+            {
+                System.Diagnostics.Process.Start(fileNames[filenamesview]);
+            }
+        }
+
+        /// <summary>
+        /// 删除文件PDF
+        /// </summary>
+        public void removepdffile()
+        {
+            Reverseorder(ref fileNamesView);
+            foreach (int filenamesview in fileNamesView)
+            {
+                //Trace.WriteLine(filenamesview);
+                fileNames.Remove(fileNames[filenamesview]);
+            }
+            if (fileNames.Count < 1)
+            {
+                SetCompressGridIsEnabled = "False";
+                AddFileVisibility = Visibility.Visible;
+            }
+            updateListview("待确定");
+        }
+
+
+        public void PDFFileCount()
+        {
+            if (fileNames.Count == 0)
+            {
+                SetCompressGridIsEnabled = "False";
+                AddFileVisibility = Visibility.Visible;
+            }
+            else
+            {
+                SetCompressGridIsEnabled = "True";
+                AddFileVisibility = Visibility.Collapsed;
+            }
+        }
+
+        public void OnNavigatedTo(NavigationContext navigationContext)
+        {
+            List<string> filepath = new List<string>();
+            navigationContext.Parameters.TryGetValue<List<string>>(ParameterNames.FilePath, out filepath);
+            if (filepath != null)
+            {
+
+                fileNames = filepath;
+                PDFFileCount();
+                updateListview("待确定");
+            }
+        }
+
+        public bool IsNavigationTarget(NavigationContext navigationContext)
+        {
+            return true;
+        }
 
+        public void OnNavigatedFrom(NavigationContext navigationContext)
+        {
+            if(tempDocument!=null)
+            tempDocument.CompressFile_Cancel(compressingIntpr);
+        }
     }
 }

+ 404 - 10
PDF Office/ViewModels/Dialog/HomePageToolsDialogs/HomePageBatchProcessing/HomePageSetPasswordDialogViewModel.cs

@@ -1,30 +1,131 @@
-using Prism.Commands;
+using ComPDFKit.PDFDocument;
+using PDF_Office.CustomControl;
+using PDF_Office.Model;
+using PDF_Office.Model.Dialog.HomePageToolsDialogs.HomePageBatchProcessing;
+using Prism.Commands;
 using Prism.Mvvm;
 using Prism.Regions;
 using Prism.Services.Dialogs;
-using System;
 using System.Collections.Generic;
 using System.Data;
+using System.IO;
 using System.Linq;
 using System.Windows;
+using System.Windows.Forms;
+using DialogResult = Prism.Services.Dialogs.DialogResult;
 
 namespace PDF_Office.ViewModels.Dialog.HomePageToolsDialogs.HomePageBatchProcessing
 {
     public class HomePageSetPasswordDialogViewModel : BindableBase, INavigationAware
     {
-        public HomePageSetPasswordDialogViewModel()
+        private List<string> fileNames;
+
+        private int fileNamesIndex = 0;
+
+        private HomePageSetPasswordDialogModel setPasswordDialogModel = new HomePageSetPasswordDialogModel();
+
+        public List<int> fileNamesView = new List<int>();
+
+        private bool _canOpen;
+        public bool CanOpen
+        {
+            get { return _canOpen; }
+            set
+            {
+                _canOpen = value;
+                RaisePropertyChanged("isChecked");
+            }
+        }
+
+        private bool _canEdit;
+        public bool CanEdit
+        {
+            get { return _canEdit; }
+            set
+            {
+                _canEdit = value;
+                RaisePropertyChanged("isChecked");
+            }
+        }
+
+        private string _changeMod = "0";
+        ///<value>
+        ///"0"为ChangeMod.None;
+        ///"1"为ChangeMod.ChangePage;
+        ///"2"为ChangeMod.FormAndSignature;
+        ///"3"为ChangeMod.AnnotAndFormAndSignature;
+        ///"4"为ChangeMod.ExceptAbstrat;
+        ///</value>
+        public string ChangeMod
+        {
+            get { return _changeMod; }
+            set
+            {
+                _changeMod = value;
+            }
+        }
+
+        private string _printMod = "0";
+        ///<value>
+        ///"0"为PrintMod.None;
+        ///"1"为PrintMod.LowDpi;
+        ///"2"为PrintMod.HighDpi;
+        ///</value>
+        public string PrintMod
+        {
+            get { return _printMod; }
+            set
+            {
+                _printMod = value;
+            }
+        }
+
+        private string safetyGridIsEnabled = "True";
+        public string SafetyGridIsEnabled
+        {
+            get
+            {
+                return safetyGridIsEnabled;
+            }
+            set
+            {
+                SetProperty(ref safetyGridIsEnabled, value);
+            }
+        }
+
+        private string setSafetyGridIsEnabled = "True";
+        public string SetSafetyGridIsEnabled
         {
+            get
+            {
+                return setSafetyGridIsEnabled;
+            }
+            set
+            {
+                SetProperty(ref setSafetyGridIsEnabled, value);
+            }
+        }
 
+        private string _isEnableConfirm = "False";
+        public string IsEnabledConfirm
+        {
+            get { return _isEnableConfirm; }
+            set
+            {
+                SetProperty(ref _isEnableConfirm, value);
+            }
         }
-        private DataTable imagesDataTable = new DataTable();
-        public DataTable ImagesDataTable
+
+        private DataTable pdfDataTable = new DataTable();
+        public DataTable PDFDataTable
         {
-            get { return imagesDataTable; }
+            get { return pdfDataTable; }
             set
             {
-                SetProperty(ref imagesDataTable, value);
+                SetProperty(ref pdfDataTable, value);
             }
         }
+
         private string removeIsEnable = "False";
         public string RemoveIsEnable
         {
@@ -57,17 +158,310 @@ namespace PDF_Office.ViewModels.Dialog.HomePageToolsDialogs.HomePageBatchProcess
             }
         }
 
+        public DelegateCommand DelegateSetOpenCommand { get; set; }
 
-        public bool IsNavigationTarget(NavigationContext navigationContext)
+        public DelegateCommand DelegateSetEditCommand { get; set; }
+
+        public DelegateCommand DelegateCanOpenTextChangedCommand { get; set; }
+
+        public DelegateCommand DelegateCanEditTextChangedCommand { get; set; }
+
+        public DelegateCommand DelegateConfirmEncryptCommand { get; set; }
+
+        public DelegateCommand DelegateCancelEncryptCommand { get; set; }
+
+        public DelegateCommand ADDPDFCommand { get; set; }
+
+        public DelegateCommand RemovePDFFileCommand { get; set; }
+
+        public DelegateCommand ADDPDFFilesCommand { get; set; }
+
+        public HomePageSetPasswordDialogViewModel()
         {
-            return true;
+            PDFDataTable.Columns.Add("FileName");
+            PDFDataTable.Columns.Add("FileSize");
+            PDFDataTable.Columns.Add("FileState");
+            HomePageSetPasswordDialogModel.PasswordForOpen = "";
+            HomePageSetPasswordDialogModel.PasswordForEdit = "";
+            DelegateConfirmEncryptCommand = new DelegateCommand(ConfirmEncrypt);
+            DelegateSetOpenCommand = new DelegateCommand(SetCanOpen);
+            DelegateSetEditCommand = new DelegateCommand(SetCanEdit);
+            DelegateCanOpenTextChangedCommand = new DelegateCommand(CanOpenTextChanged);
+            DelegateCanEditTextChangedCommand = new DelegateCommand(CanEditTextChanged);
+            ADDPDFCommand = new DelegateCommand(addpdf);
+            ADDPDFFilesCommand = new DelegateCommand(addpdffiles);
+            RemovePDFFileCommand = new DelegateCommand(removepdffile);
         }
 
-        public void OnNavigatedFrom(NavigationContext navigationContext)
+        #region 检查和初始化
+        private void CheckCanConfirmEncrypt()
+        {
+            if (setPasswordDialogModel.CanOpen)
+            {
+                if (HomePageSetPasswordDialogModel.PasswordForOpen.Length > 0)
+                {
+                    IsEnabledConfirm = "True";
+                    return;
+                }
+            }
+            if (setPasswordDialogModel.CanEdit)
+            {
+                if (HomePageSetPasswordDialogModel.PasswordForEdit.Length > 0)
+                {
+                    IsEnabledConfirm = "True";
+                    return;
+                }
+            }
+            IsEnabledConfirm = "False";
+        }
+
+        private void InitPermissionsDictionary(ref Dictionary<string, HomePageSetPasswordDialogModel.PrintMod> GetPrintMod, ref Dictionary<string, HomePageSetPasswordDialogModel.ChangeMod> GetChangeMod)
         {
+            GetPrintMod.Add("0", HomePageSetPasswordDialogModel.PrintMod.None);
+            GetPrintMod.Add("1", HomePageSetPasswordDialogModel.PrintMod.LowDpi);
+            GetPrintMod.Add("2", HomePageSetPasswordDialogModel.PrintMod.HighDpi);
+
+            GetChangeMod.Add("0", HomePageSetPasswordDialogModel.ChangeMod.None);
+            GetChangeMod.Add("1", HomePageSetPasswordDialogModel.ChangeMod.ChangePage);
+            GetChangeMod.Add("2", HomePageSetPasswordDialogModel.ChangeMod.FormAndSignature);
+            GetChangeMod.Add("3", HomePageSetPasswordDialogModel.ChangeMod.AnnotAndFormAndSignature);
+            GetChangeMod.Add("4", HomePageSetPasswordDialogModel.ChangeMod.ExceptAbstrat);
+        }
+        #endregion
+        /// <summary>
+        /// 添加PDF文件
+        /// </summary>
+        private void addpdf()
+        {
+            System.Windows.Forms.OpenFileDialog dlg = new System.Windows.Forms.OpenFileDialog();
+            dlg.Multiselect = true;
+            dlg.Filter = "PDF|*.pdf;*.PDF;";
+            if (dlg.ShowDialog() == System.Windows.Forms.DialogResult.OK)
+            {
+                fileNames.AddRange(dlg.FileNames.ToList());
+                RemoveExcess(ref fileNames);
+                SetSafetyGridIsEnabled = "True";
+                AddFileVisibility = Visibility.Collapsed;
+                updateListview("待确定");
+            }
+        }
+
+        /// <summary>
+        /// 删除重复的文件
+        /// </summary>
+        public void RemoveExcess(ref List<string> Filenames)
+        {
+            List<string> filenames = new List<string>();
+            foreach (var fileName in Filenames)
+            {
+                if (!filenames.Contains(fileName))
+                {
+                    filenames.Add(fileName);
+                }
+            }
+            Filenames.Clear();
+            Filenames = filenames;
+        }
+
+        /// <summary>
+        /// 添加PDF文件夹
+        /// </summary>
+        private void addpdffiles()
+        {
+            FolderBrowserDialog dialog = new FolderBrowserDialog();
+            dialog.Description = "请选择文件路径";
+            if (dialog.ShowDialog() == System.Windows.Forms.DialogResult.OK)
+            {
+
+                string foldPath = dialog.SelectedPath;
+                var apps = System.IO.Directory.GetFiles(foldPath);
+                foreach (string app in apps)
+                {
+                    var fi = new FileInfo(app);
+                    if (fi.Extension == ".pdf" || fi.Extension == ".PDF")
+                    {
+                        fileNames.Add(app);
+                    }
+                }
+                RemoveExcess(ref fileNames);
+                updateListview("待确定");
+                SetSafetyGridIsEnabled = "True";
+                AddFileVisibility = Visibility.Collapsed;
+            }
+        }
+
+        /// <summary>
+        /// 更新listview显示
+        /// state 状态显示字符串
+        /// </summary>
+        public void updateListview(string state)
+        {
+            DataTable pdfdatatable = new DataTable();
+            pdfdatatable.Columns.Add("FileName");
+            pdfdatatable.Columns.Add("FileSize");
+            pdfdatatable.Columns.Add("FileState");
+            foreach (var fileName in fileNames)
+            {
+                string file_all = fileName;
+                FileInfo f = new FileInfo(file_all);
+                string file_size = (((float)f.Length) / 1024).ToString() + " K";
+                pdfdatatable.Rows.Add(f.Name, file_size, state);
+            }
+            PDFDataTable = pdfdatatable;
+            HomePageBatchProcessingDialogModel.FilePaths = fileNames;
+
+        }
+
+        public void SetCanOpen()
+        {
+            setPasswordDialogModel.CanOpen = CanOpen;
+            CheckCanConfirmEncrypt();
+        }
+
+        public void SetCanEdit()
+        {
+            setPasswordDialogModel.CanEdit = CanEdit;
+            CheckCanConfirmEncrypt();
+        }
+
+        public void CanOpenTextChanged()
+        {
+            CheckCanConfirmEncrypt();
+        }
+
+        public void CanEditTextChanged()
+        {
+            CheckCanConfirmEncrypt();
+        }
+
+        public void ConfirmEncrypt()
+        {
+            SafetyGridIsEnabled = "False";
+            string openPassword = "";
+            string editPassword = "";
+            CPDFPermissionsInfo permissionsInfo = new CPDFPermissionsInfo();
+            if (setPasswordDialogModel.CanOpen)
+            {
+                if (!string.IsNullOrEmpty(HomePageSetPasswordDialogModel.PasswordForOpen))
+                {
+                    openPassword = HomePageSetPasswordDialogModel.PasswordForOpen;
+                }
+            }
+            if (setPasswordDialogModel.CanEdit)
+            {
+                if (!string.IsNullOrEmpty(HomePageSetPasswordDialogModel.PasswordForEdit))
+                {
+                    editPassword = HomePageSetPasswordDialogModel.PasswordForEdit;
+                    Dictionary<string, HomePageSetPasswordDialogModel.PrintMod> GetPrintMod = new Dictionary<string, HomePageSetPasswordDialogModel.PrintMod>();
+                    Dictionary<string, HomePageSetPasswordDialogModel.ChangeMod> GetChangeMod = new Dictionary<string, HomePageSetPasswordDialogModel.ChangeMod>(); ;
+                    InitPermissionsDictionary(ref GetPrintMod, ref GetChangeMod);
+                    permissionsInfo = setPasswordDialogModel.CreatePermissionsInfo(GetPrintMod[PrintMod], GetChangeMod[ChangeMod]);
+                }
+            }
+            fileNamesIndex = 0;
+            foreach (var filename in fileNames)
+            {
+                PDFDataTable.Rows[fileNamesIndex]["FileState"] = "待完成";
+                CPDFDocument document = CPDFDocument.InitWithFilePath(filename);
+                if (document == null)
+                {
+                    PDFDataTable.Rows[fileNamesIndex]["FileState"] = "文件出错";
+                    continue;
+                }
+                FileInfo fileinfo = new FileInfo(filename);
+                string file_size = (((float)fileinfo.Length) / 1024).ToString() + " K";
+                if (document == null)
+                {
+                    return;
+                }
+                document.Encrypt(openPassword, editPassword, permissionsInfo);
+                document.WriteToFilePath(filename + "SetPassword");
+
+                PDFDataTable.Rows[fileNamesIndex]["FileState"] = "完成";
+                fileNamesIndex++;
+                document.Release();
+            }
+            SafetyGridIsEnabled = "True";
+            MessageBoxEx.Show("已完成");
+            SetSafetyGridIsEnabled = "False";
+            AddFileVisibility = Visibility.Visible;
+            fileNames.Clear();
+            HomePageBatchProcessingDialogModel.FilePaths.Clear();
+        }
+
+        /// <summary>
+        /// 逆序int类型集合
+        /// </summary>
+        public void Reverseorder(ref List<int> Numbers)
+        {
+            Numbers = Numbers.OrderBy(a => a).ToList();
+            Numbers.Reverse();
+        }
+
+        /// <summary>
+        /// 打开文件PDF
+        /// </summary>
+        public void openfiledialog()
+        {
+
+            foreach (int filenamesview in fileNamesView)
+            {
+                System.Diagnostics.Process.Start(fileNames[filenamesview]);
+            }
+        }
+
+        /// <summary>
+        /// 删除文件PDF
+        /// </summary>
+        public void removepdffile()
+        {
+            Reverseorder(ref fileNamesView);
+            foreach (int filenamesview in fileNamesView)
+            {
+                //Trace.WriteLine(filenamesview);
+                fileNames.Remove(fileNames[filenamesview]);
+            }
+            if (fileNames.Count < 1)
+            {
+                SetSafetyGridIsEnabled = "False";
+                AddFileVisibility = Visibility.Visible;
+            }
+            updateListview("待确定");
+        }
+
+        public void PDFFileCount()
+        {
+            if (fileNames.Count == 0)
+            {
+                SetSafetyGridIsEnabled = "False";
+                AddFileVisibility = Visibility.Visible;
+            }
+            else
+            {
+                SetSafetyGridIsEnabled = "True";
+                AddFileVisibility = Visibility.Collapsed;
+            }
         }
 
         public void OnNavigatedTo(NavigationContext navigationContext)
+        {
+            List<string> filepath = new List<string>();
+            navigationContext.Parameters.TryGetValue<List<string>>(ParameterNames.FilePath, out filepath);
+            if (filepath != null)
+            {
+
+                fileNames = filepath;
+                PDFFileCount();
+                updateListview("待确定");
+            }
+        }
+
+        public bool IsNavigationTarget(NavigationContext navigationContext)
+        {
+            return true;
+        }
+
+        public void OnNavigatedFrom(NavigationContext navigationContext)
         {
         }
     }

+ 71 - 22
PDF Office/ViewModels/Dialog/HomePageToolsDialogs/HomePagePictureToPDFDialogViewModel.cs

@@ -23,9 +23,39 @@ namespace PDF_Office.ViewModels.Dialog.HomePageToolsDialogs
     {
         #region 参数和属性
         private List<string> fileNames;
-        
+
+        private int fileNamesIndex = 0;
+
         public List<int> fileNamesView = new List<int>();
+
         public HomePagePictureToPDFDialogModel pictureToPDFModel=new HomePagePictureToPDFDialogModel();
+
+        private string pictureToPDFGridIsEnabled = "True";
+        public string PictureToPDFGridIsEnabled
+        {
+            get
+            {
+                return pictureToPDFGridIsEnabled;
+            }
+            set
+            {
+                SetProperty(ref pictureToPDFGridIsEnabled, value);
+            }
+        }
+
+        private string setPictureToPDFGridIsEnabled = "True";
+        public string SetPictureToPDFGridIsEnabled
+        {
+            get
+            {
+                return setPictureToPDFGridIsEnabled;
+            }
+            set
+            {
+                SetProperty(ref setPictureToPDFGridIsEnabled, value);
+            }
+        }
+
         private DataTable imagesDataTable = new DataTable();
         public DataTable ImagesDataTable
         {
@@ -92,16 +122,19 @@ namespace PDF_Office.ViewModels.Dialog.HomePageToolsDialogs
         }
         #region 逻辑函数
         private void topdf() {
-            updateListview("正在转换");
-            DataTable imagesdatayable = new DataTable();
-            imagesdatayable.Columns.Add("FileName");
-            imagesdatayable.Columns.Add("FileSize");
-            imagesdatayable.Columns.Add("FileState");
+            PictureToPDFGridIsEnabled = "False";
             if (pictureToPDFModel.Mode == HomePagePictureToPDFDialogModel.ToPDFFileMode.NewFiles)
             {
+                fileNamesIndex = 0;
                 foreach (var filename in fileNames)
                 {
+                    ImagesDataTable.Rows[fileNamesIndex]["FileState"] = "准备转换";
                     Image img = Image.FromFile(filename);
+                    if (img == null)
+                    {
+                        ImagesDataTable.Rows[fileNamesIndex]["FileState"] = "文件出错";
+                        continue;
+                    }
                     CPDFDocument topdfdoc = CPDFDocument.CreateDocument();
                     FileInfo fileinfo = new FileInfo(filename);
                     JpegInsertPage(ref topdfdoc, filename, fileinfo,img.Width,img.Height);
@@ -109,8 +142,8 @@ namespace PDF_Office.ViewModels.Dialog.HomePageToolsDialogs
                     topdfdoc.WriteToFilePath(savefilename(filename));
                     topdfdoc.Release();
                     string file_size = (((float)fileinfo.Length) / 1024).ToString() + " K";
-                    imagesdatayable.Rows.Add(fileinfo.Name, file_size, "确认");
-                    ImagesDataTable = imagesdatayable;
+                    ImagesDataTable.Rows[fileNamesIndex]["FileState"] = "完成";
+                    fileNamesIndex++;
                 }
                 System.Diagnostics.Process.Start("Explorer", "/select," + savefilename(fileNames[0]));
             }
@@ -119,13 +152,19 @@ namespace PDF_Office.ViewModels.Dialog.HomePageToolsDialogs
                 CPDFDocument topdfdoc = CPDFDocument.CreateDocument();
                 int pageindex = 0;
                 foreach (var filename in fileNames) {
+                    ImagesDataTable.Rows[fileNamesIndex]["FileState"] = "准备转换";
                     Image img = Image.FromFile(filename);
+                    if (img == null)
+                    {
+                        ImagesDataTable.Rows[fileNamesIndex]["FileState"] = "文件出错";
+                        continue;
+                    }
                     FileInfo fileinfo = new FileInfo(filename);
                     JpegInsertPage(ref topdfdoc, filename, fileinfo,img.Width, img.Height);
                     pageindex++;
                     string file_size = (((float)fileinfo.Length) / 1024).ToString() + " K";
-                    imagesdatayable.Rows.Add(fileinfo.Name, file_size, "确认");
-                    ImagesDataTable = imagesdatayable;
+                    ImagesDataTable.Rows[fileNamesIndex]["FileState"] = "完成";
+                    fileNamesIndex++;
                 }
                 System.Diagnostics.Process.Start("Explorer", "/select," + savefilename(fileNames[0]));
                 topdfdoc.WriteToFilePath(savefilename(fileNames[0]));
@@ -151,13 +190,19 @@ namespace PDF_Office.ViewModels.Dialog.HomePageToolsDialogs
                 int pageindex = topdfdoc.PageCount;
                 foreach (var filename in fileNames)
                 {
+                    ImagesDataTable.Rows[fileNamesIndex]["FileState"] = "准备转换";
                     Image img = Image.FromFile(filename);
+                    if (img == null)
+                    {
+                        ImagesDataTable.Rows[fileNamesIndex]["FileState"] = "文件出错";
+                        continue;
+                    }
                     FileInfo fileinfo = new FileInfo(filename);
                     JpegInsertPage(ref topdfdoc, filename, fileinfo, img.Width, img.Height, pageindex);
                     pageindex++;
                     string file_size = (((float)fileinfo.Length) / 1024).ToString() + " K";
-                    imagesdatayable.Rows.Add(fileinfo.Name, file_size, "确认");
-                    ImagesDataTable = imagesdatayable;
+                    ImagesDataTable.Rows[fileNamesIndex]["FileState"] = "完成";
+                    fileNamesIndex++;
                 }
                 topdfdoc.WriteToLoadedPath();
                 System.Diagnostics.Process.Start("Explorer", "/select," + topdfdoc.FilePath);
@@ -202,6 +247,7 @@ namespace PDF_Office.ViewModels.Dialog.HomePageToolsDialogs
             {
                 fileNames.AddRange(dlg.FileNames.ToList());
                 RemoveExcess(ref fileNames);
+                SetPictureToPDFGridIsEnabled = "True";
                 AddFileVisibility = Visibility.Collapsed;
                 updateListview("待确定");
             }
@@ -229,6 +275,7 @@ namespace PDF_Office.ViewModels.Dialog.HomePageToolsDialogs
                 }
                 RemoveExcess(ref fileNames);
                 updateListview("待确定");
+                SetPictureToPDFGridIsEnabled = "True";
                 AddFileVisibility = Visibility.Collapsed;
             }
         }
@@ -245,15 +292,17 @@ namespace PDF_Office.ViewModels.Dialog.HomePageToolsDialogs
             }
             if (fileNames.Count < 1)
             {
+                SetPictureToPDFGridIsEnabled = "False";
                 AddFileVisibility = Visibility.Visible;
             }
             updateListview("待确定");
         }
 
-        /// <summary>
-        /// 打开文件图片
-        /// </summary>
-        public void openfiledialog(){
+
+            /// <summary>
+            /// 打开文件图片
+            /// </summary>
+            public void openfiledialog(){
 
             foreach (int filenamesview in fileNamesView)
             {
@@ -291,18 +340,18 @@ namespace PDF_Office.ViewModels.Dialog.HomePageToolsDialogs
         /// state 状态显示字符串
         /// </summary>
         public void updateListview( string state) {
-            DataTable imagesdatayable = new DataTable();
-            imagesdatayable.Columns.Add("FileName");
-            imagesdatayable.Columns.Add("FileSize");
-            imagesdatayable.Columns.Add("FileState");
+            DataTable imagesdatatable = new DataTable();
+            imagesdatatable.Columns.Add("FileName");
+            imagesdatatable.Columns.Add("FileSize");
+            imagesdatatable.Columns.Add("FileState");
             foreach (var fileName in fileNames)
             {
                 string file_all = fileName;
                 FileInfo f = new FileInfo(file_all);
                 string file_size = (((float)f.Length)/1024).ToString()+" K";
-                imagesdatayable.Rows.Add(f.Name, file_size, state);
+                imagesdatatable.Rows.Add(f.Name, file_size, state);
             }
-            ImagesDataTable = imagesdatayable;
+            ImagesDataTable = imagesdatatable;
 
         }
 

+ 23 - 4
PDF Office/ViewModels/HomeContentViewModel.cs

@@ -44,15 +44,16 @@ namespace PDF_Office.ViewModels
             }
         }
 
-
-
-
         private MainContentViewModel mainContentViewModel;
 
         public DelegateCommand OpenFileCommand { get; set; }
 
         public DelegateCommand<string> ShowToolCommand { get; set; }
 
+        public DelegateCommand CreateBlackPDFCommand { get; set; }
+
+        public DelegateCommand CreateFromOtherFile { get; set; }
+
         public IRegionManager toolregion;
 
         public IEventAggregator eventer;
@@ -65,6 +66,8 @@ namespace PDF_Office.ViewModels
             ToolRegionName = Guid.NewGuid().ToString();
             OpenFileCommand = new DelegateCommand(OpenFile);
             ShowToolCommand = new DelegateCommand<string>(ShowToolContent);
+            CreateBlackPDFCommand = new DelegateCommand(CreatBlankPDF);
+            CreateFromOtherFile = new DelegateCommand(createFromOtherFile);
 
             System.Windows.Application.Current.Dispatcher.BeginInvoke(System.Windows.Threading.DispatcherPriority.Send, new Action(() =>
             {
@@ -81,6 +84,14 @@ namespace PDF_Office.ViewModels
             toolregion.RequestNavigate(ToolRegionName, view);
         }
 
+        /// <summary>
+        /// 从其他格式文件创建PDF
+        /// </summary>
+        private void createFromOtherFile()
+        {
+
+        }
+
         /// <summary>
         /// 打开文件
         /// </summary>
@@ -125,11 +136,19 @@ namespace PDF_Office.ViewModels
             }
         }
 
-        public void CreatBlankPDF()
+        /// <summary>
+        /// 打开其他格式文件
+        /// </summary>
+        public void OpenFromOtherFile()
         {
 
         }
 
+        public void CreatBlankPDF()
+        {
+            mainContentViewModel.CreateFile();
+        }
+
         #region Navigate
         public void OnNavigatedTo(NavigationContext navigationContext)
         {

+ 0 - 16
PDF Office/ViewModels/HomePageSetPasswordDialogViewModel.cs

@@ -1,16 +0,0 @@
-using Prism.Commands;
-using Prism.Mvvm;
-using System;
-using System.Collections.Generic;
-using System.Linq;
-
-namespace PDF_Office.ViewModels
-{
-    public class HomePageSetPasswordDialogViewModel : BindableBase
-    {
-        public HomePageSetPasswordDialogViewModel()
-        {
-
-        }
-    }
-}

+ 52 - 0
PDF Office/ViewModels/HomePanel/CloudDrive/CloudDriveContentViewModel.cs

@@ -0,0 +1,52 @@
+using PDF_Office.Model.CloudDrive;
+using Prism.Commands;
+using Prism.Mvvm;
+using System;
+using System.Collections.Generic;
+using System.Linq;
+using System.Text;
+using System.Threading.Tasks;
+
+namespace PDF_Office.ViewModels.HomePanel.CloudDrive
+{
+    public class CloudDriveContentViewModel : BindableBase
+    {
+
+
+        public DelegateCommand<CloudBoxItem> CheckDriveCommand { get; set; }
+        public DelegateCommand<CloudBoxItem> CheckDriveLoginUserCommand { get; set; }
+
+        private CloudDriveManager Manager =>CloudDriveManager.GetInstance();
+        public event EventHandler<bool> IshowContentHandler;
+      
+        public CloudDriveContentViewModel()
+        {
+            CheckDriveCommand = new DelegateCommand<CloudBoxItem>(CheckDrive);
+            CheckDriveLoginUserCommand = new DelegateCommand<CloudBoxItem>(CheckDriveLoginUser);
+          
+        }
+
+        public void LoadUsers()
+        {
+            var result = Manager.LoadedUsers();
+
+            IshowContentHandler?.Invoke(null, !result);
+        }
+
+        public async void CheckDrive(CloudBoxItem cloudDriveItem)
+        {
+            bool result = false;
+            result = await Manager.LoginUser(cloudDriveItem.CloudDiskType);
+            IshowContentHandler?.Invoke(null, !result);
+        }
+
+        public async void CheckDriveLoginUser(CloudBoxItem cloudDriveItem)
+        {
+            bool result = false;
+            result = await Manager.LoginUser(cloudDriveItem.CloudDiskType);
+        }
+
+
+
+    }
+}

+ 107 - 0
PDF Office/ViewModels/HomePanel/CloudDrive/CloudDriveManager.cs

@@ -0,0 +1,107 @@
+using PDF_Office.Model.CloudDrive;
+using PDF_Office.ViewModels.HomePanel.CloudDrive.CloudDriveType;
+using System;
+using System.Collections.Generic;
+using System.Collections.ObjectModel;
+using System.Linq;
+using System.Text;
+using System.Threading.Tasks;
+
+namespace PDF_Office.ViewModels.HomePanel.CloudDrive
+{
+   
+    //各云盘的管理类
+    //单实例化
+    public class CloudDriveManager
+    {
+      
+        public GoogleDriveManager GoogleDrive => GoogleDriveManager.GoogleDrive;
+        public DropbBoxManager DropbBox => DropbBoxManager.DropbBox;
+        public CloudType cloudType;
+
+        private static CloudDriveManager instance;
+
+        public static CloudDriveManager GetInstance()
+        {
+            if (instance == null)
+                instance = new CloudDriveManager();
+
+            return instance;
+        }
+        private CloudDriveManager()
+        {
+        }
+
+
+        #region 用户帐号
+
+        /// <summary>
+        /// 登录
+        /// </summary>
+        public async Task<bool> LoginUser(CloudType cloudType)
+        {
+            switch(cloudType)
+            {
+                case CloudType.GoogleDrive:
+                   return await GoogleDrive.LoginUserCount();
+                case CloudType.DropBox:
+                    return await DropbBox.LoginUser();
+            }
+            return false;
+        }
+
+        public bool LoadedUsers()
+        {
+            bool isUsers = false;
+            if (Cloud.CloudLists.Count > 0)
+                isUsers = true;
+
+            return isUsers;
+
+        }
+        /// <summary>
+        /// 移除用户
+        /// </summary>
+        public async Task<bool> RemoveUser()
+        {
+            GoogleDriveUserItem userIttem = null;
+            switch (cloudType)
+            {
+                case CloudType.OneDrive:
+                    return await GoogleDrive.RemoveUser(userIttem);
+            }
+            return false;
+        }
+
+        /// <summary>
+        /// 切换用户
+        /// </summary>
+        public void SwitchUser()
+        {
+
+        }
+
+
+        #endregion
+
+
+        #region 文件
+
+        public void GetFiles()
+        {
+
+        }
+
+        public void GetFolders()
+        {
+
+        }
+
+        public void UpLoad()
+        {
+
+        }
+        #endregion
+
+    }
+}

+ 92 - 0
PDF Office/ViewModels/HomePanel/CloudDrive/CloudDriveType/DropbBoxManager.cs

@@ -0,0 +1,92 @@
+using Dropbox.Api;
+using PDF_Office.Model.CloudDrive;
+using System;
+using System.Collections.Generic;
+using System.Linq;
+using System.Text;
+using System.Threading.Tasks;
+
+namespace PDF_Office.ViewModels.HomePanel.CloudDrive.CloudDriveType
+{
+
+
+    public class DropbBoxManager
+    {
+        private static DropbBoxManager instance;
+        public static DropbBoxManager DropbBox => instance ?? (instance = new DropbBoxManager());
+
+        public DropbBoxManager()
+        {
+        }
+
+
+
+        #region 用户帐号
+
+        /// <summary>
+        /// 登录
+        /// </summary>
+        public async Task<bool> LoginUser()
+        {
+            bool result = false;
+            DropbBoxUserItem dropbBoxUserItem = new DropbBoxUserItem();
+            result = await dropbBoxUserItem.LoginUser();
+            if(result)
+            {
+                dropbBoxUserItem.cloudType = CloudType.DropBox;
+                   UserInfo user = new UserInfo();
+                user.Name = "DropBox测试" + (Cloud.CloudLists.Count + 1).ToString();
+                dropbBoxUserItem.userInfo = user;
+
+                Cloud.CloudLists.Add(dropbBoxUserItem);
+
+            }
+            return result;
+        }
+
+        /// <summary>
+        /// 移除用户
+        /// </summary>
+        public void RemoveUser()
+        {
+
+        }
+
+        /// <summary>
+        /// 切换用户
+        /// </summary>
+        public void SwitchUser()
+        {
+
+        }
+
+
+        #endregion
+
+
+        #region 文件
+
+        public void GetFiles()
+        {
+
+        }
+
+        public void GetFolders()
+        {
+
+        }
+
+        public void UpLoad()
+        {
+
+        }
+        #endregion
+
+
+
+
+
+
+
+    }
+}

+ 274 - 0
PDF Office/ViewModels/HomePanel/CloudDrive/CloudDriveType/DropbBoxUserItem.cs

@@ -0,0 +1,274 @@
+using Dropbox.Api;
+using Dropbox.Api.Files;
+using PDF_Office.Model.CloudDrive;
+using System;
+using System.Collections.Generic;
+using System.IO;
+using System.Linq;
+using System.Net;
+using System.Text;
+using System.Threading.Tasks;
+using System.Windows;
+
+namespace PDF_Office.ViewModels.HomePanel.CloudDrive.CloudDriveType
+{
+    /// <summary>
+    /// 单用户
+    /// </summary>
+    public class DropbBoxUserItem : UserBaseItem
+    {
+        DropboxClient client;
+        private List<DropbBoxFiles> FilesList = new List<DropbBoxFiles>();//文件
+        private List<Metadata> MetadataList = new List<Metadata>();//文件
+        public async Task<bool> LoginUser()
+        {
+            client = await DropbBoxStatic.Connect();
+            if (client == null)
+                return false;
+            else
+                return true;
+        }
+
+        public async Task<List<DropbBoxFiles>> RefreshList(string path = "")
+        {
+            var files = await client.Files.ListFolderAsync(path);
+            DropbBoxFiles dropbBoxFiles = new DropbBoxFiles();
+            List<DropbBoxFiles> FileList = new List<DropbBoxFiles>();
+            foreach (var file in files.Entries)
+            {
+                dropbBoxFiles.Name = file.Name;
+                FileList.Add(dropbBoxFiles);
+            }
+            MetadataList = (List<Metadata>)files.Entries;
+            this.FilesList = FileList;
+            return FileList;
+        }
+
+
+
+        public async Task<string> Download(string name, string savePath)
+        {
+            Metadata metadata = null;
+            foreach(var item in MetadataList)
+            {
+                if (item.IsFolder)
+                    continue;
+
+                if (item.Name == name)
+                {
+                    metadata = item;
+                    break;
+                }
+            }
+
+            if (metadata != null)
+            {
+                savePath = savePath + "\\" + metadata.Name;
+                using (var response = await client.Files.DownloadAsync(metadata.PathDisplay))
+                {
+                    var result = await response.GetContentAsStreamAsync();
+                    var stream = StreamToMemoryStream(result);
+                    using (var fileStream = System.IO.File.Create(savePath))
+                    {
+                        stream.Seek(0, System.IO.SeekOrigin.Begin);
+                        stream.CopyTo(fileStream);
+                    }
+                }
+               // System.Diagnostics.Process.Start(@"explorer.exe", "/select,\"" + savePath + "\"");
+                RefreshList(savePath);
+
+                return savePath;
+            }
+            
+            return "";
+
+        }
+
+        public MemoryStream StreamToMemoryStream(Stream stream)
+        {
+            MemoryStream memoryStream = new MemoryStream();
+
+            //将基础流写入内存流
+            const int bufferLength = 1024;
+            byte[] buffer = new byte[bufferLength];
+            int actual = stream.Read(buffer, 0, bufferLength);
+            while (actual > 0)
+            {
+                // 读、写过程中,流的位置会自动走。
+                memoryStream.Write(buffer, 0, actual);
+                actual = stream.Read(buffer, 0, bufferLength);
+            }
+            memoryStream.Position = 0;
+
+            return memoryStream;
+        }
+
+        private void Upload()
+        {
+            //if (ItemList.SelectedItem != null)
+            //{
+            //    var item = ItemList.SelectedItem as Metadata;
+            //    if (item.IsFolder)
+            //        return;
+
+            //OpenFileDialog openFileDialog = new OpenFileDialog();
+            //if ((bool)openFileDialog.ShowDialog())
+            //{
+            //    string folder = currentFolder; /*= item.PathDisplay.Replace("/" + item.Name, "");*/
+            //    using (var stream = System.IO.File.OpenRead(openFileDialog.FileName))
+            //    {
+            //        await client.Files.UploadAsync(folder + "/" + openFileDialog.SafeFileName, WriteMode.Overwrite.Instance, body: stream);
+            //    }
+            //    MessageBox.Show("上传完成");
+            //    RefreshList(folder);
+            //}
+            //}
+        }
+
+        private void Loaded()
+        {
+            //var text = sender as TextBlock;
+            //if (text == null)
+            //    return;
+            //if (text.DataContext is Metadata)
+            //{
+            //    var data = (text.DataContext as Metadata);
+            //    if (data.IsFile)
+            //    {
+            //        text.Text = "File";
+            //    }
+            //    if (data.IsFolder)
+            //    {
+            //        text.Text = "Folder";
+            //    }
+            //}
+        }
+
+
+    }
+
+
+    #region 身份验证
+
+    public static class DropbBoxStatic
+    {
+        // This loopback host is for demo purpose. If this port is not
+        // available on your machine you need to update this URL with an unused port.
+        public static readonly string LoopbackHost = "http://127.0.0.1:8080/";
+        // Add an ApiKey (from https://www.dropbox.com/developers/apps) here
+        public static readonly string ApiKey = "k1hv3601odbsmln";
+        // URL to receive OAuth 2 redirect from Dropbox server.
+        // You also need to register this redirect URL on https://www.dropbox.com/developers/apps.
+        public static readonly Uri RedirectUri = new Uri(LoopbackHost + "authorize");
+
+        // URL to receive access token from JS.
+        public static readonly Uri JSRedirectUri = new Uri(LoopbackHost + "token");
+
+        private static HttpListener http = new HttpListener();
+        public static async Task<DropboxClient> Connect()
+        {
+            DropboxCertHelper.InitializeCertPinning();
+            var state = Guid.NewGuid().ToString("N");
+            var OAuthflow = new PKCEOAuthFlow();
+            var authorizeUri = OAuthflow.GetAuthorizeUri(OAuthResponseType.Code, ApiKey, RedirectUri.ToString(), state: state, tokenAccessType: TokenAccessType.Offline, scopeList: null, includeGrantedScopes: IncludeGrantedScopes.None);
+            //var http = new HttpListener();
+            http.Prefixes.Clear();
+            http.Prefixes.Add(LoopbackHost);
+            http.Start();
+            System.Diagnostics.Process.Start(authorizeUri.ToString());
+
+            await HandleOAuth2Redirect(http);
+
+            // Handle redirect from JS and process OAuth response.
+            var redirectUri = await HandleJSRedirect(http);
+
+            var tokenResult = await OAuthflow.ProcessCodeFlowAsync(redirectUri, ApiKey, RedirectUri.ToString(), state);
+
+            //  Window.GetWindow(this).Activate();
+            DropboxClientConfig dropboxClientConfig = new DropboxClientConfig("ControlTest");
+
+            DropboxClient client;
+            client = new DropboxClient(tokenResult.AccessToken, dropboxClientConfig);
+            return client;
+        }
+
+        /// <summary>
+        /// Handle the redirect from JS and process raw redirect URI with fragment to
+        /// complete the authorization flow.
+        /// </summary>
+        /// <param name="http">The http listener.</param>
+        /// <returns>The <see cref="OAuth2Response"/></returns>
+        private static async Task<Uri> HandleJSRedirect(HttpListener http)
+        {
+            var context = await http.GetContextAsync();
+
+            // We only care about request to TokenRedirectUri endpoint.
+            while (context.Request.Url.AbsolutePath != JSRedirectUri.AbsolutePath)
+            {
+                context = await http.GetContextAsync();
+            }
+
+            var redirectUri = new Uri(context.Request.QueryString["url_with_fragment"]);
+
+            return redirectUri;
+        }
+
+
+        public static void ListenerCallback(IAsyncResult result)
+        {
+            HttpListener listener = (HttpListener)result.AsyncState;
+            // Call EndGetContext to complete the asynchronous operation.
+            HttpListenerContext context = listener.EndGetContext(result);
+            HttpListenerRequest request = context.Request;
+            // Obtain a response object.
+            HttpListenerResponse response = context.Response;
+            // Construct a response.
+            string responseString = "<HTML><BODY> Hello world!</BODY></HTML>";
+            byte[] buffer = System.Text.Encoding.UTF8.GetBytes(responseString);
+            // Get a response stream and write the response to it.
+            response.ContentLength64 = buffer.Length;
+            System.IO.Stream output = response.OutputStream;
+            output.Write(buffer, 0, buffer.Length);
+            // You must close the output stream.
+            output.Close();
+        }
+
+
+        /// <summary>
+        /// Handles the redirect from Dropbox server. Because we are using token flow, the local
+        /// http server cannot directly receive the URL fragment. We need to return a HTML page with
+        /// inline JS which can send URL fragment to local server as URL parameter.
+        /// </summary>
+        /// <param name="http">The http listener.</param>
+        /// <returns>The <see cref="Task"/></returns>
+        private static async Task HandleOAuth2Redirect(HttpListener http)
+        {
+            var context = await http.GetContextAsync();
+
+            // We only care about request to RedirectUri endpoint.
+            while (context.Request.Url.AbsolutePath != RedirectUri.AbsolutePath)
+            {
+                context = await http.GetContextAsync();
+            }
+
+            context.Response.ContentType = "text/html";
+
+            // Respond with a page which runs JS and sends URL fragment as query string
+            // to TokenRedirectUri.
+            using (var file = System.IO.File.OpenRead("index.html"))
+            {
+                file.CopyTo(context.Response.OutputStream);
+            }
+
+            context.Response.OutputStream.Close();
+        }
+
+
+    }
+
+
+    #endregion
+
+
+
+}

+ 102 - 0
PDF Office/ViewModels/HomePanel/CloudDrive/CloudDriveType/GoogleDriveManager.cs

@@ -0,0 +1,102 @@
+using Google.Apis.Auth.OAuth2;
+using Google.Apis.Drive.v3;
+using Google.Apis.Services;
+using Google.Apis.Util.Store;
+using PDF_Office.Model.CloudDrive;
+using System;
+using System.Collections.Generic;
+using System.Collections.ObjectModel;
+using System.IO;
+using System.Linq;
+using System.Text;
+using System.Threading;
+using System.Threading.Tasks;
+
+namespace PDF_Office.ViewModels.HomePanel.CloudDrive.CloudDriveType
+{
+    //多用户UX交互
+    public class GoogleDriveManager
+    {
+        private static GoogleDriveManager instance;
+        public static GoogleDriveManager GoogleDrive => instance ?? (instance = new GoogleDriveManager());
+        private GoogleDriveManager()
+        {
+             GoogleDriveStatic.GetFilesPathTemp();
+             GoogleDriveStatic.GetCredentialsPath();
+        }
+
+        #region   请求身份验证
+
+        /// <summary>
+        /// 获取登录过的用户
+        /// </summary>
+        public async Task<bool> GetHistoryUsers()
+        {
+            var tuples = await GoogleDriveStatic.GetHistoryService();
+            Cloud.CloudLists.Clear();
+            foreach (var tuple in tuples)
+            {
+
+                if (tuple != null && tuple.Item1 != null && tuple.Item2 != null)
+                {
+                    AddGoogleDriveUser(tuple);
+                }
+            }
+
+            if (Cloud.CloudLists.Count > 0)
+            {
+                return true;
+            }
+            return false;
+        }
+
+        public async void AddGoogleDriveUser(Tuple<DriveService, UserCredential> tuple)
+        {
+            GoogleDriveUserItem userItem = new GoogleDriveUserItem();
+            userItem.Service = tuple.Item1;
+            userItem.CurrentCredential = tuple.Item2;
+            userItem.cloudType = CloudType.GoogleDrive;
+
+            UserInfo user = new UserInfo();
+            user = await userItem.GetUserAcountAsync();
+            userItem.userInfo = user;
+
+            Cloud.CloudLists.Add(userItem);
+        }
+
+        public async Task<bool> LoginUserCount()
+        {
+            var tuple = await GoogleDriveStatic.GetServiceAsync();
+            bool result = false;
+            if (tuple != null)
+            {
+                result = true;
+                await GetUserInfo(tuple);//此处不可用异步处理,否则导致的结果是没法刷新集合呈现在UI上
+            }
+
+            return result;
+        }
+
+        public async Task<bool> GetUserInfo(Tuple<DriveService, UserCredential> tuple)
+        {
+            GoogleDriveUserItem userItem = new GoogleDriveUserItem();
+            userItem.Service = tuple.Item1;
+            userItem.CurrentCredential = tuple.Item2;
+            userItem.cloudType = CloudType.GoogleDrive;
+
+            UserInfo user = new UserInfo();
+            user = await userItem.GetUserAcountAsync();
+            userItem.userInfo = user;
+
+            Cloud.CloudLists.Add(userItem);
+            return true;
+        }
+
+        public async Task<bool> RemoveUser(GoogleDriveUserItem userIttem)
+        {
+           return await userIttem.RemoveUser();
+        }
+
+        #endregion
+    }
+}

+ 386 - 0
PDF Office/ViewModels/HomePanel/CloudDrive/CloudDriveType/GoogleDriveUserItem.cs

@@ -0,0 +1,386 @@
+using Google.Apis.Auth.OAuth2;
+using Google.Apis.Download;
+using Google.Apis.Drive.v3;
+using Google.Apis.Drive.v3.Data;
+using Google.Apis.Services;
+using Google.Apis.Util.Store;
+using PDF_Office.Model.CloudDrive;
+using System;
+using System.Collections.Generic;
+using System.IO;
+using System.Linq;
+using System.Text;
+using System.Threading;
+using System.Threading.Tasks;
+
+namespace PDF_Office.ViewModels.HomePanel.CloudDrive.CloudDriveType
+{
+
+    /// <summary>
+    /// 单个用户
+    /// </summary>
+    public class GoogleDriveUserItem: UserBaseItem
+    {
+       
+        public  DriveService Service { get; set; }//Google提供服务
+        private List<GoogleDriveFiles> FilesList = new List<GoogleDriveFiles>();//文件
+
+        public UserCredential CurrentCredential { get; set; }//当前用户访问令牌
+
+        public GoogleDriveUserItem()
+        {
+         //   User = new User();
+            
+        }
+      
+        #region   对用户账号处理
+
+        /// <summary>
+        /// 移除用户帐号
+        /// </summary>
+        /// <returns>移除后的状态</returns>
+        public async Task<bool> RemoveUser()
+        {
+            bool result = false;
+            if (CurrentCredential != null)
+            {
+                result = await CurrentCredential.RevokeTokenAsync(CancellationToken.None);
+            }
+            if (result == true)
+            {
+                CurrentCredential = null;
+                FilesList.Clear();
+            }
+               
+
+            return result;
+        }
+
+        /// <summary>
+        /// 获取帐号
+        /// </summary>
+        /// <returns>返回用户帐号地址</returns>
+        private async Task<UserInfo> GetUserAcount()
+        {
+            UserInfo userInfo = null;
+            if (Service != null)
+            {
+                userInfo = new UserInfo();
+                var about = Service.About.Get();
+                about.Fields = "user";
+                var uss = await about.ExecuteAsync();
+                User user = uss.User;
+                userInfo.UserAccount = user.EmailAddress;
+                userInfo.Name = user.DisplayName;
+            }
+
+            return userInfo;
+        }
+
+        /// <summary>
+        /// 获取帐号
+        /// </summary>
+        /// <returns>返回用户帐号地址</returns>
+        public async Task<UserInfo> GetUserAcountAsync()
+        {
+            return await GetUserAcount();
+        }
+
+
+        #endregion
+
+
+        #region   文件夹
+
+
+
+        #endregion
+
+        #region  文件
+
+        /// <summary>
+        /// 对单个用户,获取文件列表
+        /// </summary>
+        public async Task<List<GoogleDriveFiles>> GetDriveFiles(DriveService service = null)
+        {
+            if (service == null)
+                return null;
+
+            // define parameters of request.
+            FilesResource.ListRequest FileListRequest = service.Files.List(); 
+
+            //listRequest.PageSize = 10;
+            //listRequest.PageToken = 10;
+            FileListRequest.Fields = "nextPageToken, files(id, name, size, version, createdTime)";
+
+            //get file list.
+            IList<Google.Apis.Drive.v3.Data.File> files = FileListRequest.Execute().Files;
+            List<GoogleDriveFiles> FileList = new List<GoogleDriveFiles>();
+
+            if (files != null && files.Count > 0)
+            {
+                foreach (var file in files)
+                {
+                       GoogleDriveFiles File = new GoogleDriveFiles
+                    {
+                        Id = file.Id,
+                        Name = file.Name,
+                        Size = file.Size,
+                        Version = file.Version,
+                        CreatedTime = file.CreatedTime
+                    };
+                    FileList.Add(File);
+                }
+                this.FilesList = FileList;
+            }
+            return FileList;
+        }
+
+        /// <summary>
+        /// 上传文件
+        /// </summary>
+        /// <param name="filepath">本地文件路径</param>
+        public  async Task<bool> FileUpload(string filepath)
+        {
+            if (Service == null)
+                return false;
+
+            var FileMetaData = new Google.Apis.Drive.v3.Data.File();
+            var str = filepath.LastIndexOf("\\");
+            var str2 = filepath.Substring(str + 1, filepath.Length - str - 1);
+
+            FileMetaData.Name = str2;
+            FileMetaData.MimeType = "";
+
+            FilesResource.CreateMediaUpload request;
+            try
+            {
+                using (var stream = new System.IO.FileStream(filepath, System.IO.FileMode.Open))
+                {
+                    request = Service.Files.Create(FileMetaData, stream, FileMetaData.MimeType);
+                    request.Fields = "id";
+                    request.Upload();
+                }
+
+                return true;
+            }
+            catch
+            {
+               return false;
+            }
+
+        }
+
+
+        /// <summary>
+        /// Download file from Google Drive by fileId.
+        /// </summary>
+        /// <param name="googleDriveFiles"></param>
+        /// <param name="savePath"></param>
+        /// <returns></returns>
+        //
+        public  async Task<string> DownloadGoogleFile(GoogleDriveFiles googleDriveFiles, string savePath)
+        {
+            if (Service == null)
+                return "";
+
+            string fileId = googleDriveFiles.Id;
+            if (string.IsNullOrEmpty(fileId))
+                return "";
+
+            //fileId = DriveFiles[0].Id;
+
+            FilesResource.GetRequest request = Service.Files.Get(fileId);
+
+            string FileName = request.Execute().Name;
+            string FilePath = System.IO.Path.Combine(savePath, FileName);
+
+            MemoryStream stream = new MemoryStream();
+
+            // Add a handler which will be notified on progress changes.
+            // It will notify on each chunk download and when the
+            // download is completed or failed.
+            request.MediaDownloader.ProgressChanged += (Google.Apis.Download.IDownloadProgress progress) =>
+            {
+                switch (progress.Status)
+                {
+                    case DownloadStatus.Downloading:
+                        {
+                            Console.WriteLine(progress.BytesDownloaded);
+                            break;
+                        }
+                    case DownloadStatus.Completed:
+                        {
+                            Console.WriteLine("Download complete.");
+                            SaveStream(stream, FilePath);
+                            break;
+                        }
+                    case DownloadStatus.Failed:
+                        {
+                            Console.WriteLine("Download failed.");
+                            break;
+                        }
+                }
+            };
+            request.Download(stream);
+
+            if (string.IsNullOrEmpty(savePath) == false)
+            {
+
+            }
+            return FilePath;
+        }
+
+        private static void SaveStream(MemoryStream stream, string FilePath)
+        {
+            using (System.IO.FileStream file = new FileStream(FilePath, FileMode.Create, FileAccess.ReadWrite))
+            {
+                stream.WriteTo(file);
+            }
+        }
+
+        #endregion
+    }
+
+
+    public static class GoogleDriveStatic
+    {
+        public static string[] Scopes = { DriveService.Scope.Drive };
+        //Google Drive应用名称
+        private static readonly string GoogleDriveAppName = "PDF Office";
+        //请求应用进行身份验证的信息
+        public static string CredentialsPath { get; private set; }
+
+        //存放已通过身份验证的用户信息,以便下次不用登录便可使用云文档
+        public static string FilesPathTemp { get; private set; }
+        /// <summary>
+        ///  异步获取Google服务的包信息,避免UI线程卡死
+        /// </summary>
+        /// <param name="userInfoFile"></param>
+        [Obsolete]
+        public static async Task<Tuple<DriveService, UserCredential>> GetServiceAsync(string userInfoFile = "")
+        {
+            Tuple<DriveService, UserCredential> tuple = null;
+            await Task.Run(() =>
+            {
+                tuple = GetService(userInfoFile);
+            });
+            return tuple;
+        }
+
+        /// <summary>
+        /// 获取Google服务的包信息(包含访问令牌,App Key密钥等)
+        /// </summary>
+        /// <param name="FilePath">登录过的用户文件;若为空,则为新用户登录</param>
+        /// <returns></returns>
+        [Obsolete]
+        public static Tuple<DriveService, UserCredential> GetService(string FilePath = "")
+        {
+            Tuple<DriveService, UserCredential> tuple = null;
+            UserCredential credential;
+
+            if (FilePath == "")
+            {
+                var time = DateTime.Now.ToString("yyyyMMddHHmmss");
+                FilePath = System.IO.Path.Combine(FilesPathTemp, time + ".json");
+            }
+
+            try
+            {
+                using (var stream = new FileStream(CredentialsPath, FileMode.Open, FileAccess.Read))
+                {
+                    credential = GoogleWebAuthorizationBroker.AuthorizeAsync(
+                        GoogleClientSecrets.Load(stream).Secrets,
+                        Scopes,
+                        "user",
+                        CancellationToken.None,
+                        new FileDataStore(FilePath, true)).Result;
+                }
+
+                //create Drive API service.
+                DriveService service = new DriveService(new BaseClientService.Initializer()
+                {
+                    HttpClientInitializer = credential,
+                    ApplicationName = GoogleDriveAppName
+                });
+
+                return tuple = new Tuple<DriveService, UserCredential>(service, credential);
+            }
+            catch (Exception e)
+            {
+                //网络连接失败的情况
+                return null;
+            }
+            
+        }
+
+
+        /// <summary>
+        /// 获取登录过的账号
+        /// </summary>
+        /// <returns>历史账号</returns>
+        public static async Task<List<Tuple<DriveService, UserCredential>>> GetHistoryService()
+        {
+            DirectoryInfo TheFolder = new DirectoryInfo(FilesPathTemp);
+            List<Tuple<DriveService, UserCredential>> DriveServices = new List<Tuple<DriveService, UserCredential>>();
+
+            foreach (var directorieItem in TheFolder.GetDirectories())
+            {
+                var driveServiceItem = await GetServiceAsync(directorieItem.Name);
+
+                if (driveServiceItem != null)
+                {
+                    DriveServices.Add(driveServiceItem);
+                }
+            }
+            return DriveServices;
+        }
+
+
+
+        #region  云文档的用户帐户缓存路径和身份验证文件
+
+        /// <summary>
+        /// 获取或创建缓存登录帐户信息
+        /// </summary>
+        public static string GetFilesPathTemp()
+        {
+            string str_1 = System.AppDomain.CurrentDomain.BaseDirectory;
+            String FolderPath = str_1 + "GoogleDriveUsers";
+
+            if (Directory.Exists(FolderPath) == false)
+                Directory.CreateDirectory(FolderPath);
+
+            FilesPathTemp = FolderPath;
+            return FolderPath;
+        }
+
+        public static bool ClearFilesPathTemp()
+        {
+            bool result = false;
+            string str_1 = System.AppDomain.CurrentDomain.BaseDirectory;
+            String FolderPath = str_1 + "GoogleDriveUsers";
+
+            if (Directory.Exists(FolderPath) == false)
+            {
+                Directory.Delete(FolderPath);
+                result = true;
+            }
+            return result;
+        }
+
+
+        /// <summary>
+        /// 获取本地身份验证文件
+        /// </summary>
+        public static string GetCredentialsPath()
+        {
+            string str_1 = System.AppDomain.CurrentDomain.BaseDirectory;
+            String filePath = str_1 + @"\credentials.json";
+            CredentialsPath = filePath;
+            return filePath;
+        }
+
+        #endregion
+    }
+}

+ 136 - 0
PDF Office/ViewModels/HomePanel/CloudDrive/CloudFilesContentViewModel.cs

@@ -0,0 +1,136 @@
+using PDF_Office.Model.CloudDrive;
+using PDF_Office.ViewModels.HomePanel.CloudDrive.CloudDriveType;
+using Prism.Commands;
+using Prism.Mvvm;
+using System;
+using System.Collections.Generic;
+using System.Collections.ObjectModel;
+using System.Linq;
+using System.Text;
+using System.Threading.Tasks;
+
+namespace PDF_Office.ViewModels.HomePanel.CloudDrive
+{
+    //各云盘事件
+    public class CloudFilesContentViewModel : BindableBase
+    {
+     
+        public GoogleDriveManager GoogleDrive => GoogleDriveManager.GoogleDrive;
+        public DropbBoxManager DropbBox => DropbBoxManager.DropbBox;
+        public DelegateCommand OpenCloudDriveCommand { get; set; }
+        public DelegateCommand CheckDriveUsersCommand { get; set; }
+
+        public DelegateCommand<CloudBoxItem> CheckDriveCommand { get; set; }
+        
+        public CloudFilesContentViewModel()
+        {
+            OpenCloudDriveCommand = new DelegateCommand(OpenCloudDrive_Click);
+            OpenCloudDriveCommand = new DelegateCommand(CheckDriveUsers);
+
+            CheckDriveCommand = new DelegateCommand<CloudBoxItem>(CheckDrive);
+        }
+
+        public async void CheckDrive(CloudBoxItem cloudDriveItem)
+        {
+            switch (cloudDriveItem.CloudDiskType)
+            {
+                case CloudType.GoogleDrive:
+                     await GoogleDrive.LoginUserCount();
+                    break;
+                case CloudType.DropBox:
+                     await DropbBox.LoginUser();
+                    break;
+            }
+        }
+
+        #region 云盘公用接口
+
+        public async void CheckDriveUsers()
+        {
+            //   var result = await GetHistoryUser();
+            //    isFoundUserHandler?.Invoke(null, result);
+         // await  GoogleDrive.LoginUderCount();
+
+        }
+
+        #endregion
+        public void OpenCloudDrive_Click()
+        {
+
+        }
+
+
+        #region 谷歌云盘
+
+        public void LoginUser_Click()
+        {
+
+        }
+
+        public async Task<bool> GetHistoryUser()
+        {
+            bool isFound = false;
+
+            //if (await GoogleDrive.GetHistoryUsers())
+            //{
+            //    isFound = true;
+            //}
+            return isFound;
+
+        }
+
+        #endregion
+
+
+
+
+        #region 用户帐号
+
+        /// <summary>
+        /// 登录
+        /// </summary>
+        public void LoginUser()
+        {
+           
+        }
+
+        /// <summary>
+        /// 移除用户
+        /// </summary>
+        public void RemoveUser()
+        {
+
+        }
+
+        /// <summary>
+        /// 切换用户
+        /// </summary>
+        public void SwitchUser()
+        {
+
+        }
+
+
+        #endregion
+
+
+        #region 文件
+        
+        public void GetFiles()
+        {
+
+        }
+
+        public void GetFolders()
+        {
+
+        }
+
+        public void UpLoad()
+        {
+
+        }
+        #endregion
+
+    }
+}

+ 30 - 1
PDF Office/ViewModels/HomePanel/HomeCloudContentViewModel.cs

@@ -1,4 +1,8 @@
-using Prism.Mvvm;
+using PDF_Office.Model.CloudDrive;
+using PDF_Office.ViewModels.HomePanel.CloudDrive;
+using PDF_Office.ViewModels.HomePanel.CloudDrive.CloudDriveType;
+using Prism.Commands;
+using Prism.Mvvm;
 using System;
 using System.Collections.Generic;
 using System.Linq;
@@ -9,8 +13,33 @@ namespace PDF_Office.ViewModels.HomePanel
 {
     public class HomeCloudContentViewModel:BindableBase
     {
+        public DelegateCommand<CloudBoxItem> OpenCloudDriveCommand { get; set; }
         public HomeCloudContentViewModel()
         {
+            OpenCloudDriveCommand = new DelegateCommand<CloudBoxItem>(OpenCloudDrive_Click);
+        }
+
+        public void OpenCloudDrive_Click(CloudBoxItem cloudDiskItem)
+        {
+            if (cloudDiskItem != null)
+            {
+
+                switch (cloudDiskItem.CloudDiskType)
+                {
+                    case CloudType.Box:
+                        break;
+                    case CloudType.DropBox:
+                        break;
+                    case CloudType.GoogleDrive:
+                        //    isSccuess = await googleDriveViewModel.LoginUser();
+                        break;
+                    case CloudType.OneDrive:
+                        break;
+                    default:
+                        break;
+                }
+
+            }
 
         }
     }

+ 20 - 9
PDF Office/ViewModels/HomePanel/HomeGuidContentViewModel.cs

@@ -2,6 +2,7 @@
 using ComPDFKitViewer.PdfViewer;
 using PDF_Office.CustomControl;
 using PDF_Office.Model;
+using PDF_Office.Model.Dialog.HomePageToolsDialogs.HomePageBatchProcessing;
 using PDF_Office.Model.PDFTool;
 using PDF_Office.Views.HomePanel.PDFTools;
 using Prism.Commands;
@@ -35,18 +36,24 @@ namespace PDF_Office.ViewModels.HomePanel
             System.Windows.Forms.OpenFileDialog dlg = new System.Windows.Forms.OpenFileDialog();
             dlg.Multiselect = false;
             dlg.Filter = "PDF|*.pdf;*.PDF;";
-            if (toolItem.Tag == PDFToolType.Merge)
+            if (toolItem.Tag == PDFToolType.Compress || toolItem.Tag == PDFToolType.Security)
             {
                 dlg.Multiselect = true;
-                dlg.Filter = "Picture|*.png;*.PNG;*.jpg;*.JPG;*bmp;*jpeg;*gif;*tiff;*webp;";
+            }
+                if (toolItem.Tag == PDFToolType.Merge)
+            {
+                dlg.Multiselect = true;
+                dlg.Filter = "Picture|*.png;*.PNG;*.jpg;*.JPG;*bmp;*jpeg;*gif;*tiff;";
             }
             if (dlg.ShowDialog() == System.Windows.Forms.DialogResult.OK)
             {
                 CPDFViewer viewer = new CPDFViewer();
-                viewer.InitDocument(dlg.FileName);
+                
                 switch (toolItem.Tag)
                 {
                     case PDFToolType.Split:
+                        
+                        viewer.InitDocument(dlg.FileName);
                         DialogParameters splitvalue = new DialogParameters();
                         splitvalue.Add(ParameterNames.PDFViewer, viewer);
                         splitvalue.Add(ParameterNames.FilePath, dlg.FileName);
@@ -54,6 +61,7 @@ namespace PDF_Office.ViewModels.HomePanel
                         break;
 
                     case PDFToolType.Extract:
+                        viewer.InitDocument(dlg.FileName);
                         DialogParameters extractvalue = new DialogParameters();
                         extractvalue.Add(ParameterNames.PDFViewer, viewer);
                         extractvalue.Add(ParameterNames.FilePath, dlg.FileName);
@@ -61,6 +69,7 @@ namespace PDF_Office.ViewModels.HomePanel
                         break;
 
                     case PDFToolType.Insert:
+                        viewer.InitDocument(dlg.FileName);
                         DialogParameters insertvalue = new DialogParameters();
                         insertvalue.Add(ParameterNames.PDFViewer, viewer);
                         insertvalue.Add(ParameterNames.FilePath, dlg.FileName);
@@ -69,11 +78,12 @@ namespace PDF_Office.ViewModels.HomePanel
 
                     case PDFToolType.Compress:
                         DialogParameters compresspdf = new DialogParameters();
-                        compresspdf.Add(ParameterNames.PDFViewer, viewer);
-                        compresspdf.Add(ParameterNames.FilePath, dlg.FileName);
+                        compresspdf.Add(ParameterNames.BatchProcessing_Name, "1");
+                        HomePageBatchProcessingDialogModel.FilePaths = dlg.FileNames.ToList();
+                        HomePageBatchProcessingDialogModel.BatchProcessingIndex = 1;
+                        compresspdf.Add(ParameterNames.FilePath, dlg.FileNames);
                         dialogs.ShowDialog(DialogNames.HomePageBatchProcessingDialog, compresspdf, e => { });
                         break;
-                        break;
 
                     case PDFToolType.Merge:
                         DialogParameters picturetopdf = new DialogParameters();
@@ -83,15 +93,16 @@ namespace PDF_Office.ViewModels.HomePanel
 
                     case PDFToolType.Print:
                         DialogParameters printvalue = new DialogParameters();
-                        printvalue.Add(ParameterNames.PDFViewer, viewer); ;
                         printvalue.Add(ParameterNames.FilePath, dlg.FileName);
                         dialogs.ShowDialog(DialogNames.HomePagePrinterDialog, printvalue, e => { });
                         break;
 
                     case PDFToolType.Security:
                         DialogParameters securitypdf = new DialogParameters();
-                        securitypdf.Add(ParameterNames.PDFViewer, viewer); ;
-                        securitypdf.Add(ParameterNames.FilePath, dlg.FileName);
+                        securitypdf.Add(ParameterNames.BatchProcessing_Name, "2");
+                        HomePageBatchProcessingDialogModel.FilePaths = dlg.FileNames.ToList();
+                        HomePageBatchProcessingDialogModel.BatchProcessingIndex = 1;
+                        securitypdf.Add(ParameterNames.FilePath, dlg.FileNames);
                         dialogs.ShowDialog(DialogNames.HomePageBatchProcessingDialog, securitypdf, e => { });
                         
                         break;

+ 253 - 14
PDF Office/ViewModels/MainContentViewModel.cs

@@ -16,11 +16,14 @@ using System.Linq;
 using System.Text;
 using System.Threading.Tasks;
 using System.Windows;
-using System.Windows.Controls;
 using PDF_Office.Model;
 using System.ComponentModel;
 using PDF_Office.Helper;
 using PDFSettings.Settings;
+using System.Drawing;
+using System.IO;
+using System.Drawing.Imaging;
+using ComPDFKit.PDFDocument;
 
 namespace PDF_Office.ViewModels
 {
@@ -58,6 +61,8 @@ namespace PDF_Office.ViewModels
             set { SetProperty(ref fileChanged, value); }
         }
 
+        private bool isNewDocument = false;
+
         public CPDFViewer PDFViewer { get; set; }
 
 
@@ -113,6 +118,10 @@ namespace PDF_Office.ViewModels
         }
 
 
+        /// <summary>
+        /// 打开指定路径的PDF文件
+        /// </summary>
+        /// <param name="filePath"></param>
         public void OpenFile(string filePath)
         {
             var result = LoadFileFormPath(filePath);
@@ -122,28 +131,40 @@ namespace PDF_Office.ViewModels
             }
             FilePath = filePath;
 
-            NavigationParameters parameters = new NavigationParameters {
-                { ParameterNames.MainViewModel, this },
-                { ParameterNames.PDFViewer,PDFViewer}
-            };
-            System.Windows.Application.Current.Dispatcher.BeginInvoke(System.Windows.Threading.DispatcherPriority.Send, new Action(() =>
-                {
-                    if (toolregion.Regions.ContainsRegionWithName(MainContentRegionName))
-                        toolregion.RequestNavigate(MainContentRegionName, "ViewContent", parameters);
-                }));
+            NavigateToViewContent();
 
             //检查是否是新文档
             OpenFileInfo isnew = SettingHelper.GetFileInfo(filePath);
             if (isnew == null)
             {
                 isNewDocument = true;
-                if(App.OpenedFileList.Contains(filePath) == false)
+                if (App.OpenedFileList.Contains(filePath) == false)
+                {
                     App.OpenedFileList.Add(filePath);
-                SettingHelper.SortRecentOpenFiles(filePath);
-            } 
+                }
+         
+            }
+            //打开文件后,不管是新文件还是旧文件都需要更新排序
+            SettingHelper.SortRecentOpenFiles(filePath);
+        }
+
+        /// <summary>
+        /// 创建PDFviewer对象后导航到ViewContent
+        /// </summary>
+        private void NavigateToViewContent()
+        {
+            NavigationParameters parameters = new NavigationParameters {
+                { ParameterNames.MainViewModel, this },
+                { ParameterNames.PDFViewer,PDFViewer}
+            };
+            System.Windows.Application.Current.Dispatcher.BeginInvoke(System.Windows.Threading.DispatcherPriority.Send, new Action(() =>
+            {
+                if (toolregion.Regions.ContainsRegionWithName(MainContentRegionName))
+                    toolregion.RequestNavigate(MainContentRegionName, "ViewContent", parameters);
+            }));
 
         }
-        private bool isNewDocument = false;
+
         /// <summary>
         /// 从文件路径创建PDFViewer对象,已包含文档解密逻辑
         /// </summary>
@@ -195,6 +216,213 @@ namespace PDF_Office.ViewModels
             return true;
         }
 
+        /// <summary>
+        /// 创建文件,路径为空时表示创建空白文档
+        /// 否则表示从图片路径创建PDf
+        /// </summary>
+        /// <param name="imagePath"></param>
+        /// <returns></returns>
+        public bool CreateFile(string imagePath = null)
+        {
+            PDFViewer = new CPDFViewer();
+            PDFViewer.CreateDocument();
+            PDFViewer.UndoManager.PropertyChanged += UndoManager_PropertyChanged;
+            if (PDFViewer.Document == null)
+            {
+                AlertsMessage alertsMessage = new AlertsMessage();
+                alertsMessage.ShowDialog("","创建文件失败.","OK");
+                return false;
+            }
+
+            if (string.IsNullOrEmpty(imagePath))
+            {
+                FileName = "Blank Page.pdf";
+                //默认插入595*842 大小的页面
+                PDFViewer.Document.InsertPage(0, 595, 842, null);
+            }
+            else
+            {
+                FileName = imagePath.Substring(imagePath.LastIndexOf("\\") + 1, imagePath.LastIndexOf(".") - imagePath.LastIndexOf("\\") - 1) + ".pdf";
+                Bitmap pic = new Bitmap(imagePath);
+                int width = pic.Size.Width;
+                int height = pic.Size.Height;
+
+                string ex = System.IO.Path.GetExtension(imagePath);
+                //其他格式或者名称中含空格的图片 在本地先转存一下
+                if ((ex != ".jpg" && ex != ".jpeg") || !Uri.IsWellFormedUriString(imagePath, UriKind.Absolute))
+                {
+                    //将其他格式图片转换成jpg
+                    string folderPath = Path.GetTempPath();
+                    if (File.Exists(folderPath))
+                    {
+                        File.Delete(folderPath);
+                    }
+                    DirectoryInfo tempfolder = new DirectoryInfo(folderPath);
+                    if (!tempfolder.Exists)
+                    {
+                        tempfolder.Create();
+                    }
+                    string targetPath = System.IO.Path.Combine(folderPath, Guid.NewGuid().ToString());
+                    imagePath = targetPath;
+                    pic.Save(targetPath, ImageFormat.Jpeg);
+                }
+                pic.Dispose();
+
+                var result = PDFViewer.Document.InsertPage(0, width, height, imagePath);
+                if (!result)
+                {
+                    AlertsMessage alertsMessage = new AlertsMessage();
+                    alertsMessage.ShowDialog("", "创建文件失败.", "OK");
+                    return false;
+                }
+            }
+
+            //设置背景色
+            ////PDFViewer.SetBackgroundBrush(new SolidColorBrush((Color)System.Windows.Media.ColorConverter.ConvertFromString(Settings.Default.AppProperties.InitialVIew.Background)));
+            PDFViewer.Load();
+            PDFViewer.UndoManager.CanSave = true;
+            FileChanged = Visibility.Visible;
+            PDFViewer.SetFormFieldHighlight(true);
+
+            NavigateToViewContent();
+            return true;
+        }
+
+        /// <summary>
+        /// 从office文件转换成PDF
+        /// </summary>
+        /// <param name="sourcepath"></param>
+        /// <returns></returns>
+        public async Task<bool> CreateFileFromOffice(string sourcepath)
+        {
+            try
+            {
+                string folderPath = Path.GetTempPath();
+                if (File.Exists(folderPath))
+                {
+                    File.Delete(folderPath);
+                }
+                DirectoryInfo tempfolder = new DirectoryInfo(folderPath);
+                if (!tempfolder.Exists)
+                {
+                    tempfolder.Create();
+                }
+                string targetPath = System.IO.Path.Combine(folderPath, Guid.NewGuid().ToString() + ".pdf");
+
+                string ex = System.IO.Path.GetExtension(sourcepath);
+
+                switch (ex)
+                {
+
+                    case ".doc":
+                    case ".docx":
+                    case "docm":
+                    case ".dot":
+                    case ".dotx":
+                    case ".dotm":
+                    case ".txt":
+                        await Task.Run(() =>
+                        {
+
+                            Microsoft.Office.Interop.Word.Application word = new Microsoft.Office.Interop.Word.Application();
+                            Microsoft.Office.Interop.Word.Document document = null;
+
+                            word.Visible = false;
+                            word.ShowWindowsInTaskbar = true;
+                            document = word.Documents.Open(sourcepath);
+                            document?.ExportAsFixedFormat(targetPath, Microsoft.Office.Interop.Word.WdExportFormat.wdExportFormatPDF);
+                            document?.Close();
+                            word?.Quit();
+                        });
+                        break;
+                    case ".xls":
+                    case ".xlsx":
+                    case ".xlsm":
+                    case ".xlsb":
+                    case ".xlam":
+                    case ".xltx":
+                    case ".xlt":
+                        await Task.Run(() =>
+                        {
+                            Microsoft.Office.Interop.Excel.Application excele = new Microsoft.Office.Interop.Excel.Application();
+                            Microsoft.Office.Interop.Excel.Workbook workbook = null;
+
+                            excele.Visible = false;
+                            try
+                            {
+                                workbook = excele.Workbooks.Open(sourcepath);
+                            }
+                            catch (Exception e)
+                            {
+                                workbook = excele.Workbooks.Open(sourcepath, 0, true, 5, "", "", true, Microsoft.Office.Interop.Excel.XlPlatform.xlWindows, "t", false, false, 0, true, 1, Microsoft.Office.Interop.Excel.XlCorruptLoad.xlRepairFile);
+                            }
+
+
+                            workbook?.ExportAsFixedFormat(Microsoft.Office.Interop.Excel.XlFixedFormatType.xlTypePDF, targetPath);
+                            workbook?.Close();
+                            excele?.Quit();
+                        });
+                        break;
+                    case ".ppt":
+                    case ".pptx":
+                    case ".pptm":
+                    case ".pptsx":
+                    case ".pps":
+                    case ".pptsm":
+                    case ".pot":
+                    case ".potm":
+                        await Task.Run(() =>
+                        {
+                            Microsoft.Office.Interop.PowerPoint.Application ppt = new Microsoft.Office.Interop.PowerPoint.Application();
+                            Microsoft.Office.Interop.PowerPoint.Presentation presentation = null;
+
+                            ppt.Visible = Microsoft.Office.Core.MsoTriState.msoCTrue;
+                            presentation = ppt.Presentations.Open(sourcepath);
+
+                            presentation.ExportAsFixedFormat(targetPath, Microsoft.Office.Interop.PowerPoint.PpFixedFormatType.ppFixedFormatTypePDF);
+                            presentation?.Close();
+                            ppt?.Quit();
+                        });
+                        break;
+                }
+
+                PDFViewer = new CPDFViewer();
+                PDFViewer.CreateDocument();
+
+                if (PDFViewer.Document == null)
+                {
+                    AlertsMessage alertsMessage = new AlertsMessage();
+                    alertsMessage.ShowDialog("","创建PDF失败","OK");
+                    return false;
+                }
+
+                FileName = sourcepath.Substring(sourcepath.LastIndexOf("\\") + 1, sourcepath.LastIndexOf(".") - sourcepath.LastIndexOf("\\") - 1) + ".pdf";
+
+                var tempdoc = CPDFDocument.InitWithFilePath(targetPath);
+                if (tempdoc == null)
+                {
+                    AlertsMessage alertsMessage = new AlertsMessage();
+                    alertsMessage.ShowDialog("", "创建PDF失败", "OK");
+                    return false;
+                }
+
+                PDFViewer.Document.ImportPages(tempdoc, "");
+
+                //PDFViewer.SetBackgroundBrush(new SolidColorBrush((Color)System.Windows.Media.ColorConverter.ConvertFromString(Settings.Default.AppProperties.InitialVIew.Background)));
+                PDFViewer.Load();
+                PDFViewer.UndoManager.CanSave = true;
+
+
+                return true;
+            }
+            catch (Exception ex)
+            {
+                AlertsMessage alertsMessage = new AlertsMessage();
+                alertsMessage.ShowDialog("", "没有安装Office", "OK");
+                return false;
+            }
+        }
+
         private void UndoManager_PropertyChanged(object sender, PropertyChangedEventArgs e)
         {
             if (e.PropertyName == "CanSave")
@@ -203,9 +431,19 @@ namespace PDF_Office.ViewModels
                 {
                     FileChanged = Visibility.Visible;
                 }
+                else
+                {
+                    FileChanged = Visibility.Collapsed;
+                }
+
+                if (!string.IsNullOrEmpty(PDFViewer.Document.FileName))
+                {
+                    FileName = PDFViewer.Document.FileName;
+                }
             }
         }
 
+        #region Navigation
         public void OnNavigatedTo(NavigationContext navigationContext)
         {
             if (navigationContext.Parameters.Count <= 0)
@@ -225,5 +463,6 @@ namespace PDF_Office.ViewModels
         public void OnNavigatedFrom(NavigationContext navigationContext)
         {
         }
+        #endregion
     }
 }

+ 16 - 0
PDF Office/ViewModels/Tools/ConverterBarContentViewModel.cs

@@ -0,0 +1,16 @@
+using Prism.Commands;
+using Prism.Mvvm;
+using System;
+using System.Collections.Generic;
+using System.Linq;
+
+namespace PDF_Office.ViewModels.Tools
+{
+    public class ConverterBarContentViewModel : BindableBase
+    {
+        public ConverterBarContentViewModel()
+        {
+
+        }
+    }
+}

+ 314 - 26
PDF Office/ViewModels/ViewContentViewModel.cs

@@ -15,6 +15,7 @@ using PDF_Office.CustomControl;
 using PDF_Office.Model;
 using System.Windows;
 using System.Windows.Controls;
+using System.IO;
 
 namespace PDF_Office.ViewModels
 {
@@ -40,6 +41,14 @@ namespace PDF_Office.ViewModels
 
         public string ToolsBarContentRegionName { get; set; }
 
+        /// <summary>
+        /// 是否处于页面编辑模式,用于执行undo redo 的具体操作
+        /// </summary>
+        public bool isInPageEdit = false;
+
+        public Action PageEditUndo { get; set; }
+
+        public Action PageEditRedo { get; set; }
 
 
         private int gridToolRow = 1;
@@ -109,6 +118,41 @@ namespace PDF_Office.ViewModels
             }
         }
 
+        private bool canSave;
+        /// <summary>
+        /// 是否可以保存
+        /// </summary>
+        public bool CanSave
+        {
+            get { return canSave; }
+            set
+            {
+                SetProperty(ref canSave, value);
+            }
+        }
+
+        private bool canUndo;
+
+        public bool CanUndo
+        {
+            get { return canUndo; }
+            set
+            {
+                SetProperty(ref canUndo, value);
+            }
+        }
+
+        private bool canRedo;
+
+        public bool CanRedo
+        {
+            get { return canRedo; }
+            set
+            {
+                SetProperty(ref canRedo, value);
+            }
+        }
+
 
         private Dictionary<string, string> regionNameByTabItem;
 
@@ -118,8 +162,6 @@ namespace PDF_Office.ViewModels
 
         private string currentBar = "";
 
-
-
         /// <summary>
         /// 用来避免重复触发导航事件的标志符
         /// </summary>
@@ -138,6 +180,14 @@ namespace PDF_Office.ViewModels
         public DelegateCommand Load { get; set; }
 
         public DelegateCommand<object> TabControlSelectionChangedCommand { get; set; }
+
+        public DelegateCommand SaveFile { get; set; }
+
+        public DelegateCommand SaveAsFile { get; set; }
+
+        public DelegateCommand UndoCommand { get; set; }
+
+        public DelegateCommand RedoCommand { get; set; }
         #endregion
 
         public ViewContentViewModel(IRegionManager regionManager, IDialogService dialogService)
@@ -147,6 +197,10 @@ namespace PDF_Office.ViewModels
 
             LoadFile = new DelegateCommand(loadFile);
             Load = new DelegateCommand(LoadControl);
+            SaveFile = new DelegateCommand(()=> { saveFile(); });
+            SaveAsFile = new DelegateCommand(() => { saveAsFile(); });
+            UndoCommand = new DelegateCommand(Undo);
+            RedoCommand = new DelegateCommand(Redo);
             TabControlSelectionChangedCommand = new DelegateCommand<object>(TabControlSelectonChangedEvent);
 
             ViwerRegionName = Guid.NewGuid().ToString();
@@ -183,7 +237,7 @@ namespace PDF_Office.ViewModels
         {
             dictionary.Add("TabItemPageEdit", "PageEditContent");
             dictionary.Add("TabItemTool", "ToolsBarContent");
-            dictionary.Add("TabItemAnnotation", "");
+            dictionary.Add("TabItemAnnotation", "AnnotToolContent");
             dictionary.Add("TabItemConvert", "");
             dictionary.Add("TabItemScan", "");
             dictionary.Add("TabItemEdit", "");
@@ -191,23 +245,20 @@ namespace PDF_Office.ViewModels
             dictionary.Add("TabItemFill", "");
         }
 
-        private void LoadControl()
+        private void UndoManager_PropertyChanged(object sender, System.ComponentModel.PropertyChangedEventArgs e)
         {
-            //在构造函数中使用Region需要借助Dispatcher 确保UI已经加载完成,加载BOTA区域
-            System.Windows.Application.Current.Dispatcher.BeginInvoke(System.Windows.Threading.DispatcherPriority.Send, new Action(() =>
+            if (e.PropertyName == "CanSave")
             {
-                region.RequestNavigate(BOTARegionName, "BOTAContent");
+                CanSave = PDFViewer.UndoManager.CanSave;
+            }
+            if(e.PropertyName == "CanUndo")
+            {
+                CanUndo = PDFViewer.UndoManager.CanUndo;
+            }
+            if(e.PropertyName =="CanRedo")
+            {
+                CanRedo = PDFViewer.UndoManager.CanRedo;
             }
-            ));
-        }
-
-        /// <summary>
-        /// 将PDFViwer添加到Region
-        /// </summary>
-        private void loadFile()
-        {
-            PDFViewer.MouseWheelZoomHandler += PdfViewer_MouseWheelZoomHandler;
-            region.AddToRegion(ViwerRegionName, PDFViewer);
         }
 
         /// <summary>
@@ -223,15 +274,17 @@ namespace PDF_Office.ViewModels
                 currentBar = item.Name;
                 if (previousBar != currentBar)
                 {
-                        if(currentBar== "TabItemPageEdit")//如果是页面编辑则进入页面编辑模式
-                        {
-                            EnterToolMode(barContentByTabItem[currentBar]);
-                        }
-                        else//其余情况直接导航至对应的工具栏即可,不需要清空之前的content,region里是单例模式
-                        {
-                            EnterSelectedBar(currentBar);
-                        }
-                        previousBar = currentBar;
+                    if(currentBar== "TabItemPageEdit")//如果是页面编辑则进入页面编辑模式
+                    {
+                        EnterToolMode(barContentByTabItem[currentBar]);
+                        isInPageEdit = true;
+                    }
+                    else//其余情况直接导航至对应的工具栏即可,不需要清空之前的content,region里是单例模式
+                    {
+                        EnterSelectedBar(currentBar);
+                        isInPageEdit = false;
+                    }
+                    previousBar = currentBar;
                 }
             }
         }
@@ -307,6 +360,241 @@ namespace PDF_Office.ViewModels
         #endregion
 
         #region 方法
+        private void Undo()
+        {
+            if(isInPageEdit)
+            {
+                //执行页面编辑的Undo
+                PageEditUndo?.Invoke();
+            }
+            else
+            {
+                PDFViewer.UndoManager.Undo();
+            }
+        }
+
+        private void Redo()
+        {
+            if(isInPageEdit)
+            {
+                //执行页面编辑的Redo
+                PageEditRedo?.Invoke();
+            }
+            else
+            {
+                PDFViewer.UndoManager.Redo();
+            }
+        }
+
+        private void LoadControl()
+        {
+            //在构造函数中使用Region需要借助Dispatcher 确保UI已经加载完成,加载BOTA区域
+            System.Windows.Application.Current.Dispatcher.BeginInvoke(System.Windows.Threading.DispatcherPriority.Send, new Action(() =>
+            {
+                NavigationParameters parameters = new NavigationParameters();
+                parameters.Add(ParameterNames.PDFViewer, PDFViewer);
+                parameters.Add(ParameterNames.ViewContentViewModel, this);
+                region.RequestNavigate(BOTARegionName, "BOTAContent",parameters);
+            }
+            ));
+        }
+
+        /// <summary>
+        /// 将PDFViwer添加到Region
+        /// </summary>
+        private void loadFile()
+        {
+            PDFViewer.MouseWheelZoomHandler += PdfViewer_MouseWheelZoomHandler;
+            PDFViewer.UndoManager.PropertyChanged += UndoManager_PropertyChanged;
+            CanSave = PDFViewer.UndoManager.CanSave;
+            CanUndo = PDFViewer.UndoManager.CanUndo;
+            CanRedo = PDFViewer.UndoManager.CanRedo;
+            region.AddToRegion(ViwerRegionName, PDFViewer);
+        }
+
+        /// <summary>
+        /// 已有路径文档的保存逻辑
+        /// </summary>
+        private bool saveFile()
+        {
+            try
+            {
+                if (string.IsNullOrEmpty(PDFViewer.Document.FilePath))
+                    return saveAsFile();
+
+                //文档已被修复时 提示另存为
+                if (PDFViewer.Document.HasRepaired)
+                {
+                    AlertsMessage alertsMessage = new AlertsMessage();
+                    alertsMessage.ShowDialog("", "文件已被修复,建议另存为", "Cancel", "OK");
+                    if (alertsMessage.result == ContentResult.Ok)
+                        return saveAsFile();
+                    else
+                        return false;
+                }
+
+                //文件路径无法存在时
+                if (!File.Exists(PDFViewer.Document.FilePath))
+                {
+                    AlertsMessage alertsMessage = new AlertsMessage();
+                    alertsMessage.ShowDialog("", "文件路径不存在,需要另存为", "Cancel", "OK");
+                    if (alertsMessage.result == ContentResult.Ok)
+                        return saveAsFile();
+                    else
+                        return false;
+                }
+
+                //只读文件无法写入时,提示另存为
+                FileInfo fileInfo = new FileInfo(PDFViewer.Document.FilePath);
+                if (fileInfo.IsReadOnly)
+                {
+                    AlertsMessage alertsMessage = new AlertsMessage();
+                    alertsMessage.ShowDialog("", "文件为只读文件,需要另存为", "Cancel", "OK");
+                    if (alertsMessage.result == ContentResult.Ok)
+                        return saveAsFile();
+                    else
+                        return false;
+                }
+
+                bool result = PDFViewer.Document.WriteToLoadedPath();
+                if (result)
+                {
+                    PDFViewer.UndoManager.CanSave = false;
+                    App.Current.Dispatcher.Invoke(() =>
+                    {
+                        //TODO:更新缩略图
+                        //OpenFileInfo info = SettingHelper.GetFileInfo(PdfViewer.Document.FilePath);
+                        //try
+                        //{
+                        //    if (!string.IsNullOrEmpty(info.ThumbImgPath) && !PdfViewer.Document.IsEncrypted)//加密的文档不获取缩略图
+                        //    {
+                        //        var size = PdfViewer.Document.GetPageSize(0);
+                        //        System.Drawing.Bitmap bitmap = ToolMethod.RenderPageBitmapNoWait(PdfViewer.Document, (int)size.Width, (int)size.Height, 0, true, true);
+                        //        string folderPath = System.IO.Path.Combine(App.CurrentPath, "CoverImage");
+                        //        if (File.Exists(folderPath))
+                        //            File.Delete(folderPath);
+                        //        DirectoryInfo folder = new DirectoryInfo(folderPath);
+                        //        if (!folder.Exists)
+                        //            folder.Create();
+                        //        string imagePath = info.ThumbImgPath;
+                        //        if (!File.Exists(imagePath))//由加密文档变为非加密文档时 新建一个路径
+                        //        {
+                        //            string imageName = Guid.NewGuid().ToString();
+                        //            imagePath = System.IO.Path.Combine(folderPath, imageName);
+                        //            using (FileStream stream = new FileStream(imagePath, FileMode.Create))
+                        //            {
+                        //                bitmap.Save(stream, System.Drawing.Imaging.ImageFormat.Png);
+                        //            }
+                        //        }
+                        //        else
+                        //        {
+                        //            using (FileStream stream = new FileStream(imagePath, FileMode.Open))
+                        //            {
+                        //                bitmap.Save(stream, System.Drawing.Imaging.ImageFormat.Png);
+                        //            }
+                        //        }
+                        //        info.ThumbImgPath = imagePath;
+                        //        SettingHelper.SetFileInfo(info);
+                        //    }
+                        //}
+                        //catch
+                        //{
+                        //    info.ThumbImgPath = null;
+                        //    SettingHelper.SetFileInfo(info);
+                        //}
+                    });
+                }
+                else
+                {
+                    //文件被占用 保存失败时
+                    AlertsMessage alertsMessage = new AlertsMessage();
+                    alertsMessage.ShowDialog("", "文件被占用,需要另存为", "Cancel", "OK");
+                    if (alertsMessage.result == ContentResult.Ok)
+                        return saveAsFile();
+                    else
+                        return false;
+                }
+
+                return result;
+            }
+            catch { return false; }
+        }
+
+        /// <summary>
+        /// 另存为或新文档保存逻辑
+        /// </summary>
+        private bool saveAsFile()
+        {
+            var dlg = new SaveFileDialog();
+            dlg.Filter = Properties.Resources.OpenDialogFilter;
+            dlg.FileName = PDFViewer.Document.FileName;
+            if (dlg.ShowDialog() == true && !string.IsNullOrEmpty(dlg.FileName))
+            {
+                bool result = false;
+                if (App.OpenedFileList.Contains(dlg.FileName))
+                {
+                    //提示文件已经被打开
+                }
+                else
+                {
+                    result = PDFViewer.Document.WriteToFilePath(dlg.FileName);
+                    if (result)
+                    {
+                        DoAfterSaveAs(dlg.FileName);
+                    }
+                    else
+                    {
+                        //提示文件被其他软件占用 无法保存
+                        //MessageBoxEx.Show(App.MainPageLoader.GetString("Main_TheFileOccupiedWarning"), "", Winform.MessageBoxButtons.OKCancel, new string[] { App.MainPageLoader.GetString("Main_SaveAs"), App.MainPageLoader.GetString("Main_Cancel") })
+                    }
+                      ;
+                }
+                return result;
+            }
+            else
+                return false;
+        }
+
+        /// <summary>
+        /// 另存为后进行的操作
+        /// 重新打开新文档
+        /// </summary>
+        /// <param name="targetPath"></param>
+        public void DoAfterSaveAs(string targetPath)
+        {
+            App.OpenedFileList.Remove(targetPath);
+            string oldFilePath = targetPath;
+
+            PDFViewer.UndoManager.CanSave = false;
+
+            mainViewModel.OpenFile(targetPath);
+            //TODO:通知各模块更新PDFview对象
+            //var result = OpenFile(targetPath, true);
+
+            //if (result)
+            //{
+            //    FileChanged.Invoke(this, null);
+            //    Zoomer.PdfViewer = PdfViewer;
+            //    PageSelector.PdfViewer = PdfViewer;
+            //    ViewModeSelector.PdfViewer = PdfViewer;
+
+            //    OpenFileInfo fileInfo = SettingHelper.GetFileInfo(oldFilePath);
+            //    if (fileInfo != null)
+            //    {
+            //        PdfViewer.ChangeViewMode(fileInfo.LastViewMode);
+            //        PdfViewer.ChangeFitMode(fileInfo.LastFitMode);
+            //        if (fileInfo.LastFitMode == FitMode.FitFree)
+            //            PdfViewer.Zoom(fileInfo.LastZoom);
+
+            //        PdfViewer.GoToPage(fileInfo.LastPageIndex);
+            //        if (fileInfo.LastDrawMode == DrawModes.Draw_Mode_Custom && fileInfo.LastFillColor != 0)
+            //            PdfViewer.SetDrawMode(fileInfo.LastDrawMode, fileInfo.LastFillColor);
+            //        else
+            //            PdfViewer.SetDrawMode(fileInfo.LastDrawMode);
+            //    }
+            //}
+        }
+
         /// <summary>
         /// 显示前添加内容到Region
         /// </summary>

+ 92 - 6
PDF Office/Views/Dialog/HomePageToolsDialogs/HomePageBatchProcessing/HomePageBatchProcessingDialog.xaml

@@ -9,13 +9,99 @@
              d:DesignWidth="892"
              mc:Ignorable="d">
     <UserControl.Resources>
-        <Style TargetType="{x:Type TabItem}">
-            <Setter Property="Width" Value="106"/>
-            <Setter Property="Height" Value="32"/>
-            <Setter Property="Header" Value="{Binding DataContext.Title}"></Setter>
-        </Style>
+        <ResourceDictionary>
+            <ResourceDictionary.MergedDictionaries>
+                <ResourceDictionary Source="../../../../Styles/CustomBtnStyle.xaml"/>
+            </ResourceDictionary.MergedDictionaries>
+        </ResourceDictionary>
     </UserControl.Resources>
     <Grid>
-        <TabControl x:Name="BatchProcessingTabControl" prism:RegionManager.RegionName="{Binding BatchProcessingRegionName}" SelectedIndex="{Binding BatchProcessingSelectedIndex}"></TabControl>
+        <Grid.RowDefinitions>
+            <RowDefinition Height="32"/>
+            <RowDefinition/>
+        </Grid.RowDefinitions>
+        <StackPanel Orientation="Horizontal" HorizontalAlignment="Center">
+            <Button x:Name="ShiftingBtn" Style="{StaticResource HomePageCompressBtn}" Tag="0"  Width="106" Command="{Binding DelegateChangeBatchProcessingCommand}" CommandParameter="{Binding ElementName=ShiftingBtn,Path=Tag}" Click="Btn_Click">
+                <StackPanel Orientation="Vertical"  >
+                    <Border HorizontalAlignment="Center">
+                        <TextBlock Text="转档" FontSize="18"></TextBlock>
+                    </Border>
+                    <Border Margin="0,4,0,0">
+                        <Path  VerticalAlignment="Center" HorizontalAlignment="Center" Stroke="Black"  Data="M0 0L4 0 L18 0" Height="2" Stretch="Fill" Name="ShiftingPath"/>
+                    </Border>
+                </StackPanel>
+            </Button>
+            <Button x:Name="CompressBtn" Tag="1" Width="106" Style="{StaticResource HomePageCompressBtn}"  Command="{Binding DelegateChangeBatchProcessingCommand}" CommandParameter="{Binding ElementName=CompressBtn,Path=Tag}" Click="Btn_Click">
+                <StackPanel Orientation="Vertical"  >
+                    <Border HorizontalAlignment="Center">
+                        <TextBlock Text="压缩" FontSize="18"></TextBlock>
+                    </Border>
+                    <Border Margin="0,4,0,0">
+                        <Path  VerticalAlignment="Center" HorizontalAlignment="Center" Stroke="Black"  Data="M0 0L4 0 L18 0" Height="2" Stretch="Fill" Name="CompressPath"/>
+                    </Border>
+                </StackPanel>
+            </Button>
+            <Button x:Name="SecurityBtn" Tag="2" Width="106" Style="{StaticResource HomePageCompressBtn}" Command="{Binding DelegateChangeBatchProcessingCommand}" CommandParameter="{Binding ElementName=SecurityBtn,Path=Tag}" Click="Btn_Click">
+                <StackPanel Orientation="Vertical"  >
+                    <Border HorizontalAlignment="Center">
+                        <TextBlock Text="安全" FontSize="18"></TextBlock>
+                    </Border>
+                    <Border Margin="0,4,0,0">
+                        <Path  VerticalAlignment="Center" HorizontalAlignment="Center" Stroke="Black"  Data="M0 0L4 0 L18 0" Height="2" Stretch="Fill" Name="SecurityPath"/>
+                    </Border>
+                </StackPanel>
+            </Button >
+            <Button x:Name="WatermarkBtn" Tag="3" Width="118" Style="{StaticResource HomePageCompressBtn}" Command="{Binding DelegateChangeBatchProcessingCommand}" CommandParameter="{Binding ElementName=WatermarkBtn,Path=Tag}" Click="Btn_Click">
+                <StackPanel Orientation="Vertical"  >
+                    <Border HorizontalAlignment="Center">
+                        <TextBlock Text="水印" FontSize="18"></TextBlock>
+                    </Border>
+                    <Border Margin="0,4,0,0">
+                        <Path  VerticalAlignment="Center" HorizontalAlignment="Center" Stroke="Black"  Data="M0 0L4 0 L18 0" Height="2" Stretch="Fill" Name="WatermarkPath"/>
+                    </Border>
+                </StackPanel>
+            </Button>
+            <Button x:Name="BackgroundBtn" Tag="4" Width="106" Style="{StaticResource HomePageCompressBtn}" Command="{Binding DelegateChangeBatchProcessingCommand}" CommandParameter="{Binding ElementName=BackgroundBtn,Path=Tag}" Click="Btn_Click">
+                <StackPanel Orientation="Vertical"  >
+                    <Border HorizontalAlignment="Center">
+                        <TextBlock Text="背景" FontSize="18"></TextBlock>
+                    </Border>
+                    <Border Margin="0,4,0,0">
+                        <Path  VerticalAlignment="Center" HorizontalAlignment="Center" Stroke="Black"  Data="M0 0L4 0 L18 0" Height="2" Stretch="Fill" Name="BackgroundPath"/>
+                    </Border>
+                </StackPanel>
+            </Button>
+            <Button x:Name="HeaderFooterBtn" Tag="5" Width="106" Style="{StaticResource HomePageCompressBtn}" Command="{Binding DelegateChangeBatchProcessingCommand}" CommandParameter="{Binding ElementName=HeaderFooterBtn,Path=Tag}" Click="Btn_Click">
+                <StackPanel Orientation="Vertical"  >
+                    <Border HorizontalAlignment="Center">
+                        <TextBlock Text="页眉页脚" FontSize="18"></TextBlock>
+                    </Border>
+                    <Border Margin="0,4,0,0">
+                        <Path  VerticalAlignment="Center" HorizontalAlignment="Center" Stroke="Black"  Data="M0 0L4 0 L18 0" Height="2" Stretch="Fill" Name="HeaderFooterPath"/>
+                    </Border>
+                </StackPanel>
+            </Button>
+            <Button x:Name="BatesBtn" Tag="6" Width="106" Style="{StaticResource HomePageCompressBtn}" Command="{Binding DelegateChangeBatchProcessingCommand}" CommandParameter="{Binding ElementName=BatesBtn,Path=Tag}" Click="Btn_Click">
+                <StackPanel Orientation="Vertical"  >
+                    <Border HorizontalAlignment="Center">
+                        <TextBlock Text="Bates码" FontSize="18"></TextBlock>
+                    </Border>
+                    <Border Margin="0,4,0,0">
+                        <Path  VerticalAlignment="Center" HorizontalAlignment="Center" Stroke="Black"  Data="M0 0L4 0 L18 0" Height="2" Stretch="Fill" Name="BatesPath"/>
+                    </Border>
+                </StackPanel>
+            </Button>
+            <Button x:Name="RemoveSecurityBtn" Tag="7" Width="106" Style="{StaticResource HomePageCompressBtn}" Command="{Binding DelegateChangeBatchProcessingCommand}" CommandParameter="{Binding ElementName=RemoveSecurityBtn,Path=Tag}" Click="Btn_Click">
+                <StackPanel Orientation="Vertical"  >
+                    <Border HorizontalAlignment="Center">
+                        <TextBlock Text="批量移除" FontSize="18"></TextBlock>
+                    </Border>
+                    <Border Margin="0,4,0,0">
+                        <Path  VerticalAlignment="Center" HorizontalAlignment="Center" Stroke="Black"  Data="M0 0L4 0 L18 0" Height="2" Stretch="Fill" Name="RemoveSecurityPath"/>
+                    </Border>
+                </StackPanel>
+            </Button>
+        </StackPanel>
+        <ContentControl x:Name="PrintMod" prism:RegionManager.RegionName="{Binding BatchProcessingRegionName}"   Visibility="{Binding BatchProcessingVisible}" Grid.Row="1"/>
     </Grid>
 </UserControl>

+ 208 - 2
PDF Office/Views/Dialog/HomePageToolsDialogs/HomePageBatchProcessing/HomePageBatchProcessingDialog.xaml.cs

@@ -1,4 +1,7 @@
-using Prism.Ioc;
+using PDF_Office.Model.Dialog.HomePageToolsDialogs.HomePageBatchProcessing;
+using PDF_Office.ViewModels.Dialog.HomePageToolsDialogs;
+using PDF_Office.ViewModels.Dialog.HomePageToolsDialogs.HomePageBatchProcessing;
+using Prism.Ioc;
 using Prism.Regions;
 using System.Windows.Controls;
 
@@ -18,8 +21,211 @@ namespace PDF_Office.Views.Dialog.HomePageToolsDialogs.HomePageBatchProcessing
             var regionManager = containerProvider.Resolve<IRegionManager>();
             RegionManager.SetRegionManager(this, regionManager);
             RegionManager.UpdateRegions();
-            this.BatchProcessingTabControl.SelectedIndex = 0;
+            SetPathVisibility(HomePageBatchProcessingDialogModel.BatchProcessingIndex);
+        }
+
+        public void SetPathVisibility(int index) {
+            this.BatesPath.Visibility = System.Windows.Visibility.Hidden;
+            this.SecurityPath.Visibility = System.Windows.Visibility.Hidden;
+            this.ShiftingPath.Visibility = System.Windows.Visibility.Hidden;
+            this.WatermarkPath.Visibility = System.Windows.Visibility.Hidden;
+            this.HeaderFooterPath.Visibility = System.Windows.Visibility.Hidden;
+            this.BackgroundPath.Visibility = System.Windows.Visibility.Hidden;
+            this.CompressPath.Visibility = System.Windows.Visibility.Hidden;
+            this.RemoveSecurityPath.Visibility = System.Windows.Visibility.Hidden;
+            switch (index) { 
+                case 0:
+                    this.ShiftingPath.Visibility = System.Windows.Visibility.Visible;
+                    break;
+                case 1:
+                    this.CompressPath.Visibility = System.Windows.Visibility.Visible;
+                    break;
+                case 2:
+                    this.SecurityPath.Visibility = System.Windows.Visibility.Visible;
+                    break;
+                case 3:
+                    this.WatermarkPath.Visibility = System.Windows.Visibility.Visible;
+                    break;
+                case 4:
+                    this.BackgroundPath.Visibility = System.Windows.Visibility.Visible;
+                    break;
+                case 5:
+                    this.HeaderFooterPath.Visibility = System.Windows.Visibility.Visible;
+                    break;
+                case 6:
+                    this.BatesPath.Visibility = System.Windows.Visibility.Visible;
+                    break;
+                case 7:
+                    this.RemoveSecurityPath.Visibility = System.Windows.Visibility.Visible;
+                    break;
+            }
+        }
+
+        private void Btn_Click(object sender, System.Windows.RoutedEventArgs e)
+        {
+            var btn = sender as Button;
+            if (btn != null) {
+                switch (btn.Name.ToString())
+                {
+                    case "BatesBtn":
+                        this.BatesBtn.IsEnabled = false;
+                        this.SecurityBtn.IsEnabled = true;
+                        this.ShiftingBtn.IsEnabled = true;
+                        this.WatermarkBtn.IsEnabled = true;
+                        this.HeaderFooterBtn.IsEnabled = true;
+                        this.BackgroundBtn.IsEnabled = true;
+                        this.CompressBtn.IsEnabled = true;
+                        this.RemoveSecurityBtn.IsEnabled = true;
+
+                        this.BatesPath.Visibility = System.Windows.Visibility.Visible;
+                        this.SecurityPath.Visibility = System.Windows.Visibility.Hidden;
+                        this.ShiftingPath.Visibility = System.Windows.Visibility.Hidden;
+                        this.WatermarkPath.Visibility = System.Windows.Visibility.Hidden;
+                        this.HeaderFooterPath.Visibility = System.Windows.Visibility.Hidden;
+                        this.BackgroundPath.Visibility = System.Windows.Visibility.Hidden;
+                        this.CompressPath.Visibility = System.Windows.Visibility.Hidden;
+                        this.RemoveSecurityPath.Visibility = System.Windows.Visibility.Hidden;
+                        break;
+                    case "SecurityBtn":
+                        this.BatesBtn.IsEnabled =true;
+                        this.SecurityBtn.IsEnabled = false;
+                        this.ShiftingBtn.IsEnabled = true;
+                        this.WatermarkBtn.IsEnabled = true;
+                        this.HeaderFooterBtn.IsEnabled = true;
+                        this.BackgroundBtn.IsEnabled = true;
+                        this.CompressBtn.IsEnabled = true;
+                        this.RemoveSecurityBtn.IsEnabled = true;
+
+                        this.BatesPath.Visibility = System.Windows.Visibility.Hidden;
+                        this.SecurityPath.Visibility = System.Windows.Visibility.Visible;
+                        this.ShiftingPath.Visibility = System.Windows.Visibility.Hidden;
+                        this.WatermarkPath.Visibility = System.Windows.Visibility.Hidden;
+                        this.HeaderFooterPath.Visibility = System.Windows.Visibility.Hidden;
+                        this.BackgroundPath.Visibility = System.Windows.Visibility.Hidden;
+                        this.CompressPath.Visibility = System.Windows.Visibility.Hidden;
+                        this.RemoveSecurityPath.Visibility = System.Windows.Visibility.Hidden;
+                        break;
+                   
+                    case "ShiftingBtn":
+                        this.BatesBtn.IsEnabled = true;
+                        this.SecurityBtn.IsEnabled = true;
+                        this.ShiftingBtn.IsEnabled = false;
+                        this.WatermarkBtn.IsEnabled = true;
+                        this.HeaderFooterBtn.IsEnabled = true;
+                        this.BackgroundBtn.IsEnabled = true;
+                        this.CompressBtn.IsEnabled = true;
+                        this.RemoveSecurityBtn.IsEnabled = true;
+
+                        this.BatesPath.Visibility = System.Windows.Visibility.Hidden;
+                        this.SecurityPath.Visibility = System.Windows.Visibility.Hidden;
+                        this.ShiftingPath.Visibility = System.Windows.Visibility.Visible;
+                        this.WatermarkPath.Visibility = System.Windows.Visibility.Hidden;
+                        this.HeaderFooterPath.Visibility = System.Windows.Visibility.Hidden;
+                        this.BackgroundPath.Visibility = System.Windows.Visibility.Hidden;
+                        this.CompressPath.Visibility = System.Windows.Visibility.Hidden;
+                        this.RemoveSecurityPath.Visibility = System.Windows.Visibility.Hidden;
+                        break;
+                    case "WatermarkBtn":
+                        this.BatesBtn.IsEnabled = true;
+                        this.SecurityBtn.IsEnabled = true;
+                        this.ShiftingBtn.IsEnabled = true;
+                        this.WatermarkBtn.IsEnabled = false;
+                        this.HeaderFooterBtn.IsEnabled = true;
+                        this.BackgroundBtn.IsEnabled = true;
+                        this.CompressBtn.IsEnabled = true;
+                        this.RemoveSecurityBtn.IsEnabled = true;
+                        this.BatesPath.Visibility = System.Windows.Visibility.Hidden;
+                        this.SecurityPath.Visibility = System.Windows.Visibility.Hidden;
+                        this.ShiftingPath.Visibility = System.Windows.Visibility.Hidden;
+                        this.WatermarkPath.Visibility = System.Windows.Visibility.Visible;
+                        this.HeaderFooterPath.Visibility = System.Windows.Visibility.Hidden;
+                        this.BackgroundPath.Visibility = System.Windows.Visibility.Hidden;
+                        this.CompressPath.Visibility = System.Windows.Visibility.Hidden;
+                        this.RemoveSecurityPath.Visibility = System.Windows.Visibility.Hidden;
+                        break;
+                    case "HeaderFooterBtn":
+                        this.BatesBtn.IsEnabled = true;
+                        this.SecurityBtn.IsEnabled = true;
+                        this.ShiftingBtn.IsEnabled = true;
+                        this.WatermarkBtn.IsEnabled = true;
+                        this.HeaderFooterBtn.IsEnabled = false;
+                        this.BackgroundBtn.IsEnabled = true;
+                        this.CompressBtn.IsEnabled = true;
+                        this.RemoveSecurityBtn.IsEnabled = true;
 
+                        this.BatesPath.Visibility = System.Windows.Visibility.Hidden;
+                        this.SecurityPath.Visibility = System.Windows.Visibility.Hidden;
+                        this.ShiftingPath.Visibility = System.Windows.Visibility.Hidden;
+                        this.WatermarkPath.Visibility = System.Windows.Visibility.Hidden;
+                        this.HeaderFooterPath.Visibility = System.Windows.Visibility.Visible;
+                        this.BackgroundPath.Visibility = System.Windows.Visibility.Hidden;
+                        this.CompressPath.Visibility = System.Windows.Visibility.Hidden;
+                        this.RemoveSecurityPath.Visibility = System.Windows.Visibility.Hidden;
+                        break;
+                    case "BackgroundBtn":
+
+                        this.BatesBtn.IsEnabled = true;
+                        this.SecurityBtn.IsEnabled = true;
+                        this.ShiftingBtn.IsEnabled = true;
+                        this.WatermarkBtn.IsEnabled = true;
+                        this.HeaderFooterBtn.IsEnabled = true;
+                        this.BackgroundBtn.IsEnabled = false;
+                        this.CompressBtn.IsEnabled = true;
+                        this.RemoveSecurityBtn.IsEnabled = true;
+
+                        this.BatesPath.Visibility = System.Windows.Visibility.Hidden;
+                        this.SecurityPath.Visibility = System.Windows.Visibility.Hidden;
+                        this.ShiftingPath.Visibility = System.Windows.Visibility.Hidden;
+                        this.WatermarkPath.Visibility = System.Windows.Visibility.Hidden;
+                        this.HeaderFooterPath.Visibility = System.Windows.Visibility.Hidden;
+                        this.BackgroundPath.Visibility = System.Windows.Visibility.Visible;
+                        this.CompressPath.Visibility = System.Windows.Visibility.Hidden;
+                        this.RemoveSecurityPath.Visibility = System.Windows.Visibility.Hidden;
+                        break;
+                    case "CompressBtn":
+                        this.BatesBtn.IsEnabled = true;
+                        this.SecurityBtn.IsEnabled = true;
+                        this.ShiftingBtn.IsEnabled = true;
+                        this.WatermarkBtn.IsEnabled = true;
+                        this.HeaderFooterBtn.IsEnabled = true;
+                        this.BackgroundBtn.IsEnabled = true;
+                        this.CompressBtn.IsEnabled = false;
+                        this.RemoveSecurityBtn.IsEnabled = true;
+
+                        this.BatesPath.Visibility = System.Windows.Visibility.Hidden;
+                        this.SecurityPath.Visibility = System.Windows.Visibility.Hidden;
+                        this.ShiftingPath.Visibility = System.Windows.Visibility.Hidden;
+                        this.WatermarkPath.Visibility = System.Windows.Visibility.Hidden;
+                        this.HeaderFooterPath.Visibility = System.Windows.Visibility.Hidden;
+                        this.BackgroundPath.Visibility = System.Windows.Visibility.Hidden;
+                        this.CompressPath.Visibility = System.Windows.Visibility.Visible;
+                        this.RemoveSecurityPath.Visibility = System.Windows.Visibility.Hidden;
+                        break;
+                    case "RemoveSecurityBtn":
+                        this.BatesBtn.IsEnabled = true;
+                        this.SecurityBtn.IsEnabled = true;
+                        this.ShiftingBtn.IsEnabled = true;
+                        this.WatermarkBtn.IsEnabled = true;
+                        this.HeaderFooterBtn.IsEnabled = true;
+                        this.BackgroundBtn.IsEnabled = true;
+                        this.CompressBtn.IsEnabled = true;
+                        this.RemoveSecurityBtn.IsEnabled = false;
+
+                        this.BatesPath.Visibility = System.Windows.Visibility.Hidden;
+                        this.SecurityPath.Visibility = System.Windows.Visibility.Hidden;
+                        this.ShiftingPath.Visibility = System.Windows.Visibility.Hidden;
+                        this.WatermarkPath.Visibility = System.Windows.Visibility.Hidden;
+                        this.HeaderFooterPath.Visibility = System.Windows.Visibility.Hidden;
+                        this.BackgroundPath.Visibility = System.Windows.Visibility.Hidden;
+                        this.CompressPath.Visibility = System.Windows.Visibility.Hidden;
+                        this.RemoveSecurityPath.Visibility = System.Windows.Visibility.Visible;
+                        break;
+
+
+                }
+            
+            
+            }
         }
     }
 }

+ 13 - 12
PDF Office/Views/Dialog/HomePageToolsDialogs/HomePageBatchProcessing/HomePageCompressDialog.xaml

@@ -15,19 +15,19 @@
         </ResourceDictionary>
     </UserControl.Resources>
 
-    <Grid>
+    <Grid IsEnabled="{Binding CompressGridIsEnabled}">
         <Grid.ColumnDefinitions>
             <ColumnDefinition Width="632"/>
             <ColumnDefinition Width="260"/>
         </Grid.ColumnDefinitions>
         <Grid Grid.Column="0">
             <Grid.RowDefinitions>
-                <RowDefinition Height="482"/>
+                <RowDefinition Height="398"/>
                 <RowDefinition Height="72"/>
             </Grid.RowDefinitions>
-            <Button Name="BtnBlank" Grid.Row="0" Background="Green" Height="400" Width="400" Visibility="{Binding AddFileVisibility}" >
+            <Button Name="BtnBlank" Grid.Row="0" Background="Green" Height="300" Width="300" Visibility="{Binding AddFileVisibility}" Command="{Binding ADDPDFCommand}" >
             </Button>
-            <ListView x:Name="listView" DataContext="{Binding ImagesDataTable}" Grid.Row="0" Background="White"  ItemsSource="{Binding}" SelectionChanged="listView_SelectionChanged" >
+            <ListView x:Name="listView" DataContext="{Binding PDFDataTable,Mode=TwoWay}" Grid.Row="0" Background="White"  ItemsSource="{Binding}" SelectionChanged="listView_SelectionChanged" Visibility="{Binding ElementName=BtnBlank, Path=Visibility, Converter={StaticResource unVisibleConvert}}">
                 <ListView.ContextMenu>
                     <ContextMenu  StaysOpen="True" >
                         <MenuItem Header="打开文件" Name="OpenFileMenuItem"  Click="OpenFileMenuItem_Click"/>
@@ -79,8 +79,8 @@
                                 <DropShadowEffect ShadowDepth="0" Color="#FFB6B6B6"/>
                             </Border.Effect>
                             <StackPanel Margin="0">
-                                <MenuItem x:Name="添加文件" Header="添加文件"></MenuItem>
-                                <MenuItem x:Name="添加文件夹" Header="添加文件夹"></MenuItem>
+                                <MenuItem x:Name="添加文件" Header="添加文件" Command="{Binding ADDPDFCommand}"></MenuItem>
+                                <MenuItem x:Name="添加文件夹" Header="添加文件夹" Command="{Binding ADDPDFFilesCommand}"></MenuItem>
                             </StackPanel>
                         </Border>
                     </Grid>
@@ -99,33 +99,34 @@
                     Margin="25,0"
                     HorizontalAlignment="Right"
                     IsEnabled="{Binding RemoveIsEnable}"
+                    Command="{Binding RemovePDFFileCommand}"
                     >
 
                 </Button>
             </Grid>
         </Grid>
-        <Grid Grid.Column="1" Background="WhiteSmoke">
+        <Grid Grid.Column="1" Background="WhiteSmoke" IsEnabled="{Binding SetCompressGridIsEnabled}">
             <Grid.RowDefinitions>
                 <RowDefinition Height="*"/>
                 <RowDefinition Height="72"/>
             </Grid.RowDefinitions>
             <StackPanel Orientation="Vertical" Margin="15,16,0,0" Grid.Row="0">
                 <TextBlock Text="优化选项"/>
-                <RadioButton Click="RadioButton_Click" Margin="0,8,0,0">
+                <RadioButton Name="LargeQualityRadioBtn" Command="{Binding RadioButtonCommand}" CommandParameter="{Binding ElementName=LargeQualityRadioBtn,Path=Name}" Margin="0,8,0,0">
                     <TextBlock Text="大型文件"/>
                 </RadioButton>
-                <RadioButton Click="RadioButton_Click" Margin="0,8,0,0">
+                <RadioButton Name="StandardQualityRadioBtn" Command="{Binding RadioButtonCommand}" CommandParameter="{Binding ElementName=StandardQualityRadioBtn,Path=Name}" Margin="0,8,0,0">
                     <TextBlock Text="标准文件"/>
                 </RadioButton>
-                <RadioButton Click="RadioButton_Click" Margin="0,8,0,0">
+                <RadioButton Name="LittleQualityRadioBtn" Command="{Binding RadioButtonCommand}" CommandParameter="{Binding ElementName=LittleQualityRadioBtn,Path=Name}" Margin="0,8,0,0">
                     <TextBlock Text="小型文件"/>
                 </RadioButton>
-                <RadioButton Click="RadioButton_Click" Margin="0,8,0,0">
+                <RadioButton Name="MicroQualityRadioBtn" Command="{Binding RadioButtonCommand}" CommandParameter="{Binding ElementName=MicroQualityRadioBtn,Path=Name}" Margin="0,8,0,0">
                     <TextBlock Text="微型文件"/>
                 </RadioButton>
             </StackPanel>
             <Grid Grid.Row="2">
-                <Button Height="40" Width="228" Background="Black">
+                <Button Height="40" Width="228" Background="Black" Command="{Binding CompressCommand}">
                     <TextBlock Text="压缩" FontSize="18" Foreground="White"/>
                 </Button>
             </Grid>

+ 17 - 12
PDF Office/Views/Dialog/HomePageToolsDialogs/HomePageBatchProcessing/HomePageCompressDialog.xaml.cs

@@ -1,4 +1,6 @@
-using System.Collections;
+using PDF_Office.ViewModels.Dialog.HomePageToolsDialogs;
+using PDF_Office.ViewModels.Dialog.HomePageToolsDialogs.HomePageBatchProcessing;
+using System.Collections;
 using System.Windows.Controls;
 
 namespace PDF_Office.Views.Dialog.HomePageToolsDialogs.HomePageBatchProcessing
@@ -8,12 +10,9 @@ namespace PDF_Office.Views.Dialog.HomePageToolsDialogs.HomePageBatchProcessing
     /// </summary>
     public partial class HomePageCompressDialog : UserControl
     {
-        public string Title { get; set; }
         public HomePageCompressDialog()
         {
             InitializeComponent();
-            Title = "压缩";
-            this.DataContext = this;
         }
         private void Menu_Click(object sender, System.Windows.RoutedEventArgs e)
         {
@@ -24,27 +23,33 @@ namespace PDF_Office.Views.Dialog.HomePageToolsDialogs.HomePageBatchProcessing
         {
             IList list = listView.SelectedItems;
             var lists = listView.Items;
-            System.Data.DataRowView datarowview;
+            System.Data.DataRowView a;
+            ((HomePageCompressDialogViewModel)this.DataContext).fileNamesView.Clear();
             foreach (var item in list)
             {
-                datarowview = (System.Data.DataRowView)item;
+                a = (System.Data.DataRowView)item;
+                ((HomePageCompressDialogViewModel)this.DataContext).fileNamesView.Add(lists.IndexOf(a));
+            }
+            if (((HomePageCompressDialogViewModel)this.DataContext).fileNamesView.Count > 0)
+            {
+                ((HomePageCompressDialogViewModel)this.DataContext).RemoveIsEnable = "True";
+            }
+            else
+            {
+                ((HomePageCompressDialogViewModel)this.DataContext).RemoveIsEnable = "False";
             }
 
         }
 
         private void RemoveFileMenuItem_Click(object sender, System.Windows.RoutedEventArgs e)
         {
-
+            ((HomePageCompressDialogViewModel)this.DataContext).removepdffile();
         }
 
         private void OpenFileMenuItem_Click(object sender, System.Windows.RoutedEventArgs e)
         {
-
+            ((HomePageCompressDialogViewModel)this.DataContext).openfiledialog();
         }
 
-        private void RadioButton_Click(object sender, System.Windows.RoutedEventArgs e)
-        {
-
-        }
     }
 }

+ 18 - 14
PDF Office/Views/Dialog/HomePageToolsDialogs/HomePageBatchProcessing/HomePageSetPasswordDialog.xaml

@@ -15,19 +15,19 @@
         </ResourceDictionary>
     </UserControl.Resources>
 
-    <Grid>
+    <Grid IsEnabled="{Binding SafetyGridIsEnabled}">
         <Grid.ColumnDefinitions>
             <ColumnDefinition Width="632"/>
             <ColumnDefinition Width="260"/>
         </Grid.ColumnDefinitions>
         <Grid Grid.Column="0">
             <Grid.RowDefinitions>
-                <RowDefinition Height="482"/>
+                <RowDefinition Height="398"/>
                 <RowDefinition Height="72"/>
             </Grid.RowDefinitions>
-            <Button Name="BtnBlank" Grid.Row="0" Background="Green" Height="400" Width="400" Visibility="{Binding AddFileVisibility}" >
+            <Button Name="BtnBlank" Grid.Row="0" Background="Green" Height="300" Width="300" Visibility="{Binding AddFileVisibility}" Command="{Binding ADDPDFCommand}">
             </Button>
-            <ListView x:Name="listView" DataContext="{Binding ImagesDataTable}" Grid.Row="0" Background="White"  ItemsSource="{Binding}" SelectionChanged="listView_SelectionChanged" >
+            <ListView x:Name="listView" DataContext="{Binding PDFDataTable,Mode=TwoWay}" Grid.Row="0" Background="White"  ItemsSource="{Binding}" SelectionChanged="listView_SelectionChanged"  Visibility="{Binding ElementName=BtnBlank, Path=Visibility, Converter={StaticResource unVisibleConvert}}">
                 <ListView.ContextMenu>
                     <ContextMenu  StaysOpen="True" >
                         <MenuItem Header="打开文件" Name="OpenFileMenuItem"  Click="OpenFileMenuItem_Click"/>
@@ -79,8 +79,8 @@
                                 <DropShadowEffect ShadowDepth="0" Color="#FFB6B6B6"/>
                             </Border.Effect>
                             <StackPanel Margin="0">
-                                <MenuItem x:Name="添加文件" Header="添加文件" ></MenuItem>
-                                <MenuItem x:Name="添加文件夹" Header="添加文件夹" ></MenuItem>
+                                <MenuItem x:Name="添加文件" Header="添加文件" Command="{Binding ADDPDFCommand}"></MenuItem>
+                                <MenuItem x:Name="添加文件夹" Header="添加文件夹" Command="{Binding ADDPDFFilesCommand}"></MenuItem>
                             </StackPanel>
                         </Border>
                     </Grid>
@@ -99,12 +99,12 @@
                     Margin="25,0"
                     HorizontalAlignment="Right"
                     IsEnabled="{Binding RemoveIsEnable}"
-                    >
+                    Command="{Binding RemovePDFFileCommand}">
 
                 </Button>
             </Grid>
         </Grid>
-        <Grid Grid.Column="1" Background="WhiteSmoke">
+        <Grid Grid.Column="1" Background="WhiteSmoke" IsEnabled="{Binding SetSafetyGridIsEnabled}">
             <Grid.RowDefinitions>
                 <RowDefinition Height="*"/>
                 <RowDefinition Height="*"/>
@@ -114,7 +114,7 @@
                 <StackPanel Margin="15,23,0,0">
                     <TextBlock Text="设置密码" Width="48" Height="20" HorizontalAlignment="Left"/>
                     <StackPanel Margin="0,11,0,0">
-                        <CheckBox x:Name="CanOpenCheckBox" IsChecked="{Binding CanOpen}" Margin="0,0,0,10" >
+                        <CheckBox x:Name="CanOpenCheckBox" IsChecked="{Binding CanOpen}" Margin="0,0,0,10" Command="{Binding DelegateSetOpenCommand}">
                             <TextBlock Text="开启文档口令"></TextBlock>
                         </CheckBox>
                         <Grid HorizontalAlignment="Left" Width="228">
@@ -135,7 +135,7 @@
                         </Grid>
                     </StackPanel>
                     <StackPanel Margin="0,17,0,0">
-                        <CheckBox IsChecked="{Binding CanEdit}" Name="CanEditCheckBox" Margin="0,0,0,10"  >
+                        <CheckBox IsChecked="{Binding CanEdit}" Name="CanEditCheckBox" Margin="0,0,0,10"  Command="{Binding  DelegateSetEditCommand}">
                             <TextBlock Text="许可口令"></TextBlock>
                         </CheckBox>
                         <Grid HorizontalAlignment="Left" Width="228">
@@ -161,15 +161,19 @@
             <Grid Grid.Row="1">
                 <StackPanel Margin="15,0,0,0">
                     <TextBlock Text="允许打印" Width="48" Height="20" HorizontalAlignment="Left"/>
-                    <ComboBox Height="24" Width="228" HorizontalAlignment="Left" Margin="0,8.5,0,0" ></ComboBox>
+                    <ComboBox Height="24" Width="228" HorizontalAlignment="Left" Margin="0,8.5,0,0"  SelectedIndex="{Binding PrintMod,Mode=TwoWay}" IsEnabled="{Binding ElementName=CanEditCheckBox, Path=IsChecked}"></ComboBox>
                     <TextBlock Text="允许更改" Margin="0,20.5,0,0" Width="48" Height="20" HorizontalAlignment="Left"/>
-                    <ComboBox Height="24" Width="228" HorizontalAlignment="Left" Margin="0,8.5,0,0" ></ComboBox>
+                    <ComboBox Height="24" Width="228" HorizontalAlignment="Left" Margin="0,8.5,0,0" SelectedIndex="{Binding ChangeMod,Mode=TwoWay}" IsEnabled="{Binding ElementName=CanEditCheckBox, Path=IsChecked}"></ComboBox>
                     <TextBlock Text="加密级别" Width="48" Height="20" HorizontalAlignment="Left" Margin="0,20.5,0,0"/>
-                    <ComboBox Height="24" Width="228" HorizontalAlignment="Left" Margin="0,8.5,0,0" ></ComboBox>
+                    <ComboBox Height="24" Width="228" HorizontalAlignment="Left" Margin="0,8.5,0,0" >
+                        <ComboBoxItem Tag="0">128-bit-RC4</ComboBoxItem>
+                        <ComboBoxItem Tag="1">128-bit-AES</ComboBoxItem>
+                        <ComboBoxItem Tag="2">256 -bit-AES</ComboBoxItem>
+                    </ComboBox>
                 </StackPanel>
             </Grid>
             <Grid Grid.Row="2">
-                <Button Height="40" Width="228" Background="Black">
+                <Button Height="40" Width="228" Background="Black" Command="{Binding DelegateConfirmEncryptCommand}" IsEnabled="{Binding IsEnabledConfirm, Mode=TwoWay}">
                     <TextBlock Text="设置安全密码" FontSize="18" Foreground="White"/>
                 </Button>
             </Grid>

+ 27 - 17
PDF Office/Views/Dialog/HomePageToolsDialogs/HomePageBatchProcessing/HomePageSetPasswordDialog.xaml.cs

@@ -1,5 +1,6 @@
-using PDF_Office.Model.Dialog.ToolsDialogs.SaftyDialogs;
-using PDF_Office.ViewModels.Dialog.ToolsDialogs.SaftyDialogs;
+using PDF_Office.Model.Dialog.HomePageToolsDialogs.HomePageBatchProcessing;
+using PDF_Office.Model.Dialog.ToolsDialogs.SaftyDialogs;
+using PDF_Office.ViewModels.Dialog.HomePageToolsDialogs.HomePageBatchProcessing;
 using System;
 using System.Collections;
 using System.Windows;
@@ -12,7 +13,6 @@ namespace PDF_Office.Views.Dialog.HomePageToolsDialogs.HomePageBatchProcessing
     /// </summary>
     public partial class HomePageSetPasswordDialog : UserControl
     {
-        public string Title { get; set; }
 
         private Boolean canOpenPasswordBoxHasFocus = false;
         private Boolean canOpenTextBoxHasFocus = false;
@@ -35,9 +35,9 @@ namespace PDF_Office.Views.Dialog.HomePageToolsDialogs.HomePageBatchProcessing
         public HomePageSetPasswordDialog()
         {
             InitializeComponent();
-            Title = "安全";
-            this.DataContext = this;
         }
+
+
         private void Menu_Click(object sender, System.Windows.RoutedEventArgs e)
         {
             menuPop1.IsOpen = true;
@@ -47,22 +47,32 @@ namespace PDF_Office.Views.Dialog.HomePageToolsDialogs.HomePageBatchProcessing
         {
             IList list = listView.SelectedItems;
             var lists = listView.Items;
-            System.Data.DataRowView datarowview;
+            System.Data.DataRowView a;
+            ((HomePageSetPasswordDialogViewModel)this.DataContext).fileNamesView.Clear();
             foreach (var item in list)
             {
-                datarowview = (System.Data.DataRowView)item;
+                a = (System.Data.DataRowView)item;
+                ((HomePageSetPasswordDialogViewModel)this.DataContext).fileNamesView.Add(lists.IndexOf(a));
+            }
+            if (((HomePageSetPasswordDialogViewModel)this.DataContext).fileNamesView.Count > 0)
+            {
+                ((HomePageSetPasswordDialogViewModel)this.DataContext).RemoveIsEnable = "True";
+            }
+            else
+            {
+                ((HomePageSetPasswordDialogViewModel)this.DataContext).RemoveIsEnable = "False";
             }
 
         }
 
         private void RemoveFileMenuItem_Click(object sender, System.Windows.RoutedEventArgs e)
         {
-
+            ((HomePageSetPasswordDialogViewModel)this.DataContext).removepdffile();
         }
 
         private void OpenFileMenuItem_Click(object sender, System.Windows.RoutedEventArgs e)
         {
-
+            ((HomePageSetPasswordDialogViewModel)this.DataContext).openfiledialog();
         }
 
         private void PasswordBox_GotFocus(object sender, RoutedEventArgs e)
@@ -105,8 +115,8 @@ namespace PDF_Office.Views.Dialog.HomePageToolsDialogs.HomePageBatchProcessing
                     return;
                 }
                 CanOpenTextBox.Text = CanOpenPasswordBox.Password;
-               // SetPasswordDialogModel.PasswordForOpen = CanOpenTextBox.Text;
-                //((SetPasswordDialogViewModel)this.DataContext).DelegateCanOpenTextChangedCommand.Execute();
+                HomePageSetPasswordDialogModel.PasswordForOpen = CanOpenTextBox.Text;
+                ((HomePageSetPasswordDialogViewModel)this.DataContext).DelegateCanOpenTextChangedCommand.Execute();
             }
             else if (passwordBox.Name == canEditPasswordBoxName)
             {
@@ -115,8 +125,8 @@ namespace PDF_Office.Views.Dialog.HomePageToolsDialogs.HomePageBatchProcessing
                     return;
                 }
                 CanEditTextBox.Text = CanEditPasswordBox.Password;
-                //SetPasswordDialogModel.PasswordForEdit = CanEditTextBox.Text;
-                //((SetPasswordDialogViewModel)this.DataContext).DelegateCanOpenTextChangedCommand.Execute();
+                HomePageSetPasswordDialogModel.PasswordForEdit = CanEditTextBox.Text;
+                ((HomePageSetPasswordDialogViewModel)this.DataContext).DelegateCanOpenTextChangedCommand.Execute();
             }
         }
 
@@ -130,16 +140,16 @@ namespace PDF_Office.Views.Dialog.HomePageToolsDialogs.HomePageBatchProcessing
                     return;
                 }
                 CanOpenPasswordBox.Password = CanOpenTextBox.Text;
-                //SetPasswordDialogModel.PasswordForOpen = CanOpenPasswordBox.Password;
-                //((SetPasswordDialogViewModel)this.DataContext).DelegateCanOpenTextChangedCommand.Execute();
+                HomePageSetPasswordDialogModel.PasswordForOpen = CanOpenPasswordBox.Password;
+                ((HomePageSetPasswordDialogViewModel)this.DataContext).DelegateCanOpenTextChangedCommand.Execute();
             }
             else if (textBox.Name == canEditTextBoxName)
             {
                 if (canEditPasswordBoxHasFocus)
                 { return; }
                 CanEditPasswordBox.Password = CanEditTextBox.Text;
-                //SetPasswordDialogModel.PasswordForEdit = CanEditPasswordBox.Password;
-                //((SetPasswordDialogViewModel)this.DataContext).DelegateCanOpenTextChangedCommand.Execute();
+                HomePageSetPasswordDialogModel.PasswordForEdit = CanEditPasswordBox.Password;
+                ((HomePageSetPasswordDialogViewModel)this.DataContext).DelegateCanOpenTextChangedCommand.Execute();
             }
         }
 

+ 2 - 2
PDF Office/Views/Dialog/HomePageToolsDialogs/HomePagePictureToPDFDialog.xaml

@@ -17,7 +17,7 @@
         </ResourceDictionary>
     </UserControl.Resources>
 
-    <Grid>
+    <Grid IsEnabled="{Binding PictureToPDFGridIsEnabled}">
         <Grid.ColumnDefinitions>
             <ColumnDefinition Width="632"/>
             <ColumnDefinition Width="260"/>
@@ -106,7 +106,7 @@
                 </Button>
             </Grid>
         </Grid>
-        <Grid Grid.Column="1" Background="WhiteSmoke">
+        <Grid Grid.Column="1" Background="WhiteSmoke" IsEnabled="{Binding SetPictureToPDFGridIsEnabled}">
             <Grid.RowDefinitions>
                 <RowDefinition Height="*"/>
                 <RowDefinition Height="2*"/>

+ 6 - 1
PDF Office/Views/Dialog/HomePageToolsDialogs/HomePagePrinter/HomePagePrinterDialog.xaml

@@ -127,7 +127,12 @@
                             </StackPanel>
                             <StackPanel>
                                 <Grid>
-                                    <ContentControl Height="180" Margin="12" x:Name="PrintMod" prism:RegionManager.RegionName="{Binding PrintModRegionName}"   Visibility="{Binding PrintModVisible}"/>
+                                    <Grid.ColumnDefinitions>
+                                        <ColumnDefinition Width="69*"/>
+                                        <ColumnDefinition Width="50*"/>
+                                        <ColumnDefinition Width="483*"/>
+                                    </Grid.ColumnDefinitions>
+                                    <ContentControl Height="180" Margin="12,12,12,12" x:Name="PrintMod" prism:RegionManager.RegionName="{Binding PrintModRegionName}"   Visibility="{Binding PrintModVisible}" Grid.ColumnSpan="3"/>
                                 </Grid>
                             </StackPanel>
                         </StackPanel>

+ 14 - 5
PDF Office/Views/Dialog/PageEditDialogs/InsertDialog.xaml

@@ -24,19 +24,28 @@
                     <RowDefinition Height="auto" />
                     <RowDefinition Height="auto" />
                 </Grid.RowDefinitions>
-                <ListBox />
+                <ListBox BorderThickness="0" />
                 <StackPanel Grid.Row="1" Margin="16,0">
                     <TextBlock
                         FontSize="14"
                         FontWeight="SemiBold"
                         Text="页面大小" />
-                    <RadioButton Margin="0,12,0,0" Content="当前页" />
+                    <RadioButton
+                        Margin="0,12,0,0"
+                        Content="当前页"
+                        GroupName="PageSize" />
                     <StackPanel Margin="0,12" Orientation="Horizontal">
-                        <RadioButton VerticalAlignment="Center" Content="标准" />
+                        <RadioButton
+                            VerticalAlignment="Center"
+                            Content="标准"
+                            GroupName="PageSize" />
                         <ComboBox Margin="8,0" />
                     </StackPanel>
                     <StackPanel Margin="0,0,0,12" Orientation="Horizontal">
-                        <RadioButton VerticalAlignment="Center" Content="自定义" />
+                        <RadioButton
+                            VerticalAlignment="Center"
+                            Content="自定义"
+                            GroupName="PageSize" />
                         <TextBox
                             Width="80"
                             Height="32"
@@ -70,7 +79,7 @@
                     Height="32"
                     Margin="16,0"
                     HorizontalAlignment="Right"
-                    Command="{Binding CancelCommnad}"
+                    Command="{Binding CancelCommand}"
                     Content="取消" />
                 <Button
                     Width="98"

+ 41 - 18
PDF Office/Views/Dialog/ToolsDialogs/CompressDialogs/SplitDialog.xaml

@@ -23,27 +23,45 @@
                     <RowDefinition />
                     <RowDefinition />
                 </Grid.RowDefinitions>
-                <StackPanel Margin="16,0">
+                <StackPanel Margin="16,4,16,0">
                     <TextBlock
+                        Margin="0,12"
                         FontSize="14"
                         FontWeight="SemiBold"
                         Text="拆分方式" />
                     <StackPanel Orientation="Horizontal">
-                        <RadioButton Margin="0,12,0,0" Content="平均每" />
+                        <RadioButton
+                            Name="RbtnPage"
+                            Margin="0,12,0,0"
+                            Content="平均每"
+                            IsChecked="True" />
                         <TextBox
                             Width="110"
                             Height="32"
-                            Margin="8,0" />
+                            Margin="8,0"
+                            IsEnabled="{Binding ElementName=RbtnPage, Path=IsChecked}" />
                         <TextBlock VerticalAlignment="Center" Text="页拆分为一个PDF文件" />
                     </StackPanel>
                     <StackPanel Margin="0,12" Orientation="Horizontal">
-                        <RadioButton VerticalAlignment="Center" Content="平均拆分为" />
-                        <ComboBox Width="110" Margin="8,0" />
+                        <RadioButton
+                            Name="RbtnPdf"
+                            VerticalAlignment="Center"
+                            Content="平均拆分为" />
+                        <ComboBox
+                            Width="110"
+                            Margin="8,0"
+                            IsEnabled="{Binding ElementName=RbtnPdf, Path=IsChecked}" />
                         <TextBlock VerticalAlignment="Center" Text="个PDF文件" />
                     </StackPanel>
                     <StackPanel Margin="0,0,0,12" Orientation="Horizontal">
-                        <RadioButton VerticalAlignment="Center" Content="按页面范围拆分" />
-                        <ComboBox Width="110" Margin="8,0" />
+                        <RadioButton
+                            x:Name="RbtnPagerange"
+                            VerticalAlignment="Center"
+                            Content="按页面范围拆分" />
+                        <ComboBox
+                            Width="110"
+                            Margin="8,0"
+                            IsEnabled="{Binding ElementName=RbtnPagerange, Path=IsChecked}" />
                     </StackPanel>
                 </StackPanel>
                 <StackPanel Grid.Row="1" Margin="16,0">
@@ -54,34 +72,39 @@
                     <TextBox
                         Width="346"
                         Height="32"
-                        HorizontalAlignment="Left" />
-                    <CheckBox Margin="0,6" Content="将原始文档名前置" />
+                        HorizontalAlignment="Left"
+                        Focusable="False"
+                        IsReadOnly="True" />
+                    <CheckBox
+                        Margin="0,6"
+                        Content="将原始文档名前置"
+                        IsChecked="True" />
 
 
                     <StackPanel Orientation="Horizontal">
                         <CheckBox
+                            Name="ChkSign"
                             Width="{Binding ElementName=ChkSeparator, Path=ActualWidth}"
                             Margin="0,6"
-                            Content="标签" />
+                            Content="标签"
+                            IsChecked="True" />
                         <TextBox
                             Width="110"
                             Height="32"
-                            Margin="16,0" />
+                            Margin="16,0"
+                            IsEnabled="{Binding ElementName=ChkSign, Path=IsChecked}" />
                     </StackPanel>
                     <StackPanel Orientation="Horizontal">
                         <CheckBox
                             Name="ChkSeparator"
                             Margin="0,6"
-                            Content="分隔符" />
+                            Content="分隔符"
+                            IsChecked="True" />
                         <TextBox
                             Width="110"
                             Height="32"
-                            Margin="16,0" />
-                    </StackPanel>
-
-                    <StackPanel Orientation="Horizontal">
-                        <RadioButton Margin="0,12,0,16" Content="纵向页面" />
-                        <RadioButton Margin="24,12,0,16" Content="横向页面" />
+                            Margin="16,0"
+                            IsEnabled="{Binding ElementName=ChkSeparator, Path=IsChecked}" />
                     </StackPanel>
                 </StackPanel>
             </Grid>

+ 0 - 37
PDF Office/Views/HomePanel/CloudDocs/CloudDiskContent.xaml

@@ -1,37 +0,0 @@
-<UserControl x:Class="PDF_Office.Views.HomePanel.CloudDocs.CloudDiskContent"
-             xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
-             xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
-             xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006" 
-             xmlns:d="http://schemas.microsoft.com/expression/blend/2008" 
-             xmlns:local="clr-namespace:PDF_Office.Views.HomePanel.CloudDocs"
-             mc:Ignorable="d"  Background="White"
-             d:DesignHeight="450" d:DesignWidth="800">
-    <Grid  Margin="44,38,0,0">
-        <Grid.RowDefinitions>
-            <RowDefinition Height="auto"/>
-            <RowDefinition Height="auto"/>
-        </Grid.RowDefinitions>
-
-        <Grid HorizontalAlignment="Stretch">
-            <TextBlock Text="Cloud disk" HorizontalAlignment="Left"/>
-            <ComboBox x:Name="combCloudDisk" Width="115" Height="32" Background="Wheat" HorizontalAlignment="Right"/>
-        </Grid>
-        <ListBox x:Name="ListCloudDisk" Grid.Row="1">
-             
-            <ListBox.ItemsPanel>
-                <ItemsPanelTemplate>
-                    <UniformGrid Columns="4"/>
-                </ItemsPanelTemplate>
-            </ListBox.ItemsPanel>
-
-            <ListBox.ItemTemplate>
-                <DataTemplate>
-                    <Border Background="#DBDBDB" Width="218" Height="172">
-                        <TextBlock Text="{Binding}"/>
-                    </Border>
-                </DataTemplate>
-            </ListBox.ItemTemplate>
-
-        </ListBox>
-    </Grid>
-</UserControl>

+ 0 - 36
PDF Office/Views/HomePanel/CloudDocs/CloudDiskContent.xaml.cs

@@ -1,36 +0,0 @@
-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 PDF_Office.Views.HomePanel.CloudDocs
-{
-    /// <summary>
-    /// CloudDiskContent.xaml 的交互逻辑
-    /// </summary>
-    public partial class CloudDiskContent : UserControl
-    {
-
-        private List<string> list = new List<string>();
-        public CloudDiskContent()
-        {
-            InitializeComponent();
-            list.Add("Box");
-            list.Add("DropBox");
-            list.Add("GoogleDrive");
-            list.Add("OneDrive");
-            ListCloudDisk.ItemsSource = list; 
-            combCloudDisk.ItemsSource = list;
-        }
-    }
-}

+ 0 - 44
PDF Office/Views/HomePanel/CloudDocs/CloudFilesContent.xaml

@@ -1,44 +0,0 @@
-<UserControl x:Class="PDF_Office.Views.HomePanel.CloudDocs.CloudFilesContent"
-             xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
-             xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
-             xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006" 
-             xmlns:d="http://schemas.microsoft.com/expression/blend/2008" 
-             xmlns:local="clr-namespace:PDF_Office.Views.HomePanel.CloudDocs"
-             mc:Ignorable="d" 
-             d:DesignHeight="450" d:DesignWidth="800">
-    <Grid>
-        <Grid.RowDefinitions>
-            <RowDefinition Height="auto"/>
-            <RowDefinition Height="auto"/>
-        </Grid.RowDefinitions>
-        <Grid HorizontalAlignment="Stretch">
-            <Grid.ColumnDefinitions>
-                <ColumnDefinition />
-                <ColumnDefinition Width="auto"/>
-            </Grid.ColumnDefinitions>
-            <ListBox x:Name="ListFolder">
-                <ListBox.ItemsPanel>
-                    <ItemsPanelTemplate>
-                        <WrapPanel Orientation="Horizontal"/>
-                    </ItemsPanelTemplate>
-                </ListBox.ItemsPanel>
-            </ListBox>
-            <ComboBox x:Name="combCloudDisk" Grid.Column="1" Width="115" Height="32" Background="Wheat" HorizontalAlignment="Right"/>
-        </Grid>
-
-        <Grid Grid.Row="1">
-            <Grid.ColumnDefinitions>
-                <ColumnDefinition Width="Auto"/>
-                <ColumnDefinition/>
-            </Grid.ColumnDefinitions>
-
-            <ListBox x:Name="Listusers" Width="170"/>
-            <ListView x:Name="ListvmFiles" Grid.Column="1" />
-        </Grid>
-
-       
-
-
-
-    </Grid>
-</UserControl>

+ 0 - 37
PDF Office/Views/HomePanel/CloudDocs/CloudFilesContent.xaml.cs

@@ -1,37 +0,0 @@
-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 PDF_Office.Views.HomePanel.CloudDocs
-{
-    /// <summary>
-    /// CloudFilesContent.xaml 的交互逻辑
-    /// </summary>
-    public partial class CloudFilesContent : UserControl
-    {
-        private List<string> list = new List<string>();
-        public CloudFilesContent()
-        {
-            InitializeComponent();
-            list.Add("Box");
-            list.Add("DropBox");
-            list.Add("GoogleDrive");
-            list.Add("OneDrive");
-            ListFolder.ItemsSource = list;
-            Listusers.ItemsSource = list;
-            combCloudDisk.ItemsSource = list;
-            ListvmFiles.ItemsSource = list;
-        }
-    }
-}

+ 56 - 0
PDF Office/Views/HomePanel/CloudDrive/CloudDriveContent.xaml

@@ -0,0 +1,56 @@
+<UserControl x:Class="PDF_Office.Views.HomePanel.CloudDrive.CloudDriveContent"
+             xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
+             xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
+             xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006" 
+             xmlns:d="http://schemas.microsoft.com/expression/blend/2008" 
+             xmlns:local="clr-namespace:PDF_Office.Views.HomePanel.CloudDrive"
+             xmlns:prism ="http://prismlibrary.com/"
+             prism:ViewModelLocator.AutoWireViewModel="True"
+             mc:Ignorable="d" 
+             d:DesignHeight="450" d:DesignWidth="800">
+    <Grid  Margin="44,38,0,0">
+        <Grid.RowDefinitions>
+            <RowDefinition Height="auto"/>
+            <RowDefinition Height="129.367"/>
+            <RowDefinition Height="67.633"/>
+        </Grid.RowDefinitions>
+
+        <Grid>
+            <TextBlock Text="Cloud Drive" HorizontalAlignment="Left"/>
+            <ComboBox x:Name="combCloudDrive" Width="115" Height="32" Background="Wheat" HorizontalAlignment="Right" SelectionChanged="combCloudDrive_SelectionChanged">
+                <ComboBox.ItemTemplate>
+                    <DataTemplate>
+                        <Border Background="#DBDBDB">
+                            <TextBlock Text="{Binding DriveName}"/>
+                        </Border>
+                    </DataTemplate>
+                </ComboBox.ItemTemplate>
+            </ComboBox>
+        </Grid>
+        <ListBox x:Name="ListCloudDrive" Grid.Row="1" Grid.RowSpan="2">
+             
+            <ListBox.ItemsPanel>
+                <ItemsPanelTemplate>
+                    <UniformGrid Columns="4"/>
+                </ItemsPanelTemplate>
+            </ListBox.ItemsPanel>
+
+            <ListBox.ItemTemplate>
+                <DataTemplate>
+                    <Border Background="#DBDBDB" Width="218" Height="172">
+                        <TextBlock Text="{Binding DriveName}"/>
+                    </Border>
+                </DataTemplate>
+            </ListBox.ItemTemplate>
+
+            <ListBox.ItemContainerStyle>
+                <Style TargetType="{x:Type ListBoxItem}">
+                    <EventSetter Event="PreviewMouseLeftButtonUp" 
+                                 Handler="SelectCloudDrive_Click"
+                                 />
+                </Style>
+            </ListBox.ItemContainerStyle>
+
+        </ListBox>
+    </Grid>
+</UserControl>

+ 86 - 0
PDF Office/Views/HomePanel/CloudDrive/CloudDriveContent.xaml.cs

@@ -0,0 +1,86 @@
+using PDF_Office.Model.CloudDrive;
+using PDF_Office.ViewModels.HomePanel.CloudDrive;
+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 PDF_Office.Views.HomePanel.CloudDrive
+{
+    /// <summary>
+    /// CloudDriveContent.xaml 的交互逻辑
+    /// </summary>
+    public partial class CloudDriveContent : UserControl
+    {
+        private List<CloudBoxItem> CloudBoxs = new List<CloudBoxItem>();
+        private CloudDriveContentViewModel ViewModel => DataContext as CloudDriveContentViewModel;
+
+        public CloudDriveContent()
+        {
+            InitializeComponent();
+            InitCloudDrive();
+
+            Loaded += CloudDriveContent_Loaded;
+        }
+
+        private void CloudDriveContent_Loaded(object sender, RoutedEventArgs e)
+        {
+            if (ViewModel != null)
+            {
+                ViewModel.IshowContentHandler -= ViewModel_IshowContent;
+                ViewModel.IshowContentHandler += ViewModel_IshowContent;
+                ViewModel.LoadUsers();
+            }
+        }
+
+        private void ViewModel_IshowContent(object sender, bool e)
+        {
+          IsShow = e;
+        }
+
+        private void InitCloudDrive()
+        {
+            CloudBoxs = Cloud.InitCloudBoxs();
+            ListCloudDrive.ItemsSource = CloudBoxs;
+            combCloudDrive.ItemsSource = CloudBoxs;
+            combCloudDrive.SelectedIndex = 0;
+        }
+
+        private void SelectCloudDrive_Click(object sender, MouseButtonEventArgs e)
+        {
+           var cloudDriveItem = (sender as FrameworkElement).DataContext as CloudBoxItem;
+            if(cloudDriveItem != null)
+            {
+                ViewModel.CheckDriveCommand.Execute(cloudDriveItem);
+            }
+        }
+
+        private void combCloudDrive_SelectionChanged(object sender, SelectionChangedEventArgs e)
+        {
+            var cloudDriveItem = combCloudDrive.SelectedItem as CloudBoxItem;
+            if (cloudDriveItem != null)
+            {
+                ViewModel.CheckDriveCommand.Execute(cloudDriveItem);
+            }
+        }
+
+        public bool IsShow
+        {
+            get { return (bool)GetValue(IsShowProperty); }
+            set { SetValue(IsShowProperty, value); }
+        }
+        public static readonly DependencyProperty IsShowProperty =
+           DependencyProperty.Register("IsShow", typeof(bool), typeof(CloudDriveContent), new PropertyMetadata(true));
+
+    }
+}

+ 109 - 0
PDF Office/Views/HomePanel/CloudDrive/CloudFilesContent.xaml

@@ -0,0 +1,109 @@
+<UserControl x:Class="PDF_Office.Views.HomePanel.CloudDrive.CloudFilesContent"
+             xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
+             xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
+             xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006" 
+             xmlns:d="http://schemas.microsoft.com/expression/blend/2008" 
+             xmlns:prism ="http://prismlibrary.com/"
+             prism:ViewModelLocator.AutoWireViewModel="True"
+             xmlns:local="clr-namespace:PDF_Office.Views.HomePanel.CloudDrive"
+             mc:Ignorable="d" 
+             d:DesignHeight="450" d:DesignWidth="800">
+    <UserControl.Resources>
+        <ContextMenu x:Key="FlyoutMenu" FontSize="14"
+                         >
+            <ContextMenu.ItemContainerStyle>
+                <Style TargetType="MenuItem">
+                    <Setter Property="Padding" Value="0,7,0,7"/>
+                    <Setter Property="VerticalContentAlignment" Value="Center"/>
+                </Style>
+            </ContextMenu.ItemContainerStyle>
+            <MenuItem Name="OpenDocMenuItem" Header="打开文件" IsEnabled="True" Click="OpenDocMenuItem_Click">
+                <MenuItem.Icon>
+                    <Path Fill="Black" Data="M9 0H3V2H0V3H1V14H11V3H12V2H9V0ZM2 13V3H3H4H8H9H10V13H2ZM8 2V1H4V2H8ZM4 12V4H3V12H4ZM6.5 4V12H5.5V4H6.5ZM9 12V4H8V12H9Z">
+                        <Path.RenderTransform>
+                            <TranslateTransform X="5.0000" Y="0"/>
+                        </Path.RenderTransform>
+                    </Path>
+                </MenuItem.Icon>
+            </MenuItem>
+   
+
+        </ContextMenu>
+
+        <Style x:Key="itemstyle" TargetType="{x:Type ListViewItem}">
+            <Setter Property="ContextMenu" Value="{StaticResource FlyoutMenu}"></Setter>
+        </Style>
+    </UserControl.Resources>
+    <Grid>
+        <Grid.RowDefinitions>
+            <RowDefinition Height="auto"/>
+            <RowDefinition/>
+        </Grid.RowDefinitions>
+        <Grid HorizontalAlignment="Stretch">
+            <Grid.ColumnDefinitions>
+                <ColumnDefinition />
+                <ColumnDefinition Width="auto"/>
+            </Grid.ColumnDefinitions>
+            <ListBox x:Name="ListFolder">
+                <ListBox.ItemsPanel>
+                    <ItemsPanelTemplate>
+                        <WrapPanel Orientation="Horizontal"/>
+                    </ItemsPanelTemplate>
+                </ListBox.ItemsPanel>
+            </ListBox>
+            <StackPanel Grid.Column="1" Orientation="Horizontal">
+                <ComboBox x:Name="combCloudDrive" Grid.Column="1" Width="115" Height="32" Background="Wheat" HorizontalAlignment="Right" SelectionChanged="combCloudDrive_SelectionChanged">
+                    <ComboBox.ItemTemplate>
+                        <DataTemplate>
+                            <Border Background="#DBDBDB">
+                                <TextBlock Text="{Binding DriveName}"/>
+                            </Border>
+                        </DataTemplate>
+                    </ComboBox.ItemTemplate>
+                </ComboBox>
+                <Button Content="Test" Click="Button_Click"/>
+            </StackPanel>
+           
+        </Grid>
+
+        <Grid Grid.Row="1" >
+            <Grid.ColumnDefinitions>
+                <ColumnDefinition Width="Auto"/>
+                <ColumnDefinition/>
+            </Grid.ColumnDefinitions>
+
+            <ListView x:Name="Listusers" Width="220"  SelectionChanged="Listusers_SelectionChanged" VerticalAlignment="Top">
+                <ListView.ItemTemplate>
+                    <DataTemplate>
+                        <Grid Height="50" >
+                            <TextBlock VerticalAlignment="Center" Text="{Binding user.UserAccount}"/>
+                        </Grid>
+                       
+                    </DataTemplate>
+                </ListView.ItemTemplate>
+            </ListView>
+
+            <ListView x:Name="ListvmFiles" Grid.Column="1" ScrollViewer.VerticalScrollBarVisibility="Auto" ItemContainerStyle="{StaticResource itemstyle}">
+                <ListView.ItemTemplate>
+                    <DataTemplate>
+                        <StackPanel Margin="0,5,0,5">
+                            <StackPanel Orientation="Horizontal">
+                                <TextBlock Text="Id:"/>
+                                <TextBlock Text="{Binding Id}"/>
+                            </StackPanel>
+                            <StackPanel Orientation="Horizontal">
+                                <TextBlock Text="文件名:"/>
+                                <TextBlock Text="{Binding Name}"/>
+                            </StackPanel>
+                        </StackPanel>
+                    </DataTemplate>
+                </ListView.ItemTemplate>
+            </ListView>
+        </Grid>
+
+       
+
+
+
+    </Grid>
+</UserControl>

+ 175 - 0
PDF Office/Views/HomePanel/CloudDrive/CloudFilesContent.xaml.cs

@@ -0,0 +1,175 @@
+using Microsoft.Win32;
+using PDF_Office.Model.CloudDrive;
+using PDF_Office.ViewModels.HomePanel.CloudDrive;
+using PDF_Office.ViewModels.HomePanel.CloudDrive.CloudDriveType;
+using System;
+using System.Collections.Generic;
+using System.Collections.ObjectModel;
+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 PDF_Office.Views.HomePanel.CloudDrive
+{
+    /// <summary>
+    /// CloudFilesContent.xaml 的交互逻辑
+    /// </summary>
+    public partial class CloudFilesContent : UserControl
+    {
+     
+        private CloudFilesContentViewModel ViewModel => DataContext as CloudFilesContentViewModel;
+
+        private List<CloudBoxItem> CloudeDrives = new List<CloudBoxItem>();
+
+        private CloudType cloudType;
+        public CloudFilesContent()
+        {
+            InitializeComponent();
+            InitCloudDrive();
+            this.Loaded += usercontrol_Loaded;
+        }
+
+        private void InitCloudDrive()
+        {
+            CloudeDrives = Cloud.InitCloudBoxs();
+            combCloudDrive.ItemsSource = CloudeDrives;
+            combCloudDrive.SelectedIndex = 0;
+        }
+
+        private void usercontrol_Loaded(object sender, RoutedEventArgs e)
+        {
+          if(ViewModel != null)
+            {
+                ViewModel.CheckDriveUsers();
+                if (Listusers.ItemsSource == null)
+                    Listusers.ItemsSource = Cloud.CloudLists;
+            }
+        }
+
+        private void combCloudDrive_SelectionChanged(object sender, SelectionChangedEventArgs e)
+        {
+            var cloudDriveItem = combCloudDrive.SelectedItem as CloudBoxItem;
+            if (cloudDriveItem != null)
+            {
+                ViewModel.CheckDriveCommand.Execute(cloudDriveItem);
+            }
+        }
+
+
+        private void Button_Click(object sender, RoutedEventArgs e)
+        {
+
+         
+        }
+
+        private UserBaseItem CurrentUser;
+
+        private async void Listusers_SelectionChanged(object sender, SelectionChangedEventArgs e)
+        {
+            var cloudFileUser = Listusers.SelectedItem as UserBaseItem;
+            if(cloudFileUser != null)
+            {
+                CurrentUser = cloudFileUser;
+
+                switch(cloudFileUser.cloudType)
+                {
+                    case CloudType.GoogleDrive:
+                        if ((CurrentUser as GoogleDriveUserItem) != null)
+                        {
+                            var item = CurrentUser as GoogleDriveUserItem;
+                            var files = await item.GetDriveFiles(item.Service);
+                            ObservableCollection<GoogleDriveFiles> filesList = new ObservableCollection<GoogleDriveFiles>();
+                            foreach (var file in files)
+                            {
+                                if (file.Name.EndsWith(".pdf") == true)
+                                {
+                                    filesList.Add(file);
+                                }
+                            }
+                            ListvmFiles.ItemsSource = filesList;
+                        }
+                        break;
+
+                    case CloudType.DropBox:
+                        if ((CurrentUser as DropbBoxUserItem) != null)
+                        {
+                            var item = CurrentUser as DropbBoxUserItem;
+                            var files = await item.RefreshList();
+                            ObservableCollection<DropbBoxFiles> filesList = new ObservableCollection<DropbBoxFiles>();
+                            foreach (var file in files)
+                            {
+                                if (file.Name.EndsWith(".pdf") == true)
+                                {
+                                    filesList.Add(file);
+                                }
+                            }
+                            ListvmFiles.ItemsSource = filesList;
+                        }
+                        break;
+
+                }
+               
+            }
+        }
+
+        private async void OpenDocMenuItem_Click(object sender, RoutedEventArgs e)
+        {
+            var menuItem = sender as MenuItem;
+            if (menuItem == null)
+                return;
+
+            string docPath = Environment.GetFolderPath(Environment.SpecialFolder.MyDocuments);
+
+            switch (CurrentUser.cloudType)
+            {
+                case CloudType.GoogleDrive:
+               
+                    var item = menuItem.DataContext as GoogleDriveFiles;
+                    if (menuItem == null || item == null)
+                        return;
+
+                    var googleItem = CurrentUser as GoogleDriveUserItem;
+                    var filename = await googleItem.DownloadGoogleFile(item, docPath);
+                    if (filename != null)
+                    {
+                        string[] filePaths = { filename };
+                        await Task.Delay(3);
+                        MainWindow parentWindow = Window.GetWindow(this) as MainWindow;
+                        parentWindow.LoadPdfViewer(filePaths);
+                    }
+                    break;
+
+                case CloudType.DropBox:
+
+                    var file = menuItem.DataContext as DropbBoxFiles;
+                    var dropBoxItem = CurrentUser as DropbBoxUserItem;
+
+                    var dropBoxFileName = await dropBoxItem.Download(file.Name, docPath);
+                    if (dropBoxFileName != null)
+                    {
+                        string[] filePaths = { dropBoxFileName };
+                        await Task.Delay(3);
+                        MainWindow parentWindow = Window.GetWindow(this) as MainWindow;
+                        parentWindow.LoadPdfViewer(filePaths);
+                    }
+                    break;
+
+            }
+
+
+
+           
+        }
+
+       
+    }
+}

+ 10 - 3
PDF Office/Views/HomePanel/HomeCloudContent.xaml

@@ -4,14 +4,21 @@
              xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006" 
              xmlns:d="http://schemas.microsoft.com/expression/blend/2008" 
              xmlns:local="clr-namespace:PDF_Office.Views.HomePanel"
-             xmlns:Cloud="clr-namespace:PDF_Office.Views.HomePanel.CloudDocs"
+             xmlns:Cloud="clr-namespace:PDF_Office.Views.HomePanel.CloudDrive"
              xmlns:prism ="http://prismlibrary.com/"
              prism:ViewModelLocator.AutoWireViewModel="True"
+             xmlns:convert="clr-namespace:PDF_Office.DataConvert"
              Background="Yellow"
              mc:Ignorable="d" 
              d:DesignHeight="450" d:DesignWidth="800">
+    <UserControl.Resources>
+        <ResourceDictionary>
+            <convert:InvertBoolToVisibleConvert x:Key="InvertBoolToVisibleConvert" />
+            <convert:BoolToVisible x:Key="BoolToVisibleConvert" />
+        </ResourceDictionary>
+    </UserControl.Resources>
     <Grid>
-        <Cloud:CloudDiskContent/>
-        <Cloud:CloudFilesContent  Visibility="Collapsed"/>
+        <Cloud:CloudDriveContent x:Name="cloudDriveContent" Visibility="{Binding ElementName=cloudDriveContent,Path=IsShow, Converter={StaticResource  BoolToVisibleConvert}}" />
+        <Cloud:CloudFilesContent x:Name="cloudFilesContent"  Visibility="{Binding ElementName=cloudDriveContent,Path=IsShow, Converter={StaticResource InvertBoolToVisibleConvert}}"/>
     </Grid>
 </UserControl>

+ 3 - 1
PDF Office/Views/HomePanel/HomeCloudContent.xaml.cs

@@ -1,4 +1,5 @@
-using System;
+using PDF_Office.ViewModels.HomePanel.CloudDrive;
+using System;
 using System.Collections.Generic;
 using System.Linq;
 using System.Text;
@@ -24,5 +25,6 @@ namespace PDF_Office.Views.HomePanel
         {
             InitializeComponent();
         }
+
     }
 }

+ 43 - 1
PDF Office/Views/PageEdit/PageEditContent.xaml

@@ -102,7 +102,7 @@
     </UserControl.Resources>
 
     <Border BorderBrush="#F2F2F2" BorderThickness="0,1,0,0">
-        <Grid>
+        <Grid DragOver="Grid_DragOver">
             <Grid.RowDefinitions>
                 <RowDefinition Height="40" />
                 <RowDefinition />
@@ -255,8 +255,13 @@
                 Grid.Row="1"
                 Padding="0"
                 AllowDrop="True"
+                Background="#E7E9EC"
+                Drop="ListPageEdit_Drop"
                 ItemTemplate="{StaticResource PageEditListBoxItemTemplate}"
                 ItemsSource="{Binding PageEditItems}"
+                PreviewMouseLeftButtonDown="ListPageEdit_PreviewMouseLeftButtonDown"
+                PreviewMouseLeftButtonUp="ListPageEdit_PreviewMouseLeftButtonUp"
+                PreviewMouseMove="ListPageEdit_PreviewMouseMove"
                 ScrollBar.Scroll="ListPageEdit_Scroll"
                 ScrollViewer.ScrollChanged="ListPageEdit_ScrollChanged"
                 SelectedIndex="{Binding ListSelectedIndex, Mode=TwoWay}"
@@ -284,6 +289,43 @@
                     </i:EventTrigger>
                 </i:Interaction.Triggers>
             </ListBox>
+            <!--  框选的矩形框  -->
+            <Rectangle
+                Name="RectChoose"
+                Grid.Row="1"
+                HorizontalAlignment="Left"
+                VerticalAlignment="Top"
+                Fill="#AACCEE"
+                Opacity="0.3"
+                Stroke="#AACCEE"
+                StrokeThickness="2" />
+            <!--  插入标记  -->
+            <Line
+                Name="LineInset"
+                Grid.Row="1"
+                AllowDrop="True"
+                Drop="MidLane_Drop"
+                Stroke="#FF477EDE"
+                StrokeEndLineCap="Triangle"
+                StrokeStartLineCap="Triangle"
+                StrokeThickness="5"
+                Visibility="Collapsed"
+                X1="20"
+                X2="20"
+                Y1="0"
+                Y2="150" />
+            <!--  拖拽虚影  -->
+            <Image
+                Name="ImgPicture"
+                Grid.Row="1"
+                HorizontalAlignment="Left"
+                VerticalAlignment="Top"
+                AllowDrop="True"
+                Drop="ImgPicture_Drop"
+                Opacity="0.8"
+                RenderOptions.BitmapScalingMode="HighQuality"
+                UseLayoutRounding="True"
+                Visibility="{Binding ElementName=LineInset, Path=Visibility}" />
             <cus:ToastControl
                 Grid.Row="1"
                 Width="auto"

+ 700 - 0
PDF Office/Views/PageEdit/PageEditContent.xaml.cs

@@ -18,6 +18,7 @@ using System.Windows.Media.Imaging;
 using System.Windows.Navigation;
 using System.Windows.Shapes;
 using System.Windows.Threading;
+using WpfToolkit.Controls;
 
 namespace PDF_Office.Views.PageEdit
 {
@@ -47,11 +48,54 @@ namespace PDF_Office.Views.PageEdit
         /// </summary>
         private DispatcherTimer timer = new DispatcherTimer();
 
+        /// <summary>
+        /// 判断是否开始框选
+        /// </summary>
+        private bool startChoose = false;
+
+        /// <summary>
+        /// 框选的起始位置
+        /// </summary>
+        private Point starPosition = new Point();
+
         /// <summary>
         /// 记录当前滑块的状态
         /// </summary>
         private ScrollEventType scrolltype = ScrollEventType.EndScroll;
 
+        //鼠标点击时在item中的位置  实现类似点哪拖哪的细节
+        private double item_x;
+
+        private double item_y;
+
+        //插入标记代表的插入位置
+        private int InsertIndex = -1;
+
+        //拖动的Item
+        private ListBoxItem tempItem;
+
+        ///鼠标是否停留在item前半部
+        ///显示在前半部时,获取的index为实际索引值
+        ///显示在后半部时,获取的index需要+1
+        private bool isFrontHalf = false;
+
+        /// <summary>
+        /// 是否正在拖拽排序中,通过该变量避免单击触发拖动
+        /// </summary>
+        private bool isDraging = false;
+
+        //是否正在从外部拖入文件
+        private bool isDragingEnter = false;
+
+        /// <summary>
+        /// 是否需要自动滚动
+        /// </summary>
+
+        private bool needScroll = false;
+
+        //自动滚动速度
+        private int speed = 0;
+
         public PageEditContent()
         {
             InitializeComponent();
@@ -221,5 +265,661 @@ namespace PDF_Office.Views.PageEdit
                 (sender as Control).Focus();
             }
         }
+
+        private void ListPageEdit_PreviewMouseMove(object sender, MouseEventArgs e)
+        {
+            try
+            {
+                if (e.LeftButton == MouseButtonState.Pressed)
+                {
+                    //鼠标框选逻辑
+                    if (startChoose)
+                    {
+                        var position = e.GetPosition(ListPageEdit);
+                        if (position.X < 5 || position.X > ListPageEdit.ActualWidth - 5 || position.Y < 5 || position.Y > ListPageEdit.ActualHeight - 5)
+                        {
+                            startChoose = false;
+                            RectChoose.Visibility = Visibility.Collapsed;
+                            //暂时未想到靠近顶部和底部自动翻滚的好方法,只能先屏蔽这部分功能
+                            Mouse.Capture(null);
+                            return;
+                        }
+                        //矩形框内的item设为选中
+                        DoSelectItems();
+                        return;
+                    }
+                    //拖拽排序的逻辑
+                    var pos = e.GetPosition(ListPageEdit);
+                    if (pos.Y < 0 || pos.Y > ListPageEdit.ActualHeight)
+                    {
+                        LineInset.Visibility = Visibility.Collapsed;
+                        return;
+                    }
+                    HitTestResult result = VisualTreeHelper.HitTest(ListPageEdit, pos);
+                    if (result == null)
+                    {
+                        return;
+                    }
+                    var listBoxItem = CommonHelper.FindVisualParent<ListBoxItem>(result.VisualHit);
+                    if (listBoxItem == null)
+                    {
+                        return;
+                    }
+                    isDragingEnter = false;
+                    tempItem = listBoxItem;
+
+                    var item_pos = e.GetPosition(tempItem);
+                    if (item_pos != null)
+                    {
+                        item_x = item_pos.X;
+                        item_y = item_pos.Y;
+                    }
+                    var scroll = GetScrollHost(ListPageEdit);
+
+                    //string tempPath = System.IO.Path.Combine(System.IO.Path.GetTempPath(), "Temp.pdf");
+                    //System.IO.File.Create(tempPath);
+                    //string[] files = new string[1];
+                    //files[0] = tempPath;
+                    DataObject dataObj = new DataObject(DataFormats.FileDrop);
+                    DragDrop.DoDragDrop(ListPageEdit, dataObj, DragDropEffects.Move);
+                    Mouse.Capture(ListPageEdit);
+                    return;
+                }
+                RectChoose.Visibility = Visibility.Collapsed;
+                startChoose = false;
+                Mouse.Capture(null);
+            }
+            catch
+            {
+               LineInset.Visibility = Visibility.Collapsed;
+            }
+        }
+
+        /// <summary>
+        /// 判断是否开始框选、记录框选起始位置
+        /// </summary>
+        /// <param name="sender"></param>
+        /// <param name="e"></param>
+        private void ListPageEdit_PreviewMouseLeftButtonDown(object sender, MouseButtonEventArgs e)
+        {
+            var pos = e.GetPosition(ListPageEdit);
+            HitTestResult result = VisualTreeHelper.HitTest(ListPageEdit, pos);
+            if (result == null)
+            {
+                return;
+            }
+            //未选中item  并且不是点击滑轨时 开始框选
+            var listBoxItem = CommonHelper.FindVisualParent<ListBoxItem>(result.VisualHit);
+            var scroller = CommonHelper.FindVisualParent<ScrollBar>(result.VisualHit);
+            if (listBoxItem == null)
+            {
+                if (scroller != null)
+                {
+                    startChoose = false;
+                    return;
+                }
+                //点击空白处时开始框选
+                startChoose = true;
+                if (ListPageEdit.SelectedItems.Count > 0)
+                {
+                    ListPageEdit.SelectedItems.Clear();
+                }
+                starPosition = e.GetPosition(ListPageEdit);
+                starPosition = new Point(starPosition.X, starPosition.Y + GetWrapPanel(ListPageEdit).VerticalOffset);
+                Mouse.Capture(ListPageEdit);
+                return;
+            }
+            //选中了item 时,不能框选
+            startChoose = false;
+        }
+
+        private void ListPageEdit_PreviewMouseLeftButtonUp(object sender, MouseButtonEventArgs e)
+        {
+            startChoose = false;
+            Mouse.Capture(null);
+            RectChoose.Visibility = Visibility.Collapsed;
+        }
+
+        /// <summary>
+        /// 获取Listobox的Wrappanel容器
+        /// </summary>
+        /// <param name="listBox"></param>
+        /// <returns></returns>
+        public VirtualizingWrapPanel GetWrapPanel(ListBox listBox)
+        {
+            Border border = VisualTreeHelper.GetChild(listBox, 0) as Border;
+            var panel = CommonHelper.FindVisualChild<VirtualizingWrapPanel>(border);
+            return panel;
+        }
+
+        /// <summary>
+        ///根据鼠标拖选的框 选中里面的Item
+        /// </summary>
+        private void DoSelectItems()
+        {
+            var s = GetScrollHost(ListPageEdit);
+            Point start = new Point();
+            //通过 实时的垂直偏移量和第一次的偏移量抵消,来获取准确的垂直偏移值。
+            start = new Point(starPosition.X, starPosition.Y - s.VerticalOffset);
+            var rec = new Rect(start, Mouse.GetPosition(ListPageEdit));
+            RectChoose.Margin = new Thickness(rec.Left, rec.Top, 0, 0);
+            RectChoose.Width = rec.Width;
+            RectChoose.Height = rec.Height;
+            RectChoose.Visibility = Visibility.Visible;
+
+            //检测遍历所有项,筛选在矩形框中的Item
+            for (int i = 0; i < ListPageEdit.Items.Count; i++)
+            {
+                var _item = ListPageEdit.ItemContainerGenerator.ContainerFromIndex(i) as ListBoxItem;
+                //通过这一步来避免重复误选中
+                var parent = CommonHelper.FindVisualParent<VirtualizingWrapPanel>(_item);
+                if (parent == null)
+                    continue;
+
+                var v = VisualTreeHelper.GetOffset(_item);
+                if (rec.IntersectsWith(new Rect(v.X, v.Y, _item.ActualWidth, _item.ActualHeight)))
+                {
+                    ListPageEdit.SelectedItems.Add(ListPageEdit.Items[i]);
+                }
+                else
+                {
+                    ListPageEdit.SelectedItems.Remove(ListPageEdit.Items[i]);
+                }
+            }
+            return;
+        }
+
+        /// <summary>
+        /// 计算插入标记线和虚影显示
+        /// </summary>
+        /// <param name="sender"></param>
+        /// <param name="e"></param>
+        private void ListPageEdit_DragOver(object sender, DragEventArgs e)
+        {
+            try
+            {
+                //ctrl建按下 不显示插入标记和虚影  因为释放不会响应drop事件
+                if (e.KeyStates == (DragDropKeyStates.ControlKey | DragDropKeyStates.LeftMouseButton) || e.KeyStates == (DragDropKeyStates.ShiftKey | DragDropKeyStates.LeftMouseButton | DragDropKeyStates.ControlKey))
+                    return;
+
+                //滚动后有 位置不准确 要减去滚动偏移量
+                //控制线的位置
+                var pos = e.GetPosition(ListPageEdit);
+                var result = VisualTreeHelper.HitTest(ListPageEdit, pos);
+                if (result == null)
+                {
+                    //MidLane.Visibility = Visibility.Collapsed;
+                    //return;
+                }
+
+                //获取当前鼠标指针下的容器
+                var listBoxItem = CommonHelper.FindVisualParent<ListBoxItem>(result.VisualHit);
+                if (listBoxItem == null)
+                {
+                    //MidLane.Visibility = Visibility.Collapsed;
+                    //return;
+                }
+
+                #region  计算虚影位置
+                //xaml层 要设置 虚影控件为左上
+                double xPos = 0;
+                double yPos = 0;
+                //内部拖动
+                if (!isDragingEnter)
+                {
+                    //Viewbox viewBox = (tempItem.Content as StackPanel).Children[0] as Viewbox;//获取item宽度
+
+                    ImgPicture.Width = tempItem.ActualWidth;
+                    ImgPicture.Height = tempItem.ActualHeight;
+                    ImgPicture.Source = (tempItem.DataContext as PageEditItem).Image;
+                    xPos = e.GetPosition(ListPageEdit).X - item_x;
+                    yPos = e.GetPosition(ListPageEdit).Y - item_y;
+                }
+                //else
+                //{
+                //    //从外部拖入的逻辑
+                //    //var pic = ToBitmapSource(dragingEnterPath);
+                //    //ShadowPicture.Width = pic.Width;
+                //    //ShadowPicture.Height = pic.Height;
+                //    //ShadowPicture.Source = pic;
+                //    //xPos = e.GetPosition(ListPageEdit).X - pic.Width / 2;
+                //    //yPos = e.GetPosition(ListPageEdit).Y - pic.Height / 2;
+                //}
+
+                ImgPicture.Margin = new Thickness(xPos, yPos, 0, 0);
+                #endregion
+
+                #region 计算插入标记位置
+                var scroll = GetScrollHost(ListPageEdit);
+                if (listBoxItem != null)
+                {
+                    //虚拟化影响到该值计算
+                    var p = VisualTreeHelper.GetOffset(listBoxItem);//计算控件在容器中的偏移(位置)
+                    LineInset.Visibility = Visibility.Visible;
+
+                    var panel = GetWrapPanel(ListPageEdit);
+                    var item = (ListPageEdit.ItemContainerGenerator.ContainerFromIndex(0) as ListBoxItem).DesiredSize.Width;
+
+                    int count = (int)(panel.ViewportWidth / item);
+                    var gap = (panel.ViewportWidth - count * item) / (count + 1) * 1.0;
+
+                    LineInset.X2 = LineInset.X1 = p.X + gap / 2 + listBoxItem.DesiredSize.Width;
+
+                    if (pos.X < p.X + gap / 2 + listBoxItem.ActualWidth / 2)
+                    {
+                        isFrontHalf = true;//前半部 线条出现在位置前 
+                        LineInset.X2 = LineInset.X1 = p.X - gap / 2;
+                        InsertIndex = ListPageEdit.Items.IndexOf(listBoxItem);
+                    }
+                    else
+                    {
+                        isFrontHalf = false;
+                        InsertIndex = ListPageEdit.Items.IndexOf(listBoxItem) + 1;
+                    }
+                    //MidLane.Y1 = p.Y - scroll.VerticalOffset;//向下滑动后要减去滑动值
+                    LineInset.Y1 = p.Y;
+                    if (LineInset.Y1 < 0)//避免超出上边界
+                    {
+                        LineInset.Y1 = 0;
+                    }
+                    //MidLane.Y2 = p.Y + listBoxItem.ActualHeight - scroll.VerticalOffset;//仿智能滚动后可能会导致 垂直滚动偏量不准确
+                    LineInset.Y2 = p.Y + listBoxItem.ActualHeight;
+                    if (LineInset.Y2 < 0)
+                    {
+                        LineInset.Y2 = 0;
+                    }
+                }
+                #endregion
+
+                //暂时处理  鼠标移出边框时,虚影的显示问题
+                if (pos.Y <= 30 || pos.Y >= ListPageEdit.ActualHeight - 10)
+                {
+                    LineInset.Visibility = Visibility.Collapsed;
+                    needScroll = false;
+                }
+
+                if (pos.X <= 40 || pos.X >= scroll.ViewportWidth - 50)
+                {
+                    LineInset.Visibility = Visibility.Collapsed;
+                    needScroll = false;
+                }
+
+                #region 靠近上下边界时,自动滚动,离边界越近,滚动速度越快
+                //speed = 0;
+                //if (pos.Y >= PageEditListBox.ActualHeight - 30)
+                //{
+                //    speed = 30 - (int)(PageEditListBox.ActualHeight - pos.Y);
+                //    needScroll = true;
+                //}
+                //else if (pos.Y <= 30)
+                //{
+                //    speed = (int)(pos.Y - 30);
+                //    needScroll = true;
+                //}
+                //else
+                //    needScroll = false;
+
+                //var v = scroll.VerticalOffset;
+                //scroll.ScrollToVerticalOffset(v + speed);//触发连续滚动
+                #endregion
+            }
+            catch (Exception ex)
+            {
+
+            }
+        }
+
+        /// <summary>
+        /// 退出拖拽模式
+        /// </summary>
+        private void ExitDraging()
+        {
+            LineInset.Visibility = Visibility.Collapsed;
+            isDraging = false;
+        }
+
+        /// <summary>
+        /// 拖拽释放后的处理逻辑
+        /// </summary>
+        /// <param name="sender"></param>
+        /// <param name="e"></param>
+        private void ListPageEdit_Drop(object sender, DragEventArgs e)
+        {
+            needScroll = false;
+            if (!isDraging)
+            {
+                //未拖拽时隐藏插入标记和虚影
+                LineInset.Visibility = Visibility.Collapsed;
+                return;
+            }
+            #region 功能付费锁
+            //    //if (!App.IsActive())
+            //    //{
+            //    //    MidLane.Visibility = Visibility.Collapsed;
+            //    //    IAPFunctionDialog dialog = new IAPFunctionDialog("PageEdit");
+            //    //    dialog.ShowDialog();
+            //    //    return;
+            //    //}
+            #endregion
+
+            #region  从外部拖拽插入文件
+            //if (isDragingEnter)
+            //{
+
+
+            //    //在当前位置插入整个pdf
+            //    CPDFDocument dragDoc = CPDFDocument.InitWithFilePath(dragingEnterPath);
+            //    if (dragDoc.IsLocked)
+            //    {
+            //        VerifyPasswordDialog dialog = new VerifyPasswordDialog(dragDoc);
+            //        dialog.ShowDialog();
+            //        if (dragDoc.IsLocked)
+            //            return;
+            //    }
+            //    if (dragingEnterPath.Substring(dragingEnterPath.LastIndexOf(".")).ToLower() == ".pdf")
+            //    {
+            //        if (dragDoc != null)
+            //        {
+            //            int index = InsertIndex == -1 ? 0 : InsertIndex;
+            //            pdfViewer.Document.ImportPagesAtIndex(dragDoc, "1-" + dragDoc.PageCount, index);
+            //            PopulateThumbnailList();
+            //            ItemsInViewHitTest();
+
+            //            pdfViewer.UndoManager.ClearHistory();
+            //            pdfViewer.UndoManager.CanSave = true;
+            //            pdfViewer.ReloadDocument();
+            //            PageEditListBox.ScrollIntoView(PageEditListBox.SelectedItem as ListBoxItem);
+            //            PageMoved.Invoke(this, new RoutedEventArgs());
+            //            PDFViewerCtrl viewerCtrl = ParentPage?.GetCurrentViewer();
+            //            if (viewerCtrl != null)
+            //            {
+            //                viewerCtrl.IsPageEdit = true;
+            //            }
+            //            dragDoc.Release();
+            //        }
+            //        else
+            //        {
+            //            MessageBoxEx.Show(App.MainPageLoader.GetString("Merge_FileCannotOpenedWarningd"));
+            //        }
+            //        //提示文档损坏无法打开
+            //    }
+            //    else if (!string.IsNullOrEmpty(dragingEnterPath))
+            //    {
+            //        //其他文件  则新增一个页签打开
+            //        //    DragAddTab.Invoke(dragingEnterPath, new RoutedEventArgs());//底层库需要加一个  Load(TPDFDocument)的接口
+            //    }
+            //    MidLane.Visibility = Visibility.Collapsed;
+            //    isDragingEnter = false;
+            //    dragingEnterPath = null;
+            //    return;
+            //}
+            #endregion
+
+            var pos = e.GetPosition(ListPageEdit);
+            var result = VisualTreeHelper.HitTest(ListPageEdit, pos);
+            if (result == null)
+            {
+                //超出当前可控区域
+                ExitDraging();
+                return;
+            }
+            //查找元数据
+            var sourcePerson = e.Data.GetData(typeof(StackPanel)) as StackPanel;
+            if (sourcePerson == null)
+            {
+                ExitDraging();
+                return;
+            }
+            //查找目标数据
+            int targetindex = 0;//目标插入位置
+            if (InsertIndex != -1)
+            {
+                //往前移动时  此index  不是准确的,需要处理++
+                targetindex = InsertIndex;
+            }
+            else//基本不会命中  仅作为保险措施
+            {
+                var listBoxItem = CommonHelper.FindVisualParent<ListBoxItem>(result.VisualHit);
+                if (listBoxItem == null)
+                {
+                    ////鼠标停留在两个item之间或其他无效区域  暂时不做处理(比较麻烦)
+                    ExitDraging();
+                    return;
+                }
+                var targetPerson = listBoxItem;
+                targetPerson.Opacity = 1;
+                sourcePerson.Opacity = 1;
+                if (ReferenceEquals(targetPerson, sourcePerson))
+                {
+                    ExitDraging();
+                    return;
+                }
+
+                targetindex = ListPageEdit.Items.IndexOf(targetPerson);
+            }
+
+            List<ListBoxItem> list = new List<ListBoxItem>();
+            List<int> sourceindex = new List<int>();//需要保存每个页面对应的位置
+            //开始排序
+            List<int> pages = new List<int>();
+            //要先对所有选中项 根据页码排序
+            for (int i = 0; i < ListPageEdit.SelectedItems.Count; i++)
+            {
+                var pageindex = ListPageEdit.Items.IndexOf(ListPageEdit.SelectedItems[i] as ListBoxItem);
+                pages.Add(pageindex);//存入的为页码索引值
+            }
+            pages.Sort();
+            if (pages.Count <= 0)
+            {
+                ExitDraging();
+                return;
+            }
+
+            //要考虑每一次交换都会导致局部页码发生改变
+            //每次整体往后移动时,先移动大页码;整体往前移动时,先移动小页码;往中间移动时,再按上述两种情况分别移动
+            //if (targetindex <= pages[0])// 目标位置在所有选中内容左边,整体前移动  优先先判断左移的情况
+            //{
+            //    sourceindex.Add(-1);
+            //    list = new List<ListBoxItem>();
+            //    for (int i = 0; i < pages.Count; i++)
+            //    {
+            //        list.Add(PageEditListBox.Items[pages[i]] as ListBoxItem);
+            //        sourceindex.Add(pages[i]);
+            //        DragToSort(pages[i], targetindex + i);
+            //    }
+            //}
+            //else if (targetindex > pages[pages.Count - 1])//目标位置在所有选中内容右边 整体后移
+            //{
+            //    sourceindex.Add(1);
+            //    list = new List<ListBoxItem>();
+            //    for (int i = 0; i < pages.Count; i++)
+            //    {
+            //        list.Add(PageEditListBox.Items[pages[pages.Count - 1 - i]] as ListBoxItem);
+            //        sourceindex.Add(pages[pages.Count - 1 - i]);
+            //        DragToSort(pages[pages.Count - 1 - i], targetindex - 1 - i/* + (PageEditListBox.SelectedItems.Count - 1 - i)*/);
+            //    }
+            //}
+            //else//目标位置在所有选中项中间
+            //{
+            //    int i, j, k;
+            //    for (k = 0; k < pages.Count - 1; k++)//找出PageEditListBox.Items中页码等于destpage的下标
+            //    {
+            //        //这里要算入K---即前面部分的页面个数
+            //        if (pages[k] < targetindex && pages[k + 1] >= targetindex)
+            //            break;
+            //    }
+
+            //    sourceindex.Add(0);
+            //    list = new List<ListBoxItem>();
+            //    for (i = 0; i <= k; i++)//局部往后移动
+            //    {
+            //        list.Add(PageEditListBox.Items[pages[k - i]] as ListBoxItem);
+            //        sourceindex.Add(pages[k - i]);
+            //        DragToSort(pages[k - i], targetindex - 1 - i);
+            //    }
+            //    for (j = i; j < pages.Count; j++)//局部往前移动
+            //    {
+            //        list.Add(PageEditListBox.Items[pages[j]] as ListBoxItem);
+            //        sourceindex.Add(pages[j]);
+            //        DragToSort(pages[j], targetindex);
+            //        targetindex++;
+            //    }
+            //    sourceindex.Add(k);//往中间移时, index数组的最后一位 表示 间隔位置K
+            //}
+            isDraging = false;
+        }
+
+        private void MidLane_Drop(object sender, DragEventArgs e)
+        {
+            ListPageEdit_Drop(sender, e);
+        }
+
+        private void ImgPicture_Drop(object sender, DragEventArgs e)
+        {
+            ListPageEdit_Drop(sender, e);
+        }
+
+        /// <summary>
+        /// 拖拽事件写在外部的Grid里,会更加流畅
+        /// </summary>
+        /// <param name="sender"></param>
+        /// <param name="e"></param>
+        private void Grid_DragOver(object sender, DragEventArgs e)
+        {
+            try
+            {
+                //ctrl建按下 不显示插入标记和虚影  因为释放不会响应drop事件
+                if (e.KeyStates == (DragDropKeyStates.ControlKey | DragDropKeyStates.LeftMouseButton) || e.KeyStates == (DragDropKeyStates.ShiftKey | DragDropKeyStates.LeftMouseButton | DragDropKeyStates.ControlKey))
+                    return;
+
+                //滚动后有 位置不准确 要减去滚动偏移量
+                //控制线的位置
+                var pos = e.GetPosition(ListPageEdit);
+                var result = VisualTreeHelper.HitTest(ListPageEdit, pos);
+                if (result == null)
+                {
+                    //MidLane.Visibility = Visibility.Collapsed;
+                    //return;
+                }
+
+                //获取当前鼠标指针下的容器
+                var listBoxItem = CommonHelper.FindVisualParent<ListBoxItem>(result.VisualHit);
+                if (listBoxItem == null)
+                {
+                    //MidLane.Visibility = Visibility.Collapsed;
+                    //return;
+                }
+
+                #region  计算虚影位置
+                //xaml层 要设置 虚影控件为左上
+                double xPos = 0;
+                double yPos = 0;
+                //内部拖动
+                if (!isDragingEnter)
+                {
+                    //Viewbox viewBox = (tempItem.Content as StackPanel).Children[0] as Viewbox;//获取item宽度
+
+                    ImgPicture.Width = tempItem.ActualWidth;
+                    ImgPicture.Height = tempItem.ActualHeight;
+                    ImgPicture.Source = (tempItem.DataContext as PageEditItem).Image;
+                    xPos = e.GetPosition(ListPageEdit).X - item_x;
+                    yPos = e.GetPosition(ListPageEdit).Y - item_y;
+                }
+                //else
+                //{
+                //    //从外部拖入的逻辑
+                //    //var pic = ToBitmapSource(dragingEnterPath);
+                //    //ShadowPicture.Width = pic.Width;
+                //    //ShadowPicture.Height = pic.Height;
+                //    //ShadowPicture.Source = pic;
+                //    //xPos = e.GetPosition(ListPageEdit).X - pic.Width / 2;
+                //    //yPos = e.GetPosition(ListPageEdit).Y - pic.Height / 2;
+                //}
+
+                ImgPicture.Margin = new Thickness(xPos, yPos, 0, 0);
+                #endregion
+
+                #region 计算插入标记位置
+                var scroll = GetScrollHost(ListPageEdit);
+                if (listBoxItem != null)
+                {
+                    //虚拟化影响到该值计算
+                    var p = VisualTreeHelper.GetOffset(listBoxItem);//计算控件在容器中的偏移(位置)
+                    LineInset.Visibility = Visibility.Visible;
+
+                    var panel = GetWrapPanel(ListPageEdit);
+
+                    //var item = panel.ItemSize.Width;
+                    //var item = (ListPageEdit.ItemContainerGenerator.ContainerFromIndex(0) as ListBoxItem).DesiredSize.Width;
+                    var item = listBoxItem.DesiredSize.Width;
+
+                    int count = (int)(panel.ViewportWidth / item);
+                    var gap = (panel.ViewportWidth - count * item) / (count + 1) * 1.0;
+
+                    LineInset.X2 = LineInset.X1 = p.X + gap / 2 + listBoxItem.DesiredSize.Width;
+
+                    if (pos.X < p.X + gap / 2 + listBoxItem.ActualWidth / 2)
+                    {
+                        isFrontHalf = true;//前半部 线条出现在位置前 
+                        LineInset.X2 = LineInset.X1 = p.X - gap / 2;
+                        InsertIndex = ListPageEdit.Items.IndexOf(listBoxItem);
+                    }
+                    else
+                    {
+                        isFrontHalf = false;
+                        InsertIndex = ListPageEdit.Items.IndexOf(listBoxItem) + 1;
+                    }
+                    //MidLane.Y1 = p.Y - scroll.VerticalOffset;//向下滑动后要减去滑动值
+                    LineInset.Y1 = p.Y;
+                    if (LineInset.Y1 < 0)//避免超出上边界
+                    {
+                        LineInset.Y1 = 0;
+                    }
+                    //MidLane.Y2 = p.Y + listBoxItem.ActualHeight - scroll.VerticalOffset;//仿智能滚动后可能会导致 垂直滚动偏量不准确
+                    LineInset.Y2 = p.Y + listBoxItem.ActualHeight;
+                    if (LineInset.Y2 < 0)
+                    {
+                        LineInset.Y2 = 0;
+                    }
+                }
+                #endregion
+
+                //暂时处理  鼠标移出边框时,虚影的显示问题
+                if (pos.Y <= 30 || pos.Y >= ListPageEdit.ActualHeight - 10)
+                {
+                    LineInset.Visibility = Visibility.Collapsed;
+                    needScroll = false;
+                }
+
+                if (pos.X <= 40 || pos.X >= scroll.ViewportWidth - 50)
+                {
+                    LineInset.Visibility = Visibility.Collapsed;
+                    needScroll = false;
+                }
+
+                #region 靠近上下边界时,自动滚动,离边界越近,滚动速度越快
+                speed = 0;
+                if (pos.Y >= ListPageEdit.ActualHeight - 30)
+                {
+                    speed = 30 - (int)(ListPageEdit.ActualHeight - pos.Y);
+                    needScroll = true;
+                }
+                else if (pos.Y <= 30)
+                {
+                    speed = (int)(pos.Y - 30);
+                    needScroll = true;
+                }
+                else
+                    needScroll = false;
+
+                var v = scroll.VerticalOffset;
+                scroll.ScrollToVerticalOffset(v + speed);//触发连续滚动
+                #endregion
+            }
+            catch
+            {
+
+            }
+        }
     }
 }

File diff ditekan karena terlalu besar
+ 139 - 0
PDF Office/Views/Tools/AnnotToolContent.xaml


+ 61 - 0
PDF Office/Views/Tools/AnnotToolContent.xaml.cs

@@ -0,0 +1,61 @@
+using PDF_Office.CustomControl;
+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 PDF_Office.Views.Tools
+{
+    /// <summary>
+    /// AnnotToolContent.xaml 的交互逻辑
+    /// </summary>
+    public partial class AnnotToolContent : UserControl
+    {
+        public AnnotToolContent()
+        {
+            InitializeComponent();
+        }
+
+        private void BtnHand_Click(object sender, RoutedEventArgs e)
+        {
+
+        }
+
+        private void BtnTool_Click(object sender, RoutedEventArgs e)
+        {
+            CustomIconToggleBtn keepBtn = sender as CustomIconToggleBtn;
+
+            if (keepBtn != null)
+            {
+                ClearSelectedToolPanel(keepBtn);
+            }
+        }
+
+        private void ClearSelectedToolPanel(CustomIconToggleBtn keepBtn = null)
+        {
+            foreach (var item in ToolPanel.Children)
+            {
+                CustomIconToggleBtn checkBtn = item as CustomIconToggleBtn;
+                if (checkBtn != null && checkBtn != keepBtn)
+                {
+                    checkBtn.IsChecked = false;
+                }
+            }
+        }
+
+        private void BtnBookMark_Click(object sender, RoutedEventArgs e)
+        {
+
+        }
+    }
+}

+ 92 - 0
PDF Office/Views/Tools/ConverterBarContent.xaml

@@ -0,0 +1,92 @@
+<UserControl x:Class="PDF_Office.Views.Tools.ConverterBarContent"
+             xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
+             xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
+             xmlns:prism="http://prismlibrary.com/"             
+             prism:ViewModelLocator.AutoWireViewModel="True">
+    <UserControl.Resources>
+        <ResourceDictionary>
+            <ResourceDictionary.MergedDictionaries>
+                <ResourceDictionary Source="../../Styles/CustomBtnStyle.xaml"/>
+                <ResourceDictionary Source="../../Styles/MenuStyle.xaml"/>
+            </ResourceDictionary.MergedDictionaries>
+        </ResourceDictionary>
+    </UserControl.Resources>
+    <Grid>
+        <Border x:Name="ToolsBorder" BorderBrush="#1A000000" BorderThickness="0,1,0,1" Height="40">
+            <WrapPanel HorizontalAlignment="Center" Height="40">
+                <Button Style="{StaticResource InsideBarBtnStyle }" >
+
+                    <StackPanel Orientation="Horizontal" Margin="12 0 12 0">
+                        <StackPanel Margin="0,0,8,0">
+                            <Border Height="30" Width="30" Background="LightSeaGreen" ></Border>
+                        </StackPanel >
+                        <TextBlock Text="PDF转Word" VerticalAlignment="Center"></TextBlock>
+                    </StackPanel>
+                </Button>
+                <Button Style="{StaticResource InsideBarBtnStyle }" >
+
+                    <StackPanel Orientation="Horizontal" Margin="12 0 12 0">
+                        <StackPanel Margin="0,0,8,0">
+                            <Border Height="30" Width="30" Background="LightSeaGreen" ></Border>
+                        </StackPanel >
+                        <TextBlock Text="PDF转Excel" VerticalAlignment="Center"></TextBlock>
+                    </StackPanel>
+                </Button>
+                <Button Style="{StaticResource InsideBarBtnStyle }">
+
+                    <StackPanel Orientation="Horizontal" Margin="12 0 12 0">
+                        <StackPanel Margin="0,0,8,0">
+                            <Border Height="30" Width="30" Background="LightSeaGreen" ></Border>
+                        </StackPanel >
+                        <TextBlock Text="PDF转PPT" VerticalAlignment="Center"></TextBlock>
+                    </StackPanel>
+                </Button>
+                <Button Style="{StaticResource InsideBarBtnStyle }">
+
+                    <StackPanel Orientation="Horizontal" Margin="12 0 12 0">
+                        <StackPanel Margin="0,0,8,0">
+                            <Border Height="30" Width="30" Background="LightSeaGreen" ></Border>
+                        </StackPanel >
+                        <TextBlock Text="PDF转RTF" VerticalAlignment="Center"></TextBlock>
+                    </StackPanel>
+                </Button>
+                <Button Style="{StaticResource InsideBarBtnStyle }">
+
+                    <StackPanel Orientation="Horizontal" Margin="12 0 12 0">
+                        <StackPanel Margin="0,0,8,0">
+                            <Border Height="30" Width="30" Background="LightSeaGreen" ></Border>
+                        </StackPanel >
+                        <TextBlock Text="PDF转CSV" VerticalAlignment="Center"></TextBlock>
+                    </StackPanel>
+                </Button>
+                <Button Style="{StaticResource InsideBarBtnStyle }">
+
+                    <StackPanel Orientation="Horizontal" Margin="12 0 12 0">
+                        <StackPanel Margin="0,0,8,0">
+                            <Border Height="30" Width="30" Background="LightSeaGreen" ></Border>
+                        </StackPanel >
+                        <TextBlock Text="PDF转HTML" VerticalAlignment="Center"></TextBlock>
+                    </StackPanel>
+                </Button>
+                <Button Style="{StaticResource InsideBarBtnStyle }">
+
+                    <StackPanel Orientation="Horizontal" Margin="12 0 12 0">
+                        <StackPanel Margin="0,0,8,0">
+                            <Border Height="30" Width="30" Background="LightSeaGreen" ></Border>
+                        </StackPanel >
+                        <TextBlock Text="PDF转Text" VerticalAlignment="Center"></TextBlock>
+                    </StackPanel>
+                </Button>
+                <Button Style="{StaticResource InsideBarBtnStyle }">
+                    <StackPanel Orientation="Horizontal" Margin="12 0 12 0">
+                        <StackPanel Margin="0,0,8,0">
+                            <Border Height="30" Width="30" Background="LightSeaGreen" ></Border>
+                        </StackPanel >
+                        <TextBlock Text="PDF转图片" VerticalAlignment="Center"></TextBlock>
+                    </StackPanel>
+                </Button>
+                
+            </WrapPanel>
+        </Border>
+    </Grid>
+</UserControl>

+ 15 - 0
PDF Office/Views/Tools/ConverterBarContent.xaml.cs

@@ -0,0 +1,15 @@
+using System.Windows.Controls;
+
+namespace PDF_Office.Views.Tools
+{
+    /// <summary>
+    /// Interaction logic for ConverterBarContent
+    /// </summary>
+    public partial class ConverterBarContent : UserControl
+    {
+        public ConverterBarContent()
+        {
+            InitializeComponent();
+        }
+    }
+}

+ 1 - 0
PDF Office/credentials.json

@@ -0,0 +1 @@
+{"installed":{"client_id":"133109619517-90ri7o190j44mb0bf5fgotlt79ksv9gl.apps.googleusercontent.com","project_id":"myprojecttestdemo-370006","auth_uri":"https://accounts.google.com/o/oauth2/auth","token_uri":"https://oauth2.googleapis.com/token","auth_provider_x509_cert_url":"https://www.googleapis.com/oauth2/v1/certs","client_secret":"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","redirect_uris":["http://localhost"]}}

+ 9 - 0
PDF Office/index.html

@@ -0,0 +1,9 @@
+<html>
+<script type="text/javascript">
+    function redirect() {
+        // Append fragment as query string so that server can receive it.
+        document.location.href = "/token?url_with_fragment=" + encodeURIComponent(document.location.href);
+    }
+</script>
+<body onload="redirect()"/>
+</html>

+ 8 - 0
PDF Office/packages.config

@@ -1,9 +1,17 @@
 <?xml version="1.0" encoding="utf-8"?>
 <packages>
+  <package id="Dropbox.Api" version="6.33.0" targetFramework="net462" />
   <package id="DryIoc.dll" version="4.7.7" targetFramework="net462" />
+  <package id="Google.Apis" version="1.57.0" targetFramework="net462" />
+  <package id="Google.Apis.Auth" version="1.57.0" targetFramework="net462" />
+  <package id="Google.Apis.Core" version="1.57.0" targetFramework="net462" />
+  <package id="Google.Apis.Drive.v3" version="1.57.0.2859" targetFramework="net462" />
   <package id="Microsoft.AppCenter" version="4.5.0" targetFramework="net462" />
   <package id="Microsoft.AppCenter.Analytics" version="4.5.0" targetFramework="net462" />
   <package id="Microsoft.AppCenter.Crashes" version="4.5.0" targetFramework="net462" />
+  <package id="Microsoft.Office.Interop.Excel" version="15.0.4795.1001" targetFramework="net462" />
+  <package id="Microsoft.Office.Interop.PowerPoint" version="15.0.4420.1018" targetFramework="net462" />
+  <package id="Microsoft.Office.Interop.Word" version="15.0.4797.1004" targetFramework="net462" />
   <package id="Microsoft.Xaml.Behaviors.Wpf" version="1.1.31" targetFramework="net462" />
   <package id="Newtonsoft.Json" version="13.0.1" targetFramework="net462" />
   <package id="Prism.Core" version="8.1.97" targetFramework="net462" />

TEMPAT SAMPAH
PDF Office/x64/ComPDFKit.dll


TEMPAT SAMPAH
PDF Office/x86/ComPDFKit.dll