فهرست منبع

Merge branch 'practice' of http://git.kdan.cc:8865/Windows/PDFOffice_Windows_exe into practice

liuaoran 2 سال پیش
والد
کامیت
1489a747a2
46فایلهای تغییر یافته به همراه6445 افزوده شده و 27 حذف شده
  1. 12 0
      PDF Office/App.xaml.cs
  2. 96 0
      PDF Office/PDF Office.csproj
  3. 5 4
      PDF Office/SDKLisence.xml
  4. 244 0
      PDF Office/ViewModels/Dialog/HomePageToolsDialogs/HomePageBatchProcessing/HomePageBackground/HomePageBackgroundCreateBaseContentViewModel.cs
  5. 554 0
      PDF Office/ViewModels/Dialog/HomePageToolsDialogs/HomePageBatchProcessing/HomePageBackground/HomePageBackgroundCreateColorContentViewModel.cs
  6. 592 0
      PDF Office/ViewModels/Dialog/HomePageToolsDialogs/HomePageBatchProcessing/HomePageBackground/HomePageBackgroundCreateFileContentViewModel.cs
  7. 132 4
      PDF Office/ViewModels/Dialog/HomePageToolsDialogs/HomePageBatchProcessing/HomePageBackground/HomePageBackgroundDialogViewModel.cs
  8. 138 0
      PDF Office/ViewModels/Dialog/HomePageToolsDialogs/HomePageBatchProcessing/HomePageBackground/HomePageBackgroundTemplateListBaseContentViewModel.cs
  9. 237 0
      PDF Office/ViewModels/Dialog/HomePageToolsDialogs/HomePageBatchProcessing/HomePageBackground/HomePageBackgroundTemplateListColorContentViewModel.cs
  10. 242 0
      PDF Office/ViewModels/Dialog/HomePageToolsDialogs/HomePageBatchProcessing/HomePageBackground/HomePageBackgroundTemplateListFileContentViewModel.cs
  11. 246 0
      PDF Office/ViewModels/Dialog/HomePageToolsDialogs/HomePageBatchProcessing/HomePageWatermark/HomePageWatermarkCreateBaseContentViewModel.cs
  12. 720 0
      PDF Office/ViewModels/Dialog/HomePageToolsDialogs/HomePageBatchProcessing/HomePageWatermark/HomePageWatermarkCreateFileContentViewModel.cs
  13. 804 0
      PDF Office/ViewModels/Dialog/HomePageToolsDialogs/HomePageBatchProcessing/HomePageWatermark/HomePageWatermarkCreateTextContentViewModel.cs
  14. 136 4
      PDF Office/ViewModels/Dialog/HomePageToolsDialogs/HomePageBatchProcessing/HomePageWatermark/HomePageWatermarkDialogViewModel.cs
  15. 173 0
      PDF Office/ViewModels/Dialog/HomePageToolsDialogs/HomePageBatchProcessing/HomePageWatermark/HomePageWatermarkTemplateListBaseContentViewModel.cs
  16. 308 0
      PDF Office/ViewModels/Dialog/HomePageToolsDialogs/HomePageBatchProcessing/HomePageWatermark/HomePageWatermarkTemplateListFileContentViewModel.cs
  17. 265 0
      PDF Office/ViewModels/Dialog/HomePageToolsDialogs/HomePageBatchProcessing/HomePageWatermark/HomePageWatermarkTemplateListTextContentViewModel.cs
  18. 65 0
      PDF Office/Views/Dialog/HomePageToolsDialogs/HomePageBatchProcessing/HomePageBackground/HomePageBackgroundCreateBaseContent.xaml
  19. 15 0
      PDF Office/Views/Dialog/HomePageToolsDialogs/HomePageBatchProcessing/HomePageBackground/HomePageBackgroundCreateBaseContent.xaml.cs
  20. 137 0
      PDF Office/Views/Dialog/HomePageToolsDialogs/HomePageBatchProcessing/HomePageBackground/HomePageBackgroundCreateColorContent.xaml
  21. 32 0
      PDF Office/Views/Dialog/HomePageToolsDialogs/HomePageBatchProcessing/HomePageBackground/HomePageBackgroundCreateColorContent.xaml.cs
  22. 107 0
      PDF Office/Views/Dialog/HomePageToolsDialogs/HomePageBatchProcessing/HomePageBackground/HomePageBackgroundCreateFileContent.xaml
  23. 15 0
      PDF Office/Views/Dialog/HomePageToolsDialogs/HomePageBatchProcessing/HomePageBackground/HomePageBackgroundCreateFileContent.xaml.cs
  24. 6 5
      PDF Office/Views/Dialog/HomePageToolsDialogs/HomePageBatchProcessing/HomePageBackground/HomePageBackgroundDialog.xaml
  25. 45 0
      PDF Office/Views/Dialog/HomePageToolsDialogs/HomePageBatchProcessing/HomePageBackground/HomePageBackgroundTemplateListBaseContent.xaml
  26. 15 0
      PDF Office/Views/Dialog/HomePageToolsDialogs/HomePageBatchProcessing/HomePageBackground/HomePageBackgroundTemplateListBaseContent.xaml.cs
  27. 89 0
      PDF Office/Views/Dialog/HomePageToolsDialogs/HomePageBatchProcessing/HomePageBackground/HomePageBackgroundTemplateListColorContent.xaml
  28. 76 0
      PDF Office/Views/Dialog/HomePageToolsDialogs/HomePageBatchProcessing/HomePageBackground/HomePageBackgroundTemplateListColorContent.xaml.cs
  29. 87 0
      PDF Office/Views/Dialog/HomePageToolsDialogs/HomePageBatchProcessing/HomePageBackground/HomePageBackgroundTemplateListFileContent.xaml
  30. 77 0
      PDF Office/Views/Dialog/HomePageToolsDialogs/HomePageBatchProcessing/HomePageBackground/HomePageBackgroundTemplateListFileContent.xaml.cs
  31. 1 1
      PDF Office/Views/Dialog/HomePageToolsDialogs/HomePageBatchProcessing/HomePageBates/HomePageBatesCreateContent.xaml.cs
  32. 2 2
      PDF Office/Views/Dialog/HomePageToolsDialogs/HomePageBatchProcessing/HomePageBates/HomePageBatesDialog.xaml
  33. 2 2
      PDF Office/Views/Dialog/HomePageToolsDialogs/HomePageBatchProcessing/HomePageHeaderFooter/HomePageHeaderFooterDialog.xaml
  34. 67 0
      PDF Office/Views/Dialog/HomePageToolsDialogs/HomePageBatchProcessing/HomePageWatermark/HomePageWatermarkCreateBaseContent.xaml
  35. 15 0
      PDF Office/Views/Dialog/HomePageToolsDialogs/HomePageBatchProcessing/HomePageWatermark/HomePageWatermarkCreateBaseContent.xaml.cs
  36. 115 0
      PDF Office/Views/Dialog/HomePageToolsDialogs/HomePageBatchProcessing/HomePageWatermark/HomePageWatermarkCreateFileContent.xaml
  37. 15 0
      PDF Office/Views/Dialog/HomePageToolsDialogs/HomePageBatchProcessing/HomePageWatermark/HomePageWatermarkCreateFileContent.xaml.cs
  38. 132 0
      PDF Office/Views/Dialog/HomePageToolsDialogs/HomePageBatchProcessing/HomePageWatermark/HomePageWatermarkCreateTextContent.xaml
  39. 29 0
      PDF Office/Views/Dialog/HomePageToolsDialogs/HomePageBatchProcessing/HomePageWatermark/HomePageWatermarkCreateTextContent.xaml.cs
  40. 6 5
      PDF Office/Views/Dialog/HomePageToolsDialogs/HomePageBatchProcessing/HomePageWatermark/HomePageWatermarkDialog.xaml
  41. 45 0
      PDF Office/Views/Dialog/HomePageToolsDialogs/HomePageBatchProcessing/HomePageWatermark/HomePageWatermarkTemplateListBaseContent.xaml
  42. 15 0
      PDF Office/Views/Dialog/HomePageToolsDialogs/HomePageBatchProcessing/HomePageWatermark/HomePageWatermarkTemplateListBaseContent.xaml.cs
  43. 85 0
      PDF Office/Views/Dialog/HomePageToolsDialogs/HomePageBatchProcessing/HomePageWatermark/HomePageWatermarkTemplateListFileContent.xaml
  44. 84 0
      PDF Office/Views/Dialog/HomePageToolsDialogs/HomePageBatchProcessing/HomePageWatermark/HomePageWatermarkTemplateListFileContent.xaml.cs
  45. 85 0
      PDF Office/Views/Dialog/HomePageToolsDialogs/HomePageBatchProcessing/HomePageWatermark/HomePageWatermarkTemplateListTextContent.xaml
  46. 77 0
      PDF Office/Views/Dialog/HomePageToolsDialogs/HomePageBatchProcessing/HomePageWatermark/HomePageWatermarkTemplateListTextContent.xaml.cs

+ 12 - 0
PDF Office/App.xaml.cs

@@ -180,7 +180,19 @@ namespace PDF_Office
             containerRegistry.RegisterForNavigation<HomePageBatesTemplateListContent>();
             containerRegistry.RegisterForNavigation<HomePageBatesCreateContent>();
             containerRegistry.RegisterForNavigation<HomePageBackgroundDialog>();
+            containerRegistry.RegisterForNavigation<HomePageBackgroundTemplateListBaseContent>();
+            containerRegistry.RegisterForNavigation<HomePageBackgroundTemplateListColorContent>();
+            containerRegistry.RegisterForNavigation<HomePageBackgroundTemplateListFileContent>();
+            containerRegistry.RegisterForNavigation<HomePageBackgroundCreateBaseContent>();
+            containerRegistry.RegisterForNavigation<HomePageBackgroundCreateColorContent>();
+            containerRegistry.RegisterForNavigation<HomePageBackgroundCreateFileContent>();
             containerRegistry.RegisterForNavigation<HomePageWatermarkDialog>();
+            containerRegistry.RegisterForNavigation<HomePageWatermarkTemplateListBaseContent>();
+            containerRegistry.RegisterForNavigation<HomePageWatermarkTemplateListTextContent>();
+            containerRegistry.RegisterForNavigation<HomePageWatermarkTemplateListFileContent>();
+            containerRegistry.RegisterForNavigation<HomePageWatermarkCreateBaseContent>();
+            containerRegistry.RegisterForNavigation<HomePageWatermarkCreateTextContent>();
+            containerRegistry.RegisterForNavigation<HomePageWatermarkCreateFileContent>();
             containerRegistry.RegisterForNavigation<ConverterBarContent>();
             containerRegistry.RegisterForNavigation<HomePageConverterDialog>();
             containerRegistry.RegisterForNavigation<HomePageConverterCSV>();

+ 96 - 0
PDF Office/PDF Office.csproj

@@ -429,6 +429,18 @@
     <Compile Include="ViewModels\Dialog\HomePageToolsDialogs\HomePageBatchProcessing\HomePageHeaderFooter\HomePageHeaderFooterTemplateListContentViewModel.cs" />
     <Compile Include="ViewModels\Dialog\HomePageToolsDialogs\HomePageBatchProcessing\HomePageBates\HomePageBatesCreateContentViewModel.cs" />
     <Compile Include="ViewModels\Dialog\HomePageToolsDialogs\HomePageBatchProcessing\HomePageBates\HomePageBatesTemplateListContentViewModel.cs" />
+    <Compile Include="ViewModels\Dialog\HomePageToolsDialogs\HomePageBatchProcessing\HomePageBackground\HomePageBackgroundCreateBaseContentViewModel.cs" />
+    <Compile Include="ViewModels\Dialog\HomePageToolsDialogs\HomePageBatchProcessing\HomePageBackground\HomePageBackgroundCreateColorContentViewModel.cs" />
+    <Compile Include="ViewModels\Dialog\HomePageToolsDialogs\HomePageBatchProcessing\HomePageBackground\HomePageBackgroundCreateFileContentViewModel.cs" />
+    <Compile Include="ViewModels\Dialog\HomePageToolsDialogs\HomePageBatchProcessing\HomePageBackground\HomePageBackgroundTemplateListBaseContentViewModel.cs" />
+    <Compile Include="ViewModels\Dialog\HomePageToolsDialogs\HomePageBatchProcessing\HomePageBackground\HomePageBackgroundTemplateListColorContentViewModel.cs" />
+    <Compile Include="ViewModels\Dialog\HomePageToolsDialogs\HomePageBatchProcessing\HomePageBackground\HomePageBackgroundTemplateListFileContentViewModel.cs" />
+    <Compile Include="ViewModels\Dialog\HomePageToolsDialogs\HomePageBatchProcessing\HomePageWatermark\HomePageWatermarkCreateBaseContentViewModel.cs" />
+    <Compile Include="ViewModels\Dialog\HomePageToolsDialogs\HomePageBatchProcessing\HomePageWatermark\HomePageWatermarkCreateFileContentViewModel.cs" />
+    <Compile Include="ViewModels\Dialog\HomePageToolsDialogs\HomePageBatchProcessing\HomePageWatermark\HomePageWatermarkCreateTextContentViewModel.cs" />
+    <Compile Include="ViewModels\Dialog\HomePageToolsDialogs\HomePageBatchProcessing\HomePageWatermark\HomePageWatermarkTemplateListBaseContentViewModel.cs" />
+    <Compile Include="ViewModels\Dialog\HomePageToolsDialogs\HomePageBatchProcessing\HomePageWatermark\HomePageWatermarkTemplateListFileContentViewModel.cs" />
+    <Compile Include="ViewModels\Dialog\HomePageToolsDialogs\HomePageBatchProcessing\HomePageWatermark\HomePageWatermarkTemplateListTextContentViewModel.cs" />
     <Compile Include="ViewModels\HomePanel\PDFTools\PDFToolsContentViewModel.cs" />
     <Compile Include="ViewModels\HomePanel\PDFTools\QuickToolsContentViewModel.cs" />
     <Compile Include="ViewModels\PropertyPanel\AnnotPanel\SignatureAnnotPropertyViewModel.cs" />
@@ -566,9 +578,27 @@
     <Compile Include="Views\Dialog\FullScreenWindow.xaml.cs">
       <DependentUpon>FullScreenWindow.xaml</DependentUpon>
     </Compile>
+    <Compile Include="Views\Dialog\HomePageToolsDialogs\HomePageBatchProcessing\HomePageBackground\HomePageBackgroundCreateBaseContent.xaml.cs">
+      <DependentUpon>HomePageBackgroundCreateBaseContent.xaml</DependentUpon>
+    </Compile>
+    <Compile Include="Views\Dialog\HomePageToolsDialogs\HomePageBatchProcessing\HomePageBackground\HomePageBackgroundCreateColorContent.xaml.cs">
+      <DependentUpon>HomePageBackgroundCreateColorContent.xaml</DependentUpon>
+    </Compile>
+    <Compile Include="Views\Dialog\HomePageToolsDialogs\HomePageBatchProcessing\HomePageBackground\HomePageBackgroundCreateFileContent.xaml.cs">
+      <DependentUpon>HomePageBackgroundCreateFileContent.xaml</DependentUpon>
+    </Compile>
     <Compile Include="Views\Dialog\HomePageToolsDialogs\HomePageBatchProcessing\HomePageBackground\HomePageBackgroundDialog.xaml.cs">
       <DependentUpon>HomePageBackgroundDialog.xaml</DependentUpon>
     </Compile>
+    <Compile Include="Views\Dialog\HomePageToolsDialogs\HomePageBatchProcessing\HomePageBackground\HomePageBackgroundTemplateListBaseContent.xaml.cs">
+      <DependentUpon>HomePageBackgroundTemplateListBaseContent.xaml</DependentUpon>
+    </Compile>
+    <Compile Include="Views\Dialog\HomePageToolsDialogs\HomePageBatchProcessing\HomePageBackground\HomePageBackgroundTemplateListColorContent.xaml.cs">
+      <DependentUpon>HomePageBackgroundTemplateListColorContent.xaml</DependentUpon>
+    </Compile>
+    <Compile Include="Views\Dialog\HomePageToolsDialogs\HomePageBatchProcessing\HomePageBackground\HomePageBackgroundTemplateListFileContent.xaml.cs">
+      <DependentUpon>HomePageBackgroundTemplateListFileContent.xaml</DependentUpon>
+    </Compile>
     <Compile Include="Views\Dialog\HomePageToolsDialogs\HomePageBatchProcessing\HomePageBates\HomePageBatesCreateContent.xaml.cs">
       <DependentUpon>HomePageBatesCreateContent.xaml</DependentUpon>
     </Compile>
@@ -614,9 +644,27 @@
     <Compile Include="Views\Dialog\HomePageToolsDialogs\HomePageBatchProcessing\HomePageSetPasswordDialog.xaml.cs">
       <DependentUpon>HomePageSetPasswordDialog.xaml</DependentUpon>
     </Compile>
+    <Compile Include="Views\Dialog\HomePageToolsDialogs\HomePageBatchProcessing\HomePageWatermark\HomePageWatermarkCreateBaseContent.xaml.cs">
+      <DependentUpon>HomePageWatermarkCreateBaseContent.xaml</DependentUpon>
+    </Compile>
+    <Compile Include="Views\Dialog\HomePageToolsDialogs\HomePageBatchProcessing\HomePageWatermark\HomePageWatermarkCreateFileContent.xaml.cs">
+      <DependentUpon>HomePageWatermarkCreateFileContent.xaml</DependentUpon>
+    </Compile>
+    <Compile Include="Views\Dialog\HomePageToolsDialogs\HomePageBatchProcessing\HomePageWatermark\HomePageWatermarkCreateTextContent.xaml.cs">
+      <DependentUpon>HomePageWatermarkCreateTextContent.xaml</DependentUpon>
+    </Compile>
     <Compile Include="Views\Dialog\HomePageToolsDialogs\HomePageBatchProcessing\HomePageWatermark\HomePageWatermarkDialog.xaml.cs">
       <DependentUpon>HomePageWatermarkDialog.xaml</DependentUpon>
     </Compile>
+    <Compile Include="Views\Dialog\HomePageToolsDialogs\HomePageBatchProcessing\HomePageWatermark\HomePageWatermarkTemplateListBaseContent.xaml.cs">
+      <DependentUpon>HomePageWatermarkTemplateListBaseContent.xaml</DependentUpon>
+    </Compile>
+    <Compile Include="Views\Dialog\HomePageToolsDialogs\HomePageBatchProcessing\HomePageWatermark\HomePageWatermarkTemplateListFileContent.xaml.cs">
+      <DependentUpon>HomePageWatermarkTemplateListFileContent.xaml</DependentUpon>
+    </Compile>
+    <Compile Include="Views\Dialog\HomePageToolsDialogs\HomePageBatchProcessing\HomePageWatermark\HomePageWatermarkTemplateListTextContent.xaml.cs">
+      <DependentUpon>HomePageWatermarkTemplateListTextContent.xaml</DependentUpon>
+    </Compile>
     <Compile Include="Views\Dialog\HomePageToolsDialogs\HomePageExtractDialog.xaml.cs">
       <DependentUpon>HomePageExtractDialog.xaml</DependentUpon>
     </Compile>
@@ -1144,10 +1192,34 @@
       <SubType>Designer</SubType>
       <Generator>MSBuild:Compile</Generator>
     </Page>
+    <Page Include="Views\Dialog\HomePageToolsDialogs\HomePageBatchProcessing\HomePageBackground\HomePageBackgroundCreateBaseContent.xaml">
+      <SubType>Designer</SubType>
+      <Generator>MSBuild:Compile</Generator>
+    </Page>
+    <Page Include="Views\Dialog\HomePageToolsDialogs\HomePageBatchProcessing\HomePageBackground\HomePageBackgroundCreateColorContent.xaml">
+      <SubType>Designer</SubType>
+      <Generator>MSBuild:Compile</Generator>
+    </Page>
+    <Page Include="Views\Dialog\HomePageToolsDialogs\HomePageBatchProcessing\HomePageBackground\HomePageBackgroundCreateFileContent.xaml">
+      <SubType>Designer</SubType>
+      <Generator>MSBuild:Compile</Generator>
+    </Page>
     <Page Include="Views\Dialog\HomePageToolsDialogs\HomePageBatchProcessing\HomePageBackground\HomePageBackgroundDialog.xaml">
       <SubType>Designer</SubType>
       <Generator>MSBuild:Compile</Generator>
     </Page>
+    <Page Include="Views\Dialog\HomePageToolsDialogs\HomePageBatchProcessing\HomePageBackground\HomePageBackgroundTemplateListBaseContent.xaml">
+      <SubType>Designer</SubType>
+      <Generator>MSBuild:Compile</Generator>
+    </Page>
+    <Page Include="Views\Dialog\HomePageToolsDialogs\HomePageBatchProcessing\HomePageBackground\HomePageBackgroundTemplateListColorContent.xaml">
+      <SubType>Designer</SubType>
+      <Generator>MSBuild:Compile</Generator>
+    </Page>
+    <Page Include="Views\Dialog\HomePageToolsDialogs\HomePageBatchProcessing\HomePageBackground\HomePageBackgroundTemplateListFileContent.xaml">
+      <SubType>Designer</SubType>
+      <Generator>MSBuild:Compile</Generator>
+    </Page>
     <Page Include="Views\Dialog\HomePageToolsDialogs\HomePageBatchProcessing\HomePageBates\HomePageBatesCreateContent.xaml">
       <SubType>Designer</SubType>
       <Generator>MSBuild:Compile</Generator>
@@ -1180,10 +1252,34 @@
       <Generator>MSBuild:Compile</Generator>
       <SubType>Designer</SubType>
     </Page>
+    <Page Include="Views\Dialog\HomePageToolsDialogs\HomePageBatchProcessing\HomePageWatermark\HomePageWatermarkCreateBaseContent.xaml">
+      <SubType>Designer</SubType>
+      <Generator>MSBuild:Compile</Generator>
+    </Page>
+    <Page Include="Views\Dialog\HomePageToolsDialogs\HomePageBatchProcessing\HomePageWatermark\HomePageWatermarkCreateFileContent.xaml">
+      <SubType>Designer</SubType>
+      <Generator>MSBuild:Compile</Generator>
+    </Page>
+    <Page Include="Views\Dialog\HomePageToolsDialogs\HomePageBatchProcessing\HomePageWatermark\HomePageWatermarkCreateTextContent.xaml">
+      <SubType>Designer</SubType>
+      <Generator>MSBuild:Compile</Generator>
+    </Page>
     <Page Include="Views\Dialog\HomePageToolsDialogs\HomePageBatchProcessing\HomePageWatermark\HomePageWatermarkDialog.xaml">
       <SubType>Designer</SubType>
       <Generator>MSBuild:Compile</Generator>
     </Page>
+    <Page Include="Views\Dialog\HomePageToolsDialogs\HomePageBatchProcessing\HomePageWatermark\HomePageWatermarkTemplateListBaseContent.xaml">
+      <SubType>Designer</SubType>
+      <Generator>MSBuild:Compile</Generator>
+    </Page>
+    <Page Include="Views\Dialog\HomePageToolsDialogs\HomePageBatchProcessing\HomePageWatermark\HomePageWatermarkTemplateListFileContent.xaml">
+      <SubType>Designer</SubType>
+      <Generator>MSBuild:Compile</Generator>
+    </Page>
+    <Page Include="Views\Dialog\HomePageToolsDialogs\HomePageBatchProcessing\HomePageWatermark\HomePageWatermarkTemplateListTextContent.xaml">
+      <SubType>Designer</SubType>
+      <Generator>MSBuild:Compile</Generator>
+    </Page>
     <Page Include="Views\Dialog\HomePageToolsDialogs\HomePagePrinter\HomePagePrinterDocumentContent.xaml">
       <SubType>Designer</SubType>
       <Generator>MSBuild:Compile</Generator>

+ 5 - 4
PDF Office/SDKLisence.xml

@@ -1,10 +1,11 @@
 <Lisences
-	devKey = "ehrnKqkWc1XSEAWyPUt6+95GzCoLEyoKrCbsUuJkCqGmxmP5ozX4bS0R6crHItQVNTFvC5mBZ1M7QjJ6Ekdu4Daj7PM+EDLTBKbFJinK4Ri9E5E2X+a9vF5zSj0TkIscQPVnwj9ikxAFOWGIyybMwQQzwc8a4j1cGOqGXQRDMMY="
-  devSecret = "mG0c3O3Mzeu5dkZJW3gpqq9uA7o7EGQveSC38Q8TK4gQurxTxGuBlGAhs0P1mD3X3bHT+AHfcLiymaqE4DY7kTFHoPs9I3tl5ErS+BHdzHRhrp9sGpqfp0B228KI+IMTu4aGVjtYuk+Uxs/kosIBw1367/WkJ00tM7U7tttD6ccHhEu996bvBgqf8Sw8OekQKQq13VBewK5AckaDux4W7SGRhCUNWC4MItkr36JnXMD2tiFQYzMG8C66HYmRGSLh"
-  userKey = "iBPRM/Tz8b6Z1G2GQt52X7hiNCGfVYXztnPjalgrgARvqfKV6lFNH8QeScTzBRYI8GGFpwelfgh790Kd9JmL7V4adI1jCiFHUT2DLT7QucxY5Nkgys2aJItQS482Ck2G2Xf8gNgojxYxRt65o/MEzkj93foj8qIdfHagXsSorSs="
+	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="ErjZKxcU3SPvUohGZo0CBgy0XdkAsZqUYqCTbfn1AYsCQ6mxCucx61UPqLT7MDQ0n+5/oKnWY9SSk8Xv5pJtYYHD87HRdYNG+QNCaoPGHulyfVxGllmzU71U7WjflfZBFvhg/UQOFiz3OsAVKz4k2YkXPzQgNaS3glym42PVpj4="
 	ConverterDevSecret="mG0c3O3Mzeu5dkZJW3gpqq9uA7o7EGQveSC38Q8TK4iYfqdItiFUaR9LVjsPTUXicGXjRTJz0NHg67bO82qMNdkuY0NReKpg+S1SkS2QdEScM/fgvvcctF5rcqYAH1dpMv7C2jvq4o0q6sQtN3jR47j9bjclgv4TJTahQMmvDDLtOGD99YkYWB6rt/zU8htEYkwcNWVMyYvggPV2rTFvfawopGIC034QzjthmhwwX90="
 	ConverterUserkey=" WLUHzXhndQKyrTJVzvZ+dvPXDQDZeJpcSvklX3GJwRX4+urd8eQskYgbeCf0NXLZ/qJkS/k10x+qGad34i4v5rI/ASFIx901c/Nw5C0YJMH7X87dib141tdAmSmQhnKLO5TBi4FiAidboyvnLFLrYGMmS2kLQOXFPwPj5zQUv5A="
-	ConverterUserSecret="mG0c3O3Mzeu5dkZJW3gpqq9uA7o7EGQveSC38Q8TK4iK16EcneqBPRe2eKQLuJXpA79IONX9GVI/Ap3uWzMcNWaitc2UB6gDeexJXFPVaXOFAoV6NtcUJC8skonXVk7k/oKTJGcYKLPGdXenrzHolQ==" >
+	ConverterUserSecret="mG0c3O3Mzeu5dkZJW3gpqq9uA7o7EGQveSC38Q8TK4iK16EcneqBPRe2eKQLuJXpA79IONX9GVI/Ap3uWzMcNWaitc2UB6gDeexJXFPVaXOFAoV6NtcUJC8skonXVk7k/oKTJGcYKLPGdXenrzHolQ=="
+	>
 </Lisences>

+ 244 - 0
PDF Office/ViewModels/Dialog/HomePageToolsDialogs/HomePageBatchProcessing/HomePageBackground/HomePageBackgroundCreateBaseContentViewModel.cs

@@ -0,0 +1,244 @@
+using ComPDFKitViewer.PdfViewer;
+using PDF_Office.EventAggregators;
+using PDF_Office.Model;
+using PDFSettings;
+using Prism.Commands;
+using Prism.Events;
+using Prism.Mvvm;
+using Prism.Regions;
+using System;
+using System.Collections.Generic;
+using System.Linq;
+using System.Windows;
+using System.Windows.Controls;
+
+namespace PDF_Office.ViewModels.Dialog.HomePageToolsDialogs.HomePageBatchProcessing.HomePageBackground
+{
+    public class HomePageBackgroundCreateBaseContentViewModel : BindableBase, INavigationAware
+    {
+        IEventAggregator eventAggregator;
+        IRegionManager backgroundCreateRegion;
+
+        private CPDFViewer PDFViewer;
+        public BackgroundItem BackgroundItem;
+
+        public enum EnumCreateOrEdit
+        {
+            None,
+            StatusCreate,
+            StatusEdit
+        }
+
+        private EnumCreateOrEdit _createOrEdit;
+        public EnumCreateOrEdit CreateOrEdit
+        {
+            get { return _createOrEdit; }
+            set
+            {
+                _createOrEdit = value;
+                if (value == EnumCreateOrEdit.StatusEdit)
+                {
+                    EditBaseVisible = Visibility.Visible;
+                    CreateBaseVisible = Visibility.Collapsed;
+                }
+                else if (value == EnumCreateOrEdit.StatusCreate)
+                {
+                    CreateBaseVisible = Visibility.Visible;
+                    EditBaseVisible = Visibility.Collapsed;
+                }
+            }
+        }
+
+        private string backgroundCreateRegionName;
+
+        public string BackgroundCreateRegionName
+        {
+            get => backgroundCreateRegionName;
+            set => SetProperty(ref backgroundCreateRegionName, value);
+        }
+
+        private string _currentCreateModName;
+        public string CurrentCreateModName
+        {
+            get => _currentCreateModName;
+            set => _currentCreateModName = value;
+        }
+
+
+        private System.Windows.Visibility backgroundCreateVisible;
+        public System.Windows.Visibility BackgroundCreateVisible
+        {
+            get => backgroundCreateVisible;
+            set => SetProperty(ref backgroundCreateVisible, value);
+        }
+
+        private bool isFirstEnter = true;
+        public bool IsFirstEnter
+        {
+            get => isFirstEnter;
+            set => isFirstEnter = value;
+        }
+
+        private Visibility _createBaseVisible;
+        public Visibility CreateBaseVisible
+        {
+            get => _createBaseVisible;
+            set => SetProperty(ref _createBaseVisible, value);
+        }
+
+        private Visibility _editBaseVisible;
+        public Visibility EditBaseVisible
+        {
+            get => _editBaseVisible;
+            set => SetProperty(ref _editBaseVisible, value);
+        }
+
+        public EnumColorOrFile CurrentTemplateListMod;
+        public DelegateCommand<object> ChangeCreateModCommand { get; set; }
+        public DelegateCommand EnterTemplateListCommand { get; set; }
+        public DelegateCommand SaveToTemplateListCommand { get; set; }
+        public DelegateCommand SaveToCurrentTemplateListCommand { get; set; }
+
+        public string unicode = null;
+
+        public string Unicode = null;
+
+        public HomePageBackgroundCreateBaseContentViewModel(IRegionManager regionManager, IEventAggregator eventAggregator)
+        {
+            this.eventAggregator = eventAggregator;
+            this.backgroundCreateRegion = regionManager;
+            Unicode = App.mainWindowViewModel.SelectedItem.Unicode;
+            BackgroundCreateRegionName = Guid.NewGuid().ToString();
+            ChangeCreateModCommand = new DelegateCommand<object>(ChangeCreateMod);
+            EnterTemplateListCommand = new DelegateCommand(EnterTemplateList);
+            SaveToTemplateListCommand = new DelegateCommand(SaveToTemplateList);
+            SaveToCurrentTemplateListCommand = new DelegateCommand(SaveToCurrentTemplateList);
+        }
+
+        public void SaveToTemplateList()
+        {
+            if (CurrentCreateModName == "HomePageBackgroundCreateColorContent")
+            {
+                this.eventAggregator.GetEvent<SaveBackgroundTemplateEvent>().Publish(new EnumColorOrFileUnicode { Unicode = Unicode, Status = EnumColorOrFile.StatusColor });
+            }
+            if (CurrentCreateModName == "HomePageBackgroundCreateFileContent")
+            {
+                this.eventAggregator.GetEvent<SaveBackgroundTemplateEvent>().Publish(new EnumColorOrFileUnicode
+                {
+                    Unicode = Unicode,
+                    Status = EnumColorOrFile.StatusFile
+                });
+            }
+        }
+
+        public void SaveToCurrentTemplateList()
+        {
+            if (CurrentCreateModName == "HomePageBackgroundCreateColorContent")
+            {
+                eventAggregator.GetEvent<ConfirmEditBackgroundTemplateItemEvent>().Publish(new EnumColorOrFileUnicode
+                {
+                    Unicode = Unicode,
+                    Status = EnumColorOrFile.StatusColor
+                });
+            }
+            if (CurrentCreateModName == "HomePageBackgroundCreateFileContent")
+            {
+                eventAggregator.GetEvent<ConfirmEditBackgroundTemplateItemEvent>().Publish(new EnumColorOrFileUnicode
+                {
+                    Unicode = Unicode,
+                    Status = EnumColorOrFile.StatusFile
+                });
+            }
+        }
+
+        public void EnterTemplateList()
+        {
+            this.eventAggregator.GetEvent<EnterTemplateListOrCreateEvent>().Publish(new EnumTemplateListOrCreateUnicode { Unicode = Unicode, Status = EnumTemplateListOrCreate.StatusTemplate });
+        }
+
+        public void EnterSelectedCreateMod(string currentCreateName)
+        {
+            NavigationParameters param = new NavigationParameters();
+            param.Add(ParameterNames.PDFViewer, PDFViewer);
+            backgroundCreateRegion.RequestNavigate(BackgroundCreateRegionName, currentCreateName, param);
+            backgroundCreateVisible = System.Windows.Visibility.Visible;
+        }
+
+
+
+        public void EditSelectedTemplateItem(string currentCreateName)
+        {
+            NavigationParameters param = new NavigationParameters();
+            param.Add(ParameterNames.PDFViewer, PDFViewer);
+            param.Add("BackgroundItem", BackgroundItem);
+            backgroundCreateRegion.RequestNavigate(BackgroundCreateRegionName, currentCreateName, param);
+            backgroundCreateVisible = System.Windows.Visibility.Visible;
+        }
+
+        public void ChangeCreateMod(object e)
+        {
+            var args = e as Button;
+            if (args != null)
+            {
+                if (CreateOrEdit == EnumCreateOrEdit.StatusCreate)
+                {
+                    CurrentCreateModName = args.Name;
+                    EnterSelectedCreateMod(CurrentCreateModName);
+                    eventAggregator.GetEvent<SetCurrentCreateModEvent>().Publish(new stringUnicode
+                    {
+                        Unicode = Unicode,
+                        Status = CurrentCreateModName
+                    });
+                }
+                else if (CreateOrEdit == EnumCreateOrEdit.StatusEdit)
+                {
+                    CurrentCreateModName = args.Name;
+                    EditSelectedTemplateItem(CurrentCreateModName);
+                    eventAggregator.GetEvent<SetCurrentCreateModEvent>().Publish(new stringUnicode
+                    {
+                        Unicode = Unicode,
+                        Status = CurrentCreateModName
+                    });
+                }
+            }
+        }
+
+        public bool IsNavigationTarget(NavigationContext navigationContext)
+        {
+            return true;
+        }
+
+        public void OnNavigatedFrom(NavigationContext navigationContext)
+        {
+        }
+
+        public void OnNavigatedTo(NavigationContext navigationContext)
+        {
+            navigationContext.Parameters.TryGetValue<CPDFViewer>(ParameterNames.PDFViewer, out PDFViewer);
+            navigationContext.Parameters.TryGetValue<EnumColorOrFile>("CurrentTemplateListModName", out CurrentTemplateListMod);
+            if (CurrentTemplateListMod == EnumColorOrFile.StatusColor)
+            {
+                CurrentCreateModName = "HomePageBackgroundCreateColorContent";
+            }
+            else
+            {
+                CurrentCreateModName = "HomePageBackgroundCreateFileContent";
+            }
+            if (navigationContext.Parameters.TryGetValue<BackgroundItem>("BackgroundItem", out BackgroundItem))
+            {
+                EditSelectedTemplateItem(CurrentCreateModName);
+                CreateOrEdit = EnumCreateOrEdit.StatusEdit;
+            }
+            else
+            {
+                EnterSelectedCreateMod(CurrentCreateModName);
+                CreateOrEdit = EnumCreateOrEdit.StatusCreate;
+            }
+            eventAggregator.GetEvent<SetCurrentCreateModEvent>().Publish(new stringUnicode
+            {
+                Unicode = Unicode,
+                Status = CurrentCreateModName
+            });
+        }
+    }
+}

+ 554 - 0
PDF Office/ViewModels/Dialog/HomePageToolsDialogs/HomePageBatchProcessing/HomePageBackground/HomePageBackgroundCreateColorContentViewModel.cs

@@ -0,0 +1,554 @@
+using ComPDFKit.PDFDocument;
+using ComPDFKitViewer.PdfViewer;
+using PDF_Office.EventAggregators;
+using PDF_Office.Helper;
+using PDF_Office.Model.EditTools.Background;
+using PDF_Office.Model;
+using PDF_Office.Properties;
+using PDFSettings;
+using Prism.Commands;
+using Prism.Events;
+using Prism.Mvvm;
+using Prism.Regions;
+using System;
+using System.Collections.Generic;
+using System.IO;
+using System.Linq;
+using System.Windows.Media;
+
+namespace PDF_Office.ViewModels.Dialog.HomePageToolsDialogs.HomePageBatchProcessing.HomePageBackground
+{
+    public class HomePageBackgroundCreateColorContentViewModel : BindableBase, INavigationAware
+    {
+
+        IEventAggregator eventAggregator;
+        private CPDFViewer PDFViewer;
+
+        private string RedColorBtn = "RedColorBtn";
+        private string GreenColorBtn = "GreenColorBtn";
+
+        private BackgroundItem TemplateBackgroundItem;
+
+        private List<string> _rotationList = new List<string>();
+        public List<string> RotationList
+        {
+            get { return _rotationList; }
+            set { SetProperty(ref _rotationList, value); }
+        }
+
+        private List<string> _opacityList = new List<string>();
+        public List<string> OpacityList
+        {
+            get { return _opacityList; }
+            set
+            {
+                SetProperty(ref _opacityList, value);
+            }
+        }
+
+        private string _rotationText = "0";
+        public string RotationText
+        {
+            get { return _rotationText; }
+            set
+            {
+                SetProperty(ref _rotationText, value);
+            }
+        }
+
+        private string _opacityText = "100 %";
+        public string OpacityText
+        {
+            get { return _opacityText; }
+            set
+            {
+                SetProperty(ref _opacityText, value);
+
+            }
+        }
+
+        private List<string> _relativeRatioList = new List<string>();
+        public List<string> RelativeRatioList
+        {
+            get { return _relativeRatioList; }
+            set
+            {
+                SetProperty(ref _relativeRatioList, value);
+            }
+        }
+
+        private int _rotationValue = 0;
+        public int RotationValue
+        {
+            get { return _rotationValue; }
+            set
+            {
+                SetProperty(ref _rotationValue, value);
+                BackgroundInfo.Rotation = value;
+                
+            }
+        }
+
+        private int _opacityValue = 100;
+        public int OpacityValue
+        {
+            get { return _opacityValue; }
+            set
+            {
+                SetProperty(ref _opacityValue, value);
+                BackgroundInfo.Opacity = (byte)value;
+                
+            }
+        }
+
+        private int _relativeRatioValue = 50;
+        public int RelativeRatioValue
+        {
+            get { return _relativeRatioValue; }
+            set
+            {
+                SetProperty(ref _rotationValue, value);
+                BackgroundInfo.Scale = value;
+                
+            }
+        }
+
+        private string _verticalOffsetValue = "0";
+        public string VerticalOffsetValue
+        {
+            get { return _verticalOffsetValue; }
+            set
+            {
+                SetProperty(ref _verticalOffsetValue, value);
+                BackgroundInfo.VertOffset = float.Parse(VerticalOffsetValue);
+                
+            }
+        }
+
+        private string _horizontalOffset = "0";
+        public string HorizontalOffsetValue
+        {
+            get { return _horizontalOffset; }
+            set
+            {
+                SetProperty(ref _horizontalOffset, value);
+                BackgroundInfo.HorizOffset = float.Parse(HorizontalOffsetValue);
+                
+            }
+        }
+
+        private ObservableDictionary<string, bool> _getLocationFromNumber = new ObservableDictionary<string, bool>();
+        public ObservableDictionary<string, bool> GetLocationFromNumber
+        {
+            get { return _getLocationFromNumber; }
+        }
+
+        private BackgroundInfo BackgroundInfo = new BackgroundInfo();
+
+        private Color _color = Color.FromArgb(0xFF, 0xFF, 0x00, 0x00);
+        public Color Color
+        {
+            get
+            {
+                return _color;
+            }
+            set
+            {
+                SetProperty(ref _color, value);
+                BackgroundInfo.Color = EditToolsHelper.ConvertColor(value);
+                
+            }
+        }
+
+        private string _pageRangeText { get; set; } = "0";
+        public string PageRangeText
+        {
+            get { return _pageRangeText; }
+            set
+            {
+                _pageRangeText = value;
+                //EditToolsHelper.GetPageRange(PageRangeSelectIndex, PDFViewer.Document, ref BackgroundInfo.PageRange, PageRangeText);
+                
+            }
+        }
+
+        private int _pageRangeSelectIndex = 0;
+        public int PageRangeSelectIndex
+        {
+            get
+            {
+                return _pageRangeSelectIndex;
+            }
+            set
+            {
+                SetProperty(ref _pageRangeSelectIndex, value);
+                BackgroundInfo.PageRangeIndex = PageRangeSelectIndex;
+                //EditToolsHelper.GetPageRange(PageRangeSelectIndex, PDFViewer.Document, ref BackgroundInfo.PageRange, PageRangeText);
+                
+            }
+        }
+
+        private bool _isRelativeScaleValue = false;
+        public bool IsRelativeScaleValue
+        {
+            get { return _isRelativeScaleValue; }
+            set
+            {
+                SetProperty(ref _isRelativeScaleValue, value);
+                BackgroundInfo.IsRelativeScale = IsRelativeScaleValue;
+                
+            }
+        }
+
+        private string _relativeScaleText = "50 %";
+        public string RelativeScaleText
+        {
+            get { return _relativeScaleText; }
+            set
+            {
+                SetProperty(ref _relativeScaleText, value);
+                
+            }
+        }
+
+
+
+        public DelegateCommand<object> ChangeLocationCommand { get; set; }
+        public DelegateCommand<object> ChangeColorCommand { get; set; }
+
+        public string unicode = null;
+        public string Unicode = null;
+
+        public HomePageBackgroundCreateColorContentViewModel(IEventAggregator eventAggregator)
+        {
+            this.eventAggregator = eventAggregator;
+            Unicode = App.mainWindowViewModel.SelectedItem.Unicode;
+            ChangeLocationCommand = new DelegateCommand<object>(ChangeLocation);
+            ChangeColorCommand = new DelegateCommand<object>(ChangeColor);
+            BackgroundInfo.Color = EditToolsHelper.ConvertColor(Color.FromArgb(0xFF, 0xFF, 0x00, 0x00));
+            InitComponent();
+            BackgroundInfo.Horizalign = C_Background_Horizalign.BG_HORIZALIGN_CENTER;
+            BackgroundInfo.Vertalign = C_Background_Vertalign.BG_VERTALIGN_CENTER;
+            InitLocationButtonMatrix();
+            eventAggregator.GetEvent<SaveBackgroundTemplateEvent>().Subscribe(SaveBackgroundTemplate, e => e.Unicode == Unicode);
+            eventAggregator.GetEvent<ConfirmEditBackgroundTemplateItemEvent>().Subscribe(ConfirmEditBackgroundTemplateItem, e => e.Unicode == Unicode);
+        }
+
+        public void InitComponent()
+        {
+            InitRotationList();
+            InitOpacityList();
+            InitRelativeRatioList();
+        }
+
+        private void InitRotationList()
+        {
+            OpacityList.Clear();
+            for (int defaultRotation = -45; defaultRotation <= 45; defaultRotation += 15)
+            {
+                RotationList.Add(defaultRotation.ToString());
+            }
+        }
+
+        private void InitOpacityList()
+        {
+            OpacityList.Clear();
+            for (int defaultOpacity = 10; defaultOpacity <= 100; defaultOpacity += 10)
+            {
+                OpacityList.Add(defaultOpacity.ToString() + " %");
+            }
+        }
+
+        private void InitRelativeRatioList()
+        {
+            RelativeRatioList.Clear();
+            for (int defaultRelativeRatioList = 10; defaultRelativeRatioList <= 100; defaultRelativeRatioList += 10)
+            {
+                RelativeRatioList.Add(defaultRelativeRatioList.ToString() + " %");
+            }
+        }
+
+        private void InitLocationButtonMatrix()
+        {
+            GetLocationFromNumber.Clear();
+            for (var temp = 0; temp <= 22; temp++)
+            {
+                GetLocationFromNumber.Add(temp.ToString(), true);
+                if (temp % 10 == 2)
+                {
+                    temp += 7;
+                }
+            }
+            int Num = (int)BackgroundInfo.Vertalign * 10 + (int)BackgroundInfo.Horizalign;
+            GetLocationFromNumber[Num.ToString()] = false;
+        }
+
+        public void ChangeLocation(object e)
+        {
+            string args = e as string;
+            if (args != null)
+            {
+                BackgroundInfo.Vertalign = (C_Background_Vertalign)(int.Parse(args) / 10);
+                BackgroundInfo.Horizalign = (C_Background_Horizalign)(int.Parse(args) % 10);
+                
+            }
+        }
+
+
+        public void ChangeColor(object e)
+        {
+            if (e != null)
+            {
+                var colorValue = (Color)e;
+                if (colorValue != null)
+                {
+                    Color = colorValue;
+                }
+            }
+        }
+
+        public void ConvertInfoToItem(ref BackgroundItem backgroundItem, BackgroundInfo backgroundInfo)
+        {
+            if (backgroundItem != null)
+            {
+                backgroundItem.type = C_Background_Type.BG_TYPE_COLOR;
+                backgroundItem.bgColor = backgroundInfo.Color;
+                backgroundItem.horizalign = backgroundInfo.Horizalign;
+                backgroundItem.vertalign = backgroundInfo.Vertalign;
+                backgroundItem.vertOffset = backgroundInfo.VertOffset;
+                backgroundItem.horizalign = backgroundInfo.Horizalign;
+                backgroundItem.opacity = backgroundInfo.Opacity;
+                backgroundItem.rotation = backgroundInfo.Rotation;
+                backgroundItem.PageRangeIndex = backgroundInfo.PageRangeIndex;
+                backgroundItem.pageRange = backgroundInfo.PageRange;
+                backgroundItem.isRelativeScale = backgroundInfo.IsRelativeScale;
+                backgroundItem.scale = backgroundInfo.Scale;
+            }
+
+        }
+
+        public void SaveCurrentTemplate()
+        {
+            var backgroundItem = new BackgroundItem();
+            ConvertInfoToItem(ref backgroundItem, BackgroundInfo);
+            backgroundItem.templateName += Settings.Default.BackgroundIndex.ToString();
+            try
+            {
+                //创建缓存文件夹
+                string folderPath = Path.Combine(App.CurrentPath, "Background");
+                //有可能因为其他原因存在同名文件,导致创建文件夹失败,需要先删除同名文件
+                //保险措施(猜测)
+                if (File.Exists(folderPath))
+                {
+                    File.Delete(folderPath);
+                }
+
+                DirectoryInfo tempfolder = new DirectoryInfo(folderPath);
+                if (!tempfolder.Exists)
+                {
+                    tempfolder.Create();
+                }
+
+                //预览图缓存
+                string saveName = Guid.NewGuid().ToString();
+                string savePath = Path.Combine(folderPath, saveName);
+                System.Windows.Size pageSize =new System.Windows.Size();
+                CPDFDocument tempDocument = CPDFDocument.CreateDocument();
+                if (tempDocument != null)
+                {
+                    tempDocument.InsertPage(0, 550, 880, null);
+                    var tempBackground = tempDocument.GetBackground();
+                    tempBackground.SetBackgroundType(BackgroundInfo.BackgroundType);
+                    tempBackground.SetColor(BackgroundInfo.Color);
+                    if (!BackgroundInfo.IsRelativeScale)
+                    {
+                        tempBackground.SetScale(1);
+                    }
+                    else
+                    {
+                        tempBackground.SetScale(BackgroundInfo.Scale / 100);
+                    }
+                    tempBackground.SetRotation((float)((BackgroundInfo.Rotation / 180) * Math.PI));
+                    tempBackground.SetOpacity((byte)((float)(BackgroundInfo.Opacity / 100) * 255));
+                    tempBackground.SetVertalign(BackgroundInfo.Vertalign);
+                    tempBackground.SetHorizalign(BackgroundInfo.Horizalign);
+                    tempBackground.SetXOffset(BackgroundInfo.HorizOffset);
+                    tempBackground.SetYOffset(BackgroundInfo.VertOffset);
+                    tempBackground.SetPages("0");
+                    tempBackground.SetAllowsPrint(true);
+                    tempBackground.SetAllowsView(true);
+                    tempBackground.Update();
+
+                    //获取透明背景的图片
+                    var bitmap = ToolMethod.RenderPageBitmapNoWait(tempDocument, 550, 880, 0, false, false, 0x00FFFFFF);
+                    using (FileStream stream = new FileStream(savePath, FileMode.Create))
+                    {
+                        bitmap.Save(stream, System.Drawing.Imaging.ImageFormat.Png);
+                    }
+
+                    backgroundItem.previewImagePath = savePath;
+                    tempDocument.Release();
+
+                    Settings.Default.BackgroundTemplateList.Add(backgroundItem);
+                    Settings.Default.Save();
+                }
+            }
+            catch
+            {
+
+            }
+
+            this.eventAggregator.GetEvent<EnterTemplateListOrCreateEvent>().Publish(new EnumTemplateListOrCreateUnicode
+            {
+                Unicode = Unicode,
+                Status = EnumTemplateListOrCreate.StatusTemplate
+            });
+        }
+
+        public void ConvertItemToInfo(BackgroundItem backgroundItem, ref BackgroundInfo backgroundInfo)
+        {
+            if (backgroundItem != null)
+            {
+                backgroundInfo.BackgroundType = C_Background_Type.BG_TYPE_COLOR;
+                backgroundInfo.Color = backgroundItem.bgColor;
+                backgroundInfo.Horizalign = backgroundItem.horizalign;
+                backgroundInfo.Vertalign = backgroundItem.vertalign;
+                backgroundInfo.VertOffset = backgroundItem.vertOffset;
+                backgroundInfo.Horizalign = backgroundItem.horizalign;
+                backgroundInfo.Opacity = backgroundItem.opacity;
+                backgroundInfo.Rotation = backgroundItem.rotation;
+                backgroundInfo.IsRelativeScale = backgroundItem.isRelativeScale;
+                backgroundInfo.Scale = backgroundItem.scale;
+                backgroundInfo.PageRangeIndex = backgroundItem.PageRangeIndex;
+                backgroundInfo.PageRange = backgroundItem.pageRange;
+            }
+        }
+
+        /// <summary>
+        /// 根据已知Info初始化
+        /// </summary>
+        public void InitComponentBySelectedInfo()
+        {
+            ConvertItemToInfo(TemplateBackgroundItem, ref BackgroundInfo);
+            Color = EditToolsHelper.ConvertColor(BackgroundInfo.Color);
+            RotationText = BackgroundInfo.Rotation.ToString();
+            OpacityText = BackgroundInfo.Opacity.ToString() + "%";
+            InitLocationButtonMatrix();
+            HorizontalOffsetValue = (BackgroundInfo.HorizOffset).ToString();
+            VerticalOffsetValue = (BackgroundInfo.VertOffset).ToString();
+            PageRangeSelectIndex = BackgroundInfo.PageRangeIndex;
+            IsRelativeScaleValue = BackgroundInfo.IsRelativeScale;
+        }
+
+        public void ConfirmEditBackgroundTemplateItem(EnumColorOrFileUnicode enumColorOrFileunicode)
+        {
+            EnumColorOrFile enumColorOrFile = enumColorOrFileunicode.Status;
+            if (enumColorOrFile == EnumColorOrFile.StatusColor)
+            {
+                var backgroundItem = new BackgroundItem();
+                ConvertInfoToItem(ref backgroundItem, BackgroundInfo);
+                try
+                {
+                    //创建缓存文件夹
+                    string folderPath = Path.Combine(App.CurrentPath, "Background");
+                    //有可能因为其他原因存在同名文件,导致创建文件夹失败,需要先删除同名文件
+                    //保险措施(猜测)
+                    if (File.Exists(folderPath))
+                    {
+                        File.Delete(folderPath);
+                    }
+
+                    DirectoryInfo tempfolder = new DirectoryInfo(folderPath);
+                    if (!tempfolder.Exists)
+                    {
+                        tempfolder.Create();
+                    }
+
+                    //预览图缓存
+                    string saveName = Guid.NewGuid().ToString();
+                    string savePath = Path.Combine(folderPath, saveName);
+                    System.Windows.Size pageSize = new System.Windows.Size();
+                    CPDFDocument tempDocument = CPDFDocument.CreateDocument();
+                    if (tempDocument != null)
+                    {
+                        tempDocument.InsertPage(0, 595, 842, null);
+                        var tempBackground = tempDocument.GetBackground();
+                        tempBackground.SetBackgroundType(BackgroundInfo.BackgroundType);
+                        tempBackground.SetColor(BackgroundInfo.Color);
+                        if (!BackgroundInfo.IsRelativeScale)
+                        {
+                            tempBackground.SetScale(1);
+                        }
+                        else
+                        {
+                            tempBackground.SetScale(BackgroundInfo.Scale / 100);
+
+                        }
+                        tempBackground.SetRotation((float)((BackgroundInfo.Rotation / 180) * Math.PI));
+                        tempBackground.SetOpacity((byte)((float)(BackgroundInfo.Opacity / 100) * 255));
+                        tempBackground.SetVertalign(BackgroundInfo.Vertalign);
+                        tempBackground.SetHorizalign(BackgroundInfo.Horizalign);
+                        tempBackground.SetXOffset(BackgroundInfo.HorizOffset);
+                        tempBackground.SetYOffset(BackgroundInfo.VertOffset);
+                        tempBackground.SetPages("0");
+                        tempBackground.SetAllowsPrint(true);
+                        tempBackground.SetAllowsView(true);
+                        tempBackground.Update();
+
+                        //获取透明背景的图片
+                        var bitmap = ToolMethod.RenderPageBitmapNoWait(tempDocument, 595, 842, 0, false, false, 0x00FFFFFF);
+                        using (FileStream stream = new FileStream(savePath, FileMode.Create))
+                        {
+                            bitmap.Save(stream, System.Drawing.Imaging.ImageFormat.Png);
+                        }
+
+                        backgroundItem.previewImagePath = savePath;
+                        tempDocument.Release();
+
+                        Settings.Default.BackgroundTemplateList[TemplateBackgroundItem.listIndex] = backgroundItem;
+                        Settings.Default.Save();
+                    }
+                }
+                catch
+                {
+
+                }
+                this.eventAggregator.GetEvent<EnterTemplateListOrCreateEvent>().Publish(new EnumTemplateListOrCreateUnicode
+                {
+                    Unicode = Unicode,
+                    Status = EnumTemplateListOrCreate.StatusTemplate
+                });
+            }
+        }
+
+
+        public void SaveBackgroundTemplate(EnumColorOrFileUnicode enumColorOrFileunicode)
+        {
+            EnumColorOrFile enumColorOrFile = enumColorOrFileunicode.Status;
+            if (enumColorOrFile == EnumColorOrFile.StatusColor)
+            {
+                SaveCurrentTemplate();
+            }
+        }
+
+        public bool IsNavigationTarget(NavigationContext navigationContext)
+        {
+            return true;
+        }
+
+        public void OnNavigatedFrom(NavigationContext navigationContext)
+        {
+        }
+
+        public void OnNavigatedTo(NavigationContext navigationContext)
+        {
+
+            navigationContext.Parameters.TryGetValue<CPDFViewer>(ParameterNames.PDFViewer, out PDFViewer);
+            //EditToolsHelper.GetPageRange(PageRangeSelectIndex, PDFViewer.Document, ref BackgroundInfo.PageRange, PageRangeText);
+            if (navigationContext.Parameters.TryGetValue<BackgroundItem>("BackgroundItem", out TemplateBackgroundItem))
+            {
+                InitComponentBySelectedInfo();
+            }
+        }
+    }
+}

+ 592 - 0
PDF Office/ViewModels/Dialog/HomePageToolsDialogs/HomePageBatchProcessing/HomePageBackground/HomePageBackgroundCreateFileContentViewModel.cs

@@ -0,0 +1,592 @@
+using ComPDFKit.PDFDocument;
+using ComPDFKit.PDFPage;
+using ComPDFKitViewer.PdfViewer;
+using PDF_Office.EventAggregators;
+using PDF_Office.Helper;
+using PDF_Office.Model.EditTools.Background;
+using PDF_Office.Model;
+using PDF_Office.Properties;
+using PDFSettings;
+using Prism.Commands;
+using Prism.Events;
+using Prism.Mvvm;
+using Prism.Regions;
+using System;
+using System.Collections.Generic;
+using System.IO;
+using System.Linq;
+using System.Windows;
+using System.Threading.Tasks;
+
+namespace PDF_Office.ViewModels.Dialog.HomePageToolsDialogs.HomePageBatchProcessing.HomePageBackground
+{
+    public class HomePageBackgroundCreateFileContentViewModel : BindableBase, INavigationAware
+    {
+        IEventAggregator eventAggregator;
+
+        private BackgroundItem TemplateBackgroundItem;
+
+        public BackgroundInfo BackgroundInfo = new BackgroundInfo();
+        private CPDFViewer PDFViewer;
+
+        private List<string> _rotationList = new List<string>();
+        public List<string> RotationList
+        {
+            get { return _rotationList; }
+            set { SetProperty(ref _rotationList, value); }
+        }
+
+        private List<string> _opacityList = new List<string>();
+        public List<string> OpacityList
+        {
+            get { return _opacityList; }
+            set
+            {
+                SetProperty(ref _opacityList, value);
+            }
+        }
+
+        private List<string> _relativeRatioList = new List<string>();
+        public List<string> RelativeRatioList
+        {
+            get { return _relativeRatioList; }
+            set
+            {
+                SetProperty(ref _relativeRatioList, value);
+            }
+        }
+
+        private int _rotationValue = 0;
+        public int RotationValue
+        {
+            get { return _rotationValue; }
+            set
+            {
+                SetProperty(ref _rotationValue, value);
+                BackgroundInfo.Rotation = value;
+                
+
+            }
+        }
+
+
+        private int _opacityValue = 100;
+        public int OpacityValue
+        {
+            get { return _opacityValue; }
+            set
+            {
+                SetProperty(ref _opacityValue, value);
+                BackgroundInfo.Opacity = (byte)(value);
+                
+
+            }
+        }
+
+        private int _relativeRatioValue = 50;
+        public int RelativeRatioValue
+        {
+            get { return _relativeRatioValue; }
+            set
+            {
+                SetProperty(ref _rotationValue, value);
+                BackgroundInfo.Scale = value;
+                
+
+            }
+        }
+
+        private string _verticalOffsetValue = "0";
+        public string VerticalOffsetValue
+        {
+            get { return _verticalOffsetValue; }
+            set
+            {
+                SetProperty(ref _verticalOffsetValue, value);
+                BackgroundInfo.VertOffset = float.Parse(VerticalOffsetValue);
+               
+
+            }
+        }
+
+        private string _relativeScaleText = "50 %";
+        public string RelativeScaleText
+        {
+            get { return _relativeScaleText; }
+            set
+            {
+                SetProperty(ref _relativeScaleText, value);
+                
+
+            }
+        }
+
+
+        private string _horizOffsetValue = "0";
+        public string HorizontalOffsetValue
+        {
+            get { return _horizOffsetValue; }
+            set
+            {
+                SetProperty(ref _horizOffsetValue, value);
+                BackgroundInfo.HorizOffset = float.Parse(HorizontalOffsetValue);
+                
+
+            }
+        }
+
+        private string _rotationText = "0";
+        public string RotationText
+        {
+            get { return _rotationText; }
+            set
+            {
+                SetProperty(ref _rotationText, value);
+            }
+        }
+
+        private string _opacityText = "100 %";
+        public string OpacityText
+        {
+            get { return _opacityText; }
+            set
+            {
+                SetProperty(ref _opacityText, value);
+
+            }
+        }
+
+        private ObservableDictionary<string, bool> _getLocationFromNumber = new ObservableDictionary<string, bool>();
+        public ObservableDictionary<string, bool> GetLocationFromNumber
+        {
+            get { return _getLocationFromNumber; }
+        }
+
+        private string _fileNameText = "";
+        public string FileNameText
+        {
+            get { return _fileNameText; }
+            set
+            {
+                SetProperty(ref _fileNameText, value);
+            }
+        }
+
+        private bool isFirstEnter = true;
+        public bool IsFirstEnter
+        {
+            get => isFirstEnter;
+            set => isFirstEnter = value;
+        }
+
+        private Visibility _createModFileVisible = Visibility.Collapsed;
+        public Visibility CreateModFileVisible
+        {
+            get => _createModFileVisible;
+            set => SetProperty(ref _createModFileVisible, value);
+        }
+
+        private bool _isRelativeScaleValue = false;
+        public bool IsRelativeScaleValue
+        {
+            get { return _isRelativeScaleValue; }
+            set
+            {
+                SetProperty(ref _isRelativeScaleValue, value);
+                BackgroundInfo.IsRelativeScale = IsRelativeScaleValue;
+                
+
+            }
+        }
+
+
+
+        public DelegateCommand OpenFileCommand { get; set; }
+        public DelegateCommand<object> ChangeLocationCommand { get; set; }
+
+        public string unicode = null;
+        public string Unicode = null;
+
+        public HomePageBackgroundCreateFileContentViewModel(IEventAggregator eventAggregator)
+        {
+            this.eventAggregator = eventAggregator;
+            Unicode = App.mainWindowViewModel.SelectedItem.Unicode;
+            BackgroundInfo.BackgroundType = C_Background_Type.BG_TYPE_IMAGE;
+            ChangeLocationCommand = new DelegateCommand<object>(ChangeLocation);
+            InitComponent();
+            BackgroundInfo.Horizalign = C_Background_Horizalign.BG_HORIZALIGN_CENTER;
+            BackgroundInfo.Vertalign = C_Background_Vertalign.BG_VERTALIGN_CENTER;
+            InitLocationButtonMatrix();
+            OpenFileCommand = new DelegateCommand(OpenFile);
+            eventAggregator.GetEvent<SaveBackgroundTemplateEvent>().Subscribe(SaveBackgroundTemplate, e => e.Unicode == Unicode);
+            eventAggregator.GetEvent<ConfirmEditBackgroundTemplateItemEvent>().Subscribe(ConfirmEditBackgroundTemplateItem, e => e.Unicode == Unicode);
+
+
+        }
+
+        public string _pageRangeText { get; set; } = "0";
+        public string PageRangeText
+        {
+            get { return _pageRangeText; }
+            set
+            {
+                _pageRangeText = value;
+               // EditToolsHelper.GetPageRange(PageRangeSelectIndex, PDFViewer.Document, ref BackgroundInfo.PageRange, PageRangeText);
+                
+            }
+        }
+
+        private int _pageRangeSelectIndex = 0;
+        public int PageRangeSelectIndex
+        {
+            get { return _pageRangeSelectIndex; }
+            set
+            {
+                SetProperty(ref _pageRangeSelectIndex, value);
+                //EditToolsHelper.GetPageRange(PageRangeSelectIndex, PDFViewer.Document, ref BackgroundInfo.PageRange, PageRangeText);
+            }
+        }
+
+
+        public void InitComponent()
+        {
+            InitOpacityList();
+            InitRotationList();
+            InitRelativeRatioList();
+        }
+
+        private void InitRotationList()
+        {
+            RotationList.Clear();
+            for (int defaultRotation = -45; defaultRotation <= 45; defaultRotation += 15)
+            {
+                RotationList.Add(defaultRotation.ToString());
+            }
+        }
+
+        private void InitOpacityList()
+        {
+            OpacityList.Clear();
+            for (int defaultOpacity = 10; defaultOpacity <= 100; defaultOpacity += 10)
+            {
+                OpacityList.Add(defaultOpacity.ToString() + " %");
+            }
+        }
+
+        private void InitRelativeRatioList()
+        {
+            RelativeRatioList.Clear();
+            for (int defaultRelativeRatioList = 10; defaultRelativeRatioList <= 100; defaultRelativeRatioList += 10)
+            {
+                RelativeRatioList.Add(defaultRelativeRatioList.ToString() + " %");
+            }
+        }
+
+        private void InitLocationButtonMatrix()
+        {
+            GetLocationFromNumber.Clear();
+            for (var temp = 0; temp <= 22; temp++)
+            {
+                GetLocationFromNumber.Add(temp.ToString(), true);
+                if (temp % 10 == 2)
+                {
+                    temp += 7;
+                }
+            }
+            int Num = (int)BackgroundInfo.Vertalign * 10 + (int)BackgroundInfo.Horizalign;
+            GetLocationFromNumber[Num.ToString()] = false;
+
+        }
+
+        public void InitComponentBySelectedInfo()
+        {
+            ConvertItemToInfo(TemplateBackgroundItem, ref BackgroundInfo);
+            RotationText = BackgroundInfo.Rotation.ToString();
+            OpacityText = BackgroundInfo.Opacity.ToString();
+            InitLocationButtonMatrix();
+            IsRelativeScaleValue = BackgroundInfo.IsRelativeScale;
+            RelativeScaleText = BackgroundInfo.Scale.ToString();
+            HorizontalOffsetValue = (BackgroundInfo.HorizOffset).ToString();
+            VerticalOffsetValue = (BackgroundInfo.VertOffset).ToString();
+            PageRangeSelectIndex = BackgroundInfo.PageRangeIndex;
+        }
+
+        public void ChangeLocation(object e)
+        {
+            string args = e as string;
+            if (args != null)
+            {
+                BackgroundInfo.Vertalign = (C_Background_Vertalign)(int.Parse(args) / 10);
+                BackgroundInfo.Horizalign = (C_Background_Horizalign)(int.Parse(args) % 10);
+                
+
+                InitLocationButtonMatrix();
+            }
+        }
+
+        public void OpenFile()
+        {
+            System.Windows.Forms.OpenFileDialog dlg = new System.Windows.Forms.OpenFileDialog();
+            dlg.Multiselect = false;
+            dlg.Filter = "PDF|*.png;*.jpg;*.pdf";
+            if (dlg.ShowDialog() == System.Windows.Forms.DialogResult.OK)
+            {
+                FileNameText = dlg.SafeFileName;
+                FileInfo file = new FileInfo(dlg.FileName);
+                if (file.Extension == ".pdf")
+                {
+                    GetBitmapFromDocment(dlg.FileName);
+                }
+                else
+                {
+                    EditToolsHelper.ChooseFile(dlg.FileName, ref BackgroundInfo);
+                }
+                CreateModFileVisible = Visibility.Visible;
+                
+
+            }
+        }
+
+        public async void GetBitmapFromDocment(string filePath)
+        {
+            CPDFDocument document = CPDFDocument.InitWithFilePath(filePath);
+            CPDFPage page = document.PageAtIndex(0);
+            byte[] bmp_data = new byte[(int)page.PageSize.Width * (int)page.PageSize.Height * 4];
+            await Task.Run(delegate
+            {
+                page.RenderPageBitmap(0, 0, (int)page.PageSize.Width, (int)page.PageSize.Height, 0xffffffff, bmp_data, 1);
+            });
+            BackgroundInfo.ImageArray = bmp_data;
+            BackgroundInfo.ImageWidth = (int)page.PageSize.Width;
+            BackgroundInfo.ImageHeight = (int)page.PageSize.Height;
+            document.ReleasePages();
+            document.Release();
+        }
+
+        public void ConvertItemToInfo(BackgroundItem backgroundItem, ref BackgroundInfo backgroundInfo)
+        {
+            if (backgroundItem != null)
+            {
+                backgroundInfo.BackgroundType = C_Background_Type.BG_TYPE_IMAGE;
+                backgroundInfo.Color = backgroundItem.bgColor;
+                backgroundInfo.Horizalign = backgroundItem.horizalign;
+                backgroundInfo.Vertalign = backgroundItem.vertalign;
+                backgroundInfo.VertOffset = backgroundItem.vertOffset;
+                backgroundInfo.Horizalign = backgroundItem.horizalign;
+                backgroundInfo.Opacity = backgroundItem.opacity;
+                backgroundInfo.Rotation = backgroundItem.rotation;
+                backgroundInfo.IsRelativeScale = backgroundItem.isRelativeScale;
+
+                backgroundInfo.Scale = backgroundItem.scale;
+                backgroundInfo.PageRangeIndex = backgroundItem.PageRangeIndex;
+                backgroundInfo.PageRange = backgroundItem.pageRange;
+            }
+        }
+        public void ConvertInfoToItem(ref BackgroundItem backgroundItem, BackgroundInfo backgroundInfo)
+        {
+            backgroundItem.type = C_Background_Type.BG_TYPE_IMAGE;
+            backgroundItem.imageArray = backgroundInfo.ImageArray;
+            backgroundItem.imageWidth = backgroundInfo.ImageWidth;
+            backgroundItem.imageHeight = backgroundInfo.ImageHeight;
+            backgroundItem.horizalign = backgroundInfo.Horizalign;
+            backgroundItem.vertalign = backgroundInfo.Vertalign;
+            backgroundItem.vertOffset = backgroundInfo.VertOffset;
+            backgroundItem.horizalign = backgroundInfo.Horizalign;
+            backgroundItem.opacity = backgroundInfo.Opacity;
+            backgroundItem.rotation = backgroundInfo.Rotation;
+            backgroundItem.isRelativeScale = backgroundInfo.IsRelativeScale;
+            backgroundItem.scale = backgroundInfo.Scale;
+            //backgroundItem.pagRangeMode = backgroundInfo.PageRange;
+        }
+
+        public void SaveCurrentTemplate()
+        {
+            var backgroundItem = new BackgroundItem();
+            ConvertInfoToItem(ref backgroundItem, BackgroundInfo);
+            backgroundItem.templateName += Settings.Default.BackgroundIndex.ToString();
+            try
+            {
+                //创建缓存文件夹
+                string folderPath = Path.Combine(App.CurrentPath, "Background");
+                //有可能因为其他原因存在同名文件,导致创建文件夹失败,需要先删除同名文件
+                //保险措施(猜测)
+                if (File.Exists(folderPath))
+                {
+                    File.Delete(folderPath);
+                }
+
+                DirectoryInfo tempfolder = new DirectoryInfo(folderPath);
+                if (!tempfolder.Exists)
+                {
+                    tempfolder.Create();
+                }
+
+                //预览图缓存
+                string saveName = Guid.NewGuid().ToString();
+                string savePath = Path.Combine(folderPath, saveName);
+                System.Windows.Size pageSize =new System.Windows.Size() ;
+                CPDFDocument tempDocument = CPDFDocument.CreateDocument();
+                if (tempDocument != null)
+                {
+                    tempDocument.InsertPage(0, 595, 842, null);
+                    var tempBackground = tempDocument.GetBackground();
+                    tempBackground.SetBackgroundType(BackgroundInfo.BackgroundType);
+                    tempBackground.SetImage(BackgroundInfo.ImageArray, BackgroundInfo.ImageWidth, BackgroundInfo.ImageHeight, ComPDFKit.Import.C_Scale_Type.fitCenter);
+                    if (!BackgroundInfo.IsRelativeScale)
+                    {
+                        tempBackground.SetScale(1);
+                    }
+                    else
+                    {
+                        tempBackground.SetScale(BackgroundInfo.Scale / 100);
+
+                    }
+                    tempBackground.SetRotation((float)((BackgroundInfo.Rotation / 180) * Math.PI));
+                    tempBackground.SetOpacity((byte)((float)(BackgroundInfo.Opacity / 100) * 255));
+                    tempBackground.SetVertalign(BackgroundInfo.Vertalign);
+                    tempBackground.SetHorizalign(BackgroundInfo.Horizalign);
+                    tempBackground.SetXOffset(BackgroundInfo.HorizOffset);
+                    tempBackground.SetYOffset(BackgroundInfo.VertOffset);
+                    tempBackground.SetPages("0");
+                    tempBackground.SetAllowsPrint(true);
+                    tempBackground.SetAllowsView(true);
+                    tempBackground.Update();
+
+                    //获取透明背景的图片
+                    var bitmap = ToolMethod.RenderPageBitmapNoWait(tempDocument, 595, 842, 0, false, false, 0x00FFFFFF);
+                    using (FileStream stream = new FileStream(savePath, FileMode.Create))
+                    {
+                        bitmap.Save(stream, System.Drawing.Imaging.ImageFormat.Png);
+                    }
+
+                    backgroundItem.previewImagePath = savePath;
+                    tempDocument.Release();
+
+                    Settings.Default.BackgroundTemplateList.Add(backgroundItem);
+                    Settings.Default.Save();
+                }
+            }
+            catch
+            {
+
+            }
+            this.eventAggregator.GetEvent<EnterTemplateListOrCreateEvent>().Publish(new EnumTemplateListOrCreateUnicode
+            {
+                Unicode = Unicode,
+                Status = EnumTemplateListOrCreate.StatusTemplate
+            });
+        }
+
+        public void ConfirmEditBackgroundTemplateItem(EnumColorOrFileUnicode enumColorOrFileunicode)
+        {
+            EnumColorOrFile enumColorOrFile = enumColorOrFileunicode.Status;
+            if (enumColorOrFile == EnumColorOrFile.StatusFile)
+            {
+                var backgroundItem = new BackgroundItem();
+                ConvertInfoToItem(ref backgroundItem, BackgroundInfo);
+
+                this.eventAggregator.GetEvent<EnterTemplateListOrCreateEvent>().Publish(new EnumTemplateListOrCreateUnicode { Unicode = Unicode, Status = EnumTemplateListOrCreate.StatusTemplate });
+
+                try
+                {
+                    //创建缓存文件夹
+                    string folderPath = Path.Combine(App.CurrentPath, "Background");
+                    //有可能因为其他原因存在同名文件,导致创建文件夹失败,需要先删除同名文件
+                    //保险措施(猜测)
+                    if (File.Exists(folderPath))
+                    {
+                        File.Delete(folderPath);
+                    }
+
+                    DirectoryInfo tempfolder = new DirectoryInfo(folderPath);
+                    if (!tempfolder.Exists)
+                    {
+                        tempfolder.Create();
+                    }
+
+                    //预览图缓存
+                    string saveName = Guid.NewGuid().ToString();
+                    string savePath = Path.Combine(folderPath, saveName);
+                    System.Windows.Size pageSize = PDFViewer.Document.GetPageSize(0);
+                    CPDFDocument tempDocument = CPDFDocument.CreateDocument();
+                    if (tempDocument != null)
+                    {
+                        tempDocument.InsertPage(0, pageSize.Width, pageSize.Height, null);
+                        var tempBackground = tempDocument.GetBackground();
+                        tempBackground.SetBackgroundType(BackgroundInfo.BackgroundType);
+                        tempBackground.SetImage(BackgroundInfo.ImageArray, BackgroundInfo.ImageWidth, BackgroundInfo.ImageHeight, ComPDFKit.Import.C_Scale_Type.fitCenter);
+                        if (!BackgroundInfo.IsRelativeScale)
+                        {
+                            tempBackground.SetScale(1);
+                        }
+                        else
+                        {
+                            tempBackground.SetScale(BackgroundInfo.Scale / 100);
+
+                        }
+                        tempBackground.SetRotation((float)((BackgroundInfo.Rotation / 180) * Math.PI));
+                        tempBackground.SetOpacity((byte)((float)(BackgroundInfo.Opacity / 100) * 255));
+                        tempBackground.SetVertalign(BackgroundInfo.Vertalign);
+                        tempBackground.SetHorizalign(BackgroundInfo.Horizalign);
+                        tempBackground.SetXOffset(BackgroundInfo.HorizOffset);
+                        tempBackground.SetYOffset(BackgroundInfo.VertOffset);
+                        tempBackground.SetPages("0");
+                        tempBackground.SetAllowsPrint(true);
+                        tempBackground.SetAllowsView(true);
+                        tempBackground.Update();
+
+                        //获取透明背景的图片
+                        var bitmap = ToolMethod.RenderPageBitmapNoWait(tempDocument, (int)pageSize.Width, (int)pageSize.Height, 0, false, false, 0x00FFFFFF);
+                        using (FileStream stream = new FileStream(savePath, FileMode.Create))
+                        {
+                            bitmap.Save(stream, System.Drawing.Imaging.ImageFormat.Png);
+                        }
+
+                        backgroundItem.previewImagePath = savePath;
+                        tempDocument.Release();
+
+                        Settings.Default.BackgroundTemplateList[TemplateBackgroundItem.listIndex] = backgroundItem;
+                        Settings.Default.Save();
+                    }
+                }
+                catch
+                {
+
+                }
+                this.eventAggregator.GetEvent<EnterTemplateListOrCreateEvent>().Publish(new EnumTemplateListOrCreateUnicode
+                {
+                    Unicode = Unicode,
+                    Status = EnumTemplateListOrCreate.StatusTemplate
+                });
+            }
+        }
+
+
+        public void SaveBackgroundTemplate(EnumColorOrFileUnicode enumColorOrFileunicode)
+        {
+            EnumColorOrFile enumColorOrFile = enumColorOrFileunicode.Status;
+            if (enumColorOrFile == EnumColorOrFile.StatusFile)
+            {
+                SaveCurrentTemplate();
+            }
+        }
+        public bool IsNavigationTarget(NavigationContext navigationContext)
+        {
+            return true;
+        }
+
+        public void OnNavigatedFrom(NavigationContext navigationContext)
+        {
+        }
+
+        public void OnNavigatedTo(NavigationContext navigationContext)
+        {
+            navigationContext.Parameters.TryGetValue<CPDFViewer>(ParameterNames.PDFViewer, out PDFViewer);
+            navigationContext.Parameters.TryGetValue<string>("UniCode", out unicode);
+            if (navigationContext.Parameters.TryGetValue<BackgroundItem>("BackgroundItem", out TemplateBackgroundItem))
+            {
+                InitComponentBySelectedInfo();
+            }
+        }
+    }
+}

+ 132 - 4
PDF Office/ViewModels/Dialog/HomePageToolsDialogs/HomePageBatchProcessing/HomePageBackground/HomePageBackgroundDialogViewModel.cs

@@ -14,6 +14,10 @@ using PDF_Office.Model;
 using System.Diagnostics;
 using System.IO;
 using System.Windows.Forms;
+using Prism.Events;
+using ComPDFKitViewer.PdfViewer;
+using PDF_Office.EventAggregators;
+using PDFSettings;
 
 namespace PDF_Office.ViewModels.Dialog.HomePageToolsDialogs.HomePageBatchProcessing.HomePageBackground
 {
@@ -27,7 +31,55 @@ namespace PDF_Office.ViewModels.Dialog.HomePageToolsDialogs.HomePageBatchProcess
 
         public string PageNumber = "";
 
-        public IRegionManager BackgroundRegion;
+        public IRegionManager backgroundRegion;
+        public IEventAggregator eventAggregator;
+
+        private CPDFViewer PDFViewer;
+
+        private ViewContentViewModel viewContentViewModel;
+
+        public string TemplateListBaseName = "HomePageBackgroundTemplateListBaseContent";
+        public string CreateBaseName = "HomePageBackgroundCreateBaseContent";
+
+        public string CreateModColorName = "HomePageBackgroundCreateColorContent";
+        public string CreateModFileName = "HomePageBackgroundCreateFileContent";
+
+        public string TemplateListModColorName = "HomePageBackgroundTemplateListColorContent";
+        public string TemplateListModFileName = "HomePageBackgroundTemplateListFileContent";
+
+        private string _backgroundSettingsRegionName;
+        /// <summary>
+        /// 属性设置Region
+        /// </summary>
+        public string BackgroundSettingsRegionName
+        {
+            get { return _backgroundSettingsRegionName; }
+            set { _backgroundSettingsRegionName = value; }
+        }
+
+        private Visibility _backgroundSettingsVisible = Visibility.Collapsed;
+        /// <summary>
+        /// 属性设置Region可见
+        /// </summary>
+        public Visibility BackgroundSettingsVisible
+        {
+            get { return _backgroundSettingsVisible; }
+            set { _backgroundSettingsVisible = value; }
+        }
+
+        private EnumColorOrFile _currentCreateMod;
+        public EnumColorOrFile CurrentCreateMod
+        {
+            get { return _currentCreateMod; }
+            set { _currentCreateMod = value; }
+        }
+
+        private EnumColorOrFile _currentTemplateListMod;
+        public EnumColorOrFile CurrentTemplateListMod
+        {
+            get { return _currentTemplateListMod; }
+            set { _currentTemplateListMod = value; }
+        }
 
         public List<int> fileNamesView = new List<int>();
 
@@ -131,22 +183,95 @@ namespace PDF_Office.ViewModels.Dialog.HomePageToolsDialogs.HomePageBatchProcess
 
         public DelegateCommand ADDPDFFilesCommand { get; set; }
         #endregion
-        public HomePageBackgroundDialogViewModel(IRegionManager backgroundRegion)
+
+        public string Unicode = null;
+
+        public HomePageBackgroundDialogViewModel(IRegionManager backgroundRegion, IEventAggregator eventAggregator)
         {
+            this.eventAggregator = eventAggregator;
+            this.backgroundRegion = backgroundRegion;
             PDFDataTable.Columns.Add("FileName");
             PDFDataTable.Columns.Add("FilePageRangeText");
             PDFDataTable.Columns.Add("FilePageRangeSelectIndex");
             PDFDataTable.Columns.Add("FileSize");
             PDFDataTable.Columns.Add("FileState");
+            Unicode = App.mainWindowViewModel.SelectedItem.Unicode;
+            BackgroundSettingsVisible = Visibility.Visible;
             ADDPDFCommand = new DelegateCommand(addpicture);
             ADDPDFFilesCommand = new DelegateCommand(addpicturefiles);
             RemovePDFFileCommand = new DelegateCommand(removepdffile);
             CreateCommand = new DelegateCommand(create);
-            BackgroundRegion = backgroundRegion;
-            BackgroundRegionName = Guid.NewGuid().ToString();
+            BackgroundSettingsRegionName = Guid.NewGuid().ToString();
+            eventAggregator.GetEvent<EnterTemplateListOrCreateEvent>().Subscribe(EnterTemplateListOrCreate, e => e.Unicode == Unicode);
+            eventAggregator.GetEvent<SetCurrentCreateModEvent>().Subscribe(SetCurrentCreateMod, e => e.Unicode == Unicode);
+            eventAggregator.GetEvent<SetCurrentTemplateListModEvent>().Subscribe(SetCurrentTemplateListMod, e => e.Unicode == Unicode);
+            eventAggregator.GetEvent<EditBackgroundTemplateItemEvent>().Subscribe(EditBackgroundTemplateItem, e => e.Unicode == Unicode);
         }
         #region 逻辑函数
+        public void EnterTemplateListOrCreate(EnumTemplateListOrCreateUnicode enumTemplateListOrCreateunicode)
+        {
+            EnumTemplateListOrCreate enumTemplateListOrCreate = enumTemplateListOrCreateunicode.Status;
+            if (enumTemplateListOrCreate == EnumTemplateListOrCreate.StatusTemplate)
+            {
+                EnterSelectedContent(TemplateListBaseName);
+            }
+            else
+            {
+                EnterSelectedContent(CreateBaseName);
+            }
+        }
+        public void EnterSelectedContent(string SelectedContentName)
+        {
+            NavigationParameters param = new NavigationParameters();
+            param.Add(ParameterNames.PDFViewer, PDFViewer);
+            if (SelectedContentName == TemplateListBaseName)
+            {
+                param.Add("CurrentCreateModName", CurrentCreateMod);
+            }
+            else if (SelectedContentName == CreateBaseName)
+            {
+                param.Add("CurrentTemplateListModName", CurrentTemplateListMod);
+            }
+            backgroundRegion.RequestNavigate(BackgroundSettingsRegionName, SelectedContentName, param);
+            BackgroundSettingsVisible = Visibility.Visible;
+        }
+
+        public void SetCurrentCreateMod(stringUnicode currentCreateModNameunicode)
+        {
+            string currentCreateModName = currentCreateModNameunicode.Status;
+            if (currentCreateModName == CreateModColorName)
+            {
+                CurrentCreateMod = EnumColorOrFile.StatusColor;
+            }
+            else if (currentCreateModName == CreateModFileName)
+            {
+                CurrentCreateMod = EnumColorOrFile.StatusFile;
+            }
+        }
 
+        public void SetCurrentTemplateListMod(stringUnicode currentTemplateListModNameunicode)
+        {
+            string currentTemplateListModName = currentTemplateListModNameunicode.Status;
+            if (currentTemplateListModName == TemplateListModColorName)
+            {
+                CurrentTemplateListMod = EnumColorOrFile.StatusColor;
+            }
+            else if (currentTemplateListModName == TemplateListModFileName)
+            {
+                CurrentTemplateListMod = EnumColorOrFile.StatusFile;
+            }
+        }
+
+        public void EditBackgroundTemplateItem(BackgroundItemUnicode backgroundItemunicode)
+        {
+            BackgroundItem backgroundItem = backgroundItemunicode.Status;
+            NavigationParameters param = new NavigationParameters();
+            param.Add(ParameterNames.PDFViewer, PDFViewer);
+            param.Add("CurrentTemplateListModName", CurrentTemplateListMod);
+            param.Add("BackgroundItem", backgroundItem);
+            backgroundRegion.RequestNavigate(BackgroundSettingsRegionName, CreateBaseName, param);
+            BackgroundSettingsVisible = Visibility.Visible;
+        }
 
         private void create()
         {
@@ -335,12 +460,15 @@ namespace PDF_Office.ViewModels.Dialog.HomePageToolsDialogs.HomePageBatchProcess
         public void OnNavigatedTo(NavigationContext navigationContext)
         {
             List<string> filepath = new List<string>();
+            navigationContext.Parameters.TryGetValue<ViewContentViewModel>(ParameterNames.ViewContentViewModel, out viewContentViewModel);
+            navigationContext.Parameters.TryGetValue<CPDFViewer>(ParameterNames.PDFViewer, out PDFViewer);
             navigationContext.Parameters.TryGetValue<List<string>>(ParameterNames.FilePath, out filepath);
             if (filepath != null)
             {
                 fileNames = filepath;
                 PDFFileCount();
                 updateListview("待确定");
+                EnterSelectedContent(TemplateListBaseName);
             }
         }
 

+ 138 - 0
PDF Office/ViewModels/Dialog/HomePageToolsDialogs/HomePageBatchProcessing/HomePageBackground/HomePageBackgroundTemplateListBaseContentViewModel.cs

@@ -0,0 +1,138 @@
+using PDF_Office.EventAggregators;
+using Prism.Commands;
+using Prism.Events;
+using Prism.Mvvm;
+using Prism.Regions;
+using System;
+using System.Collections.Generic;
+using System.Linq;
+using System.Windows.Controls;
+
+namespace PDF_Office.ViewModels.Dialog.HomePageToolsDialogs.HomePageBatchProcessing.HomePageBackground
+{
+    public class HomePageBackgroundTemplateListBaseContentViewModel : BindableBase, INavigationAware
+    {
+        public IRegionManager backgroundTemplateListRegion;
+        private readonly IEventAggregator eventAggregator;
+
+        private string BackgroundTemplateListColorContentName = "HomePageBackgroundTemplateListColorContent";
+        private string BackgroundTemplateListFileContentName = "HomePageBackgroundTemplateListFileContent";
+
+        public EnumColorOrFile CurrentCreateMod;
+
+
+        private string _currentTemplateListModName;
+        public string CurrentTemplateListModName
+        {
+            get { return _currentTemplateListModName; }
+            set { _currentTemplateListModName = value; }
+        }
+
+        private string backgroundTemplateListRegionName;
+
+        public string BackgroundTemplateListRegionName
+        {
+            get => backgroundTemplateListRegionName;
+            set => SetProperty(ref backgroundTemplateListRegionName, value);
+        }
+
+
+        private System.Windows.Visibility backgroundTemplateListVisible;
+        public System.Windows.Visibility BackgroundTemplateListVisible
+        {
+            get => backgroundTemplateListVisible;
+            set => SetProperty(ref backgroundTemplateListVisible, value);
+        }
+
+        private bool isFirstEnter = true;
+        public bool IsFirstEnter
+        {
+            get => isFirstEnter;
+            set => isFirstEnter = value;
+        }
+
+        public DelegateCommand<object> ChangeTemplateListModCommand { get; set; }
+        public DelegateCommand EnterCreateCommand { get; set; }
+
+        public string unicode = null;
+        public string Unicode = null;
+
+        public HomePageBackgroundTemplateListBaseContentViewModel(IRegionManager backgroundTemplateListRegion, IEventAggregator eventAggregator)
+        {
+            this.backgroundTemplateListRegion = backgroundTemplateListRegion;
+            this.eventAggregator = eventAggregator;
+            Unicode = App.mainWindowViewModel.SelectedItem.Unicode;
+            BackgroundTemplateListRegionName = Guid.NewGuid().ToString();
+            ChangeTemplateListModCommand = new DelegateCommand<object>(ChangeTemplateListMod);
+            EnterCreateCommand = new DelegateCommand(EnterCreate);
+        }
+
+        public void EnterCreate()
+        {
+            this.eventAggregator.GetEvent<EnterTemplateListOrCreateEvent>().Publish(new EnumTemplateListOrCreateUnicode { Unicode = Unicode, Status = EnumTemplateListOrCreate.StatusCreate });
+        }
+
+        public void EnterSelectedTemplateListMod(string currentTemplateListName)
+        {
+            NavigationParameters param = new NavigationParameters();
+            param.Add("UniCode", unicode);
+            backgroundTemplateListRegion.RequestNavigate(BackgroundTemplateListRegionName, currentTemplateListName);
+            backgroundTemplateListVisible = System.Windows.Visibility.Visible;
+        }
+
+        public void ChangeTemplateListMod(object e)
+        {
+            var args = e as Button;
+            if (args != null)
+            {
+                CurrentTemplateListModName = args.Name;
+                EnterSelectedTemplateListMod(CurrentTemplateListModName);
+                eventAggregator.GetEvent<SetCurrentTemplateListModEvent>().Publish(new stringUnicode
+                {
+                    Unicode = Unicode,
+                    Status = CurrentTemplateListModName
+                });
+            }
+        }
+
+        public bool IsNavigationTarget(NavigationContext navigationContext)
+        {
+            return true;
+        }
+
+        public void OnNavigatedFrom(NavigationContext navigationContext)
+        {
+        }
+
+        public void OnNavigatedTo(NavigationContext navigationContext)
+        {
+
+            navigationContext.Parameters.TryGetValue<string>("UniCode", out unicode);
+            if (IsFirstEnter)
+            {
+                CurrentTemplateListModName = BackgroundTemplateListColorContentName;
+                EnterSelectedTemplateListMod(CurrentTemplateListModName);
+                IsFirstEnter = false;
+            }
+            else
+            {
+                navigationContext.Parameters.TryGetValue<EnumColorOrFile>("CurrentCreateModName", out CurrentCreateMod);
+                if (CurrentCreateMod == EnumColorOrFile.StatusColor)
+                {
+                    CurrentTemplateListModName = "HomePageBackgroundTemplateListColorContent";
+                }
+                else
+                {
+                    CurrentTemplateListModName = "HomePageBackgroundTemplateListFileContent";
+                }
+                EnterSelectedTemplateListMod(CurrentTemplateListModName);
+                eventAggregator.GetEvent<SetCurrentTemplateListModEvent>().Publish(new stringUnicode
+                {
+                    Unicode = Unicode,
+                    Status = CurrentTemplateListModName
+                });
+
+            }
+        }
+    }
+}

+ 237 - 0
PDF Office/ViewModels/Dialog/HomePageToolsDialogs/HomePageBatchProcessing/HomePageBackground/HomePageBackgroundTemplateListColorContentViewModel.cs

@@ -0,0 +1,237 @@
+using PDF_Office.EventAggregators;
+using PDF_Office.Model.EditTools.Background;
+using PDF_Office.Properties;
+using PDFSettings;
+using Prism.Commands;
+using Prism.Events;
+using Prism.Mvvm;
+using Prism.Regions;
+using System;
+using System.Collections.Generic;
+using System.Collections.ObjectModel;
+using System.IO;
+using System.Linq;
+using System.Windows;
+using System.Windows.Controls;
+
+namespace PDF_Office.ViewModels.Dialog.HomePageToolsDialogs.HomePageBatchProcessing.HomePageBackground
+{
+    public class HomePageBackgroundTemplateListColorContentViewModel : BindableBase, INavigationAware
+    {
+        private readonly IEventAggregator eventAggregator;
+        public BackgroundInfo BackgroundInfo = new BackgroundInfo();
+        public BackgroundItem BackgroundItem = new BackgroundItem();
+        public int TemplateIndex = 0;
+
+        private ObservableCollection<BackgroundItem> backgroundModcolorCollection = new ObservableCollection<BackgroundItem>();
+        public ObservableCollection<BackgroundItem> BackgroundModColorCollection
+        {
+            get { return backgroundModcolorCollection; }
+            set
+            {
+                backgroundModcolorCollection = value;
+                RaisePropertyChanged();
+            }
+        }
+
+        private Visibility _createTemplateVisible;
+        public Visibility CreateTemplateVisible
+        {
+            get { return _createTemplateVisible; }
+            set { SetProperty(ref _createTemplateVisible, value); }
+        }
+
+        public DelegateCommand AddTemplateCommand { get; set; }
+        public DelegateCommand<object> DeleteTemplateItemCommand { get; set; }
+        public DelegateCommand<object> EditTemplateItemCommand { get; set; }
+        public DelegateCommand DeleteAllTemplateItemCommand { get; set; }
+        public DelegateCommand<object> SelectTemplateItemCommand { get; set; }
+
+        public string unicode = null;
+        public string Unicode = null;
+
+        public HomePageBackgroundTemplateListColorContentViewModel(IEventAggregator eventAggregator)
+        {
+            Unicode = App.mainWindowViewModel.SelectedItem.Unicode;
+            this.eventAggregator = eventAggregator;
+            AddTemplateCommand = new DelegateCommand(AddTemplate);
+            EditTemplateItemCommand = new DelegateCommand<object>(RequestEditTemplateItem);
+            DeleteTemplateItemCommand = new DelegateCommand<object>(DeleteTemplateItem);
+            DeleteAllTemplateItemCommand = new DelegateCommand(DeleteAllTemplateItem);
+            SelectTemplateItemCommand = new DelegateCommand<object>(SelectTemplateItem);
+
+            eventAggregator.GetEvent<SaveEditedBackgroundTemplateItemEvent>().Subscribe(SaveEditedBackgroundTemplateItem, e => e.Unicode == Unicode);
+        }
+
+        private void CheckTemplateListIsEmpty(List<BackgroundItem> backgroundTemplateList)
+        {
+            if (backgroundTemplateList.Count() == 0)
+            {
+                CreateTemplateVisible = Visibility.Visible;
+            }
+            else
+            {
+                CreateTemplateVisible = Visibility.Collapsed;
+            }
+        }
+
+        private void GetBackgroundSource()
+        {
+            List<BackgroundItem> backgroundModColorTemplateList = new List<BackgroundItem>();
+            for (int temp = 0; temp < Settings.Default.BackgroundTemplateList.Count; temp++)
+            {
+                if (Settings.Default.BackgroundTemplateList[temp].type == ComPDFKit.PDFDocument.C_Background_Type.BG_TYPE_COLOR)
+                {
+                    backgroundModColorTemplateList.Add(Settings.Default.BackgroundTemplateList[temp]);
+                }
+            }
+            BackgroundModColorCollection = new ObservableCollection<BackgroundItem>(backgroundModColorTemplateList);
+            CheckTemplateListIsEmpty(backgroundModColorTemplateList);
+        }
+
+        private void InitBackgroundTemplateList()
+        {
+            if (Settings.Default.BackgroundTemplateList == null)
+            {
+                Settings.Default.BackgroundTemplateList = new BackgroundTemplateList();
+            }
+            GetBackgroundSource();
+        }
+
+        public void AddTemplate()
+        {
+            this.eventAggregator.GetEvent<EnterTemplateListOrCreateEvent>().Publish(new EnumTemplateListOrCreateUnicode
+            {
+                Unicode = Unicode,
+                Status = EnumTemplateListOrCreate.StatusCreate
+            });
+        }
+
+        public void SaveEditedBackgroundTemplateItem(BackgroundItemUnicode backgroundItemunicode)
+        {
+            BackgroundItem backgroundItem = backgroundItemunicode.Status;
+            if (backgroundItem.type == ComPDFKit.PDFDocument.C_Background_Type.BG_TYPE_COLOR)
+            {
+                Settings.Default.BackgroundTemplateList[TemplateIndex] = backgroundItem;
+                Settings.Default.Save();
+            }
+            GetBackgroundSource();
+        }
+
+
+        public void RequestEditTemplateItem(object e)
+        {
+            var control = e as Control;
+            if (control == null)
+            {
+                return;
+            }
+            var template = control.DataContext as BackgroundItem;
+            if (template == null)
+            {
+                return;
+            }
+            TemplateIndex = Settings.Default.BackgroundTemplateList.IndexOf(template);
+            template.listIndex = TemplateIndex;
+            ConvertItemToInfo(template, ref BackgroundInfo);
+            this.eventAggregator.GetEvent<EditBackgroundTemplateItemEvent>().Publish(new BackgroundItemUnicode
+            {
+                Unicode = Unicode,
+                Status = template
+            });
+        }
+
+
+        public void DeleteTemplateItem(object e)
+        {
+            var btn = e as System.Windows.Controls.Button;
+            if (btn == null)
+            {
+                return;
+            }
+            BackgroundItem = btn.DataContext as BackgroundItem;
+            if (BackgroundItem == null)
+            {
+                return;
+            }
+            if (!string.IsNullOrEmpty(BackgroundItem.previewImagePath) && File.Exists(BackgroundItem.previewImagePath))
+            {
+                Settings.Default.AppProperties.NeedToDeletePath.Add(BackgroundItem.previewImagePath);
+            }
+            Settings.Default.BackgroundTemplateList.Remove(BackgroundItem);
+            Settings.Default.Save();
+            BackgroundModColorCollection.Remove(BackgroundItem);
+            GetBackgroundSource();
+        }
+
+        public void DeleteAllTemplateItem()
+        {
+            while (Settings.Default.BackgroundTemplateList.Count != 0)
+            {
+                int temp = 0;
+                var template = Settings.Default.BackgroundTemplateList[temp];
+                if (template.type == ComPDFKit.PDFDocument.C_Background_Type.BG_TYPE_IMAGE)
+                {
+                    if (!string.IsNullOrEmpty(BackgroundItem.previewImagePath) && File.Exists(BackgroundItem.previewImagePath))
+                    {
+                        Settings.Default.AppProperties.NeedToDeletePath.Add(BackgroundItem.previewImagePath);
+                    }
+
+                    Settings.Default.BackgroundTemplateList.Remove(template);
+                    Settings.Default.Save();
+
+                    BackgroundModColorCollection.Remove(template);
+                }
+            }
+            GetBackgroundSource();
+        }
+
+        public void ConvertItemToInfo(BackgroundItem backgroundItem, ref BackgroundInfo backgroundInfo)
+        {
+            backgroundInfo.BackgroundType = backgroundItem.type;
+            backgroundInfo.Color = backgroundItem.bgColor;
+            backgroundInfo.Horizalign = backgroundItem.horizalign;
+            backgroundInfo.Vertalign = backgroundItem.vertalign;
+            backgroundInfo.VertOffset = backgroundItem.vertOffset;
+            backgroundInfo.Horizalign = backgroundItem.horizalign;
+            backgroundInfo.Opacity = backgroundItem.opacity;
+            backgroundInfo.Rotation = backgroundItem.rotation;
+            backgroundInfo.Scale = backgroundItem.scale;
+            //  backgroundItem.pagRangeMode = backgroundInfo.PageRange;
+
+        }
+
+        public void SendTemplateItemToDocument(BackgroundItem template)
+        {
+            if (template != null)
+            {
+                ConvertItemToInfo(template, ref BackgroundInfo);
+               
+            }
+
+        }
+
+
+        public void SelectTemplateItem(object e)
+        {
+            var listBox = e as ListBox;
+            BackgroundItem BackgroundItem = listBox.SelectedItem as BackgroundItem;
+            SendTemplateItemToDocument(BackgroundItem);
+        }
+
+
+        public bool IsNavigationTarget(NavigationContext navigationContext)
+        {
+            return true;
+        }
+
+        public void OnNavigatedFrom(NavigationContext navigationContext)
+        {
+        }
+
+        public void OnNavigatedTo(NavigationContext navigationContext)
+        {
+            InitBackgroundTemplateList();
+        }
+    }
+}

+ 242 - 0
PDF Office/ViewModels/Dialog/HomePageToolsDialogs/HomePageBatchProcessing/HomePageBackground/HomePageBackgroundTemplateListFileContentViewModel.cs

@@ -0,0 +1,242 @@
+using PDF_Office.EventAggregators;
+using PDF_Office.Model.EditTools.Background;
+using PDF_Office.Properties;
+using PDFSettings;
+using Prism.Commands;
+using Prism.Events;
+using Prism.Mvvm;
+using Prism.Regions;
+using System;
+using System.Collections.Generic;
+using System.Collections.ObjectModel;
+using System.IO;
+using System.Linq;
+using System.Windows;
+using System.Windows.Controls;
+
+namespace PDF_Office.ViewModels.Dialog.HomePageToolsDialogs.HomePageBatchProcessing.HomePageBackground
+{
+    public class HomePageBackgroundTemplateListFileContentViewModel : BindableBase, INavigationAware
+    {
+        private readonly IEventAggregator eventAggregator;
+        public BackgroundInfo BackgroundInfo = new BackgroundInfo();
+        public BackgroundItem BackgroundItem = new BackgroundItem();
+        public int TemplateIndex = 0;
+
+        public ObservableCollection<BackgroundItem> backgroundModFileCollection = new ObservableCollection<BackgroundItem>();
+        public ObservableCollection<BackgroundItem> BackgroundModFileCollection
+        {
+            get { return backgroundModFileCollection; }
+            set
+            {
+                backgroundModFileCollection = value;
+                RaisePropertyChanged();
+            }
+        }
+
+        private Visibility _createTemplateVisible;
+        public Visibility CreateTemplateVisible
+        {
+            get { return _createTemplateVisible; }
+            set { SetProperty(ref _createTemplateVisible, value); }
+        }
+
+        public DelegateCommand AddTemplateCommand { get; set; }
+        public DelegateCommand<object> DeleteTemplateItemCommand { get; set; }
+        public DelegateCommand<object> EditTemplateItemCommand { get; set; }
+        public DelegateCommand DeleteAllTemplateItemCommand { get; set; }
+        public DelegateCommand<object> SelectTemplateItemCommand { get; set; }
+
+        public string unicode = null;
+        public string Unicode = null;
+
+        public HomePageBackgroundTemplateListFileContentViewModel(IEventAggregator eventAggregator)
+        {
+            Unicode = App.mainWindowViewModel.SelectedItem.Unicode;
+            this.eventAggregator = eventAggregator;
+            AddTemplateCommand = new DelegateCommand(AddTemplate);
+            EditTemplateItemCommand = new DelegateCommand<object>(RequestEditTemplateItem);
+            DeleteTemplateItemCommand = new DelegateCommand<object>(DeleteTemplateItem);
+            DeleteAllTemplateItemCommand = new DelegateCommand(DeleteAllTemplateItem);
+            SelectTemplateItemCommand = new DelegateCommand<object>(SelectTemplateItem);
+
+            eventAggregator.GetEvent<SaveEditedBackgroundTemplateItemEvent>().Subscribe(SaveEditedBackgroundTemplateItem, e => e.Unicode == Unicode);
+
+        }
+
+        private void CheckTemplateListIsEmpty(List<BackgroundItem> backgroundTemplateList)
+        {
+            if (backgroundTemplateList.Count() == 0)
+            {
+                CreateTemplateVisible = Visibility.Visible;
+            }
+            else
+            {
+                CreateTemplateVisible = Visibility.Collapsed;
+            }
+        }
+
+        private void GetBackgroundSource()
+        {
+            List<BackgroundItem> backgroundModFileTemplateList = new List<BackgroundItem>();
+            for (int temp = 0; temp < Settings.Default.BackgroundTemplateList.Count; temp++)
+            {
+                if (Settings.Default.BackgroundTemplateList[temp].type == ComPDFKit.PDFDocument.C_Background_Type.BG_TYPE_IMAGE)
+                {
+                    backgroundModFileTemplateList.Add(Settings.Default.BackgroundTemplateList[temp]);
+                }
+            }
+            BackgroundModFileCollection = new ObservableCollection<BackgroundItem>(backgroundModFileTemplateList);
+            CheckTemplateListIsEmpty(backgroundModFileTemplateList);
+        }
+
+
+
+        private void InitBackgroundTemplateList()
+        {
+            if (Settings.Default.BackgroundTemplateList == null)
+            {
+                Settings.Default.BackgroundTemplateList = new BackgroundTemplateList();
+            }
+            GetBackgroundSource();
+        }
+
+        public void AddTemplate()
+        {
+            this.eventAggregator.GetEvent<EnterTemplateListOrCreateEvent>().Publish(new EnumTemplateListOrCreateUnicode
+            {
+                Unicode = Unicode,
+                Status = EnumTemplateListOrCreate.StatusCreate
+            });
+        }
+
+        public void SaveEditedBackgroundTemplateItem(BackgroundItemUnicode backgroundItemunicode)
+        {
+            BackgroundItem backgroundItem = backgroundItemunicode.Status;
+            if (backgroundItem.type == ComPDFKit.PDFDocument.C_Background_Type.BG_TYPE_IMAGE)
+            {
+                Settings.Default.BackgroundTemplateList[TemplateIndex] = backgroundItem;
+                Settings.Default.Save();
+            }
+            GetBackgroundSource();
+
+        }
+        public void RequestEditTemplateItem(object e)
+        {
+            var control = e as Control;
+            if (control == null)
+            {
+                return;
+            }
+            var template = control.DataContext as BackgroundItem;
+            if (template == null)
+            {
+                return;
+            }
+            TemplateIndex = Settings.Default.BackgroundTemplateList.IndexOf(template);
+            template.listIndex = TemplateIndex;
+            this.eventAggregator.GetEvent<EditBackgroundTemplateItemEvent>().Publish(new BackgroundItemUnicode
+            {
+                Unicode = Unicode,
+                Status = template
+            });
+        }
+
+        public void DeleteTemplateItem(object e)
+        {
+            var control = e as Control;
+            if (control == null)
+            {
+                return;
+            }
+            var template = control.DataContext as BackgroundItem;
+            if (template == null)
+            {
+                return;
+            }
+            if (!string.IsNullOrEmpty(BackgroundItem.previewImagePath) && File.Exists(BackgroundItem.previewImagePath))
+            {
+                Settings.Default.AppProperties.NeedToDeletePath.Add(BackgroundItem.previewImagePath);
+            }
+
+            Settings.Default.BackgroundTemplateList.Remove(template);
+            Settings.Default.Save();
+
+            BackgroundModFileCollection.Remove(template);
+            GetBackgroundSource();
+
+        }
+
+        public void DeleteAllTemplateItem()
+        {
+            while (Settings.Default.BackgroundTemplateList.Count != 0)
+            {
+                int temp = 0;
+
+                var template = Settings.Default.BackgroundTemplateList[temp];
+                if (template.type == ComPDFKit.PDFDocument.C_Background_Type.BG_TYPE_COLOR)
+                {
+
+                    if (!string.IsNullOrEmpty(BackgroundItem.previewImagePath))
+                    {
+                        Settings.Default.AppProperties.NeedToDeletePath.Add(BackgroundItem.previewImagePath);
+                    }
+
+                    Settings.Default.BackgroundTemplateList.Remove(template);
+                    Settings.Default.Save();
+
+                    BackgroundModFileCollection.Remove(template);
+                }
+            }
+
+            GetBackgroundSource();
+        }
+
+        public void ConvertItemToInfo(BackgroundItem backgroundItem, ref BackgroundInfo backgroundInfo)
+        {
+            if (backgroundItem != null)
+            {
+                backgroundInfo.BackgroundType = backgroundItem.type;
+                backgroundInfo.ImageArray = backgroundItem.imageArray;
+                backgroundInfo.ImageWidth = backgroundItem.imageWidth;
+                backgroundInfo.ImageHeight = backgroundItem.imageHeight;
+                backgroundInfo.Horizalign = backgroundItem.horizalign;
+                backgroundInfo.Vertalign = backgroundItem.vertalign;
+                backgroundInfo.VertOffset = backgroundItem.vertOffset;
+                backgroundInfo.Horizalign = backgroundItem.horizalign;
+                backgroundInfo.Opacity = backgroundItem.opacity;
+                backgroundInfo.Rotation = backgroundItem.rotation;
+                backgroundInfo.Scale = backgroundItem.scale;
+                //  backgroundItem.pagRangeMode = backgroundInfo.PageRange;
+            }
+        }
+
+        public void SendTemplateItemToDocument(BackgroundItem BackgroundItem)
+        {
+            ConvertItemToInfo(BackgroundItem, ref BackgroundInfo);
+        }
+
+        public void SelectTemplateItem(object e)
+        {
+            var listBox = e as ListBox;
+            BackgroundItem BackgroundItem = listBox.SelectedItem as BackgroundItem;
+            SendTemplateItemToDocument(BackgroundItem);
+        }
+
+
+        public bool IsNavigationTarget(NavigationContext navigationContext)
+        {
+            return true;
+        }
+
+        public void OnNavigatedFrom(NavigationContext navigationContext)
+        {
+        }
+
+        public void OnNavigatedTo(NavigationContext navigationContext)
+        {
+            InitBackgroundTemplateList();
+        }
+    }
+}
+

+ 246 - 0
PDF Office/ViewModels/Dialog/HomePageToolsDialogs/HomePageBatchProcessing/HomePageWatermark/HomePageWatermarkCreateBaseContentViewModel.cs

@@ -0,0 +1,246 @@
+using ComPDFKitViewer.PdfViewer;
+using PDF_Office.EventAggregators;
+using PDF_Office.Model;
+using PDFSettings;
+using Prism.Commands;
+using Prism.Events;
+using Prism.Mvvm;
+using Prism.Regions;
+using System;
+using System.Collections.Generic;
+using System.Linq;
+using System.Windows;
+using System.Windows.Controls;
+
+namespace PDF_Office.ViewModels.Dialog.HomePageToolsDialogs.HomePageBatchProcessing.HomePageWatermark
+{
+    public class HomePageWatermarkCreateBaseContentViewModel : BindableBase, INavigationAware
+    {
+        IEventAggregator eventAggregator;
+        IRegionManager watermarkCreateRegion;
+
+        private CPDFViewer PDFViewer;
+
+        public WatermarkItem WatermarkItem;
+
+        public EnumTextOrFile CurrentTemplateListMod;
+
+        private string watermarkCreateRegionName;
+
+        public string WatermarkCreateRegionName
+        {
+            get => watermarkCreateRegionName;
+            set => SetProperty(ref watermarkCreateRegionName, value);
+        }
+
+        private string _currentCreateModName;
+        public string CurrentCreateModName
+        {
+            get => _currentCreateModName;
+            set => _currentCreateModName = value;
+        }
+
+
+
+        public enum EnumCreateOrEdit
+        {
+            None,
+            StatusCreate,
+            StatusEdit
+        }
+
+        private EnumCreateOrEdit _createOrEdit;
+        public EnumCreateOrEdit CreateOrEdit
+        {
+            get { return _createOrEdit; }
+            set
+            {
+                _createOrEdit = value;
+                if (value == EnumCreateOrEdit.StatusEdit)
+                {
+                    EditBaseVisible = Visibility.Visible;
+                    CreateBaseVisible = Visibility.Collapsed;
+                }
+                else if (value == EnumCreateOrEdit.StatusCreate)
+                {
+                    CreateBaseVisible = Visibility.Visible;
+                    EditBaseVisible = Visibility.Collapsed;
+                }
+            }
+        }
+
+        private Visibility watermarkCreateVisible;
+        public Visibility WatermarkCreateVisible
+        {
+            get => watermarkCreateVisible;
+            set => SetProperty(ref watermarkCreateVisible, value);
+        }
+
+        private Visibility _createBaseVisible;
+        public Visibility CreateBaseVisible
+        {
+            get => _createBaseVisible;
+            set => SetProperty(ref _createBaseVisible, value);
+        }
+
+        private Visibility _editBaseVisible;
+        public Visibility EditBaseVisible
+        {
+            get => _editBaseVisible;
+            set => SetProperty(ref _editBaseVisible, value);
+        }
+
+        public DelegateCommand<object> ChangeCreateModCommand { get; set; }
+
+        public DelegateCommand EnterTemplateListCommand { get; set; }
+
+        public DelegateCommand SaveToTemplateListCommand { get; set; }
+
+        public DelegateCommand SaveToCurrentTemplateListCommand { get; set; }
+
+        public string Unicode = null;
+
+        public HomePageWatermarkCreateBaseContentViewModel(IRegionManager regionManager, IEventAggregator eventAggregator)
+        {
+            this.eventAggregator = eventAggregator;
+            this.watermarkCreateRegion = regionManager;
+            Unicode = App.mainWindowViewModel.SelectedItem.Unicode;
+            WatermarkCreateRegionName = Guid.NewGuid().ToString();
+            ChangeCreateModCommand = new DelegateCommand<object>(ChangeCreateMod);
+            EnterTemplateListCommand = new DelegateCommand(EnterTemplateList);
+            SaveToTemplateListCommand = new DelegateCommand(SaveToTemplateList);
+
+            SaveToCurrentTemplateListCommand = new DelegateCommand(SaveToCurrentTemplateList);
+
+        }
+
+        public void SaveToTemplateList()
+        {
+            if (CurrentCreateModName == "HomePageWatermarkCreateTextContent")
+            {
+                this.eventAggregator.GetEvent<SaveWatermarkTemplateEvent>().Publish(new EnumTextOrFileUnicode
+                {
+                    Unicode = Unicode,
+                    Status = EnumTextOrFile.StatusText
+                });
+            }
+            if (CurrentCreateModName == "HomePageWatermarkCreateFileContent")
+            {
+                this.eventAggregator.GetEvent<SaveWatermarkTemplateEvent>().Publish(new EnumTextOrFileUnicode
+                {
+                    Unicode = Unicode,
+                    Status = EnumTextOrFile.StatusFile
+                });
+            }
+        }
+
+        public void SaveToCurrentTemplateList()
+        {
+
+            if (CurrentCreateModName == "HomePageWatermarkCreateTextContent")
+            {
+                eventAggregator.GetEvent<ConfirmEditWatermarkTemplateItemEvent>().Publish(new EnumTextOrFileUnicode
+                {
+                    Unicode = Unicode,
+                    Status = EnumTextOrFile.StatusText
+                });
+            }
+            if (CurrentCreateModName == "HomePageWatermarkCreateFileContent")
+            {
+                eventAggregator.GetEvent<ConfirmEditWatermarkTemplateItemEvent>().Publish(new EnumTextOrFileUnicode
+                {
+                    Unicode = Unicode,
+                    Status = EnumTextOrFile.StatusFile
+                });
+            }
+        }
+
+        public void EnterTemplateList()
+        {
+            this.eventAggregator.GetEvent<EnterTemplateListOrCreateEvent>().Publish(new EnumTemplateListOrCreateUnicode { Unicode = Unicode, Status = EnumTemplateListOrCreate.StatusTemplate });
+        }
+
+        public void EnterSelectedCreateMod(string currentCreateName)
+        {
+            NavigationParameters param = new NavigationParameters();
+            param.Add(ParameterNames.PDFViewer, PDFViewer);
+            watermarkCreateRegion.RequestNavigate(WatermarkCreateRegionName, currentCreateName, param);
+            watermarkCreateVisible = System.Windows.Visibility.Visible;
+        }
+
+        public void EditSelectedTemplateItem(string currentCreateName)
+        {
+            NavigationParameters param = new NavigationParameters();
+            param.Add(ParameterNames.PDFViewer, PDFViewer);
+            param.Add("WatermarkItem", WatermarkItem);
+            watermarkCreateRegion.RequestNavigate(WatermarkCreateRegionName, currentCreateName, param);
+            watermarkCreateVisible = System.Windows.Visibility.Visible;
+        }
+
+        public void ChangeCreateMod(object e)
+        {
+            var args = e as Button;
+            if (args != null)
+            {
+                if (CreateOrEdit == EnumCreateOrEdit.StatusCreate)
+                {
+                    CurrentCreateModName = args.Name;
+                    EnterSelectedCreateMod(CurrentCreateModName);
+                    eventAggregator.GetEvent<SetCurrentCreateModEvent>().Publish(new stringUnicode
+                    {
+                        Unicode = Unicode,
+                        Status = CurrentCreateModName
+                    });
+                }
+                else if (CreateOrEdit == EnumCreateOrEdit.StatusEdit)
+                {
+                    CurrentCreateModName = args.Name;
+                    EditSelectedTemplateItem(CurrentCreateModName);
+                    eventAggregator.GetEvent<SetCurrentCreateModEvent>().Publish(new stringUnicode
+                    {
+                        Unicode = Unicode,
+                        Status = CurrentCreateModName
+                    });
+                }
+            }
+        }
+
+        public bool IsNavigationTarget(NavigationContext navigationContext)
+        {
+            return true;
+        }
+
+        public void OnNavigatedFrom(NavigationContext navigationContext)
+        {
+        }
+
+        public void OnNavigatedTo(NavigationContext navigationContext)
+        {
+            navigationContext.Parameters.TryGetValue<CPDFViewer>(ParameterNames.PDFViewer, out PDFViewer);
+            navigationContext.Parameters.TryGetValue<EnumTextOrFile>("CurrentTemplateListModName", out CurrentTemplateListMod);
+            if (CurrentTemplateListMod == EnumTextOrFile.StatusText)
+            {
+                CurrentCreateModName = "HomePageWatermarkCreateTextContent";
+            }
+            else
+            {
+                CurrentCreateModName = "HomePageWatermarkCreateFileContent";
+            }
+            if (navigationContext.Parameters.TryGetValue<WatermarkItem>("WatermarkItem", out WatermarkItem))
+            {
+                EditSelectedTemplateItem(CurrentCreateModName);
+                CreateOrEdit = EnumCreateOrEdit.StatusEdit;
+            }
+            else
+            {
+                EnterSelectedCreateMod(CurrentCreateModName);
+                CreateOrEdit = EnumCreateOrEdit.StatusCreate;
+            }
+            eventAggregator.GetEvent<SetCurrentCreateModEvent>().Publish(new stringUnicode
+            {
+                Unicode = Unicode,
+                Status = CurrentCreateModName
+            });
+        }
+    }
+}

+ 720 - 0
PDF Office/ViewModels/Dialog/HomePageToolsDialogs/HomePageBatchProcessing/HomePageWatermark/HomePageWatermarkCreateFileContentViewModel.cs

@@ -0,0 +1,720 @@
+using ComPDFKit.PDFDocument;
+using ComPDFKit.PDFPage;
+using ComPDFKit.PDFWatermark;
+using ComPDFKitViewer.PdfViewer;
+using PDF_Office.CustomControl;
+using PDF_Office.EventAggregators;
+using PDF_Office.Helper;
+using PDF_Office.Model.EditTools.Watermark;
+using PDF_Office.Model;
+using PDF_Office.Properties;
+using PDFSettings;
+using Prism.Commands;
+using Prism.Events;
+using Prism.Mvvm;
+using Prism.Regions;
+using System;
+using System.Collections.Generic;
+using System.Diagnostics;
+using System.IO;
+using System.Linq;
+using System.Windows;
+using System.Threading.Tasks;
+
+namespace PDF_Office.ViewModels.Dialog.HomePageToolsDialogs.HomePageBatchProcessing.HomePageWatermark
+{
+    public class HomePageWatermarkCreateFileContentViewModel : BindableBase, INavigationAware
+    {
+        public WatermarkInfo WatermarkInfo = new WatermarkInfo();
+
+        private WatermarkItem TemplateWatermarkItem;
+
+        private CPDFViewer PDFViewer;
+
+        IEventAggregator eventAggregator;
+
+        private List<string> _opacityList = new List<string>();
+        public List<string> OpacityList
+        {
+            get { return _opacityList; }
+            set
+            {
+                SetProperty(ref _opacityList, value);
+            }
+        }
+
+        private void InitOpacityList()
+        {
+            OpacityList.Clear();
+            for (int temp = 0; temp <= 100; temp += 10)
+            {
+                OpacityList.Add(temp.ToString() + " %");
+            }
+        }
+
+        private List<string> _rotationList = new List<string>();
+        public List<string> RotationList
+        {
+            get { return _rotationList; }
+            set
+            {
+                SetProperty(ref _rotationList, value);
+            }
+        }
+
+        private void InitRotationList()
+        {
+            RotationList.Clear();
+            for (int temp = -45; temp <= 45; temp += 15)
+            {
+                RotationList.Add(temp.ToString());
+            }
+        }
+
+        private List<string> _scaleList = new List<string>();
+        public List<string> ScaleList
+        {
+            get { return _scaleList; }
+            set
+            {
+                SetProperty(ref _scaleList, value);
+            }
+        }
+
+        private void InitScaleList()
+        {
+            ScaleList.Clear();
+            for (int temp = 0; temp <= 100; temp += 10)
+            {
+                ScaleList.Add(temp.ToString() + " %");
+            }
+        }
+
+        private List<string> _isFrontList = new List<string>();
+        public List<string> IsFrontList
+        {
+            get { return _isFrontList; }
+            set
+            {
+                SetProperty(ref _isFrontList, value);
+            }
+        }
+
+        private void InitIsFrontList()
+        {
+            IsFrontList.Clear();
+            IsFrontList.Add("位于页面上方");
+            IsFrontList.Add("位于页面下方");
+        }
+
+        private int _rotationValue = 0;
+        public int RotationValue
+        {
+            get { return _rotationValue; }
+            set
+            {
+                SetProperty(ref _rotationValue, value);
+                WatermarkInfo.Rotation = RotationValue;
+               
+            }
+        }
+
+        private int _opacityValue = 100;
+        public int OpacityValue
+        {
+            get { return _opacityValue; }
+            set
+            {
+                SetProperty(ref _opacityValue, value);
+                WatermarkInfo.Opacity = (byte)OpacityValue;
+                
+            }
+        }
+
+
+        private string _rotationText = "0";
+        public string RotationText
+        {
+            get { return _rotationText; }
+            set
+            {
+                SetProperty(ref _rotationText, value);
+            }
+        }
+
+        private string _opacityText = "100 %";
+        public string OpacityText
+        {
+            get { return _opacityText; }
+            set
+            {
+                SetProperty(ref _opacityText, value);
+
+            }
+        }
+
+        private string _relativeScaleText = "50 %";
+        public string RelativeScaleText
+        {
+            get { return _relativeScaleText; }
+            set
+            {
+                SetProperty(ref _relativeScaleText, value);
+            }
+        }
+
+
+        private int _relativeScaleValue = 50;
+        public int RelativeScaleValue
+        {
+            get { return _relativeScaleValue; }
+            set
+            {
+                SetProperty(ref _relativeScaleValue, value);
+                WatermarkInfo.ImageSize = RelativeScaleValue;
+                
+            }
+        }
+
+        private string _vertOffsetValue = "0";
+        public string VertOffsetValue
+        {
+            get { return _vertOffsetValue; }
+            set
+            {
+                SetProperty(ref _vertOffsetValue, value);
+                WatermarkInfo.VertOffset = float.Parse(VertOffsetValue);
+                
+            }
+        }
+
+        private string _horizOffsetValue = "0";
+        public string HorizOffsetValue
+        {
+            get { return _horizOffsetValue; }
+            set
+            {
+                SetProperty(ref _horizOffsetValue, value);
+                WatermarkInfo.HorizOffset = float.Parse(HorizOffsetValue);
+                
+            }
+        }
+
+        private string _verticalSpacingValue = "6";
+        public string VerticalSpacingValue
+        {
+            get { return _verticalSpacingValue; }
+            set
+            {
+                SetProperty(ref _verticalSpacingValue, value);
+                WatermarkInfo.VerticalSpacing = float.Parse(VerticalSpacingValue);
+                
+            }
+        }
+
+        private string _horizontalSpacingValue = "6";
+        public string HorizontalSpacingValue
+        {
+            get { return _horizontalSpacingValue; }
+            set
+            {
+                SetProperty(ref _horizontalSpacingValue, value);
+                WatermarkInfo.HorizontalSpacing = float.Parse(HorizontalSpacingValue);
+                
+            }
+        }
+
+        public string _pageRangeText = "0";
+        public string PageRangeText
+        {
+            get { return _pageRangeText; }
+            set
+            {
+                _pageRangeText = value;
+                //EditToolsHelper.GetPageRange(PageRangeSelectIndex, PDFViewer.Document, ref WatermarkInfo.PageRange, PageRangeText);
+                
+            }
+        }
+
+        private bool _isFullValue = false;
+        public bool IsFullValue
+        {
+            get { return _isFullValue; }
+            set
+            {
+                SetProperty(ref _isFullValue, value);
+                WatermarkInfo.Isfull = IsFullValue;
+                
+            }
+        }
+
+        private bool _isRelativeScaleValue = false;
+        public bool IsRelativeScaleValue
+        {
+            get { return _isRelativeScaleValue; }
+            set
+            {
+                SetProperty(ref _isRelativeScaleValue, value);
+                WatermarkInfo.IsRelativeScale = IsRelativeScaleValue;
+               
+            }
+        }
+
+        private int _pageRangeSelectIndex = 0;
+        public int PageRangeSelectIndex
+        {
+            get { return _pageRangeSelectIndex; }
+            set
+            {
+                SetProperty(ref _pageRangeSelectIndex, value);
+                WatermarkInfo.PageRangeIndex = PageRangeSelectIndex;
+                //EditToolsHelper.GetPageRange(PageRangeSelectIndex, PDFViewer.Document, ref WatermarkInfo.PageRange, PageRangeText);
+                
+
+            }
+        }
+
+        private int _isFrontSelectedIndex = 0;
+        public int IsFrontSelectedIndex
+        {
+            get { return _isFrontSelectedIndex; }
+            set
+            {
+                SetProperty(ref _isFrontSelectedIndex, value);
+                SetIsFront(IsFrontSelectedIndex);
+                
+            }
+        }
+
+        private string _fileNameText = "";
+        public string FileNameText
+        {
+            get { return _fileNameText; }
+            set
+            {
+                SetProperty(ref _fileNameText, value);
+            }
+        }
+
+        private Visibility _createFileVisible = Visibility.Collapsed;
+        public Visibility CreateFileVisible
+        {
+            get { return _createFileVisible; }
+            set { SetProperty(ref _createFileVisible, value); }
+        }
+
+        private ObservableDictionary<string, bool> _getLocationFromNumber = new ObservableDictionary<string, bool>();
+        public ObservableDictionary<string, bool> GetLocationFromNumber
+        {
+            get { return _getLocationFromNumber; }
+            set { _getLocationFromNumber = value; }
+        }
+
+
+        public DelegateCommand<object> ChangeLocationCommand { get; set; }
+
+        public DelegateCommand OpenFileCommand { get; set; }
+
+        public string Unicode = null;
+
+        public HomePageWatermarkCreateFileContentViewModel(IEventAggregator eventAggregator)
+        {
+            this.eventAggregator = eventAggregator;
+            Unicode = App.mainWindowViewModel.SelectedItem.Unicode;
+            WatermarkInfo.WatermarkType = C_Watermark_Type.WATERMARK_TYPE_IMG;
+            ChangeLocationCommand = new DelegateCommand<object>(ChangeLocation);
+            OpenFileCommand = new DelegateCommand(OpenFile);
+            InitList();
+            InitWatermarkInfo();
+            InitLocationButtonMatrix();
+            eventAggregator.GetEvent<SaveWatermarkTemplateEvent>().Subscribe(SaveWatermarkTemplate, e => e.Unicode == Unicode);
+            eventAggregator.GetEvent<ConfirmEditWatermarkTemplateItemEvent>().Subscribe(ConfirmEditWatermarkTemplateItem, e => e.Unicode == Unicode);
+        }
+
+        public void SaveWatermarkTemplate(EnumTextOrFileUnicode enumTextOrFileunicode)
+        {
+            EnumTextOrFile enumTextOrFile = enumTextOrFileunicode.Status;
+            if (enumTextOrFile == EnumTextOrFile.StatusFile && FileNameText != "")
+            {
+                SaveCurrentTemplate();
+            }
+        }
+
+        public void ConvertInfoToItem(ref WatermarkItem watermarkItem, WatermarkInfo watermarkInfo)
+        {
+            if (watermarkInfo != null)
+            {
+                watermarkItem.type = watermarkInfo.WatermarkType;
+                //watermarkItem.imageArray = watermarkInfo.ImageArray;
+                watermarkItem.imagepath = watermarkInfo.ImagePath;
+                watermarkItem.imageSize = watermarkInfo.ImageSize;
+                watermarkItem.imageWidth = watermarkInfo.ImageWidth;
+                watermarkItem.imageHeight = watermarkInfo.ImageHeight;
+                watermarkItem.horizalign = watermarkInfo.WatermarkHorizalign;
+                watermarkItem.vertalign = watermarkInfo.WatermarkVertalign;
+                watermarkItem.isRelativeScale = watermarkInfo.IsRelativeScale;
+                watermarkItem.isFullScreen = watermarkInfo.Isfull;
+                watermarkItem.isfront = watermarkInfo.IsFront;
+                watermarkItem.opacity = watermarkInfo.Opacity;
+                watermarkItem.rotation = watermarkInfo.Rotation;
+                watermarkItem.vertOffset = watermarkInfo.VertOffset;
+                watermarkItem.horizOffset = watermarkInfo.HorizOffset;
+                watermarkItem.verticalSpacing = watermarkInfo.VerticalSpacing;
+                watermarkItem.horizontalSpacing = watermarkInfo.HorizontalSpacing;
+                watermarkItem.pageRangeIndex = watermarkInfo.PageRangeIndex;
+                watermarkItem.pageRange = watermarkInfo.PageRange;
+            }
+        }
+
+        public void ConvertItemToInfo(WatermarkItem watermarkItem, ref WatermarkInfo watermarkInfo)
+        {
+            if (watermarkItem != null)
+            {
+                watermarkInfo.WatermarkType = C_Watermark_Type.WATERMARK_TYPE_IMG;
+                if (watermarkItem.imagepath != "")
+                {
+                    FileInfo file = new FileInfo(watermarkItem.imagepath);
+                    if (file.Exists)
+                    {
+                        if (file.Extension == ".pdf")
+                        {
+                            GetBitmapFromDocment(watermarkItem.imagepath);
+                        }
+                        else
+                        {
+                            EditToolsHelper.ChooseFile(watermarkItem.imagepath, ref WatermarkInfo);
+                        }
+                    }
+                    else
+                    {
+                        watermarkInfo.WatermarkType = ComPDFKit.PDFWatermark.C_Watermark_Type.WATERMARK_TYPE_UNKWON;
+                        MessageBoxEx.Show("原路径为:" + watermarkItem.imagepath + ",该文件不存在");
+                    }
+                }
+                watermarkInfo.WatermarkHorizalign = watermarkItem.horizalign;
+                watermarkInfo.WatermarkVertalign = watermarkItem.vertalign;
+                watermarkInfo.IsRelativeScale = watermarkItem.isRelativeScale;
+                watermarkInfo.Isfull = watermarkItem.isFullScreen;
+                watermarkInfo.IsFront = watermarkItem.isfront;
+                watermarkInfo.ImageSize = watermarkItem.imageSize;
+                watermarkInfo.Opacity = watermarkItem.opacity;
+                watermarkInfo.Rotation = watermarkItem.rotation;
+                watermarkInfo.VertOffset = watermarkItem.vertOffset;
+                watermarkInfo.HorizOffset = watermarkItem.horizOffset;
+                watermarkInfo.VerticalSpacing = watermarkItem.verticalSpacing;
+                watermarkInfo.HorizontalSpacing = watermarkItem.horizontalSpacing;
+                //EditToolsHelper.GetPageRange(watermarkItem.pageRangeIndex, PDFViewer.Document, ref WatermarkInfo.PageRange, watermarkItem.pageRange);
+            }
+        }
+
+        public void SaveCurrentTemplate()
+        {
+            var watermarkItem = new WatermarkItem();
+            ConvertInfoToItem(ref watermarkItem, WatermarkInfo);
+            watermarkItem.templateName += Settings.Default.WatermarkIndex.ToString();
+            try
+            {
+                //创建缓存文件夹
+                string folderPath = Path.Combine(App.CurrentPath, "Watermark");
+                //有可能因为其他原因存在同名文件,导致创建文件夹失败,需要先删除同名文件
+                //保险措施(猜测)
+                if (File.Exists(folderPath))
+                {
+                    File.Delete(folderPath);
+                }
+
+                DirectoryInfo tempfolder = new DirectoryInfo(folderPath);
+                if (!tempfolder.Exists)
+                {
+                    tempfolder.Create();
+                }
+
+                //预览图缓存
+                string saveName = Guid.NewGuid().ToString();
+                string savePath = Path.Combine(folderPath, saveName);
+                System.Windows.Size pageSize = new Size { Width = 128, Height = 160 };
+                CPDFDocument tempDocument = CPDFDocument.CreateDocument();
+                if (tempDocument != null)
+                {
+                    tempDocument.InsertPage(0, pageSize.Width, pageSize.Height, null);
+                    CreateWatermark(tempDocument, WatermarkInfo);
+                    //获取透明背景的图片
+                    var bitmap = ToolMethod.RenderPageBitmapNoWait(tempDocument, (int)pageSize.Width, (int)pageSize.Height, 0, false, false, 0x00FFFFFF);
+                    using (FileStream stream = new FileStream(savePath, FileMode.Create))
+                    {
+                        bitmap.Save(stream, System.Drawing.Imaging.ImageFormat.Png);
+                    }
+
+                    watermarkItem.previewImagePath = savePath;
+                    tempDocument.Release();
+
+                    Settings.Default.WatermarkTemplateList.Add(watermarkItem);
+                    Settings.Default.Save();
+                }
+            }
+            catch
+            {
+
+            }
+
+            this.eventAggregator.GetEvent<EnterTemplateListOrCreateEvent>().Publish(new EnumTemplateListOrCreateUnicode
+            {
+                Unicode = Unicode,
+                Status = EnumTemplateListOrCreate.StatusTemplate
+            });
+        }
+
+        private void SetIsFront(int Index)
+        {
+            if (Index == 0)
+            {
+                WatermarkInfo.IsFront = true;
+            }
+            if (Index == 1)
+            {
+                WatermarkInfo.IsFront = false;
+            }
+        }
+
+        private void InitList()
+        {
+            InitOpacityList();
+            InitIsFrontList();
+            InitRotationList();
+            InitScaleList();
+        }
+
+        private void InitWatermarkInfo()
+        {
+
+            WatermarkInfo.Rotation = RotationValue;
+            WatermarkInfo.ImageSize = RelativeScaleValue;
+            WatermarkInfo.Opacity = (byte)OpacityValue;
+            WatermarkInfo.VertOffset = float.Parse(VertOffsetValue);
+            WatermarkInfo.HorizOffset = float.Parse(HorizOffsetValue);
+            WatermarkInfo.VerticalSpacing = float.Parse(VerticalSpacingValue);
+            WatermarkInfo.HorizontalSpacing = float.Parse(HorizontalSpacingValue);
+            WatermarkInfo.WatermarkHorizalign = C_Watermark_Horizalign.WATERMARK_HORIZALIGN_CENTER;
+            WatermarkInfo.WatermarkVertalign = C_Watermark_Vertalign.WATERMARK_VERTALIGN_CENTER;
+            WatermarkInfo.IsRelativeScale = IsRelativeScaleValue;
+            WatermarkInfo.Isfull = IsFullValue;
+            SetIsFront(IsFrontSelectedIndex);
+        }
+
+        private void InitLocationButtonMatrix()
+        {
+            GetLocationFromNumber.Clear();
+            for (var temp = 0; temp <= 22; temp++)
+            {
+                GetLocationFromNumber.Add(temp.ToString(), true);
+                if (temp % 10 == 2)
+                {
+                    temp += 7;
+                }
+            }
+            int Num = (int)WatermarkInfo.WatermarkVertalign * 10 + (int)WatermarkInfo.WatermarkHorizalign;
+            GetLocationFromNumber[Num.ToString()] = false;
+
+        }
+
+        public void ChangeLocation(object e)
+        {
+            string args = e as string;
+            if (args != null)
+            {
+                WatermarkInfo.WatermarkVertalign = (C_Watermark_Vertalign)(int.Parse(args) / 10);
+                WatermarkInfo.WatermarkHorizalign = (C_Watermark_Horizalign)(int.Parse(args) % 10);
+                
+                InitLocationButtonMatrix();
+            }
+        }
+
+        public void ConfirmEditToolsWatermark()
+        {
+
+           
+
+        }
+
+        public void CreateWatermark(CPDFDocument document, WatermarkInfo watermarkInfo)
+        {
+            if (watermarkInfo != null)
+            {
+                document.DeleteWatermarks();
+                CPDFWatermark watermark;
+                if (watermarkInfo.WatermarkType == C_Watermark_Type.WATERMARK_TYPE_TEXT)
+                {
+                    watermark = document.InitWatermark(C_Watermark_Type.WATERMARK_TYPE_TEXT);
+                    watermark.SetText(watermarkInfo.Text);
+                    watermark.SetFontName(watermarkInfo.FontName);
+                    watermark.SetFontSize(watermarkInfo.TextSize);
+                    //watermark.SetScale(watermarkInfo.TextSize);
+                    watermark.SetTextRGBColor(watermarkInfo.TextColor);
+                }
+                else
+                {
+                    watermark = document.InitWatermark(C_Watermark_Type.WATERMARK_TYPE_IMG);
+                    if (watermarkInfo.ImageArray != null)
+                    {
+                        watermark.SetImage(watermarkInfo.ImageArray, watermarkInfo.ImageWidth, watermarkInfo.ImageHeight);
+                    }
+                    watermark.SetScale(watermarkInfo.ImageSize / 100);
+                }
+                watermark.SetRotation((float)((watermarkInfo.Rotation / 180) * Math.PI));
+                watermark.SetOpacity((byte)(((float)watermarkInfo.Opacity / 100) * 255));
+                watermark.SetFront(watermarkInfo.IsFront);
+                watermark.SetVertalign(watermarkInfo.WatermarkVertalign);
+                watermark.SetHorizalign(watermarkInfo.WatermarkHorizalign);
+                watermark.SetFullScreen(watermarkInfo.Isfull);
+                watermark.SetVertOffset(watermarkInfo.VertOffset);
+                watermark.SetHorizOffset(watermarkInfo.HorizOffset);
+                watermark.SetHorizontalSpacing(watermarkInfo.HorizontalSpacing);
+                watermark.SetVerticalSpacing(watermarkInfo.VerticalSpacing);
+                watermark.SetPages("0");
+                Trace.WriteLine("IsCreateWatermark: " + watermark.CreateWatermark());
+                Trace.WriteLine("IsUpdateWatermark: " + watermark.UpdateWatermark());
+            }
+        }
+
+        public void ConfirmEditWatermarkTemplateItem(EnumTextOrFileUnicode enumTextOrFileunicode)
+        {
+            EnumTextOrFile enumTextOrFile = enumTextOrFileunicode.Status;
+            if (enumTextOrFile == EnumTextOrFile.StatusFile && FileNameText != "")
+            {
+                var watermarkItem = new WatermarkItem();
+                ConvertInfoToItem(ref watermarkItem, WatermarkInfo);
+                try
+                {
+                    //创建缓存文件夹
+                    string folderPath = Path.Combine(App.CurrentPath, "Watermark");
+                    //有可能因为其他原因存在同名文件,导致创建文件夹失败,需要先删除同名文件
+                    //保险措施(猜测)
+                    if (File.Exists(folderPath))
+                    {
+                        File.Delete(folderPath);
+                    }
+
+                    DirectoryInfo tempfolder = new DirectoryInfo(folderPath);
+                    if (!tempfolder.Exists)
+                    {
+                        tempfolder.Create();
+                    }
+
+                    //预览图缓存
+                    string saveName = Guid.NewGuid().ToString();
+                    string savePath = Path.Combine(folderPath, saveName);
+                    System.Windows.Size pageSize = new Size { Width = 128, Height = 160 };
+                    CPDFDocument tempDocument = CPDFDocument.CreateDocument();
+                    if (tempDocument != null)
+                    {
+                        tempDocument.InsertPage(0, pageSize.Width / 4, pageSize.Height, null);
+                        CreateWatermark(tempDocument, WatermarkInfo);
+                        //获取透明背景的图片
+                        var bitmap = ToolMethod.RenderPageBitmapNoWait(tempDocument, (int)pageSize.Width, (int)pageSize.Height, 0, false, false, 0x00FFFFFF);
+                        using (FileStream stream = new FileStream(savePath, FileMode.Create))
+                        {
+                            bitmap.Save(stream, System.Drawing.Imaging.ImageFormat.Png);
+                        }
+
+                        watermarkItem.previewImagePath = savePath;
+                        tempDocument.Release();
+
+                        Settings.Default.WatermarkTemplateList[TemplateWatermarkItem.listIndex] = watermarkItem;
+                        Settings.Default.Save();
+                    }
+                }
+                catch
+                {
+
+                }
+
+
+                this.eventAggregator.GetEvent<EnterTemplateListOrCreateEvent>().Publish(new EnumTemplateListOrCreateUnicode
+                {
+                    Unicode = Unicode,
+                    Status = EnumTemplateListOrCreate.StatusTemplate
+                });
+            }
+        }
+
+        /// <summary>
+        /// 根据已知Info初始化
+        /// </summary>
+        public void InitComponentBySelectedInfo()
+        {
+            ConvertItemToInfo(TemplateWatermarkItem, ref WatermarkInfo);
+            VertOffsetValue = WatermarkInfo.VertOffset.ToString();
+            HorizOffsetValue = WatermarkInfo.HorizOffset.ToString();
+            VerticalSpacingValue = WatermarkInfo.VerticalSpacing.ToString();
+            HorizontalSpacingValue = WatermarkInfo.HorizontalSpacing.ToString();
+            PageRangeSelectIndex = WatermarkInfo.PageRangeIndex;
+            IsFrontSelectedIndex = Convert.ToInt32(!WatermarkInfo.IsFront);
+            RotationText = WatermarkInfo.Rotation.ToString();
+            OpacityText = WatermarkInfo.Opacity.ToString() + " %";
+            RelativeScaleText = WatermarkInfo.TextSize.ToString() + " %";
+            InitLocationButtonMatrix();
+            CreateFileVisible = Visibility.Visible;
+            IsRelativeScaleValue = WatermarkInfo.IsRelativeScale;
+            IsFullValue = WatermarkInfo.Isfull;
+            RelativeScaleText = WatermarkInfo.ImageSize.ToString() + " %";
+        }
+
+        public void OpenFile()
+        {
+            System.Windows.Forms.OpenFileDialog dlg = new System.Windows.Forms.OpenFileDialog();
+            dlg.Multiselect = false;
+            dlg.Filter = "PDF|*.png;*.jpg;*.pdf";
+            if (dlg.ShowDialog() == System.Windows.Forms.DialogResult.OK)
+            {
+                FileNameText = dlg.SafeFileName;
+                FileInfo file = new FileInfo(dlg.FileName);
+                if (file.Extension == ".pdf")
+                {
+                    GetBitmapFromDocment(dlg.FileName);
+                }
+                else
+                {
+                    EditToolsHelper.ChooseFile(dlg.FileName, ref WatermarkInfo);
+                }
+                WatermarkInfo.ImagePath = dlg.FileName;
+                CreateFileVisible = Visibility.Visible;
+            }
+        }
+
+        public async void GetBitmapFromDocment(string filePath)
+        {
+            CPDFDocument document = CPDFDocument.InitWithFilePath(filePath);
+            CPDFPage page = document.PageAtIndex(0);
+            byte[] bmp_data = new byte[(int)page.PageSize.Width * (int)page.PageSize.Height * 4];
+            await Task.Run(delegate
+            {
+                page.RenderPageBitmap(0, 0, (int)page.PageSize.Width, (int)page.PageSize.Height, 0xffffffff, bmp_data, 1);
+            });
+            WatermarkInfo.ImageArray = bmp_data;
+            WatermarkInfo.ImageWidth = (int)page.PageSize.Width;
+            WatermarkInfo.ImageHeight = (int)page.PageSize.Height;
+            document.ReleasePages();
+            document.Release();
+        }
+
+        public bool IsNavigationTarget(NavigationContext navigationContext)
+        {
+            return true;
+        }
+
+        public void OnNavigatedFrom(NavigationContext navigationContext)
+        {
+        }
+
+        public void OnNavigatedTo(NavigationContext navigationContext)
+        {
+            navigationContext.Parameters.TryGetValue<CPDFViewer>(ParameterNames.PDFViewer, out PDFViewer);
+            //EditToolsHelper.GetPageRange(PageRangeSelectIndex, PDFViewer.Document, ref WatermarkInfo.PageRange, PageRangeText);
+            if (navigationContext.Parameters.TryGetValue<WatermarkItem>("WatermarkItem", out TemplateWatermarkItem))
+            {
+                InitComponentBySelectedInfo();
+            }
+        }
+    }
+}
+

+ 804 - 0
PDF Office/ViewModels/Dialog/HomePageToolsDialogs/HomePageBatchProcessing/HomePageWatermark/HomePageWatermarkCreateTextContentViewModel.cs

@@ -0,0 +1,804 @@
+using ComPDFKit.PDFDocument;
+using ComPDFKit.PDFWatermark;
+using ComPDFKitViewer.PdfViewer;
+using PDF_Office.EventAggregators;
+using PDF_Office.Helper;
+using PDF_Office.Model.EditTools.Watermark;
+using PDF_Office.Model;
+using PDF_Office.Properties;
+using PDFSettings;
+using Prism.Commands;
+using Prism.Events;
+using Prism.Mvvm;
+using Prism.Regions;
+using System;
+using System.Collections.Generic;
+using System.Diagnostics;
+using System.IO;
+using System.Linq;
+using System.Windows.Media;
+
+namespace PDF_Office.ViewModels.Dialog.HomePageToolsDialogs.HomePageBatchProcessing.HomePageWatermark
+{
+    public class HomePageWatermarkCreateTextContentViewModel : BindableBase, INavigationAware
+    {
+        public WatermarkInfo WatermarkInfo = new WatermarkInfo();
+
+        private WatermarkItem TemplateWatermarkItem;
+
+        IEventAggregator eventAggregator;
+
+        private CPDFViewer PDFViewer;
+
+        private List<string> _opacityList = new List<string>();
+        public List<string> OpacityList
+        {
+            get { return _opacityList; }
+            set
+            {
+                SetProperty(ref _opacityList, value);
+            }
+        }
+
+        private void InitOpacityList()
+        {
+            OpacityList.Clear();
+            for (int temp = 0; temp <= 100; temp += 10)
+            {
+                OpacityList.Add(temp.ToString() + " %");
+            }
+        }
+
+        private List<string> _rotationList = new List<string>();
+        public List<string> RotationList
+        {
+            get { return _rotationList; }
+            set
+            {
+                SetProperty(ref _rotationList, value);
+            }
+        }
+
+        private void InitRotationList()
+        {
+            RotationList.Clear();
+            for (int temp = -45; temp <= 45; temp += 15)
+            {
+                RotationList.Add(temp.ToString());
+            }
+        }
+
+        private List<string> _fontNameList = new List<string>();
+        public List<string> FontNameList
+        {
+            get { return _fontNameList; }
+            set
+            {
+                SetProperty(ref _fontNameList, value);
+            }
+        }
+
+        private void InitFontNameList()
+        {
+            FontNameList.Clear();
+            FontNameList.Add("Courier");
+            FontNameList.Add("Courier-Bold");
+            FontNameList.Add("Courier-Oblique");
+            FontNameList.Add("Courier-BoldOblique");
+            FontNameList.Add("Helvetica");
+            FontNameList.Add("Helvetica-Bold");
+            FontNameList.Add("Helvetica-Oblique");
+            FontNameList.Add("Helvetica-BoldOblique");
+            FontNameList.Add("Times-Roman");
+            FontNameList.Add("Times-Bold");
+            FontNameList.Add("Times-Italic");
+            FontNameList.Add("Times-BoldItalic");
+        }
+
+        private List<string> _fontSizeList = new List<string>();
+        public List<string> FontSizeList
+        {
+            get { return _fontSizeList; }
+            set
+            {
+                SetProperty(ref _fontSizeList, value);
+            }
+        }
+
+        private void InitFontSizeList()
+        {
+            FontSizeList.Clear();
+            FontSizeList.Add("自动");
+            for (int temp = 8; temp <= 15; temp += 1)
+            {
+                FontSizeList.Add(temp.ToString() + "pt");
+            }
+        }
+
+        private List<string> _scaleList = new List<string>();
+        public List<string> ScaleList
+        {
+            get { return _scaleList; }
+            set
+            {
+                SetProperty(ref _scaleList, value);
+            }
+        }
+
+        private void InitScaleList()
+        {
+            ScaleList.Clear();
+            for (int temp = 0; temp <= 100; temp += 10)
+            {
+                ScaleList.Add(temp.ToString() + " %");
+            }
+        }
+
+        private List<string> _isFrontList = new List<string>();
+        public List<string> IsFrontList
+        {
+            get { return _isFrontList; }
+            set
+            {
+                SetProperty(ref _isFrontList, value);
+            }
+        }
+
+        private void InitIsFrontList()
+        {
+            IsFrontList.Clear();
+            IsFrontList.Add("位于页面上方");
+            IsFrontList.Add("位于页面下方");
+        }
+
+        private string _textValue = "一个水印";
+        public string TextValue
+        {
+            get { return _textValue; }
+            set
+            {
+                SetProperty(ref _textValue, value);
+
+            }
+        }
+
+        private int _rotationValue = 0;
+        public int RotationValue
+        {
+            get { return _rotationValue; }
+            set
+            {
+                SetProperty(ref _rotationValue, value);
+                WatermarkInfo.Rotation = RotationValue;
+                
+            }
+        }
+
+        private int _opacityValue = 100;
+        public int OpacityValue
+        {
+            get { return _opacityValue; }
+            set
+            {
+                SetProperty(ref _opacityValue, value);
+                WatermarkInfo.Opacity = (byte)OpacityValue;
+                
+            }
+        }
+
+        private int _relativeScaleValue = 50;
+        public int RelativeScaleValue
+        {
+            get { return _relativeScaleValue; }
+            set
+            {
+                SetProperty(ref _relativeScaleValue, value);
+            }
+        }
+
+        private string _rotationText = "0";
+        public string RotationText
+        {
+            get { return _rotationText; }
+            set
+            {
+                SetProperty(ref _rotationText, value);
+            }
+        }
+
+        private string _opacityText = "100 %";
+        public string OpacityText
+        {
+            get { return _opacityText; }
+            set
+            {
+                SetProperty(ref _opacityText, value);
+
+            }
+        }
+
+        private string _relativeScaleText = "50 %";
+        public string RelativeScaleText
+        {
+            get { return _relativeScaleText; }
+            set
+            {
+                SetProperty(ref _relativeScaleText, value);
+            }
+        }
+
+        private string _vertOffsetValue = "0";
+        public string VertOffsetValue
+        {
+            get { return _vertOffsetValue; }
+            set
+            {
+                SetProperty(ref _vertOffsetValue, value);
+                WatermarkInfo.VertOffset = float.Parse(VertOffsetValue);
+                
+            }
+        }
+
+        private string _horizOffsetValue = "0";
+        public string HorizOffsetValue
+        {
+            get { return _horizOffsetValue; }
+            set
+            {
+                SetProperty(ref _horizOffsetValue, value);
+                WatermarkInfo.HorizOffset = float.Parse(HorizOffsetValue);
+                
+            }
+        }
+
+        private string _verticalSpacingValue = "6";
+        public string VerticalSpacingValue
+        {
+            get { return _verticalSpacingValue; }
+            set
+            {
+                SetProperty(ref _verticalSpacingValue, value);
+                WatermarkInfo.VerticalSpacing = float.Parse(VerticalSpacingValue);
+                
+            }
+        }
+
+        private string _horizontalSpacingValue = "6";
+        public string HorizontalSpacingValue
+        {
+            get { return _horizontalSpacingValue; }
+            set
+            {
+                SetProperty(ref _horizontalSpacingValue, value);
+                WatermarkInfo.HorizontalSpacing = float.Parse(HorizontalSpacingValue);
+                
+            }
+        }
+
+        private int _fontSizeSelectedIndex = 0;
+        public int FontSizeSelectedIndex
+        {
+            get { return _fontSizeSelectedIndex; }
+            set
+            {
+                SetProperty(ref _fontSizeSelectedIndex, value);
+                SetFontSize(FontSizeSelectedIndex);
+                
+            }
+        }
+
+        private int _fontNameSelectedIndex = 0;
+        public int FontNameSelectedIndex
+        {
+            get { return _fontNameSelectedIndex; }
+            set
+            {
+                SetProperty(ref _fontNameSelectedIndex, value);
+                SetFontName(FontNameSelectedIndex);
+                
+            }
+        }
+
+        private int _isFrontSelectedIndex = 0;
+        public int IsFrontSelectedIndex
+        {
+            get { return _isFrontSelectedIndex; }
+            set
+            {
+                SetProperty(ref _isFrontSelectedIndex, value);
+                SetIsFront(IsFrontSelectedIndex);
+                
+            }
+        }
+
+        private bool _isFullValue = false;
+        public bool IsFullValue
+        {
+            get { return _isFullValue; }
+            set
+            {
+                SetProperty(ref _isFullValue, value);
+                WatermarkInfo.Isfull = IsFullValue;
+                
+            }
+        }
+
+        private bool _isRelativeScaleValue = false;
+        public bool IsRelativeScaleValue
+        {
+            get { return _isRelativeScaleValue; }
+            set
+            {
+                SetProperty(ref _isRelativeScaleValue, value);
+                WatermarkInfo.IsRelativeScale = IsRelativeScaleValue;
+                
+            }
+        }
+
+        private SolidColorBrush _solidColorBrush = null;
+        public SolidColorBrush SolidColorBrush
+        {
+            get
+            {
+                return _solidColorBrush;
+            }
+            set
+            {
+
+                SetProperty(ref _solidColorBrush, value);
+            }
+        }
+
+        private Color _stringColor = Color.FromArgb(0xFF, 0xFF, 0x00, 0x00);
+        public Color StringColor
+        {
+            get
+            {
+                return _stringColor;
+            }
+            set
+            {
+                SetProperty(ref _stringColor, value);
+                WatermarkInfo.TextColor = EditToolsHelper.ConvertColor(value);
+                SolidColorBrush = new SolidColorBrush(_stringColor);
+                
+            }
+        }
+        public string _pageRangeText = "0";
+        public string PageRangeText
+        {
+            get { return _pageRangeText; }
+            set
+            {
+                _pageRangeText = value;
+                //EditToolsHelper.GetPageRange(PageRangeSelectIndex, PDFViewer.Document, ref WatermarkInfo.PageRange, PageRangeText);
+                
+            }
+        }
+
+        private int _pageRangeSelectIndex = 0;
+        public int PageRangeSelectIndex
+        {
+            get { return _pageRangeSelectIndex; }
+            set
+            {
+                SetProperty(ref _pageRangeSelectIndex, value);
+                WatermarkInfo.PageRangeIndex = PageRangeSelectIndex;
+                //EditToolsHelper.GetPageRange(PageRangeSelectIndex, PDFViewer.Document, ref WatermarkInfo.PageRange, PageRangeText);
+                
+            }
+        }
+
+        private ObservableDictionary<string, bool> _getLocationFromNumber = new ObservableDictionary<string, bool>();
+        public ObservableDictionary<string, bool> GetLocationFromNumber
+        {
+            get { return _getLocationFromNumber; }
+            set { _getLocationFromNumber = value; }
+        }
+
+        public DelegateCommand<object> ChangeLocationCommand { get; set; }
+
+        public DelegateCommand<object> SelectedColorChangedCommand { get; set; }
+
+        public DelegateCommand<object> TextValueChangedCommand { get; set; }
+
+        public string Unicode = null;
+
+        public HomePageWatermarkCreateTextContentViewModel(IEventAggregator eventAggregator)
+        {
+            this.eventAggregator = eventAggregator;
+            Unicode = App.mainWindowViewModel.SelectedItem.Unicode;
+            WatermarkInfo.WatermarkType = C_Watermark_Type.WATERMARK_TYPE_TEXT;
+            ChangeLocationCommand = new DelegateCommand<object>(ChangeLocation);
+            SelectedColorChangedCommand = new DelegateCommand<object>(ChangedColor);
+            TextValueChangedCommand = new DelegateCommand<object>(TextValueChanged);
+
+            InitList();
+            InitWatermarkInfo();
+            InitLocationButtonMatrix();
+            eventAggregator.GetEvent<SaveWatermarkTemplateEvent>().Subscribe(SaveWatermarkTemplate, e => e.Unicode == Unicode);
+            eventAggregator.GetEvent<ConfirmEditWatermarkTemplateItemEvent>().Subscribe(ConfirmEditWatermarkTemplateItem, e => e.Unicode == Unicode);
+        }
+
+        public void SaveWatermarkTemplate(EnumTextOrFileUnicode enumTextOrFileunicode)
+        {
+            EnumTextOrFile enumTextOrFile = enumTextOrFileunicode.Status;
+            if (enumTextOrFile == EnumTextOrFile.StatusText)
+            {
+                SaveCurrentTemplate();
+            }
+        }
+
+        public void ConvertInfoToItem(ref WatermarkItem watermarkItem, WatermarkInfo watermarkInfo)
+        {
+            if (watermarkInfo != null)
+            {
+                watermarkItem.type = watermarkInfo.WatermarkType;
+                watermarkItem.text = watermarkInfo.Text;
+                watermarkItem.fontSize = watermarkInfo.TextSize;
+                watermarkItem.fontName = watermarkInfo.FontName;
+                watermarkItem.textcolor = watermarkInfo.TextColor;
+                watermarkItem.horizalign = watermarkInfo.WatermarkHorizalign;
+                watermarkItem.vertalign = watermarkInfo.WatermarkVertalign;
+                watermarkItem.isFullScreen = watermarkInfo.Isfull;
+                watermarkItem.isRelativeScale = watermarkInfo.IsRelativeScale;
+                watermarkItem.isfront = watermarkInfo.IsFront;
+                watermarkItem.opacity = watermarkInfo.Opacity;
+                watermarkItem.rotation = watermarkInfo.Rotation;
+                watermarkItem.vertOffset = watermarkInfo.VertOffset;
+                watermarkItem.horizOffset = watermarkInfo.HorizOffset;
+                watermarkItem.verticalSpacing = watermarkInfo.VerticalSpacing;
+                watermarkItem.horizontalSpacing = watermarkInfo.HorizontalSpacing;
+                watermarkItem.pageRangeIndex = watermarkInfo.PageRangeIndex;
+                watermarkItem.pageRange = watermarkInfo.PageRange;
+            }
+        }
+
+        public void ConvertItemToInfo(WatermarkItem watermarkItem, ref WatermarkInfo watermarkInfo)
+        {
+            if (watermarkItem != null)
+            {
+                watermarkInfo.WatermarkType = C_Watermark_Type.WATERMARK_TYPE_TEXT;
+                watermarkInfo.Text = watermarkItem.text;
+                watermarkInfo.TextSize = watermarkItem.fontSize;
+                watermarkInfo.FontName = watermarkItem.fontName;
+                watermarkInfo.TextColor = watermarkItem.textcolor;
+                watermarkInfo.WatermarkHorizalign = watermarkItem.horizalign;
+                watermarkInfo.WatermarkVertalign = watermarkItem.vertalign;
+                watermarkInfo.IsRelativeScale = watermarkItem.isRelativeScale;
+                watermarkInfo.Isfull = watermarkItem.isFullScreen;
+                watermarkInfo.IsFront = watermarkItem.isfront;
+                watermarkInfo.Opacity = watermarkItem.opacity;
+                watermarkInfo.Rotation = watermarkItem.rotation;
+                watermarkInfo.VertOffset = watermarkItem.vertOffset;
+                watermarkInfo.HorizOffset = watermarkItem.horizOffset;
+                watermarkInfo.VerticalSpacing = watermarkItem.verticalSpacing;
+                watermarkInfo.HorizontalSpacing = watermarkItem.horizontalSpacing;
+                watermarkInfo.PageRangeIndex = watermarkItem.pageRangeIndex;
+                //EditToolsHelper.GetPageRange(watermarkItem.pageRangeIndex, PDFViewer.Document, ref WatermarkInfo.PageRange, watermarkItem.pageRange);
+            }
+
+        }
+
+
+        public void SaveCurrentTemplate()
+        {
+            var watermarkItem = new WatermarkItem();
+            ConvertInfoToItem(ref watermarkItem, WatermarkInfo);
+            watermarkItem.templateName += Settings.Default.WatermarkIndex.ToString();
+            try
+            {
+                //创建缓存文件夹
+                string folderPath = Path.Combine(App.CurrentPath, "Watermark");
+                //有可能因为其他原因存在同名文件,导致创建文件夹失败,需要先删除同名文件
+                //保险措施(猜测)
+                if (File.Exists(folderPath))
+                {
+                    File.Delete(folderPath);
+                }
+
+                DirectoryInfo tempfolder = new DirectoryInfo(folderPath);
+                if (!tempfolder.Exists)
+                {
+                    tempfolder.Create();
+                }
+
+                //预览图缓存
+                string saveName = Guid.NewGuid().ToString();
+                string savePath = Path.Combine(folderPath, saveName);
+                System.Windows.Size pageSize = new System.Windows.Size { Width = 128, Height = 160 };
+                CPDFDocument tempDocument = CPDFDocument.CreateDocument();
+                if (tempDocument != null)
+                {
+                    tempDocument.InsertPage(0, pageSize.Width, pageSize.Height, null);
+                    CreateWatermark(tempDocument, WatermarkInfo);
+                    //获取透明背景的图片
+                    var bitmap = ToolMethod.RenderPageBitmapNoWait(tempDocument, (int)pageSize.Width, (int)pageSize.Height, 0, false, false, 0x00FFFFFF);
+                    using (FileStream stream = new FileStream(savePath, FileMode.Create))
+                    {
+                        bitmap.Save(stream, System.Drawing.Imaging.ImageFormat.Png);
+                    }
+
+                    watermarkItem.previewImagePath = savePath;
+                    tempDocument.Release();
+
+                    Settings.Default.WatermarkTemplateList.Add(watermarkItem);
+                    Settings.Default.Save();
+                }
+            }
+            catch
+            {
+
+            }
+            this.eventAggregator.GetEvent<EnterTemplateListOrCreateEvent>().Publish(new EnumTemplateListOrCreateUnicode
+            {
+                Unicode = Unicode,
+                Status = EnumTemplateListOrCreate.StatusTemplate
+            });
+        }
+
+        private void InitLocationButtonMatrix()
+        {
+            GetLocationFromNumber.Clear();
+            for (var temp = 0; temp <= 22; temp++)
+            {
+                GetLocationFromNumber.Add(temp.ToString(), true);
+                if (temp % 10 == 2)
+                {
+                    temp += 7;
+                }
+            }
+            int Num = (int)WatermarkInfo.WatermarkVertalign * 10 + (int)WatermarkInfo.WatermarkHorizalign;
+            GetLocationFromNumber[Num.ToString()] = false;
+
+        }
+
+        public void ChangeLocation(object e)
+        {
+            string args = e as string;
+            if (args != null)
+            {
+                WatermarkInfo.WatermarkVertalign = (C_Watermark_Vertalign)(int.Parse(args) / 10);
+                WatermarkInfo.WatermarkHorizalign = (C_Watermark_Horizalign)(int.Parse(args) % 10);
+               
+                InitLocationButtonMatrix();
+            }
+        }
+
+        private void ChangedColor(object obj)
+        {
+            if (obj != null)
+            {
+                var colorValue = (Color)obj;
+                if (colorValue != null)
+                {
+
+                    StringColor = colorValue;
+                }
+            }
+        }
+        private void TextValueChanged(object obj)
+        {
+            if (obj != null)
+            {
+                var textValue = obj as System.Windows.Controls.TextBox;
+                if (textValue != null)
+                {
+
+                    TextValue = textValue.Text;
+                    WatermarkInfo.Text = TextValue;
+                    
+                }
+            }
+
+        }
+
+        private void SetFontName(int Index)
+        {
+            WatermarkInfo.FontName = FontNameList[Index];
+        }
+
+        private void SetFontSize(int Index)
+        {
+            if (Index == 0)
+            {
+                WatermarkInfo.TextSize = 10;
+            }
+            else
+            {
+                WatermarkInfo.TextSize = (Index + 7) * 1.33f;
+            }
+        }
+
+        private void SetIsFront(int Index)
+        {
+            if (Index == 0)
+            {
+                WatermarkInfo.IsFront = true;
+            }
+            if (Index == 1)
+            {
+                WatermarkInfo.IsFront = false;
+            }
+        }
+
+        public void ConfirmEditToolsWatermark()
+        {
+            
+        }
+
+        private void InitList()
+        {
+            InitOpacityList();
+            InitFontNameList();
+            InitFontSizeList();
+            InitIsFrontList();
+            InitRotationList();
+            InitScaleList();
+        }
+
+        private void InitWatermarkInfo()
+        {
+
+            WatermarkInfo.Text = TextValue;
+            WatermarkInfo.Rotation = RotationValue;
+            WatermarkInfo.Opacity = (byte)OpacityValue;
+            WatermarkInfo.VertOffset = float.Parse(VertOffsetValue);
+            WatermarkInfo.HorizOffset = float.Parse(HorizOffsetValue);
+            WatermarkInfo.VerticalSpacing = float.Parse(VerticalSpacingValue);
+            WatermarkInfo.HorizontalSpacing = float.Parse(HorizontalSpacingValue);
+            WatermarkInfo.WatermarkHorizalign = C_Watermark_Horizalign.WATERMARK_HORIZALIGN_CENTER;
+            WatermarkInfo.WatermarkVertalign = C_Watermark_Vertalign.WATERMARK_VERTALIGN_CENTER;
+            WatermarkInfo.IsRelativeScale = IsRelativeScaleValue;
+            WatermarkInfo.Isfull = IsFullValue;
+            SetFontName(FontNameSelectedIndex);
+            SetFontSize(FontSizeSelectedIndex);
+            SetIsFront(IsFrontSelectedIndex);
+            StringColor = Color.FromArgb(0xFF, 0xFF, 0x00, 0x00);
+        }
+
+        /// <summary>
+        /// 根据已知Info初始化
+        /// </summary>
+        public void InitComponentBySelectedInfo()
+        {
+            ConvertItemToInfo(TemplateWatermarkItem, ref WatermarkInfo);
+            TextValue = WatermarkInfo.Text;
+            StringColor = EditToolsHelper.ConvertColor(WatermarkInfo.TextColor);
+            VertOffsetValue = WatermarkInfo.VertOffset.ToString();
+            HorizOffsetValue = WatermarkInfo.HorizOffset.ToString();
+            VerticalSpacingValue = WatermarkInfo.VerticalSpacing.ToString();
+            HorizontalSpacingValue = WatermarkInfo.HorizontalSpacing.ToString();
+            PageRangeSelectIndex = WatermarkInfo.PageRangeIndex;
+            FontNameSelectedIndex = FontNameList.IndexOf(WatermarkInfo.FontName);
+            FontSizeSelectedIndex = FontSizeList.IndexOf(((int)(WatermarkInfo.TextSize / 1.33f)).ToString() + "pt");
+            IsFrontSelectedIndex = Convert.ToInt32(!WatermarkInfo.IsFront);
+            RotationText = WatermarkInfo.Rotation.ToString();
+            OpacityText = WatermarkInfo.Opacity.ToString() + " %";
+            RelativeScaleText = WatermarkInfo.TextSize.ToString() + " %";
+            IsFullValue = WatermarkInfo.Isfull;
+            IsRelativeScaleValue = WatermarkInfo.IsRelativeScale;
+            InitLocationButtonMatrix();
+
+        }
+        public void CreateWatermark(CPDFDocument document, WatermarkInfo watermarkInfo)
+        {
+            if (watermarkInfo != null)
+            {
+                document.DeleteWatermarks();
+                CPDFWatermark watermark;
+                if (watermarkInfo.WatermarkType == C_Watermark_Type.WATERMARK_TYPE_TEXT)
+                {
+                    watermark = document.InitWatermark(C_Watermark_Type.WATERMARK_TYPE_TEXT);
+                    watermark.SetText(watermarkInfo.Text);
+                    watermark.SetFontName(watermarkInfo.FontName);
+                    watermark.SetFontSize(watermarkInfo.TextSize);
+                    watermark.SetTextRGBColor(watermarkInfo.TextColor);
+                }
+                else
+                {
+                    watermark = document.InitWatermark(C_Watermark_Type.WATERMARK_TYPE_IMG);
+                    if (watermarkInfo.ImageArray != null)
+                    {
+                        watermark.SetImage(watermarkInfo.ImageArray, watermarkInfo.ImageWidth, watermarkInfo.ImageHeight);
+                    }
+                    watermark.SetScale(watermarkInfo.ImageSize / 100);
+                }
+                watermark.SetRotation((float)((watermarkInfo.Rotation / 180) * Math.PI));
+                watermark.SetOpacity((byte)(((float)watermarkInfo.Opacity / 100) * 255));
+                watermark.SetFront(watermarkInfo.IsFront);
+                watermark.SetVertalign(watermarkInfo.WatermarkVertalign);
+                watermark.SetHorizalign(watermarkInfo.WatermarkHorizalign);
+                watermark.SetFullScreen(watermarkInfo.Isfull);
+                watermark.SetVertOffset(watermarkInfo.VertOffset);
+                watermark.SetHorizOffset(watermarkInfo.HorizOffset);
+                watermark.SetHorizontalSpacing(watermarkInfo.HorizontalSpacing);
+                watermark.SetVerticalSpacing(watermarkInfo.VerticalSpacing);
+                watermark.SetPages("0");
+                Trace.WriteLine("IsCreateWatermark: " + watermark.CreateWatermark());
+                Trace.WriteLine("IsUpdateWatermark: " + watermark.UpdateWatermark());
+            }
+        }
+
+        public void ConfirmEditWatermarkTemplateItem(EnumTextOrFileUnicode enumTextOrFileunicode)
+        {
+            EnumTextOrFile enumTextOrFile = enumTextOrFileunicode.Status;
+            if (enumTextOrFile == EnumTextOrFile.StatusText)
+            {
+                var watermarkItem = new WatermarkItem();
+                ConvertInfoToItem(ref watermarkItem, WatermarkInfo);
+                try
+                {
+                    //创建缓存文件夹
+                    string folderPath = Path.Combine(App.CurrentPath, "Watermark");
+                    //有可能因为其他原因存在同名文件,导致创建文件夹失败,需要先删除同名文件
+                    //保险措施(猜测)
+                    if (File.Exists(folderPath))
+                    {
+                        File.Delete(folderPath);
+                    }
+
+                    DirectoryInfo tempfolder = new DirectoryInfo(folderPath);
+                    if (!tempfolder.Exists)
+                    {
+                        tempfolder.Create();
+                    }
+
+                    //预览图缓存
+                    string saveName = Guid.NewGuid().ToString();
+                    string savePath = Path.Combine(folderPath, saveName);
+                    System.Windows.Size pageSize = new System.Windows.Size { Width = 128, Height = 160 };
+                    CPDFDocument tempDocument = CPDFDocument.CreateDocument();
+                    if (tempDocument != null)
+                    {
+                        tempDocument.InsertPage(0, pageSize.Width, pageSize.Height, null);
+                        CreateWatermark(tempDocument, WatermarkInfo);
+
+                        //获取透明背景的图片
+                        var bitmap = ToolMethod.RenderPageBitmapNoWait(tempDocument, (int)pageSize.Width, (int)pageSize.Height, 0, false, false, 0x00FFFFFF);
+                        using (FileStream stream = new FileStream(savePath, FileMode.Create))
+                        {
+                            bitmap.Save(stream, System.Drawing.Imaging.ImageFormat.Png);
+                        }
+
+                        watermarkItem.previewImagePath = savePath;
+                        tempDocument.Release();
+
+                        Settings.Default.WatermarkTemplateList[TemplateWatermarkItem.listIndex] = watermarkItem;
+                        Settings.Default.Save();
+                    }
+                }
+                catch
+                {
+
+                }
+                this.eventAggregator.GetEvent<EnterTemplateListOrCreateEvent>().Publish(new EnumTemplateListOrCreateUnicode
+                {
+                    Unicode = Unicode,
+                    Status = EnumTemplateListOrCreate.StatusTemplate
+                });
+
+            }
+        }
+
+        public bool IsNavigationTarget(NavigationContext navigationContext)
+        {
+            return true;
+        }
+
+        public void OnNavigatedFrom(NavigationContext navigationContext)
+        {
+        }
+
+        public void OnNavigatedTo(NavigationContext navigationContext)
+        {
+            navigationContext.Parameters.TryGetValue<CPDFViewer>(ParameterNames.PDFViewer, out PDFViewer);
+            //EditToolsHelper.GetPageRange(PageRangeSelectIndex, PDFViewer.Document, ref WatermarkInfo.PageRange, PageRangeText);
+            if (navigationContext.Parameters.TryGetValue<WatermarkItem>("WatermarkItem", out TemplateWatermarkItem))
+            {
+                InitComponentBySelectedInfo();
+            }
+
+        }
+    }
+}

+ 136 - 4
PDF Office/ViewModels/Dialog/HomePageToolsDialogs/HomePageBatchProcessing/HomePageWatermark/HomePageWatermarkDialogViewModel.cs

@@ -14,6 +14,10 @@ using System.Windows.Forms;
 using PDF_Office.Helper;
 using System.Windows;
 using System.Data;
+using ComPDFKitViewer.PdfViewer;
+using Prism.Events;
+using PDF_Office.EventAggregators;
+using PDFSettings;
 
 namespace PDF_Office.ViewModels.Dialog.HomePageToolsDialogs.HomePageBatchProcessing.HomePageWatermark
 {
@@ -26,7 +30,50 @@ namespace PDF_Office.ViewModels.Dialog.HomePageToolsDialogs.HomePageBatchProcess
 
         public string PageNumber = "";
 
-        public IRegionManager WatermarkRegion;
+        public IEventAggregator eventAggregator;
+        public IRegionManager watermarkRegion;
+
+        private CPDFViewer PDFViewer;
+
+        private CPDFViewer CurrentPDFViewer;
+
+        private ViewContentViewModel viewContentViewModel;
+
+        public string TemplateListName = "HomePageWatermarkTemplateListBaseContent";
+        public string CreateBaseName = "HomePageWatermarkCreateBaseContent";
+        public string CreateModTextName = "HomePageWatermarkCreateTextContent";
+        public string CreateModFileName = "HomePageWatermarkCreateFileContent";
+
+        public string TemplateListModTextName = "HomePageWatermarkTemplateListTextContent";
+        public string TemplateListModFileName = "HomePageWatermarkTemplateListFileContent";
+
+        private string _watermarkSettingsRegionName;
+        public string WatermarkSettingsRegionName
+        {
+            get { return _watermarkSettingsRegionName; }
+            set { _watermarkSettingsRegionName = value; }
+        }
+
+        private Visibility _watermarkSettingsVisible = Visibility.Collapsed;
+        public Visibility WatermarkSettingsVisible
+        {
+            get { return _watermarkSettingsVisible; }
+            set { _watermarkSettingsVisible = value; }
+        }
+
+        private EnumTextOrFile _currentCreateMod;
+        public EnumTextOrFile CurrentCreateMod
+        {
+            get { return _currentCreateMod; }
+            set { _currentCreateMod = value; }
+        }
+
+        private EnumTextOrFile _currentTemplateListMod;
+        public EnumTextOrFile CurrentTemplateListMod
+        {
+            get { return _currentTemplateListMod; }
+            set { _currentTemplateListMod = value; }
+        }
 
         public List<int> fileNamesView = new List<int>();
 
@@ -130,8 +177,15 @@ namespace PDF_Office.ViewModels.Dialog.HomePageToolsDialogs.HomePageBatchProcess
 
         public DelegateCommand ADDPDFFilesCommand { get; set; }
         #endregion
-        public HomePageWatermarkDialogViewModel(IRegionManager watermarkRegion)
+
+        public string Unicode = null;
+
+        public HomePageWatermarkDialogViewModel(IRegionManager watermarkRegion, IEventAggregator eventAggregator)
         {
+            this.eventAggregator = eventAggregator;
+            this.watermarkRegion = watermarkRegion;
+            Unicode = App.mainWindowViewModel.SelectedItem.Unicode;
+            WatermarkSettingsVisible = Visibility.Visible;
             PDFDataTable.Columns.Add("FileName");
             PDFDataTable.Columns.Add("FilePageRangeText");
             PDFDataTable.Columns.Add("FilePageRangeSelectIndex");
@@ -141,11 +195,85 @@ namespace PDF_Office.ViewModels.Dialog.HomePageToolsDialogs.HomePageBatchProcess
             ADDPDFFilesCommand = new DelegateCommand(addpicturefiles);
             RemovePDFFileCommand = new DelegateCommand(removepdffile);
             CreateCommand = new DelegateCommand(create);
-            WatermarkRegion = watermarkRegion;
-            WatermarkRegionName = Guid.NewGuid().ToString();
+            WatermarkSettingsRegionName = Guid.NewGuid().ToString();
+            eventAggregator.GetEvent<EnterTemplateListOrCreateEvent>().Subscribe(EnterTemplateListOrCreate, e => e.Unicode == Unicode);
+            eventAggregator.GetEvent<SetCurrentCreateModEvent>().Subscribe(SetCurrentCreateMod, e => e.Unicode == Unicode);
+            eventAggregator.GetEvent<SetCurrentTemplateListModEvent>().Subscribe(SetCurrentTemplateListMod, e => e.Unicode == Unicode);
+            eventAggregator.GetEvent<CurrentWatermarkPDFViewerEvent>().Subscribe(CurrentWatermarkPDFViewer, e => e.Unicode == Unicode);
+            eventAggregator.GetEvent<EditWatermarkTemplateItemEvent>().Subscribe(EditWatermarkTemplateItem, e => e.Unicode == Unicode);
         }
         #region 逻辑函数
+        public void EnterTemplateListOrCreate(EnumTemplateListOrCreateUnicode enumTemplateListOrCreateunicode)
+        {
+            EnumTemplateListOrCreate enumTemplateListOrCreate = enumTemplateListOrCreateunicode.Status;
+            if (enumTemplateListOrCreate == EnumTemplateListOrCreate.StatusTemplate)
+            {
+                EnterSelectedContent(TemplateListName);
+            }
+            else
+            {
+                EnterSelectedContent(CreateBaseName);
+            }
+        }
 
+        public void EnterSelectedContent(string SelectedContentName)
+        {
+            NavigationParameters param = new NavigationParameters();
+            param.Add(ParameterNames.PDFViewer, PDFViewer);
+            if (SelectedContentName == TemplateListName)
+            {
+                param.Add("CurrentCreateModName", CurrentCreateMod);
+            }
+            else if (SelectedContentName == CreateBaseName)
+            {
+                param.Add("CurrentTemplateListModName", CurrentTemplateListMod);
+            }
+            watermarkRegion.RequestNavigate(WatermarkSettingsRegionName, SelectedContentName, param);
+            WatermarkSettingsVisible = Visibility.Visible;
+        }
+
+        public void SetCurrentCreateMod(stringUnicode currentCreateModNameunicode)
+        {
+            string currentCreateModName = currentCreateModNameunicode.Status;
+            if (currentCreateModName == CreateModTextName)
+            {
+                CurrentCreateMod = EnumTextOrFile.StatusText;
+            }
+            else if (currentCreateModName == CreateModFileName)
+            {
+                CurrentCreateMod = EnumTextOrFile.StatusFile;
+            }
+        }
+
+        public void SetCurrentTemplateListMod(stringUnicode currentTemplateListModNameunicode)
+        {
+            string currentTemplateListModName = currentTemplateListModNameunicode.Status;
+            if (currentTemplateListModName == TemplateListModTextName)
+            {
+                CurrentTemplateListMod = EnumTextOrFile.StatusText;
+            }
+            else if (currentTemplateListModName == TemplateListModFileName)
+            {
+                CurrentTemplateListMod = EnumTextOrFile.StatusFile;
+            }
+        }
+
+        public void CurrentWatermarkPDFViewer(CPDFViewerUnicode cPDFViewerunicod)
+        {
+            CurrentPDFViewer = cPDFViewerunicod.Status;
+
+        }
+
+        public void EditWatermarkTemplateItem(WatermarkItemUnicode watermarkItemunicode)
+        {
+            WatermarkItem watermarkItem = watermarkItemunicode.Status;
+            NavigationParameters param = new NavigationParameters();
+            param.Add(ParameterNames.PDFViewer, PDFViewer);
+            param.Add("CurrentTemplateListModName", CurrentTemplateListMod);
+            param.Add("WatermarkItem", watermarkItem);
+            watermarkRegion.RequestNavigate(WatermarkSettingsRegionName, CreateBaseName, param);
+            WatermarkSettingsVisible = Visibility.Visible;
+        }
 
         private void create()
         {
@@ -334,9 +462,13 @@ namespace PDF_Office.ViewModels.Dialog.HomePageToolsDialogs.HomePageBatchProcess
         public void OnNavigatedTo(NavigationContext navigationContext)
         {
             List<string> filepath = new List<string>();
+            navigationContext.Parameters.TryGetValue<ViewContentViewModel>(ParameterNames.ViewContentViewModel, out viewContentViewModel);
+            navigationContext.Parameters.TryGetValue<CPDFViewer>(ParameterNames.PDFViewer, out PDFViewer);
+            
             navigationContext.Parameters.TryGetValue<List<string>>(ParameterNames.FilePath, out filepath);
             if (filepath != null)
             {
+                EnterSelectedContent(TemplateListName);
                 fileNames = filepath;
                 PDFFileCount();
                 updateListview("待确定");

+ 173 - 0
PDF Office/ViewModels/Dialog/HomePageToolsDialogs/HomePageBatchProcessing/HomePageWatermark/HomePageWatermarkTemplateListBaseContentViewModel.cs

@@ -0,0 +1,173 @@
+using ComPDFKitViewer.PdfViewer;
+using PDF_Office.CustomControl;
+using PDF_Office.EventAggregators;
+using PDF_Office.Model;
+using Prism.Commands;
+using Prism.Events;
+using Prism.Mvvm;
+using Prism.Regions;
+using System;
+using System.Collections.Generic;
+using System.Linq;
+using System.Windows.Controls;
+
+namespace PDF_Office.ViewModels.Dialog.HomePageToolsDialogs.HomePageBatchProcessing.HomePageWatermark
+{
+    public class HomePageWatermarkTemplateListBaseContentViewModel : BindableBase, INavigationAware
+    {
+        public IRegionManager watermarkTemplateListRegion;
+        private readonly IEventAggregator eventAggregator;
+
+        private CPDFViewer CurrentPDFViewer;
+
+        private string WatermarkTemplateListTextContentName = "HomePageWatermarkTemplateListTextContent";
+        private string WatermarkTemplateListFileContentName = "HomePageWatermarkTemplateListFileContent";
+
+        public bool IsFirstEnter = true;
+
+        public EnumTextOrFile CurrentCreateMod;
+
+        private string _currentTemplateListModName;
+        public string CurrentTemplateListModName
+        {
+            get { return _currentTemplateListModName; }
+            set { _currentTemplateListModName = value; }
+        }
+
+        private string watermarkTemplateListRegionName;
+
+        public string WatermarkTemplateListRegionName
+        {
+            get => watermarkTemplateListRegionName;
+            set => SetProperty(ref watermarkTemplateListRegionName, value);
+        }
+
+
+        private System.Windows.Visibility watermarkTemplateListVisible;
+        public System.Windows.Visibility WatermarkTemplateListVisible
+        {
+            get => watermarkTemplateListVisible;
+            set => SetProperty(ref watermarkTemplateListVisible, value);
+        }
+
+        public DelegateCommand<object> ChangeTemplateListModCommand { get; set; }
+        public DelegateCommand EnterCreateCommand { get; set; }
+
+        public string Unicode = null;
+
+        public HomePageWatermarkTemplateListBaseContentViewModel(IRegionManager watermarkTemplateListRegion, IEventAggregator eventAggregator)
+        {
+            this.watermarkTemplateListRegion = watermarkTemplateListRegion;
+            this.eventAggregator = eventAggregator;
+            Unicode = App.mainWindowViewModel.SelectedItem.Unicode;
+            WatermarkTemplateListRegionName = Guid.NewGuid().ToString();
+            ChangeTemplateListModCommand = new DelegateCommand<object>(ChangeTemplateListMod);
+            EnterCreateCommand = new DelegateCommand(EnterCreate);
+            EnterSelectedTemplateListMod("HomePageWatermarkTemplateListColorContent");
+            eventAggregator.GetEvent<CurrentWatermarkPDFViewerEvent>().Subscribe(CurrentWatermarkPDFViewer, e => e.Unicode == Unicode);
+
+        }
+        public void CurrentWatermarkPDFViewer(CPDFViewerUnicode cPDFViewerunicode)
+        {
+            CurrentPDFViewer = cPDFViewerunicode.Status;
+        }
+        public void EnterCreate()
+        {
+            AlertsMessage alertsMessage = new AlertsMessage();
+            //if (CurrentPDFViewer.Document.GetWatermarkCount() > 0)
+            //{
+            //    alertsMessage.ShowDialog("文件中已添加水印,您要替换现有的水印吗?", "", "取消", "确定");
+            //    if (alertsMessage.result == ContentResult.Ok)
+            //    {
+            //        this.eventAggregator.GetEvent<DeleteWatermarkEvent>().Publish(new EnumDeleteUnicode
+            //        {
+            //            Unicode = Unicode,
+            //            Status = EnumDelete.StatusDeleteInitial
+            //        });
+            //    }
+            //    else
+            //    {
+            //        this.eventAggregator.GetEvent<DeleteWatermarkEvent>().Publish(new EnumDeleteUnicode
+            //        {
+            //            Unicode = Unicode,
+            //            Status = EnumDelete.StatusCreate
+            //        });
+            //    }
+            //}
+            this.eventAggregator.GetEvent<EnterTemplateListOrCreateEvent>().Publish(new EnumTemplateListOrCreateUnicode
+            {
+                Unicode = Unicode,
+                Status = EnumTemplateListOrCreate.StatusCreate
+            });
+
+        }
+
+        public void EnterSelectedTemplateListMod(string currentTemplateListName)
+        {
+            NavigationParameters param = new NavigationParameters();
+            param.Add(ParameterNames.PDFViewer, CurrentPDFViewer);
+            watermarkTemplateListRegion.RequestNavigate(WatermarkTemplateListRegionName, currentTemplateListName, param);
+            eventAggregator.GetEvent<CurrentWatermarkPDFViewerEvent>().Publish(new CPDFViewerUnicode
+            {
+                Unicode = Unicode,
+                Status = CurrentPDFViewer
+            });
+            watermarkTemplateListVisible = System.Windows.Visibility.Visible;
+        }
+
+        public void ChangeTemplateListMod(object e)
+        {
+            var args = e as Button;
+            if (args != null)
+            {
+                CurrentTemplateListModName = args.Name;
+                EnterSelectedTemplateListMod(CurrentTemplateListModName);
+                eventAggregator.GetEvent<SetCurrentTemplateListModEvent>().Publish(new stringUnicode
+                {
+                    Unicode = Unicode,
+                    Status = CurrentTemplateListModName
+                });
+            }
+        }
+
+        public bool IsNavigationTarget(NavigationContext navigationContext)
+        {
+            return true;
+        }
+
+        public void OnNavigatedFrom(NavigationContext navigationContext)
+        {
+        }
+
+        public void OnNavigatedTo(NavigationContext navigationContext)
+        {
+            if (IsFirstEnter)
+            {
+                CurrentTemplateListModName = WatermarkTemplateListTextContentName;
+                EnterSelectedTemplateListMod(CurrentTemplateListModName);
+                IsFirstEnter = false;
+            }
+            else
+            {
+                navigationContext.Parameters.TryGetValue<EnumTextOrFile>("CurrentCreateModName", out CurrentCreateMod);
+                if (CurrentCreateMod == EnumTextOrFile.StatusText)
+                {
+                    CurrentTemplateListModName = WatermarkTemplateListTextContentName;
+                }
+                else
+                {
+                    CurrentTemplateListModName = WatermarkTemplateListFileContentName;
+                }
+                EnterSelectedTemplateListMod(CurrentTemplateListModName);
+                eventAggregator.GetEvent<SetCurrentTemplateListModEvent>().Publish(new stringUnicode
+                {
+                    Unicode = Unicode,
+                    Status = CurrentTemplateListModName
+                });
+
+
+            }
+        }
+    }
+}
+

+ 308 - 0
PDF Office/ViewModels/Dialog/HomePageToolsDialogs/HomePageBatchProcessing/HomePageWatermark/HomePageWatermarkTemplateListFileContentViewModel.cs

@@ -0,0 +1,308 @@
+using ComPDFKit.PDFDocument;
+using ComPDFKit.PDFPage;
+using ComPDFKitViewer.PdfViewer;
+using PDF_Office.CustomControl;
+using PDF_Office.EventAggregators;
+using PDF_Office.Helper;
+using PDF_Office.Model.EditTools.Watermark;
+using PDF_Office.Properties;
+using PDFSettings;
+using Prism.Commands;
+using Prism.Events;
+using Prism.Mvvm;
+using Prism.Regions;
+using System;
+using System.Collections.Generic;
+using System.Collections.ObjectModel;
+using System.IO;
+using System.Linq;
+using System.Threading.Tasks;
+using System.Windows;
+using System.Windows.Controls;
+using System.Windows.Media;
+
+namespace PDF_Office.ViewModels.Dialog.HomePageToolsDialogs.HomePageBatchProcessing.HomePageWatermark
+{
+    public class HomePageWatermarkTemplateListFileContentViewModel : BindableBase, INavigationAware
+    {
+        private readonly IEventAggregator eventAggregator;
+
+        private CPDFViewer CurrentPDFViewer;
+
+        public WatermarkInfo WatermarkInfo = new WatermarkInfo();
+
+        public WatermarkItem WatermarkItem = new WatermarkItem();
+
+        public int TemplateIndex = 0;
+        public ObservableCollection<WatermarkItem> watermarkModFileCollection = new ObservableCollection<WatermarkItem>();
+        public ObservableCollection<WatermarkItem> WatermarkModFileCollection
+        {
+            get { return watermarkModFileCollection; }
+            set
+            {
+                watermarkModFileCollection = value;
+                RaisePropertyChanged();
+            }
+        }
+
+        private Visibility _createTemplateVisible;
+        public Visibility CreateTemplateVisible
+        {
+            get { return _createTemplateVisible; }
+            set { SetProperty(ref _createTemplateVisible, value); }
+        }
+
+        private ImageSource _imageSource;
+        public ImageSource ImageSource
+        {
+
+            get { return _imageSource; }
+            set { SetProperty(ref _imageSource, value); }
+        }
+
+        public DelegateCommand AddTemplateCommand { get; set; }
+        public DelegateCommand<object> DeleteTemplateItemCommand { get; set; }
+        public DelegateCommand<object> EditTemplateItemCommand { get; set; }
+        public DelegateCommand DeleteAllTemplateItemCommand { get; set; }
+        public DelegateCommand<object> SelectTemplateItemCommand { get; set; }
+
+        public string Unicode = null;
+
+        public HomePageWatermarkTemplateListFileContentViewModel(IEventAggregator eventAggregator)
+        {
+            this.eventAggregator = eventAggregator;
+            Unicode = App.mainWindowViewModel.SelectedItem.Unicode;
+            AddTemplateCommand = new DelegateCommand(AddTemplate);
+            DeleteTemplateItemCommand = new DelegateCommand<object>(DeleteTemplateItem);
+            EditTemplateItemCommand = new DelegateCommand<object>(RequestEditTemplateItem);
+            DeleteAllTemplateItemCommand = new DelegateCommand(DeleteAllTemplateItem);
+            SelectTemplateItemCommand = new DelegateCommand<object>(SelectTemplateItem);
+
+            eventAggregator.GetEvent<CurrentWatermarkPDFViewerEvent>().Subscribe(CurrentWatermarkPDFViewer, e => e.Unicode == Unicode);
+            eventAggregator.GetEvent<SaveEditedWatermarkTemplateItemEvent>().Subscribe(SaveEditedWatermarkTemplateItem, e => e.Unicode == Unicode);
+
+        }
+        public void CurrentWatermarkPDFViewer(CPDFViewerUnicode cPDFViewerunicode)
+        {
+            CurrentPDFViewer = cPDFViewerunicode.Status;
+        }
+
+        private void CheckTemplateListIsEmpty(List<WatermarkItem> watermarkTemplateList)
+        {
+            if (watermarkTemplateList.Count() == 0)
+            {
+                CreateTemplateVisible = Visibility.Visible;
+            }
+            else
+            {
+                CreateTemplateVisible = Visibility.Collapsed;
+            }
+        }
+
+        private void GetWatermarkSource()
+        {
+            List<WatermarkItem> watermarkModTextTemplateList = new List<WatermarkItem>();
+            for (int temp = 0; temp < Settings.Default.WatermarkTemplateList.Count; temp++)
+            {
+                if (Settings.Default.WatermarkTemplateList[temp].type == ComPDFKit.PDFWatermark.C_Watermark_Type.WATERMARK_TYPE_IMG)
+                {
+                    watermarkModTextTemplateList.Add(Settings.Default.WatermarkTemplateList[temp]);
+
+                }
+            }
+            WatermarkModFileCollection = new ObservableCollection<WatermarkItem>(watermarkModTextTemplateList);
+            CheckTemplateListIsEmpty(watermarkModTextTemplateList);
+        }
+
+
+
+        private void InitWatermarkTemplateList()
+        {
+            if (Settings.Default.WatermarkTemplateList == null)
+            {
+                Settings.Default.WatermarkTemplateList = new WatermarkTemplateList();
+            }
+            GetWatermarkSource();
+        }
+
+
+        public void AddTemplate()
+        {
+            this.eventAggregator.GetEvent<EnterTemplateListOrCreateEvent>().Publish(new EnumTemplateListOrCreateUnicode
+            {
+                Unicode = Unicode,
+                Status = EnumTemplateListOrCreate.StatusCreate
+            });
+        }
+
+        public void DeleteTemplateItem(object e)
+        {
+            var btn = e as System.Windows.Controls.Control;
+            if (btn == null)
+            {
+                return;
+            }
+            var template = btn.DataContext as WatermarkItem;
+            if (template == null)
+            {
+                return;
+            }
+
+            Settings.Default.WatermarkTemplateList.Remove(template);
+            Settings.Default.Save();
+
+            WatermarkModFileCollection.Remove(template);
+            GetWatermarkSource();
+
+        }
+
+        public void DeleteAllTemplateItem()
+        {
+            while (Settings.Default.WatermarkTemplateList.Count != 0)
+            {
+                int temp = 0;
+                var template = Settings.Default.WatermarkTemplateList[temp];
+                if (template.type == ComPDFKit.PDFWatermark.C_Watermark_Type.WATERMARK_TYPE_IMG)
+                {
+                    Settings.Default.WatermarkTemplateList.Remove(template);
+                    Settings.Default.Save();
+                    WatermarkModFileCollection.Remove(template);
+                }
+            }
+            GetWatermarkSource();
+        }
+
+        public void SaveEditedWatermarkTemplateItem(WatermarkItemUnicode watermarkItemunicode)
+        {
+            WatermarkItem watermarkItem = watermarkItemunicode.Status;
+            Settings.Default.WatermarkTemplateList[TemplateIndex] = watermarkItem;
+            Settings.Default.Save();
+            GetWatermarkSource();
+        }
+
+
+        public void RequestEditTemplateItem(object e)
+        {
+            var control = e as Control;
+            if (control == null)
+            {
+                return;
+            }
+            var template = control.DataContext as WatermarkItem;
+            if (template == null)
+            {
+                return;
+            }
+            TemplateIndex = Settings.Default.WatermarkTemplateList.IndexOf(template);
+            template.listIndex = TemplateIndex;
+            this.eventAggregator.GetEvent<EditWatermarkTemplateItemEvent>().Publish(new WatermarkItemUnicode
+            {
+                Unicode = Unicode,
+                Status = template
+            });
+        }
+
+        public void SelectTemplateItem(object e)
+        {
+            AlertsMessage alertsMessage = new AlertsMessage();
+            //if (CurrentPDFViewer.Document.GetWatermarkCount() > 0)
+            //{
+            //    alertsMessage.ShowDialog("文件中已添加水印,您要替换现有的水印吗?", "", "取消", "确定");
+            //    if (alertsMessage.result == ContentResult.Ok)
+            //    {
+            //        this.eventAggregator.GetEvent<DeleteWatermarkEvent>().Publish(new EnumDeleteUnicode
+            //        {
+            //            Unicode = Unicode,
+            //            Status = EnumDelete.StatusDeleteInitial
+            //        });
+            //    }
+            //    else
+            //    {
+            //        this.eventAggregator.GetEvent<DeleteWatermarkEvent>().Publish(new EnumDeleteUnicode
+            //        {
+            //            Unicode = Unicode,
+            //            Status = EnumDelete.StatusCreate
+            //        });
+            //    }
+            //}
+            var listBox = e as ListBox;
+            WatermarkItem WatermarkItem = listBox.SelectedItem as WatermarkItem;
+            SendTemplateItemToDocument(WatermarkItem);
+        }
+
+        public void ConvertItemToInfo(WatermarkItem watermarkItem, ref WatermarkInfo watermarkInfo)
+        {
+            if (watermarkItem != null)
+            {
+                watermarkInfo.WatermarkType = watermarkItem.type;
+                FileInfo file = new FileInfo(watermarkItem.imagepath);
+                if (file.Exists)
+                {
+                    if (file.Extension == ".pdf")
+                    {
+                        GetBitmapFromDocment(watermarkItem.imagepath);
+                    }
+                    else
+                    {
+                        EditToolsHelper.ChooseFile(watermarkItem.imagepath, ref WatermarkInfo);
+                    }
+                }
+                else
+                {
+                    watermarkInfo.WatermarkType = ComPDFKit.PDFWatermark.C_Watermark_Type.WATERMARK_TYPE_UNKWON;
+                    MessageBoxEx.Show("原路径为:" + watermarkItem.imagepath + ",该文件不存在");
+                }
+                watermarkInfo.WatermarkHorizalign = watermarkItem.horizalign;
+                watermarkInfo.WatermarkVertalign = watermarkItem.vertalign;
+                watermarkInfo.IsRelativeScale = watermarkItem.isRelativeScale;
+                watermarkInfo.Isfull = watermarkItem.isFullScreen;
+                watermarkInfo.IsFront = watermarkItem.isfront;
+                watermarkInfo.ImageSize = watermarkItem.imageSize;
+                watermarkInfo.Opacity = watermarkItem.opacity;
+                watermarkInfo.Rotation = watermarkItem.rotation;
+                watermarkInfo.VertOffset = watermarkItem.vertOffset;
+                watermarkInfo.HorizOffset = watermarkItem.horizOffset;
+                watermarkInfo.VerticalSpacing = watermarkItem.verticalSpacing;
+                watermarkInfo.HorizontalSpacing = watermarkItem.horizontalSpacing;
+                //EditToolsHelper.GetPageRange(watermarkItem.pageRangeIndex, CurrentPDFViewer.Document, ref WatermarkInfo.PageRange, watermarkItem.pageRange);
+            }
+        }
+
+        public async void GetBitmapFromDocment(string filePath)
+        {
+            CPDFDocument document = CPDFDocument.InitWithFilePath(filePath);
+            CPDFPage page = document.PageAtIndex(0);
+            byte[] bmp_data = new byte[(int)page.PageSize.Width * (int)page.PageSize.Height * 4];
+            await Task.Run(delegate
+            {
+                page.RenderPageBitmap(0, 0, (int)page.PageSize.Width, (int)page.PageSize.Height, 0xffffffff, bmp_data, 1);
+            });
+            WatermarkInfo.ImageArray = bmp_data;
+            WatermarkInfo.ImageWidth = (int)page.PageSize.Width;
+            WatermarkInfo.ImageHeight = (int)page.PageSize.Height;
+            document.ReleasePages();
+            document.Release();
+        }
+
+        public void SendTemplateItemToDocument(WatermarkItem WatermarkItem)
+        {
+            ConvertItemToInfo(WatermarkItem, ref WatermarkInfo);
+            
+        }
+
+
+        public bool IsNavigationTarget(NavigationContext navigationContext)
+        {
+            return true;
+        }
+
+        public void OnNavigatedFrom(NavigationContext navigationContext)
+        {
+        }
+
+        public void OnNavigatedTo(NavigationContext navigationContext)
+        {
+            InitWatermarkTemplateList();
+        }
+    }
+}

+ 265 - 0
PDF Office/ViewModels/Dialog/HomePageToolsDialogs/HomePageBatchProcessing/HomePageWatermark/HomePageWatermarkTemplateListTextContentViewModel.cs

@@ -0,0 +1,265 @@
+using ComPDFKitViewer.PdfViewer;
+using PDF_Office.CustomControl;
+using PDF_Office.EventAggregators;
+using PDF_Office.Helper;
+using PDF_Office.Model.EditTools.Watermark;
+using PDF_Office.Properties;
+using PDFSettings;
+using Prism.Commands;
+using Prism.Events;
+using Prism.Mvvm;
+using Prism.Regions;
+using System;
+using System.Collections.Generic;
+using System.Collections.ObjectModel;
+using System.Linq;
+using System.Windows;
+using System.Windows.Controls;
+
+namespace PDF_Office.ViewModels.Dialog.HomePageToolsDialogs.HomePageBatchProcessing.HomePageWatermark
+{
+    public class HomePageWatermarkTemplateListTextContentViewModel : BindableBase, INavigationAware
+    {
+        private readonly IEventAggregator eventAggregator;
+
+        private CPDFViewer CurrentPDFViewer;
+
+        public WatermarkInfo WatermarkInfo = new WatermarkInfo();
+
+        public WatermarkItem WatermarkItem = new WatermarkItem();
+
+        public int TemplateIndex = 0;
+
+        public ObservableCollection<WatermarkItem> watermarkModTextCollection = new ObservableCollection<WatermarkItem>();
+        public ObservableCollection<WatermarkItem> WatermarkModTextCollection
+        {
+            get { return watermarkModTextCollection; }
+            set
+            {
+                watermarkModTextCollection = value;
+                RaisePropertyChanged();
+            }
+        }
+
+        private Visibility _createTemplateVisible;
+        public Visibility CreateTemplateVisible
+        {
+            get { return _createTemplateVisible; }
+            set { SetProperty(ref _createTemplateVisible, value); }
+        }
+
+        public DelegateCommand AddTemplateCommand { get; set; }
+        public DelegateCommand<object> DeleteTemplateItemCommand { get; set; }
+        public DelegateCommand<object> EditTemplateItemCommand { get; set; }
+        public DelegateCommand DeleteAllTemplateItemCommand { get; set; }
+        public DelegateCommand<object> SelectTemplateItemCommand { get; set; }
+
+        public string Unicode = null;
+
+
+        public HomePageWatermarkTemplateListTextContentViewModel(IEventAggregator eventAggregator)
+        {
+            this.eventAggregator = eventAggregator;
+            Unicode = App.mainWindowViewModel.SelectedItem.Unicode;
+            AddTemplateCommand = new DelegateCommand(AddTemplate);
+            DeleteTemplateItemCommand = new DelegateCommand<object>(DeleteTemplateItem);
+            DeleteAllTemplateItemCommand = new DelegateCommand(DeleteAllTemplateItem);
+            EditTemplateItemCommand = new DelegateCommand<object>(RequestEditTemplateItem);
+            SelectTemplateItemCommand = new DelegateCommand<object>(SelectTemplateItem);
+            eventAggregator.GetEvent<CurrentWatermarkPDFViewerEvent>().Subscribe(CurrentWatermarkPDFViewer, e => e.Unicode == Unicode);
+            eventAggregator.GetEvent<SaveEditedWatermarkTemplateItemEvent>().Subscribe(SaveEditedWatermarkTemplateItem, e => e.Unicode == Unicode);
+
+        }
+        public void CurrentWatermarkPDFViewer(CPDFViewerUnicode cPDFViewerunicode)
+        {
+            CurrentPDFViewer = cPDFViewerunicode.Status;
+        }
+
+        private void CheckTemplateListIsEmpty(List<WatermarkItem> watermarkTemplateList)
+        {
+            if (watermarkTemplateList.Count() == 0)
+            {
+                CreateTemplateVisible = Visibility.Visible;
+            }
+            else
+            {
+                CreateTemplateVisible = Visibility.Collapsed;
+            }
+        }
+
+        private void GetWatermarkSource()
+        {
+            List<WatermarkItem> watermarkModTextTemplateList = new List<WatermarkItem>();
+            for (int temp = 0; temp < Settings.Default.WatermarkTemplateList.Count; temp++)
+            {
+                if (Settings.Default.WatermarkTemplateList[temp].type == ComPDFKit.PDFWatermark.C_Watermark_Type.WATERMARK_TYPE_TEXT)
+                {
+
+
+                    watermarkModTextTemplateList.Add(Settings.Default.WatermarkTemplateList[temp]);
+                }
+            }
+            WatermarkModTextCollection = new ObservableCollection<WatermarkItem>(watermarkModTextTemplateList);
+            CheckTemplateListIsEmpty(watermarkModTextTemplateList);
+        }
+
+
+
+        private void InitWatermarkTemplateList()
+        {
+            if (Settings.Default.WatermarkTemplateList == null)
+            {
+                Settings.Default.WatermarkTemplateList = new WatermarkTemplateList();
+            }
+            GetWatermarkSource();
+        }
+
+        public void AddTemplate()
+        {
+            this.eventAggregator.GetEvent<EnterTemplateListOrCreateEvent>().Publish(new EnumTemplateListOrCreateUnicode
+            {
+                Unicode = Unicode,
+                Status = EnumTemplateListOrCreate.StatusCreate
+            });
+        }
+
+        public void DeleteTemplateItem(object e)
+        {
+            var btn = e as System.Windows.Controls.Control;
+            if (btn == null)
+            {
+                return;
+            }
+            var template = btn.DataContext as WatermarkItem;
+            if (template == null)
+            {
+                return;
+            }
+
+            Settings.Default.WatermarkTemplateList.Remove(template);
+            Settings.Default.Save();
+
+            WatermarkModTextCollection.Remove(template);
+            GetWatermarkSource();
+
+        }
+
+        public void DeleteAllTemplateItem()
+        {
+            while (Settings.Default.WatermarkTemplateList.Count != 0)
+            {
+                int temp = 0;
+                var template = Settings.Default.WatermarkTemplateList[temp];
+                if (template.type == ComPDFKit.PDFWatermark.C_Watermark_Type.WATERMARK_TYPE_IMG)
+                {
+                    Settings.Default.WatermarkTemplateList.Remove(template);
+                    Settings.Default.Save();
+                    WatermarkModTextCollection.Remove(template);
+                }
+            }
+            GetWatermarkSource();
+        }
+
+        public void RequestEditTemplateItem(object e)
+        {
+            var control = e as Control;
+            if (control == null)
+            {
+                return;
+            }
+            var template = control.DataContext as WatermarkItem;
+            if (template == null)
+            {
+                return;
+            }
+            TemplateIndex = Settings.Default.WatermarkTemplateList.IndexOf(template);
+            template.listIndex = TemplateIndex;
+            this.eventAggregator.GetEvent<EditWatermarkTemplateItemEvent>().Publish(new WatermarkItemUnicode
+            {
+                Unicode = Unicode,
+                Status = template
+            });
+        }
+
+        public void SelectTemplateItem(object e)
+        {
+            AlertsMessage alertsMessage = new AlertsMessage();
+            //if (CurrentPDFViewer.Document.GetWatermarkCount() > 0)
+            //{
+            //    alertsMessage.ShowDialog("文件中已添加水印,您要替换现有的水印吗?", "", "取消", "确定");
+            //    if (alertsMessage.result == ContentResult.Ok)
+            //    {
+            //        this.eventAggregator.GetEvent<DeleteWatermarkEvent>().Publish(new EnumDeleteUnicode
+            //        {
+            //            Unicode = Unicode,
+            //            Status = EnumDelete.StatusDeleteInitial
+            //        });
+            //    }
+            //    else
+            //    {
+            //        this.eventAggregator.GetEvent<DeleteWatermarkEvent>().Publish(new EnumDeleteUnicode
+            //        {
+            //            Unicode = Unicode,
+            //            Status = EnumDelete.StatusCreate
+            //        });
+            //    }
+            //}
+            var listBox = e as ListBox;
+            WatermarkItem WatermarkItem = listBox.SelectedItem as WatermarkItem;
+            SendTemplateItemToDocument(WatermarkItem);
+        }
+
+        public void SaveEditedWatermarkTemplateItem(WatermarkItemUnicode watermarkItemunicode)
+        {
+            WatermarkItem watermarkItem = watermarkItemunicode.Status;
+            Settings.Default.WatermarkTemplateList[TemplateIndex] = watermarkItem;
+            Settings.Default.Save();
+            GetWatermarkSource();
+        }
+
+        public void ConvertItemToInfo(WatermarkItem watermarkItem, ref WatermarkInfo watermarkInfo)
+        {
+            if (watermarkItem != null)
+            {
+                watermarkInfo.WatermarkType = watermarkItem.type;
+                watermarkInfo.Text = watermarkItem.text;
+                watermarkInfo.TextSize = watermarkItem.fontSize;
+                watermarkInfo.FontName = watermarkItem.fontName;
+                watermarkInfo.TextColor = watermarkItem.textcolor;
+                watermarkInfo.WatermarkHorizalign = watermarkItem.horizalign;
+                watermarkInfo.WatermarkVertalign = watermarkItem.vertalign;
+                watermarkInfo.IsRelativeScale = watermarkItem.isRelativeScale;
+                watermarkInfo.Isfull = watermarkItem.isFullScreen;
+                watermarkInfo.IsFront = watermarkItem.isfront;
+                watermarkInfo.Opacity = watermarkItem.opacity;
+                watermarkInfo.Rotation = watermarkItem.rotation;
+                watermarkInfo.VertOffset = watermarkItem.vertOffset;
+                watermarkInfo.HorizOffset = watermarkItem.horizOffset;
+                watermarkInfo.VerticalSpacing = watermarkItem.verticalSpacing;
+                watermarkInfo.HorizontalSpacing = watermarkItem.horizontalSpacing;
+                //EditToolsHelper.GetPageRange(watermarkItem.pageRangeIndex, CurrentPDFViewer.Document, ref WatermarkInfo.PageRange, watermarkItem.pageRange);
+            }
+
+        }
+
+        public void SendTemplateItemToDocument(WatermarkItem WatermarkItem)
+        {
+            ConvertItemToInfo(WatermarkItem, ref WatermarkInfo);
+            
+        }
+
+        public bool IsNavigationTarget(NavigationContext navigationContext)
+        {
+            return true;
+        }
+
+        public void OnNavigatedFrom(NavigationContext navigationContext)
+        {
+        }
+
+        public void OnNavigatedTo(NavigationContext navigationContext)
+        {
+            InitWatermarkTemplateList();
+        }
+    }
+}

+ 65 - 0
PDF Office/Views/Dialog/HomePageToolsDialogs/HomePageBatchProcessing/HomePageBackground/HomePageBackgroundCreateBaseContent.xaml

@@ -0,0 +1,65 @@
+<UserControl x:Class="PDF_Office.Views.Dialog.HomePageToolsDialogs.HomePageBatchProcessing.HomePageBackground.HomePageBackgroundCreateBaseContent"
+             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"
+              xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
+             xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006" xmlns:background="clr-namespace:PDF_Office.ViewModels.EditTools.Background" d:DataContext="{d:DesignInstance Type=background:BackgroundCreateBaseContentViewModel}"
+             mc:Ignorable="d"
+             d:DesignHeight="720"
+             d:DesignWidth="260" >
+    <Grid>
+        <Grid.RowDefinitions>
+            <RowDefinition Height="40"></RowDefinition>
+            <RowDefinition Height="48"></RowDefinition>
+            <RowDefinition></RowDefinition>
+        </Grid.RowDefinitions>
+        <Grid Grid.Row="0" Visibility="{Binding CreateBaseVisible, Mode=TwoWay}">
+            <Button  Height="24" Width="90" HorizontalAlignment="Left" Margin="16,0,0,0"  Command="{Binding EnterTemplateListCommand}">
+                <StackPanel Orientation="Horizontal">
+                    <TextBlock Text="&lt;" Margin="0,0,9,0" FontSize="16"></TextBlock>
+                    <TextBlock Text="创建背景" FontSize="16"></TextBlock>
+                </StackPanel>
+            </Button>
+            <Button  Height="20" Width="64" Margin="0,0,16,0" HorizontalAlignment="Right" Command="{Binding SaveToTemplateListCommand}">
+                <StackPanel>
+                    <TextBlock Text="保存至模板"  Foreground="#18A0FB"></TextBlock>
+                    <Rectangle Height="1" Fill="#18A0FB"></Rectangle>
+                </StackPanel>
+            </Button>
+        </Grid>
+        <Grid Grid.Row="0" Visibility="{Binding EditBaseVisible, Mode=TwoWay}">
+            <Button  Height="24" Width="90" HorizontalAlignment="Left" Margin="16,0,0,0"  Command="{Binding EnterTemplateListCommand}">
+                <StackPanel Orientation="Horizontal">
+                    <TextBlock Text="&lt;" Margin="0,0,9,0" FontSize="16"></TextBlock>
+                    <TextBlock Text="编辑模板" FontSize="16"></TextBlock>
+                </StackPanel>
+            </Button>
+            <Button  Height="20" Width="64" Margin="0,0,16,0" HorizontalAlignment="Right" Command="{Binding SaveToCurrentTemplateListCommand}">
+                <StackPanel>
+                    <TextBlock Text="保存"  Foreground="#18A0FB"></TextBlock>
+                    <Rectangle Height="1" Fill="#18A0FB"></Rectangle>
+                </StackPanel>
+            </Button>
+        </Grid>
+        <Grid Grid.Row="1" Margin="16,0,16,0">
+            <Grid.ColumnDefinitions>
+                <ColumnDefinition></ColumnDefinition>
+                <ColumnDefinition></ColumnDefinition>
+            </Grid.ColumnDefinitions>
+            <Button Name="HomePageBackgroundCreateColorContent" Grid.Column="0" Command="{Binding ChangeCreateModCommand}" CommandParameter="{Binding ElementName=HomePageBackgroundCreateColorContent}">
+                <StackPanel Orientation="Vertical"  >
+                    <TextBlock Text="颜色" FontSize="18"></TextBlock>
+                </StackPanel>
+            </Button>
+            <Button Name="HomePageBackgroundCreateFileContent" Grid.Column="1" Command="{Binding ChangeCreateModCommand}" CommandParameter="{Binding ElementName=HomePageBackgroundCreateFileContent}">
+                <StackPanel Orientation="Vertical"  >
+                    <TextBlock Text="文件" FontSize="18" VerticalAlignment="Center"></TextBlock>
+                </StackPanel>
+            </Button>
+        </Grid>
+        <Grid Grid.Row="2">
+            <ContentControl prism:RegionManager.RegionName="{Binding BackgroundCreateRegionName}" Visibility="{Binding BackgroundCreateVisible}"></ContentControl>
+        </Grid>
+    </Grid>
+</UserControl>

+ 15 - 0
PDF Office/Views/Dialog/HomePageToolsDialogs/HomePageBatchProcessing/HomePageBackground/HomePageBackgroundCreateBaseContent.xaml.cs

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

+ 137 - 0
PDF Office/Views/Dialog/HomePageToolsDialogs/HomePageBatchProcessing/HomePageBackground/HomePageBackgroundCreateColorContent.xaml

@@ -0,0 +1,137 @@
+<UserControl x:Class="PDF_Office.Views.Dialog.HomePageToolsDialogs.HomePageBatchProcessing.HomePageBackground.HomePageBackgroundCreateColorContent"
+             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"
+               xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
+             xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006" xmlns:cus="clr-namespace:PDF_Office.CustomControl" xmlns:background="clr-namespace:PDF_Office.ViewModels.EditTools.Background" xmlns:CompositeControl="clr-namespace:PDF_Office.CustomControl.CompositeControl" d:DataContext="{d:DesignInstance Type=background:BackgroundCreateColorContentViewModel}"
+             mc:Ignorable="d"
+             d:DesignHeight="632"
+             d:DesignWidth="260">
+    <UserControl.Resources>
+        <ResourceDictionary>
+            <ResourceDictionary.MergedDictionaries>
+                <ResourceDictionary Source="../../../../../Styles/CheckBoxStyle.xaml"/>
+            </ResourceDictionary.MergedDictionaries>
+        </ResourceDictionary>
+    </UserControl.Resources>
+    <Grid Margin="16,0,0,0">
+        <Grid.RowDefinitions>
+            <RowDefinition Height="76"></RowDefinition>
+            <RowDefinition Height="156"></RowDefinition>
+            <RowDefinition Height="118"></RowDefinition>
+            <RowDefinition Height="76"></RowDefinition>
+            <RowDefinition></RowDefinition>
+        </Grid.RowDefinitions>
+        <Grid Grid.Row="0" >
+            <StackPanel Orientation="Vertical">
+                <TextBlock Text="背景颜色" Height="20" Width="48" HorizontalAlignment="Left" Margin="0,16,16,8" Foreground="#666666"></TextBlock>
+                <!--<StackPanel Orientation="Horizontal">
+                    <Button Name="RedColorBtn" Height="32" Width="32" Margin="0,0,8,0" Command="{Binding ChangeColorCommand}" CommandParameter="{Binding ElementName=RedColorBtn}">
+                        <Rectangle Height="22" Width="22" Fill="Red" RadiusX="20" RadiusY="20"></Rectangle>
+                    </Button>
+                    <Button Name="GreenColorBtn" Height="32" Width="32" Margin="0,0,8,0"  Command="{Binding ChangeColorCommand}" CommandParameter="{Binding ElementName=GreenColorBtn}">
+                        <Rectangle Height="22" Width="22" Fill="#008000" RadiusX="20" RadiusY="20"></Rectangle>
+
+                    </Button>
+                    <Button Height="32" Width="32" Margin="0,0,8,0"></Button>
+                    <Button Height="32" Width="32" Margin="0,0,8,0"></Button>
+                    <Button Height="32" Width="66">
+                        <Grid Height="32" Width="66" HorizontalAlignment="Center" VerticalAlignment="Center">
+                            <Grid.ColumnDefinitions>
+                                <ColumnDefinition></ColumnDefinition>
+                                <ColumnDefinition></ColumnDefinition>
+                            </Grid.ColumnDefinitions>
+                            <Grid Grid.Column="0" Height="22" Width="22">
+                                <Rectangle Fill="{Binding StringColor, Mode=TwoWay}" RadiusX="20" RadiusY="20"></Rectangle>
+                            </Grid>
+                        </Grid>
+                    </Button>
+                </StackPanel>-->
+                <CompositeControl:ColorContent Grid.Row="1" Margin="0,-2,0,0"  x:Name="cusColor"/>
+            </StackPanel>
+        </Grid>
+        <Grid Grid.Row="1">
+            <StackPanel Orientation="Vertical">
+                <TextBlock Text="外观" Margin="0,16,0,8" Foreground="#666666"></TextBlock>
+                <StackPanel Orientation="Horizontal">
+                    <TextBlock Height="24" Width="24" Background= "Bisque" Margin="0,0,8,0"></TextBlock>
+                    <cus:CommonWritableComboBox HorizontalAlignment="Left" Width="66" Height="32" Margin="0,0,28,0"   Minimum="-360" Maximum="360"  TypeSouce="{Binding RotationList,Mode=TwoWay}" Value="{Binding RotationValue, Mode=TwoWay}" Text="{Binding RotationText,Mode=TwoWay}" ></cus:CommonWritableComboBox>
+
+                    <TextBlock Height="24" Width="24" Background="CadetBlue" Margin="0,0,8,0"></TextBlock>
+                    <cus:CommonWritableComboBox HorizontalAlignment="Left" Width="66" Height="32" TypeSouce="{Binding OpacityList,Mode=TwoWay}" Value="{Binding OpacityValue,Mode=TwoWay}" Text="{Binding OpacityText,Mode=TwoWay}" Loaded="CommonWritableComboBox_Loaded"></cus:CommonWritableComboBox>
+                </StackPanel>
+                <StackPanel Orientation="Horizontal"></StackPanel>
+                <Grid Margin="0,19,0,0">
+
+                    <CheckBox Name="RelativeScaleCheckBox"  Grid.Column="0" Style="{StaticResource EditToolsCheckBoxStyle}" Content="相对目标页面的比例" Margin="0,0,0,0" Height="22"  IsChecked="{Binding IsRelativeScaleValue}"></CheckBox>
+                </Grid>
+                <cus:CommonWritableComboBox HorizontalAlignment="Left" Width="66" Height="32" Margin="0,11,0,0" TypeSouce="{Binding RelativeRatioList,Mode=TwoWay}" Value="{Binding RelativeRatioValue,Mode=TwoWay}" Text="{Binding RelativeScaleText,Mode=TwoWay}"  IsEnabled="{Binding ElementName=RelativeScaleCheckBox,Path=IsChecked}" ></cus:CommonWritableComboBox>
+
+
+            </StackPanel>
+
+        </Grid>
+        <Grid  Grid.Row="2" Margin="0,16,0,0">
+            <StackPanel>
+                <TextBlock Text="位置" FontSize="12" Foreground="#666666" Height="20" Width="24" HorizontalAlignment="Left"></TextBlock>
+                <StackPanel Orientation="Horizontal" Margin="0,8,0,0">
+                    <Grid Width="74" Height="74">
+                        <Grid.ColumnDefinitions>
+                            <ColumnDefinition></ColumnDefinition>
+                            <ColumnDefinition></ColumnDefinition>
+                            <ColumnDefinition></ColumnDefinition>
+                        </Grid.ColumnDefinitions>
+                        <Grid.RowDefinitions>
+                            <RowDefinition></RowDefinition>
+                            <RowDefinition></RowDefinition>
+                            <RowDefinition></RowDefinition>
+                        </Grid.RowDefinitions>
+                        <Button Grid.Column="0" Grid.Row="0" Tag="0" Command="{Binding ChangeLocationCommand}" CommandParameter="{Binding RelativeSource={RelativeSource Self}, Path=Tag}" IsEnabled="{Binding GetLocationFromNumber[0],Mode=TwoWay}"></Button>
+                        <Button Grid.Column="1" Grid.Row="0" Tag="1" Command="{Binding ChangeLocationCommand}" CommandParameter="{Binding RelativeSource={RelativeSource Self}, Path=Tag}"  IsEnabled="{Binding GetLocationFromNumber[1], Mode=TwoWay}"></Button>
+                        <Button Grid.Column="2" Grid.Row="0" Tag="2" Command="{Binding ChangeLocationCommand}" CommandParameter="{Binding RelativeSource={RelativeSource Self}, Path=Tag}"  IsEnabled="{Binding GetLocationFromNumber[2], Mode=TwoWay}"></Button>
+                        <Button Grid.Column="0" Grid.Row="1" Tag="10" Command="{Binding ChangeLocationCommand}"  CommandParameter="{Binding RelativeSource={RelativeSource Self}, Path=Tag}"  IsEnabled="{Binding GetLocationFromNumber[10], Mode=TwoWay}"></Button>
+                        <Button Grid.Column="1" Grid.Row="1" Tag="11" Command="{Binding ChangeLocationCommand}"  CommandParameter="{Binding RelativeSource={RelativeSource Self}, Path=Tag}"  IsEnabled="{Binding GetLocationFromNumber[11], Mode=TwoWay}"></Button>
+                        <Button Grid.Column="2" Grid.Row="1" Tag="12" Command="{Binding ChangeLocationCommand}"  CommandParameter="{Binding RelativeSource={RelativeSource Self}, Path=Tag}"  IsEnabled="{Binding GetLocationFromNumber[12], Mode=TwoWay}"></Button>
+                        <Button Grid.Column="0" Grid.Row="2" Tag="20" Command="{Binding ChangeLocationCommand}"  CommandParameter="{Binding RelativeSource={RelativeSource Self}, Path=Tag}"  IsEnabled="{Binding GetLocationFromNumber[20], Mode=TwoWay}"></Button>
+                        <Button Grid.Column="1" Grid.Row="2" Tag="21" Command="{Binding ChangeLocationCommand}"  CommandParameter="{Binding RelativeSource={RelativeSource Self}, Path=Tag}"  IsEnabled="{Binding GetLocationFromNumber[21], Mode=TwoWay}"></Button>
+                        <Button Grid.Column="2" Grid.Row="2" Tag="22" Command="{Binding ChangeLocationCommand}"  CommandParameter="{Binding RelativeSource={RelativeSource Self}, Path=Tag}"  IsEnabled="{Binding GetLocationFromNumber[22], Mode=TwoWay}"></Button>
+                    </Grid>
+                    <StackPanel Orientation="Vertical" Margin="70,0,0,0">
+                        <StackPanel Orientation="Horizontal">
+                            <TextBlock Text="X"  Width="9" Height="20" VerticalAlignment="Center"/>
+                            <cus:NumericUpDown  Width="66" Height="32" Margin="9,0,0,0"  Text="{Binding HorizontalOffsetValue, Mode=TwoWay}" ></cus:NumericUpDown>
+
+                        </StackPanel>
+                        <StackPanel Orientation="Horizontal" Margin="0,8,0,0">
+                            <TextBlock Text="Y" Width="9" Height="20" VerticalAlignment="Center"/>
+                            <cus:NumericUpDown Width="66" Height="32" Margin="9,0,0,0"  Text="{Binding VerticalOffsetValue, Mode=TwoWay}"></cus:NumericUpDown>
+                        </StackPanel>
+                    </StackPanel>
+
+                </StackPanel>
+                <CheckBox Margin="0,24,0,0" >
+                    <TextBlock Text="平铺" Width="144" Height="22" FontSize="14"/>
+                </CheckBox>
+                <StackPanel Orientation="Horizontal" Margin="0,8,0,0">
+                    <StackPanel Orientation="Horizontal">
+                        <TextBlock Text="X"  Width="9" Height="20" VerticalAlignment="Center"/>
+                        <TextBox Width="66" Height="32" Margin="9,0,0,0"></TextBox>
+                    </StackPanel>
+                    <StackPanel Orientation="Horizontal" >
+                        <TextBlock Text="Y" Width="9" Height="20" VerticalAlignment="Center"/>
+                        <TextBox Width="66" Height="32" Margin="9,0,0,0"></TextBox>
+                    </StackPanel>
+                </StackPanel>
+            </StackPanel>
+        </Grid>
+        <Grid Grid.Row="3" Margin="0,16,0,0">
+            <StackPanel Orientation="Vertical">
+                <TextBlock Text="页面范围" FontSize="12" Foreground="#666666" Height="20" Width="48" HorizontalAlignment="Left"></TextBlock>
+                <cus:WritableComboBox  Height="32" Width="228" Margin="0,8,0,0" HorizontalAlignment="Left" Text="{Binding PageRangeText,Mode=TwoWay}" SelectedIndex="{Binding PageRangeSelectIndex,Mode=TwoWay}"></cus:WritableComboBox>
+            </StackPanel>
+        </Grid>
+        <Grid Grid.Row="4">
+        </Grid>
+    </Grid>
+</UserControl>

+ 32 - 0
PDF Office/Views/Dialog/HomePageToolsDialogs/HomePageBatchProcessing/HomePageBackground/HomePageBackgroundCreateColorContent.xaml.cs

@@ -0,0 +1,32 @@
+using PDF_Office.ViewModels.Dialog.HomePageToolsDialogs.HomePageBatchProcessing.HomePageBackground;
+using PDF_Office.ViewModels.EditTools.Background;
+using System.Windows.Controls;
+using System.Windows.Media;
+
+namespace PDF_Office.Views.Dialog.HomePageToolsDialogs.HomePageBatchProcessing.HomePageBackground
+{
+    /// <summary>
+    /// Interaction logic for HomePageBackgroundCreateColorContent
+    /// </summary>
+    public partial class HomePageBackgroundCreateColorContent : UserControl
+    {
+        public HomePageBackgroundCreateColorContent()
+        {
+            InitializeComponent();
+            cusColor.SelectedColorHandler += cusColor_SelectedColor;
+        }
+        private void cusColor_SelectedColor(object sender, Color e)
+        {
+            var data = this.DataContext as HomePageBackgroundCreateColorContentViewModel;
+            if (data != null)
+            {
+                data.ChangeColorCommand?.Execute(e);
+            }
+        }
+
+        private void CommonWritableComboBox_Loaded(object sender, System.Windows.RoutedEventArgs e)
+        {
+
+        }
+    }
+}

+ 107 - 0
PDF Office/Views/Dialog/HomePageToolsDialogs/HomePageBatchProcessing/HomePageBackground/HomePageBackgroundCreateFileContent.xaml

@@ -0,0 +1,107 @@
+<UserControl x:Class="PDF_Office.Views.Dialog.HomePageToolsDialogs.HomePageBatchProcessing.HomePageBackground.HomePageBackgroundCreateFileContent"
+             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"
+              xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
+             xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006" xmlns:cus="clr-namespace:PDF_Office.CustomControl" xmlns:background="clr-namespace:PDF_Office.ViewModels.EditTools.Background" d:DataContext="{d:DesignInstance Type=background:BackgroundCreateFileContentViewModel}"
+             mc:Ignorable="d"
+             d:DesignHeight="632"
+             d:DesignWidth="260">
+    <UserControl.Resources>
+        <ResourceDictionary>
+            <ResourceDictionary.MergedDictionaries>
+                <ResourceDictionary Source="../../../../../Styles/CheckBoxStyle.xaml"/>
+            </ResourceDictionary.MergedDictionaries>
+        </ResourceDictionary>
+    </UserControl.Resources>
+    <Grid Margin="16,0,0,0">
+        <Grid.ColumnDefinitions>
+            <ColumnDefinition Width="58*"/>
+            <ColumnDefinition Width="3*"/>
+        </Grid.ColumnDefinitions>
+        <Grid.RowDefinitions>
+            <RowDefinition Height="48"></RowDefinition>
+            <RowDefinition Height="423"></RowDefinition>
+            <RowDefinition></RowDefinition>
+        </Grid.RowDefinitions>
+        <Grid Grid.Row="0" Grid.ColumnSpan="2">
+            <StackPanel Orientation="Horizontal" VerticalAlignment="Bottom">
+                <TextBox Height="32" Width="189" Margin="0,0,7,0" IsReadOnly="True"  Text="{Binding FileNameText}" FontSize="14" VerticalAlignment="Center"></TextBox>
+                <Button Height="32" Width="32" Command="{Binding OpenFileCommand}"></Button>
+            </StackPanel>
+        </Grid>
+        <Grid Grid.Row="1" Visibility="{Binding CreateModFileVisible}" Grid.ColumnSpan="2">
+            <Grid.RowDefinitions>
+                <RowDefinition Height="157"></RowDefinition>
+                <RowDefinition Height="163"></RowDefinition>
+                <RowDefinition Height="103"></RowDefinition>
+                <RowDefinition></RowDefinition>
+            </Grid.RowDefinitions>
+            <Grid Grid.Row="0">
+                <StackPanel Orientation="Vertical">
+                    <TextBlock Text="外观" Margin="0,16,0,8" Foreground="#666666"></TextBlock>
+                    <StackPanel Orientation="Horizontal">
+                        <TextBlock Height="24" Width="24" Background= "Bisque" Margin="0,0,8,0"></TextBlock>
+                        <cus:CommonWritableComboBox HorizontalAlignment="Left" Width="66" Height="32" Margin="0,0,28,0" TypeSouce="{Binding RotationList, Mode=TwoWay}" Text="{Binding RotationText,Mode=TwoWay}" Value="{Binding RotationValue,Mode=TwoWay}"></cus:CommonWritableComboBox>
+                        <TextBlock Height="24" Width="24" Background="CadetBlue" Margin="0,0,8,0"></TextBlock>
+                        <cus:CommonWritableComboBox HorizontalAlignment="Left" Width="66" Height="32" Margin="0,0,28,0" TypeSouce="{Binding OpacityList, Mode=TwoWay}" Text="{Binding OpacityText,Mode=TwoWay}"  Value="{Binding OpacityValue,Mode=TwoWay}"></cus:CommonWritableComboBox>
+                    </StackPanel>
+                    <StackPanel Orientation="Horizontal"></StackPanel>
+                    <Grid Margin="0,19,0,0">
+                        <CheckBox Name="RelativeScaleCheckBox"  Grid.Column="0" Style="{StaticResource EditToolsCheckBoxStyle}" Content="相对目标页面的比例" Margin="0,0,0,0" Height="22"  IsChecked="{Binding IsRelativeScaleValue}"></CheckBox>
+                    </Grid>
+                    <cus:CommonWritableComboBox HorizontalAlignment="Left" Width="66" Height="32" Margin="0,11,28,0" TypeSouce="{Binding RelativeRatioList, Mode=TwoWay}" Value="{Binding RelativeRatioValue,Mode=TwoWay}"   Text="{Binding RelativeScaleText,Mode=TwoWay}"  IsEnabled="{Binding ElementName=RelativeScaleCheckBox,Path=IsChecked}"></cus:CommonWritableComboBox>
+                </StackPanel>
+            </Grid>
+            <Grid  Grid.Row="1" Margin="0,16,0,0" VerticalAlignment="Bottom">
+                <Grid.ColumnDefinitions>
+                    <ColumnDefinition Width="3*"/>
+                    <ColumnDefinition Width="241*"/>
+                </Grid.ColumnDefinitions>
+                <StackPanel Grid.ColumnSpan="2">
+                    <TextBlock Text="位置" FontSize="12" Foreground="#666666" Height="20" Width="24" HorizontalAlignment="Left"></TextBlock>
+                    <StackPanel Orientation="Horizontal" Margin="0,8,0,0">
+                        <Grid Width="74" Height="74">
+                            <Grid.ColumnDefinitions>
+                                <ColumnDefinition></ColumnDefinition>
+                                <ColumnDefinition></ColumnDefinition>
+                                <ColumnDefinition></ColumnDefinition>
+                            </Grid.ColumnDefinitions>
+                            <Grid.RowDefinitions>
+                                <RowDefinition></RowDefinition>
+                                <RowDefinition></RowDefinition>
+                                <RowDefinition></RowDefinition>
+                            </Grid.RowDefinitions>
+                            <Button Grid.Column="0" Grid.Row="0" Tag="0" Command="{Binding ChangeLocationCommand}" CommandParameter="{Binding RelativeSource={RelativeSource Self}, Path=Tag}" IsEnabled="{Binding GetLocationFromNumber[0],Mode=TwoWay}"></Button>
+                            <Button Grid.Column="1" Grid.Row="0" Tag="1" Command="{Binding ChangeLocationCommand}" CommandParameter="{Binding RelativeSource={RelativeSource Self}, Path=Tag}"  IsEnabled="{Binding GetLocationFromNumber[1], Mode=TwoWay}"></Button>
+                            <Button Grid.Column="2" Grid.Row="0" Tag="2" Command="{Binding ChangeLocationCommand}" CommandParameter="{Binding RelativeSource={RelativeSource Self}, Path=Tag}"  IsEnabled="{Binding GetLocationFromNumber[2], Mode=TwoWay}"></Button>
+                            <Button Grid.Column="0" Grid.Row="1" Tag="10" Command="{Binding ChangeLocationCommand}"  CommandParameter="{Binding RelativeSource={RelativeSource Self}, Path=Tag}"  IsEnabled="{Binding GetLocationFromNumber[10], Mode=TwoWay}"></Button>
+                            <Button Grid.Column="1" Grid.Row="1" Tag="11" Command="{Binding ChangeLocationCommand}"  CommandParameter="{Binding RelativeSource={RelativeSource Self}, Path=Tag}"  IsEnabled="{Binding GetLocationFromNumber[11], Mode=TwoWay}"></Button>
+                            <Button Grid.Column="2" Grid.Row="1" Tag="12" Command="{Binding ChangeLocationCommand}"  CommandParameter="{Binding RelativeSource={RelativeSource Self}, Path=Tag}"  IsEnabled="{Binding GetLocationFromNumber[12], Mode=TwoWay}"></Button>
+                            <Button Grid.Column="0" Grid.Row="2" Tag="20" Command="{Binding ChangeLocationCommand}"  CommandParameter="{Binding RelativeSource={RelativeSource Self}, Path=Tag}"  IsEnabled="{Binding GetLocationFromNumber[20], Mode=TwoWay}"></Button>
+                            <Button Grid.Column="1" Grid.Row="2" Tag="21" Command="{Binding ChangeLocationCommand}"  CommandParameter="{Binding RelativeSource={RelativeSource Self}, Path=Tag}"  IsEnabled="{Binding GetLocationFromNumber[21], Mode=TwoWay}"></Button>
+                            <Button Grid.Column="2" Grid.Row="2" Tag="22" Command="{Binding ChangeLocationCommand}"  CommandParameter="{Binding RelativeSource={RelativeSource Self}, Path=Tag}"  IsEnabled="{Binding GetLocationFromNumber[22], Mode=TwoWay}"></Button>
+                        </Grid>
+                        <StackPanel Orientation="Vertical" Margin="70,0,0,0">
+                            <StackPanel Orientation="Horizontal">
+                                <TextBlock Text="X"  Width="9" Height="20" VerticalAlignment="Center"/>
+                                <cus:NumericUpDown Width="66" Height="32" Margin="9,0,0,0"  Text="{Binding HorizontalOffsetValue, Mode=TwoWay}"></cus:NumericUpDown>
+                            </StackPanel>
+                            <StackPanel Orientation="Horizontal" Margin="0,8,0,0">
+                                <TextBlock Text="Y" Width="9" Height="20" VerticalAlignment="Center"/>
+                                <cus:NumericUpDown Width="66" Height="32" Margin="9,0,0,0"  Text="{Binding VerticalOffsetValue, Mode=TwoWay}"></cus:NumericUpDown>
+                            </StackPanel>
+                        </StackPanel>
+                    </StackPanel>
+                </StackPanel>
+            </Grid>
+            <Grid Grid.Row="2" Margin="0,16,0,0" VerticalAlignment="Bottom">
+                <StackPanel Orientation="Vertical">
+                    <TextBlock Text="页面范围" FontSize="12" Foreground="#666666" Height="20" Width="48" HorizontalAlignment="Left"></TextBlock>
+                    <cus:WritableComboBox  Height="32" Width="228" Margin="0,8,0,0" HorizontalAlignment="Left" Text="{Binding PageRangeText,Mode=TwoWay}" SelectedIndex="{Binding PageRangeSelectIndex,Mode=TwoWay}"></cus:WritableComboBox>
+                </StackPanel>
+            </Grid>
+        </Grid>
+    </Grid>
+</UserControl>

+ 15 - 0
PDF Office/Views/Dialog/HomePageToolsDialogs/HomePageBatchProcessing/HomePageBackground/HomePageBackgroundCreateFileContent.xaml.cs

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

+ 6 - 5
PDF Office/Views/Dialog/HomePageToolsDialogs/HomePageBatchProcessing/HomePageBackground/HomePageBackgroundDialog.xaml

@@ -16,7 +16,7 @@
         </ResourceDictionary>
     </UserControl.Resources>
 
-    <Grid IsEnabled="{Binding ConverterGridIsEnabled}">
+    <Grid IsEnabled="{Binding BackgroundGridIsEnabled}">
         <Grid.ColumnDefinitions>
             <ColumnDefinition Width="558*"/>
             <ColumnDefinition Width="260*"/>
@@ -121,14 +121,15 @@
                 </Button>
             </Grid>
         </Grid>
-        <Grid Grid.Column="1" Background="WhiteSmoke" IsEnabled="{Binding SetConverterGridIsEnabled}">
+        <Grid Grid.Column="1" Background="WhiteSmoke" IsEnabled="{Binding SetBackgroundGridIsEnabled}">
             <Grid.RowDefinitions>
                 <RowDefinition Height="*"/>
                 <RowDefinition Height="72"/>
             </Grid.RowDefinitions>
-            <StackPanel Orientation="Vertical" Margin="15,16,0,0" Grid.Row="0">
-            </StackPanel>
-            <Grid Grid.Row="2">
+            <Grid Grid.Row="0" Background="#F3F3F3">
+                <ContentControl prism:RegionManager.RegionName="{Binding BackgroundSettingsRegionName}" Visibility="{Binding BackgroundSettingsVisible}"></ContentControl>
+            </Grid>
+            <Grid Grid.Row="1">
                 <Button Height="40" Width="228" Background="Black" Command="{Binding CreateCommand}">
                     <TextBlock Text="Apply" FontSize="18" Foreground="White"/>
                 </Button>

+ 45 - 0
PDF Office/Views/Dialog/HomePageToolsDialogs/HomePageBatchProcessing/HomePageBackground/HomePageBackgroundTemplateListBaseContent.xaml

@@ -0,0 +1,45 @@
+<UserControl x:Class="PDF_Office.Views.Dialog.HomePageToolsDialogs.HomePageBatchProcessing.HomePageBackground.HomePageBackgroundTemplateListBaseContent"
+             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"
+              xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
+             xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006" xmlns:background="clr-namespace:PDF_Office.ViewModels.EditTools.Background" d:DataContext="{d:DesignInstance Type=background:BackgroundTemplateListBaseContentViewModel}"
+             mc:Ignorable="d"
+             d:DesignHeight="720"
+             d:DesignWidth="260" >
+    <Grid>
+        <Grid.RowDefinitions>
+            <RowDefinition Height="40"></RowDefinition>
+            <RowDefinition Height="48"></RowDefinition>
+            <RowDefinition></RowDefinition>
+        </Grid.RowDefinitions>
+        <Grid Grid.Row="0">
+            <TextBlock Width="32" Height="24" Text="背景" FontSize="16" Margin="16,0,16,0" HorizontalAlignment="Left"></TextBlock>
+            <StackPanel Orientation="Horizontal" HorizontalAlignment="Right">
+                <Button  Height="20" Width="20"></Button>
+                <Button  Height="20" Width="20" Margin="16,0,16,0" Command="{Binding EnterCreateCommand}"></Button>
+            </StackPanel>
+        </Grid>
+        <Grid Grid.Row="1" Margin="16,0,16,0">
+            <Grid.ColumnDefinitions>
+                <ColumnDefinition></ColumnDefinition>
+                <ColumnDefinition></ColumnDefinition>
+            </Grid.ColumnDefinitions>
+            <Button x:Name="HomePageBackgroundTemplateListColorContent" Grid.Column="0"  Command="{Binding ChangeTemplateListModCommand}" CommandParameter="{Binding ElementName=HomePageBackgroundTemplateListColorContent}">
+                <StackPanel Orientation="Vertical"  >
+                    <TextBlock Text="颜色" FontSize="18"></TextBlock>
+                </StackPanel>
+
+            </Button>
+            <Button Grid.Column="1"  x:Name="HomePageBackgroundTemplateListFileContent"  Command="{Binding ChangeTemplateListModCommand}" CommandParameter="{Binding ElementName=HomePageBackgroundTemplateListFileContent}">
+                <StackPanel Orientation="Vertical"  >
+                    <TextBlock Text="文件" FontSize="18" VerticalAlignment="Center"></TextBlock>
+                </StackPanel>
+            </Button>
+        </Grid>
+        <Grid Grid.Row="2">
+            <ContentControl prism:RegionManager.RegionName="{Binding BackgroundTemplateListRegionName}" Visibility="{Binding BackgroundTemplateListVisible}"></ContentControl>
+        </Grid>
+    </Grid>
+</UserControl>

+ 15 - 0
PDF Office/Views/Dialog/HomePageToolsDialogs/HomePageBatchProcessing/HomePageBackground/HomePageBackgroundTemplateListBaseContent.xaml.cs

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

+ 89 - 0
PDF Office/Views/Dialog/HomePageToolsDialogs/HomePageBatchProcessing/HomePageBackground/HomePageBackgroundTemplateListColorContent.xaml

@@ -0,0 +1,89 @@
+<UserControl x:Class="PDF_Office.Views.Dialog.HomePageToolsDialogs.HomePageBatchProcessing.HomePageBackground.HomePageBackgroundTemplateListColorContent"
+             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"
+             xmlns:data ="clr-namespace:PDFSettings;assembly=PDFSettings"
+               xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
+             xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006" xmlns:watermark="clr-namespace:PDF_Office.ViewModels.EditTools.Watermark" xmlns:background="clr-namespace:PDF_Office.ViewModels.EditTools.Background" d:DataContext="{d:DesignInstance Type=background:BackgroundTemplateListColorContentViewModel}"
+             mc:Ignorable="d"
+             d:DesignHeight="632"
+             d:DesignWidth="260">
+    <UserControl.Resources>
+        <ContextMenu x:Key="FlyoutMenu" FontSize="14" >
+            <ContextMenu.ItemContainerStyle>
+                <Style TargetType="{x:Type MenuItem}">
+                    <Setter Property="Padding" Value="0,8,0,8"/>
+                    <Setter Property="VerticalContentAlignment" Value="Center"/>
+                </Style>
+            </ContextMenu.ItemContainerStyle>
+            <MenuItem Name="MenuEdit" Header="编辑模板" Click="MenuEdit_Click" >
+            </MenuItem>
+            <MenuItem Name="MenuDeleteCurrent" Header="删除模板"  Click="MenuDeleteCurrent_Click">
+            </MenuItem>
+            <MenuItem Name="MenuDeleteAll" Header="删除全部" Click="MenuDeleteAll_Click"></MenuItem>
+        </ContextMenu>
+    </UserControl.Resources>
+
+    <Grid Background="#F3F3F3">
+        <ListBox           Width="240" 
+                                BorderThickness="0"
+                                ScrollViewer.CanContentScroll="True"
+                                ScrollViewer.HorizontalScrollBarVisibility="Disabled"
+                                ScrollViewer.VerticalScrollBarVisibility="Hidden"
+                                VirtualizingPanel.IsVirtualizing="True"
+                                VirtualizingPanel.VirtualizationMode="Standard"
+                                VirtualizingPanel.CacheLengthUnit="Page"
+                                VirtualizingPanel.CacheLength="1"
+                                VirtualizingPanel.ScrollUnit="Pixel"   
+                                Background="#F3F3F3"
+                 ItemsSource="{Binding BackgroundModColorCollection}"
+                           SelectionChanged="ListBox_SelectionChanged">
+            <ListBox.ItemContainerStyle>
+                <Style TargetType="ListBoxItem">
+                    <Setter Property="Margin" Value="20"/>
+                    <Setter Property="Padding" Value="0"/>
+                    <Setter Property="Height" Value="160"/>
+                    <Setter Property="Width" Value="128"/>
+                    <Setter Property="ContextMenu" Value="{StaticResource FlyoutMenu}"/>
+                    <Setter Property="Template" Value="{DynamicResource EditToolsItemControlTemplate}"/>
+                </Style>
+            </ListBox.ItemContainerStyle>
+            <ListBox.ItemTemplate>
+                <DataTemplate DataType="{x:Type data:BackgroundItem}">
+                    <StackPanel Name="itemPanel" Loaded="itemPanel_Loaded">
+                        <Border BorderThickness="1" BorderBrush="#A0A2AE">
+                            <Grid Height="160" Width=" 128" Margin="1">
+
+                                <Image  Name="BackgroundPreview" Stretch="Fill" RenderOptions.BitmapScalingMode="HighQuality"/>
+
+                                <Button Name="EditTemplateBtn" Height="43" Width="64" Margin="0" HorizontalAlignment="Left" VerticalAlignment="Bottom" Click="EditTemplateBtn_Click"></Button>
+                                <Button Name="DeleteTemplateBtn"  Height="43" Width="64" Margin="0" HorizontalAlignment="Right" VerticalAlignment="Bottom" Click="DeleteTemplateBtn_Click" >
+                                </Button>
+                            </Grid>
+                        </Border>
+                    </StackPanel>
+                    <DataTemplate.Triggers>
+                        <Trigger Property="IsMouseOver" Value="True">
+                            <Setter TargetName="EditTemplateBtn" Property="Visibility" Value="Visible"/>
+                            <Setter TargetName="DeleteTemplateBtn" Property="Visibility" Value="Visible"/>
+
+                        </Trigger>
+                        <Trigger Property="IsMouseOver" Value="False">
+                            <Setter TargetName="EditTemplateBtn" Property="Visibility" Value="Collapsed"/>
+                            <Setter TargetName="DeleteTemplateBtn" Property="Visibility" Value="Collapsed"/>
+                        </Trigger>
+                    </DataTemplate.Triggers>
+                </DataTemplate>
+            </ListBox.ItemTemplate>
+        </ListBox>
+        <Grid Margin="64,153,56,0" Visibility="{Binding CreateTemplateVisible, Mode=OneWay}">
+            <StackPanel Orientation="Vertical">
+                <Label Height="87" Width="87" HorizontalAlignment="Center" Background="BlueViolet"></Label>
+                <TextBlock Height="24" FontSize="14" Text="请先创建一个背景模板" Margin="0,8,0,0" VerticalAlignment="Center" ></TextBlock>
+                <Button Height="24" Width="44" Margin="0,12,0,0" Content ="新建" Command="{Binding AddTemplateCommand}"></Button>
+            </StackPanel>
+        </Grid>
+    </Grid>
+</UserControl>
+

+ 76 - 0
PDF Office/Views/Dialog/HomePageToolsDialogs/HomePageBatchProcessing/HomePageBackground/HomePageBackgroundTemplateListColorContent.xaml.cs

@@ -0,0 +1,76 @@
+using PDF_Office.ViewModels.EditTools.Background;
+using PDFSettings;
+using System.Diagnostics;
+using System.Windows;
+using System;
+using System.Windows.Controls;
+using System.Windows.Media.Imaging;
+using PDF_Office.ViewModels.Dialog.HomePageToolsDialogs.HomePageBatchProcessing.HomePageBackground;
+using System.IO;
+
+namespace PDF_Office.Views.Dialog.HomePageToolsDialogs.HomePageBatchProcessing.HomePageBackground
+{
+    /// <summary>
+    /// Interaction logic for HomePageBackgroundTemplateListColorContent
+    /// </summary>
+    public partial class HomePageBackgroundTemplateListColorContent : UserControl
+    {
+        private HomePageBackgroundTemplateListColorContentViewModel viewModel;
+
+        public HomePageBackgroundTemplateListColorContent()
+        {
+            InitializeComponent();
+            viewModel = this.DataContext as HomePageBackgroundTemplateListColorContentViewModel;
+        }
+
+        private void DeleteTemplateBtn_Click(object sender, System.Windows.RoutedEventArgs e)
+        {
+            viewModel.DeleteTemplateItemCommand?.Execute(sender);
+        }
+
+        private void ListBox_SelectionChanged(object sender, SelectionChangedEventArgs e)
+        {
+            var listBox = sender as ListBox;
+            viewModel.SelectTemplateItemCommand?.Execute(sender);
+            listBox.SelectedIndex = -1;
+        }
+
+        private void MenuEdit_Click(object sender, RoutedEventArgs e)
+        {
+            viewModel.EditTemplateItemCommand?.Execute(sender);
+        }
+
+        private void MenuDeleteCurrent_Click(object sender, RoutedEventArgs e)
+        {
+            viewModel.DeleteTemplateItemCommand?.Execute(sender);
+
+        }
+
+        private void MenuDeleteAll_Click(object sender, RoutedEventArgs e)
+        {
+            viewModel.DeleteAllTemplateItemCommand?.Execute();
+        }
+
+        private void EditTemplateBtn_Click(object sender, RoutedEventArgs e)
+        {
+            viewModel.EditTemplateItemCommand?.Execute(sender);
+        }
+
+        private void itemPanel_Loaded(object sender, RoutedEventArgs e)
+        {
+            try
+            {
+                StackPanel panel = sender as StackPanel;
+                var data = panel.DataContext as BackgroundItem;
+                var img = panel.FindName("BackgroundPreview") as Image;
+                Trace.WriteLine(data.previewImagePath);
+                if (!string.IsNullOrEmpty(data.previewImagePath) && File.Exists(data.previewImagePath))
+                {
+                    BitmapSource bmp = new BitmapImage(new Uri(data.previewImagePath));
+                    img.Source = bmp;
+                }
+            }
+            catch { }
+        }
+    }
+}

+ 87 - 0
PDF Office/Views/Dialog/HomePageToolsDialogs/HomePageBatchProcessing/HomePageBackground/HomePageBackgroundTemplateListFileContent.xaml

@@ -0,0 +1,87 @@
+<UserControl x:Class="PDF_Office.Views.Dialog.HomePageToolsDialogs.HomePageBatchProcessing.HomePageBackground.HomePageBackgroundTemplateListFileContent"
+             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" 
+             xmlns:data ="clr-namespace:PDFSettings;assembly=PDFSettings"
+             xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
+             xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006" xmlns:background="clr-namespace:PDF_Office.ViewModels.EditTools.Background" d:DataContext="{d:DesignInstance Type=background:BackgroundTemplateListFileContentViewModel}"
+             mc:Ignorable="d"
+             d:DesignHeight="632"
+             d:DesignWidth="260">
+    <UserControl.Resources>
+        <ContextMenu x:Key="FlyoutMenu" FontSize="14" >
+            <ContextMenu.ItemContainerStyle>
+                <Style TargetType="{x:Type MenuItem}">
+                    <Setter Property="Padding" Value="0,8,0,8"/>
+                    <Setter Property="VerticalContentAlignment" Value="Center"/>
+                </Style>
+            </ContextMenu.ItemContainerStyle>
+            <MenuItem Name="MenuEdit" Header="编辑模板" Click="MenuEdit_Click" >
+            </MenuItem>
+            <MenuItem Name="MenuDeleteCurrent" Header="删除模板"  Click="MenuDeleteCurrent_Click">
+            </MenuItem>
+            <MenuItem Name="MenuDeleteAll" Header="删除全部" Click="MenuDeleteAll_Click"></MenuItem>
+        </ContextMenu>
+    </UserControl.Resources>
+
+    <Grid Background="#F3F3F3">
+        <ListBox
+                                Width="240" 
+                                BorderThickness="0"
+                                ScrollViewer.CanContentScroll="True"
+                                ScrollViewer.HorizontalScrollBarVisibility="Disabled"
+                                ScrollViewer.VerticalScrollBarVisibility="Hidden"
+                                VirtualizingPanel.IsVirtualizing="True"
+                                VirtualizingPanel.VirtualizationMode="Standard"
+                                VirtualizingPanel.CacheLengthUnit="Page"
+                                VirtualizingPanel.CacheLength="1"
+                                VirtualizingPanel.ScrollUnit="Pixel"   
+                                Background="#F3F3F3"
+                 ItemsSource="{Binding BackgroundModFileCollection}"  
+            SelectionChanged="ListBox_SelectionChanged">
+
+            <ListBox.ItemContainerStyle>
+                <Style TargetType="ListBoxItem">
+                    <Setter Property="Margin" Value="20"/>
+                    <Setter Property="Padding" Value="0 0 0 0"/>
+                    <Setter Property="Height" Value="160"/>
+                    <Setter Property="Width" Value="128"/>
+                    <Setter Property="ContextMenu" Value="{StaticResource FlyoutMenu}"/>
+                    <Setter Property="Template" Value="{DynamicResource EditToolsItemControlTemplate}"/>
+                </Style>
+            </ListBox.ItemContainerStyle>
+            <ListBox.ItemTemplate>
+                <DataTemplate DataType="{x:Type data:BackgroundItem}">
+                    <StackPanel Name="itemPanel" Loaded="itemPanel_Loaded">
+                        <Border BorderThickness="1" BorderBrush="#A0A2AE">
+                            <Grid Height="160" Width=" 128" >
+                                <Image  Name="BackgroundPreview" Stretch="Fill" RenderOptions.BitmapScalingMode="HighQuality"/>
+                                <Button Name="EditTemplateBtn" Height="43" Width="63" HorizontalAlignment="Left" VerticalAlignment="Bottom" Click="EditTemplateBtn_Click"></Button>
+                                <Button Name="DeleteTemplateBtn"  Height="43" Width="63" HorizontalAlignment="Right" VerticalAlignment="Bottom" Click="DeleteTemplateBtn_Click">
+                                </Button>
+                            </Grid>
+                        </Border>
+                    </StackPanel>
+                    <DataTemplate.Triggers>
+                        <Trigger Property="IsMouseOver" Value="True">
+                            <Setter TargetName="EditTemplateBtn" Property="Visibility" Value="Visible"/>
+                            <Setter TargetName="DeleteTemplateBtn" Property="Visibility" Value="Visible"/>
+                        </Trigger>
+                        <Trigger Property="IsMouseOver" Value="False">
+                            <Setter TargetName="EditTemplateBtn" Property="Visibility" Value="Collapsed"/>
+                            <Setter TargetName="DeleteTemplateBtn" Property="Visibility" Value="Collapsed"/>
+                        </Trigger>
+                    </DataTemplate.Triggers>
+                </DataTemplate>
+            </ListBox.ItemTemplate>
+        </ListBox>
+        <Grid Width="140"  Margin="64,153,56,0" Visibility="{Binding CreateTemplateVisible, Mode=OneWay}">
+            <StackPanel Orientation="Vertical">
+                <Label Height="87" Width="87" HorizontalAlignment="Center" Background="BlueViolet"></Label>
+                <TextBlock Height="24" FontSize="14" Text="请先创建一个背景模板" Margin="0,8,0,0" VerticalAlignment="Center" ></TextBlock>
+                <Button Height="24" Width="44" Margin="0,12,0,0" Content ="新建" Command="{Binding AddTemplateCommand}"></Button>
+            </StackPanel>
+        </Grid>
+    </Grid>
+</UserControl>

+ 77 - 0
PDF Office/Views/Dialog/HomePageToolsDialogs/HomePageBatchProcessing/HomePageBackground/HomePageBackgroundTemplateListFileContent.xaml.cs

@@ -0,0 +1,77 @@
+using PDF_Office.ViewModels.EditTools.Background;
+using PDFSettings;
+using System.Diagnostics;
+using System.Windows;
+using System;
+using System.Windows.Controls;
+using System.Windows.Media.Imaging;
+using PDF_Office.ViewModels.Dialog.HomePageToolsDialogs.HomePageBatchProcessing.HomePageBackground;
+using System.IO;
+
+namespace PDF_Office.Views.Dialog.HomePageToolsDialogs.HomePageBatchProcessing.HomePageBackground
+{
+    /// <summary>
+    /// Interaction logic for HomePageBackgroundTemplateListFileContent
+    /// </summary>
+    public partial class HomePageBackgroundTemplateListFileContent : UserControl
+    {
+        private HomePageBackgroundTemplateListFileContentViewModel viewModel;
+
+        public HomePageBackgroundTemplateListFileContent()
+        {
+            InitializeComponent();
+            viewModel = this.DataContext as HomePageBackgroundTemplateListFileContentViewModel;
+        }
+
+        private void DeleteTemplateBtn_Click(object sender, System.Windows.RoutedEventArgs e)
+        {
+            viewModel.DeleteTemplateItemCommand?.Execute(sender);
+        }
+
+
+        private void ListBox_SelectionChanged(object sender, SelectionChangedEventArgs e)
+        {
+            var listBox = sender as ListBox;
+            viewModel.SelectTemplateItemCommand?.Execute(sender);
+            listBox.SelectedIndex = -1;
+        }
+
+        private void MenuEdit_Click(object sender, RoutedEventArgs e)
+        {
+            viewModel.EditTemplateItemCommand?.Execute(sender);
+        }
+
+        private void MenuDeleteCurrent_Click(object sender, RoutedEventArgs e)
+        {
+            viewModel.DeleteTemplateItemCommand?.Execute(sender);
+        }
+
+        private void MenuDeleteAll_Click(object sender, RoutedEventArgs e)
+        {
+            viewModel.DeleteAllTemplateItemCommand?.Execute();
+        }
+
+        private void EditTemplateBtn_Click(object sender, RoutedEventArgs e)
+        {
+            viewModel.EditTemplateItemCommand?.Execute(sender);
+        }
+
+        private void itemPanel_Loaded(object sender, RoutedEventArgs e)
+        {
+            try
+            {
+                StackPanel panel = sender as StackPanel;
+                var data = panel.DataContext as BackgroundItem;
+                var img = panel.FindName("BackgroundPreview") as Image;
+                Trace.WriteLine(data.previewImagePath);
+                if (!string.IsNullOrEmpty(data.previewImagePath) && File.Exists(data.previewImagePath))
+                {
+                    BitmapSource bmp = new BitmapImage(new Uri(data.previewImagePath));
+                    img.Source = bmp;
+                }
+            }
+            catch { }
+        }
+    }
+}
+

+ 1 - 1
PDF Office/Views/Dialog/HomePageToolsDialogs/HomePageBatchProcessing/HomePageBates/HomePageBatesCreateContent.xaml.cs

@@ -20,7 +20,7 @@ namespace PDF_Office.Views.Dialog.HomePageToolsDialogs.HomePageBatchProcessing.H
 
         private void cusColor_SelectedColor(object sender, Color e)
         {
-            var data = this.DataContext as BatesCreateContentViewModel;
+            var data = this.DataContext as HomePageBatesCreateContentViewModel;
             if (data != null)
             {
                 data.SelectedColorChangedCommand?.Execute(e);

+ 2 - 2
PDF Office/Views/Dialog/HomePageToolsDialogs/HomePageBatchProcessing/HomePageBates/HomePageBatesDialog.xaml

@@ -16,7 +16,7 @@
         </ResourceDictionary>
     </UserControl.Resources>
 
-    <Grid IsEnabled="{Binding ConverterGridIsEnabled}">
+    <Grid IsEnabled="{Binding BatesGridIsEnabled}">
         <Grid.ColumnDefinitions>
             <ColumnDefinition Width="558*"/>
             <ColumnDefinition Width="260*"/>
@@ -121,7 +121,7 @@
                 </Button>
             </Grid>
         </Grid>
-        <Grid Grid.Column="1" Background="WhiteSmoke" IsEnabled="{Binding SetConverterGridIsEnabled}">
+        <Grid Grid.Column="1" Background="WhiteSmoke" IsEnabled="{Binding SetBatesGridIsEnabled}">
             <Grid.RowDefinitions>
                 <RowDefinition Height="*"/>
                 <RowDefinition Height="72"/>

+ 2 - 2
PDF Office/Views/Dialog/HomePageToolsDialogs/HomePageBatchProcessing/HomePageHeaderFooter/HomePageHeaderFooterDialog.xaml

@@ -16,7 +16,7 @@
         </ResourceDictionary>
     </UserControl.Resources>
 
-    <Grid IsEnabled="{Binding ConverterGridIsEnabled}">
+    <Grid IsEnabled="{Binding HeaderFooterGridIsEnabled}">
         <Grid.ColumnDefinitions>
             <ColumnDefinition Width="558*"/>
             <ColumnDefinition Width="260*"/>
@@ -121,7 +121,7 @@
                 </Button>
             </Grid>
         </Grid>
-        <Grid Grid.Column="1" Background="WhiteSmoke" IsEnabled="{Binding SetConverterGridIsEnabled}">
+        <Grid Grid.Column="1" Background="WhiteSmoke" IsEnabled="{Binding SetHeaderFooterGridIsEnabled}">
             <Grid.RowDefinitions>
                 <RowDefinition Height="*"/>
                 <RowDefinition Height="72"/>

+ 67 - 0
PDF Office/Views/Dialog/HomePageToolsDialogs/HomePageBatchProcessing/HomePageWatermark/HomePageWatermarkCreateBaseContent.xaml

@@ -0,0 +1,67 @@
+<UserControl x:Class="PDF_Office.Views.Dialog.HomePageToolsDialogs.HomePageBatchProcessing.HomePageWatermark.HomePageWatermarkCreateBaseContent"
+             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"
+             xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
+             xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006" xmlns:watermark="clr-namespace:PDF_Office.ViewModels.EditTools.Watermark" d:DataContext="{d:DesignInstance Type=watermark:WatermarkCreateBaseContentViewModel}"
+             mc:Ignorable="d"
+             d:DesignHeight="720"
+             d:DesignWidth="260" >
+    <Grid>
+        <Grid.RowDefinitions>
+            <RowDefinition Height="40"></RowDefinition>
+            <RowDefinition Height="48"></RowDefinition>
+            <RowDefinition></RowDefinition>
+        </Grid.RowDefinitions>
+        <Grid Grid.Row="0" Visibility="{Binding CreateBaseVisible, Mode=TwoWay}">
+            <Button  Height="24" Width="90" HorizontalAlignment="Left" Margin="16,0,0,0"  Command="{Binding EnterTemplateListCommand}">
+                <StackPanel Orientation="Horizontal">
+                    <TextBlock Text="&lt;" Margin="0,0,9,0" FontSize="16"></TextBlock>
+                    <TextBlock Text="创建水印" FontSize="16"></TextBlock>
+                </StackPanel>
+            </Button>
+            <Button  Height="20" Width="64" Margin="0,0,16,0" HorizontalAlignment="Right" Command="{Binding SaveToTemplateListCommand}">
+                <StackPanel>
+                    <TextBlock Text="保存至模板"  Foreground="#18A0FB"></TextBlock>
+                    <Rectangle Height="1" Fill="#18A0FB"></Rectangle>
+                </StackPanel>
+            </Button>
+        </Grid>
+        <Grid Grid.Row="0" Visibility="{Binding EditBaseVisible, Mode=TwoWay}">
+            <Button  Height="24" Width="90" HorizontalAlignment="Left" Margin="16,0,0,0"  Command="{Binding EnterTemplateListCommand}">
+                <StackPanel Orientation="Horizontal">
+                    <TextBlock Text="&lt;" Margin="0,0,9,0" FontSize="16"></TextBlock>
+                    <TextBlock Text="编辑模板" FontSize="16"></TextBlock>
+                </StackPanel>
+            </Button>
+            <Button  Height="20" Width="64" Margin="0,0,16,0" HorizontalAlignment="Right" Command="{Binding SaveToCurrentTemplateListCommand}">
+                <StackPanel>
+                    <TextBlock Text="保存"  Foreground="#18A0FB"></TextBlock>
+                    <Rectangle Height="1" Fill="#18A0FB"></Rectangle>
+                </StackPanel>
+            </Button>
+        </Grid>
+        <Grid Grid.Row="1" Margin="16,0,16,0">
+            <Grid.ColumnDefinitions>
+                <ColumnDefinition></ColumnDefinition>
+                <ColumnDefinition></ColumnDefinition>
+            </Grid.ColumnDefinitions>
+            <Button Name="HomePageWatermarkCreateTextContent" Grid.Column="0" Command="{Binding ChangeCreateModCommand}" CommandParameter="{Binding ElementName=HomePageWatermarkCreateTextContent}">
+                <StackPanel Orientation="Vertical">
+                    <TextBlock Text="文本" FontSize="18"></TextBlock>
+                </StackPanel>
+
+            </Button>
+            <Button Grid.Column="1" Name="HomePageWatermarkCreateFileContent" Command="{Binding ChangeCreateModCommand}" CommandParameter="{Binding ElementName=HomePageWatermarkCreateFileContent}">
+                <StackPanel Orientation="Vertical"  >
+                    <TextBlock Text="文件" FontSize="18" VerticalAlignment="Center"></TextBlock>
+                </StackPanel>
+            </Button>
+        </Grid>
+        <Grid Grid.Row="2">
+            <ContentControl prism:RegionManager.RegionName="{Binding WatermarkCreateRegionName}" Visibility="{Binding WatermarkCreateVisible}"></ContentControl>
+        </Grid>
+    </Grid>
+</UserControl>
+

+ 15 - 0
PDF Office/Views/Dialog/HomePageToolsDialogs/HomePageBatchProcessing/HomePageWatermark/HomePageWatermarkCreateBaseContent.xaml.cs

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

+ 115 - 0
PDF Office/Views/Dialog/HomePageToolsDialogs/HomePageBatchProcessing/HomePageWatermark/HomePageWatermarkCreateFileContent.xaml

@@ -0,0 +1,115 @@
+<UserControl x:Class="PDF_Office.Views.Dialog.HomePageToolsDialogs.HomePageBatchProcessing.HomePageWatermark.HomePageWatermarkCreateFileContent"
+             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"
+             xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
+             xmlns:cus="clr-namespace:PDF_Office.CustomControl"
+             xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006" xmlns:watermark="clr-namespace:PDF_Office.ViewModels.EditTools.Watermark" d:DataContext="{d:DesignInstance Type=watermark:WatermarkCreateFileContentViewModel}"
+             mc:Ignorable="d"
+             d:DesignHeight="632"
+             d:DesignWidth="260" >
+    <UserControl.Resources>
+        <ResourceDictionary>
+            <ResourceDictionary.MergedDictionaries>
+                <ResourceDictionary Source="../../../../../Styles/CheckBoxStyle.xaml"/>
+            </ResourceDictionary.MergedDictionaries>
+        </ResourceDictionary>
+    </UserControl.Resources>
+    <Grid>
+        <Grid.RowDefinitions>
+            <RowDefinition Height="48"/>
+            <RowDefinition Height="584"/>
+        </Grid.RowDefinitions>
+        <Grid Grid.Row="0" Width="228" Margin="0,16,0,0">
+            <StackPanel Orientation="Horizontal">
+                <TextBox Name="FileNameTextBox" IsReadOnly="True"  Text="{Binding FileNameText}" FontSize="14" VerticalContentAlignment="Center"  Width="188"></TextBox>
+                <Button Content="+" Width="32" Height="32" Margin="8,0,0,0" Command="{Binding OpenFileCommand}"></Button>
+            </StackPanel>
+        </Grid>
+        <Grid Grid.Row="1" Visibility="{Binding CreateFileVisible}">
+            <Grid.RowDefinitions>
+                <RowDefinition Height="199"/>
+                <RowDefinition Height="200"/>
+                <RowDefinition Height="*"/>
+            </Grid.RowDefinitions>
+            <Grid Grid.Row="0" Margin="16,23,16,0" Width="228">
+                <StackPanel Orientation="Vertical">
+                    <TextBlock Text="外观" FontSize="12" Foreground="#666666" Height="20" Width="24" HorizontalAlignment="Left"></TextBlock>
+                    <StackPanel Orientation="Horizontal" Margin="0,8,0,0">
+                        <StackPanel Orientation="Horizontal">
+                            <TextBlock Width="24" Height="24" Background="CadetBlue"></TextBlock>
+                            <cus:CommonWritableComboBox Width="66" Height="32" Margin="8,0,0,0" TypeSouce="{Binding RotationList}" Minimum="-360" Maximum="360" Unit=" " Text="{Binding RotationText,Mode=TwoWay}" Value="{Binding RotationValue,Mode=TwoWay}"></cus:CommonWritableComboBox>
+                        </StackPanel>
+                        <StackPanel Orientation="Horizontal" Margin="28,0,0,0">
+                            <TextBlock Width="24" Height="24" Background="CadetBlue"></TextBlock>
+                            <cus:CommonWritableComboBox Width="66" Height="32" Margin="8,0,0,0" TypeSouce="{Binding OpacityList,Mode=TwoWay}" Text="{Binding OpacityText,Mode=TwoWay}" Value="{Binding OpacityValue,Mode=TwoWay}"></cus:CommonWritableComboBox>
+                        </StackPanel>
+                    </StackPanel>
+                    <ComboBox Height="32" Margin="0,8,0,0" ItemsSource="{Binding IsFrontList}" SelectedIndex="{Binding IsFrontSelectedIndex}"></ComboBox>
+                    <CheckBox Style="{StaticResource EditToolsCheckBoxStyle}" Content="相对目标页面的比例" Margin="0,11,0,0" Name="RelativeScaleCheckBox" IsChecked="{Binding IsRelativeScaleValue}">
+
+                    </CheckBox>
+                    <cus:CommonWritableComboBox Width="66" Height="32" HorizontalAlignment="Left" Margin="0,9,0,0" TypeSouce="{Binding ScaleList}" IsEnabled="{Binding ElementName=RelativeScaleCheckBox,Path=IsChecked}" Text="{Binding RelativeScaleText,Mode=TwoWay}" Value="{Binding RelativeScaleValue,Mode=TwoWay}"></cus:CommonWritableComboBox>
+                </StackPanel>
+            </Grid>
+            <Grid  Grid.Row="1"  Margin="16,8,16,0" Width="228">
+                <StackPanel>
+                    <TextBlock Text="位置" FontSize="12" Foreground="#666666" Height="20" Width="24" HorizontalAlignment="Left"></TextBlock>
+                    <StackPanel Orientation="Horizontal" Margin="0,8,0,0">
+                        <Grid Width="74" Height="74">
+                            <Grid.ColumnDefinitions>
+                                <ColumnDefinition></ColumnDefinition>
+                                <ColumnDefinition></ColumnDefinition>
+                                <ColumnDefinition></ColumnDefinition>
+                            </Grid.ColumnDefinitions>
+                            <Grid.RowDefinitions>
+                                <RowDefinition></RowDefinition>
+                                <RowDefinition></RowDefinition>
+                                <RowDefinition></RowDefinition>
+                            </Grid.RowDefinitions>
+                            <Button Grid.Column="0" Grid.Row="0" Tag="0" Command="{Binding ChangeLocationCommand}" CommandParameter="{Binding RelativeSource={RelativeSource Self}, Path=Tag}" IsEnabled="{Binding GetLocationFromNumber[0],Mode=TwoWay}"></Button>
+                            <Button Grid.Column="1" Grid.Row="0" Tag="1" Command="{Binding ChangeLocationCommand}" CommandParameter="{Binding RelativeSource={RelativeSource Self}, Path=Tag}"  IsEnabled="{Binding GetLocationFromNumber[1], Mode=TwoWay}"></Button>
+                            <Button Grid.Column="2" Grid.Row="0" Tag="2" Command="{Binding ChangeLocationCommand}" CommandParameter="{Binding RelativeSource={RelativeSource Self}, Path=Tag}"  IsEnabled="{Binding GetLocationFromNumber[2], Mode=TwoWay}"></Button>
+                            <Button Grid.Column="0" Grid.Row="1" Tag="10" Command="{Binding ChangeLocationCommand}"  CommandParameter="{Binding RelativeSource={RelativeSource Self}, Path=Tag}"  IsEnabled="{Binding GetLocationFromNumber[10], Mode=TwoWay}"></Button>
+                            <Button Grid.Column="1" Grid.Row="1" Tag="11" Command="{Binding ChangeLocationCommand}"  CommandParameter="{Binding RelativeSource={RelativeSource Self}, Path=Tag}"  IsEnabled="{Binding GetLocationFromNumber[11], Mode=TwoWay}"></Button>
+                            <Button Grid.Column="2" Grid.Row="1" Tag="12" Command="{Binding ChangeLocationCommand}"  CommandParameter="{Binding RelativeSource={RelativeSource Self}, Path=Tag}"  IsEnabled="{Binding GetLocationFromNumber[12], Mode=TwoWay}"></Button>
+                            <Button Grid.Column="0" Grid.Row="2" Tag="20" Command="{Binding ChangeLocationCommand}"  CommandParameter="{Binding RelativeSource={RelativeSource Self}, Path=Tag}"  IsEnabled="{Binding GetLocationFromNumber[20], Mode=TwoWay}"></Button>
+                            <Button Grid.Column="1" Grid.Row="2" Tag="21" Command="{Binding ChangeLocationCommand}"  CommandParameter="{Binding RelativeSource={RelativeSource Self}, Path=Tag}"  IsEnabled="{Binding GetLocationFromNumber[21], Mode=TwoWay}"></Button>
+                            <Button Grid.Column="2" Grid.Row="2" Tag="22" Command="{Binding ChangeLocationCommand}"  CommandParameter="{Binding RelativeSource={RelativeSource Self}, Path=Tag}"  IsEnabled="{Binding GetLocationFromNumber[22], Mode=TwoWay}"></Button>
+                        </Grid>
+                        <StackPanel Orientation="Vertical" Margin="70,0,0,0">
+                            <StackPanel Orientation="Horizontal">
+                                <TextBlock Text="X"  Width="9" Height="20" VerticalAlignment="Center"/>
+                                <cus:NumericUpDown Width="66" Height="32" Margin="9,0,0,0"  Text="{Binding HorizOffsetValue,Mode=TwoWay}"></cus:NumericUpDown>
+                            </StackPanel>
+                            <StackPanel Orientation="Horizontal" Margin="0,8,0,0">
+                                <TextBlock Text="Y" Width="9" Height="20" VerticalAlignment="Center"/>
+                                <cus:NumericUpDown Width="66" Height="32" Margin="9,0,0,0"  Text="{Binding VertOffsetValue,Mode=TwoWay}"></cus:NumericUpDown>
+                            </StackPanel>
+                        </StackPanel>
+
+                    </StackPanel>
+                    <CheckBox Style="{StaticResource EditToolsCheckBoxStyle}" Content="平铺" Margin="0,24,0,0" Name="IsFullCheckBox" IsChecked="{Binding IsFullValue}">
+                    </CheckBox>
+                    <StackPanel Orientation="Horizontal" Margin="0,8,0,0">
+                        <StackPanel Orientation="Horizontal">
+                            <TextBlock Text="" Background="Aquamarine" Width="25" Height="9" VerticalAlignment="Center"/>
+                            <cus:NumericUpDown Width="66" Height="32" Margin="9,0,0,0"  Text="{Binding HorizontalSpacingValue,Mode=TwoWay}" IsEnabled="{Binding ElementName=IsFullCheckBox,Path=IsChecked}"></cus:NumericUpDown>
+                        </StackPanel>
+                        <StackPanel Orientation="Horizontal" Margin="32,0,0,0">
+                            <TextBlock Background="AntiqueWhite" Width="9" Height="25" VerticalAlignment="Center"/>
+                            <cus:NumericUpDown Width="66" Height="32" Margin="9,0,0,0" Text="{Binding VerticalSpacingValue,Mode=TwoWay}" IsEnabled="{Binding ElementName=IsFullCheckBox,Path=IsChecked}"></cus:NumericUpDown>
+                        </StackPanel>
+                    </StackPanel>
+                </StackPanel>
+            </Grid>
+            <Grid Width="228" Grid.Row="2"  Margin="16,10,16,4" Grid.RowSpan="2">
+                <StackPanel Orientation="Vertical">
+                    <TextBlock Text="页面范围" FontSize="12" Foreground="#666666" Height="20" Width="48" HorizontalAlignment="Left"></TextBlock>
+                    <cus:WritableComboBox Height="32" Margin="0,8,0,0" Text="{Binding PageRangeText,Mode=TwoWay}" SelectedIndex="{Binding PageRangeSelectIndex,Mode=TwoWay}"></cus:WritableComboBox>
+                </StackPanel>
+            </Grid>
+        </Grid>
+    </Grid>
+</UserControl>

+ 15 - 0
PDF Office/Views/Dialog/HomePageToolsDialogs/HomePageBatchProcessing/HomePageWatermark/HomePageWatermarkCreateFileContent.xaml.cs

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

+ 132 - 0
PDF Office/Views/Dialog/HomePageToolsDialogs/HomePageBatchProcessing/HomePageWatermark/HomePageWatermarkCreateTextContent.xaml

@@ -0,0 +1,132 @@
+<UserControl x:Class="PDF_Office.Views.Dialog.HomePageToolsDialogs.HomePageBatchProcessing.HomePageWatermark.HomePageWatermarkCreateTextContent"
+             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"
+             xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
+             xmlns:convert="clr-namespace:PDF_Office.DataConvert"
+             xmlns:i="http://schemas.microsoft.com/xaml/behaviors"
+             xmlns:cus="clr-namespace:PDF_Office.CustomControl"
+             xmlns:CompositeControl="clr-namespace:PDF_Office.CustomControl.CompositeControl"
+             xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006" xmlns:watermark="clr-namespace:PDF_Office.ViewModels.EditTools.Watermark" d:DataContext="{d:DesignInstance Type=watermark:WatermarkCreateTextContentViewModel}"
+             mc:Ignorable="d"
+             d:DesignHeight="632"
+             d:DesignWidth="260" >
+    <UserControl.Resources>
+        <ResourceDictionary>
+            <convert:InvertBoolConvert x:Key="InvertBoolConvert"/>
+            <ResourceDictionary.MergedDictionaries>
+                <ResourceDictionary Source="../../../../../Styles/CheckBoxStyle.xaml"/>
+            </ResourceDictionary.MergedDictionaries>
+        </ResourceDictionary>
+    </UserControl.Resources>
+    <Grid>
+        <Grid.RowDefinitions>
+            <RowDefinition Height="168"/>
+            <RowDefinition Height="192"/>
+            <RowDefinition Height="200"/>
+            <RowDefinition Height="*"/>
+        </Grid.RowDefinitions>
+        <Grid Grid.Row="0" Width="228">
+            <StackPanel Orientation="Vertical">
+                <TextBox Name="TextValueTextBox" Height="72" Margin="0,16,0,0" Text="{Binding TextValue}"  Foreground="{Binding SolidColorBrush}" FontSize="14"  AcceptsReturn="True">
+                    <i:Interaction.Triggers>
+                        <i:EventTrigger EventName="TextChanged">
+                            <i:InvokeCommandAction Command="{Binding TextValueChangedCommand}" CommandParameter="{Binding ElementName=TextValueTextBox}" />
+                        </i:EventTrigger>
+                    </i:Interaction.Triggers>
+                </TextBox>
+                <StackPanel Orientation="Horizontal" Margin="0,8,0,0">
+                    <ComboBox Width="154" Height="32" SelectedIndex="{Binding FontNameSelectedIndex}" ItemsSource="{Binding FontNameList}"></ComboBox>
+                    <ComboBox Width="66" Height="32" Margin="8,0,0,0" ItemsSource="{Binding FontSizeList}" SelectedIndex="{Binding FontSizeSelectedIndex}" IsEnabled="{Binding ElementName=RelativeScaleCheckBox, Path=IsChecked, Converter={StaticResource InvertBoolConvert}}"></ComboBox>
+                </StackPanel>
+                <StackPanel Orientation="Horizontal" Margin="0,8,0,0">
+                    <StackPanel Orientation="Horizontal">
+                        <Button Width="34.67" Height="32"></Button>
+                        <Button Width="34.67" Height="32"></Button>
+                        <Button Width="34.67" Height="32"></Button>
+                    </StackPanel>
+                    <CompositeControl:ColorContent x:Name="cusColor" Height="32" Width="66"  Margin="8,0,0,0" >
+
+                    </CompositeControl:ColorContent>
+                </StackPanel>
+            </StackPanel>
+        </Grid>
+        <Grid Grid.Row="1" Margin="0,16,0,0" Width="228">
+            <StackPanel Orientation="Vertical">
+                <TextBlock Text="外观" FontSize="12" Foreground="#666666" Height="20" Width="24" HorizontalAlignment="Left"></TextBlock>
+                <StackPanel Orientation="Horizontal" Margin="0,8,0,0">
+                    <StackPanel Orientation="Horizontal">
+                        <TextBlock Width="24" Height="24" Background="CadetBlue"></TextBlock>
+                        <cus:CommonWritableComboBox  Width="66" Height="32" Margin="8,0,0,0" TypeSouce="{Binding RotationList,Mode=TwoWay}" Minimum="-360" Maximum="360" Unit=" " Text="{Binding RotationText,Mode=TwoWay}" Value="{Binding RotationValue,Mode=TwoWay}"></cus:CommonWritableComboBox>
+                    </StackPanel>
+                    <StackPanel Orientation="Horizontal" Margin="28,0,0,0">
+                        <TextBlock Width="24" Height="24" Background="CadetBlue"></TextBlock>
+                        <cus:CommonWritableComboBox Width="66" Height="32" Margin="8,0,0,0" TypeSouce="{Binding OpacityList,Mode=TwoWay}" Text="{Binding OpacityText,Mode=TwoWay}" Value="{Binding OpacityValue,Mode=TwoWay}"></cus:CommonWritableComboBox>
+                    </StackPanel>
+                </StackPanel>
+                <ComboBox Height="32" Margin="0,8,0,0" ItemsSource="{Binding IsFrontList}" SelectedIndex="{Binding IsFrontSelectedIndex}"></ComboBox>
+                <CheckBox Style="{StaticResource EditToolsCheckBoxStyle}" Content="相对目标页面的比例" Margin="0,11,0,0" Name="RelativeScaleCheckBox" IsChecked="{Binding IsRelativeScaleValue}">
+                </CheckBox>
+                <cus:CommonWritableComboBox Width="66" Height="32" HorizontalAlignment="Left" Margin="0,9,0,0" TypeSouce="{Binding ScaleList,Mode=TwoWay}" IsEnabled="{Binding ElementName=RelativeScaleCheckBox,Path=IsChecked}" Text="{Binding RelativeScaleText,Mode=TwoWay}" Value="{Binding RelativeScaleValue,Mode=TwoWay}"></cus:CommonWritableComboBox>
+            </StackPanel>
+        </Grid>
+        <Grid  Grid.Row="2"  Margin="0,8,0,0" Width="228">
+            <StackPanel>
+                <TextBlock Text="位置" FontSize="12" Foreground="#666666" Height="20" Width="48" HorizontalAlignment="Left"></TextBlock>
+                <StackPanel Orientation="Horizontal" Margin="0,8,0,0">
+                    <Grid Width="74" Height="74">
+                        <Grid.ColumnDefinitions>
+                            <ColumnDefinition></ColumnDefinition>
+                            <ColumnDefinition></ColumnDefinition>
+                            <ColumnDefinition></ColumnDefinition>
+                        </Grid.ColumnDefinitions>
+                        <Grid.RowDefinitions>
+                            <RowDefinition></RowDefinition>
+                            <RowDefinition></RowDefinition>
+                            <RowDefinition></RowDefinition>
+                        </Grid.RowDefinitions>
+                        <Button Grid.Column="0" Grid.Row="0" Tag="0" Command="{Binding ChangeLocationCommand}" CommandParameter="{Binding RelativeSource={RelativeSource Self}, Path=Tag}" IsEnabled="{Binding GetLocationFromNumber[0],Mode=TwoWay}"></Button>
+                        <Button Grid.Column="1" Grid.Row="0" Tag="1" Command="{Binding ChangeLocationCommand}" CommandParameter="{Binding RelativeSource={RelativeSource Self}, Path=Tag}"  IsEnabled="{Binding GetLocationFromNumber[1], Mode=TwoWay}"></Button>
+                        <Button Grid.Column="2" Grid.Row="0" Tag="2" Command="{Binding ChangeLocationCommand}" CommandParameter="{Binding RelativeSource={RelativeSource Self}, Path=Tag}"  IsEnabled="{Binding GetLocationFromNumber[2], Mode=TwoWay}"></Button>
+                        <Button Grid.Column="0" Grid.Row="1" Tag="10" Command="{Binding ChangeLocationCommand}"  CommandParameter="{Binding RelativeSource={RelativeSource Self}, Path=Tag}"  IsEnabled="{Binding GetLocationFromNumber[10], Mode=TwoWay}"></Button>
+                        <Button Grid.Column="1" Grid.Row="1" Tag="11" Command="{Binding ChangeLocationCommand}"  CommandParameter="{Binding RelativeSource={RelativeSource Self}, Path=Tag}"  IsEnabled="{Binding GetLocationFromNumber[11], Mode=TwoWay}"></Button>
+                        <Button Grid.Column="2" Grid.Row="1" Tag="12" Command="{Binding ChangeLocationCommand}"  CommandParameter="{Binding RelativeSource={RelativeSource Self}, Path=Tag}"  IsEnabled="{Binding GetLocationFromNumber[12], Mode=TwoWay}"></Button>
+                        <Button Grid.Column="0" Grid.Row="2" Tag="20" Command="{Binding ChangeLocationCommand}"  CommandParameter="{Binding RelativeSource={RelativeSource Self}, Path=Tag}"  IsEnabled="{Binding GetLocationFromNumber[20], Mode=TwoWay}"></Button>
+                        <Button Grid.Column="1" Grid.Row="2" Tag="21" Command="{Binding ChangeLocationCommand}"  CommandParameter="{Binding RelativeSource={RelativeSource Self}, Path=Tag}"  IsEnabled="{Binding GetLocationFromNumber[21], Mode=TwoWay}"></Button>
+                        <Button Grid.Column="2" Grid.Row="2" Tag="22" Command="{Binding ChangeLocationCommand}"  CommandParameter="{Binding RelativeSource={RelativeSource Self}, Path=Tag}"  IsEnabled="{Binding GetLocationFromNumber[22], Mode=TwoWay}"></Button>
+                    </Grid>
+                    <StackPanel Orientation="Vertical" Margin="70,0,0,0">
+                        <StackPanel Orientation="Horizontal">
+                            <TextBlock Text="X"  Width="9" Height="20" VerticalAlignment="Center"/>
+                            <cus:NumericUpDown Width="66" Height="32" Margin="9,0,0,0"  Text="{Binding HorizOffsetValue,Mode=TwoWay}"></cus:NumericUpDown>
+                        </StackPanel>
+                        <StackPanel Orientation="Horizontal" Margin="0,8,0,0">
+                            <TextBlock Text="Y" Width="9" Height="20" VerticalAlignment="Center"/>
+                            <cus:NumericUpDown Width="66" Height="32" Margin="9,0,0,0"  Text="{Binding VertOffsetValue,Mode=TwoWay}"></cus:NumericUpDown>
+                        </StackPanel>
+                    </StackPanel>
+
+                </StackPanel>
+                <CheckBox Style="{StaticResource EditToolsCheckBoxStyle}" Content="平铺" Margin="0,24,0,0" Name="IsFullCheckBox" IsChecked="{Binding IsFullValue}">
+                </CheckBox>
+                <StackPanel Orientation="Horizontal" Margin="0,8,0,0">
+                    <StackPanel Orientation="Horizontal">
+                        <TextBlock Text="" Background="Aquamarine" Width="25" Height="9" VerticalAlignment="Center"/>
+                        <cus:NumericUpDown Width="66" Height="32" Margin="9,0,0,0"  Text="{Binding HorizontalSpacingValue,Mode=TwoWay}" IsEnabled="{Binding ElementName=IsFullCheckBox,Path=IsChecked}"></cus:NumericUpDown>
+                    </StackPanel>
+                    <StackPanel Orientation="Horizontal" Margin="32,0,0,0">
+                        <TextBlock Background="AntiqueWhite" Width="9" Height="25" VerticalAlignment="Center"/>
+                        <cus:NumericUpDown Width="66" Height="32" Margin="9,0,0,0" Text="{Binding VerticalSpacingValue,Mode=TwoWay}" IsEnabled="{Binding ElementName=IsFullCheckBox,Path=IsChecked}"></cus:NumericUpDown>
+                    </StackPanel>
+                </StackPanel>
+            </StackPanel>
+        </Grid>
+        <Grid Width="228" Grid.Row="4"  Margin="0,8,0,4">
+            <StackPanel Orientation="Vertical">
+                <TextBlock Text="页面范围" FontSize="12" Foreground="#666666" Height="20" Width="24" HorizontalAlignment="Left"></TextBlock>
+                <cus:WritableComboBox Height="32" Margin="0,8,0,0" Text="{Binding PageRangeText,Mode=TwoWay}" SelectedIndex="{Binding PageRangeSelectIndex,Mode=TwoWay}"></cus:WritableComboBox>
+            </StackPanel>
+        </Grid>
+    </Grid>
+</UserControl>

+ 29 - 0
PDF Office/Views/Dialog/HomePageToolsDialogs/HomePageBatchProcessing/HomePageWatermark/HomePageWatermarkCreateTextContent.xaml.cs

@@ -0,0 +1,29 @@
+using PDF_Office.ViewModels;
+using PDF_Office.ViewModels.Dialog.HomePageToolsDialogs.HomePageBatchProcessing.HomePageWatermark;
+using PDF_Office.ViewModels.EditTools.Watermark;
+using System.Windows.Controls;
+using System.Windows.Media;
+
+namespace PDF_Office.Views.Dialog.HomePageToolsDialogs.HomePageBatchProcessing.HomePageWatermark
+{
+    /// <summary>
+    /// Interaction logic for HomePageWatermarkCreateTextContent
+    /// </summary>
+    public partial class HomePageWatermarkCreateTextContent : UserControl
+    {
+        public HomePageWatermarkCreateTextContent()
+        {
+            InitializeComponent();
+            cusColor.SelectedColorHandler += cusColor_SelectedColor;
+        }
+
+        private void cusColor_SelectedColor(object sender, Color e)
+        {
+            var data = this.DataContext as HomePageWatermarkCreateTextContentViewModel;
+            if (data != null)
+            {
+                data.SelectedColorChangedCommand?.Execute(e);
+            }
+        }
+    }
+}

+ 6 - 5
PDF Office/Views/Dialog/HomePageToolsDialogs/HomePageBatchProcessing/HomePageWatermark/HomePageWatermarkDialog.xaml

@@ -16,7 +16,7 @@
         </ResourceDictionary>
     </UserControl.Resources>
 
-    <Grid IsEnabled="{Binding ConverterGridIsEnabled}">
+    <Grid IsEnabled="{Binding WatermarkGridIsEnabled}">
         <Grid.ColumnDefinitions>
             <ColumnDefinition Width="558*"/>
             <ColumnDefinition Width="260*"/>
@@ -121,14 +121,15 @@
                 </Button>
             </Grid>
         </Grid>
-        <Grid Grid.Column="1" Background="WhiteSmoke" IsEnabled="{Binding SetConverterGridIsEnabled}">
+        <Grid Grid.Column="1" Background="WhiteSmoke" IsEnabled="{Binding SetWatermarkGridIsEnabled}">
             <Grid.RowDefinitions>
                 <RowDefinition Height="*"/>
                 <RowDefinition Height="72"/>
             </Grid.RowDefinitions>
-            <StackPanel Orientation="Vertical" Margin="15,16,0,0" Grid.Row="0">
-            </StackPanel>
-            <Grid Grid.Row="2">
+            <Grid  Grid.Row="0" Background="#F3F3F3">
+                <ContentControl prism:RegionManager.RegionName="{Binding WatermarkSettingsRegionName}" Visibility="{Binding WatermarkSettingsVisible}"></ContentControl>
+            </Grid>
+            <Grid Grid.Row="1">
                 <Button Height="40" Width="228" Background="Black" Command="{Binding CreateCommand}">
                     <TextBlock Text="Apply" FontSize="18" Foreground="White"/>
                 </Button>

+ 45 - 0
PDF Office/Views/Dialog/HomePageToolsDialogs/HomePageBatchProcessing/HomePageWatermark/HomePageWatermarkTemplateListBaseContent.xaml

@@ -0,0 +1,45 @@
+<UserControl x:Class="PDF_Office.Views.Dialog.HomePageToolsDialogs.HomePageBatchProcessing.HomePageWatermark.HomePageWatermarkTemplateListBaseContent"
+             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"
+              xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
+             xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006" 
+             mc:Ignorable="d"
+             d:DesignHeight="720"
+             d:DesignWidth="260">
+    <Grid>
+        <Grid.RowDefinitions>
+            <RowDefinition Height="48"/>
+            <RowDefinition Height="48"/>
+            <RowDefinition/>
+        </Grid.RowDefinitions>
+        <Grid Grid.Row="0">
+            <TextBlock Width="32" Height="24" Text="水印" FontSize="16" Margin="16,0,16,0" HorizontalAlignment="Left"></TextBlock>
+            <StackPanel HorizontalAlignment="Right" Orientation="Horizontal" >
+                <Button Height="20" Width="20"></Button>
+                <Button Height="20" Width="20" Margin="16,0,6,0" Command="{Binding EnterCreateCommand}"></Button>
+            </StackPanel>
+        </Grid>
+        <Grid Grid.Row="1" Margin="16,0,16,0">
+            <Grid.ColumnDefinitions>
+                <ColumnDefinition></ColumnDefinition>
+                <ColumnDefinition></ColumnDefinition>
+            </Grid.ColumnDefinitions>
+            <Button Grid.Column="0" x:Name="HomePageWatermarkTemplateListTextContent"  Command="{Binding ChangeTemplateListModCommand}" CommandParameter="{Binding ElementName=HomePageWatermarkTemplateListTextContent}">
+                <StackPanel Orientation="Vertical"  >
+                    <TextBlock Text="文本" FontSize="18"></TextBlock>
+                </StackPanel>
+
+            </Button>
+            <Button Grid.Column="1" x:Name="HomePageWatermarkTemplateListFileContent"  Command="{Binding ChangeTemplateListModCommand}" CommandParameter="{Binding ElementName=HomePageWatermarkTemplateListFileContent}">
+                <StackPanel Orientation="Vertical"  >
+                    <TextBlock Text="文件" FontSize="18" VerticalAlignment="Center"></TextBlock>
+                </StackPanel>
+            </Button>
+        </Grid>
+        <Grid Grid.Row="2">
+            <ContentControl prism:RegionManager.RegionName="{Binding WatermarkTemplateListRegionName}" Visibility="{Binding WatermarkTemplateListVisible}"></ContentControl>
+        </Grid>
+    </Grid>
+</UserControl>

+ 15 - 0
PDF Office/Views/Dialog/HomePageToolsDialogs/HomePageBatchProcessing/HomePageWatermark/HomePageWatermarkTemplateListBaseContent.xaml.cs

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

+ 85 - 0
PDF Office/Views/Dialog/HomePageToolsDialogs/HomePageBatchProcessing/HomePageWatermark/HomePageWatermarkTemplateListFileContent.xaml

@@ -0,0 +1,85 @@
+<UserControl x:Class="PDF_Office.Views.Dialog.HomePageToolsDialogs.HomePageBatchProcessing.HomePageWatermark.HomePageWatermarkTemplateListFileContent"
+             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"
+             xmlns:data ="clr-namespace:PDFSettings;assembly=PDFSettings"
+               xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
+             xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006" xmlns:watermark="clr-namespace:PDF_Office.ViewModels.EditTools.Watermark" d:DataContext="{d:DesignInstance Type=watermark:WatermarkTemplateListFileContentViewModel}"
+             mc:Ignorable="d"
+             d:DesignHeight="632"
+             d:DesignWidth="260">
+
+    <UserControl.Resources>
+        <ContextMenu x:Key="FlyoutMenu" FontSize="14" >
+            <ContextMenu.ItemContainerStyle>
+                <Style TargetType="{x:Type MenuItem}">
+                    <Setter Property="Padding" Value="0,8,0,8"/>
+                    <Setter Property="VerticalContentAlignment" Value="Center"/>
+                </Style>
+            </ContextMenu.ItemContainerStyle>
+            <MenuItem Name="MenuEdit" Header="编辑模板" Click="MenuEdit_Click" >
+            </MenuItem>
+            <MenuItem Name="MenuDeleteCurrent" Header="删除模板"  Click="MenuDeleteCurrent_Click">
+            </MenuItem>
+            <MenuItem Name="MenuDeleteAll" Header="删除全部" Click="MenuDeleteAll_Click"></MenuItem>
+        </ContextMenu>
+    </UserControl.Resources>
+
+    <Grid Background="#F3F3F3">
+        <ListBox Name="FileWatermarkListbox" 
+                                Width="240" 
+                                BorderThickness="0"
+                                ScrollViewer.CanContentScroll="True"
+                                ScrollViewer.HorizontalScrollBarVisibility="Disabled"
+                                ScrollViewer.VerticalScrollBarVisibility="Hidden"
+                                VirtualizingPanel.IsVirtualizing="True"
+                                VirtualizingPanel.VirtualizationMode="Standard"
+                                VirtualizingPanel.CacheLengthUnit="Page"
+                                VirtualizingPanel.CacheLength="1"
+                                VirtualizingPanel.ScrollUnit="Pixel"   
+                                Background="#F3F3F3"
+                 ItemsSource="{Binding WatermarkModFileCollection}"
+                 SelectionChanged="ListBox_SelectionChanged">
+            <ListBox.ItemContainerStyle>
+                <Style TargetType="ListBoxItem">
+                    <Setter Property="Margin" Value="20"/>
+                    <Setter Property="Padding" Value="0 0 0 0"/>
+                    <Setter Property="Height" Value="160"/>
+                    <Setter Property="Width" Value="128"/>
+                    <Setter Property="ContextMenu" Value="{StaticResource FlyoutMenu}"/>
+                    <Setter Property="Template" Value="{DynamicResource EditToolsItemControlTemplate}"/>
+                </Style>
+            </ListBox.ItemContainerStyle>
+            <ListBox.ItemTemplate>
+                <DataTemplate DataType="{x:Type data:WatermarkItem}">
+                    <StackPanel Name="itemPanel" Loaded="itemPanel_Loaded">
+                        <Grid Height="160" Width=" 128" >
+                            <Image  Name="WatermarkPreview" Stretch="Fill" RenderOptions.BitmapScalingMode="HighQuality" />
+                            <Button Name="EditTemplateBtn" Height="43" Width="63" HorizontalAlignment="Left" VerticalAlignment="Bottom" Click="EditTemplateBtn_Click"></Button>
+                            <Button Name="DeleteTemplateBtn"  Height="43" Width="63" HorizontalAlignment="Right" VerticalAlignment="Bottom" Click="DeleteTemplateBtn_Click" >
+                            </Button>
+                        </Grid>
+                    </StackPanel>
+                    <DataTemplate.Triggers>
+                        <Trigger Property="IsMouseOver" Value="True">
+                            <Setter TargetName="EditTemplateBtn" Property="Visibility" Value="Visible"/>
+                            <Setter TargetName="DeleteTemplateBtn" Property="Visibility" Value="Visible"/>
+                        </Trigger>
+                        <Trigger Property="IsMouseOver" Value="False">
+                            <Setter TargetName="EditTemplateBtn" Property="Visibility" Value="Collapsed"/>
+                            <Setter TargetName="DeleteTemplateBtn" Property="Visibility" Value="Collapsed"/>
+                        </Trigger>
+                    </DataTemplate.Triggers>
+                </DataTemplate>
+            </ListBox.ItemTemplate>
+        </ListBox>
+        <Grid Width="140" Margin="64,154,56,312" Visibility="{Binding CreateTemplateVisible, Mode=OneWay}">
+            <StackPanel Orientation="Vertical">
+                <Label Height="87" Width="87" HorizontalAlignment="Center" Background="BlueViolet"></Label>
+                <TextBlock Height="24" FontSize="14" Text="请先创建一个水印模板" Margin="0,8,0,0" VerticalAlignment="Center" ></TextBlock>
+                <Button Height="24" Width="44" Margin="0,12,0,0" Content ="新建" Command="{Binding AddTemplateCommand}"></Button>
+            </StackPanel>
+        </Grid>
+    </Grid>
+</UserControl>

+ 84 - 0
PDF Office/Views/Dialog/HomePageToolsDialogs/HomePageBatchProcessing/HomePageWatermark/HomePageWatermarkTemplateListFileContent.xaml.cs

@@ -0,0 +1,84 @@
+using PDF_Office.ViewModels.EditTools.Watermark;
+using PDFSettings;
+using System.Diagnostics;
+using System.Windows;
+using System;
+using System.Windows.Controls;
+using System.Windows.Media.Imaging;
+using PDF_Office.ViewModels;
+using System.IO;
+using System.Collections;
+using PDF_Office.ViewModels.Dialog.HomePageToolsDialogs.HomePageBatchProcessing.HomePageWatermark;
+
+namespace PDF_Office.Views.Dialog.HomePageToolsDialogs.HomePageBatchProcessing.HomePageWatermark
+{
+    /// <summary>
+    /// Interaction logic for HomePageWatermarkTemplateListFileContent
+    /// </summary>
+    public partial class HomePageWatermarkTemplateListFileContent : UserControl
+    {
+        private HomePageWatermarkTemplateListFileContentViewModel viewModel;
+        public HomePageWatermarkTemplateListFileContent()
+        {
+            InitializeComponent();
+            viewModel = this.DataContext as HomePageWatermarkTemplateListFileContentViewModel;
+        }
+
+        private void DeleteTemplateBtn_Click(object sender, System.Windows.RoutedEventArgs e)
+        {
+            viewModel.DeleteTemplateItemCommand?.Execute(sender);
+        }
+
+        private void ListBox_SelectionChanged(object sender, SelectionChangedEventArgs e)
+        {
+            IList list = FileWatermarkListbox.SelectedItems;
+            var lists = FileWatermarkListbox.Items;
+            System.Data.DataRowView a;
+            foreach (var item in list)
+            {
+
+                Trace.WriteLine(lists.IndexOf(item));
+            }
+            viewModel.SelectTemplateItemCommand?.Execute(sender);
+            FileWatermarkListbox.SelectedIndex = -1;
+        }
+
+        private void MenuEdit_Click(object sender, RoutedEventArgs e)
+        {
+            viewModel.EditTemplateItemCommand?.Execute(sender);
+        }
+
+        private void MenuDeleteCurrent_Click(object sender, RoutedEventArgs e)
+        {
+            viewModel.DeleteTemplateItemCommand?.Execute(sender);
+
+        }
+
+        private void MenuDeleteAll_Click(object sender, RoutedEventArgs e)
+        {
+            viewModel.DeleteAllTemplateItemCommand?.Execute();
+        }
+
+        private void EditTemplateBtn_Click(object sender, RoutedEventArgs e)
+        {
+            viewModel.EditTemplateItemCommand?.Execute(sender);
+        }
+        private void itemPanel_Loaded(object sender, RoutedEventArgs e)
+        {
+            try
+            {
+                StackPanel panel = sender as StackPanel;
+                var data = panel.DataContext as WatermarkItem;
+                var img = panel.FindName("WatermarkPreview") as Image;
+                Trace.WriteLine(data.previewImagePath);
+                if (!string.IsNullOrEmpty(data.previewImagePath) && File.Exists(data.previewImagePath))
+                {
+                    BitmapSource bmp = new BitmapImage(new Uri(data.previewImagePath));
+                    img.Source = bmp;
+                }
+            }
+            catch { }
+        }
+    }
+}
+

+ 85 - 0
PDF Office/Views/Dialog/HomePageToolsDialogs/HomePageBatchProcessing/HomePageWatermark/HomePageWatermarkTemplateListTextContent.xaml

@@ -0,0 +1,85 @@
+<UserControl x:Class="PDF_Office.Views.Dialog.HomePageToolsDialogs.HomePageBatchProcessing.HomePageWatermark.HomePageWatermarkTemplateListTextContent"
+             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"
+             xmlns:data ="clr-namespace:PDFSettings;assembly=PDFSettings"
+               xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
+             xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006" xmlns:watermark="clr-namespace:PDF_Office.ViewModels.EditTools.Watermark" d:DataContext="{d:DesignInstance Type=watermark:WatermarkTemplateListTextContentViewModel}"
+             mc:Ignorable="d"
+             d:DesignHeight="632"
+             d:DesignWidth="260">
+
+    <UserControl.Resources>
+        <ContextMenu x:Key="FlyoutMenu" FontSize="14" >
+            <ContextMenu.ItemContainerStyle>
+                <Style TargetType="{x:Type MenuItem}">
+                    <Setter Property="Padding" Value="0,8,0,8"/>
+                    <Setter Property="VerticalContentAlignment" Value="Center"/>
+                </Style>
+            </ContextMenu.ItemContainerStyle>
+            <MenuItem Name="MenuEdit" Header="编辑模板" Click="MenuEdit_Click" >
+            </MenuItem>
+            <MenuItem Name="MenuDeleteCurrent" Header="删除模板"  Click="MenuDeleteCurrent_Click">
+            </MenuItem>
+            <MenuItem Name="MenuDeleteAll" Header="删除全部" Click="MenuDeleteAll_Click"></MenuItem>
+        </ContextMenu>
+    </UserControl.Resources>
+
+    <Grid Background="#F3F3F3">
+        <ListBox Name="TextWatermarkListbox" 
+                                Width="240" 
+                                BorderThickness="0"
+                                ScrollViewer.CanContentScroll="True"
+                                ScrollViewer.HorizontalScrollBarVisibility="Disabled"
+                                ScrollViewer.VerticalScrollBarVisibility="Hidden"
+                                VirtualizingPanel.IsVirtualizing="True"
+                                VirtualizingPanel.VirtualizationMode="Standard"
+                                VirtualizingPanel.CacheLengthUnit="Page"
+                                VirtualizingPanel.CacheLength="1"
+                                VirtualizingPanel.ScrollUnit="Pixel"   
+                                Background="#F3F3F3"
+                 ItemsSource="{Binding WatermarkModTextCollection}"
+                 SelectionChanged="ListBox_SelectionChanged">
+            <ListBox.ItemContainerStyle>
+                <Style TargetType="ListBoxItem">
+                    <Setter Property="Margin" Value="20"/>
+                    <Setter Property="Padding" Value="0 0 0 0"/>
+                    <Setter Property="Height" Value="160"/>
+                    <Setter Property="Width" Value="128"/>
+                    <Setter Property="ContextMenu" Value="{StaticResource FlyoutMenu}"/>
+                    <Setter Property="Template" Value="{DynamicResource EditToolsItemControlTemplate}"/>
+                </Style>
+            </ListBox.ItemContainerStyle>
+            <ListBox.ItemTemplate>
+                <DataTemplate DataType="{x:Type data:WatermarkItem}">
+                    <StackPanel Name="itemPanel" Loaded="itemPanel_Loaded">
+                        <Grid Height="160" Width=" 128">
+                            <Image  Name="WatermarkPreview" Stretch="Fill" RenderOptions.BitmapScalingMode="HighQuality"/>
+                            <Button Name="EditTemplateBtn" Height="43" Width="63" HorizontalAlignment="Left" VerticalAlignment="Bottom" Click="EditTemplateBtn_Click"></Button>
+                            <Button Name="DeleteTemplateBtn"  Height="43" Width="63" HorizontalAlignment="Right" VerticalAlignment="Bottom" Click="DeleteTemplateBtn_Click" >
+                            </Button>
+                        </Grid>
+                    </StackPanel>
+                    <DataTemplate.Triggers>
+                        <Trigger Property="IsMouseOver" Value="True">
+                            <Setter TargetName="EditTemplateBtn" Property="Visibility" Value="Visible"/>
+                            <Setter TargetName="DeleteTemplateBtn" Property="Visibility" Value="Visible"/>
+                        </Trigger>
+                        <Trigger Property="IsMouseOver" Value="False">
+                            <Setter TargetName="EditTemplateBtn" Property="Visibility" Value="Collapsed"/>
+                            <Setter TargetName="DeleteTemplateBtn" Property="Visibility" Value="Collapsed"/>
+                        </Trigger>
+                    </DataTemplate.Triggers>
+                </DataTemplate>
+            </ListBox.ItemTemplate>
+        </ListBox>
+        <Grid Width="140" Margin="64,154,56,312" Visibility="{Binding CreateTemplateVisible, Mode=OneWay}">
+            <StackPanel Orientation="Vertical">
+                <Label Height="87" Width="87" HorizontalAlignment="Center" Background="BlueViolet"></Label>
+                <TextBlock Height="24" FontSize="14" Text="请先创建一个水印模板" Margin="0,8,0,0" VerticalAlignment="Center" ></TextBlock>
+                <Button Height="24" Width="44" Margin="0,12,0,0" Content ="新建" Command="{Binding AddTemplateCommand}"></Button>
+            </StackPanel>
+        </Grid>
+    </Grid>
+</UserControl>

+ 77 - 0
PDF Office/Views/Dialog/HomePageToolsDialogs/HomePageBatchProcessing/HomePageWatermark/HomePageWatermarkTemplateListTextContent.xaml.cs

@@ -0,0 +1,77 @@
+using PDF_Office.ViewModels.EditTools.Watermark;
+using PDFSettings;
+using System.Diagnostics;
+using System.Windows;
+using System;
+using System.Windows.Controls;
+using System.Windows.Media.Imaging;
+using PDF_Office.ViewModels;
+using System.IO;
+using PDF_Office.ViewModels.Dialog.HomePageToolsDialogs.HomePageBatchProcessing.HomePageWatermark;
+
+namespace PDF_Office.Views.Dialog.HomePageToolsDialogs.HomePageBatchProcessing.HomePageWatermark
+{
+    /// <summary>
+    /// Interaction logic for HomePageWatermarkTemplateListTextContent
+    /// </summary>
+    public partial class HomePageWatermarkTemplateListTextContent : UserControl
+    {
+        private HomePageWatermarkTemplateListTextContentViewModel viewModel;
+        public HomePageWatermarkTemplateListTextContent()
+        {
+            InitializeComponent();
+            viewModel = this.DataContext as HomePageWatermarkTemplateListTextContentViewModel;
+        }
+
+        private void DeleteTemplateBtn_Click(object sender, System.Windows.RoutedEventArgs e)
+        {
+            viewModel.DeleteTemplateItemCommand?.Execute(sender);
+        }
+
+
+        private void ListBox_SelectionChanged(object sender, SelectionChangedEventArgs e)
+        {
+            viewModel.SelectTemplateItemCommand?.Execute(sender);
+
+            TextWatermarkListbox.SelectedIndex = -1;
+        }
+
+        private void MenuEdit_Click(object sender, RoutedEventArgs e)
+        {
+            viewModel.EditTemplateItemCommand?.Execute(sender);
+        }
+
+        private void MenuDeleteCurrent_Click(object sender, RoutedEventArgs e)
+        {
+            viewModel.DeleteTemplateItemCommand?.Execute(sender);
+
+        }
+
+        private void MenuDeleteAll_Click(object sender, RoutedEventArgs e)
+        {
+            viewModel.DeleteAllTemplateItemCommand?.Execute();
+        }
+
+        private void EditTemplateBtn_Click(object sender, RoutedEventArgs e)
+        {
+            viewModel.EditTemplateItemCommand?.Execute(sender);
+        }
+        private void itemPanel_Loaded(object sender, RoutedEventArgs e)
+        {
+            try
+            {
+                StackPanel panel = sender as StackPanel;
+                var data = panel.DataContext as WatermarkItem;
+                var img = panel.FindName("WatermarkPreview") as Image;
+                Trace.WriteLine(data.previewImagePath);
+                if (!string.IsNullOrEmpty(data.previewImagePath) && File.Exists(data.previewImagePath))
+                {
+                    BitmapSource bmp = new BitmapImage(new Uri(data.previewImagePath));
+                    img.Source = bmp;
+                }
+            }
+            catch { }
+        }
+    }
+}
+