Bläddra i källkod

Merge branch 'practice' into dev

# Conflicts:
#	PDF Office/App.xaml.cs
#	PDF Office/CustomControl/WritableComboBox.xaml.cs
#	PDF Office/Model/DialogNames.cs
#	PDF Office/Model/ParameterNames.cs
#	PDF Office/PDF Office.csproj
#	PDF Office/Properties/Settings.Designer.cs
#	PDF Office/Properties/Settings.settings
#	PDF Office/Styles/RadioButtonStyle.xaml
ZhouJieSheng 2 år sedan
förälder
incheckning
94fff85ce4
100 ändrade filer med 17034 tillägg och 2880 borttagningar
  1. 7 1
      PDF Office/App.config
  2. 29 1
      PDF Office/App.xaml.cs
  3. 25 2
      PDF Office/CustomControl/CommonWritableComboBox.xaml
  4. 3 3
      PDF Office/CustomControl/NumericUpDown.xaml
  5. 3 2
      PDF Office/CustomControl/WritableComboBox.xaml
  6. 11 0
      PDF Office/CustomControl/WritableComboBox.xaml.cs
  7. 41 0
      PDF Office/EventAggregators/EditToolsEvent.cs
  8. 46 0
      PDF Office/EventAggregators/SendPrintInfoEvent.cs
  9. 163 6
      PDF Office/Helper/ConverterHelper.cs
  10. 1 1
      PDF Office/Helper/EditToolsHelper.cs
  11. 10 1
      PDF Office/Model/Dialog/ConverterDialogs/ConverterHTMLDialogModel.cs
  12. 2 1
      PDF Office/Model/Dialog/ConverterDialogs/ConverterImgDialogModel.cs
  13. 1 1
      PDF Office/Model/Dialog/HomePageToolsDialogs/HomePageBatchProcessing/HomePageBatchProcessingDialogModel.cs
  14. 10 1
      PDF Office/Model/Dialog/HomePageToolsDialogs/HomePageBatchProcessing/HomePageConverter/HomePageConverterHTMLModel.cs
  15. 1 0
      PDF Office/Model/Dialog/HomePageToolsDialogs/HomePageBatchProcessing/HomePageConverter/HomePageConverterImgModel.cs
  16. 90 64
      PDF Office/Model/Dialog/HomePageToolsDialogs/HomePagePrinter/HomePagePrinterDialogModel.cs
  17. 1 1
      PDF Office/Model/DialogNames.cs
  18. 6 10
      PDF Office/Model/EditTools/Background/BackgroundCreateModel.cs
  19. 88 0
      PDF Office/Model/EditTools/Bates/BatesCreateModel.cs
  20. 82 0
      PDF Office/Model/EditTools/HeaderFooter/HeaderFooterCreateModel.cs
  21. 5 0
      PDF Office/Model/EditTools/Watermark/WatermarkCreateModel.cs
  22. 51 45
      PDF Office/Model/ParameterNames.cs
  23. 15 0
      PDF Office/Model/RegionNames.cs
  24. 245 15
      PDF Office/PDF Office.csproj
  25. 46 0
      PDF Office/Properties/Settings.Designer.cs
  26. 12 0
      PDF Office/Properties/Settings.settings
  27. 4 4
      PDF Office/SDKLisence.xml
  28. 1 0
      PDF Office/Styles/CheckBoxStyle.xaml
  29. 129 2
      PDF Office/Styles/RadioButtonStyle.xaml
  30. 3 0
      PDF Office/ViewModels/Dialog/ConverterDialogs/ConverterExcelDialogViewModel.cs
  31. 1 0
      PDF Office/ViewModels/Dialog/ConverterDialogs/ConverterHTMLDialogViewModel.cs
  32. 24 9
      PDF Office/ViewModels/Dialog/ConverterDialogs/ConverterImgDialogViewModel.cs
  33. 36 1
      PDF Office/ViewModels/Dialog/ConverterDialogs/ConverterProgressBarDialogViewModel.cs
  34. 244 0
      PDF Office/ViewModels/Dialog/HomePageToolsDialogs/HomePageBatchProcessing/HomePageBackground/HomePageBackgroundCreateBaseContentViewModel.cs
  35. 554 0
      PDF Office/ViewModels/Dialog/HomePageToolsDialogs/HomePageBatchProcessing/HomePageBackground/HomePageBackgroundCreateColorContentViewModel.cs
  36. 592 0
      PDF Office/ViewModels/Dialog/HomePageToolsDialogs/HomePageBatchProcessing/HomePageBackground/HomePageBackgroundCreateFileContentViewModel.cs
  37. 539 0
      PDF Office/ViewModels/Dialog/HomePageToolsDialogs/HomePageBatchProcessing/HomePageBackground/HomePageBackgroundDialogViewModel.cs
  38. 138 0
      PDF Office/ViewModels/Dialog/HomePageToolsDialogs/HomePageBatchProcessing/HomePageBackground/HomePageBackgroundTemplateListBaseContentViewModel.cs
  39. 237 0
      PDF Office/ViewModels/Dialog/HomePageToolsDialogs/HomePageBatchProcessing/HomePageBackground/HomePageBackgroundTemplateListColorContentViewModel.cs
  40. 242 0
      PDF Office/ViewModels/Dialog/HomePageToolsDialogs/HomePageBatchProcessing/HomePageBackground/HomePageBackgroundTemplateListFileContentViewModel.cs
  41. 1 2
      PDF Office/ViewModels/Dialog/HomePageToolsDialogs/HomePageBatchProcessing/HomePageBatchProcessingDialogViewModel.cs
  42. 718 0
      PDF Office/ViewModels/Dialog/HomePageToolsDialogs/HomePageBatchProcessing/HomePageBates/HomePageBatesCreateContentViewModel.cs
  43. 485 0
      PDF Office/ViewModels/Dialog/HomePageToolsDialogs/HomePageBatchProcessing/HomePageBates/HomePageBatesDialogViewModel.cs
  44. 229 0
      PDF Office/ViewModels/Dialog/HomePageToolsDialogs/HomePageBatchProcessing/HomePageBates/HomePageBatesTemplateListContentViewModel.cs
  45. 56 1
      PDF Office/ViewModels/Dialog/HomePageToolsDialogs/HomePageBatchProcessing/HomePageCompressDialogViewModel.cs
  46. 59 2
      PDF Office/ViewModels/Dialog/HomePageToolsDialogs/HomePageBatchProcessing/HomePageConverter/HomePageConverterDialogViewModel.cs
  47. 3 0
      PDF Office/ViewModels/Dialog/HomePageToolsDialogs/HomePageBatchProcessing/HomePageConverter/HomePageConverterExcelViewModel.cs
  48. 39 1
      PDF Office/ViewModels/Dialog/HomePageToolsDialogs/HomePageBatchProcessing/HomePageConverter/HomePageConverterImgViewModel.cs
  49. 730 0
      PDF Office/ViewModels/Dialog/HomePageToolsDialogs/HomePageBatchProcessing/HomePageHeaderFooter/HomePageHeaderFooterCreateContentViewModel.cs
  50. 486 0
      PDF Office/ViewModels/Dialog/HomePageToolsDialogs/HomePageBatchProcessing/HomePageHeaderFooter/HomePageHeaderFooterDialogViewModel.cs
  51. 225 0
      PDF Office/ViewModels/Dialog/HomePageToolsDialogs/HomePageBatchProcessing/HomePageHeaderFooter/HomePageHeaderFooterTemplateListContentViewModel.cs
  52. 519 0
      PDF Office/ViewModels/Dialog/HomePageToolsDialogs/HomePageBatchProcessing/HomePageRemoveDialogViewModel.cs
  53. 54 2
      PDF Office/ViewModels/Dialog/HomePageToolsDialogs/HomePageBatchProcessing/HomePageSetPasswordDialogViewModel.cs
  54. 246 0
      PDF Office/ViewModels/Dialog/HomePageToolsDialogs/HomePageBatchProcessing/HomePageWatermark/HomePageWatermarkCreateBaseContentViewModel.cs
  55. 720 0
      PDF Office/ViewModels/Dialog/HomePageToolsDialogs/HomePageBatchProcessing/HomePageWatermark/HomePageWatermarkCreateFileContentViewModel.cs
  56. 804 0
      PDF Office/ViewModels/Dialog/HomePageToolsDialogs/HomePageBatchProcessing/HomePageWatermark/HomePageWatermarkCreateTextContentViewModel.cs
  57. 541 0
      PDF Office/ViewModels/Dialog/HomePageToolsDialogs/HomePageBatchProcessing/HomePageWatermark/HomePageWatermarkDialogViewModel.cs
  58. 173 0
      PDF Office/ViewModels/Dialog/HomePageToolsDialogs/HomePageBatchProcessing/HomePageWatermark/HomePageWatermarkTemplateListBaseContentViewModel.cs
  59. 308 0
      PDF Office/ViewModels/Dialog/HomePageToolsDialogs/HomePageBatchProcessing/HomePageWatermark/HomePageWatermarkTemplateListFileContentViewModel.cs
  60. 265 0
      PDF Office/ViewModels/Dialog/HomePageToolsDialogs/HomePageBatchProcessing/HomePageWatermark/HomePageWatermarkTemplateListTextContentViewModel.cs
  61. 477 1913
      PDF Office/ViewModels/Dialog/HomePageToolsDialogs/HomePagePrinter/HomePagePrinterDialogViewModel.cs
  62. 2155 0
      PDF Office/ViewModels/Dialog/HomePageToolsDialogs/HomePagePrinter/HomePagePrinterDocumentContentViewModel.cs
  63. 43 3
      PDF Office/ViewModels/Dialog/HomePageToolsDialogs/HomePagePrinter/HomePagePrinterModBookletContentViewModel.cs
  64. 53 14
      PDF Office/ViewModels/Dialog/HomePageToolsDialogs/HomePagePrinter/HomePagePrinterModMultipleContentViewModel.cs
  65. 312 1
      PDF Office/ViewModels/Dialog/HomePageToolsDialogs/HomePagePrinter/HomePagePrinterModPosterContentViewModel.cs
  66. 38 80
      PDF Office/ViewModels/Dialog/HomePageToolsDialogs/HomePagePrinter/HomePagePrinterModSizeContentViewModel.cs
  67. 0 245
      PDF Office/ViewModels/Dialog/HomePageToolsDialogs/HomePagePrinter/HomePagePrinterPageSetDialogViewModel.cs
  68. 237 0
      PDF Office/ViewModels/Dialog/HomePageToolsDialogs/HomePagePrinter/HomePagePrinterPaperSettingsDialogViewModel.cs
  69. 0 14
      PDF Office/ViewModels/Dialog/HomePageToolsDialogs/HomePagePrinter/ModInfoSendEvent.cs
  70. 25 1
      PDF Office/ViewModels/EditTools/Background/BackgroundContentViewModel.cs
  71. 96 18
      PDF Office/ViewModels/EditTools/Background/BackgroundCreateColorContentViewModel.cs
  72. 121 16
      PDF Office/ViewModels/EditTools/Background/BackgroundCreateFileContentViewModel.cs
  73. 37 11
      PDF Office/ViewModels/EditTools/Background/BackgroundDocumentContentViewModel.cs
  74. 0 2
      PDF Office/ViewModels/EditTools/Background/BackgroundTemplateListColorContentViewModel.cs
  75. 1 0
      PDF Office/ViewModels/EditTools/Background/BackgroundTemplateListFileContentViewModel.cs
  76. 27 1
      PDF Office/ViewModels/EditTools/Bates/BatesContentViewModel.cs
  77. 732 1
      PDF Office/ViewModels/EditTools/Bates/BatesCreateContentViewModel.cs
  78. 230 2
      PDF Office/ViewModels/EditTools/Bates/BatesDocumentContentViewModel.cs
  79. 194 2
      PDF Office/ViewModels/EditTools/Bates/BatesTemplateListContentViewModel.cs
  80. 27 3
      PDF Office/ViewModels/EditTools/HeaderFooter/HeaderFooterContentViewModel.cs
  81. 756 1
      PDF Office/ViewModels/EditTools/HeaderFooter/HeaderFooterCreateContentViewModel.cs
  82. 283 2
      PDF Office/ViewModels/EditTools/HeaderFooter/HeaderFooterDocumentContentViewModel.cs
  83. 190 1
      PDF Office/ViewModels/EditTools/HeaderFooter/HeaderFooterTemplateListContentViewModel.cs
  84. 0 1
      PDF Office/ViewModels/EditTools/Watermark/WatermarkContentViewModel.cs
  85. 1 0
      PDF Office/ViewModels/EditTools/Watermark/WatermarkCreateBaseContentViewModel.cs
  86. 40 11
      PDF Office/ViewModels/EditTools/Watermark/WatermarkCreateFileContentViewModel.cs
  87. 124 101
      PDF Office/ViewModels/EditTools/Watermark/WatermarkCreateTextContentViewModel.cs
  88. 94 25
      PDF Office/ViewModels/EditTools/Watermark/WatermarkDocumentContentViewModel.cs
  89. 1 0
      PDF Office/ViewModels/EditTools/Watermark/WatermarkTemplateListFileContentViewModel.cs
  90. 1 0
      PDF Office/ViewModels/EditTools/Watermark/WatermarkTemplateListTextContentViewModel.cs
  91. 263 223
      PDF Office/ViewModels/HomePanel/PDFTools/QuickToolsContentViewModel.cs
  92. 1 1
      PDF Office/Views/Dialog/ConverterDialogs/ConverterCSVDialog.xaml
  93. 6 3
      PDF Office/Views/Dialog/ConverterDialogs/ConverterExcelDialog.xaml
  94. 1 1
      PDF Office/Views/Dialog/ConverterDialogs/ConverterHTMLDialog.xaml
  95. 1 1
      PDF Office/Views/Dialog/ConverterDialogs/ConverterPPTDialog.xaml
  96. 1 1
      PDF Office/Views/Dialog/ConverterDialogs/ConverterRTFDialog.xaml
  97. 1 1
      PDF Office/Views/Dialog/ConverterDialogs/ConverterTextDialog.xaml
  98. 1 1
      PDF Office/Views/Dialog/ConverterDialogs/ConverterWordDialog.xaml
  99. 65 0
      PDF Office/Views/Dialog/HomePageToolsDialogs/HomePageBatchProcessing/HomePageBackground/HomePageBackgroundCreateBaseContent.xaml
  100. 0 0
      PDF Office/Views/Dialog/HomePageToolsDialogs/HomePageBatchProcessing/HomePageBackground/HomePageBackgroundCreateBaseContent.xaml.cs

+ 7 - 1
PDF Office/App.config

@@ -1,7 +1,7 @@
 <?xml version="1.0" encoding="utf-8"?>
 <configuration>
     <configSections>
-        <sectionGroup name="userSettings" type="System.Configuration.UserSettingsGroup, System, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089" >
+        <sectionGroup name="userSettings" type="System.Configuration.UserSettingsGroup, System, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089">
             <section name="PDF_Office.Properties.Settings" type="System.Configuration.ClientSettingsSection, System, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089" allowExeDefinition="MachineToLocalUser" requirePermission="false" />
         </sectionGroup>
     </configSections>
@@ -24,6 +24,12 @@
       <setting name="WatermarkIndex" serializeAs="String">
         <value>0</value>
       </setting>
+      <setting name="BatesIndex" serializeAs="String">
+        <value>0</value>
+      </setting>
+      <setting name="HeaderFooterIndex" serializeAs="String">
+        <value>0</value>
+      </setting>
     </PDF_Office.Properties.Settings>
   </userSettings>
 </configuration>

+ 29 - 1
PDF Office/App.xaml.cs

@@ -47,6 +47,11 @@ using PDF_Office.Views.EditTools.Redaction;
 using PDF_Office.Views.Form;
 using PDF_Office.Views.PropertyPanel.PDFEdit;
 using PDF_Office.Views.Dialog.ToolsDialogs;
+using PDF_Office.Views.Dialog.HomePageToolsDialogs.HomePageBatchProcessing.HomePageHeaderFooter;
+using PDF_Office.Views.Dialog.HomePageToolsDialogs.HomePageBatchProcessing.HomePageBates;
+using PDF_Office.Views.Dialog.HomePageToolsDialogs.HomePageBatchProcessing.HomePageWatermark;
+using PDF_Office.Views.Dialog.HomePageToolsDialogs.HomePageBatchProcessing.HomePageBackground;
+
 
 namespace PDF_Office
 {
@@ -161,12 +166,35 @@ namespace PDF_Office
             containerRegistry.RegisterForNavigation<AnnotationContent>();
             containerRegistry.RegisterForNavigation<ReadViewContent>();
 
+
+            containerRegistry.RegisterForNavigation<HomePagePrinterDocumentContent>();
             containerRegistry.RegisterForNavigation<HomePagePrinterModSizeContent>();
             containerRegistry.RegisterForNavigation<HomePagePrinterModPosterContent>();
             containerRegistry.RegisterForNavigation<HomePagePrinterModMultipleContent>();
             containerRegistry.RegisterForNavigation<HomePagePrinterModBookletContent>();
             containerRegistry.RegisterForNavigation<HomePageCompressDialog>();
             containerRegistry.RegisterForNavigation<HomePageSetPasswordDialog>();
+            containerRegistry.RegisterForNavigation<HomePageRemoveDialog>();
+            containerRegistry.RegisterForNavigation<HomePageHeaderFooterDialog>();
+            containerRegistry.RegisterForNavigation<HomePageHeaderFooterTemplateListContent>();
+            containerRegistry.RegisterForNavigation<HomePageHeaderFooterCreateContent>();
+            containerRegistry.RegisterForNavigation<HomePageBatesDialog>();
+            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>();
@@ -244,7 +272,7 @@ namespace PDF_Office
             containerRegistry.RegisterDialog<HomePageInsertDialog>(DialogNames.HomePageInsertDialog);
             containerRegistry.RegisterDialog<HomePageSplitDialog>(DialogNames.HomePageSplitDialog);
             containerRegistry.RegisterDialog<HomePagePrinterDialog>(DialogNames.HomePagePrinterDialog);
-            containerRegistry.RegisterDialog<HomePagePrinterPageSetDialog>(DialogNames.HomePagePrinterPageSetDialog);
+            containerRegistry.RegisterDialog<HomePagePrinterPaperSettingsDialog>(DialogNames.HomePagePrinterPaperSettingsDialog);
             containerRegistry.RegisterDialog<HomePagePictureToPDFDialog>(DialogNames.HomePagePictureToPDFDialog);
             containerRegistry.RegisterDialog<HomePageBatchProcessingDialog>(DialogNames.HomePageBatchProcessingDialog);
             containerRegistry.RegisterDialog<DynamicPropertyDialog>(DialogNames.DynamicPropertyDialog);

+ 25 - 2
PDF Office/CustomControl/CommonWritableComboBox.xaml

@@ -6,6 +6,27 @@
              xmlns:local="clr-namespace:PDF_Office.CustomControl"
              mc:Ignorable="d" 
               d:DesignHeight="32" d:DesignWidth="66">
+    <UserControl.Resources>
+        <Style x:Key="PagesView_txtContext" TargetType="{x:Type TextBox}">
+            <Setter Property="Template">
+                <Setter.Value>
+                    <ControlTemplate TargetType="{x:Type TextBox}">
+                        <Border x:Name="Bd" BorderBrush="{TemplateBinding BorderBrush}" BorderThickness="{TemplateBinding BorderThickness}"
+                                    Background="{TemplateBinding Background}" SnapsToDevicePixels="True">
+                            <ScrollViewer x:Name="PART_ContentHost"/>
+                        </Border>
+                        <ControlTemplate.Triggers>
+                            <Trigger Property="IsEnabled" Value="false">
+                                <Setter Property="Background" TargetName="Bd" Value="{DynamicResource {x:Static SystemColors.ControlBrushKey}}"/>
+                                <Setter Property="Foreground" Value="{DynamicResource {x:Static SystemColors.GrayTextBrushKey}}"/>
+                            </Trigger>
+                        </ControlTemplate.Triggers>
+                    </ControlTemplate>
+                </Setter.Value>
+            </Setter>
+        </Style>
+    </UserControl.Resources>
+    
     <Border CornerRadius="1" BorderBrush="Black" BorderThickness="1,1,1,1" Panel.ZIndex="2">
     <Grid>
         <Grid.ColumnDefinitions>
@@ -28,10 +49,12 @@
                 TextAlignment="Left"
                 KeyDown="CurrentPage_KeyDown"
                 TextChanged="TextBox_Num_TextChanged"
-                 Panel.ZIndex="1">
+                 Panel.ZIndex="1"
+                 Style="{StaticResource PagesView_txtContext}">
          
             </TextBox>
-        <ComboBox Name="ComboBox_Type" MinHeight="28" MinWidth="64" HorizontalAlignment="Right" BorderThickness="00" Background="#F3F3F3" Grid.Column="0" Grid.ColumnSpan="2" SelectionChanged="ComboBox_SelectionChanged" ItemsSource="{Binding RelativeSource={RelativeSource Mode=FindAncestor, AncestorType=local:CommonWritableComboBox}, Path=TypeSouce}" Panel.ZIndex="0">
+        <ComboBox Name="ComboBox_Type" MinHeight="28" MinWidth="64" HorizontalAlignment="Right" BorderThickness="00" Background="#F3F3F3" Grid.Column="0" Grid.ColumnSpan="2" SelectionChanged="ComboBox_SelectionChanged" ItemsSource="{Binding RelativeSource={RelativeSource Mode=FindAncestor, AncestorType=local:CommonWritableComboBox}, Path=TypeSouce}" Panel.ZIndex="0"
+                  >
         </ComboBox>
 
     </Grid>

+ 3 - 3
PDF Office/CustomControl/NumericUpDown.xaml

@@ -5,7 +5,7 @@
     xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
     xmlns:local="clr-namespace:PDF_Office.CustomControl"
     xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
-    d:DesignHeight="40"
+    d:DesignHeight="32"
     d:DesignWidth="80"
     Background="#EEEEEE"
     FontSize="20"
@@ -19,7 +19,7 @@
             <TextBox
                 Name="TextBox_Num"
                 MinWidth="80"
-                MinHeight="20"
+                MinHeight="32"
                 Padding="16,0,0,0"
                 VerticalContentAlignment="Center"
                 Background="Transparent"
@@ -32,7 +32,7 @@
                 Text="{Binding RelativeSource={RelativeSource Mode=FindAncestor, AncestorType=local:NumericUpDown}, Path=Text}"
                 TextAlignment="Left"
                 TextChanged="TextBox_Num_TextChanged" />
-            <Grid Grid.Column="1" Width="20">
+            <Grid Grid.Column="1" Width="16">
                 <Grid.RowDefinitions>
                     <RowDefinition />
                     <RowDefinition />

+ 3 - 2
PDF Office/CustomControl/WritableComboBox.xaml

@@ -5,7 +5,7 @@
     xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
     xmlns:local="clr-namespace:PDF_Office.CustomControl"
     xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
-    d:DesignHeight="32"
+    d:DesignHeight="24"
     d:DesignWidth="200"
     mc:Ignorable="d">
     <Grid>
@@ -13,7 +13,7 @@
             x:Name="writableComboBox"
             Grid.Column="1"
             MinWidth="58"
-            MinHeight="32"
+            MinHeight="24"
             VerticalContentAlignment="Center"
             SelectionChanged="writableComboBox_SelectionChanged"
             SelectedIndex="{Binding RelativeSource={RelativeSource Mode=FindAncestor, AncestorType=local:WritableComboBox}, Path=SelectedIndex}"
@@ -26,6 +26,7 @@
         <TextBox
             x:Name="writableTextBox"
             Grid.Column="0"
+            Text="{Binding RelativeSource={RelativeSource Mode=FindAncestor, AncestorType=local:WritableComboBox}, Path=Text}"
             MinHeight="{Binding ElementName=writableComboBox, Path=MinHeight}"
             HorizontalAlignment="Left"
             VerticalContentAlignment="Center"

+ 11 - 0
PDF Office/CustomControl/WritableComboBox.xaml.cs

@@ -120,6 +120,15 @@ namespace PDF_Office.CustomControl
 
 
 
+        public ItemCollection Items
+        {
+            get { return (ItemCollection)GetValue(ItemsProperty); }
+            set { SetValue(ItemsProperty, value); }
+        }
+         
+        public static readonly DependencyProperty ItemsProperty =
+
+    DependencyProperty.Register("Items", typeof(ItemCollection), typeof(WritableComboBox), new PropertyMetadata());
         /// <summary>
         /// 把子控件的事件传递出去,方便绑定
         /// </summary>
@@ -136,6 +145,8 @@ namespace PDF_Office.CustomControl
         public WritableComboBox()
         {
             InitializeComponent();
+
+           this.Items = this.writableComboBox.Items;
         }
 
 

+ 41 - 0
PDF Office/EventAggregators/EditToolsEvent.cs

@@ -1,6 +1,8 @@
 using ComPDFKitViewer.PdfViewer;
 using PDF_Office.Model.EditTools.Background;
 using PDF_Office.Model.EditTools.Watermark;
+using PDF_Office.Model.EditTools.Bates;
+using PDF_Office.Model.EditTools.HeaderFooter;
 using PDFSettings;
 using Prism.Commands;
 using Prism.Events;
@@ -103,6 +105,18 @@ namespace PDF_Office.EventAggregators
         public WatermarkInfo Status;
     }
 
+    public class BatesInfoUnicode
+    {
+        public string Unicode;
+        public BatesInfo Status;
+    }
+
+    public class HeaderFooterInfoUnicode
+    {
+        public string Unicode;
+        public HeaderFooterInfo Status;
+    }
+
     public class BackgroundItemUnicode
     {
         public string Unicode;
@@ -122,6 +136,7 @@ namespace PDF_Office.EventAggregators
         public BatesHeaderFooterItem Status;
     }
 
+
     public class CPDFViewerUnicode
     {
         public string Unicode;
@@ -148,6 +163,12 @@ namespace PDF_Office.EventAggregators
     public class ConfirmEditToolsWatermarkEvent : PubSubEvent
     {
     }
+    public class ConfirmEditToolsBatesEvent : PubSubEvent<string>
+    {
+    }
+    public class ConfirmEditToolsHeaderFooterEvent : PubSubEvent<string>
+    {
+    }
 
     public class SetCurrentCreateModEvent : PubSubEvent<stringUnicode>
     {
@@ -165,6 +186,14 @@ namespace PDF_Office.EventAggregators
     {
     }
 
+    public class SetBatesEvent : PubSubEvent<BatesInfoUnicode>
+    {
+    }
+
+    public class SetHeaderFooterEvent : PubSubEvent<HeaderFooterInfoUnicode>
+    {
+    }
+
     public class SaveBackgroundTemplateEvent : PubSubEvent<EnumColorOrFileUnicode>
     {
     }
@@ -177,6 +206,18 @@ namespace PDF_Office.EventAggregators
     {
     }
 
+    public class DeleteBackgroundEvent : PubSubEvent<EnumDeleteUnicode>
+    {
+    }
+
+    public class DeleteBatesEvent : PubSubEvent<EnumDeleteUnicode>
+    {
+    }
+
+    public class DeleteHeaderFooterEvent : PubSubEvent<EnumDeleteUnicode>
+    {
+    }
+
     public class CurrentWatermarkPDFViewerEvent : PubSubEvent<CPDFViewerUnicode>
     {
     }

+ 46 - 0
PDF Office/EventAggregators/SendPrintInfoEvent.cs

@@ -0,0 +1,46 @@
+using PDF_Office.Model.Dialog.HomePageToolsDialogs.HomePagePrinter;
+using PDFSettings;
+using Prism.Events;
+using System;
+using System.Collections.Generic;
+using System.Linq;
+using System.Printing;
+using System.Security.Cryptography.X509Certificates;
+using System.Text;
+using System.Threading.Tasks;
+
+namespace PDF_Office.EventAggregators
+{
+
+    public class PrintSettingsInfoWithUnicode
+    {
+        public PrintSettingsInfo printSettingsInfo;
+        public string Unicode;
+    }
+
+    public class PrintModInfoWithUnicode
+    {
+        public PrintModInfo printModInfo;
+        public string Unicode;
+    }
+
+    public class PrintQueueWithUnicode
+    {
+        public PrintQueue printQueue;
+        public string Unicode;
+    }
+
+    public class SendPrintSettingsInfoEvent:PubSubEvent<PrintSettingsInfoWithUnicode>
+    {
+
+    }
+
+    public class SendPrintSettingsModInfoEvent:PubSubEvent<PrintModInfoWithUnicode>
+    {
+
+    }
+
+    public class SendPrintQueueEvent : PubSubEvent<PrintQueueWithUnicode>
+    {
+    }
+}

+ 163 - 6
PDF Office/Helper/ConverterHelper.cs

@@ -11,6 +11,8 @@ using static Dropbox.Api.Sharing.ListFileMembersIndividualResult;
 using ComPDFKit_Conversion.Options;
 using PDF_Office.CustomControl;
 using Exception = System.Exception;
+using ImageMagick;
+using System.IO.Compression;
 
 namespace PDF_Office.Helper
 {
@@ -22,6 +24,8 @@ namespace PDF_Office.Helper
         public static CPDFConverterTxt txtConverter = null;
         public static CPDFConverterCsv csvConverter = null;
         public static CPDFConverterImg imgConverter = null;
+        public static CPDFConverterRTF rtfConverter = null;
+        public static CPDFConverterHTML htmlConverter = null;
         public static async Task<bool> WordConvert(string inputpath, string outputpath, OnProgress getProgress, List<int> pageIndexLists, string pawssword)
         {
             bool result = false;
@@ -164,7 +168,84 @@ namespace PDF_Office.Helper
             return result;
         }
 
-        public static async Task<bool> ImgConvert(string inputpath, string outputpath, OnProgress getProgress, List<int> pageIndexLists,string pawssword, ImgType type)
+        public static void ImageMagickPDFToImage(string imageType,string filePath,string outputFolder,string outputFileName) {
+            ZipFile.ExtractToDirectory(filePath, outputFolder + "\\" + outputFileName);
+            var files = Directory.GetFiles(outputFolder + "\\" + outputFileName, "*.png");
+            int i=0;
+            var images = new MagickImageCollection();
+            foreach (var file in files)
+            {
+                //pdf整体转为gif,将.gifoff改为.gif
+                Trace.WriteLine(file);
+                if (imageType == ".gifoff") {
+                    images.Add(file);
+                    images[i].AnimationDelay = 100; // in this example delay is 1000ms/1sec
+                    images[i].Flip();
+                }
+                
+                using (var image = new MagickImage(file))
+                {
+                    if (imageType != ".gifoff")
+                    {
+                    //Save frame as jpg
+                    //image.Format = MagickFormat.Jp2;
+                    image.Write(file.Remove(file.LastIndexOf(".png"), 4) + imageType);
+                    }
+                    // 删除该文件
+                    System.IO.File.Delete(file);
+                }
+            }
+            if (imageType == ".gifoff")
+            {
+                // Optionally reduce colors
+                var settings = new QuantizeSettings();
+                settings.Colors = 256;
+                images.Quantize(settings);
+
+                // Optionally optimize the images (images should have the same size).
+                images.Optimize();
+
+                // Save gif
+                int fileIndex = 1;
+                if (File.Exists(outputFolder + "\\" + outputFileName + ".gif"))
+                {
+                    while (fileIndex >= 1)
+                    {
+                        if (!File.Exists(outputFolder + "\\" + outputFileName + "_" + fileIndex + ".gif"))
+                        {
+                            images.Write(outputFolder + "\\" + outputFileName + ".gif");
+                            fileIndex = -1;
+                        }
+                        fileIndex++;
+                    }
+                }
+                else { images.Write(outputFolder + "\\" + outputFileName + ".gif"); }
+               
+            }
+            else {
+                int fileIndex = 1;
+                
+                if (File.Exists(outputFolder + "\\" + outputFileName + ".zip"))
+                {
+                    while (fileIndex>=1) {
+                        if (!File.Exists(outputFolder + "\\" + outputFileName + "_" + fileIndex + ".zip"))
+                        {
+                            ZipFile.CreateFromDirectory(outputFolder + "\\" + outputFileName, outputFolder + "\\" + outputFileName + "_" + fileIndex + ".zip");
+                            fileIndex=-1;
+                        }
+                        fileIndex++;
+                    }
+                }
+                else { ZipFile.CreateFromDirectory(outputFolder + "\\" + outputFileName, outputFolder + "\\" + outputFileName + ".zip"); }
+                
+            }
+            DirectoryInfo di = new DirectoryInfo(outputFolder + "\\" + outputFileName);
+            di.Delete(true);
+
+
+        }       
+
+        public static async Task<bool> ImgConvert(string inputpath, string outputpath, OnProgress getProgress, List<int> pageIndexLists,string pawssword, ImgType type,string imageType=".png")
         {
             bool result = false;
             try
@@ -175,7 +256,36 @@ namespace PDF_Office.Helper
                 string outputFolder = outputpath;
                 string outputFileName = Path.GetFileNameWithoutExtension(inputpath);
                 ConvertError error = ConvertError.ERR_UNKNOWN;
-                result = await Task.Run(() => imgConverter.Convert(outputFolder, ref outputFileName, pageArray, type, ref error, getProgress));
+                if (imageType == ".png" || imageType == ".jpg")
+                {
+                    result = await Task.Run(() => imgConverter.Convert(outputFolder, ref outputFileName, pageArray, type, ref error, getProgress));
+                }
+                else
+                { //创建缓存文件夹
+                   
+                    string folderPath = Path.Combine(App.CurrentPath, "ConverterImg");
+                    //有可能因为其他原因存在同名文件,导致创建文件夹失败,需要先删除同名文件
+                    //保险措施(猜测)
+                    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);
+                     result = await Task.Run(() => imgConverter.Convert(folderPath, ref saveName, pageArray, type, ref error, getProgress));
+                    ImageMagickPDFToImage(imageType, saveName, outputFolder, outputFileName);
+                    DirectoryInfo di = new DirectoryInfo(folderPath);
+                    di.Delete(true);
+                }
+                
                 if (result)
                 {
                     if (File.Exists(outputFileName))
@@ -189,6 +299,49 @@ namespace PDF_Office.Helper
             return result;
         }
 
+        public static async Task<bool> RTFConvert(string inputpath, string outputpath, OnProgress getProgress, List<int> pageIndexLists, string pawssword)
+        {
+            bool result = false;
+            try
+            {
+                int[] pageArray = pageIndexLists.ToArray();
+                rtfConverter = new CPDFConverterRTF(inputpath, pawssword);
+                string outputFolder = outputpath;
+                string outputFileName = Path.GetFileNameWithoutExtension(inputpath);
+                ConvertError error = ConvertError.ERR_UNKNOWN;
+                result = await Task.Run(() => rtfConverter.Convert(outputFolder, ref outputFileName, pageArray, ref error, getProgress));
+            }
+            catch (Exception ex)
+            {
+
+            }
+            return result;
+        }
+
+        public static async Task<bool> HTMLConvert(string inputpath, string outputpath, OnProgress getProgress, List<int> pageIndexLists, string pawssword, CPDFConvertHTMLOptions HtmlOption)
+        {
+            bool result = false;
+            try
+            {
+                htmlConverter = new CPDFConverterHTML(inputpath, pawssword);
+                int[] pageArray = pageIndexLists.ToArray();
+
+                string outputFolder = outputpath;
+                string outputFileName = Path.GetFileNameWithoutExtension(inputpath);
+                ConvertError error = ConvertError.ERR_UNKNOWN;
+                result = await Task.Run(() => htmlConverter.Convert(outputFolder, ref outputFileName, HtmlOption, pageArray, ref error, getProgress));
+                if (result)
+                {
+                    
+                }
+            }
+            catch (Exception ex)
+            {
+
+            }
+            return result;
+        }
+
         public static void Clear()
         {
             if (wordConverter != null)
@@ -207,14 +360,18 @@ namespace PDF_Office.Helper
             {
                 txtConverter.Cancel();
             }
-            //if (tableConverter != null)
-            //{
-            //    tableConverter.Cancel();
-            //}
             if (csvConverter != null)
             {
                 csvConverter.Cancel();
             }
+            if (rtfConverter != null)
+            {
+                rtfConverter.Cancel();
+            }
+            if (htmlConverter != null)
+            {
+                htmlConverter.Cancel();
+            }
             Console.WriteLine("killed");
         }
         private static void StartFile(string path)

+ 1 - 1
PDF Office/Helper/EditToolsHelper.cs

@@ -36,10 +36,10 @@ namespace PDF_Office.Helper
         public static Color ConvertColor(byte[] rgb_array)
         {
             Color color = new Color();
+            color.A = 0xFF;
             color.R = rgb_array[0];
             color.G = rgb_array[1];
             color.B = rgb_array[2];
-
             return color;
         }
 

+ 10 - 1
PDF Office/Model/Dialog/ConverterDialogs/ConverterHTMLDialogModel.cs

@@ -1,4 +1,5 @@
-using System;
+using ComPDFKit_Conversion.Options;
+using System;
 using System.Collections.Generic;
 using System.Linq;
 using System.Text;
@@ -8,5 +9,13 @@ namespace PDF_Office.Model.Dialog.ConverterDialogs
 {
     public class ConverterHTMLDialogModel : ConverterDialogsModel
     {
+        public CPDFConvertHTMLOptions htmlOption = new CPDFConvertHTMLOptions();
+
+        public CPDFConvertHTMLOptions HTMLOptions(PageAndNavigationPaneOptions pageAndNavigationPaneOptions = PageAndNavigationPaneOptions.MultiplePages)
+        {
+
+            htmlOption.PageAndNavigationPaneOpts = pageAndNavigationPaneOptions;
+            return htmlOption;
+        }
     }
 }

+ 2 - 1
PDF Office/Model/Dialog/ConverterDialogs/ConverterImgDialogModel.cs

@@ -9,7 +9,8 @@ namespace PDF_Office.Model.Dialog.ConverterDialogs
 {
     public class ConverterImgDialogModel : ConverterDialogsModel
     {
-        public ImgType Type =ImgType.JPEG;
+        public ImgType Type =ImgType.PNG;
         public string DPI = "50";
+        public string imageType = ".jpeg";
     }
 }

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

@@ -12,7 +12,7 @@ namespace PDF_Office.Model.Dialog.HomePageToolsDialogs.HomePageBatchProcessing
 
         public static List<string> FilePaths=new List<string>();
 
-        public static List<string> GetBatchProcessing = new List<string> { "HomePageConverterDialog", "HomePageCompressDialog", "HomePageSetPasswordDialog", "HomePageWatermarkDialog", "HomePageBackgroundDialog", "HomePageHeaderFooterDialog", "HomePageBatesDialog", "HomePageDeleteSafetySettintgsDialog" };
+        public static List<string> GetBatchProcessing = new List<string> { "HomePageConverterDialog", "HomePageCompressDialog", "HomePageSetPasswordDialog", "HomePageWatermarkDialog", "HomePageBackgroundDialog", "HomePageHeaderFooterDialog", "HomePageBatesDialog", "HomePageRemoveDialog" };
 
     }
 }

+ 10 - 1
PDF Office/Model/Dialog/HomePageToolsDialogs/HomePageBatchProcessing/HomePageConverter/HomePageConverterHTMLModel.cs

@@ -1,4 +1,5 @@
-using System;
+using ComPDFKit_Conversion.Options;
+using System;
 using System.Collections.Generic;
 using System.Linq;
 using System.Text;
@@ -8,5 +9,13 @@ namespace PDF_Office.Model.Dialog.HomePageToolsDialogs.HomePageBatchProcessing.H
 {
     public class HomePageConverterHTMLModel : HomePageConverterDialogModel
     {
+        public CPDFConvertHTMLOptions htmlOption = new CPDFConvertHTMLOptions();
+
+        public CPDFConvertHTMLOptions HTMLOptions(PageAndNavigationPaneOptions pageAndNavigationPaneOptions = PageAndNavigationPaneOptions.MultiplePages)
+        {
+
+            htmlOption.PageAndNavigationPaneOpts = pageAndNavigationPaneOptions;
+            return htmlOption;
+        }
     }
 }

+ 1 - 0
PDF Office/Model/Dialog/HomePageToolsDialogs/HomePageBatchProcessing/HomePageConverter/HomePageConverterImgModel.cs

@@ -10,6 +10,7 @@ namespace PDF_Office.Model.Dialog.HomePageToolsDialogs.HomePageBatchProcessing.H
     public class HomePageConverterImgModel : HomePageConverterDialogModel
     {
         public ImgType Type = ImgType.JPEG;
+        public string imageType = ".jpeg";
         public string DPI = "50";
     }
 }

+ 90 - 64
PDF Office/Model/Dialog/HomePageToolsDialogs/HomePagePrinter/HomePagePrinterDialogModel.cs

@@ -3,6 +3,7 @@ using System.Collections.Generic;
 using System.Drawing.Printing;
 using System.Linq;
 using System.Numerics;
+using System.Printing;
 using System.Runtime.Remoting.Channels;
 using System.Text;
 using System.Threading.Tasks;
@@ -12,44 +13,71 @@ namespace PDF_Office.Model.Dialog.HomePageToolsDialogs.HomePagePrinter
 {
     public class PrintSettingsInfo
     {
-        public bool IsBlackAndWhite { get; set; }
-        public bool IsReverseOrder { get; set; }
-        public EnumPaperSize EnumPaperSize { get; set; }
-        public EnumPageRange EnumPageRange { get; set; }
+        /// <summary>
+        /// 灰度
+        /// </summary>
+        public bool IsGrayscale { get; set; }
+        /// <summary>
+        /// 纸张尺寸
+        /// </summary>
+        public PageMediaSize PageMediaSize;
+        /// <summary>
+        /// 页码范围
+        /// </summary>
+        public EnumPageRange EnumPageRange = EnumPageRange.StatusAllRange;
+        /// <summary>
+        /// 逆页序
+        /// </summary>
         public bool IsIndexReverse { get; set; }
-        public EnumPrintOrientation EnumPrintOrientation { get; set; }
-        public bool PrintWithAnnot { get; set; }
-        public bool PrintWithForm { get; set; }
+
+        /// <summary>
+        /// 双面打印
+        /// </summary>
+        public bool IsDuplex = false;
+
+        /// <summary>
+        /// 是否打印页面边框
+        /// </summary>
+        public bool IsPrintPageBorde = false;
+        /// <summary>
+        /// 打印方向
+        /// </summary>
+        public EnumPrintOrientation EnumPrintOrientation = EnumPrintOrientation.StatusPortrait;
+        /// <summary>
+        /// 带Annot
+        /// </summary>
+        public bool IsPrintWithAnnot { get; set; }
+        /// <summary>
+        /// 带Form
+        /// </summary>
+        public bool IsPrintWithForm { get; set; }
+        /// <summary>
+        /// Copies
+        /// </summary>
         public int Copies { get; set; }
+        /// <summary>
+        /// 打印机名称
+        /// </summary>
         public string PrinterName { get; set; }
-        public string CustomizeRange { get; set; }
-        public PrintMod printMod { get; set; }
+        /// <summary>
+        /// 自定义打印页码范围
+        /// </summary>
+        public List<int> PageRangeList = new List<int>();
+        /// <summary>
+        /// 打印Mod
+        /// </summary>
+        public PrintModInfo printModInfo  = new SizeInfo();
+
+
+        public bool IsBothSides = false;
+
+        public List<int> Margin = new List<int>();
     }
 
     public class HomePagePrinterDialogModel
     {
-      
-    }
-
-    public enum EnumPaperSize
-    { 
-        StatusA3,
-        StatusA4,
-        StatusA5,
-        StatusB5,
-        StatusNo10Envelope,
-        StatusChoukei3Envelope,
-        StatusDLEnvelope,
-        StatusJISB5,
-        StatusROC16K,
-        StatusExtraLargeBA3,
-        StatusTabloid,
-        StatusExraLargeTabloid,
-        StatusAmericanLegal,
-        StatusAmericanLetter,
-        StatusCustomized
-    }
 
+    } 
 
 
     public enum EnumSizeType
@@ -62,7 +90,6 @@ namespace PDF_Office.Model.Dialog.HomePageToolsDialogs.HomePagePrinter
     public enum EnumPageRange
     {
         StatusAllRange,
-        StatusCurrentRange,
         StatusOddRange,
         StatusEvenRange,
         StatusCustomizedRange
@@ -70,15 +97,16 @@ namespace PDF_Office.Model.Dialog.HomePageToolsDialogs.HomePagePrinter
 
     public enum EnumPrintOrientation
     {
-        StatusLandscape,
-        StatusPortrait
+        StatusPortrait,
+        StatusLandscape
     }
 
     public enum EnumPrintContent
     {
         StatusOnlyDocument,
         StatusDocumentAndMarkUps,
-        StatusDocumentAndForm,
+        StatusDocumentAndStamps,
+        StatusDocumentAndForm
     }
 
     public enum EnumPrintMod
@@ -123,54 +151,52 @@ namespace PDF_Office.Model.Dialog.HomePageToolsDialogs.HomePagePrinter
     public enum EnumBookletBinding
     {
         StatusLeft,
-        StatusRight,
+        StatusRight
     }
 
-    public abstract class PrintMod { }
 
-    public class SizeInfo : PrintMod
+    public class PrintModInfo
     {
-        public EnumSizeType EnumSizeType { get; set; }
-        public int DisplayRatio { get; set; }
+        public EnumPrintMod EnumPrintMod = EnumPrintMod.StatusSize;
     }
 
-
-    public class PosterInfo : PrintMod
+    public class SizeInfo : PrintModInfo
     {
-        public EnumPosterMod EnumPosterMod; 
-        public bool HasCutMarks { get; set; }
-        public bool HasLabel { get; set; }
-        public double OverLap { get; set; }
+        public EnumSizeType EnumSizeType = EnumSizeType.StatusAdaptive;
+        public int DisplayRatio = 100;
     }
 
-    public class PostModTileInfo : PosterInfo
-    {
-        public int TileRatio { get; set; }
-    }
 
-    public class PostModSplitInfo : PosterInfo
+    public class PosterInfo : PrintModInfo
     {
+        public EnumPosterMod EnumPosterMod;
+        public bool HasCutMarks { get; set; }
+        public bool HasLabel { get; set; }
+        public double OverLap { get; set; }
         public EnumDisplayPageNumber EnumDisplayPageNumber { get; set; }
+        public int HorizontalSheetNumber { get; set; }
+        public int VerticalSheetNumber { get; set; }
         public int TileRatio { get; set; }
-        public int WidthPartNumber { get; set; }
-        public int HeightPartNumber { get; set; }
+
+        public string Label;
+
     }
 
-    public class MultipleInfo : PrintMod
+    public class MultipleInfo : PrintModInfo
     {
-        public EnumPageOrder EnumPageOrder { set; get; }
-        public EnumDisplayPageNumber EnumDisplayPageNumber { get; set; }
-        public int HorizontalPageNumber { get; set; }
-        public int VerticalPageNumber { get; set; }
-        public bool IsAutoRotate { get; set; }
+        public EnumPageOrder EnumPageOrder = EnumPageOrder.StatusHorizontalOrder;
+        public EnumDisplayPageNumber EnumDisplayPageNumber = EnumDisplayPageNumber.StatusTwo;
+        public int HorizontalPageNumber = 2;
+        public int VerticalPageNumber = 1;
+        public bool IsAutoRotate  = false;
     }
 
-    public class BookletInfo : PrintMod
+    public class BookletInfo : PrintModInfo
     {
-        public EnumBookletSubset EnumBookletSubset { get; set; }
-        public EnumBookletBinding EnumBookletBinding { get; set; }
-        public int BeginPaperIndex { get; set; }
-        public int EndPaperIndex { get; set; }
-        public bool IsAutoRotate { get; set; }
+        public EnumBookletSubset EnumBookletSubset = EnumBookletSubset.StatusBothSides;
+        public EnumBookletBinding EnumBookletBinding = EnumBookletBinding.StatusLeft;
+        public int BeginPaperIndex = 1;
+        public int EndPaperIndex = 1;
+        public bool IsAutoRotate = false;
     }
 }

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

@@ -89,7 +89,7 @@ namespace PDF_Office.Model
         ///<summary>
         ///打印弹窗-打印页面设置
         /// </summary>
-        public static string HomePagePrinterPageSetDialog = "HomePagePrinterPageSetDialog";
+        public static string HomePagePrinterPaperSettingsDialog = "HomePagePrinterPaperSettingsDialog";
 
         ///<summary>
         ///主页工具-图片转PDF弹窗

+ 6 - 10
PDF Office/Model/EditTools/Background/BackgroundCreateModel.cs

@@ -44,15 +44,6 @@ namespace PDF_Office.Model.EditTools.Background
         /// </summary>
         public byte Opacity;
         
-        /// <summary>
-        /// 是否相对比例
-        /// </summary>
-        public bool IsRelativeRatio;
-        
-        /// <summary>
-        ///相对比例大小 
-        /// </summary>
-        public int RelativeRatio;
 
         /// <summary>
         /// 
@@ -103,5 +94,10 @@ namespace PDF_Office.Model.EditTools.Background
         /// 3:自定义页
         /// </summary>
         public int PageRangeIndex = 0;
-    }
+
+        /// <summary>
+        /// -
+        /// </summary>
+        public bool IsRelativeScale = true;
+     }
 }

+ 88 - 0
PDF Office/Model/EditTools/Bates/BatesCreateModel.cs

@@ -0,0 +1,88 @@
+using System;
+using System.Collections.Generic;
+using PDFSettings;
+using System.Linq;
+using System.Text;
+using System.Threading.Tasks;
+
+namespace PDF_Office.Model.EditTools.Bates
+{
+    public class BatesCreateModel
+    {
+    }
+    public class BatesInfo
+    {
+        /// <summary>
+        /// 模板名称
+        /// </summary>
+        public string ItemName = "";
+        /// <summary>
+        /// 内容
+        /// </summary>
+        public contentItem[] TextData = new contentItem[6];
+        /// <summary>
+        /// 间距
+        /// </summary>
+        /// 
+        public float[] margin = new float[4];
+        
+
+        /// <summary>
+        /// 起始页
+        /// </summary>
+        public int StarPagetNumber = 1;
+
+        /// <summary>
+        /// 贝茨码:前缀
+        /// </summary>
+        public string Prefix = "";
+
+        /// <summary>
+        /// 贝茨码:后缀
+        /// </summary>
+        public string Suffix = "";
+
+        /// <summary>
+        /// 贝茨码:位数
+        /// </summary>
+        public int DigitNumber = 1;
+
+        /// <summary>
+        /// 页面范围
+        /// </summary>
+        public string PageRange = "0";
+
+        /// <summary>
+        /// 页面范围索引;
+        /// 0:全部页面
+        /// 1:奇数页
+        /// 2;偶数页
+        /// 3:自定义页
+        /// </summary>
+        public int PageRangeIndex = 0;
+    }
+
+    //public struct contentItem
+    //{
+    //    public BateHeaderFooter_ContentType textTag;
+    //    public string text;
+    //    public string fontName;
+    //    public float fontSize;
+
+    //    /// <summary>
+    //    /// 纯色背景颜色
+    //    /// </summary>
+    //    public byte[] Color;
+    //}
+
+    //public enum BateHeaderFooter_ContentType
+    //{
+    //    L_Header,
+    //    C_Header,
+    //    R_Header,
+    //    L_Footer,
+    //    C_Footer,
+    //    R_Footer
+    //}
+
+}

+ 82 - 0
PDF Office/Model/EditTools/HeaderFooter/HeaderFooterCreateModel.cs

@@ -0,0 +1,82 @@
+using System;
+using System.Collections.Generic;
+using PDFSettings;
+using System.Linq;
+using System.Text;
+using System.Threading.Tasks;
+
+namespace PDF_Office.Model.EditTools.HeaderFooter
+{
+    public class HeaderFooterCreateModel
+    {
+    }
+
+    public class HeaderFooterInfo {
+        /// <summary>
+        /// 模板名称
+        /// </summary>
+        public string ItemName = "";
+        /// <summary>
+        /// 内容
+        /// </summary>
+        public contentItem[] TextData = new contentItem[6];
+        /// <summary>
+        /// 间距
+        /// </summary>
+        /// 
+        public float[] margin = new float[4];
+
+        /// <summary>
+        /// 起始页
+        /// </summary>
+        public int StarPagetNumber = 1;
+
+
+        /// <summary>
+        /// 页眉页脚:页码格式
+        /// </summary>
+        public string PageNumberFormat = "1";
+        /// <summary>
+        /// 页眉页脚:日期格式
+        /// </summary>
+        public string DateTimeFormat = "m/d";
+
+        /// <summary>
+        /// 页面范围
+        /// </summary>
+        public string PageRange = "0";
+
+        /// <summary>
+        /// 页面范围索引;
+        /// 0:全部页面
+        /// 1:奇数页
+        /// 2;偶数页
+        /// 3:自定义页
+        /// </summary>
+        public int PageRangeIndex = 0;
+    }
+
+    //public struct contentItem
+    //{
+    //    public BateHeaderFooter_ContentType textTag;
+    //    public string text;
+    //    public string fontName;
+    //    public float fontSize;
+    //    /// <summary>
+    //    /// 纯色背景颜色
+    //    /// </summary>
+    //    public byte[] Color;
+    //}
+
+    //public enum BateHeaderFooter_ContentType
+    //{
+    //    L_Header,
+    //    C_Header,
+    //    R_Header,
+    //    L_Footer,
+    //    C_Footer,
+    //    R_Footer
+    //}
+
+}
+

+ 5 - 0
PDF Office/Model/EditTools/Watermark/WatermarkCreateModel.cs

@@ -129,5 +129,10 @@ namespace PDF_Office.Model.EditTools.Watermark
         /// </summary>
         public bool IsFront = false;
 
+        /// <summary>
+        /// 水印是否自适应比例;
+        /// </summary>
+        public bool IsRelativeScale = false;
+
     }
 }

+ 51 - 45
PDF Office/Model/ParameterNames.cs

@@ -5,56 +5,56 @@ using System.Text;
 using System.Threading.Tasks;
 
 namespace PDF_Office.Model
-{
+{
     /// <summary>
     /// 记录常用的参数的Key名称,防止String写错
     /// </summary>
-    public static class ParameterNames
-    {
+    public static class ParameterNames
+    {
         #region ViewModelName
 
-        public static string MainViewModel = "MainViewModel";
-
-        public static string ViewContentViewModel = "ViewContentViewModel";
-
+        public static string MainViewModel = "MainViewModel";
+
+        public static string ViewContentViewModel = "ViewContentViewModel";
+
         public static string PropertyPanelContentViewModel = "PropertyPanelContentViewModel";
-
+
         #endregion ViewModelName
-
-        public static string PDFViewer = "PDFViewer";
-
-        public static string FilePath = "FilePath";
-
-        public static string PassWord = "PassWord";
-
-        public static string PDFDocument = "PDFDocument";
-
-        public static string AddTab = "AddTab";
-
-        public static string InsertType_File = "Insert_File";
-
-        public static string InsertType_Blank = "Insert_Blank";
-
-        public static string InsertType_Custom = "Insert_Custom";
-
-        public static string BatchProcessing_Name = "BatchProcessing_Name";
-
+
+        public static string PDFViewer = "PDFViewer";
+
+        public static string FilePath = "FilePath";
+
+        public static string PassWord = "PassWord";
+
+        public static string PDFDocument = "PDFDocument";
+
+        public static string AddTab = "AddTab";
+
+        public static string InsertType_File = "Insert_File";
+
+        public static string InsertType_Blank = "Insert_Blank";
+
+        public static string InsertType_Custom = "Insert_Custom";
+
+        public static string BatchProcessing_Name = "BatchProcessing_Name";
+
         /// <summary>
         /// 书签
         /// </summary>
-        public static string Bookmark = "Bookmark";
-
-        public static string Title = "Title";
-
-        public static string BookmarkInfo = "BookmarkInfo";
-
-        /// <summary>
-        /// 注释列表
+        public static string Bookmark = "Bookmark";
+
+        public static string Title = "Title";
+
+        public static string BookmarkInfo = "BookmarkInfo";
+
+        /// <summary>
+        /// 注释列表
         /// </summary>
-
-        public static string Annotation = "Annotation";
+
+        public static string Annotation = "Annotation";
         public static string AnnotEvent = "AnnotEvent";
-        public static string AnnotationList = "AnnotationList";
+        public static string AnnotationList = "AnnotationList";
         public static string AnnotArgsTypes = "AnnotArgsTypes";
         public static string AnnotationColors = "AnnotationColors";
         public static string AnnotationAuthor = "AnnotationAuthor";
@@ -62,18 +62,18 @@ namespace PDF_Office.Model
         /// <summary>
         /// 底部工具栏
         /// </summary>
-        public static string BottomToolContentViewModel = "BottomToolContentViewModel";
-
+        public static string BottomToolContentViewModel = "BottomToolContentViewModel";
+
         /// <summary>
         /// BOTA缩略图
         /// </summary>
-        public static string BOTAThumb = "Thumbnail";
-
+        public static string BOTAThumb = "Thumbnail";
+
         /// <summary>
         /// 用于弹窗传参的数据模型
         /// </summary>
-        public static string DataModel = "Model";
-
+        public static string DataModel = "Model";
+
         /// <summary>
         /// 转换类型
         /// </summary>
@@ -82,6 +82,12 @@ namespace PDF_Office.Model
         /// <summary>
         /// 用于转换数据模型
         /// </summary>
-        public static string ConverterTypeModel = "ConverterTypeModel";
+        public static string ConverterTypeModel = "ConverterTypeModel";
+
+        /// <summary>
+        /// 打印
+        /// </summary>
+        public static string PrintQueue = "PrintQueue";
+        public static string PrintSettingsInfo = "PrintSettingsInfo";
     }
 }

+ 15 - 0
PDF Office/Model/RegionNames.cs

@@ -66,6 +66,21 @@ namespace PDF_Office.Model
             }
         }
 
+        public static string BatesViewerRegionName
+        {
+            get
+            {
+                return GetRegionName("BatesViewerRegionName");
+            }
+        }
+        public static string HeaderFooterViewerRegionName
+        {
+            get
+            {
+                return GetRegionName("HeaderFooterViewerRegionName");
+            }
+        }
+
         public static string RedactionViewerRegionName
         {
             get

+ 245 - 15
PDF Office/PDF Office.csproj

@@ -17,6 +17,21 @@
     <Deterministic>true</Deterministic>
     <NuGetPackageImportStamp>
     </NuGetPackageImportStamp>
+    <PublishUrl>publish\</PublishUrl>
+    <Install>true</Install>
+    <InstallFrom>Disk</InstallFrom>
+    <UpdateEnabled>false</UpdateEnabled>
+    <UpdateMode>Foreground</UpdateMode>
+    <UpdateInterval>7</UpdateInterval>
+    <UpdateIntervalUnits>Days</UpdateIntervalUnits>
+    <UpdatePeriodically>false</UpdatePeriodically>
+    <UpdateRequired>false</UpdateRequired>
+    <MapFileExtensions>true</MapFileExtensions>
+    <ApplicationRevision>0</ApplicationRevision>
+    <ApplicationVersion>1.0.0.%2a</ApplicationVersion>
+    <IsWebBootstrapper>false</IsWebBootstrapper>
+    <UseApplicationTrust>false</UseApplicationTrust>
+    <BootstrapperEnabled>true</BootstrapperEnabled>
   </PropertyGroup>
   <PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|AnyCPU' ">
     <PlatformTarget>AnyCPU</PlatformTarget>
@@ -90,6 +105,12 @@
     <Reference Include="Google.Apis.PlatformServices, Version=1.57.0.0, Culture=neutral, PublicKeyToken=4b01fa6e34db77ab, processorArchitecture=MSIL">
       <HintPath>packages\Google.Apis.1.57.0\lib\net45\Google.Apis.PlatformServices.dll</HintPath>
     </Reference>
+    <Reference Include="Magick.NET-Q16-AnyCPU, Version=12.2.0.0, Culture=neutral, PublicKeyToken=2004825badfa91ec, processorArchitecture=MSIL">
+      <HintPath>packages\Magick.NET-Q16-AnyCPU.12.2.2\lib\netstandard20\Magick.NET-Q16-AnyCPU.dll</HintPath>
+    </Reference>
+    <Reference Include="Magick.NET.Core, Version=12.2.0.0, Culture=neutral, PublicKeyToken=2004825badfa91ec, processorArchitecture=MSIL">
+      <HintPath>packages\Magick.NET.Core.12.2.2\lib\netstandard20\Magick.NET.Core.dll</HintPath>
+    </Reference>
     <Reference Include="Microsoft.AppCenter, Version=0.0.0.0, Culture=neutral, PublicKeyToken=8a600e2fee7ba272, processorArchitecture=MSIL">
       <HintPath>packages\Microsoft.AppCenter.4.5.0\lib\net461\Microsoft.AppCenter.dll</HintPath>
     </Reference>
@@ -130,6 +151,7 @@
     <Reference Include="Prism.Wpf, Version=8.1.97.5141, Culture=neutral, PublicKeyToken=40ee6c3a2184dc59, processorArchitecture=MSIL">
       <HintPath>packages\Prism.Wpf.8.1.97\lib\net461\Prism.Wpf.dll</HintPath>
     </Reference>
+    <Reference Include="ReachFramework" />
     <Reference Include="SQLitePCLRaw.batteries_v2, Version=2.0.2.669, Culture=neutral, PublicKeyToken=8226ea5df37bcae9, processorArchitecture=MSIL">
       <HintPath>packages\SQLitePCLRaw.bundle_green.2.0.2\lib\net461\SQLitePCLRaw.batteries_v2.dll</HintPath>
     </Reference>
@@ -150,6 +172,7 @@
     <Reference Include="System.Data" />
     <Reference Include="System.Deployment" />
     <Reference Include="System.Drawing" />
+    <Reference Include="System.IO.Compression.FileSystem" />
     <Reference Include="System.Management" />
     <Reference Include="System.Memory, Version=4.0.1.1, Culture=neutral, PublicKeyToken=cc7b13ffcd2ddd51, processorArchitecture=MSIL">
       <HintPath>packages\System.Memory.4.5.3\lib\netstandard2.0\System.Memory.dll</HintPath>
@@ -158,6 +181,7 @@
     <Reference Include="System.Numerics.Vectors, Version=4.1.3.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a, processorArchitecture=MSIL">
       <HintPath>packages\System.Numerics.Vectors.4.4.0\lib\net46\System.Numerics.Vectors.dll</HintPath>
     </Reference>
+    <Reference Include="System.Printing" />
     <Reference Include="System.Runtime.CompilerServices.Unsafe, Version=4.0.4.1, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a, processorArchitecture=MSIL">
       <HintPath>packages\System.Runtime.CompilerServices.Unsafe.4.5.2\lib\netstandard2.0\System.Runtime.CompilerServices.Unsafe.dll</HintPath>
     </Reference>
@@ -263,6 +287,7 @@
     <Compile Include="EventAggregators\EditToolsEvent.cs" />
     <Compile Include="EventAggregators\PageEditNotifyEvent.cs" />
     <Compile Include="EventAggregators\PageEditRefreshEvent.cs" />
+    <Compile Include="EventAggregators\SendPrintInfoEvent.cs" />
     <Compile Include="Helper\CacheFilePath.cs" />
     <Compile Include="Helper\ConverterHelper.cs" />
     <Compile Include="Helper\DpiHelpers.cs" />
@@ -327,6 +352,8 @@
     <Compile Include="Model\Dialog\HomePageToolsDialogs\HomePageSplitDialogModel.cs" />
     <Compile Include="Model\EditTools\Background\BackgroundCreateModel.cs" />
     <Compile Include="Model\EditTools\Background\BackgroundTemplateListModel.cs" />
+    <Compile Include="Model\EditTools\Bates\BatesCreateModel.cs" />
+    <Compile Include="Model\EditTools\HeaderFooter\HeaderFooterCreateModel.cs" />
     <Compile Include="Model\EditTools\Watermark\WatermarkCreateModel.cs" />
     <Compile Include="Model\EditTools\Watermark\WatermarkTemplateListModel.cs" />
     <Compile Include="Model\From\FormFieldType.cs" />
@@ -354,6 +381,9 @@
     </Compile>
     <Compile Include="ViewModels\Dialog\HomePageToolsDialogs\CreateFromHtmlDialogViewModel.cs" />
     <Compile Include="ViewModels\Dialog\ToolsDialogs\MergeDialogViewModel.cs" />
+    <Compile Include="ViewModels\Dialog\HomePageToolsDialogs\HomePageBatchProcessing\HomePageRemoveDialogViewModel.cs" />
+    <Compile Include="ViewModels\Dialog\HomePageToolsDialogs\HomePagePrinter\HomePagePrinterDocumentContentViewModel.cs" />
+    <Compile Include="ViewModels\Dialog\HomePageToolsDialogs\HomePagePrinter\HomePagePrinterPaperSettingsDialogViewModel.cs" />
     <Compile Include="ViewModels\EditTools\Bates\BatesContentViewModel.cs" />
     <Compile Include="ViewModels\EditTools\Bates\BatesCreateContentViewModel.cs" />
     <Compile Include="ViewModels\EditTools\Bates\BatesDocumentContentViewModel.cs" />
@@ -406,6 +436,26 @@
     <Compile Include="ViewModels\Form\RadioButtonPropertyViewModel.cs" />
     <Compile Include="ViewModels\Form\SignPropertyViewModel.cs" />
     <Compile Include="ViewModels\Form\TextFieldPropertyViewModel.cs" />
+    <Compile Include="ViewModels\Dialog\HomePageToolsDialogs\HomePageBatchProcessing\HomePageBackground\HomePageBackgroundDialogViewModel.cs" />
+    <Compile Include="ViewModels\Dialog\HomePageToolsDialogs\HomePageBatchProcessing\HomePageBates\HomePageBatesDialogViewModel.cs" />
+    <Compile Include="ViewModels\Dialog\HomePageToolsDialogs\HomePageBatchProcessing\HomePageHeaderFooter\HomePageHeaderFooterDialogViewModel.cs" />
+    <Compile Include="ViewModels\Dialog\HomePageToolsDialogs\HomePageBatchProcessing\HomePageWatermark\HomePageWatermarkDialogViewModel.cs" />
+    <Compile Include="ViewModels\Dialog\HomePageToolsDialogs\HomePageBatchProcessing\HomePageHeaderFooter\HomePageHeaderFooterCreateContentViewModel.cs" />
+    <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" />
@@ -426,8 +476,6 @@
     <Compile Include="ViewModels\Dialog\HomePageToolsDialogs\HomePagePrinter\HomePagePrinterModMultipleContentViewModel.cs" />
     <Compile Include="ViewModels\Dialog\HomePageToolsDialogs\HomePagePrinter\HomePagePrinterModPosterContentViewModel.cs" />
     <Compile Include="ViewModels\Dialog\HomePageToolsDialogs\HomePagePrinter\HomePagePrinterModSizeContentViewModel.cs" />
-    <Compile Include="ViewModels\Dialog\HomePageToolsDialogs\HomePagePrinter\HomePagePrinterPageSetDialogViewModel.cs" />
-    <Compile Include="ViewModels\Dialog\HomePageToolsDialogs\HomePagePrinter\ModInfoSendEvent.cs" />
     <Compile Include="ViewModels\Dialog\HomePageToolsDialogs\HomePageSplitDialogViewModel.cs" />
     <Compile Include="ViewModels\Dialog\PageEditDialogs\ExtractDialogViewModel.cs" />
     <Compile Include="ViewModels\Dialog\PageEditDialogs\InsertDialogViewModel.cs" />
@@ -549,9 +597,45 @@
     <Compile Include="Views\Dialog\HomePageToolsDialogs\CreateFromHtmlDialog.xaml.cs">
       <DependentUpon>CreateFromHtmlDialog.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>
+    <Compile Include="Views\Dialog\HomePageToolsDialogs\HomePageBatchProcessing\HomePageBates\HomePageBatesTemplateListContent.xaml.cs">
+      <DependentUpon>HomePageBatesTemplateListContent.xaml</DependentUpon>
+    </Compile>
+    <Compile Include="Views\Dialog\HomePageToolsDialogs\HomePageBatchProcessing\HomePageHeaderFooter\HomePageHeaderFooterCreateContent.xaml.cs">
+      <DependentUpon>HomePageHeaderFooterCreateContent.xaml</DependentUpon>
+    </Compile>
+    <Compile Include="Views\Dialog\HomePageToolsDialogs\HomePageBatchProcessing\HomePageHeaderFooter\HomePageHeaderFooterTemplateListContent.xaml.cs">
+      <DependentUpon>HomePageHeaderFooterTemplateListContent.xaml</DependentUpon>
+    </Compile>
     <Compile Include="Views\Dialog\HomePageToolsDialogs\HomePageBatchProcessing\HomePageBatchProcessingDialog.xaml.cs">
       <DependentUpon>HomePageBatchProcessingDialog.xaml</DependentUpon>
     </Compile>
+    <Compile Include="Views\Dialog\HomePageToolsDialogs\HomePageBatchProcessing\HomePageBates\HomePageBatesDialog.xaml.cs">
+      <DependentUpon>HomePageBatesDialog.xaml</DependentUpon>
+    </Compile>
     <Compile Include="Views\Dialog\HomePageToolsDialogs\HomePageBatchProcessing\HomePageCompressDialog.xaml.cs">
       <DependentUpon>HomePageCompressDialog.xaml</DependentUpon>
     </Compile>
@@ -570,9 +654,36 @@
     <Compile Include="Views\Dialog\HomePageToolsDialogs\HomePageBatchProcessing\HomePageConverter\HomePageConverterWord.xaml.cs">
       <DependentUpon>HomePageConverterWord.xaml</DependentUpon>
     </Compile>
+    <Compile Include="Views\Dialog\HomePageToolsDialogs\HomePageBatchProcessing\HomePageHeaderFooter\HomePageHeaderFooterDialog.xaml.cs">
+      <DependentUpon>HomePageHeaderFooterDialog.xaml</DependentUpon>
+    </Compile>
+    <Compile Include="Views\Dialog\HomePageToolsDialogs\HomePageBatchProcessing\HomePageRemoveDialog.xaml.cs">
+      <DependentUpon>HomePageRemoveDialog.xaml</DependentUpon>
+    </Compile>
     <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>
@@ -582,6 +693,9 @@
     <Compile Include="Views\Dialog\HomePageToolsDialogs\HomePagePictureToPDFDialog.xaml.cs">
       <DependentUpon>HomePagePictureToPDFDialog.xaml</DependentUpon>
     </Compile>
+    <Compile Include="Views\Dialog\HomePageToolsDialogs\HomePagePrinter\HomePagePrinterDocumentContent.xaml.cs">
+      <DependentUpon>HomePagePrinterDocumentContent.xaml</DependentUpon>
+    </Compile>
     <Compile Include="Views\Dialog\HomePageToolsDialogs\HomePagePrinter\HomePagePrinterModBookletContent.xaml.cs">
       <DependentUpon>HomePagePrinterModBookletContent.xaml</DependentUpon>
     </Compile>
@@ -594,8 +708,8 @@
     <Compile Include="Views\Dialog\HomePageToolsDialogs\HomePagePrinter\HomePagePrinterModSizeContent.xaml.cs">
       <DependentUpon>HomePagePrinterModSizeContent.xaml</DependentUpon>
     </Compile>
-    <Compile Include="Views\Dialog\HomePageToolsDialogs\HomePagePrinter\HomePagePrinterPageSetDialog.xaml.cs">
-      <DependentUpon>HomePagePrinterPageSetDialog.xaml</DependentUpon>
+    <Compile Include="Views\Dialog\HomePageToolsDialogs\HomePagePrinter\HomePagePrinterPaperSettingsDialog.xaml.cs">
+      <DependentUpon>HomePagePrinterPaperSettingsDialog.xaml</DependentUpon>
     </Compile>
     <Compile Include="Views\Dialog\HomePageToolsDialogs\HomePageSplitDialog.xaml.cs">
       <DependentUpon>HomePageSplitDialog.xaml</DependentUpon>
@@ -1134,6 +1248,50 @@
       <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>
+    </Page>
+    <Page Include="Views\Dialog\HomePageToolsDialogs\HomePageBatchProcessing\HomePageBates\HomePageBatesTemplateListContent.xaml">
+      <SubType>Designer</SubType>
+      <Generator>MSBuild:Compile</Generator>
+    </Page>
+    <Page Include="Views\Dialog\HomePageToolsDialogs\HomePageBatchProcessing\HomePageHeaderFooter\HomePageHeaderFooterCreateContent.xaml">
+      <SubType>Designer</SubType>
+      <Generator>MSBuild:Compile</Generator>
+    </Page>
+    <Page Include="Views\Dialog\HomePageToolsDialogs\HomePageBatchProcessing\HomePageHeaderFooter\HomePageHeaderFooterTemplateListContent.xaml">
+      <SubType>Designer</SubType>
+      <Generator>MSBuild:Compile</Generator>
+    </Page>
     <Page Include="Views\Dialog\HomePageToolsDialogs\CreateFromHtmlDialog.xaml">
       <SubType>Designer</SubType>
       <Generator>MSBuild:Compile</Generator>
@@ -1142,6 +1300,54 @@
       <SubType>Designer</SubType>
       <Generator>MSBuild:Compile</Generator>
     </Page>
+    <Page Include="Views\Dialog\HomePageToolsDialogs\HomePageBatchProcessing\HomePageBates\HomePageBatesDialog.xaml">
+      <SubType>Designer</SubType>
+      <Generator>MSBuild:Compile</Generator>
+    </Page>
+    <Page Include="Views\Dialog\HomePageToolsDialogs\HomePageBatchProcessing\HomePageHeaderFooter\HomePageHeaderFooterDialog.xaml">
+      <SubType>Designer</SubType>
+      <Generator>MSBuild:Compile</Generator>
+    </Page>
+    <Page Include="Views\Dialog\HomePageToolsDialogs\HomePageBatchProcessing\HomePageRemoveDialog.xaml">
+      <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>
+    </Page>
+    <Page Include="Views\Dialog\HomePageToolsDialogs\HomePagePrinter\HomePagePrinterPaperSettingsDialog.xaml">
+      <SubType>Designer</SubType>
+      <Generator>MSBuild:Compile</Generator>
+    </Page>
     <Page Include="Views\Dialog\PageEditDialogs\SplitDialog.xaml">
       <SubType>Designer</SubType>
       <Generator>MSBuild:Compile</Generator>
@@ -1326,10 +1532,6 @@
       <SubType>Designer</SubType>
       <Generator>MSBuild:Compile</Generator>
     </Page>
-    <Page Include="Views\Dialog\HomePageToolsDialogs\HomePagePrinter\HomePagePrinterPageSetDialog.xaml">
-      <SubType>Designer</SubType>
-      <Generator>MSBuild:Compile</Generator>
-    </Page>
     <Page Include="Views\Dialog\HomePageToolsDialogs\HomePageSplitDialog.xaml">
       <SubType>Designer</SubType>
       <Generator>MSBuild:Compile</Generator>
@@ -1627,7 +1829,9 @@
       <Generator>SettingsSingleFileGenerator</Generator>
       <LastGenOutput>Settings.Designer.cs</LastGenOutput>
     </None>
-    <None Include="source\AnalysisWord\Res\word\_rels\document.xml.rels" />
+    <Content Include="source\AnalysisWord\Res\word\_rels\document.xml.rels">
+      <CopyToOutputDirectory>Always</CopyToOutputDirectory>
+    </Content>
     <Resource Include="Resources\BOTA\Annotation\Arrow.png" />
     <Resource Include="Resources\BOTA\Annotation\Bookmark.png" />
     <Resource Include="Resources\BOTA\Annotation\Circle.png" />
@@ -1825,12 +2029,24 @@
     <Content Include="source\AnalysisWord\Res\docProps\core.xml">
       <CopyToOutputDirectory>Always</CopyToOutputDirectory>
     </Content>
-    <Resource Include="source\AnalysisWord\Res\word\document.xml" />
-    <Resource Include="source\AnalysisWord\Res\word\document0.xml" />
-    <Resource Include="source\AnalysisWord\Res\word\endnotes.xml" />
-    <Resource Include="source\AnalysisWord\Res\word\footnotes.xml" />
-    <Resource Include="source\AnalysisWord\Res\word\settings.xml" />
-    <Resource Include="source\AnalysisWord\Res\word\theme\theme1.xml" />
+    <Content Include="source\AnalysisWord\Res\word\document.xml">
+      <CopyToOutputDirectory>Always</CopyToOutputDirectory>
+    </Content>
+    <Content Include="source\AnalysisWord\Res\word\document0.xml">
+      <CopyToOutputDirectory>Always</CopyToOutputDirectory>
+    </Content>
+    <Content Include="source\AnalysisWord\Res\word\endnotes.xml">
+      <CopyToOutputDirectory>Always</CopyToOutputDirectory>
+    </Content>
+    <Content Include="source\AnalysisWord\Res\word\footnotes.xml">
+      <CopyToOutputDirectory>Always</CopyToOutputDirectory>
+    </Content>
+    <Content Include="source\AnalysisWord\Res\word\settings.xml">
+      <CopyToOutputDirectory>Always</CopyToOutputDirectory>
+    </Content>
+    <Content Include="source\AnalysisWord\Res\word\theme\theme1.xml">
+      <CopyToOutputDirectory>Always</CopyToOutputDirectory>
+    </Content>
     <Content Include="source\AnalysisWord\Res\[Content_Types].xml">
       <CopyToOutputDirectory>Always</CopyToOutputDirectory>
     </Content>
@@ -1912,12 +2128,26 @@
       <LastGenOutput>Resources.Designer.cs</LastGenOutput>
     </EmbeddedResource>
   </ItemGroup>
+  <ItemGroup>
+    <BootstrapperPackage Include=".NETFramework,Version=v4.6.2">
+      <Visible>False</Visible>
+      <ProductName>Microsoft .NET Framework 4.6.2 %28x86 和 x64%29</ProductName>
+      <Install>true</Install>
+    </BootstrapperPackage>
+    <BootstrapperPackage Include="Microsoft.Net.Framework.3.5.SP1">
+      <Visible>False</Visible>
+      <ProductName>.NET Framework 3.5 SP1</ProductName>
+      <Install>false</Install>
+    </BootstrapperPackage>
+  </ItemGroup>
   <Import Project="$(MSBuildToolsPath)\Microsoft.CSharp.targets" />
   <Target Name="EnsureNuGetPackageBuildImports" BeforeTargets="PrepareForBuild">
     <PropertyGroup>
       <ErrorText>这台计算机上缺少此项目引用的 NuGet 程序包。使用“NuGet 程序包还原”可下载这些程序包。有关更多信息,请参见 http://go.microsoft.com/fwlink/?LinkID=322105。缺少的文件是 {0}。</ErrorText>
     </PropertyGroup>
     <Error Condition="!Exists('packages\SQLitePCLRaw.lib.e_sqlite3.2.0.2\build\net461\SQLitePCLRaw.lib.e_sqlite3.targets')" Text="$([System.String]::Format('$(ErrorText)', 'packages\SQLitePCLRaw.lib.e_sqlite3.2.0.2\build\net461\SQLitePCLRaw.lib.e_sqlite3.targets'))" />
+    <Error Condition="!Exists('packages\Magick.NET-Q16-AnyCPU.12.2.2\build\netstandard20\Magick.NET-Q16-AnyCPU.targets')" Text="$([System.String]::Format('$(ErrorText)', 'packages\Magick.NET-Q16-AnyCPU.12.2.2\build\netstandard20\Magick.NET-Q16-AnyCPU.targets'))" />
   </Target>
   <Import Project="packages\SQLitePCLRaw.lib.e_sqlite3.2.0.2\build\net461\SQLitePCLRaw.lib.e_sqlite3.targets" Condition="Exists('packages\SQLitePCLRaw.lib.e_sqlite3.2.0.2\build\net461\SQLitePCLRaw.lib.e_sqlite3.targets')" />
+  <Import Project="packages\Magick.NET-Q16-AnyCPU.12.2.2\build\netstandard20\Magick.NET-Q16-AnyCPU.targets" Condition="Exists('packages\Magick.NET-Q16-AnyCPU.12.2.2\build\netstandard20\Magick.NET-Q16-AnyCPU.targets')" />
 </Project>

+ 46 - 0
PDF Office/Properties/Settings.Designer.cs

@@ -124,6 +124,52 @@ namespace PDF_Office.Properties {
             }
         }
         
+        [global::System.Configuration.UserScopedSettingAttribute()]
+        [global::System.Diagnostics.DebuggerNonUserCodeAttribute()]
+        public global::PDFSettings.BatesTemplateList BatesTemplateList {
+            get {
+                return ((global::PDFSettings.BatesTemplateList)(this["BatesTemplateList"]));
+            }
+            set {
+                this["BatesTemplateList"] = value;
+            }
+        }
+        
+        [global::System.Configuration.UserScopedSettingAttribute()]
+        [global::System.Diagnostics.DebuggerNonUserCodeAttribute()]
+        [global::System.Configuration.DefaultSettingValueAttribute("0")]
+        public int BatesIndex {
+            get {
+                return ((int)(this["BatesIndex"]));
+            }
+            set {
+                this["BatesIndex"] = value;
+            }
+        }
+        
+        [global::System.Configuration.UserScopedSettingAttribute()]
+        [global::System.Diagnostics.DebuggerNonUserCodeAttribute()]
+        public global::PDFSettings.HeaderFooterTemplateList HeaderFooterTemplateList {
+            get {
+                return ((global::PDFSettings.HeaderFooterTemplateList)(this["HeaderFooterTemplateList"]));
+            }
+            set {
+                this["HeaderFooterTemplateList"] = value;
+            }
+        }
+        
+        [global::System.Configuration.UserScopedSettingAttribute()]
+        [global::System.Diagnostics.DebuggerNonUserCodeAttribute()]
+        [global::System.Configuration.DefaultSettingValueAttribute("0")]
+        public int HeaderFooterIndex {
+            get {
+                return ((int)(this["HeaderFooterIndex"]));
+            }
+            set {
+                this["HeaderFooterIndex"] = value;
+            }
+        }
+        
         [global::System.Configuration.UserScopedSettingAttribute()]
         [global::System.Diagnostics.DebuggerNonUserCodeAttribute()]
         public global::PDFSettings.CustomStampList CustomStampList {

+ 12 - 0
PDF Office/Properties/Settings.settings

@@ -29,6 +29,18 @@
     <Setting Name="WatermarkIndex" Type="System.Int32" Scope="User">
       <Value Profile="(Default)">0</Value>
     </Setting>
+    <Setting Name="BatesTemplateList" Type="PDFSettings.BatesTemplateList" Scope="User">
+      <Value Profile="(Default)" />
+    </Setting>
+    <Setting Name="BatesIndex" Type="System.Int32" Scope="User">
+      <Value Profile="(Default)">0</Value>
+    </Setting>
+    <Setting Name="HeaderFooterTemplateList" Type="PDFSettings.HeaderFooterTemplateList" Scope="User">
+      <Value Profile="(Default)" />
+    </Setting>
+    <Setting Name="HeaderFooterIndex" Type="System.Int32" Scope="User">
+      <Value Profile="(Default)">0</Value>
+    </Setting>
     <Setting Name="CustomStampList" Type="PDFSettings.CustomStampList" Scope="User">
       <Value Profile="(Default)" />
     </Setting>

+ 4 - 4
PDF Office/SDKLisence.xml

@@ -1,10 +1,10 @@
 <Lisences
-	devKey = "sTHSivIW4YnZQavIYDLVw4vaFcN5DQTUtRGrVyv5p9aeaHX3GirG/MBxl6Wy9TJbNOwR4CU6LPjHmGe3Po3OtBCPqIRheam9+LomScw3AvoUTHFlG1134e2J4enF43WJQ6PyOnjwZqsG1kUdlBPNztkoPzDAE2pQKgZWf6V2i34="
-    devSecret = "mG0c3O3Mzeu5dkZJW3gpqq9uA7o7EGQveSC38Q8TK4gQurxTxGuBlGAhs0P1mD3X3bHT+AHfcLiymaqE4DY7kTFHoPs9I3tl5ErS+BHdzHRhrp9sGpqfp0B228KI+IMTu4aGVjtYuk+Uxs/kosIBw1367/WkJ00tM7U7tttD6cfaiHpW8pgW2aur3AxuQIBBLuJD5gcmNxTYW3KA32JLG8alfyXjKFVS3gka9bngvwfZ7GuNXybjKlmz1tnN6iVHpnbSj+xOHhWEperY4HHrSg=="
-	userKey = "iBPRM/Tz8b6Z1G2GQt52X7hiNCGfVYXztnPjalgrgARvqfKV6lFNH8QeScTzBRYI8GGFpwelfgh790Kd9JmL7V4adI1jCiFHUT2DLT7QucxY5Nkgys2aJItQS482Ck2G2Xf8gNgojxYxRt65o/MEzkj93foj8qIdfHagXsSorSs="
+	devKey = "ehrnKqkWc1XSEAWyPUt6+95GzCoLEyoKrCbsUuJkCqGmxmP5ozX4bS0R6crHItQVNTFvC5mBZ1M7QjJ6Ekdu4Daj7PM+EDLTBKbFJinK4Ri9E5E2X+a9vF5zSj0TkIscQPVnwj9ikxAFOWGIyybMwQQzwc8a4j1cGOqGXQRDMMY="
+  devSecret = "mG0c3O3Mzeu5dkZJW3gpqq9uA7o7EGQveSC38Q8TK4gQurxTxGuBlGAhs0P1mD3X3bHT+AHfcLiymaqE4DY7kTFHoPs9I3tl5ErS+BHdzHRhrp9sGpqfp0B228KI+IMTu4aGVjtYuk+Uxs/kosIBw1367/WkJ00tM7U7tttD6ccHhEu996bvBgqf8Sw8OekQKQq13VBewK5AckaDux4W7SGRhCUNWC4MItkr36JnXMD2tiFQYzMG8C66HYmRGSLh"
+  userKey = "iBPRM/Tz8b6Z1G2GQt52X7hiNCGfVYXztnPjalgrgARvqfKV6lFNH8QeScTzBRYI8GGFpwelfgh790Kd9JmL7V4adI1jCiFHUT2DLT7QucxY5Nkgys2aJItQS482Ck2G2Xf8gNgojxYxRt65o/MEzkj93foj8qIdfHagXsSorSs="
 	userSecret="mG0c3O3Mzeu5dkZJW3gpqq9uA7o7EGQveSC38Q8TK4ivEHOmPIqbfhpDnKKj+7Ymj2rXQvfZRmke06HMV+3tt064G64WjPW8+EbGCNZaAh1hrp9sGpqfp0B228KI+IMTu4aGVjtYuk+Uxs/kosIBw1FKJi6HYB+DuugQyaqI2prfej861QnJrU4s2T/npZK/"
 	ConverterDevKey="Eahwo7OZAYHJaCF7TJQYKSVqC62MzfBdllVXnC5BRR5BQFDKnQ1FJtCRVdug+VNg/ti+/DeA5Sq4IH2CBpQjAZst5705uk5Sz0ZwRu8Qdn9HFGwh2pG6dJEIrl7lOccoZS6+1IxgOTcTeHqYpym3NsmtbhBWE848Pvme3scpW28="
 	ConverterDevSecret="mG0c3O3Mzeu5dkZJW3gpqq9uA7o7EGQveSC38Q8TK4iccr16WMBclnQACarlyblNUvAm/S8uFbhXMvxwgBSgULSsrbuyF/SIZ3I+dl0qU8EiR4IKrcJxus3VRNu+jx8P7CGq2BlSjPVXRHBI1lV8ukpCIUGmcK+P+Z0QbYdkAHAm6NPgs2c4tp1jOFPPbnUkTtX7riDb9xRCx1YNm3/+xd96PzrVCcmtTizZP+elkr8="
 	ConverterUserkey=" WLUHzXhndQKyrTJVzvZ+dvPXDQDZeJpcSvklX3GJwRX4+urd8eQskYgbeCf0NXLZ/qJkS/k10x+qGad34i4v5rI/ASFIx901c/Nw5C0YJMH7X87dib141tdAmSmQhnKLO5TBi4FiAidboyvnLFLrYGMmS2kLQOXFPwPj5zQUv5A="
-	ConverterUserSecret="mG0c3O3Mzeu5dkZJW3gpqq9uA7o7EGQveSC38Q8TK4iK16EcneqBPRe2eKQLuJXpA79IONX9GVI/Ap3uWzMcNWaitc2UB6gDeexJXFPVaXOFAoV6NtcUJC8skonXVk7k/oKTJGcYKLPGdXenrzHolQ==">
+	ConverterUserSecret="mG0c3O3Mzeu5dkZJW3gpqq9uA7o7EGQveSC38Q8TK4iK16EcneqBPRe2eKQLuJXpA79IONX9GVI/Ap3uWzMcNWaitc2UB6gDeexJXFPVaXOFAoV6NtcUJC8skonXVk7k/oKTJGcYKLPGdXenrzHolQ==" >
 </Lisences>

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

@@ -105,6 +105,7 @@
             </Trigger>
         </ControlTemplate.Triggers>
     </ControlTemplate>
+    
     <Style x:Key="EditToolsCheckBoxStyle" TargetType="{x:Type CheckBox}">
         <Setter Property="SnapsToDevicePixels" Value="true" />
         <Setter Property="OverridesDefaultStyle" Value="False" />

+ 129 - 2
PDF Office/Styles/RadioButtonStyle.xaml

@@ -277,8 +277,74 @@
                             <Setter TargetName="root" Property="Border.Background" Value="White" />
                         </Trigger>
                         <Trigger Property="IsChecked" Value="{x:Null}">
-                            <Setter TargetName="optionMark" Property="Opacity" Value="0.56" />
+                            <Setter Property="Opacity" TargetName="optionMark" Value="0.56"/>
+                        </Trigger>
+                    </ControlTemplate.Triggers>
+                </ControlTemplate>
+            </Setter.Value>
+        </Setter>
+    </Style>
 
+    <Style x:Key="LocationRadioBtnStyle"  TargetType="{x:Type RadioButton}">
+        <Setter Property="Background" Value="{StaticResource RadioButton.Static.Background}" />
+        <Setter Property="BorderBrush" Value="{StaticResource RadioButton.Static.Border}" />
+        <Setter Property="Foreground" Value="{DynamicResource {x:Static SystemColors.ControlTextBrushKey}}" />
+        <Setter Property="BorderThickness" Value="0" />
+        <Setter Property="Width" Value="72" />
+        <Setter Property="Height" Value="80" />
+        <Setter Property="HorizontalContentAlignment" Value="Center" />
+        <Setter Property="VerticalContentAlignment" Value="Center" />
+        <Setter Property="Template">
+            <Setter.Value>
+                <ControlTemplate TargetType="{x:Type RadioButton}">
+                    <Grid
+                        x:Name="templateRoot"
+                        Background="Transparent"
+                        SnapsToDevicePixels="True">
+                        <Border
+                            x:Name="radioButtonBorder"
+                            HorizontalAlignment="{TemplateBinding HorizontalContentAlignment}"
+                            VerticalAlignment="{TemplateBinding VerticalContentAlignment}"
+                            Background="{TemplateBinding Background}"
+                            BorderBrush="{TemplateBinding BorderBrush}"
+                            BorderThickness="{TemplateBinding BorderThickness}">
+                            <Rectangle
+                                x:Name="optionMark"
+                                Width="{TemplateBinding Width}"
+                                Height="{TemplateBinding Height}"
+                                Opacity="0" />
+                        </Border>
+                        <ContentPresenter
+                            x:Name="contentPresenter"
+                            Margin="{TemplateBinding Padding}"
+                            HorizontalAlignment="{TemplateBinding HorizontalContentAlignment}"
+                            VerticalAlignment="{TemplateBinding VerticalContentAlignment}"
+                            Focusable="False"
+                            RecognizesAccessKey="True"
+                            SnapsToDevicePixels="{TemplateBinding SnapsToDevicePixels}" />
+                    </Grid>
+                    <ControlTemplate.Triggers>
+                        <Trigger Property="IsMouseOver" Value="true">
+                            <Setter TargetName="radioButtonBorder" Property="Background" Value="{StaticResource RadioButton.MouseOver.Background}" />
+                            <Setter TargetName="radioButtonBorder" Property="BorderBrush" Value="{StaticResource RadioButton.MouseOver.Border}" />
+                            <Setter TargetName="optionMark" Property="Fill" Value="{StaticResource RadioButton.MouseOver.Glyph}" />
+                        </Trigger>
+                        <Trigger Property="IsEnabled" Value="false">
+                            <Setter TargetName="radioButtonBorder" Property="Background" Value="{StaticResource RadioButton.Disabled.Background}" />
+                            <Setter TargetName="radioButtonBorder" Property="BorderBrush" Value="{StaticResource RadioButton.Disabled.Border}" />
+                            <Setter TargetName="optionMark" Property="Fill" Value="{StaticResource RadioButton.Disabled.Glyph}" />
+                        </Trigger>
+                        <Trigger Property="IsPressed" Value="true">
+                            <Setter TargetName="radioButtonBorder" Property="Background" Value="{StaticResource RadioButton.Pressed.Background}" />
+                            <Setter TargetName="radioButtonBorder" Property="BorderBrush" Value="{StaticResource RadioButton.Pressed.Border}" />
+                            <Setter TargetName="optionMark" Property="Fill" Value="{StaticResource RadioButton.Pressed.Glyph}" />
+                        </Trigger>
+                        <Trigger Property="IsChecked" Value="true">
+                            <Setter TargetName="optionMark" Property="Opacity" Value="1" />
+                            <Setter TargetName="optionMark" Property="Fill" Value="Black" />
+                        </Trigger>
+                        <Trigger Property="IsChecked" Value="{x:Null}">
+                            <Setter TargetName="optionMark" Property="Opacity" Value="0.56" />
                         </Trigger>
                     </ControlTemplate.Triggers>
                 </ControlTemplate>
@@ -333,7 +399,68 @@
                             <Setter Property="Foreground" Value="#616469" />
                             <Setter TargetName="templateRoot" Property="BorderThickness" Value="1" />
                         </Trigger>
-                        <Trigger Property="IsChecked" Value="{x:Null}" />
+                    </ControlTemplate.Triggers>
+                </ControlTemplate>
+            </Setter.Value>
+        </Setter>
+    </Style>
+
+    <Style x:Key="BatchButton" TargetType="{x:Type RadioButton}">
+        <Setter Property="Foreground" Value="{DynamicResource {x:Static SystemColors.ControlTextBrushKey}}"/>
+        <Setter Property="Background" Value="#F7F8FA"/>
+        <Setter Property="BorderThickness" Value="0"/>
+        <Setter Property="Cursor" Value="Hand"/>
+        <Setter Property="Template">
+            <Setter.Value>
+                <ControlTemplate TargetType="{x:Type RadioButton}">
+                    <ControlTemplate.Resources>
+                        <Storyboard x:Key="Storyboard1">
+                            <ColorAnimationUsingKeyFrames Storyboard.TargetProperty="(Panel.Background).(SolidColorBrush.Color)" Storyboard.TargetName="bd">
+                                <EasingColorKeyFrame KeyTime="0" Value="White"/>
+                                <EasingColorKeyFrame KeyTime="0:0:0.3" Value="#FFAFAFAF"/>
+                            </ColorAnimationUsingKeyFrames>
+                        </Storyboard>
+                        <Storyboard x:Key="Storyboard2">
+                            <ColorAnimationUsingKeyFrames Storyboard.TargetProperty="(Panel.Background).(SolidColorBrush.Color)" Storyboard.TargetName="bd">
+                                <EasingColorKeyFrame KeyTime="0" Value="#FFAFAFAF"/>
+                                <EasingColorKeyFrame KeyTime="0:0:0.5" Value="#D3D3D3"/>
+                            </ColorAnimationUsingKeyFrames>
+                        </Storyboard>
+                    </ControlTemplate.Resources>
+                    <BulletDecorator Background="Transparent">
+                        <Border x:Name="bd"  HorizontalAlignment="Center" Background="White" CornerRadius="5">
+                            <Border.OpacityMask>
+                                <LinearGradientBrush EndPoint="0.5,1" StartPoint="0.5,0">
+                                    <GradientStop Color="Black" Offset="0"/>
+                                    <GradientStop Color="White" Offset="1"/>
+                                </LinearGradientBrush>
+                            </Border.OpacityMask>
+                            <ContentPresenter Width="{TemplateBinding Width}" Height="{TemplateBinding Height}" HorizontalAlignment="{TemplateBinding HorizontalContentAlignment}" Margin="{TemplateBinding Padding}" RecognizesAccessKey="True" VerticalAlignment="{TemplateBinding VerticalContentAlignment}"/>
+                        </Border>
+                    </BulletDecorator>
+                    <ControlTemplate.Triggers>
+                        <Trigger Property="IsEnabled" Value="false">
+                            <Setter TargetName="bd" Property="Background" Value="gray" />
+                        </Trigger>
+                        <Trigger Property="IsChecked" Value="false">
+                            <Setter TargetName="bd" Property="Background" Value="{x:Null}" />
+                        </Trigger>
+                        <Trigger Property="IsChecked" Value="true">
+                            <Trigger.EnterActions>
+                                <BeginStoryboard x:Name="Storyboard2_BeginStoryboard" Storyboard="{StaticResource Storyboard2}"/>
+                            </Trigger.EnterActions>
+                            <Setter TargetName="bd" Property="Background" Value="#FF606060" />
+                        </Trigger>
+                        <MultiTrigger>
+                            <MultiTrigger.EnterActions>
+                                <BeginStoryboard Storyboard="{StaticResource Storyboard1}"/>
+                            </MultiTrigger.EnterActions>
+                            <MultiTrigger.Conditions>
+                                <Condition Property="IsMouseOver" Value="True"/>
+                                <Condition Property="IsChecked" Value="False"/>
+                            </MultiTrigger.Conditions>
+                            <Setter TargetName="bd" Property="Background" Value="Red" />
+                        </MultiTrigger>
                     </ControlTemplate.Triggers>
                 </ControlTemplate>
             </Setter.Value>

+ 3 - 0
PDF Office/ViewModels/Dialog/ConverterDialogs/ConverterExcelDialogViewModel.cs

@@ -183,6 +183,9 @@ namespace PDF_Office.ViewModels.Dialog.ConverterDialogs
                     case "OnlyTableRadioBtn":
                         ConverterExcelModel.excelOption = ConverterExcelModel.ExcelOptions(WorksheetOptions.ForEachTable, ContentOptions.OnlyTable);
                         break;
+                    case "OnlyTextRadioBtn":
+                        ConverterExcelModel.excelOption = ConverterExcelModel.ExcelOptions(WorksheetOptions.ForTheDocument, ContentOptions.OnlyText);
+                        break;
                     default:
                         break;
                 }

+ 1 - 0
PDF Office/ViewModels/Dialog/ConverterDialogs/ConverterHTMLDialogViewModel.cs

@@ -80,6 +80,7 @@ namespace PDF_Office.ViewModels.Dialog.ConverterDialogs
                 MessageBoxEx.Show("输入不对");
                 return;
             }
+            ConverterHTMLModel.htmlOption=ConverterHTMLModel.HTMLOptions();
             //result = await ConverterHelper.TxtConvert(ConverterTextModel.InputPath, ConverterTextModel.OutputPath, ConverterTextModel.GetProgress, ConverterTextModel.PageIndexLists, ConverterTextModel.Pawssword);
             DialogParameters value = new DialogParameters();
             value.Add(ParameterNames.ConverterType, "HTML");

+ 24 - 9
PDF Office/ViewModels/Dialog/ConverterDialogs/ConverterImgDialogViewModel.cs

@@ -37,7 +37,7 @@ namespace PDF_Office.ViewModels.Dialog.ConverterDialogs
 
         public string PageRangeSelectIndex { set; get; } = "0";
 
-        public List<string> ImageTypeFamily { set; get; } =new List<string>();
+        public List<string> ImageTypeFamily { set; get; } = new List<string>();
 
         private int imageTypeSelectedIndex;
         /// <summary>
@@ -50,7 +50,7 @@ namespace PDF_Office.ViewModels.Dialog.ConverterDialogs
             set
             {
                 SetProperty(ref imageTypeSelectedIndex, value);
-                
+
                 UpdateImageType(ImageTypeSelectedIndex);
             }
         }
@@ -66,7 +66,7 @@ namespace PDF_Office.ViewModels.Dialog.ConverterDialogs
             set
             {
                 SetProperty(ref imageDPISelectedIndex, value);
-                
+
                 UpdateImageDPI(ImageDPISelectedIndex);
             }
         }
@@ -121,20 +121,34 @@ namespace PDF_Office.ViewModels.Dialog.ConverterDialogs
         /// <param name="index"></param>
         private void UpdateImageType(int index)
         {
+            this.ConverterImgModel.Type = ImgType.PNG;
             switch (index)
             {
                 //case结果是同样的情况下,case可堆叠在一起,表示处理方式一样
                 case 0:
-                case 1:
+                    this.ConverterImgModel.imageType = ".jpeg";
+                    break;
+                case 7:
+                    this.ConverterImgModel.imageType = ".jp2";
+                    break;
                 case 3:
+                    this.ConverterImgModel.imageType = ".gif";
+                    break;
                 case 4:
+                    this.ConverterImgModel.imageType = ".tiff";
+                    break;
                 case 5:
+                    this.ConverterImgModel.imageType = ".tga";
+                    break;
                 case 6:
-                case 7:
-                    this.ConverterImgModel.Type = ImgType.JPEG;
+                    this.ConverterImgModel.imageType = ".bmp";
                     break;
                 case 2:
-                    this.ConverterImgModel.Type = ImgType.PNG;
+                    this.ConverterImgModel.imageType = ".png";
+                    break;
+                case 1:
+                    this.ConverterImgModel.imageType = ".jpg";
+                    this.ConverterImgModel.Type = ImgType.JPEG;
                     break;
                 default:
                     break;
@@ -173,8 +187,9 @@ namespace PDF_Office.ViewModels.Dialog.ConverterDialogs
             RequestClose.Invoke(new DialogResult(ButtonResult.Cancel));
         }
 
-        private  void converter()
+        private void converter()
         {
+
             FolderBrowserDialog dlg = new FolderBrowserDialog();
             if (dlg.ShowDialog() == System.Windows.Forms.DialogResult.OK)
             {
@@ -189,7 +204,7 @@ namespace PDF_Office.ViewModels.Dialog.ConverterDialogs
                 MessageBoxEx.Show("输入不对");
                 return;
             }
-           
+
             DialogParameters value = new DialogParameters();
             value.Add(ParameterNames.ConverterType, "Img");
             value.Add(ParameterNames.ConverterTypeModel, ConverterImgModel);

+ 36 - 1
PDF Office/ViewModels/Dialog/ConverterDialogs/ConverterProgressBarDialogViewModel.cs

@@ -9,8 +9,10 @@ using Prism.Mvvm;
 using Prism.Services.Dialogs;
 using System;
 using System.Collections.Generic;
+using System.Diagnostics;
 using System.Linq;
 using System.Net.Mime;
+using System.Windows.Media;
 using static Dropbox.Api.Sharing.ListFileMembersIndividualResult;
 
 namespace PDF_Office.ViewModels.Dialog.ConverterDialogs
@@ -89,6 +91,10 @@ namespace PDF_Office.ViewModels.Dialog.ConverterDialogs
                     if (ConverterCSVModel != null)
                     {
                         PageNumber = ConverterCSVModel.PageIndexLists.Count().ToString();
+                        for (int i = 0; ConverterCSVModel.PageIndexLists.Count > i; i++)
+                        {
+                            ConverterCSVModel.PageIndexLists[i] = ConverterCSVModel.PageIndexLists[i] + 1;
+                        }
                         result = await ConverterHelper.CSVConvert(ConverterCSVModel.InputPath, ConverterCSVModel.OutputPath, GetProgress, ConverterCSVModel.PageIndexLists, ConverterCSVModel.Pawssword);
                        
                     }
@@ -99,6 +105,10 @@ namespace PDF_Office.ViewModels.Dialog.ConverterDialogs
                     if (ConverterExcelModel != null)
                     {
                         PageNumber = ConverterExcelModel.PageIndexLists.Count().ToString();
+                        for (int i = 0; ConverterExcelModel.PageIndexLists.Count > i; i++)
+                        {
+                            ConverterExcelModel.PageIndexLists[i] = ConverterExcelModel.PageIndexLists[i] + 1;
+                        }
                         result = await ConverterHelper.ExcelConvert(ConverterExcelModel.InputPath, ConverterExcelModel.OutputPath, GetProgress, ConverterExcelModel.PageIndexLists, ConverterExcelModel.Pawssword, ConverterExcelModel.excelOption);
                     }
                     break;
@@ -108,6 +118,11 @@ namespace PDF_Office.ViewModels.Dialog.ConverterDialogs
                     if (ConverterHTMLModel != null)
                     {
                         PageNumber = ConverterHTMLModel.PageIndexLists.Count().ToString();
+                        for (int i = 0; ConverterHTMLModel.PageIndexLists.Count > i; i++)
+                        {
+                            ConverterHTMLModel.PageIndexLists[i] = ConverterHTMLModel.PageIndexLists[i] + 1;
+                        }
+                        result = await ConverterHelper.HTMLConvert(ConverterHTMLModel.InputPath, ConverterHTMLModel.OutputPath, GetProgress, ConverterHTMLModel.PageIndexLists, ConverterHTMLModel.Pawssword, ConverterHTMLModel.htmlOption);
                     }
                     break;
                 case "Img":
@@ -116,7 +131,10 @@ namespace PDF_Office.ViewModels.Dialog.ConverterDialogs
                     if (ConverterImgModel != null)
                     {
                         PageNumber = ConverterImgModel.PageIndexLists.Count().ToString();
-                        result = await ConverterHelper.ImgConvert(ConverterImgModel.InputPath, ConverterImgModel.OutputPath, GetProgress, ConverterImgModel.PageIndexLists, ConverterImgModel.Pawssword, ConverterImgModel.Type);
+                        for (int i=0; ConverterImgModel.PageIndexLists.Count>i;i++) {
+                            ConverterImgModel.PageIndexLists[i] = ConverterImgModel.PageIndexLists[i] + 1;
+                        }
+                        result = await ConverterHelper.ImgConvert(ConverterImgModel.InputPath, ConverterImgModel.OutputPath, GetProgress, ConverterImgModel.PageIndexLists, ConverterImgModel.Pawssword, ConverterImgModel.Type,ConverterImgModel.imageType);
                     }
                     break;
                 case "PPT":
@@ -125,6 +143,10 @@ namespace PDF_Office.ViewModels.Dialog.ConverterDialogs
                     if (ConverterPPTModel != null)
                     {
                         PageNumber = ConverterPPTModel.PageIndexLists.Count().ToString();
+                        for (int i = 0; ConverterPPTModel.PageIndexLists.Count > i; i++)
+                        {
+                            ConverterPPTModel.PageIndexLists[i] = ConverterPPTModel.PageIndexLists[i] + 1;
+                        }
                         result = await ConverterHelper.PPTConvert(ConverterPPTModel.InputPath, ConverterPPTModel.OutputPath, GetProgress, ConverterPPTModel.PageIndexLists, ConverterPPTModel.Pawssword);
                     }
                     break;
@@ -134,6 +156,11 @@ namespace PDF_Office.ViewModels.Dialog.ConverterDialogs
                     if (ConverterRTFModel != null)
                     {
                         PageNumber = ConverterRTFModel.PageIndexLists.Count().ToString();
+                        for (int i = 0; ConverterRTFModel.PageIndexLists.Count > i; i++)
+                        {
+                            ConverterRTFModel.PageIndexLists[i] = ConverterRTFModel.PageIndexLists[i] + 1;
+                        }
+                        result = await ConverterHelper.RTFConvert(ConverterRTFModel.InputPath, ConverterRTFModel.OutputPath, GetProgress, ConverterRTFModel.PageIndexLists, ConverterRTFModel.Pawssword);
                     }
                         break;
                 case "Text":
@@ -142,6 +169,10 @@ namespace PDF_Office.ViewModels.Dialog.ConverterDialogs
                     if (ConverterTextModel != null)
                     {
                         PageNumber = ConverterTextModel.PageIndexLists.Count().ToString();
+                        for (int i = 0; ConverterTextModel.PageIndexLists.Count > i; i++)
+                        {
+                            ConverterTextModel.PageIndexLists[i] = ConverterTextModel.PageIndexLists[i] + 1;
+                        }
                         result = await ConverterHelper.TxtConvert(ConverterTextModel.InputPath, ConverterTextModel.OutputPath, GetProgress, ConverterTextModel.PageIndexLists, ConverterTextModel.Pawssword);
                     }
                     break;
@@ -150,6 +181,10 @@ namespace PDF_Office.ViewModels.Dialog.ConverterDialogs
                     parameters.TryGetValue<ConverterWordDialogModel>(ParameterNames.ConverterTypeModel, out ConverterWordModel);
                     if (ConverterWordModel != null) {
                         PageNumber = ConverterWordModel.PageIndexLists.Count().ToString();
+                        for (int i = 0; ConverterWordModel.PageIndexLists.Count > i; i++)
+                        {
+                            ConverterWordModel.PageIndexLists[i] = ConverterWordModel.PageIndexLists[i] + 1;
+                        }
                         result = await ConverterHelper.WordConvert(ConverterWordModel.InputPath, ConverterWordModel.OutputPath, GetProgress, ConverterWordModel.PageIndexLists, ConverterWordModel.Pawssword);
                     }
                     break;

+ 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();
+            }
+        }
+    }
+}

+ 539 - 0
PDF Office/ViewModels/Dialog/HomePageToolsDialogs/HomePageBatchProcessing/HomePageBackground/HomePageBackgroundDialogViewModel.cs

@@ -0,0 +1,539 @@
+using Prism.Commands;
+using Prism.Mvvm;
+using System;
+using System.Collections.Generic;
+using System.Linq;
+using System.Data;
+using System.Windows;
+using PDF_Office.Helper;
+using Prism.Regions;
+using ComPDFKit.PDFDocument;
+using PDF_Office.CustomControl;
+using PDF_Office.Model.Dialog.HomePageToolsDialogs.HomePageBatchProcessing;
+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
+{
+    public class HomePageBackgroundDialogViewModel : BindableBase, INavigationAware
+    {
+        #region 参数和属性
+        private List<string> fileNames;
+
+
+        private CPDFDocument tempDocument;
+
+        public string PageNumber = "";
+
+        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>();
+
+        private int fileNamesIndex = 0;
+
+        private int FileNameNumber = 0;
+
+        private string backgroundGridIsEnabled = "True";
+        public string BackgroundGridIsEnabled
+        {
+            get
+            {
+                return backgroundGridIsEnabled;
+            }
+            set
+            {
+                SetProperty(ref backgroundGridIsEnabled, value);
+            }
+        }
+
+        private string setBackgroundGridIsEnabled = "True";
+        public string SetBackgroundGridIsEnabled
+        {
+            get
+            {
+                return setBackgroundGridIsEnabled;
+            }
+            set
+            {
+                SetProperty(ref setBackgroundGridIsEnabled, value);
+            }
+        }
+
+        private DataTable pdfDataTable = new DataTable();
+        public DataTable PDFDataTable
+        {
+            get { return pdfDataTable; }
+            set
+            {
+                SetProperty(ref pdfDataTable, value);
+            }
+        }
+
+        private DataTable pdfCurrentDataTable = new DataTable();
+        public DataTable PDFCurrentDataTable
+        {
+            get { return pdfCurrentDataTable; }
+            set
+            {
+                SetProperty(ref pdfCurrentDataTable, value);
+            }
+        }
+
+        private string removeIsEnable = "False";
+        public string RemoveIsEnable
+        {
+            get { return removeIsEnable; }
+            set
+            {
+                SetProperty(ref removeIsEnable, value);
+            }
+        }
+
+        private string selectFileName = "False";
+        public string SelectFileName
+        {
+            get { return selectFileName; }
+            set
+            {
+                SetProperty(ref selectFileName, value);
+            }
+        }
+
+        private string backgroundRegionName;
+        public string BackgroundRegionName
+        {
+            get
+            {
+                return backgroundRegionName;
+            }
+            set
+            {
+                SetProperty(ref backgroundRegionName, value);
+            }
+        }
+
+        private Visibility backgroundVisible = Visibility.Collapsed;
+        public Visibility BackgroundVisible
+        {
+            get { return backgroundVisible; }
+            set { SetProperty(ref backgroundVisible, value); }
+        }
+
+        private Visibility addFileVisibility = Visibility.Hidden;
+        public Visibility AddFileVisibility
+        {
+            get { return addFileVisibility; }
+            set
+            {
+                SetProperty(ref addFileVisibility, value);
+                RaisePropertyChanged();
+
+            }
+        }
+        #endregion
+
+        #region 委托声明
+        public DelegateCommand ADDPDFCommand { get; set; }
+
+        public DelegateCommand RemovePDFFileCommand { get; set; }
+
+        public DelegateCommand CreateCommand { get; set; }
+
+        public DelegateCommand ADDPDFFilesCommand { get; set; }
+        #endregion
+
+        public string Unicode = null;
+
+        public HomePageBackgroundDialogViewModel(IRegionManager backgroundRegion, IEventAggregator eventAggregator)
+        {
+            this.eventAggregator = eventAggregator;
+            this.backgroundRegion = backgroundRegion;
+            PDFCurrentDataTable.Columns.Add("FilePageRangeText");
+            PDFCurrentDataTable.Columns.Add("FilePageRangeSelectIndex");
+            PDFCurrentDataTable.Columns.Add("FileState");
+            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);
+            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()
+        {
+
+            fileNamesIndex = 0;
+            BackgroundGridIsEnabled = "False";
+            foreach (var filename in fileNames)
+            {
+            //    FileInfo fileinfo = new FileInfo(filename);
+            //    string OutputPath = fileinfo.DirectoryName;
+            //    char[] enumerationSeparator = new char[] { ',' };
+            //    char[] rangeSeparator = new char[] { '-' };
+            //    List<int> PageIndexLists = new List<int>();
+            //    CPDFDocument document = CPDFDocument.InitWithFilePath(filename);
+            //    if (document == null)
+            //    {
+            //        PDFDataTable.Rows[fileNamesIndex]["FileState"] = "文件出错";
+            //        continue;
+            //    }
+            //    if (!CommonHelper.GetPagesInRange(ref PageIndexLists, "1-" + document.PageCount.ToString(), document.PageCount, enumerationSeparator, rangeSeparator))
+            //    { //TODO
+            //        Trace.WriteLine("输入不对");
+            //        MessageBoxEx.Show("输入不对");
+            //        return;
+            //    }
+
+            //    document.Release();
+                PDFDataTable.Rows[fileNamesIndex]["FilePageRangeSelectIndex"] = "2";
+                PDFDataTable.Rows[fileNamesIndex]["FileState"] = "完成";
+                PDFCurrentDataTable.Rows[fileNamesIndex]["FilePageRangeText"] = "2";
+                PDFCurrentDataTable.Rows[fileNamesIndex]["FilePageRangeSelectIndex"] = "2";
+                PDFCurrentDataTable.Rows[fileNamesIndex]["FileState"] = "完成";
+                fileNamesIndex++;
+            }
+            BackgroundGridIsEnabled = "True";
+        }
+        #endregion
+
+        #region 批量处理逻辑函数
+        /// <summary>
+        /// 添加PDF文件
+        /// </summary>
+        private void addpicture()
+        {
+            FileNameNumber = fileNames.Count;
+            System.Windows.Forms.OpenFileDialog dlg = new System.Windows.Forms.OpenFileDialog();
+            dlg.Multiselect = true;
+            dlg.Filter = "PDF|*.pdf;*.PDF;";
+            if (dlg.ShowDialog() == System.Windows.Forms.DialogResult.OK)
+            {
+                fileNames.AddRange(dlg.FileNames.ToList());
+                RemoveExcess(ref fileNames);
+                SetBackgroundGridIsEnabled = "True";
+                AddFileVisibility = Visibility.Collapsed;
+                updateListview("待确定");
+            }
+        }
+
+        public void addPDFFiles(string filename)
+        {
+            FileNameNumber = fileNames.Count;
+            fileNames.Add(filename);
+            RemoveExcess(ref fileNames);
+            SetBackgroundGridIsEnabled = "True";
+            AddFileVisibility = Visibility.Collapsed;
+            updateListview("待确定");
+        }
+
+        /// <summary>
+        /// 删除重复的文件
+        /// </summary>
+        public void RemoveExcess(ref List<string> Filenames)
+        {
+            List<string> filenames = new List<string>();
+            foreach (var fileName in Filenames)
+            {
+                if (!filenames.Contains(fileName))
+                {
+                    filenames.Add(fileName);
+                }
+            }
+            Filenames.Clear();
+            Filenames = filenames;
+        }
+
+        /// <summary>
+        /// 添加PDF文件夹
+        /// </summary>
+        private void addpicturefiles()
+        {
+            FileNameNumber = fileNames.Count;
+            FolderBrowserDialog dialog = new FolderBrowserDialog();
+            dialog.Description = "请选择文件路径";
+            if (dialog.ShowDialog() == System.Windows.Forms.DialogResult.OK)
+            {
+
+                string foldPath = dialog.SelectedPath;
+                var apps = System.IO.Directory.GetFiles(foldPath);
+                foreach (string app in apps)
+                {
+                    var fi = new FileInfo(app);
+                    if (fi.Extension == ".pdf" || fi.Extension == ".PDF")
+                    {
+                        fileNames.Add(app);
+                    }
+                }
+                RemoveExcess(ref fileNames);
+                updateListview("待确定");
+                SetBackgroundGridIsEnabled = "True";
+                AddFileVisibility = Visibility.Collapsed;
+            }
+
+        }
+        /// <summary>
+        /// 更新listview显示
+        /// state 状态显示字符串
+        /// </summary>
+        public void updateListview(string state)
+        {
+            updateCurrentListview();
+            DataTable pdfdatatable = new DataTable();
+            pdfdatatable.Columns.Add("FileName");
+            pdfdatatable.Columns.Add("FilePageRangeText");
+            pdfdatatable.Columns.Add("FilePageRangeSelectIndex");
+            pdfdatatable.Columns.Add("FileSize");
+            pdfdatatable.Columns.Add("FileState");
+            int datatableindex = 0;
+            foreach (var fileName in fileNames)
+            {
+                string file_all = fileName;
+                FileInfo f = new FileInfo(file_all);
+                string file_size = (((float)f.Length) / 1024).ToString() + " K";
+                pdfdatatable.Rows.Add(f.Name, PDFCurrentDataTable.Rows[datatableindex]["FilePageRangeText"], PDFCurrentDataTable.Rows[datatableindex]["FilePageRangeSelectIndex"], file_size, PDFCurrentDataTable.Rows[datatableindex]["FileState"]); 
+                datatableindex++;
+            }
+            PDFDataTable = pdfdatatable;
+            HomePageBatchProcessingDialogModel.FilePaths = fileNames;
+
+        }
+
+        /// <summary>
+        /// 更新Currentlistview显示
+        /// pagerangetext 自定义页面范围字符串  pagerangeselectindex combobox下拉索引(0全部页面 1奇数页 2偶数页 3自定义页面) state 状态显示字符串
+        /// </summary>
+        public void updateCurrentListview(string pagerangetext = "1", string pagerangeselectindex = "0", string state = "待完成")
+        {
+            if (fileNames.Count >= FileNameNumber)
+            {
+                for (int i = 0; fileNames.Count - FileNameNumber > i; i++)
+                {
+                    PDFCurrentDataTable.Rows.Add(pagerangetext, pagerangeselectindex, state);
+                }
+            }
+            else
+            {
+                Reverseorder(ref fileNamesView);
+                foreach (int filenamesview in fileNamesView)
+                {
+                    PDFCurrentDataTable.Rows.RemoveAt(filenamesview);
+                }
+            }
+        }
+
+        /// <summary>
+        /// 逆序int类型集合
+        /// </summary>
+        public void Reverseorder(ref List<int> Numbers)
+        {
+            Numbers = Numbers.OrderBy(a => a).ToList();
+            Numbers.Reverse();
+        }
+
+        /// <summary>
+        /// 打开文件PDF
+        /// </summary>
+        public void openfiledialog()
+        {
+
+            foreach (int filenamesview in fileNamesView)
+            {
+                System.Diagnostics.Process.Start(fileNames[filenamesview]);
+            }
+        }
+
+        /// <summary>
+        /// 删除文件PDF
+        /// </summary>
+        public void removepdffile()
+        {
+            FileNameNumber = fileNames.Count;
+            Reverseorder(ref fileNamesView);
+            foreach (int filenamesview in fileNamesView)
+            {
+                //Trace.WriteLine(filenamesview);
+                fileNames.Remove(fileNames[filenamesview]);
+            }
+            if (fileNames.Count < 1)
+            {
+                SetBackgroundGridIsEnabled = "False";
+                AddFileVisibility = Visibility.Visible;
+            }
+            updateListview("待确定");
+        }
+
+
+        public void PDFFileCount()
+        {
+            if (fileNames.Count == 0)
+            {
+                SetBackgroundGridIsEnabled = "False";
+                AddFileVisibility = Visibility.Visible;
+            }
+            else
+            {
+                SetBackgroundGridIsEnabled = "True";
+                AddFileVisibility = Visibility.Collapsed;
+            }
+        }
+
+        #endregion
+
+        #region 构架行为
+        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);
+            }
+        }
+
+
+        public bool IsNavigationTarget(NavigationContext navigationContext)
+        {
+            return true;
+        }
+
+        public void OnNavigatedFrom(NavigationContext navigationContext)
+        {
+        }
+        #endregion
+    }
+}
+

+ 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();
+        }
+    }
+}
+

+ 1 - 2
PDF Office/ViewModels/Dialog/HomePageToolsDialogs/HomePageBatchProcessing/HomePageBatchProcessingDialogViewModel.cs

@@ -54,13 +54,12 @@ namespace PDF_Office.ViewModels.Dialog.HomePageToolsDialogs.HomePageBatchProcess
         }
         #region 逻辑函数
         public void ChangeBatchProcessing(string index) {
-            if (index=="0"||index =="1"||index=="2") { 
+            
             NavigationParameters param = new NavigationParameters();
             param.Add(ParameterNames.FilePath, HomePageBatchProcessingDialogModel.FilePaths);
             BatchProcessingVisible = Visibility.Collapsed;
             BatchProcessingRegion.RequestNavigate(BatchProcessingRegionName, HomePageBatchProcessingDialogModel.GetBatchProcessing[int.Parse(index)], param);
             BatchProcessingVisible = Visibility.Visible;
-            }
         }
         #endregion
 

+ 718 - 0
PDF Office/ViewModels/Dialog/HomePageToolsDialogs/HomePageBatchProcessing/HomePageBates/HomePageBatesCreateContentViewModel.cs

@@ -0,0 +1,718 @@
+using ComPDFKitViewer.PdfViewer;
+using PDF_Office.EventAggregators;
+using PDF_Office.Helper;
+using PDF_Office.Model.EditTools.Bates;
+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;
+using System.Windows;
+
+namespace PDF_Office.ViewModels.Dialog.HomePageToolsDialogs.HomePageBatchProcessing.HomePageBates
+{
+    public class HomePageBatesCreateContentViewModel : BindableBase, INavigationAware
+    {
+        private CPDFViewer PDFViewer;
+
+        public BatesInfo BatesInfo = new BatesInfo();
+
+        public BatesHeaderFooterItem TemplateBatesItem;
+
+        public enum EnumCreateOrEdit
+        {
+            None,
+            StatusCreate,
+            StatusEdit
+        }
+
+        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 int _fontNameSelectedIndex = 0;
+        public int FontNameSelectedIndex
+        {
+            get { return _fontNameSelectedIndex; }
+            set
+            {
+                SetProperty(ref _fontNameSelectedIndex, value);
+                SetFontName(FontNameSelectedIndex);
+                
+
+            }
+        }
+
+        private List<string> _fontSizeList = new List<string>();
+        public List<string> FontSizeList
+        {
+            get { return _fontSizeList; }
+            set
+            {
+                SetProperty(ref _fontSizeList, value);
+            }
+        }
+
+        private void InitFontSizeList()
+        {
+            FontSizeList.Clear();
+            for (int temp = 10; temp <= 15; temp += 1)
+            {
+                FontSizeList.Add(temp.ToString() + "pt");
+            }
+        }
+
+        private int _fontSizeSelectedIndex = 0;
+        public int FontSizeSelectedIndex
+        {
+            get { return _fontSizeSelectedIndex; }
+            set
+            {
+                SetProperty(ref _fontSizeSelectedIndex, value);
+                SetFontSize(FontSizeSelectedIndex);
+                
+            }
+        }
+
+        private List<string> _starPagetNumberList = new List<string>();
+        public List<string> StarPagetNumberList
+        {
+            get { return _starPagetNumberList; }
+            set
+            {
+                SetProperty(ref _starPagetNumberList, value);
+            }
+        }
+
+        private void InitStarPagetNumberList()
+        {
+            StarPagetNumberList.Clear();
+            for (int temp = 10; temp <= 15; temp += 1)
+            {
+                StarPagetNumberList.Add(temp.ToString());
+            }
+        }
+
+        private int _starPagetNumberIndex = 0;
+        public int StarPagetNumberIndex
+        {
+            get { return _starPagetNumberIndex; }
+            set
+            {
+                SetProperty(ref _starPagetNumberIndex, value);
+                SetStarPagetNumber(StarPagetNumberIndex);
+            }
+        }
+
+        public string _pageRangeText = "0";
+        public string PageRangeText
+        {
+            get { return _pageRangeText; }
+            set
+            {
+                _pageRangeText = value;
+                //EditToolsHelper.GetPageRange(PageRangeSelectIndex, PDFViewer.Document, ref BatesInfo.PageRange, PageRangeText);
+                
+            }
+        }
+
+        private int _pageRangeSelectIndex = 0;
+        public int PageRangeSelectIndex
+        {
+            get { return _pageRangeSelectIndex; }
+            set
+            {
+                SetProperty(ref _pageRangeSelectIndex, value);
+                BatesInfo.PageRangeIndex = PageRangeSelectIndex;
+                //EditToolsHelper.GetPageRange(PageRangeSelectIndex, PDFViewer.Document, ref BatesInfo.PageRange, PageRangeText);
+                
+            }
+        }
+
+        private SolidColorBrush _solidColorBrush = new SolidColorBrush(Color.FromArgb(0xFF, 0xFF, 0x00, 0x00));
+        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);
+                SolidColorBrush = new SolidColorBrush(StringColor);
+                for (int i = 0; i <= 5; i++)
+                {
+                    BatesInfo.TextData[i].Color = EditToolsHelper.ConvertColor(value);
+                }
+                
+
+            }
+        }
+
+
+        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 _createBaseVisible;
+        public Visibility CreateBaseVisible
+        {
+            get => _createBaseVisible;
+            set => SetProperty(ref _createBaseVisible, value);
+        }
+
+        private Visibility _editBaseVisible;
+        public Visibility EditBaseVisible
+        {
+            get => _editBaseVisible;
+            set => SetProperty(ref _editBaseVisible, value);
+        }
+
+        private string _marginTopValue = "3";
+        public string MarginTopValue
+        {
+            get { return _marginTopValue; }
+            set
+            {
+                SetProperty(ref _marginTopValue, value);
+                bool ValueEQ = true;
+                if (BatesInfo.margin[1] == float.Parse(MarginTopValue))
+                {
+                    ValueEQ = false;
+                }
+                BatesInfo.margin[1] = float.Parse(MarginTopValue);
+                if (ValueEQ)
+                {
+                    
+                }
+            }
+        }
+
+        private string _marginDownValue = "3";
+        public string MarginDownValue
+        {
+            get { return _marginDownValue; }
+            set
+            {
+                SetProperty(ref _marginDownValue, value);
+                bool ValueEQ = true;
+                if (BatesInfo.margin[3] == float.Parse(MarginTopValue))
+                {
+                    ValueEQ = false;
+                }
+                BatesInfo.margin[3] = float.Parse(MarginDownValue);
+                if (ValueEQ)
+                {
+                    
+                }
+            }
+        }
+
+        private string _marginLeftValue = "3";
+        public string MarginLeftValue
+        {
+            get { return _marginLeftValue; }
+            set
+            {
+                SetProperty(ref _marginLeftValue, value);
+                bool ValueEQ = true;
+                if (BatesInfo.margin[0] == float.Parse(MarginTopValue))
+                {
+                    ValueEQ = false;
+                }
+                BatesInfo.margin[0] = float.Parse(MarginLeftValue);
+                if (ValueEQ)
+                {
+                    
+                }
+            }
+        }
+
+        private string _marginRightValue = "3";
+        public string MarginRightValue
+        {
+            get { return _marginRightValue; }
+            set
+            {
+                SetProperty(ref _marginRightValue, value);
+                bool ValueEQ = true;
+                if (BatesInfo.margin[2] == float.Parse(MarginTopValue))
+                {
+                    ValueEQ = false;
+                }
+                if (ValueEQ)
+                {
+                    BatesInfo.margin[2] = float.Parse(MarginRightValue);
+                    
+                }
+            }
+        }
+
+        private string _digitNumberValue = "1";
+        public string DigitNumberValue
+        {
+            get { return _digitNumberValue; }
+            set
+            {
+                SetProperty(ref _digitNumberValue, value);
+                BatesInfo.DigitNumber = int.Parse(DigitNumberValue);
+            }
+        }
+
+
+        private string _textValue = "";
+        public string TextValue
+        {
+            get { return _textValue; }
+            set
+            {
+                SetProperty(ref _textValue, value);
+            }
+        }
+
+
+        private string _prefixTextValue = "";
+        public string PrefixTextValue
+        {
+            get { return _prefixTextValue; }
+            set
+            {
+
+                _prefixTextValue = value;
+
+            }
+        }
+
+        private string _surfixTextValue = "";
+        public string SurfixTextValue
+        {
+            get { return _surfixTextValue; }
+            set
+            {
+                _surfixTextValue = value;
+            }
+        }
+
+        public int GetLocationIndex = 0;
+
+        private Dictionary<string, string> _getTextValueFromNumber = new Dictionary<string, string>();
+        public Dictionary<string, string> GetTextValueFromNumber
+        {
+            get { return _getTextValueFromNumber; }
+            set
+            {
+                _getTextValueFromNumber = value;
+            }
+        }
+
+        public IEventAggregator eventAggregator;
+
+        public DelegateCommand<object> ChangeLocationCommand { get; set; }
+        public DelegateCommand EnterTemplateListCommand { get; set; }
+        public DelegateCommand SaveToTemplateListCommand { get; set; }
+        public DelegateCommand SaveToCurrentTemplateListCommand { get; set; }
+        public DelegateCommand<object> SelectedColorChangedCommand { get; set; }
+        public DelegateCommand<object> TextValueChangedCommand { get; set; }
+        public DelegateCommand ADDBatesCommand { get; set; }
+
+        public string Unicode = null;
+
+        public HomePageBatesCreateContentViewModel(IEventAggregator eventAggregator)
+        {
+            this.eventAggregator = eventAggregator;
+            Unicode = App.mainWindowViewModel.SelectedItem.Unicode;
+            for (int i = 0; i <= 5; i++)
+            {
+                BatesInfo.TextData[i].Color = EditToolsHelper.ConvertColor(Color.FromArgb(0xFF, 0xFF, 0x00, 0x00));
+            }
+            InitList();
+            InitBatesInfo();
+            ChangeLocationCommand = new DelegateCommand<object>(ChangeLocation);
+            SelectedColorChangedCommand = new DelegateCommand<object>(ChangedColor);
+            EnterTemplateListCommand = new DelegateCommand(EnterTemplateList);
+            SaveToTemplateListCommand = new DelegateCommand(SaveToTemplateList);
+            SaveToCurrentTemplateListCommand = new DelegateCommand(SaveToCurrentTemplateList);
+            TextValueChangedCommand = new DelegateCommand<object>(TextValueChanged);
+            ADDBatesCommand = new DelegateCommand(ADDBates);
+        }
+
+        private void InitList()
+        {
+
+            InitFontNameList();
+            InitFontSizeList();
+            InitStarPagetNumberList();
+            InitLocationButtonMatrix();
+
+        }
+
+        private void InitLocationButtonMatrix()
+        {
+            GetTextValueFromNumber.Clear();
+            for (var temp = 0; temp <= 5; temp++)
+            {
+                GetTextValueFromNumber.Add(temp.ToString(), temp.ToString());
+            }
+        }
+
+        private void InitBatesInfo()
+        {
+            for (int i = 0; i <= 5; i++)
+            {
+                BatesInfo.TextData[i].text = GetTextValueFromNumber[i.ToString()];
+            }
+            BatesInfo.margin[0] = float.Parse(MarginTopValue);
+            BatesInfo.margin[1] = float.Parse(MarginRightValue);
+            BatesInfo.margin[2] = float.Parse(MarginDownValue);
+            BatesInfo.margin[3] = float.Parse(MarginLeftValue);
+            BatesInfo.Prefix = PrefixTextValue;
+            BatesInfo.Suffix = SurfixTextValue;
+            BatesInfo.DigitNumber = int.Parse(DigitNumberValue);
+            SetFontName(FontNameSelectedIndex);
+            SetFontSize(FontSizeSelectedIndex);
+            SetStarPagetNumber(StarPagetNumberIndex);
+            StringColor = Color.FromArgb(0xFF, 0xFF, 0x00, 0x00);
+        }
+
+        private void SetFontName(int Index)
+        {
+            for (int i = 0; i <= 5; i++) { BatesInfo.TextData[i].fontName = FontNameList[Index]; }
+        }
+
+        private void SetFontSize(int Index)
+        {
+            for (int i = 0; i <= 5; i++) { BatesInfo.TextData[i].fontSize = (Index + 7) * 1.33f; }
+        }
+
+        private void SetStarPagetNumber(int Index)
+        {
+            BatesInfo.StarPagetNumber = Index;
+        }
+
+
+        public void ChangeLocation(object e)
+        {
+            string args = e as string;
+            if (args != null)
+            {
+                GetLocationIndex = int.Parse(args);
+                TextValue = GetTextValueFromNumber[args];
+
+            }
+        }
+
+        private void ChangedColor(object obj)
+        {
+            if (obj != null)
+            {
+                var colorValue = (Color)obj;
+                if (colorValue != null)
+                {
+
+                    StringColor = colorValue;
+                }
+            }
+        }
+
+        public void EnterTemplateList()
+        {
+            this.eventAggregator.GetEvent<EnterTemplateListOrCreateEvent>().Publish(new EnumTemplateListOrCreateUnicode { Unicode = Unicode, Status = EnumTemplateListOrCreate.StatusTemplate });
+        }
+
+        public void SaveToTemplateList()
+        {
+            SaveCurrentTemplate();
+        }
+
+        public void SaveToCurrentTemplateList()
+        {
+            ConfirmEditBackgroundTemplateItem();
+        }
+
+        private void TextValueChanged(object obj)
+        {
+            if (obj != null)
+            {
+                var textValue = obj as System.Windows.Controls.TextBox;
+                if (textValue != null)
+                {
+                    bool TextEQ = true;
+                    switch (textValue.Name)
+                    {
+                        case "TextValueTextBox":
+
+                            if (GetTextValueFromNumber[GetLocationIndex.ToString()] == textValue.Text)
+                            {
+                                TextEQ = false;
+                            }
+                            GetTextValueFromNumber[GetLocationIndex.ToString()] = textValue.Text;
+                            BatesInfo.TextData[GetLocationIndex].text = GetTextValueFromNumber[GetLocationIndex.ToString()];
+
+                            break;
+                        case "PrefixTextValueTextBox":
+                            if (BatesInfo.Prefix == textValue.Text)
+                            {
+                                TextEQ = false;
+                            }
+                            BatesInfo.Prefix = textValue.Text;
+
+                            break;
+                        case "SuffixTextValueTextBox":
+                            if (BatesInfo.Suffix == textValue.Text)
+                            {
+                                TextEQ = false;
+                            }
+                            BatesInfo.Suffix = textValue.Text;
+                            break;
+                        default:
+                            break;
+                    }
+                    if (TextEQ)
+                    {
+                        
+                    }
+
+                }
+            }
+        }
+
+        public void ADDBates()
+        {
+            if (PrefixTextValue == "" || SurfixTextValue == "")
+            {
+                if (SurfixTextValue == "" && PrefixTextValue == "")
+                {
+                    GetTextValueFromNumber[GetLocationIndex.ToString()] = GetTextValueFromNumber[GetLocationIndex.ToString()] + "<<" + "#" + DigitNumberValue + "#" + (StarPagetNumberIndex + 1).ToString() + ">>";
+                }
+                else if (SurfixTextValue == "")
+                {
+                    GetTextValueFromNumber[GetLocationIndex.ToString()] = GetTextValueFromNumber[GetLocationIndex.ToString()] + "<<" + "#" + DigitNumberValue + "#" + (StarPagetNumberIndex + 1).ToString() + "#" + PrefixTextValue + ">>";
+                }
+                else
+                {
+                    GetTextValueFromNumber[GetLocationIndex.ToString()] = GetTextValueFromNumber[GetLocationIndex.ToString()] + "<<" + "#" + DigitNumberValue + "#" + (StarPagetNumberIndex + 1).ToString() + "#" + "#" + SurfixTextValue + ">>";
+                }
+            }
+            else
+            {
+                GetTextValueFromNumber[GetLocationIndex.ToString()] = GetTextValueFromNumber[GetLocationIndex.ToString()] + "<<" + "#" + DigitNumberValue + "#" + (StarPagetNumberIndex + 1).ToString() + "#" + PrefixTextValue + "#" + SurfixTextValue + ">>";
+            }
+            BatesInfo.TextData[GetLocationIndex].text = GetTextValueFromNumber[GetLocationIndex.ToString()];
+            
+        }
+
+        public void ConvertInfoToItem(ref BatesHeaderFooterItem batesItem, BatesInfo batesInfo)
+        {
+            batesItem.TextData = batesInfo.TextData;
+            batesItem.DigitNumber = batesInfo.DigitNumber;
+            batesItem.ItemName = batesInfo.ItemName;
+            batesItem.Prefix = batesInfo.Prefix;
+            batesItem.Suffix = batesInfo.Suffix;
+            batesItem.StarPagetNumber = batesInfo.StarPagetNumber;
+            batesItem.margin = batesInfo.margin;
+            batesItem.PageRange = batesInfo.PageRange;
+            batesItem.PageRangeIndex = batesInfo.PageRangeIndex;
+
+        }
+
+        public void ConvertItemToInfo(BatesHeaderFooterItem batesItem, ref BatesInfo batesInfo)
+        {
+            batesInfo.TextData = batesItem.TextData;
+            batesInfo.ItemName = batesItem.ItemName;
+            batesInfo.DigitNumber = batesItem.DigitNumber;
+            batesInfo.Prefix = batesItem.Prefix;
+            batesInfo.Suffix = batesItem.Suffix;
+            batesInfo.StarPagetNumber = batesItem.StarPagetNumber;
+            batesInfo.margin = batesItem.margin;
+            batesInfo.PageRangeIndex = batesItem.PageRangeIndex;
+            //EditToolsHelper.GetPageRange(batesInfo.PageRangeIndex, PDFViewer.Document, ref batesInfo.PageRange, batesItem.PageRange);
+
+        }
+
+        public void SaveCurrentTemplate()
+        {
+            var batesItem = new BatesHeaderFooterItem();
+            ConvertInfoToItem(ref batesItem, BatesInfo);
+            batesItem.ItemName += Settings.Default.BatesTemplateList.Count().ToString();
+            try
+            {
+                //创建缓存文件夹
+                string folderPath = Path.Combine(App.CurrentPath, "Bates");
+                //有可能因为其他原因存在同名文件,导致创建文件夹失败,需要先删除同名文件
+                //保险措施(猜测)
+                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);
+                Settings.Default.BatesTemplateList.Add(batesItem);
+                Settings.Default.Save();
+            }
+            catch
+            {
+
+            }
+
+            this.eventAggregator.GetEvent<EnterTemplateListOrCreateEvent>().Publish(new EnumTemplateListOrCreateUnicode
+            {
+                Unicode = Unicode,
+                Status = EnumTemplateListOrCreate.StatusTemplate
+            });
+        }
+
+        public void ConfirmEditBackgroundTemplateItem()
+        {
+
+            var batesItem = new BatesHeaderFooterItem();
+            ConvertInfoToItem(ref batesItem, BatesInfo);
+            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();
+                }
+                Settings.Default.BatesTemplateList[TemplateBatesItem.listIndex] = batesItem;
+                Settings.Default.Save();
+            }
+            catch
+            {
+
+            }
+            this.eventAggregator.GetEvent<EnterTemplateListOrCreateEvent>().Publish(new EnumTemplateListOrCreateUnicode
+            {
+                Unicode = Unicode,
+                Status = EnumTemplateListOrCreate.StatusTemplate
+            });
+
+        }
+
+        public void InitComponentBySelectedInfo()
+        {
+            ConvertItemToInfo(TemplateBatesItem, ref BatesInfo);
+            for (int i = 0; i <= 5; i++)
+            {
+                GetTextValueFromNumber[i.ToString()] = BatesInfo.TextData[i].text;
+            }
+            MarginTopValue = BatesInfo.margin[0].ToString();
+            MarginRightValue = BatesInfo.margin[1].ToString();
+            MarginDownValue = BatesInfo.margin[2].ToString();
+            MarginLeftValue = BatesInfo.margin[3].ToString();
+            PrefixTextValue = BatesInfo.Prefix;
+            SurfixTextValue = BatesInfo.Suffix;
+            DigitNumberValue = BatesInfo.DigitNumber.ToString();
+            FontNameSelectedIndex = FontNameList.IndexOf(BatesInfo.TextData[0].fontName);
+            FontSizeSelectedIndex = FontSizeList.IndexOf(BatesInfo.TextData[0].fontSize.ToString());
+            StarPagetNumberIndex = StarPagetNumberList.IndexOf(BatesInfo.StarPagetNumber.ToString());
+            StringColor = EditToolsHelper.ConvertColor(BatesInfo.TextData[0].Color);
+            SolidColorBrush = new SolidColorBrush(StringColor);
+            PageRangeSelectIndex = BatesInfo.PageRangeIndex;
+        }
+        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 BatesInfo.PageRange, PageRangeText);
+
+            if (navigationContext.Parameters.TryGetValue<BatesHeaderFooterItem>("BatesItem", out TemplateBatesItem))
+            {
+                CreateOrEdit = EnumCreateOrEdit.StatusEdit;
+                InitComponentBySelectedInfo();
+            }
+            else
+            {
+                CreateOrEdit = EnumCreateOrEdit.StatusCreate;
+            }
+        }
+
+
+    }
+}
+

+ 485 - 0
PDF Office/ViewModels/Dialog/HomePageToolsDialogs/HomePageBatchProcessing/HomePageBates/HomePageBatesDialogViewModel.cs

@@ -0,0 +1,485 @@
+using ComPDFKit.PDFDocument;
+using PDF_Office.CustomControl;
+using PDF_Office.Model.Dialog.HomePageToolsDialogs.HomePageBatchProcessing;
+using PDF_Office.Model;
+using Prism.Commands;
+using Prism.Mvvm;
+using Prism.Regions;
+using System;
+using System.Collections.Generic;
+using System.Data;
+using System.Diagnostics;
+using System.IO;
+using System.Linq;
+using PDF_Office.Helper;
+using System.Windows;
+using System.Windows.Forms;
+using ComPDFKitViewer.PdfViewer;
+using Prism.Events;
+using PDF_Office.EventAggregators;
+using PDFSettings;
+using ImTools;
+
+namespace PDF_Office.ViewModels.Dialog.HomePageToolsDialogs.HomePageBatchProcessing.HomePageBates
+{
+    public class HomePageBatesDialogViewModel : BindableBase, INavigationAware
+    {
+        #region 参数和属性
+        private List<string> fileNames;
+
+
+        private CPDFDocument tempDocument;
+
+        public string PageNumber = "";
+
+        public IEventAggregator eventAggregator;
+        public IRegionManager batesRegion;
+
+        private CPDFViewer PDFViewer;
+
+        private ViewContentViewModel viewContentViewModel;
+
+        public string TemplateListName = "HomePageBatesTemplateListContent";
+        public string CreateName = "HomePageBatesCreateContent";
+
+        public string BatesDocumentName = "HomePageBatesDocumentContent";
+
+        public string BatesType = "HomePageBatesType";
+
+        public List<int> fileNamesView = new List<int>();
+
+        private int fileNamesIndex = 0;
+
+        private int FileNameNumber = 0;
+
+        private string _batesSettingsRegionName;
+        /// <summary>
+        /// 属性设置Region
+        /// </summary>
+        public string BatesSettingsRegionName
+        {
+            get { return _batesSettingsRegionName; }
+            set { _batesSettingsRegionName = value; }
+        }
+
+        private Visibility _batesSettingsVisible = Visibility.Visible;
+        /// <summary>
+        /// 属性设置Region可见
+        /// </summary>
+        public Visibility BatesSettingsVisible
+        {
+            get { return _batesSettingsVisible; }
+            set { _batesSettingsVisible = value; }
+        }
+
+        private string batesGridIsEnabled = "True";
+        public string BatesGridIsEnabled
+        {
+            get
+            {
+                return batesGridIsEnabled;
+            }
+            set
+            {
+                SetProperty(ref batesGridIsEnabled, value);
+            }
+        }
+
+        private string setBatesGridIsEnabled = "True";
+        public string SetBatesGridIsEnabled
+        {
+            get
+            {
+                return setBatesGridIsEnabled;
+            }
+            set
+            {
+                SetProperty(ref setBatesGridIsEnabled, value);
+            }
+        }
+
+        private DataTable pdfDataTable = new DataTable();
+        public DataTable PDFDataTable
+        {
+            get { return pdfDataTable; }
+            set
+            {
+                SetProperty(ref pdfDataTable, value);
+            }
+        }
+
+        private DataTable pdfCurrentDataTable = new DataTable();
+        public DataTable PDFCurrentDataTable
+        {
+            get { return pdfCurrentDataTable; }
+            set
+            {
+                SetProperty(ref pdfCurrentDataTable, value);
+            }
+        }
+
+        private string removeIsEnable = "False";
+        public string RemoveIsEnable
+        {
+            get { return removeIsEnable; }
+            set
+            {
+                SetProperty(ref removeIsEnable, value);
+            }
+        }
+
+        private string selectFileName = "False";
+        public string SelectFileName
+        {
+            get { return selectFileName; }
+            set
+            {
+                SetProperty(ref selectFileName, value);
+            }
+        }
+
+        private Visibility batesVisible = Visibility.Collapsed;
+        public Visibility BatesVisible
+        {
+            get { return batesVisible; }
+            set { SetProperty(ref batesVisible, value); }
+        }
+
+        private Visibility addFileVisibility = Visibility.Hidden;
+        public Visibility AddFileVisibility
+        {
+            get { return addFileVisibility; }
+            set
+            {
+                SetProperty(ref addFileVisibility, value);
+                RaisePropertyChanged();
+
+            }
+        }
+        #endregion
+
+        #region 委托声明
+        public DelegateCommand ADDPDFCommand { get; set; }
+
+        public DelegateCommand RemovePDFFileCommand { get; set; }
+
+        public DelegateCommand CreateCommand { get; set; }
+
+        public DelegateCommand ADDPDFFilesCommand { get; set; }
+        #endregion
+
+        public string Unicode = null;
+
+        public HomePageBatesDialogViewModel(IRegionManager batesRegion, IEventAggregator eventAggregator)
+        {
+            this.eventAggregator = eventAggregator;
+            this.batesRegion = batesRegion;
+            BatesSettingsRegionName = Guid.NewGuid().ToString();
+            Unicode = App.mainWindowViewModel.SelectedItem.Unicode;
+            PDFCurrentDataTable.Columns.Add("FilePageRangeText");
+            PDFCurrentDataTable.Columns.Add("FilePageRangeSelectIndex");
+            PDFCurrentDataTable.Columns.Add("FileState");
+            PDFDataTable.Columns.Add("FileName");
+            PDFDataTable.Columns.Add("FilePageRangeText");
+            PDFDataTable.Columns.Add("FilePageRangeSelectIndex");
+            PDFDataTable.Columns.Add("FileSize");
+            PDFDataTable.Columns.Add("FileState");
+            ADDPDFCommand = new DelegateCommand(addpicture);
+            ADDPDFFilesCommand = new DelegateCommand(addpicturefiles);
+            RemovePDFFileCommand = new DelegateCommand(removepdffile);
+            CreateCommand = new DelegateCommand(create);
+            eventAggregator.GetEvent<EditBatesHeaderFooterTemplateItemEvent>().Subscribe(EditBatesTemplateItem, e => e.Unicode == Unicode && e.Type == BatesType);
+            eventAggregator.GetEvent<EnterTemplateListOrCreateEvent>().Subscribe(EnterTemplateListOrCreate, e => e.Unicode == Unicode);
+        }
+        #region 逻辑函数
+        public void EditBatesTemplateItem(BatesHeaderFooterItemUnicode batesItemunicode)
+        {
+            BatesHeaderFooterItem batesItem = batesItemunicode.Status;
+            NavigationParameters param = new NavigationParameters();
+            param.Add(ParameterNames.PDFViewer, PDFViewer);
+            param.Add("BatesItem", batesItem);
+            batesRegion.RequestNavigate(BatesSettingsRegionName, CreateName, param);
+            BatesSettingsVisible = Visibility.Visible;
+        }
+
+        public void EnterTemplateListOrCreate(EnumTemplateListOrCreateUnicode enumTemplateListOrCreateunicode)
+        {
+            EnumTemplateListOrCreate enumTemplateListOrCreate = enumTemplateListOrCreateunicode.Status;
+            if (enumTemplateListOrCreate == EnumTemplateListOrCreate.StatusTemplate)
+            {
+                EnterSelectedContent(TemplateListName);
+            }
+            else
+            {
+                EnterSelectedContent(CreateName);
+            }
+        }
+
+        public void EnterSelectedContent(string SelectedContentName)
+        {
+            NavigationParameters param = new NavigationParameters();
+            param.Add(ParameterNames.PDFViewer, PDFViewer);
+            batesRegion.RequestNavigate(BatesSettingsRegionName, SelectedContentName, param);
+            BatesSettingsVisible = Visibility.Visible;
+        }
+
+        private void create()
+        {
+
+            fileNamesIndex = 0;
+            BatesGridIsEnabled = "False";
+            foreach (var filename in fileNames)
+            {
+                //FileInfo fileinfo = new FileInfo(filename);
+                //string OutputPath = fileinfo.DirectoryName;
+                //char[] enumerationSeparator = new char[] { ',' };
+                //char[] rangeSeparator = new char[] { '-' };
+                //List<int> PageIndexLists = new List<int>();
+                //CPDFDocument document = CPDFDocument.InitWithFilePath(filename);
+                //if (document == null)
+                //{
+                //    PDFDataTable.Rows[fileNamesIndex]["FileState"] = "文件出错";
+                //    continue;
+                //}
+                //if (!CommonHelper.GetPagesInRange(ref PageIndexLists, "1-" + document.PageCount.ToString(), document.PageCount, enumerationSeparator, rangeSeparator))
+                //{ //TODO
+                //    Trace.WriteLine("输入不对");
+                //    MessageBoxEx.Show("输入不对");
+                //    return;
+                //}
+
+                //document.Release();
+                PDFDataTable.Rows[fileNamesIndex]["FilePageRangeSelectIndex"] = "2";
+                PDFDataTable.Rows[fileNamesIndex]["FileState"] = "完成";
+                PDFCurrentDataTable.Rows[fileNamesIndex]["FilePageRangeText"] = "2";
+                PDFCurrentDataTable.Rows[fileNamesIndex]["FilePageRangeSelectIndex"] = "2";
+                PDFCurrentDataTable.Rows[fileNamesIndex]["FileState"] = "完成";
+                fileNamesIndex++;
+            }
+            BatesGridIsEnabled = "True";
+        }
+        #endregion
+
+        #region 批量处理逻辑函数
+        /// <summary>
+        /// 添加PDF文件
+        /// </summary>
+        private void addpicture()
+        {
+            FileNameNumber = fileNames.Count;
+            System.Windows.Forms.OpenFileDialog dlg = new System.Windows.Forms.OpenFileDialog();
+            dlg.Multiselect = true;
+            dlg.Filter = "PDF|*.pdf;*.PDF;";
+            if (dlg.ShowDialog() == System.Windows.Forms.DialogResult.OK)
+            {
+                fileNames.AddRange(dlg.FileNames.ToList());
+                RemoveExcess(ref fileNames);
+                SetBatesGridIsEnabled = "True";
+                AddFileVisibility = Visibility.Collapsed;
+                updateListview("待确定");
+            }
+        }
+        /// <summary>
+        /// 拖拽添加PDF文件
+        /// </summary>
+        public void addPDFFiles(string filename)
+        {
+            FileNameNumber = fileNames.Count;
+            fileNames.Add(filename);
+            RemoveExcess(ref fileNames);
+            SetBatesGridIsEnabled = "True";
+            AddFileVisibility = Visibility.Collapsed;
+            updateListview("待确定");
+        }
+
+        /// <summary>
+        /// 删除重复的文件
+        /// </summary>
+        public void RemoveExcess(ref List<string> Filenames)
+        {
+            List<string> filenames = new List<string>();
+            foreach (var fileName in Filenames)
+            {
+                if (!filenames.Contains(fileName))
+                {
+                    filenames.Add(fileName);
+                }
+            }
+            Filenames.Clear();
+            Filenames = filenames;
+        }
+
+        /// <summary>
+        /// 添加PDF文件夹
+        /// </summary>
+        private void addpicturefiles()
+        {
+            FileNameNumber = fileNames.Count;
+            FolderBrowserDialog dialog = new FolderBrowserDialog();
+            dialog.Description = "请选择文件路径";
+            if (dialog.ShowDialog() == System.Windows.Forms.DialogResult.OK)
+            {
+
+                string foldPath = dialog.SelectedPath;
+                var apps = System.IO.Directory.GetFiles(foldPath);
+                foreach (string app in apps)
+                {
+                    var fi = new FileInfo(app);
+                    if (fi.Extension == ".pdf" || fi.Extension == ".PDF")
+                    {
+                        fileNames.Add(app);
+                    }
+                }
+                RemoveExcess(ref fileNames);
+                updateListview("待确定");
+                SetBatesGridIsEnabled = "True";
+                AddFileVisibility = Visibility.Collapsed;
+            }
+
+        }
+        /// <summary>
+        /// 更新listview显示
+        /// state 状态显示字符串
+        /// </summary>
+        public void updateListview(string state)
+        {
+            updateCurrentListview();
+            DataTable pdfdatatable = new DataTable();
+            pdfdatatable.Columns.Add("FileName");
+            pdfdatatable.Columns.Add("FilePageRangeText");
+            pdfdatatable.Columns.Add("FilePageRangeSelectIndex");
+            pdfdatatable.Columns.Add("FileSize");
+            pdfdatatable.Columns.Add("FileState");
+            int datatableindex = 0;
+            foreach (var fileName in fileNames)
+            {
+                string file_all = fileName;
+                FileInfo f = new FileInfo(file_all);
+                string file_size = (((float)f.Length) / 1024).ToString() + " K";
+
+                pdfdatatable.Rows.Add(f.Name, PDFCurrentDataTable.Rows[datatableindex]["FilePageRangeText"], PDFCurrentDataTable.Rows[datatableindex]["FilePageRangeSelectIndex"], file_size, PDFCurrentDataTable.Rows[datatableindex]["FileState"]);
+                datatableindex++;
+
+
+
+            }
+            PDFDataTable = pdfdatatable;
+            HomePageBatchProcessingDialogModel.FilePaths = fileNames;
+
+        }
+        /// <summary>
+        /// 更新Currentlistview显示
+        /// pagerangetext 自定义页面范围字符串  pagerangeselectindex combobox下拉索引(0全部页面 1奇数页 2偶数页 3自定义页面) state 状态显示字符串
+        /// </summary>
+        public void updateCurrentListview(string pagerangetext = "1", string pagerangeselectindex = "0", string state = "待完成")
+        {
+            if (fileNames.Count >= FileNameNumber)
+            {
+                for (int i = 0; fileNames.Count - FileNameNumber > i; i++)
+                {
+                    PDFCurrentDataTable.Rows.Add(pagerangetext, pagerangeselectindex, state);
+                    //PDFCurrentDataTable.Rows[i]["FilePageRangeText"] = pagerangetext;
+                    //PDFCurrentDataTable.Rows[i]["FilePageRangeSelectIndex"] = pagerangeselectindex;
+                    //PDFCurrentDataTable.Rows[i]["FileState"] = state;
+                }
+            }
+            else
+            {
+                Reverseorder(ref fileNamesView);
+                foreach (int filenamesview in fileNamesView)
+                {
+                    PDFCurrentDataTable.Rows.RemoveAt(filenamesview);
+                }
+            }
+        }
+        /// <summary>
+        /// 逆序int类型集合
+        /// </summary>
+        public void Reverseorder(ref List<int> Numbers)
+        {
+            Numbers = Numbers.OrderBy(a => a).ToList();
+            Numbers.Reverse();
+        }
+
+        /// <summary>
+        /// 打开文件PDF
+        /// </summary>
+        public void openfiledialog()
+        {
+
+            foreach (int filenamesview in fileNamesView)
+            {
+                System.Diagnostics.Process.Start(fileNames[filenamesview]);
+            }
+        }
+
+        /// <summary>
+        /// 删除文件PDF
+        /// </summary>
+        public void removepdffile()
+        {
+            FileNameNumber = fileNames.Count;
+            Reverseorder(ref fileNamesView);
+            foreach (int filenamesview in fileNamesView)
+            {
+                //Trace.WriteLine(filenamesview);
+                fileNames.Remove(fileNames[filenamesview]);
+            }
+            if (fileNames.Count < 1)
+            {
+                SetBatesGridIsEnabled = "False";
+                AddFileVisibility = Visibility.Visible;
+            }
+
+            updateListview("待确定");
+        }
+
+
+        public void PDFFileCount()
+        {
+            if (fileNames.Count == 0)
+            {
+                SetBatesGridIsEnabled = "False";
+                AddFileVisibility = Visibility.Visible;
+            }
+            else
+            {
+                SetBatesGridIsEnabled = "True";
+                AddFileVisibility = Visibility.Collapsed;
+            }
+        }
+
+
+
+        #endregion
+
+        #region 构架行为
+        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(TemplateListName);
+            }
+        }
+
+
+        public bool IsNavigationTarget(NavigationContext navigationContext)
+        {
+            return true;
+        }
+
+        public void OnNavigatedFrom(NavigationContext navigationContext)
+        {
+        }
+        #endregion
+    }
+}
+

+ 229 - 0
PDF Office/ViewModels/Dialog/HomePageToolsDialogs/HomePageBatchProcessing/HomePageBates/HomePageBatesTemplateListContentViewModel.cs

@@ -0,0 +1,229 @@
+using ComPDFKitViewer.PdfViewer;
+using PDF_Office.EventAggregators;
+using PDF_Office.Helper;
+using PDF_Office.Model.EditTools.Bates;
+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.Collections.ObjectModel;
+using System.Linq;
+using System.Windows.Controls;
+using System.Windows;
+
+namespace PDF_Office.ViewModels.Dialog.HomePageToolsDialogs.HomePageBatchProcessing.HomePageBates
+{
+    public class HomePageBatesTemplateListContentViewModel : BindableBase, INavigationAware
+    {
+        private CPDFViewer PDFViewer;
+        public IEventAggregator eventAggregator;
+        public BatesInfo BatesInfo = new BatesInfo();
+        public BatesHeaderFooterItem BatesItem = new BatesHeaderFooterItem();
+        public int TemplateIndex = 0;
+
+        private ObservableCollection<BatesHeaderFooterItem> batesModCollection = new ObservableCollection<BatesHeaderFooterItem>();
+        public ObservableCollection<BatesHeaderFooterItem> BatesModCollection
+        {
+            get { return batesModCollection; }
+            set
+            {
+                batesModCollection = 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 DelegateCommand EnterCreateCommand { get; set; }
+
+        public string Unicode = null;
+
+        public HomePageBatesTemplateListContentViewModel(IEventAggregator eventAggregator)
+        {
+            this.eventAggregator = eventAggregator;
+            Unicode = App.mainWindowViewModel.SelectedItem.Unicode;
+            EnterCreateCommand = new DelegateCommand(EnterCreate);
+            AddTemplateCommand = new DelegateCommand(AddTemplate);
+            EditTemplateItemCommand = new DelegateCommand<object>(RequestEditTemplateItem);
+            DeleteTemplateItemCommand = new DelegateCommand<object>(DeleteTemplateItem);
+            DeleteAllTemplateItemCommand = new DelegateCommand(DeleteAllTemplateItem);
+            SelectTemplateItemCommand = new DelegateCommand<object>(SelectTemplateItem);
+        }
+
+        private void InitBackgroundTemplateList()
+        {
+            if (Settings.Default.BatesTemplateList == null)
+            {
+                Settings.Default.BatesTemplateList = new BatesTemplateList();
+            }
+            GetBatesSource();
+        }
+
+        public void EnterCreate()
+        {
+            this.eventAggregator.GetEvent<EnterTemplateListOrCreateEvent>().Publish(new EnumTemplateListOrCreateUnicode { Unicode = Unicode, Status = EnumTemplateListOrCreate.StatusCreate });
+        }
+
+        public void AddTemplate()
+        {
+            this.eventAggregator.GetEvent<EnterTemplateListOrCreateEvent>().Publish(new EnumTemplateListOrCreateUnicode
+            {
+                Unicode = Unicode,
+                Status = EnumTemplateListOrCreate.StatusCreate
+            });
+        }
+
+        public void SaveEditedBatesTemplateItem(BatesHeaderFooterItemUnicode BatesItemunicode)
+        {
+            BatesHeaderFooterItem batesItem = BatesItemunicode.Status;
+
+            Settings.Default.BatesTemplateList[TemplateIndex] = batesItem;
+            Settings.Default.Save();
+
+            GetBatesSource();
+        }
+
+        public void RequestEditTemplateItem(object e)
+        {
+            var control = e as Control;
+            if (control == null)
+            {
+                return;
+            }
+            var template = control.DataContext as BatesHeaderFooterItem;
+            if (template == null)
+            {
+                return;
+            }
+            TemplateIndex = Settings.Default.BatesTemplateList.IndexOf(template);
+            template.listIndex = TemplateIndex;
+            ConvertItemToInfo(template, ref BatesInfo);
+            this.eventAggregator.GetEvent<EditBatesHeaderFooterTemplateItemEvent>().Publish(new BatesHeaderFooterItemUnicode
+            {
+                Unicode = Unicode,
+                Type = "HomePageBatesType",
+                Status = template
+            });
+        }
+
+        public void DeleteTemplateItem(object e)
+        {
+            var btn = e as System.Windows.Controls.Button;
+            if (btn == null)
+            {
+                return;
+            }
+            BatesItem = btn.DataContext as BatesHeaderFooterItem;
+            if (BatesItem == null)
+            {
+                return;
+            }
+
+            Settings.Default.BatesTemplateList.Remove(BatesItem);
+            Settings.Default.Save();
+            BatesModCollection.Remove(BatesItem);
+            GetBatesSource();
+        }
+
+        public void DeleteAllTemplateItem()
+        {
+            while (Settings.Default.BatesTemplateList.Count != 0)
+            {
+                int temp = 0;
+                var template = Settings.Default.BatesTemplateList[temp];
+
+                Settings.Default.BatesTemplateList.Remove(template);
+                Settings.Default.Save();
+
+                BatesModCollection.Remove(template);
+
+            }
+            GetBatesSource();
+        }
+
+        public void SelectTemplateItem(object e)
+        {
+            var listBox = e as ListBox;
+            BatesHeaderFooterItem BatesItem = listBox.SelectedItem as BatesHeaderFooterItem;
+            SendTemplateItemToDocument(BatesItem);
+        }
+
+        public void SendTemplateItemToDocument(BatesHeaderFooterItem template)
+        {
+            if (template != null)
+            {
+                ConvertItemToInfo(template, ref BatesInfo);
+                
+            }
+
+        }
+
+        private void GetBatesSource()
+        {
+            List<BatesHeaderFooterItem> batesModColorTemplateList = new List<BatesHeaderFooterItem>();
+            for (int temp = 0; temp < Settings.Default.BatesTemplateList.Count; temp++)
+            {
+                Settings.Default.BatesTemplateList[temp].ItemName = (temp + 1).ToString();
+                batesModColorTemplateList.Add(Settings.Default.BatesTemplateList[temp]);
+
+            }
+            BatesModCollection = new ObservableCollection<BatesHeaderFooterItem>(batesModColorTemplateList);
+            CheckTemplateListIsEmpty(batesModColorTemplateList);
+        }
+
+        public void ConvertItemToInfo(BatesHeaderFooterItem batesItem, ref BatesInfo batesInfo)
+        {
+            batesInfo.TextData = batesItem.TextData;
+            batesInfo.ItemName = batesItem.ItemName;
+            batesInfo.DigitNumber = batesItem.DigitNumber;
+            batesInfo.Prefix = batesItem.Prefix;
+            batesInfo.Suffix = batesItem.Suffix;
+            batesInfo.StarPagetNumber = batesItem.StarPagetNumber;
+            batesInfo.margin = batesItem.margin;
+            batesInfo.PageRangeIndex = batesItem.PageRangeIndex;
+            //EditToolsHelper.GetPageRange(batesInfo.PageRangeIndex, PDFViewer.Document, ref batesInfo.PageRange, batesItem.PageRange);
+
+        }
+        private void CheckTemplateListIsEmpty(List<BatesHeaderFooterItem> batesTemplateList)
+        {
+            if (batesTemplateList.Count() == 0)
+            {
+                CreateTemplateVisible = Visibility.Visible;
+            }
+            else
+            {
+                CreateTemplateVisible = Visibility.Collapsed;
+            }
+        }
+
+        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);
+            InitBackgroundTemplateList();
+        }
+    }
+}

+ 56 - 1
PDF Office/ViewModels/Dialog/HomePageToolsDialogs/HomePageBatchProcessing/HomePageCompressDialogViewModel.cs

@@ -30,6 +30,8 @@ namespace PDF_Office.ViewModels.Dialog.HomePageToolsDialogs.HomePageBatchProcess
 
         private int fileNamesIndex = 0;
 
+        private int FileNameNumber = 0;
+
         private IntPtr compressingIntpr = IntPtr.Zero;
 
         private CPDFDocument.GetPageIndexDelegate indexDelegate = null;
@@ -46,6 +48,16 @@ namespace PDF_Office.ViewModels.Dialog.HomePageToolsDialogs.HomePageBatchProcess
             }
         }
 
+        private DataTable pdfCurrentDataTable = new DataTable();
+        public DataTable PDFCurrentDataTable
+        {
+            get { return pdfCurrentDataTable; }
+            set
+            {
+                SetProperty(ref pdfCurrentDataTable, value);
+            }
+        }
+
         private string compressGridIsEnabled="True";
         public string CompressGridIsEnabled
         {
@@ -119,6 +131,7 @@ namespace PDF_Office.ViewModels.Dialog.HomePageToolsDialogs.HomePageBatchProcess
 
         public HomePageCompressDialogViewModel()
         {
+            PDFCurrentDataTable.Columns.Add("FileState");
             PDFDataTable.Columns.Add("FileName");
             PDFDataTable.Columns.Add("FileSize");
             PDFDataTable.Columns.Add("FileState");
@@ -168,6 +181,7 @@ namespace PDF_Office.ViewModels.Dialog.HomePageToolsDialogs.HomePageBatchProcess
                 CPDFDocument document = CPDFDocument.InitWithFilePath(filename);
                 if (document == null) {
                     PDFDataTable.Rows[fileNamesIndex]["FileState"] = "文件出错";
+                    PDFCurrentDataTable.Rows[fileNamesIndex]["FileState"] = "文件出错";
                     continue;
                 }
                 FileInfo fileinfo = new FileInfo(filename);
@@ -177,6 +191,7 @@ namespace PDF_Office.ViewModels.Dialog.HomePageToolsDialogs.HomePageBatchProcess
                 tempDocument = document;
                 await Task.Run<bool>(() => { return document.CompressFile_Start(compressingIntpr, filename+"compress.pdf"); });
                 PDFDataTable.Rows[fileNamesIndex]["FileState"] = "完成";
+                PDFCurrentDataTable.Rows[fileNamesIndex]["FileState"] = "完成";
                 fileNamesIndex++;
                 document.Release();
             }
@@ -192,6 +207,7 @@ namespace PDF_Office.ViewModels.Dialog.HomePageToolsDialogs.HomePageBatchProcess
         /// </summary>
         private void addpicture()
         {
+            FileNameNumber = fileNames.Count;
             System.Windows.Forms.OpenFileDialog dlg = new System.Windows.Forms.OpenFileDialog();
             dlg.Multiselect = true;
             dlg.Filter = "PDF|*.pdf;*.PDF;";
@@ -205,6 +221,16 @@ namespace PDF_Office.ViewModels.Dialog.HomePageToolsDialogs.HomePageBatchProcess
             }
         }
 
+        public void addPDFFiles(string filename)
+        {
+            FileNameNumber = fileNames.Count;
+            fileNames.Add(filename);
+            RemoveExcess(ref fileNames);
+            SetCompressGridIsEnabled = "True";
+            AddFileVisibility = Visibility.Collapsed;
+            updateListview("待确定");
+        }
+
         /// <summary>
         /// 删除重复的文件
         /// </summary>
@@ -227,6 +253,7 @@ namespace PDF_Office.ViewModels.Dialog.HomePageToolsDialogs.HomePageBatchProcess
         /// </summary>
         private void addpicturefiles()
         {
+            FileNameNumber = fileNames.Count;
             FolderBrowserDialog dialog = new FolderBrowserDialog();
             dialog.Description = "请选择文件路径";
             if (dialog.ShowDialog() == System.Windows.Forms.DialogResult.OK)
@@ -255,21 +282,48 @@ namespace PDF_Office.ViewModels.Dialog.HomePageToolsDialogs.HomePageBatchProcess
         /// </summary>
         public void updateListview(string state)
         {
+            updateCurrentListview();
             DataTable pdfdatatable = new DataTable();
             pdfdatatable.Columns.Add("FileName");
             pdfdatatable.Columns.Add("FileSize");
             pdfdatatable.Columns.Add("FileState");
+            int datatableindex = 0;
             foreach (var fileName in fileNames)
             {
                 string file_all = fileName;
                 FileInfo f = new FileInfo(file_all);
                 string file_size = (((float)f.Length) / 1024).ToString() + " K";
-                pdfdatatable.Rows.Add(f.Name, file_size, state);
+                pdfdatatable.Rows.Add(f.Name, file_size, PDFCurrentDataTable.Rows[datatableindex]["FileState"]);
+                datatableindex++;
             }
             PDFDataTable = pdfdatatable;
             HomePageBatchProcessingDialogModel.FilePaths = fileNames;
 
         }
+
+        /// <summary>
+        /// 更新Currentlistview显示
+        /// state 状态显示字符串
+        /// </summary>
+        public void updateCurrentListview(string state = "待完成")
+        {
+            if (fileNames.Count >= FileNameNumber)
+            {
+                for (int i = 0; fileNames.Count - FileNameNumber > i; i++)
+                {
+                    PDFCurrentDataTable.Rows.Add(state);
+                }
+            }
+            else
+            {
+                Reverseorder(ref fileNamesView);
+                foreach (int filenamesview in fileNamesView)
+                {
+                    PDFCurrentDataTable.Rows.RemoveAt(filenamesview);
+                }
+            }
+        }
+
         /// <summary>
         /// 逆序int类型集合
         /// </summary>
@@ -296,6 +350,7 @@ namespace PDF_Office.ViewModels.Dialog.HomePageToolsDialogs.HomePageBatchProcess
         /// </summary>
         public void removepdffile()
         {
+            FileNameNumber = fileNames.Count;
             Reverseorder(ref fileNamesView);
             foreach (int filenamesview in fileNamesView)
             {

+ 59 - 2
PDF Office/ViewModels/Dialog/HomePageToolsDialogs/HomePageBatchProcessing/HomePageConverter/HomePageConverterDialogViewModel.cs

@@ -50,6 +50,8 @@ namespace PDF_Office.ViewModels.Dialog.HomePageToolsDialogs.HomePageBatchProcess
 
         private int fileNamesIndex = 0;
 
+        private int FileNameNumber = 0;
+
         public List<string> ConverterTypeFamily { set; get; } = new List<string>();
 
         private void SetImageTypeOrigin()
@@ -100,6 +102,16 @@ namespace PDF_Office.ViewModels.Dialog.HomePageToolsDialogs.HomePageBatchProcess
             }
         }
 
+        private DataTable pdfCurrentDataTable = new DataTable();
+        public DataTable PDFCurrentDataTable
+        {
+            get { return pdfCurrentDataTable; }
+            set
+            {
+                SetProperty(ref pdfCurrentDataTable, value);
+            }
+        }
+
         private string removeIsEnable = "False";
         public string RemoveIsEnable
         {
@@ -167,6 +179,7 @@ namespace PDF_Office.ViewModels.Dialog.HomePageToolsDialogs.HomePageBatchProcess
         {
 
             SetImageTypeOrigin();
+            PDFCurrentDataTable.Columns.Add("FileState");
             PDFDataTable.Columns.Add("FileName");
             PDFDataTable.Columns.Add("FileSize");
             PDFDataTable.Columns.Add("FileState");
@@ -203,6 +216,7 @@ namespace PDF_Office.ViewModels.Dialog.HomePageToolsDialogs.HomePageBatchProcess
                 if (document == null)
                 {
                     PDFDataTable.Rows[fileNamesIndex]["FileState"] = "文件出错";
+                    PDFCurrentDataTable.Rows[fileNamesIndex]["FileState"] = "文件出错";
                     continue;
                 }
                 if (!CommonHelper.GetPagesInRange(ref PageIndexLists, "1-" + document.PageCount.ToString(),document.PageCount, enumerationSeparator, rangeSeparator))
@@ -241,6 +255,7 @@ namespace PDF_Office.ViewModels.Dialog.HomePageToolsDialogs.HomePageBatchProcess
                         if (ConverterRTFModel != null)
                         {
                             PageNumber = ConverterRTFModel.PageIndexLists.Count().ToString();
+                            result = await ConverterHelper.RTFConvert(filename, OutputPath, GetProgress, PageIndexLists, ConverterRTFModel.Pawssword);
                         }
                         break;
                     case 4:
@@ -248,6 +263,7 @@ namespace PDF_Office.ViewModels.Dialog.HomePageToolsDialogs.HomePageBatchProcess
                         if (ConverterHTMLModel != null)
                         {
                             PageNumber = ConverterHTMLModel.PageIndexLists.Count().ToString();
+                            result = await ConverterHelper.HTMLConvert(filename, OutputPath, GetProgress, PageIndexLists, ConverterHTMLModel.Pawssword, ConverterHTMLModel.HTMLOptions());
                         }
                         break;
                     case 5:
@@ -270,7 +286,7 @@ namespace PDF_Office.ViewModels.Dialog.HomePageToolsDialogs.HomePageBatchProcess
                         if (ConverterImgModel != null)
                         {
                             PageNumber = ConverterImgModel.PageIndexLists.Count().ToString();
-                            result = await ConverterHelper.ImgConvert(filename, OutputPath, GetProgress, PageIndexLists, ConverterImgModel.Pawssword, ConverterImgModel.Type);
+                            result = await ConverterHelper.ImgConvert(filename, OutputPath, GetProgress, PageIndexLists, ConverterImgModel.Pawssword, ConverterImgModel.Type, ConverterImgModel.imageType);
                         }
                         break;
                     default:
@@ -278,6 +294,7 @@ namespace PDF_Office.ViewModels.Dialog.HomePageToolsDialogs.HomePageBatchProcess
                 }
                 document.Release();
                 PDFDataTable.Rows[fileNamesIndex]["FileState"] = "完成";
+                PDFCurrentDataTable.Rows[fileNamesIndex]["FileState"] = "完成";
                 fileNamesIndex++;
             }
             ConverterGridIsEnabled = "True";
@@ -290,6 +307,7 @@ namespace PDF_Office.ViewModels.Dialog.HomePageToolsDialogs.HomePageBatchProcess
         /// </summary>
         private void addpicture()
         {
+            FileNameNumber = fileNames.Count;
             System.Windows.Forms.OpenFileDialog dlg = new System.Windows.Forms.OpenFileDialog();
             dlg.Multiselect = true;
             dlg.Filter = "PDF|*.pdf;*.PDF;";
@@ -303,6 +321,16 @@ namespace PDF_Office.ViewModels.Dialog.HomePageToolsDialogs.HomePageBatchProcess
             }
         }
 
+        public void addPDFFiles(string filename)
+        {
+            FileNameNumber = fileNames.Count;
+            fileNames.Add(filename);
+            RemoveExcess(ref fileNames);
+            SetConverterGridIsEnabled = "True"; 
+            AddFileVisibility = Visibility.Collapsed;
+            updateListview("待确定");
+        }
+
         /// <summary>
         /// 删除重复的文件
         /// </summary>
@@ -325,6 +353,7 @@ namespace PDF_Office.ViewModels.Dialog.HomePageToolsDialogs.HomePageBatchProcess
         /// </summary>
         private void addpicturefiles()
         {
+            FileNameNumber = fileNames.Count;
             FolderBrowserDialog dialog = new FolderBrowserDialog();
             dialog.Description = "请选择文件路径";
             if (dialog.ShowDialog() == System.Windows.Forms.DialogResult.OK)
@@ -353,21 +382,48 @@ namespace PDF_Office.ViewModels.Dialog.HomePageToolsDialogs.HomePageBatchProcess
         /// </summary>
         public void updateListview(string state)
         {
+            updateCurrentListview();
             DataTable pdfdatatable = new DataTable();
             pdfdatatable.Columns.Add("FileName");
             pdfdatatable.Columns.Add("FileSize");
             pdfdatatable.Columns.Add("FileState");
+            int datatableindex = 0;
             foreach (var fileName in fileNames)
             {
                 string file_all = fileName;
                 FileInfo f = new FileInfo(file_all);
                 string file_size = (((float)f.Length) / 1024).ToString() + " K";
-                pdfdatatable.Rows.Add(f.Name, file_size, state);
+                pdfdatatable.Rows.Add(f.Name, file_size, PDFCurrentDataTable.Rows[datatableindex]["FileState"]);
+                datatableindex++;
             }
             PDFDataTable = pdfdatatable;
             HomePageBatchProcessingDialogModel.FilePaths = fileNames;
 
         }
+
+        /// <summary>
+        /// 更新Currentlistview显示
+        /// state 状态显示字符串
+        /// </summary>
+        public void updateCurrentListview(string state = "待完成")
+        {
+            if (fileNames.Count >= FileNameNumber)
+            {
+                for (int i = 0; fileNames.Count - FileNameNumber > i; i++)
+                {
+                    PDFCurrentDataTable.Rows.Add(state);
+                }
+            }
+            else
+            {
+                Reverseorder(ref fileNamesView);
+                foreach (int filenamesview in fileNamesView)
+                {
+                    PDFCurrentDataTable.Rows.RemoveAt(filenamesview);
+                }
+            }
+        }
+
         /// <summary>
         /// 逆序int类型集合
         /// </summary>
@@ -394,6 +450,7 @@ namespace PDF_Office.ViewModels.Dialog.HomePageToolsDialogs.HomePageBatchProcess
         /// </summary>
         public void removepdffile()
         {
+            FileNameNumber = fileNames.Count;
             Reverseorder(ref fileNamesView);
             foreach (int filenamesview in fileNamesView)
             {

+ 3 - 0
PDF Office/ViewModels/Dialog/HomePageToolsDialogs/HomePageBatchProcessing/HomePageConverter/HomePageConverterExcelViewModel.cs

@@ -43,6 +43,9 @@ namespace PDF_Office.ViewModels.Dialog.HomePageToolsDialogs.HomePageBatchProcess
                     case "OnlyTableRadioBtn":
                         homePageConverterDialogViewModel.ConverterExcelModel.excelOption = ConverterExcelModel.ExcelOptions(WorksheetOptions.ForEachTable, ContentOptions.OnlyTable);
                         break;
+                    case "OnlyTextRadioBtn":
+                        ConverterExcelModel.excelOption = ConverterExcelModel.ExcelOptions(WorksheetOptions.ForTheDocument, ContentOptions.OnlyText);
+                        break;
                     default:
                         break;
                 }

+ 39 - 1
PDF Office/ViewModels/Dialog/HomePageToolsDialogs/HomePageBatchProcessing/HomePageConverter/HomePageConverterImgViewModel.cs

@@ -1,4 +1,5 @@
-using PDF_Office.Model;
+using ComPDFKit_Conversion.Converter;
+using PDF_Office.Model;
 using Prism.Commands;
 using Prism.Mvvm;
 using Prism.Regions;
@@ -44,6 +45,43 @@ namespace PDF_Office.ViewModels.Dialog.HomePageToolsDialogs.HomePageBatchProcess
             SetImageTypeOrigin();
             SetImageDPIOrigin();
         }
+
+        public void UpdateImageType(int index)
+        {
+            this.homePageConverterDialogViewModel.ConverterImgModel.Type = ImgType.PNG;
+            switch (index)
+            {
+                //case结果是同样的情况下,case可堆叠在一起,表示处理方式一样
+                case 0:
+                    this.homePageConverterDialogViewModel.ConverterImgModel.imageType = ".jpeg";
+                    break;
+                case 7:
+                    this.homePageConverterDialogViewModel.ConverterImgModel.imageType = ".jp2";
+                    break;
+                case 3:
+                    this.homePageConverterDialogViewModel.ConverterImgModel.imageType = ".gif";
+                    break;
+                case 4:
+                    this.homePageConverterDialogViewModel.ConverterImgModel.imageType = ".tiff";
+                    break;
+                case 5:
+                    this.homePageConverterDialogViewModel.ConverterImgModel.imageType = ".tga";
+                    break;
+                case 6:
+                    this.homePageConverterDialogViewModel.ConverterImgModel.imageType = ".bmp";
+                    break;
+                case 2:
+                    this.homePageConverterDialogViewModel.ConverterImgModel.imageType = ".png";
+                    break;
+                case 1:
+                    this.homePageConverterDialogViewModel.ConverterImgModel.imageType = ".jpg";
+                    this.homePageConverterDialogViewModel.ConverterImgModel.Type = ImgType.JPEG;
+                    break;
+                default:
+                    break;
+            }
+        }
+
         #region 构架行为
         public void OnNavigatedTo(NavigationContext navigationContext)
         {

+ 730 - 0
PDF Office/ViewModels/Dialog/HomePageToolsDialogs/HomePageBatchProcessing/HomePageHeaderFooter/HomePageHeaderFooterCreateContentViewModel.cs

@@ -0,0 +1,730 @@
+using ComPDFKitViewer.PdfViewer;
+using PDF_Office.EventAggregators;
+using PDF_Office.Helper;
+using PDF_Office.Model.EditTools.HeaderFooter;
+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;
+using System.Windows;
+
+namespace PDF_Office.ViewModels.Dialog.HomePageToolsDialogs.HomePageBatchProcessing.HomePageHeaderFooter
+{
+    public class HomePageHeaderFooterCreateContentViewModel : BindableBase, INavigationAware
+    {
+        private CPDFViewer PDFViewer;
+
+        public HeaderFooterInfo HeaderFooterInfo = new HeaderFooterInfo();
+
+        public BatesHeaderFooterItem TemplateHeaderFooterItem;
+
+        public enum EnumCreateOrEdit
+        {
+            None,
+            StatusCreate,
+            StatusEdit
+        }
+
+        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 int _fontNameSelectedIndex = 0;
+        public int FontNameSelectedIndex
+        {
+            get { return _fontNameSelectedIndex; }
+            set
+            {
+                SetProperty(ref _fontNameSelectedIndex, value);
+                SetFontName(FontNameSelectedIndex);
+                
+            }
+        }
+
+        private List<string> _fontSizeList = new List<string>();
+        public List<string> FontSizeList
+        {
+            get { return _fontSizeList; }
+            set
+            {
+                SetProperty(ref _fontSizeList, value);
+            }
+        }
+
+        private void InitFontSizeList()
+        {
+            FontSizeList.Clear();
+            for (int temp = 10; temp <= 15; temp += 1)
+            {
+                FontSizeList.Add(temp.ToString() + "pt");
+            }
+        }
+
+        private int _fontSizeSelectedIndex = 0;
+        public int FontSizeSelectedIndex
+        {
+            get { return _fontSizeSelectedIndex; }
+            set
+            {
+                SetProperty(ref _fontSizeSelectedIndex, value);
+                SetFontSize(FontSizeSelectedIndex);
+                
+            }
+        }
+
+        private List<string> _starPagetNumberList = new List<string>();
+        public List<string> StarPagetNumberList
+        {
+            get { return _starPagetNumberList; }
+            set
+            {
+                SetProperty(ref _starPagetNumberList, value);
+            }
+        }
+
+        private void InitStarPagetNumberList()
+        {
+            StarPagetNumberList.Clear();
+            for (int temp = 10; temp <= 15; temp += 1)
+            {
+                StarPagetNumberList.Add(temp.ToString());
+            }
+        }
+
+        private int _starPagetNumberIndex = 0;
+        public int StarPagetNumberIndex
+        {
+            get { return _starPagetNumberIndex; }
+            set
+            {
+                SetProperty(ref _starPagetNumberIndex, value);
+                SetStarPagetNumber(StarPagetNumberIndex);
+                
+            }
+        }
+
+        private List<string> _pageNumberFormatList = new List<string>();
+        public List<string> PageNumberFormatList
+        {
+            get { return _pageNumberFormatList; }
+            set
+            {
+                SetProperty(ref _pageNumberFormatList, value);
+            }
+        }
+
+        private void InitPageNumberFormatList()
+        {
+            PageNumberFormatList.Clear();
+            PageNumberFormatList.Add("1");
+            PageNumberFormatList.Add("1 of n");
+            PageNumberFormatList.Add("1/n");
+            PageNumberFormatList.Add("Page 1");
+            PageNumberFormatList.Add("Page 1 of n");
+        }
+
+        private int _pageNumberFormatIndex = 0;
+        public int PageNumberFormatIndex
+        {
+            get { return _pageNumberFormatIndex; }
+            set
+            {
+                SetProperty(ref _pageNumberFormatIndex, value);
+                SetPageNumberFormat(PageNumberFormatIndex);
+            }
+        }
+
+        private List<string> _dateTimeFormatList = new List<string>();
+        public List<string> DateTimeFormatList
+        {
+            get { return _dateTimeFormatList; }
+            set
+            {
+                SetProperty(ref _dateTimeFormatList, value);
+            }
+        }
+
+        private void InitDateTimeFormatList()
+        {
+            DateTimeFormatList.Clear();
+            DateTimeFormatList.Add("m/d");
+            DateTimeFormatList.Add("m/d/yy");
+            DateTimeFormatList.Add("m/d/yyyy");
+            DateTimeFormatList.Add("mm/dd/yy");
+            DateTimeFormatList.Add("mm/dd/yyyy");
+            DateTimeFormatList.Add("d/m/yy");
+            DateTimeFormatList.Add("d/m/yyyy");
+            DateTimeFormatList.Add("dd/mm/yy");
+            DateTimeFormatList.Add("dd/mm/yyyy");
+            DateTimeFormatList.Add("mm/yy");
+            DateTimeFormatList.Add("mm/yyyy");
+            DateTimeFormatList.Add("m.d.yy");
+            DateTimeFormatList.Add("m.d.yyyy");
+            DateTimeFormatList.Add("mm.dd.yy");
+            DateTimeFormatList.Add("mm.dd.yyyy");
+            DateTimeFormatList.Add("mm.yy");
+            DateTimeFormatList.Add("mm.yyyy");
+            DateTimeFormatList.Add("d.m.yy");
+            DateTimeFormatList.Add("dd.mm.yy");
+            DateTimeFormatList.Add("dd.mm.yyyy");
+            DateTimeFormatList.Add("yy-mm-dd");
+            DateTimeFormatList.Add("yyyy-mm-dd");
+        }
+
+        private int _dateTimeFormatIndex = 0;
+        public int DateTimeFormatIndex
+        {
+            get { return _dateTimeFormatIndex; }
+            set
+            {
+                SetProperty(ref _dateTimeFormatIndex, value);
+                SetDateTimeFormat(DateTimeFormatIndex);
+            }
+        }
+
+        public string _pageRangeText = "0";
+        public string PageRangeText
+        {
+            get { return _pageRangeText; }
+            set
+            {
+                _pageRangeText = value;
+                //EditToolsHelper.GetPageRange(PageRangeSelectIndex, PDFViewer.Document, ref HeaderFooterInfo.PageRange, PageRangeText);
+                
+            }
+        }
+
+        private int _pageRangeSelectIndex = 0;
+        public int PageRangeSelectIndex
+        {
+            get { return _pageRangeSelectIndex; }
+            set
+            {
+                SetProperty(ref _pageRangeSelectIndex, value);
+                HeaderFooterInfo.PageRangeIndex = PageRangeSelectIndex;
+                //EditToolsHelper.GetPageRange(PageRangeSelectIndex, PDFViewer.Document, ref HeaderFooterInfo.PageRange, PageRangeText);
+               
+            }
+        }
+
+        private SolidColorBrush _solidColorBrush = new SolidColorBrush(Color.FromArgb(0xFF, 0xFF, 0x00, 0x00));
+        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);
+                SolidColorBrush = new SolidColorBrush(StringColor);
+                for (int i = 0; i <= 5; i++)
+                {
+                    HeaderFooterInfo.TextData[i].Color = EditToolsHelper.ConvertColor(value);
+                }
+                
+            }
+        }
+
+        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 _createBaseVisible;
+        public Visibility CreateBaseVisible
+        {
+            get => _createBaseVisible;
+            set => SetProperty(ref _createBaseVisible, value);
+        }
+
+        private Visibility _editBaseVisible;
+        public Visibility EditBaseVisible
+        {
+            get => _editBaseVisible;
+            set => SetProperty(ref _editBaseVisible, value);
+        }
+
+        private string _marginTopValue = "3";
+        public string MarginTopValue
+        {
+            get { return _marginTopValue; }
+            set
+            {
+                SetProperty(ref _marginTopValue, value);
+                bool ValueEQ = true;
+                if (HeaderFooterInfo.margin[1] == float.Parse(MarginTopValue))
+                {
+                    ValueEQ = false;
+                }
+                HeaderFooterInfo.margin[1] = float.Parse(MarginTopValue);
+                if (ValueEQ)
+                {
+                    
+                }
+            }
+        }
+
+        private string _marginDownValue = "3";
+        public string MarginDownValue
+        {
+            get { return _marginDownValue; }
+            set
+            {
+                SetProperty(ref _marginDownValue, value);
+                bool ValueEQ = true;
+                if (HeaderFooterInfo.margin[3] == float.Parse(MarginTopValue))
+                {
+                    ValueEQ = false;
+                }
+                HeaderFooterInfo.margin[3] = float.Parse(MarginDownValue);
+                if (ValueEQ)
+                {
+                   
+                }
+            }
+        }
+
+        private string _marginLeftValue = "3";
+        public string MarginLeftValue
+        {
+            get { return _marginLeftValue; }
+            set
+            {
+                SetProperty(ref _marginLeftValue, value);
+                bool ValueEQ = true;
+                if (HeaderFooterInfo.margin[0] == float.Parse(MarginTopValue))
+                {
+                    ValueEQ = false;
+                }
+                HeaderFooterInfo.margin[0] = float.Parse(MarginLeftValue);
+                if (ValueEQ)
+                {
+                   
+                }
+            }
+        }
+
+        private string _marginRightValue = "3";
+        public string MarginRightValue
+        {
+            get { return _marginRightValue; }
+            set
+            {
+                SetProperty(ref _marginRightValue, value);
+                bool ValueEQ = true;
+                if (HeaderFooterInfo.margin[2] == float.Parse(MarginTopValue))
+                {
+                    ValueEQ = false;
+                }
+                if (ValueEQ)
+                {
+                   
+                }
+            }
+        }
+
+        private string _textValue = "";
+        public string TextValue
+        {
+            get { return _textValue; }
+            set
+            {
+                SetProperty(ref _textValue, value);
+
+            }
+        }
+
+        public int GetLocationIndex = 0;
+
+        private Dictionary<string, string> _getTextValueFromNumber = new Dictionary<string, string>();
+        public Dictionary<string, string> GetTextValueFromNumber
+        {
+            get { return _getTextValueFromNumber; }
+            set
+            {
+                _getTextValueFromNumber = value;
+            }
+        }
+
+        public IEventAggregator eventAggregator;
+
+        public DelegateCommand<object> ChangeLocationCommand { get; set; }
+        public DelegateCommand EnterTemplateListCommand { get; set; }
+        public DelegateCommand SaveToTemplateListCommand { get; set; }
+        public DelegateCommand SaveToCurrentTemplateListCommand { get; set; }
+        public DelegateCommand<object> SelectedColorChangedCommand { get; set; }
+        public DelegateCommand<object> TextValueChangedCommand { get; set; }
+        public DelegateCommand ADDDateCommand { get; set; }
+        public DelegateCommand ADDPagesCommand { get; set; }
+        public string Unicode = null;
+        public HomePageHeaderFooterCreateContentViewModel(IEventAggregator eventAggregator)
+        {
+            this.eventAggregator = eventAggregator;
+            Unicode = App.mainWindowViewModel.SelectedItem.Unicode;
+            for (int i = 0; i <= 5; i++)
+            {
+                HeaderFooterInfo.TextData[i].Color = EditToolsHelper.ConvertColor(Color.FromArgb(0xFF, 0xFF, 0x00, 0x00));
+            }
+            InitList();
+            InitHeaderFooterInfo();
+            ChangeLocationCommand = new DelegateCommand<object>(ChangeLocation);
+            SelectedColorChangedCommand = new DelegateCommand<object>(ChangedColor);
+            EnterTemplateListCommand = new DelegateCommand(EnterTemplateList);
+            SaveToTemplateListCommand = new DelegateCommand(SaveToTemplateList);
+            SaveToCurrentTemplateListCommand = new DelegateCommand(SaveToCurrentTemplateList);
+            TextValueChangedCommand = new DelegateCommand<object>(TextValueChanged);
+            ADDDateCommand = new DelegateCommand(ADDDate);
+            ADDPagesCommand = new DelegateCommand(ADDPages);
+        }
+
+        private void InitList()
+        {
+
+            InitFontNameList();
+            InitFontSizeList();
+            InitStarPagetNumberList();
+            InitDateTimeFormatList();
+            InitPageNumberFormatList();
+            InitLocationButtonMatrix();
+
+        }
+
+        private void InitLocationButtonMatrix()
+        {
+            GetTextValueFromNumber.Clear();
+            for (var temp = 0; temp <= 5; temp++)
+            {
+                GetTextValueFromNumber.Add(temp.ToString(), "");
+            }
+        }
+
+        private void InitHeaderFooterInfo()
+        {
+            for (int i = 0; i <= 5; i++)
+            {
+                HeaderFooterInfo.TextData[i].text = GetTextValueFromNumber[i.ToString()];
+            }
+            HeaderFooterInfo.margin[0] = float.Parse(MarginTopValue);
+            HeaderFooterInfo.margin[1] = float.Parse(MarginRightValue);
+            HeaderFooterInfo.margin[2] = float.Parse(MarginDownValue);
+            HeaderFooterInfo.margin[3] = float.Parse(MarginLeftValue);
+            SetFontName(FontNameSelectedIndex);
+            SetFontSize(FontSizeSelectedIndex);
+            SetDateTimeFormat(DateTimeFormatIndex);
+            SetPageNumberFormat(PageNumberFormatIndex);
+            SetStarPagetNumber(StarPagetNumberIndex);
+            StringColor = Color.FromArgb(0xFF, 0xFF, 0x00, 0x00);
+        }
+
+        private void SetFontName(int Index)
+        {
+            for (int i = 0; i <= 5; i++) { HeaderFooterInfo.TextData[i].fontName = FontNameList[Index]; }
+        }
+
+        private void SetFontSize(int Index)
+        {
+            for (int i = 0; i <= 5; i++) { HeaderFooterInfo.TextData[i].fontSize = (Index + 7) * 1.33f; }
+        }
+
+        private void SetDateTimeFormat(int Index)
+        {
+            HeaderFooterInfo.DateTimeFormat = DateTimeFormatList[Index];
+        }
+
+        private void SetPageNumberFormat(int Index)
+        {
+            HeaderFooterInfo.PageNumberFormat = PageNumberFormatList[Index];
+        }
+
+        private void SetStarPagetNumber(int Index)
+        {
+            HeaderFooterInfo.StarPagetNumber = Index;
+        }
+
+        public void ChangeLocation(object e)
+        {
+            string args = e as string;
+            if (args != null)
+            {
+                GetLocationIndex = int.Parse(args);
+                TextValue = GetTextValueFromNumber[args];
+
+            }
+        }
+        private void ChangedColor(object obj)
+        {
+            if (obj != null)
+            {
+                var colorValue = (Color)obj;
+                if (colorValue != null)
+                {
+
+                    StringColor = colorValue;
+                }
+            }
+        }
+
+        public void EnterTemplateList()
+        {
+            this.eventAggregator.GetEvent<EnterTemplateListOrCreateEvent>().Publish(new EnumTemplateListOrCreateUnicode { Unicode = Unicode, Status = EnumTemplateListOrCreate.StatusTemplate });
+        }
+
+        public void SaveToTemplateList()
+        {
+            SaveCurrentTemplate();
+            this.eventAggregator.GetEvent<EnterTemplateListOrCreateEvent>().Publish(new EnumTemplateListOrCreateUnicode { Unicode = Unicode, Status = EnumTemplateListOrCreate.StatusTemplate });
+        }
+
+        public void SaveToCurrentTemplateList()
+        {
+            ConfirmEditBackgroundTemplateItem();
+            this.eventAggregator.GetEvent<EnterTemplateListOrCreateEvent>().Publish(new EnumTemplateListOrCreateUnicode { Unicode = Unicode, Status = EnumTemplateListOrCreate.StatusTemplate });
+        }
+
+        private void TextValueChanged(object obj)
+        {
+            if (obj != null)
+            {
+                var textValue = obj as System.Windows.Controls.TextBox;
+                if (textValue != null)
+                {
+                    bool TextEQ = true;
+                    if (GetTextValueFromNumber[GetLocationIndex.ToString()] == textValue.Text)
+                    {
+                        TextEQ = false;
+                    }
+                    GetTextValueFromNumber[GetLocationIndex.ToString()] = textValue.Text;
+                    HeaderFooterInfo.TextData[GetLocationIndex].text = GetTextValueFromNumber[GetLocationIndex.ToString()];
+                    if (TextEQ)
+                    {
+                       
+                    }
+
+                }
+            }
+
+        }
+
+        public void ADDDate()
+        {
+            GetTextValueFromNumber[GetLocationIndex.ToString()] = GetTextValueFromNumber[GetLocationIndex.ToString()] + "<<" + DateTimeFormatList[DateTimeFormatIndex] + ">>";
+            TextValue = GetTextValueFromNumber[GetLocationIndex.ToString()];
+            HeaderFooterInfo.TextData[GetLocationIndex].text = GetTextValueFromNumber[GetLocationIndex.ToString()];
+          
+        }
+        public void ADDPages()
+        {
+            GetTextValueFromNumber[GetLocationIndex.ToString()] = GetTextValueFromNumber[GetLocationIndex.ToString()] + "<<" + PageNumberFormatList[PageNumberFormatIndex] + ">>";
+            TextValue = GetTextValueFromNumber[GetLocationIndex.ToString()];
+            HeaderFooterInfo.TextData[GetLocationIndex].text = GetTextValueFromNumber[GetLocationIndex.ToString()];
+           
+        }
+
+        public void ConvertInfoToItem(ref BatesHeaderFooterItem headerFooterItem, HeaderFooterInfo headerFooterInfo)
+        {
+            headerFooterItem.TextData = headerFooterInfo.TextData;
+            headerFooterItem.ItemName = headerFooterInfo.ItemName;
+            headerFooterItem.DateTimeFormat = headerFooterInfo.DateTimeFormat;
+            headerFooterItem.StarPagetNumber = headerFooterInfo.StarPagetNumber;
+            headerFooterItem.PageNumberFormat = headerFooterInfo.PageNumberFormat;
+            headerFooterItem.margin = headerFooterInfo.margin;
+            headerFooterItem.PageRange = headerFooterInfo.PageRange;
+            headerFooterItem.PageRangeIndex = headerFooterInfo.PageRangeIndex;
+        }
+
+        public void ConvertItemToInfo(BatesHeaderFooterItem headerFooterItem, ref HeaderFooterInfo headerFooterInfo)
+        {
+            headerFooterInfo.TextData = headerFooterItem.TextData;
+            headerFooterInfo.ItemName = headerFooterItem.ItemName;
+            headerFooterInfo.DateTimeFormat = headerFooterItem.DateTimeFormat;
+            headerFooterInfo.StarPagetNumber = headerFooterItem.StarPagetNumber;
+            headerFooterInfo.PageNumberFormat = headerFooterItem.PageNumberFormat;
+            headerFooterInfo.margin = headerFooterItem.margin;
+            headerFooterInfo.PageRangeIndex = headerFooterItem.PageRangeIndex;
+            //EditToolsHelper.GetPageRange(headerFooterInfo.PageRangeIndex, PDFViewer.Document, ref headerFooterInfo.PageRange, headerFooterItem.PageRange);
+        }
+
+        public void SaveCurrentTemplate()
+        {
+            var headerFooterItem = new BatesHeaderFooterItem();
+
+            ConvertInfoToItem(ref headerFooterItem, HeaderFooterInfo);
+            headerFooterItem.ItemName += Settings.Default.HeaderFooterTemplateList.Count().ToString();
+            try
+            {
+                //创建缓存文件夹
+                string folderPath = Path.Combine(App.CurrentPath, "HeaderFooter");
+                //有可能因为其他原因存在同名文件,导致创建文件夹失败,需要先删除同名文件
+                //保险措施(猜测)
+                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);
+                Settings.Default.HeaderFooterTemplateList.Add(headerFooterItem);
+                Settings.Default.Save();
+            }
+            catch
+            {
+
+            }
+
+            this.eventAggregator.GetEvent<EnterTemplateListOrCreateEvent>().Publish(new EnumTemplateListOrCreateUnicode
+            {
+                Unicode = Unicode,
+                Status = EnumTemplateListOrCreate.StatusTemplate
+            });
+        }
+
+        public void ConfirmEditBackgroundTemplateItem()
+        {
+
+            var headerFooterItem = new BatesHeaderFooterItem();
+            ConvertInfoToItem(ref headerFooterItem, HeaderFooterInfo);
+            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();
+                }
+                Settings.Default.HeaderFooterTemplateList[TemplateHeaderFooterItem.listIndex] = headerFooterItem;
+                Settings.Default.Save();
+            }
+            catch
+            {
+
+            }
+            this.eventAggregator.GetEvent<EnterTemplateListOrCreateEvent>().Publish(new EnumTemplateListOrCreateUnicode
+            {
+                Unicode = Unicode,
+                Status = EnumTemplateListOrCreate.StatusTemplate
+            });
+
+        }
+
+        public void InitComponentBySelectedInfo()
+        {
+            ConvertItemToInfo(TemplateHeaderFooterItem, ref HeaderFooterInfo);
+            for (int i = 0; i <= 5; i++)
+            {
+                GetTextValueFromNumber[i.ToString()] = HeaderFooterInfo.TextData[i].text;
+            }
+            MarginTopValue = HeaderFooterInfo.margin[0].ToString();
+            MarginRightValue = HeaderFooterInfo.margin[1].ToString();
+            MarginDownValue = HeaderFooterInfo.margin[2].ToString();
+            MarginLeftValue = HeaderFooterInfo.margin[3].ToString();
+            DateTimeFormatIndex = DateTimeFormatList.IndexOf(HeaderFooterInfo.DateTimeFormat);
+            PageNumberFormatIndex = PageNumberFormatList.IndexOf(HeaderFooterInfo.PageNumberFormat);
+            FontNameSelectedIndex = FontNameList.IndexOf(HeaderFooterInfo.TextData[0].fontName);
+            FontSizeSelectedIndex = FontSizeList.IndexOf(HeaderFooterInfo.TextData[0].fontSize.ToString());
+            StarPagetNumberIndex = StarPagetNumberList.IndexOf(HeaderFooterInfo.StarPagetNumber.ToString());
+            StringColor = EditToolsHelper.ConvertColor(HeaderFooterInfo.TextData[0].Color);
+            SolidColorBrush = new SolidColorBrush(StringColor);
+            PageRangeSelectIndex = HeaderFooterInfo.PageRangeIndex;
+
+        }
+
+        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 HeaderFooterInfo.PageRange, PageRangeText);
+            if (navigationContext.Parameters.TryGetValue<BatesHeaderFooterItem>("HeaderFooterItem", out TemplateHeaderFooterItem))
+            {
+                CreateOrEdit = EnumCreateOrEdit.StatusEdit;
+                InitComponentBySelectedInfo();
+            }
+            else
+            {
+                CreateOrEdit = EnumCreateOrEdit.StatusCreate;
+            }
+        }
+    }
+}

+ 486 - 0
PDF Office/ViewModels/Dialog/HomePageToolsDialogs/HomePageBatchProcessing/HomePageHeaderFooter/HomePageHeaderFooterDialogViewModel.cs

@@ -0,0 +1,486 @@
+using ComPDFKit.PDFDocument;
+using PDF_Office.CustomControl;
+using PDF_Office.Helper;
+using PDF_Office.Model.Dialog.HomePageToolsDialogs.HomePageBatchProcessing;
+using PDF_Office.Model;
+using Prism.Commands;
+using Prism.Mvvm;
+using Prism.Regions;
+using System;
+using System.Collections.Generic;
+using System.Data;
+using System.Diagnostics;
+using System.IO;
+using System.Linq;
+using System.Windows;
+using System.Windows.Forms;
+using Prism.Events;
+using ComPDFKitViewer.PdfViewer;
+using PDF_Office.EventAggregators;
+using PDFSettings;
+
+namespace PDF_Office.ViewModels.Dialog.HomePageToolsDialogs.HomePageBatchProcessing.HomePageHeaderFooter
+{
+    public class HomePageHeaderFooterDialogViewModel : BindableBase, INavigationAware
+    {
+        #region 参数和属性
+        private List<string> fileNames;
+
+
+        private CPDFDocument tempDocument;
+
+        public string PageNumber = "";
+
+        public IRegionManager headerFooterRegion;
+        public IEventAggregator eventAggregator;
+
+        private CPDFViewer PDFViewer;
+
+        private ViewContentViewModel viewContentViewModel;
+
+        public string TemplateListName = "HomePageHeaderFooterTemplateListContent";
+        public string CreateName = "HomePageHeaderFooterCreateContent";
+
+        public string HeaderFooterType = "HomePageHeaderFooterType";
+
+        private string _headerFooterSettingsRegionName;
+        /// <summary>
+        /// 属性设置Region
+        /// </summary>
+        public string HeaderFooterSettingsRegionName
+        {
+            get { return _headerFooterSettingsRegionName; }
+            set { _headerFooterSettingsRegionName = value; }
+        }
+
+        private Visibility _headerFooterSettingsVisible = Visibility.Visible;
+        /// <summary>
+        /// 属性设置Region可见
+        /// </summary>
+        public Visibility HeaderFooterSettingsVisible
+        {
+            get { return _headerFooterSettingsVisible; }
+            set { _headerFooterSettingsVisible = value; }
+        }
+
+
+        public List<int> fileNamesView = new List<int>();
+
+        private int fileNamesIndex = 0;
+
+        private int FileNameNumber = 0;
+
+        private string headerFooterGridIsEnabled = "True";
+        public string HeaderFooterGridIsEnabled
+        {
+            get
+            {
+                return headerFooterGridIsEnabled;
+            }
+            set
+            {
+                SetProperty(ref headerFooterGridIsEnabled, value);
+            }
+        }
+
+        private string setHeaderFooterGridIsEnabled = "True";
+        public string SetHeaderFooterGridIsEnabled
+        {
+            get
+            {
+                return setHeaderFooterGridIsEnabled;
+            }
+            set
+            {
+                SetProperty(ref setHeaderFooterGridIsEnabled, value);
+            }
+        }
+
+        private DataTable pdfDataTable = new DataTable();
+        public DataTable PDFDataTable
+        {
+            get { return pdfDataTable; }
+            set
+            {
+                SetProperty(ref pdfDataTable, value);
+            }
+        }
+
+        private DataTable pdfCurrentDataTable = new DataTable();
+        public DataTable PDFCurrentDataTable
+        {
+            get { return pdfCurrentDataTable; }
+            set
+            {
+                SetProperty(ref pdfCurrentDataTable, value);
+            }
+        }
+
+        private string removeIsEnable = "False";
+        public string RemoveIsEnable
+        {
+            get { return removeIsEnable; }
+            set
+            {
+                SetProperty(ref removeIsEnable, value);
+            }
+        }
+
+        private string selectFileName = "False";
+        public string SelectFileName
+        {
+            get { return selectFileName; }
+            set
+            {
+                SetProperty(ref selectFileName, value);
+            }
+        }
+
+        private string headerFooterRegionName;
+        public string HeaderFooterRegionName
+        {
+            get
+            {
+                return headerFooterRegionName;
+            }
+            set
+            {
+                SetProperty(ref headerFooterRegionName, value);
+            }
+        }
+
+        private Visibility headerFooterVisible = Visibility.Collapsed;
+        public Visibility HeaderFooterVisible
+        {
+            get { return headerFooterVisible; }
+            set { SetProperty(ref headerFooterVisible, value); }
+        }
+
+        private Visibility addFileVisibility = Visibility.Hidden;
+        public Visibility AddFileVisibility
+        {
+            get { return addFileVisibility; }
+            set
+            {
+                SetProperty(ref addFileVisibility, value);
+                RaisePropertyChanged();
+
+            }
+        }
+        #endregion
+
+        #region 委托声明
+        public DelegateCommand ADDPDFCommand { get; set; }
+
+        public DelegateCommand RemovePDFFileCommand { get; set; }
+
+        public DelegateCommand CreateCommand { get; set; }
+
+        public DelegateCommand ADDPDFFilesCommand { get; set; }
+        #endregion
+
+        public string Unicode = null;
+
+        public HomePageHeaderFooterDialogViewModel(IRegionManager regionManager, IEventAggregator eventAggregator)
+        {
+            this.eventAggregator = eventAggregator;
+            this.headerFooterRegion = regionManager;
+
+            HeaderFooterSettingsRegionName = Guid.NewGuid().ToString();
+            Unicode = App.mainWindowViewModel.SelectedItem.Unicode;
+            PDFCurrentDataTable.Columns.Add("FilePageRangeText");
+            PDFCurrentDataTable.Columns.Add("FilePageRangeSelectIndex");
+            PDFCurrentDataTable.Columns.Add("FileState");
+            PDFDataTable.Columns.Add("FileName");
+            PDFDataTable.Columns.Add("FilePageRangeText");
+            PDFDataTable.Columns.Add("FilePageRangeSelectIndex");
+            PDFDataTable.Columns.Add("FileSize");
+            PDFDataTable.Columns.Add("FileState");
+            ADDPDFCommand = new DelegateCommand(addpicture);
+            ADDPDFFilesCommand = new DelegateCommand(addpicturefiles);
+            RemovePDFFileCommand = new DelegateCommand(removepdffile);
+            CreateCommand = new DelegateCommand(create);
+            eventAggregator.GetEvent<EditBatesHeaderFooterTemplateItemEvent>().Subscribe(EditHeaderFooterTemplateItem, e => e.Unicode == Unicode && e.Type == HeaderFooterType);
+            eventAggregator.GetEvent<EnterTemplateListOrCreateEvent>().Subscribe(EnterTemplateListOrCreate, e => e.Unicode == Unicode);
+        }
+        #region 逻辑函数
+
+        public void EditHeaderFooterTemplateItem(BatesHeaderFooterItemUnicode headerfooterItemunicode)
+        {
+            BatesHeaderFooterItem headerfooterItem = headerfooterItemunicode.Status;
+            NavigationParameters param = new NavigationParameters();
+            param.Add(ParameterNames.PDFViewer, PDFViewer);
+            param.Add("HeaderFooterItem", headerfooterItem);
+            headerFooterRegion.RequestNavigate(HeaderFooterSettingsRegionName, CreateName, param);
+            HeaderFooterSettingsVisible = Visibility.Visible;
+        }
+
+        public void EnterTemplateListOrCreate(EnumTemplateListOrCreateUnicode enumTemplateListOrCreateunicode)
+        {
+            EnumTemplateListOrCreate enumTemplateListOrCreate = enumTemplateListOrCreateunicode.Status;
+            if (enumTemplateListOrCreate == EnumTemplateListOrCreate.StatusTemplate)
+            {
+                EnterSelectedContent(TemplateListName);
+            }
+            else
+            {
+                EnterSelectedContent(CreateName);
+            }
+        }
+
+        public void EnterSelectedContent(string SelectedContentName)
+        {
+            NavigationParameters param = new NavigationParameters();
+            param.Add(ParameterNames.PDFViewer, PDFViewer);
+            headerFooterRegion.RequestNavigate(HeaderFooterSettingsRegionName, SelectedContentName, param);
+            HeaderFooterSettingsVisible = Visibility.Visible;
+        }
+
+        private  void create()
+        {
+
+            fileNamesIndex = 0;
+            HeaderFooterGridIsEnabled = "False";
+            foreach (var filename in fileNames)
+            {
+                //FileInfo fileinfo = new FileInfo(filename);
+                //string OutputPath = fileinfo.DirectoryName;
+                //char[] enumerationSeparator = new char[] { ',' };
+                //char[] rangeSeparator = new char[] { '-' };
+                //List<int> PageIndexLists = new List<int>();
+                //CPDFDocument document = CPDFDocument.InitWithFilePath(filename);
+                //if (document == null)
+                //{
+                //    PDFDataTable.Rows[fileNamesIndex]["FileState"] = "文件出错";
+                //    continue;
+                //}
+                //if (!CommonHelper.GetPagesInRange(ref PageIndexLists, "1-" + document.PageCount.ToString(), document.PageCount, enumerationSeparator, rangeSeparator))
+                //{ //TODO
+                //    Trace.WriteLine("输入不对");
+                //    MessageBoxEx.Show("输入不对");
+                //    return;
+                //}
+
+                //document.Release();
+                PDFDataTable.Rows[fileNamesIndex]["FilePageRangeSelectIndex"] = "2";
+                PDFDataTable.Rows[fileNamesIndex]["FileState"] = "完成";
+                PDFCurrentDataTable.Rows[fileNamesIndex]["FilePageRangeText"] = "2";
+                PDFCurrentDataTable.Rows[fileNamesIndex]["FilePageRangeSelectIndex"] = "2";
+                PDFCurrentDataTable.Rows[fileNamesIndex]["FileState"] = "完成";
+                fileNamesIndex++;
+            }
+            HeaderFooterGridIsEnabled = "True";
+        }
+        #endregion
+
+        #region 批量处理逻辑函数
+        /// <summary>
+        /// 添加PDF文件
+        /// </summary>
+        private void addpicture()
+        {
+            FileNameNumber = fileNames.Count;
+            System.Windows.Forms.OpenFileDialog dlg = new System.Windows.Forms.OpenFileDialog();
+            dlg.Multiselect = true;
+            dlg.Filter = "PDF|*.pdf;*.PDF;";
+            if (dlg.ShowDialog() == System.Windows.Forms.DialogResult.OK)
+            {
+                fileNames.AddRange(dlg.FileNames.ToList());
+                RemoveExcess(ref fileNames);
+                SetHeaderFooterGridIsEnabled = "True";
+                AddFileVisibility = Visibility.Collapsed;
+                updateListview("待确定");
+            }
+        }
+
+        public void addPDFFiles(string filename)
+        {
+            FileNameNumber = fileNames.Count;
+            fileNames.Add(filename);
+            RemoveExcess(ref fileNames);
+            SetHeaderFooterGridIsEnabled = "True";
+            AddFileVisibility = Visibility.Collapsed;
+            updateListview("待确定");
+        }
+
+        /// <summary>
+        /// 删除重复的文件
+        /// </summary>
+        public void RemoveExcess(ref List<string> Filenames)
+        {
+            List<string> filenames = new List<string>();
+            foreach (var fileName in Filenames)
+            {
+                if (!filenames.Contains(fileName))
+                {
+                    filenames.Add(fileName);
+                }
+            }
+            Filenames.Clear();
+            Filenames = filenames;
+        }
+
+        /// <summary>
+        /// 添加PDF文件夹
+        /// </summary>
+        private void addpicturefiles()
+        {
+            FileNameNumber = fileNames.Count;
+            FolderBrowserDialog dialog = new FolderBrowserDialog();
+            dialog.Description = "请选择文件路径";
+            if (dialog.ShowDialog() == System.Windows.Forms.DialogResult.OK)
+            {
+
+                string foldPath = dialog.SelectedPath;
+                var apps = System.IO.Directory.GetFiles(foldPath);
+                foreach (string app in apps)
+                {
+                    var fi = new FileInfo(app);
+                    if (fi.Extension == ".pdf" || fi.Extension == ".PDF")
+                    {
+                        fileNames.Add(app);
+                    }
+                }
+                RemoveExcess(ref fileNames);
+                updateListview("待确定");
+                SetHeaderFooterGridIsEnabled = "True";
+                AddFileVisibility = Visibility.Collapsed;
+            }
+
+        }
+        /// <summary>
+        /// 更新listview显示
+        /// state 状态显示字符串
+        /// </summary>
+        public void updateListview(string state)
+        {
+            updateCurrentListview();
+            DataTable pdfdatatable = new DataTable();
+            pdfdatatable.Columns.Add("FileName");
+            pdfdatatable.Columns.Add("FilePageRangeText");
+            pdfdatatable.Columns.Add("FilePageRangeSelectIndex");
+            pdfdatatable.Columns.Add("FileSize");
+            pdfdatatable.Columns.Add("FileState");
+            int datatableindex = 0;
+            foreach (var fileName in fileNames)
+            {
+                string file_all = fileName;
+                FileInfo f = new FileInfo(file_all);
+                string file_size = (((float)f.Length) / 1024).ToString() + " K";
+                pdfdatatable.Rows.Add(f.Name, PDFCurrentDataTable.Rows[datatableindex]["FilePageRangeText"], PDFCurrentDataTable.Rows[datatableindex]["FilePageRangeSelectIndex"], file_size, PDFCurrentDataTable.Rows[datatableindex]["FileState"]); 
+                datatableindex++;
+            }
+            PDFDataTable = pdfdatatable;
+            HomePageBatchProcessingDialogModel.FilePaths = fileNames;
+
+        }
+
+        /// <summary>
+        /// 更新Currentlistview显示
+        /// pagerangetext 自定义页面范围字符串  pagerangeselectindex combobox下拉索引(0全部页面 1奇数页 2偶数页 3自定义页面) state 状态显示字符串
+        /// </summary>
+        public void updateCurrentListview(string pagerangetext = "1", string pagerangeselectindex = "0", string state = "待完成")
+        {
+            if (fileNames.Count >= FileNameNumber)
+            {
+                for (int i = 0; fileNames.Count - FileNameNumber > i; i++)
+                {
+                    PDFCurrentDataTable.Rows.Add(pagerangetext, pagerangeselectindex, state);
+                }
+            }
+            else
+            {
+                Reverseorder(ref fileNamesView);
+                foreach (int filenamesview in fileNamesView)
+                {
+                    PDFCurrentDataTable.Rows.RemoveAt(filenamesview);
+                }
+            }
+        }
+
+        /// <summary>
+        /// 逆序int类型集合
+        /// </summary>
+        public void Reverseorder(ref List<int> Numbers)
+        {
+            Numbers = Numbers.OrderBy(a => a).ToList();
+            Numbers.Reverse();
+        }
+
+        /// <summary>
+        /// 打开文件PDF
+        /// </summary>
+        public void openfiledialog()
+        {
+
+            foreach (int filenamesview in fileNamesView)
+            {
+                System.Diagnostics.Process.Start(fileNames[filenamesview]);
+            }
+        }
+
+        /// <summary>
+        /// 删除文件PDF
+        /// </summary>
+        public void removepdffile()
+        {
+            FileNameNumber = fileNames.Count;
+            Reverseorder(ref fileNamesView);
+            foreach (int filenamesview in fileNamesView)
+            {
+                //Trace.WriteLine(filenamesview);
+                fileNames.Remove(fileNames[filenamesview]);
+            }
+            if (fileNames.Count < 1)
+            {
+                SetHeaderFooterGridIsEnabled = "False";
+                AddFileVisibility = Visibility.Visible;
+            }
+            updateListview("待确定");
+        }
+
+
+        public void PDFFileCount()
+        {
+            if (fileNames.Count == 0)
+            {
+                SetHeaderFooterGridIsEnabled = "False";
+                AddFileVisibility = Visibility.Visible;
+            }
+            else
+            {
+                SetHeaderFooterGridIsEnabled = "True";
+                AddFileVisibility = Visibility.Collapsed;
+            }
+        }
+       
+        #endregion
+
+        #region 构架行为
+        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(TemplateListName);
+            }
+        }
+
+
+        public bool IsNavigationTarget(NavigationContext navigationContext)
+        {
+            return true;
+        }
+
+        public void OnNavigatedFrom(NavigationContext navigationContext)
+        {
+        }
+        #endregion
+    }
+}

+ 225 - 0
PDF Office/ViewModels/Dialog/HomePageToolsDialogs/HomePageBatchProcessing/HomePageHeaderFooter/HomePageHeaderFooterTemplateListContentViewModel.cs

@@ -0,0 +1,225 @@
+using ComPDFKitViewer.PdfViewer;
+using PDF_Office.EventAggregators;
+using PDF_Office.Helper;
+using PDF_Office.Model.EditTools.HeaderFooter;
+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.Collections.ObjectModel;
+using System.Linq;
+using System.Windows.Controls;
+using System.Windows;
+
+namespace PDF_Office.ViewModels.Dialog.HomePageToolsDialogs.HomePageBatchProcessing.HomePageHeaderFooter
+{
+    public class HomePageHeaderFooterTemplateListContentViewModel : BindableBase, INavigationAware
+    {
+        public IEventAggregator eventAggregator;
+        private CPDFViewer PDFViewer;
+        public HeaderFooterInfo HeaderFooterInfo = new HeaderFooterInfo();
+        public BatesHeaderFooterItem HeaderFooterItem = new BatesHeaderFooterItem();
+        public int TemplateIndex = 0;
+
+        private ObservableCollection<BatesHeaderFooterItem> headerFooterModCollection = new ObservableCollection<BatesHeaderFooterItem>();
+        public ObservableCollection<BatesHeaderFooterItem> HeaderFooterModCollection
+        {
+            get { return headerFooterModCollection; }
+            set
+            {
+                headerFooterModCollection = 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 DelegateCommand EnterCreateCommand { get; set; }
+
+        public string Unicode = null;
+        public HomePageHeaderFooterTemplateListContentViewModel(IEventAggregator eventAggregator)
+        {
+            this.eventAggregator = eventAggregator;
+            Unicode = App.mainWindowViewModel.SelectedItem.Unicode;
+            EnterCreateCommand = new DelegateCommand(EnterCreate);
+            AddTemplateCommand = new DelegateCommand(AddTemplate);
+            EditTemplateItemCommand = new DelegateCommand<object>(RequestEditTemplateItem);
+            DeleteTemplateItemCommand = new DelegateCommand<object>(DeleteTemplateItem);
+            DeleteAllTemplateItemCommand = new DelegateCommand(DeleteAllTemplateItem);
+            SelectTemplateItemCommand = new DelegateCommand<object>(SelectTemplateItem);
+        }
+
+        private void InitBackgroundTemplateList()
+        {
+            if (Settings.Default.HeaderFooterTemplateList == null)
+            {
+                Settings.Default.HeaderFooterTemplateList = new HeaderFooterTemplateList();
+            }
+            GetHeaderFooterSource();
+        }
+
+        public void EnterCreate()
+        {
+            this.eventAggregator.GetEvent<EnterTemplateListOrCreateEvent>().Publish(new EnumTemplateListOrCreateUnicode { Unicode = Unicode, Status = EnumTemplateListOrCreate.StatusCreate });
+        }
+
+        public void AddTemplate()
+        {
+            this.eventAggregator.GetEvent<EnterTemplateListOrCreateEvent>().Publish(new EnumTemplateListOrCreateUnicode
+            {
+                Unicode = Unicode,
+                Status = EnumTemplateListOrCreate.StatusCreate
+            });
+        }
+
+        public void SaveEditedBatesTemplateItem(BatesHeaderFooterItemUnicode HeaderFooterItemunicode)
+        {
+            BatesHeaderFooterItem headerFooterItem = HeaderFooterItemunicode.Status;
+
+            Settings.Default.HeaderFooterTemplateList[TemplateIndex] = headerFooterItem;
+            Settings.Default.Save();
+
+            GetHeaderFooterSource();
+        }
+
+        public void RequestEditTemplateItem(object e)
+        {
+            var control = e as Control;
+            if (control == null)
+            {
+                return;
+            }
+            var template = control.DataContext as BatesHeaderFooterItem;
+            if (template == null)
+            {
+                return;
+            }
+            TemplateIndex = Settings.Default.HeaderFooterTemplateList.IndexOf(template);
+            template.listIndex = TemplateIndex;
+            ConvertItemToInfo(template, ref HeaderFooterInfo);
+            this.eventAggregator.GetEvent<EditBatesHeaderFooterTemplateItemEvent>().Publish(new BatesHeaderFooterItemUnicode
+            {
+                Unicode = Unicode,
+                Type = "HomePageHeaderFooterType",
+                Status = template
+            });
+        }
+
+        public void DeleteTemplateItem(object e)
+        {
+            var btn = e as System.Windows.Controls.Button;
+            if (btn == null)
+            {
+                return;
+            }
+            HeaderFooterItem = btn.DataContext as BatesHeaderFooterItem;
+            if (HeaderFooterItem == null)
+            {
+                return;
+            }
+
+            Settings.Default.HeaderFooterTemplateList.Remove(HeaderFooterItem);
+            Settings.Default.Save();
+            HeaderFooterModCollection.Remove(HeaderFooterItem);
+            GetHeaderFooterSource();
+        }
+
+        public void DeleteAllTemplateItem()
+        {
+            while (Settings.Default.HeaderFooterTemplateList.Count != 0)
+            {
+                int temp = 0;
+                var template = Settings.Default.HeaderFooterTemplateList[temp];
+
+                Settings.Default.HeaderFooterTemplateList.Remove(template);
+                Settings.Default.Save();
+
+                HeaderFooterModCollection.Remove(template);
+
+            }
+            GetHeaderFooterSource();
+        }
+
+        public void SelectTemplateItem(object e)
+        {
+            var listBox = e as ListBox;
+            BatesHeaderFooterItem HeaderFooterItem = listBox.SelectedItem as BatesHeaderFooterItem;
+            SendTemplateItemToDocument(HeaderFooterItem);
+        }
+
+        public void SendTemplateItemToDocument(BatesHeaderFooterItem template)
+        {
+            if (template != null)
+            {
+                ConvertItemToInfo(template, ref HeaderFooterInfo);
+            }
+
+        }
+
+        private void GetHeaderFooterSource()
+        {
+            List<BatesHeaderFooterItem> headerFooterModColorTemplateList = new List<BatesHeaderFooterItem>();
+            for (int temp = 0; temp < Settings.Default.HeaderFooterTemplateList.Count; temp++)
+            {
+                Settings.Default.HeaderFooterTemplateList[temp].ItemName = (temp + 1).ToString();
+                headerFooterModColorTemplateList.Add(Settings.Default.HeaderFooterTemplateList[temp]);
+
+            }
+            HeaderFooterModCollection = new ObservableCollection<BatesHeaderFooterItem>(headerFooterModColorTemplateList);
+            CheckTemplateListIsEmpty(headerFooterModColorTemplateList);
+        }
+
+        public void ConvertItemToInfo(BatesHeaderFooterItem headerFooterItem, ref HeaderFooterInfo headerFooterInfo)
+        {
+            headerFooterInfo.TextData = headerFooterItem.TextData;
+            headerFooterInfo.ItemName = headerFooterItem.ItemName;
+            headerFooterInfo.DateTimeFormat = headerFooterItem.DateTimeFormat;
+            headerFooterInfo.StarPagetNumber = headerFooterItem.StarPagetNumber;
+            headerFooterInfo.PageNumberFormat = headerFooterItem.PageNumberFormat;
+            headerFooterInfo.margin = headerFooterItem.margin;
+            headerFooterInfo.PageRangeIndex = headerFooterItem.PageRangeIndex;
+            EditToolsHelper.GetPageRange(headerFooterInfo.PageRangeIndex, PDFViewer.Document, ref headerFooterInfo.PageRange, headerFooterItem.PageRange);
+        }
+        private void CheckTemplateListIsEmpty(List<BatesHeaderFooterItem> headerFooterTemplateList)
+        {
+            if (headerFooterTemplateList.Count() == 0)
+            {
+                CreateTemplateVisible = Visibility.Visible;
+            }
+            else
+            {
+                CreateTemplateVisible = Visibility.Collapsed;
+            }
+        }
+
+        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);
+            InitBackgroundTemplateList();
+        }
+    }
+}

+ 519 - 0
PDF Office/ViewModels/Dialog/HomePageToolsDialogs/HomePageBatchProcessing/HomePageRemoveDialogViewModel.cs

@@ -0,0 +1,519 @@
+using ComPDFKit.PDFDocument;
+using ComPDFKitViewer.PdfViewer;
+using PDF_Office.CustomControl;
+using PDF_Office.Model;
+using PDF_Office.Model.Dialog.HomePageToolsDialogs.HomePageBatchProcessing;
+using PDF_Office.Model.Dialog.ToolsDialogs.SaftyDialogs;
+using Prism.Commands;
+using Prism.Mvvm;
+using Prism.Regions;
+using Prism.Services.Dialogs;
+using System;
+using System.Collections.Generic;
+using System.Data;
+using System.IO;
+using System.Linq;
+using System.Windows;
+using System.Windows.Forms;
+using DataTable = System.Data.DataTable;
+using DialogResult = Prism.Services.Dialogs.DialogResult;
+using Task = System.Threading.Tasks.Task;
+
+namespace PDF_Office.ViewModels.Dialog.HomePageToolsDialogs.HomePageBatchProcessing
+{
+    public class HomePageRemoveDialogViewModel : BindableBase, INavigationAware
+    {
+
+        #region 参数和属性
+        public IDialogService dialogs;
+
+        private List<string> fileNames;
+
+        private CPDFDocument tempDocument;
+
+        public List<int> fileNamesView = new List<int>();
+
+        private int fileNamesIndex = 0;
+
+        private int FileNameNumber = 0;
+
+        HomePageCompressDialogModel homePageCompressDialogModel = new HomePageCompressDialogModel();
+
+        private DataTable pdfDataTable = new DataTable();
+        public DataTable PDFDataTable
+        {
+            get { return pdfDataTable; }
+            set
+            {
+                SetProperty(ref pdfDataTable, value);
+            }
+        }
+
+        private DataTable pdfCurrentDataTable = new DataTable();
+        public DataTable PDFCurrentDataTable
+        {
+            get { return pdfCurrentDataTable; }
+            set
+            {
+                SetProperty(ref pdfCurrentDataTable, value);
+            }
+        }
+
+        private string optionsRemoveGridIsEnabled = "True";
+        public string OptionsRemoveGridIsEnabled
+        {
+            get
+            {
+                return optionsRemoveGridIsEnabled;
+            }
+            set
+            {
+                SetProperty(ref optionsRemoveGridIsEnabled, value);
+            }
+        }
+
+        private string setOptionsRemoveGridIsEnabled = "True";
+        public string SetOptionsRemoveGridIsEnabled
+        {
+            get
+            {
+                return setOptionsRemoveGridIsEnabled;
+            }
+            set
+            {
+                SetProperty(ref setOptionsRemoveGridIsEnabled, value);
+            }
+        }
+
+        private string removeIsEnable = "False";
+        public string RemoveIsEnable
+        {
+            get { return removeIsEnable; }
+            set
+            {
+                SetProperty(ref removeIsEnable, value);
+            }
+        }
+
+        private string selectFileName = "False";
+        public string SelectFileName
+        {
+            get { return selectFileName; }
+            set
+            {
+                SetProperty(ref selectFileName, value);
+            }
+        }
+
+        private Visibility addFileVisibility = Visibility.Hidden;
+        public Visibility AddFileVisibility
+        {
+            get { return addFileVisibility; }
+            set
+            {
+                SetProperty(ref addFileVisibility, value);
+                RaisePropertyChanged();
+
+            }
+        }
+
+        private bool securityIsRemove = false;
+        public bool SecurityIsRemove
+        {
+            get { return securityIsRemove; }
+            set
+            {
+                SetProperty(ref securityIsRemove, value);
+            }
+        }
+
+        private bool watermarkIsRemove = false;
+        public bool WatermarkIsRemove
+        {
+            get { return watermarkIsRemove; }
+            set
+            {
+                SetProperty(ref watermarkIsRemove, value);
+            }
+        }
+
+        private bool backgroundIsRemove = false;
+        public bool BackgroundIsRemove
+        {
+            get { return backgroundIsRemove; }
+            set
+            {
+                SetProperty(ref backgroundIsRemove, value);
+            }
+        }
+
+        private bool headerFooterIsRemove = false;
+        public bool HeaderFooterIsRemove
+        {
+            get { return headerFooterIsRemove; }
+            set
+            {
+                SetProperty(ref headerFooterIsRemove, value);
+            }
+        }
+
+        private bool batesIsRemove = false;
+        public bool BatesIsRemove
+        {
+            get { return batesIsRemove; }
+            set
+            {
+                SetProperty(ref batesIsRemove, value);
+            }
+        }
+        #endregion
+
+        #region 委托声明
+        public DelegateCommand ADDPDFCommand { get; set; }
+
+        public DelegateCommand RemovePDFFileCommand { get; set; }
+
+        public DelegateCommand ADDPDFFilesCommand { get; set; }
+
+        public DelegateCommand OptionsRemoveCommand { get; set; }
+
+        #endregion
+        public HomePageRemoveDialogViewModel(IDialogService dialogService)
+        {
+            dialogs = dialogService;
+            PDFCurrentDataTable.Columns.Add("FileState");
+            PDFDataTable.Columns.Add("FileName");
+            PDFDataTable.Columns.Add("FileSize");
+            PDFDataTable.Columns.Add("FileState");
+            ADDPDFCommand = new DelegateCommand(addpicture);
+            ADDPDFFilesCommand = new DelegateCommand(addpicturefiles);
+            RemovePDFFileCommand = new DelegateCommand(removepdffile);
+            OptionsRemoveCommand = new DelegateCommand(OptionsRemove);
+        }
+        #region 逻辑函数
+
+        private bool CheckHaveAllPermissions(CPDFDocument document)
+        {
+            CPDFPermissionsInfo permissionsInfo = document.GetPermissionsInfo();
+            if (permissionsInfo.AllowsDocumentChanges &&
+                permissionsInfo.AllowsPrinting &&
+                permissionsInfo.AllowsHighQualityPrinting &&
+                permissionsInfo.AllowsCopying &&
+                //permissionsInfo.AllowsDocumentAssembly&&
+                //TODO: 这个权限有问题
+                permissionsInfo.AllowsCommenting)
+            {
+                return true;
+            }
+            else
+            {
+                return false;
+            }
+        }
+
+        private DeleteSafetySettintgsModel.EnumNeedPassword CheckNeedPassword(CPDFDocument document)
+        {
+            if (document.IsLocked)
+            {
+                return DeleteSafetySettintgsModel.EnumNeedPassword.StatusVerifyPassword;
+            }
+            else { }
+            if (document.IsEncrypted)
+            {
+                if (CheckHaveAllPermissions(document))
+                {
+                    return DeleteSafetySettintgsModel.EnumNeedPassword.StatusDirectDescrypt;
+                }
+                else
+                {
+                    return DeleteSafetySettintgsModel.EnumNeedPassword.StatusVerifyPassword;
+                }
+            }
+            else
+            {
+                return DeleteSafetySettintgsModel.EnumNeedPassword.StatusCannotDecrypt;
+            }
+        }
+
+        private void OptionsRemove()
+        {
+            OptionsRemoveGridIsEnabled = "False";
+            //GC.KeepAlive(indexDelegate);
+            fileNamesIndex = 0;
+            foreach (var filename in fileNames)
+            {
+                PDFDataTable.Rows[fileNamesIndex]["FileState"] = "待完成";
+                CPDFDocument document = CPDFDocument.InitWithFilePath(filename);
+                
+                if (document == null)
+                {
+                    PDFDataTable.Rows[fileNamesIndex]["FileState"] = "文件出错";
+                    PDFCurrentDataTable.Rows[fileNamesIndex]["FileState"] = "文件出错";
+                    continue;
+                }
+                FileInfo fileinfo = new FileInfo(filename);
+                if (document.IsLocked)
+                {
+                    DialogParameters value = new DialogParameters();
+                    value.Add(ParameterNames.PDFDocument, document);
+                    dialogs.ShowDialog(DialogNames.VerifyPassWordDialog, value, e =>
+                    {
+                        if (e.Result == ButtonResult.OK)
+                        {
+                            if (e.Parameters.ContainsKey(ParameterNames.PassWord) && e.Parameters.GetValue<string>(ParameterNames.PassWord) != null)
+                            {
+                              
+                            }
+                        }
+                    });
+
+                    if (document.IsLocked)
+                    {
+                        //未成功解密文档时,释放Document对象,返回
+                        document.Release();
+                        PDFDataTable.Rows[fileNamesIndex]["FileState"] = "文件出错";
+                        PDFCurrentDataTable.Rows[fileNamesIndex]["FileState"] = "文件出错";
+                        continue;
+                    }
+                }
+                if (WatermarkIsRemove)
+                {
+                    document.DeleteWatermarks();
+                }
+                if (BackgroundIsRemove)
+                {
+                    document.GetBackground().Clear();
+                }
+                if (HeaderFooterIsRemove)
+                {
+                    document.GetHeaderFooter().Clear();
+                }
+                if (BatesIsRemove)
+                {
+                    document.GetBates().Clear();
+                }
+                if (SecurityIsRemove)
+                {
+                    document.Descrypt(filename + "_Remove.pdf");
+
+                }
+                else
+                {
+                    document.WriteToFilePath(filename + "_Remove.pdf");
+                }
+                PDFDataTable.Rows[fileNamesIndex]["FileState"] = "完成";
+                PDFCurrentDataTable.Rows[fileNamesIndex]["FileState"] = "完成";
+                fileNamesIndex++;
+                document.Release();
+            }
+            OptionsRemoveGridIsEnabled = "True";
+        }
+        #endregion
+
+        #region 批量处理逻辑函数
+        /// <summary>
+        /// 添加PDF文件
+        /// </summary>
+        private void addpicture()
+        {
+            FileNameNumber = fileNames.Count;
+            System.Windows.Forms.OpenFileDialog dlg = new System.Windows.Forms.OpenFileDialog();
+            dlg.Multiselect = true;
+            dlg.Filter = "PDF|*.pdf;*.PDF;";
+            if (dlg.ShowDialog() == System.Windows.Forms.DialogResult.OK)
+            {
+                fileNames.AddRange(dlg.FileNames.ToList());
+                RemoveExcess(ref fileNames);
+                SetOptionsRemoveGridIsEnabled = "True";
+                AddFileVisibility = Visibility.Collapsed;
+                updateListview("待确定");
+            }
+        }
+
+        public void addPDFFiles(string filename) {
+            FileNameNumber = fileNames.Count;
+            fileNames.Add(filename);
+            RemoveExcess(ref fileNames);
+            SetOptionsRemoveGridIsEnabled = "True";
+            AddFileVisibility = Visibility.Collapsed;
+            updateListview("待确定");
+        }
+        
+
+        /// <summary>
+        /// 删除重复的文件
+        /// </summary>
+        public void RemoveExcess(ref List<string> Filenames)
+        {
+            List<string> filenames = new List<string>();
+            foreach (var fileName in Filenames)
+            {
+                if (!filenames.Contains(fileName))
+                {
+                    filenames.Add(fileName);
+                }
+            }
+            Filenames.Clear();
+            Filenames = filenames;
+        }
+
+        /// <summary>
+        /// 添加PDF文件夹
+        /// </summary>
+        private void addpicturefiles()
+        {
+            FileNameNumber = fileNames.Count;
+            FolderBrowserDialog dialog = new FolderBrowserDialog();
+            dialog.Description = "请选择文件路径";
+            if (dialog.ShowDialog() == System.Windows.Forms.DialogResult.OK)
+            {
+
+                string foldPath = dialog.SelectedPath;
+                var apps = System.IO.Directory.GetFiles(foldPath);
+                foreach (string app in apps)
+                {
+                    var fi = new FileInfo(app);
+                    if (fi.Extension == ".pdf" || fi.Extension == ".PDF")
+                    {
+                        fileNames.Add(app);
+                    }
+                }
+                RemoveExcess(ref fileNames);
+                updateListview("待确定");
+                SetOptionsRemoveGridIsEnabled = "True";
+                AddFileVisibility = Visibility.Collapsed;
+            }
+
+        }
+        /// <summary>
+        /// 更新listview显示
+        /// state 状态显示字符串
+        /// </summary>
+        public void updateListview(string state)
+        {
+            updateCurrentListview();
+            DataTable pdfdatatable = new DataTable();
+            pdfdatatable.Columns.Add("FileName");
+            pdfdatatable.Columns.Add("FileSize");
+            pdfdatatable.Columns.Add("FileState");
+            int datatableindex = 0;
+            foreach (var fileName in fileNames)
+            {
+                string file_all = fileName;
+                FileInfo f = new FileInfo(file_all);
+                string file_size = (((float)f.Length) / 1024).ToString() + " K";
+                pdfdatatable.Rows.Add(f.Name, file_size, state);
+                pdfdatatable.Rows.Add(f.Name, file_size, PDFCurrentDataTable.Rows[datatableindex]["FileState"]);
+                datatableindex++;
+            }
+            PDFDataTable = pdfdatatable;
+            HomePageBatchProcessingDialogModel.FilePaths = fileNames;
+
+        }
+
+        /// <summary>
+        /// 更新Currentlistview显示
+        /// state 状态显示字符串
+        /// </summary>
+        public void updateCurrentListview(string state = "待完成")
+        {
+            if (fileNames.Count >= FileNameNumber)
+            {
+                for (int i = 0; fileNames.Count - FileNameNumber > i; i++)
+                {
+                    PDFCurrentDataTable.Rows.Add(state);
+                }
+            }
+            else
+            {
+                Reverseorder(ref fileNamesView);
+                foreach (int filenamesview in fileNamesView)
+                {
+                    PDFCurrentDataTable.Rows.RemoveAt(filenamesview);
+                }
+            }
+        }
+
+        /// <summary>
+        /// 逆序int类型集合
+        /// </summary>
+        public void Reverseorder(ref List<int> Numbers)
+        {
+            Numbers = Numbers.OrderBy(a => a).ToList();
+            Numbers.Reverse();
+        }
+
+        /// <summary>
+        /// 打开文件PDF
+        /// </summary>
+        public void openfiledialog()
+        {
+
+            foreach (int filenamesview in fileNamesView)
+            {
+                System.Diagnostics.Process.Start(fileNames[filenamesview]);
+            }
+        }
+
+        /// <summary>
+        /// 删除文件PDF
+        /// </summary>
+        public void removepdffile()
+        {
+            FileNameNumber = fileNames.Count;
+            Reverseorder(ref fileNamesView);
+            foreach (int filenamesview in fileNamesView)
+            {
+                //Trace.WriteLine(filenamesview);
+                fileNames.Remove(fileNames[filenamesview]);
+            }
+            if (fileNames.Count < 1)
+            {
+                SetOptionsRemoveGridIsEnabled = "False";
+                AddFileVisibility = Visibility.Visible;
+            }
+            updateListview("待确定");
+        }
+
+
+        public void PDFFileCount()
+        {
+            if (fileNames.Count == 0)
+            {
+                SetOptionsRemoveGridIsEnabled = "False";
+                AddFileVisibility = Visibility.Visible;
+            }
+            else
+            {
+                SetOptionsRemoveGridIsEnabled = "True";
+                AddFileVisibility = Visibility.Collapsed;
+            }
+        }
+        #endregion
+
+        #region 构架行为
+        public void OnNavigatedTo(NavigationContext navigationContext)
+        {
+            List<string> filepath = new List<string>();
+            navigationContext.Parameters.TryGetValue<List<string>>(ParameterNames.FilePath, out filepath);
+            if (filepath != null)
+            {
+
+                fileNames = filepath;
+                PDFFileCount();
+                updateListview("待确定");
+            }
+        }
+
+        public bool IsNavigationTarget(NavigationContext navigationContext)
+        {
+            return true;
+        }
+
+        public void OnNavigatedFrom(NavigationContext navigationContext)
+        {
+
+        }
+        #endregion
+    }
+}

+ 54 - 2
PDF Office/ViewModels/Dialog/HomePageToolsDialogs/HomePageBatchProcessing/HomePageSetPasswordDialogViewModel.cs

@@ -23,6 +23,8 @@ namespace PDF_Office.ViewModels.Dialog.HomePageToolsDialogs.HomePageBatchProcess
 
         private int fileNamesIndex = 0;
 
+        private int FileNameNumber = 0;
+
         private HomePageSetPasswordDialogModel setPasswordDialogModel = new HomePageSetPasswordDialogModel();
 
         public List<int> fileNamesView = new List<int>();
@@ -127,6 +129,16 @@ namespace PDF_Office.ViewModels.Dialog.HomePageToolsDialogs.HomePageBatchProcess
             }
         }
 
+        private DataTable pdfCurrentDataTable = new DataTable();
+        public DataTable PDFCurrentDataTable
+        {
+            get { return pdfCurrentDataTable; }
+            set
+            {
+                SetProperty(ref pdfCurrentDataTable, value);
+            }
+        }
+
         private string removeIsEnable = "False";
         public string RemoveIsEnable
         {
@@ -183,6 +195,7 @@ namespace PDF_Office.ViewModels.Dialog.HomePageToolsDialogs.HomePageBatchProcess
 
         public HomePageSetPasswordDialogViewModel()
         {
+            PDFCurrentDataTable.Columns.Add("FileState");
             PDFDataTable.Columns.Add("FileName");
             PDFDataTable.Columns.Add("FileSize");
             PDFDataTable.Columns.Add("FileState");
@@ -288,6 +301,7 @@ namespace PDF_Office.ViewModels.Dialog.HomePageToolsDialogs.HomePageBatchProcess
                 if (document == null)
                 {
                     PDFDataTable.Rows[fileNamesIndex]["FileState"] = "文件出错";
+                    PDFCurrentDataTable.Rows[fileNamesIndex]["FileState"] = "文件出错";
                     continue;
                 }
                 FileInfo fileinfo = new FileInfo(filename);
@@ -300,6 +314,7 @@ namespace PDF_Office.ViewModels.Dialog.HomePageToolsDialogs.HomePageBatchProcess
                 document.WriteToFilePath(filename + "SetPassword");
 
                 PDFDataTable.Rows[fileNamesIndex]["FileState"] = "完成";
+                PDFCurrentDataTable.Rows[fileNamesIndex]["FileState"] = "完成";
                 fileNamesIndex++;
                 document.Release();
             }
@@ -314,6 +329,7 @@ namespace PDF_Office.ViewModels.Dialog.HomePageToolsDialogs.HomePageBatchProcess
         /// </summary>
         private void addpdf()
         {
+            FileNameNumber = fileNames.Count;
             System.Windows.Forms.OpenFileDialog dlg = new System.Windows.Forms.OpenFileDialog();
             dlg.Multiselect = true;
             dlg.Filter = "PDF|*.pdf;*.PDF;";
@@ -327,6 +343,16 @@ namespace PDF_Office.ViewModels.Dialog.HomePageToolsDialogs.HomePageBatchProcess
             }
         }
 
+        public void addPDFFiles(string filename)
+        {
+            FileNameNumber = fileNames.Count;
+            fileNames.Add(filename);
+            RemoveExcess(ref fileNames);
+            SetSafetyGridIsEnabled = "True";
+            AddFileVisibility = Visibility.Collapsed;
+            updateListview("待确定");
+        }
+
         /// <summary>
         /// 删除重复的文件
         /// </summary>
@@ -349,6 +375,7 @@ namespace PDF_Office.ViewModels.Dialog.HomePageToolsDialogs.HomePageBatchProcess
         /// </summary>
         private void addpdffiles()
         {
+            FileNameNumber = fileNames.Count;
             FolderBrowserDialog dialog = new FolderBrowserDialog();
             dialog.Description = "请选择文件路径";
             if (dialog.ShowDialog() == System.Windows.Forms.DialogResult.OK)
@@ -377,23 +404,47 @@ namespace PDF_Office.ViewModels.Dialog.HomePageToolsDialogs.HomePageBatchProcess
         /// </summary>
         public void updateListview(string state)
         {
+            updateCurrentListview();
             DataTable pdfdatatable = new DataTable();
             pdfdatatable.Columns.Add("FileName");
             pdfdatatable.Columns.Add("FileSize");
             pdfdatatable.Columns.Add("FileState");
+            int datatableindex = 0;
             foreach (var fileName in fileNames)
             {
                 string file_all = fileName;
                 FileInfo f = new FileInfo(file_all);
                 string file_size = (((float)f.Length) / 1024).ToString() + " K";
-                pdfdatatable.Rows.Add(f.Name, file_size, state);
+                pdfdatatable.Rows.Add(f.Name, file_size, PDFCurrentDataTable.Rows[datatableindex]["FileState"]);
+                datatableindex++;
             }
             PDFDataTable = pdfdatatable;
             HomePageBatchProcessingDialogModel.FilePaths = fileNames;
 
         }
 
-        
+        /// <summary>
+        /// 更新Currentlistview显示
+        /// state 状态显示字符串
+        /// </summary>
+        public void updateCurrentListview( string state = "待完成")
+        {
+            if (fileNames.Count >= FileNameNumber)
+            {
+                for (int i = 0; fileNames.Count - FileNameNumber > i; i++)
+                {
+                    PDFCurrentDataTable.Rows.Add(state);
+                }
+            }
+            else
+            {
+                Reverseorder(ref fileNamesView);
+                foreach (int filenamesview in fileNamesView)
+                {
+                    PDFCurrentDataTable.Rows.RemoveAt(filenamesview);
+                }
+            }
+        }
 
         /// <summary>
         /// 逆序int类型集合
@@ -421,6 +472,7 @@ namespace PDF_Office.ViewModels.Dialog.HomePageToolsDialogs.HomePageBatchProcess
         /// </summary>
         public void removepdffile()
         {
+            FileNameNumber = fileNames.Count;
             Reverseorder(ref fileNamesView);
             foreach (int filenamesview in fileNamesView)
             {

+ 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();
+            }
+
+        }
+    }
+}

+ 541 - 0
PDF Office/ViewModels/Dialog/HomePageToolsDialogs/HomePageBatchProcessing/HomePageWatermark/HomePageWatermarkDialogViewModel.cs

@@ -0,0 +1,541 @@
+using ComPDFKit.PDFDocument;
+using PDF_Office.CustomControl;
+using PDF_Office.Model.Dialog.HomePageToolsDialogs.HomePageBatchProcessing;
+using PDF_Office.Model;
+using Prism.Commands;
+using Prism.Mvvm;
+using Prism.Regions;
+using System;
+using System.Collections.Generic;
+using System.Diagnostics;
+using System.IO;
+using System.Linq;
+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
+{
+    public class HomePageWatermarkDialogViewModel : BindableBase, INavigationAware
+    {
+        #region 参数和属性
+        private List<string> fileNames;
+
+        private CPDFDocument tempDocument;
+
+        public string PageNumber = "";
+
+        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>();
+
+        private int fileNamesIndex = 0;
+
+        private int FileNameNumber = 0;
+
+        private string watermarkGridIsEnabled = "True";
+        public string WatermarkGridIsEnabled
+        {
+            get
+            {
+                return watermarkGridIsEnabled;
+            }
+            set
+            {
+                SetProperty(ref watermarkGridIsEnabled, value);
+            }
+        }
+
+        private string setWatermarkGridIsEnabled = "True";
+        public string SetWatermarkGridIsEnabled
+        {
+            get
+            {
+                return setWatermarkGridIsEnabled;
+            }
+            set
+            {
+                SetProperty(ref setWatermarkGridIsEnabled, value);
+            }
+        }
+
+        private DataTable pdfDataTable = new DataTable();
+        public DataTable PDFDataTable
+        {
+            get { return pdfDataTable; }
+            set
+            {
+                SetProperty(ref pdfDataTable, value);
+            }
+        }
+
+        private DataTable pdfCurrentDataTable = new DataTable();
+        public DataTable PDFCurrentDataTable
+        {
+            get { return pdfCurrentDataTable; }
+            set
+            {
+                SetProperty(ref pdfCurrentDataTable, value);
+            }
+        }
+
+        private string removeIsEnable = "False";
+        public string RemoveIsEnable
+        {
+            get { return removeIsEnable; }
+            set
+            {
+                SetProperty(ref removeIsEnable, value);
+            }
+        }
+
+        private string selectFileName = "False";
+        public string SelectFileName
+        {
+            get { return selectFileName; }
+            set
+            {
+                SetProperty(ref selectFileName, value);
+            }
+        }
+
+        private string watermarkRegionName;
+        public string WatermarkRegionName
+        {
+            get
+            {
+                return watermarkRegionName;
+            }
+            set
+            {
+                SetProperty(ref watermarkRegionName, value);
+            }
+        }
+
+        private Visibility watermarkVisible = Visibility.Collapsed;
+        public Visibility WatermarkVisible
+        {
+            get { return watermarkVisible; }
+            set { SetProperty(ref watermarkVisible, value); }
+        }
+
+        private Visibility addFileVisibility = Visibility.Hidden;
+        public Visibility AddFileVisibility
+        {
+            get { return addFileVisibility; }
+            set
+            {
+                SetProperty(ref addFileVisibility, value);
+                RaisePropertyChanged();
+
+            }
+        }
+        #endregion
+
+        #region 委托声明
+        public DelegateCommand ADDPDFCommand { get; set; }
+
+        public DelegateCommand RemovePDFFileCommand { get; set; }
+
+        public DelegateCommand CreateCommand { get; set; }
+
+        public DelegateCommand ADDPDFFilesCommand { get; set; }
+        #endregion
+
+        public string Unicode = null;
+
+        public HomePageWatermarkDialogViewModel(IRegionManager watermarkRegion, IEventAggregator eventAggregator)
+        {
+            this.eventAggregator = eventAggregator;
+            this.watermarkRegion = watermarkRegion;
+            Unicode = App.mainWindowViewModel.SelectedItem.Unicode;
+            WatermarkSettingsVisible = Visibility.Visible;
+            PDFCurrentDataTable.Columns.Add("FilePageRangeText");
+            PDFCurrentDataTable.Columns.Add("FilePageRangeSelectIndex");
+            PDFCurrentDataTable.Columns.Add("FileState");
+            PDFDataTable.Columns.Add("FileName");
+            PDFDataTable.Columns.Add("FilePageRangeText");
+            PDFDataTable.Columns.Add("FilePageRangeSelectIndex");
+            PDFDataTable.Columns.Add("FileSize");
+            PDFDataTable.Columns.Add("FileState");
+            ADDPDFCommand = new DelegateCommand(addpicture);
+            ADDPDFFilesCommand = new DelegateCommand(addpicturefiles);
+            RemovePDFFileCommand = new DelegateCommand(removepdffile);
+            CreateCommand = new DelegateCommand(create);
+            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()
+        {
+
+            fileNamesIndex = 0;
+            WatermarkGridIsEnabled = "False";
+            foreach (var filename in fileNames)
+            {
+                //FileInfo fileinfo = new FileInfo(filename);
+                //string OutputPath = fileinfo.DirectoryName;
+                //char[] enumerationSeparator = new char[] { ',' };
+                //char[] rangeSeparator = new char[] { '-' };
+                //List<int> PageIndexLists = new List<int>();
+                //CPDFDocument document = CPDFDocument.InitWithFilePath(filename);
+                //if (document == null)
+                //{
+                //    PDFDataTable.Rows[fileNamesIndex]["FileState"] = "文件出错";
+                //    continue;
+                //}
+                //if (!CommonHelper.GetPagesInRange(ref PageIndexLists, "1-" + document.PageCount.ToString(), document.PageCount, enumerationSeparator, rangeSeparator))
+                //{ //TODO
+                //    Trace.WriteLine("输入不对");
+                //    MessageBoxEx.Show("输入不对");
+                //    return;
+                //}
+
+                //document.Release();
+                PDFDataTable.Rows[fileNamesIndex]["FilePageRangeSelectIndex"] = "2";
+                PDFDataTable.Rows[fileNamesIndex]["FileState"] = "完成";
+                PDFCurrentDataTable.Rows[fileNamesIndex]["FilePageRangeText"] = "2";
+                PDFCurrentDataTable.Rows[fileNamesIndex]["FilePageRangeSelectIndex"] = "2";
+                PDFCurrentDataTable.Rows[fileNamesIndex]["FileState"] = "完成";
+                fileNamesIndex++;
+            }
+            WatermarkGridIsEnabled = "True";
+        }
+        #endregion
+
+        #region 批量处理逻辑函数
+        /// <summary>
+        /// 添加PDF文件
+        /// </summary>
+        private void addpicture()
+        {
+            FileNameNumber = fileNames.Count;
+            System.Windows.Forms.OpenFileDialog dlg = new System.Windows.Forms.OpenFileDialog();
+            dlg.Multiselect = true;
+            dlg.Filter = "PDF|*.pdf;*.PDF;";
+            if (dlg.ShowDialog() == System.Windows.Forms.DialogResult.OK)
+            {
+                fileNames.AddRange(dlg.FileNames.ToList());
+                RemoveExcess(ref fileNames);
+                SetWatermarkGridIsEnabled = "True";
+                AddFileVisibility = Visibility.Collapsed;
+                updateListview("待确定");
+            }
+        }
+
+        public void addPDFFiles(string filename)
+        {
+            FileNameNumber = fileNames.Count;
+            fileNames.Add(filename);
+            RemoveExcess(ref fileNames);
+            SetWatermarkGridIsEnabled = "True";
+            AddFileVisibility = Visibility.Collapsed;
+            updateListview("待确定");
+        }
+
+        /// <summary>
+        /// 删除重复的文件
+        /// </summary>
+        public void RemoveExcess(ref List<string> Filenames)
+        {
+            List<string> filenames = new List<string>();
+            foreach (var fileName in Filenames)
+            {
+                if (!filenames.Contains(fileName))
+                {
+                    filenames.Add(fileName);
+                }
+            }
+            Filenames.Clear();
+            Filenames = filenames;
+        }
+
+        /// <summary>
+        /// 添加PDF文件夹
+        /// </summary>
+        private void addpicturefiles()
+        {
+            FileNameNumber = fileNames.Count;
+            FolderBrowserDialog dialog = new FolderBrowserDialog();
+            dialog.Description = "请选择文件路径";
+            if (dialog.ShowDialog() == System.Windows.Forms.DialogResult.OK)
+            {
+
+                string foldPath = dialog.SelectedPath;
+                var apps = System.IO.Directory.GetFiles(foldPath);
+                foreach (string app in apps)
+                {
+                    var fi = new FileInfo(app);
+                    if (fi.Extension == ".pdf" || fi.Extension == ".PDF")
+                    {
+                        fileNames.Add(app);
+                    }
+                }
+                RemoveExcess(ref fileNames);
+                updateListview("待确定");
+                SetWatermarkGridIsEnabled = "True";
+                AddFileVisibility = Visibility.Collapsed;
+            }
+
+        }
+        /// <summary>
+        /// 更新listview显示
+        /// state 状态显示字符串
+        /// </summary>
+        public void updateListview(string state)
+        {
+            updateCurrentListview();
+            DataTable pdfdatatable = new DataTable();
+            pdfdatatable.Columns.Add("FileName");
+            pdfdatatable.Columns.Add("FilePageRangeText");
+            pdfdatatable.Columns.Add("FilePageRangeSelectIndex");
+            pdfdatatable.Columns.Add("FileSize");
+            pdfdatatable.Columns.Add("FileState");
+            int datatableindex = 0;
+            foreach (var fileName in fileNames)
+            {
+                string file_all = fileName;
+                FileInfo f = new FileInfo(file_all);
+                string file_size = (((float)f.Length) / 1024).ToString() + " K";
+                pdfdatatable.Rows.Add(f.Name, PDFCurrentDataTable.Rows[datatableindex]["FilePageRangeText"], PDFCurrentDataTable.Rows[datatableindex]["FilePageRangeSelectIndex"], file_size, PDFCurrentDataTable.Rows[datatableindex]["FileState"]);
+                datatableindex++;
+            }
+            PDFDataTable = pdfdatatable;
+            HomePageBatchProcessingDialogModel.FilePaths = fileNames;
+
+        }
+
+        /// <summary>
+        /// 更新Currentlistview显示
+        /// pagerangetext 自定义页面范围字符串  pagerangeselectindex combobox下拉索引(0全部页面 1奇数页 2偶数页 3自定义页面) state 状态显示字符串
+        /// </summary>
+        public void updateCurrentListview(string pagerangetext = "1", string pagerangeselectindex = "0", string state = "待完成")
+        {
+            if (fileNames.Count >= FileNameNumber)
+            {
+                for (int i = 0; fileNames.Count - FileNameNumber > i; i++)
+                {
+                    PDFCurrentDataTable.Rows.Add(pagerangetext, pagerangeselectindex, state);
+                }
+            }
+            else
+            {
+                Reverseorder(ref fileNamesView);
+                foreach (int filenamesview in fileNamesView)
+                {
+                    PDFCurrentDataTable.Rows.RemoveAt(filenamesview);
+                }
+            }
+        }
+
+        /// <summary>
+        /// 逆序int类型集合
+        /// </summary>
+        public void Reverseorder(ref List<int> Numbers)
+        {
+            Numbers = Numbers.OrderBy(a => a).ToList();
+            Numbers.Reverse();
+        }
+
+        /// <summary>
+        /// 打开文件PDF
+        /// </summary>
+        public void openfiledialog()
+        {
+
+            foreach (int filenamesview in fileNamesView)
+            {
+                System.Diagnostics.Process.Start(fileNames[filenamesview]);
+            }
+        }
+
+        /// <summary>
+        /// 删除文件PDF
+        /// </summary>
+        public void removepdffile()
+        {
+            FileNameNumber = fileNames.Count;
+            Reverseorder(ref fileNamesView);
+            foreach (int filenamesview in fileNamesView)
+            {
+                //Trace.WriteLine(filenamesview);
+                fileNames.Remove(fileNames[filenamesview]);
+            }
+            if (fileNames.Count < 1)
+            {
+                SetWatermarkGridIsEnabled = "False";
+                AddFileVisibility = Visibility.Visible;
+            }
+            updateListview("待确定");
+        }
+
+
+        public void PDFFileCount()
+        {
+            if (fileNames.Count == 0)
+            {
+                SetWatermarkGridIsEnabled = "False";
+                AddFileVisibility = Visibility.Visible;
+            }
+            else
+            {
+                SetWatermarkGridIsEnabled = "True";
+                AddFileVisibility = Visibility.Collapsed;
+            }
+        }
+
+        #endregion
+
+        #region 构架行为
+        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("待确定");
+            }
+        }
+
+
+        public bool IsNavigationTarget(NavigationContext navigationContext)
+        {
+            return true;
+        }
+
+        public void OnNavigatedFrom(NavigationContext navigationContext)
+        {
+        }
+        #endregion
+    }
+}

+ 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();
+        }
+    }
+}

Filskillnaden har hållts tillbaka eftersom den är för stor
+ 477 - 1913
PDF Office/ViewModels/Dialog/HomePageToolsDialogs/HomePagePrinter/HomePagePrinterDialogViewModel.cs


Filskillnaden har hållts tillbaka eftersom den är för stor
+ 2155 - 0
PDF Office/ViewModels/Dialog/HomePageToolsDialogs/HomePagePrinter/HomePagePrinterDocumentContentViewModel.cs


+ 43 - 3
PDF Office/ViewModels/Dialog/HomePageToolsDialogs/HomePagePrinter/HomePagePrinterModBookletContentViewModel.cs

@@ -1,4 +1,5 @@
 using ComPDFKit.PDFDocument;
+using PDF_Office.EventAggregators;
 using PDF_Office.Model.Dialog.HomePageToolsDialogs.HomePagePrinter;
 using Prism.Commands;
 using Prism.Events;
@@ -9,13 +10,14 @@ using System.Collections.Generic;
 using System.Diagnostics;
 using System.Linq;
 using System.Management.Instrumentation;
+using System.Windows.Controls;
 
 namespace PDF_Office.ViewModels.Dialog.HomePageToolsDialogs.HomePagePrinter
 {
     public class HomePagePrinterModBookletContentViewModel : BindableBase, INavigationAware
     {
         private IEventAggregator eventAggregator;
-
+        private string Unicode = null;
         private CPDFDocument document;
 
         private bool _isAutoRotate;
@@ -25,7 +27,7 @@ namespace PDF_Office.ViewModels.Dialog.HomePageToolsDialogs.HomePagePrinter
             set { _isAutoRotate = value; }
         }
 
-        private int? _paperFrom;
+        private int? _paperFrom = 1;
         public int? PaperFrom
         {
             get
@@ -121,6 +123,8 @@ namespace PDF_Office.ViewModels.Dialog.HomePageToolsDialogs.HomePagePrinter
             set { _maxPaperNumber = value; }
         }
 
+        public DelegateCommand<object> SetSheetCommand { get; set; }
+
         public HomePagePrinterModBookletContentViewModel(IEventAggregator eventAggregator)
         {
             this.eventAggregator = eventAggregator;
@@ -131,6 +135,9 @@ namespace PDF_Office.ViewModels.Dialog.HomePageToolsDialogs.HomePagePrinter
             InitBindingList();
 
             BookletInfo = new BookletInfo();
+            BookletInfo.EnumPrintMod = EnumPrintMod.StatusBooklet;
+
+            SetSheetCommand = new DelegateCommand<object>(SetSheet);
         }
 
         private void InitSubsetList()
@@ -171,11 +178,43 @@ namespace PDF_Office.ViewModels.Dialog.HomePageToolsDialogs.HomePagePrinter
             BookletInfo.IsAutoRotate = IsAutoRotate;
         }
 
+        public void SetSheet(object e)
+        {
+            var txt = e as TextBox;
+            if (txt != null)
+            {
+                if (PaperFrom == null)
+                {
+                    PaperFrom = 1;
+                }
+                if (PaperTo == null)
+                {
+                    PaperTo = MaxPaperNumber;
+                }
+                if (txt.Name == "PaperFromTxt")
+                {
+                    PaperFrom = int.Parse(txt.Text);
+                }
+                else
+                {
+                    PaperTo= int.Parse(txt.Text);
+                }
+                BookletInfo.BeginPaperIndex=(int)PaperFrom;
+                BookletInfo.EndPaperIndex=(int)PaperTo;
+                SendBookletInfo();
+            } 
+        }
+
         public void SendBookletInfo()
         {
             if (BookletInfo != null)
             {
-                this.eventAggregator.GetEvent<ModInfoSendEvent>().Publish(BookletInfo);
+                if (BookletInfo.BeginPaperIndex > BookletInfo.EndPaperIndex)
+                {
+                    PaperFrom = PaperTo;
+                    BookletInfo.BeginPaperIndex = (int)PaperFrom;
+                }
+                this.eventAggregator.GetEvent<SendPrintSettingsModInfoEvent>().Publish(new PrintModInfoWithUnicode { printModInfo = BookletInfo, Unicode = this.Unicode });
             }
         }
 
@@ -190,6 +229,7 @@ namespace PDF_Office.ViewModels.Dialog.HomePageToolsDialogs.HomePagePrinter
 
         public void OnNavigatedTo(NavigationContext navigationContext)
         {
+            navigationContext.Parameters.TryGetValue<string>("Unicode", out Unicode);
             if (navigationContext.Parameters.ContainsKey("document"))
             {
                 document = navigationContext.Parameters.GetValue<CPDFDocument>("document");

+ 53 - 14
PDF Office/ViewModels/Dialog/HomePageToolsDialogs/HomePagePrinter/HomePagePrinterModMultipleContentViewModel.cs

@@ -1,4 +1,5 @@
-using PDF_Office.Model.Dialog.HomePageToolsDialogs.HomePagePrinter;
+using PDF_Office.EventAggregators;
+using PDF_Office.Model.Dialog.HomePageToolsDialogs.HomePagePrinter;
 using Prism.Commands;
 using Prism.Events;
 using Prism.Mvvm;
@@ -12,6 +13,7 @@ namespace PDF_Office.ViewModels.Dialog.HomePageToolsDialogs.HomePagePrinter
     public class HomePagePrinterModMultipleContentViewModel : BindableBase, INavigationAware
     {
         private IEventAggregator eventAggregator;
+        private string Unicode = null;
 
         private int? _verticalPageNumber;
         public int? VerticalPageNumber
@@ -87,8 +89,8 @@ namespace PDF_Office.ViewModels.Dialog.HomePageToolsDialogs.HomePagePrinter
             get { return _pageOrderIndex; }
             set
             {
-                _pageOrderIndex = value; 
-                InitMultipleInfo();
+                _pageOrderIndex = value;
+                SetMultipleInfo();
                 SendMultipleInfo();
             }
         }
@@ -113,6 +115,11 @@ namespace PDF_Office.ViewModels.Dialog.HomePageToolsDialogs.HomePagePrinter
             set { _multipleInfo = value; }
         }
 
+        public DelegateCommand<object> SetPageMatrixCommand { get; set; }
+        public DelegateCommand<object> SetCustomMatrixCommand { get; set; }
+        public DelegateCommand SetPageOrderCommand { get; set; }
+        public DelegateCommand<object> SetAutoRotateCommand { get; set; }
+
         public HomePagePrinterModMultipleContentViewModel(IEventAggregator eventAggregator)
         {
             this.eventAggregator = eventAggregator;
@@ -124,14 +131,45 @@ namespace PDF_Office.ViewModels.Dialog.HomePageToolsDialogs.HomePagePrinter
             PageOrderList = new List<string>();
             InitPageOrderList();
 
+            SetPageMatrixCommand = new DelegateCommand<object>(SetPageMatrix);
+            SetCustomMatrixCommand = new DelegateCommand<object>(SetCustomMatrix);
+            SetPageOrderCommand = new DelegateCommand(SetPageOrder);
+            SetAutoRotateCommand = new DelegateCommand<object>(SetAutoRotate);
+
             MultipleInfo = new MultipleInfo();
+            MultipleInfo.EnumPrintMod = EnumPrintMod.StatusMultiple;
+        }
+
+        public void SetPageMatrix(object e)
+        {
+            SetMultipleInfo();
+            SendMultipleInfo();
+        }
+
+        public void SetCustomMatrix(object e)
+        {
+            SetMultipleInfo();
+            SendMultipleInfo();
+        }
+
+        public void SetPageOrder()
+        {
+            SetMultipleInfo();
+            SendMultipleInfo();
+        }
+
+        public void SetAutoRotate(object e)
+        {
+            SetMultipleInfo();
+            SendMultipleInfo();
         }
 
         public void SendMultipleInfo()
         {
             if (MultipleInfo != null)
-            {
-                this.eventAggregator.GetEvent<ModInfoSendEvent>().Publish(MultipleInfo);
+            { 
+                this.eventAggregator.GetEvent<SendPrintSettingsModInfoEvent>().Publish(new PrintModInfoWithUnicode { printModInfo = MultipleInfo, Unicode = this.Unicode });
+
             }
         }
 
@@ -162,7 +200,7 @@ namespace PDF_Office.ViewModels.Dialog.HomePageToolsDialogs.HomePagePrinter
                 case 0:
                     HorizontalPageNumber = 1;
                     VerticalPageNumber = 2;
-                    InitMultipleInfo();
+                    SetMultipleInfo();
                     SendMultipleInfo();
 
                     break;
@@ -170,7 +208,7 @@ namespace PDF_Office.ViewModels.Dialog.HomePageToolsDialogs.HomePagePrinter
                 case 1:
                     HorizontalPageNumber = 2;
                     VerticalPageNumber = 2;
-                    InitMultipleInfo();
+                    SetMultipleInfo();
 
                     SendMultipleInfo();
 
@@ -179,7 +217,7 @@ namespace PDF_Office.ViewModels.Dialog.HomePageToolsDialogs.HomePagePrinter
                 case 2:
                     HorizontalPageNumber = 3;
                     VerticalPageNumber = 2;
-                    InitMultipleInfo();
+                    SetMultipleInfo();
 
                     SendMultipleInfo();
 
@@ -188,7 +226,7 @@ namespace PDF_Office.ViewModels.Dialog.HomePageToolsDialogs.HomePagePrinter
                 case 3:
                     HorizontalPageNumber = 3;
                     VerticalPageNumber = 3;
-                    InitMultipleInfo();
+                    SetMultipleInfo();
 
                     SendMultipleInfo();
 
@@ -196,7 +234,7 @@ namespace PDF_Office.ViewModels.Dialog.HomePageToolsDialogs.HomePagePrinter
                 case 4:
                     HorizontalPageNumber = 4;
                     VerticalPageNumber = 4;
-                    InitMultipleInfo();
+                    SetMultipleInfo();
 
                     SendMultipleInfo();
 
@@ -209,7 +247,9 @@ namespace PDF_Office.ViewModels.Dialog.HomePageToolsDialogs.HomePagePrinter
             }
         }
 
-        private void InitMultipleInfo()
+
+
+        private void SetMultipleInfo()
         {
             if (HorizontalPageNumber == null)
             {
@@ -224,11 +264,9 @@ namespace PDF_Office.ViewModels.Dialog.HomePageToolsDialogs.HomePagePrinter
             {
                 MultipleInfo.VerticalPageNumber = (int)VerticalPageNumber;
                 MultipleInfo.HorizontalPageNumber = (int)HorizontalPageNumber;
-                MultipleInfo.EnumDisplayPageNumber = EnumDisplayPageNumber.StatusTwo;
                 MultipleInfo.IsAutoRotate = IsAutoRotate;
                 MultipleInfo.EnumPageOrder = (EnumPageOrder)PageOrderIndex;
             }
-
         }
 
         public bool IsNavigationTarget(NavigationContext navigationContext)
@@ -242,8 +280,9 @@ namespace PDF_Office.ViewModels.Dialog.HomePageToolsDialogs.HomePagePrinter
 
         public void OnNavigatedTo(NavigationContext navigationContext)
         {
-            InitMultipleInfo();
+            SetMultipleInfo();
             SendMultipleInfo();
+            navigationContext.Parameters.TryGetValue<string>("Unicode", out Unicode);
         }
     }
 }

+ 312 - 1
PDF Office/ViewModels/Dialog/HomePageToolsDialogs/HomePagePrinter/HomePagePrinterModPosterContentViewModel.cs

@@ -1,16 +1,324 @@
-using Prism.Commands;
+using Microsoft.Office.Interop.Word;
+using PDF_Office.EventAggregators;
+using PDF_Office.Model.Dialog.HomePageToolsDialogs.HomePagePrinter;
+using Prism.Commands;
+using Prism.Events;
 using Prism.Mvvm;
 using Prism.Regions;
 using System;
 using System.Collections.Generic;
 using System.Diagnostics;
 using System.Linq;
+using System.Printing;
+using System.Windows;
+using System.Windows.Controls;
+using System.Windows.Media;
 
 namespace PDF_Office.ViewModels.Dialog.HomePageToolsDialogs.HomePagePrinter
 {
     public class HomePagePrinterModPosterContentViewModel : BindableBase, INavigationAware
     {
 
+        private IEventAggregator eventAggregator;
+        private string Unicode = null;
+        private Visibility _pageRangeSettingVisibility = Visibility.Visible;
+
+        public bool HasCutMarks = false;
+        public bool HasLabel = false;
+
+        private string _defaultLabel;
+        public string DefaultLabel
+        {
+            get { return _defaultLabel; }
+            set { _defaultLabel = value; }
+        }
+
+        public Visibility PageRangeSettingVisibility
+        {
+            get => _pageRangeSettingVisibility;
+            set => SetProperty(ref _pageRangeSettingVisibility, value);
+        }
+
+        private Visibility _pagesPerSheetVisibility = Visibility.Hidden;
+        public Visibility PagesPerSheetVisibility
+        {
+            get => _pagesPerSheetVisibility;
+            set => SetProperty(ref _pagesPerSheetVisibility, value);
+        }
+
+        private string _tileRatio = "100";
+        public string TileRatio
+        {
+            get => _tileRatio;
+            set => SetProperty(ref _tileRatio, value);
+        }
+
+        private PosterInfo _posterInfo = new PosterInfo();
+        public PosterInfo PosterInfo
+        {
+            get => _posterInfo;
+            set => _posterInfo = value;
+        }
+
+        private List<string> _pageSheetList = new List<string>();
+        /// <summary>
+        /// <para>0: 1x2</para>
+        /// <para>1: 2x2</para>
+        /// <para>2: 3x2</para>
+        /// <para>3: 3x3</para>
+        /// <para>4: 4x4</para>
+        /// <para>5: 自定义</para>
+        /// </summary>
+        public List<string> PageSheetList
+        {
+            get => _pageSheetList;
+            set => _pageSheetList = value;
+        }
+
+        private bool _enableCustomSheet;
+        public bool EnableCustomSheet
+        {
+            get { return _enableCustomSheet; }
+            set
+            {
+                SetProperty(ref _enableCustomSheet, value);
+            }
+        }
+
+        private int _pageSheetIndex = 0;
+        public int PageSheetIndex
+        {
+            get { return _pageSheetIndex; }
+            set
+            {
+                _pageSheetIndex = value;
+                if (_pageSheetIndex < 5)
+                {
+                    EnableCustomSheet = false;
+                }
+                else
+                {
+                    EnableCustomSheet = true;
+                }
+                SetPageSheetValue(value);
+            }
+        }
+
+        private int? _horizontalSheetNumber = 1;
+        public int? HorizontalSheetNumber
+        {
+            get => _horizontalSheetNumber;
+            set => SetProperty(ref _horizontalSheetNumber, value);
+        }
+
+        private int? _verticalSheetNumber = 2;
+        public int? VerticalSheetNumber
+        {
+            get => _verticalSheetNumber;
+            set => SetProperty(ref _verticalSheetNumber, value);
+        }
+
+        private double? _overlapNumber = 0;
+        public double? OverlapNumber
+        {
+            get => _overlapNumber;
+            set
+            {
+                if (value > 5.08)
+                {
+                    value = 5.08;
+                }
+                else if (value < 0)
+                {
+                    value = 0;
+                }
+                SetProperty(ref _overlapNumber, value);
+            }
+        }
+
+        public DelegateCommand<object> SetModPosterStatusCommand { get; set; }
+        public DelegateCommand<object> SetSheetCommand { get; set; }
+        public DelegateCommand SetCustomSheetCommand { get; set; }
+        public DelegateCommand SetOverlapCommand { get; set; }
+        public DelegateCommand<object> SetCutMarksCommand { get; set; }
+        public DelegateCommand<object> SetLabelCommand { get; set; }
+        public DelegateCommand SetTileRatioCommand { get; set; }
+        HomePagePrinterModPosterContentViewModel(IEventAggregator eventAggregator)
+        {
+            this.eventAggregator = eventAggregator;
+            SetModPosterStatusCommand = new DelegateCommand<object>(SetModPosterStatus);
+            SetSheetCommand = new DelegateCommand<object>(SetSheet);
+            SetCustomSheetCommand = new DelegateCommand(SetCustomSheet);
+            SetOverlapCommand = new DelegateCommand(SetOverlap);
+            SetCutMarksCommand = new DelegateCommand<object>(SetCutMarks);
+            SetLabelCommand = new DelegateCommand<object>(SetLabel);
+            SetTileRatioCommand = new DelegateCommand(SetTileRatio);
+            InitComponent();
+
+            PosterInfo.EnumPrintMod = EnumPrintMod.StatusPoster;
+        }
+
+        public void InitPageSheetList()
+        {
+            PageSheetList.Clear();
+            PageSheetList.Add("2");
+            PageSheetList.Add("4");
+            PageSheetList.Add("6");
+            PageSheetList.Add("9");
+            PageSheetList.Add("16");
+            PageSheetList.Add("Custom");
+        }
+
+        public void InitComponent()
+        {
+            InitPageSheetList();
+        }
+
+        public void SetModPosterStatus(object e)
+        {
+            var rdo = e as RadioButton;
+            if (rdo.Name == "StatusTileRdo")
+            {
+                PosterInfo.EnumPosterMod = EnumPosterMod.StatusTile;
+                PageRangeSettingVisibility = Visibility.Visible;
+                PagesPerSheetVisibility = Visibility.Hidden;
+            }
+            else
+            {
+                PosterInfo.EnumPosterMod = EnumPosterMod.StatusSplit;
+                PageRangeSettingVisibility = Visibility.Hidden;
+                PagesPerSheetVisibility = Visibility.Visible;
+            }
+            SendPosterInfo();
+        }
+
+        public void SetSheet(object e)
+        {
+            SendPosterInfo();
+        }
+
+        public void SetCustomSheet()
+        {
+            SendPosterInfo();
+        }
+
+        public void SetOverlap()
+        {
+            SendPosterInfo();
+        }
+
+        public void SetTileRatio()
+        {
+            int previousDisplayRatio = PosterInfo.TileRatio;
+            PosterInfo.TileRatio = int.Parse(TileRatio);
+            if (previousDisplayRatio != PosterInfo.TileRatio)
+            {
+                SendPosterInfo();
+            }
+        }
+
+        public void SetPageSheetValue(int sheetIndex)
+        {
+            switch (sheetIndex)
+            {
+                case 0:
+                    HorizontalSheetNumber = 1;
+                    VerticalSheetNumber = 2;
+                    break;
+                case 1:
+                    HorizontalSheetNumber = 2;
+                    VerticalSheetNumber = 2;
+                    break;
+                case 2:
+                    HorizontalSheetNumber = 3;
+                    VerticalSheetNumber = 2;
+                    break;
+                case 3:
+                    HorizontalSheetNumber = 3;
+                    VerticalSheetNumber = 3;
+                    break;
+                case 4:
+                    HorizontalSheetNumber = 4;
+                    VerticalSheetNumber = 4;
+                    break;
+                case 5:
+                    HorizontalSheetNumber = null;
+                    VerticalSheetNumber = null;
+                    break;
+            }
+            SendPosterInfo();
+        }
+
+        public void SendPosterInfo()
+        {
+            if (HorizontalSheetNumber == null)
+            {
+                HorizontalSheetNumber = 1;
+            }
+
+            if (VerticalSheetNumber == null)
+            {
+                VerticalSheetNumber = 1;
+            }
+            if (OverlapNumber == null)
+            {
+                OverlapNumber = 0;
+            }
+            else if (OverlapNumber < 0)
+            {
+                OverlapNumber = 0;
+            }
+            else if (OverlapNumber > 5.08)
+            {
+                OverlapNumber = 5.08;
+            }
+            if (PosterInfo != null)
+            {
+                if (PosterInfo.EnumPosterMod == EnumPosterMod.StatusTile)
+                {
+                    PosterInfo.TileRatio = int.Parse(TileRatio);
+                }
+                else
+                {
+                    PosterInfo.HorizontalSheetNumber = (int)HorizontalSheetNumber;
+                    PosterInfo.VerticalSheetNumber = (int)VerticalSheetNumber;
+                }
+                PosterInfo.OverLap = (double)OverlapNumber;
+                PosterInfo.HasCutMarks = HasCutMarks;
+                PosterInfo.HasLabel = HasLabel;
+            }
+            this.eventAggregator.GetEvent<SendPrintSettingsModInfoEvent>().Publish(new PrintModInfoWithUnicode { printModInfo = PosterInfo, Unicode = this.Unicode }); 
+        }
+
+
+        public void SetCutMarks(object e)
+        {
+            var chk = e as System.Windows.Controls.CheckBox;
+            if(chk.IsChecked == true)
+            {
+               HasCutMarks = true;
+            }
+            else
+            {
+                HasCutMarks = false;
+            }
+            SendPosterInfo();
+        }
+
+        public void SetLabel(object e)
+        {
+            var chk = e as System.Windows.Controls.CheckBox;
+            if (chk.IsChecked == true)
+            {
+                HasLabel = true;
+            }
+            else
+            {
+                HasLabel = false;
+            }
+            SendPosterInfo();
+        }
+
         public bool IsNavigationTarget(NavigationContext navigationContext)
         {
             return true;
@@ -22,6 +330,9 @@ namespace PDF_Office.ViewModels.Dialog.HomePageToolsDialogs.HomePagePrinter
 
         public void OnNavigatedTo(NavigationContext navigationContext)
         {
+            DefaultLabel = "(column, row) 1.pdf "+ DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss");
+            navigationContext.Parameters.TryGetValue<string>("Unicode", out Unicode);
+            SendPosterInfo();
         }
     }
 }

+ 38 - 80
PDF Office/ViewModels/Dialog/HomePageToolsDialogs/HomePagePrinter/HomePagePrinterModSizeContentViewModel.cs

@@ -1,4 +1,5 @@
-using PDF_Office.Model.Dialog.HomePageToolsDialogs.HomePagePrinter;
+using PDF_Office.EventAggregators;
+using PDF_Office.Model.Dialog.HomePageToolsDialogs.HomePagePrinter;
 using Prism.Commands;
 using Prism.Events;
 using Prism.Mvvm;
@@ -7,39 +8,15 @@ using System;
 using System.Collections.Generic;
 using System.Linq;
 using System.Management.Instrumentation;
+using System.Windows.Controls;
 
 namespace PDF_Office.ViewModels.Dialog.HomePageToolsDialogs.HomePagePrinter
 {
     public class HomePagePrinterModSizeContentViewModel : BindableBase, INavigationAware
     {
         private IEventAggregator eventAggregator;
-
-        private bool _isStatusAdaptive = true;
-        public bool IsStatusAdaptive
-        {
-            get { return _isStatusAdaptive; }
-            set
-            {
-                SetProperty(ref _isStatusAdaptive, value);
-            }
-        }
-
-        private bool _isStatusActural = false;
-        public bool IsStatusActural
-        {
-            get { return _isStatusActural; }
-            set
-            {
-                SetProperty(ref _isStatusActural, value);
-            }
-        }
-        
-        private bool _isStatusCustomized = false;
-        public bool IsStatusCustomized
-        {
-            get { return _isStatusCustomized; }
-            set { SetProperty(ref _isStatusCustomized, value); }
-        }
+        private string Unicode = null;
+        public string CurrentSelectedRdoName = "StatusAdaptiveRdo";
 
         private string _displayRatio = "100";
         public string DisplayRatio
@@ -55,9 +32,7 @@ namespace PDF_Office.ViewModels.Dialog.HomePageToolsDialogs.HomePagePrinter
             set { _sizeInfo = value; }
         }
 
-        public DelegateCommand SetStatusAdaptiveCommand { get; set; }
-        public DelegateCommand SetStatusActuralCommand { get; set; }
-        public DelegateCommand SetStatusCustomizedCommand { get; set; }
+        public DelegateCommand<object> SetModSizeStatusCommand { get; set; }
         public DelegateCommand SetDisplayRatioCommand { get; set; }
 
         //public DelegateCommand sendSizeInfoCommand;
@@ -69,48 +44,47 @@ namespace PDF_Office.ViewModels.Dialog.HomePageToolsDialogs.HomePagePrinter
         {
             this.eventAggregator = eventAggregator;
             SizeInfo = new SizeInfo();
-            SetStatusAdaptiveCommand = new DelegateCommand(SetStatusAdaptive);
-            SetStatusActuralCommand = new DelegateCommand(SetStatusActural);
-            SetStatusCustomizedCommand = new DelegateCommand(SetStatusCustomized);
+            SizeInfo.EnumPrintMod = EnumPrintMod.StatusSize;
+            SetModSizeStatusCommand = new DelegateCommand<object>(SetModSizeStatus);
+
             SetDisplayRatioCommand = new DelegateCommand(SetDisplayRatio);
         }
 
         public void SendSizeInfo()
         {
-            if(SizeInfo!= null)
+            if (SizeInfo != null)
             {
-                this.eventAggregator.GetEvent<ModInfoSendEvent>().Publish(SizeInfo);
+                this.eventAggregator.GetEvent<SendPrintSettingsModInfoEvent>().Publish(new PrintModInfoWithUnicode { printModInfo = SizeInfo, Unicode = this.Unicode});
             }
         }
 
-        public void SetStatusActural()
-        {
-            IsStatusActural = true;
-            IsStatusAdaptive = false;
-            IsStatusCustomized = false;
-
-            SizeInfo.EnumSizeType = EnumSizeType.StatusActural;
-
-            SendSizeInfo();
-        }
-
-        public void SetStatusAdaptive()
-        {
-            IsStatusActural = false;
-            IsStatusAdaptive = true;
-            IsStatusCustomized = false;
-
-            SizeInfo.EnumSizeType = EnumSizeType.StatusAdaptive;
-            SendSizeInfo();
-        }
-
-        public void SetStatusCustomized()
+        public void SetModSizeStatus(object e)
         {
-            IsStatusActural = false;
-            IsStatusAdaptive = false;
-            IsStatusCustomized = true;
-
-            SizeInfo.EnumSizeType = EnumSizeType.StatusCustomized;
+            var rdo = e as RadioButton;
+            if (rdo.Name == CurrentSelectedRdoName)
+            {
+                return;
+            }
+            else
+            {
+                CurrentSelectedRdoName = rdo.Name;
+                if (rdo.Name == "StatusAdaptiveRdo")
+                {
+                    SizeInfo.EnumSizeType = EnumSizeType.StatusAdaptive;
+                }
+                else if (rdo.Name == "StatusActuralRdo")
+                {
+                    SizeInfo.EnumSizeType = EnumSizeType.StatusActural;
+                }
+                else
+                {
+                    SizeInfo.EnumSizeType = EnumSizeType.StatusCustomized;
+                }
+                if (SizeInfo.EnumSizeType == EnumSizeType.StatusAdaptive || SizeInfo.EnumSizeType == EnumSizeType.StatusActural || (SizeInfo.EnumSizeType == EnumSizeType.StatusCustomized)&& DisplayRatio != null)
+                {
+                    SendSizeInfo();
+                }
+            }
         }
 
         public void SetDisplayRatio()
@@ -123,22 +97,6 @@ namespace PDF_Office.ViewModels.Dialog.HomePageToolsDialogs.HomePagePrinter
             }
         }
 
-        private void InitSizeInfo()
-        {
-            if (IsStatusAdaptive)
-            {
-                SizeInfo.EnumSizeType = EnumSizeType.StatusAdaptive;
-            }
-            else if (IsStatusActural)
-            {
-                SizeInfo.EnumSizeType = EnumSizeType.StatusActural;
-            }
-            else
-            {
-                SizeInfo.EnumSizeType = EnumSizeType.StatusCustomized;
-            }
-            SizeInfo.DisplayRatio = int.Parse(DisplayRatio);
-        }
 
         public bool IsNavigationTarget(NavigationContext navigationContext)
         {
@@ -151,7 +109,7 @@ namespace PDF_Office.ViewModels.Dialog.HomePageToolsDialogs.HomePagePrinter
 
         public void OnNavigatedTo(NavigationContext navigationContext)
         {
-            InitSizeInfo();
+            navigationContext.Parameters.TryGetValue<string>("Unicode", out Unicode);
             SendSizeInfo();
         }
     }

+ 0 - 245
PDF Office/ViewModels/Dialog/HomePageToolsDialogs/HomePagePrinter/HomePagePrinterPageSetDialogViewModel.cs

@@ -1,245 +0,0 @@
-using PDF_Office.Model.Dialog.HomePageToolsDialogs.HomePagePrinter;
-using Prism.Commands;
-using Prism.Mvvm;
-using Prism.Services.Dialogs;
-using System;
-using System.Collections.Generic;
-using System.Linq;
-using System.Runtime.InteropServices;
-using System.Windows;
-
-namespace PDF_Office.ViewModels.Dialog.HomePageToolsDialogs.HomePagePrinter
-{
-    public class HomePagePrinterPageSetDialogViewModel : BindableBase, IDialogAware
-    {
-        private int _paperSizeIndex;
-        public int PaperSizeIndex
-        {
-            get { return _paperSizeIndex; }
-            set { _paperSizeIndex = value; }
-        }
-
-        private int _paperSizeWidth;
-        public int PaperSizeWidth
-        {
-            get { return _paperSizeWidth; }
-            set
-            {
-                SetProperty(ref _paperSizeWidth, value);
-            }
-        }
-
-        private int _paperSizeHeight;
-        public int PaperSizeHeight
-        {
-            get { return _paperSizeHeight; }
-            set
-            {
-                SetProperty(ref _paperSizeHeight, value);
-            }
-        }
-
-        private List<string> _paperSizeNameList;
-        public List<string> PaperSizeNameList
-        {
-            get { return _paperSizeNameList; }
-            set { _paperSizeNameList = value; }
-        }
-
-        public Dictionary<EnumPaperSize, string> GetPaperSizeNameFromEnumPaperSize;
-
-        private int _leftMargin;
-        public int LeftMargin
-        {
-            get { return _leftMargin; }
-            set { _leftMargin = value; }
-        }
-
-        private int _rightMargin;
-        public int RightMargin
-        {
-            get { return _rightMargin; }
-            set { _rightMargin = value; }
-        }
-
-        private int _bottomMargin;
-        public int BottomMargin
-        {
-            get { return _bottomMargin; }
-            set { _bottomMargin = value; }
-        }
-
-        private int _topMargin;
-        public int TopMargin
-        {
-            get { return _topMargin; }
-            set { _topMargin = value; }
-        }
-
-        private int[] _paperMargin;
-        public int[] PaperMargin
-        {
-            get { return _paperMargin; }
-            set { _paperMargin = value; }
-        }
-
-        private Visibility _isPageSizeStackPanelsVisible = Visibility.Hidden;
-        public Visibility IsPageSizeStackPanelsVisible
-        {
-            get { return _isPageSizeStackPanelsVisible; }
-            set { SetProperty(ref _isPageSizeStackPanelsVisible, value); }
-        }
-
-        public DelegateCommand SetPaperSizeCommand { get; set; }
-        public DelegateCommand ConfirmSetPageSizeCommand { get; set; }
-        public DelegateCommand CancelSetPageSizeCommand { get; set; }
-
-        public HomePagePrinterPageSetDialogViewModel()
-        {
-            HomePagePrinterDialogModel homePagePrinterDialogModel = new HomePagePrinterDialogModel();
-            SetPaperSizeCommand = new DelegateCommand(SetPaperSize);
-            ConfirmSetPageSizeCommand = new DelegateCommand(ConfirmSetPageSize);
-            CancelSetPageSizeCommand = new DelegateCommand(CancelSetPageSize);
-
-            GetPaperSizeNameFromEnumPaperSize = new Dictionary<EnumPaperSize, string> { };
-            InitGetPaperSizeNameFromEnumPaperSize(ref GetPaperSizeNameFromEnumPaperSize);
-            InitPaperSizeList();
-        }
-
-        public void InitGetPaperSizeNameFromEnumPaperSize(ref Dictionary<EnumPaperSize, string> Dictionary)
-        {
-            GetPaperSizeNameFromEnumPaperSize.Clear();
-            GetPaperSizeNameFromEnumPaperSize.Add(EnumPaperSize.StatusA3, "A3");
-            GetPaperSizeNameFromEnumPaperSize.Add(EnumPaperSize.StatusA4, "A4");
-            GetPaperSizeNameFromEnumPaperSize.Add(EnumPaperSize.StatusA5, "A5");
-            GetPaperSizeNameFromEnumPaperSize.Add(EnumPaperSize.StatusB5, "B5");
-            GetPaperSizeNameFromEnumPaperSize.Add(EnumPaperSize.StatusNo10Envelope, "10号信封");
-            GetPaperSizeNameFromEnumPaperSize.Add(EnumPaperSize.StatusChoukei3Envelope, "Choukei 3信封");
-            GetPaperSizeNameFromEnumPaperSize.Add(EnumPaperSize.StatusDLEnvelope, "DL信封");
-            GetPaperSizeNameFromEnumPaperSize.Add(EnumPaperSize.StatusJISB5, "JIS B5");
-            GetPaperSizeNameFromEnumPaperSize.Add(EnumPaperSize.StatusROC16K, "ROC 16K");
-            GetPaperSizeNameFromEnumPaperSize.Add(EnumPaperSize.StatusExtraLargeBA3, "超大型B/A3型");
-            GetPaperSizeNameFromEnumPaperSize.Add(EnumPaperSize.StatusTabloid, "小报用纸");
-            GetPaperSizeNameFromEnumPaperSize.Add(EnumPaperSize.StatusExraLargeTabloid, "小报用纸(特大)");
-            GetPaperSizeNameFromEnumPaperSize.Add(EnumPaperSize.StatusAmericanLegal, "美国法定用纸");
-            GetPaperSizeNameFromEnumPaperSize.Add(EnumPaperSize.StatusAmericanLetter, "美国信纸");
-            GetPaperSizeNameFromEnumPaperSize.Add(EnumPaperSize.StatusCustomized, "自定义");
-        }
-
-        public void InitPaperSizeList()
-        {
-            PaperSizeNameList = new List<string>();
-            for (int temp = 0; temp < GetPaperSizeNameFromEnumPaperSize.Count; temp++)
-            {
-                PaperSizeNameList.Add(GetPaperSizeNameFromEnumPaperSize[(EnumPaperSize)temp]);
-            }
-        }
-
-        public void SetPaperSize()
-        {
-            IsPageSizeStackPanelsVisible = Visibility.Hidden;
-            switch (PaperSizeIndex)
-            {
-                case (int)EnumPaperSize.StatusA3:
-                    PaperSizeWidth = 297;
-                    PaperSizeHeight = 420;
-                    break;
-                case (int)EnumPaperSize.StatusA4:
-                    PaperSizeWidth = 210;
-                    PaperSizeHeight = 297;
-                    break;
-                case (int)EnumPaperSize.StatusA5:
-                    PaperSizeWidth = 148;
-                    PaperSizeHeight = 210;
-                    break;
-                case (int)EnumPaperSize.StatusB5:
-                    PaperSizeWidth = 176;
-                    PaperSizeHeight = 250;
-                    break;
-                case (int)EnumPaperSize.StatusNo10Envelope:
-                    PaperSizeWidth = 458;
-                    PaperSizeHeight = 324;
-                    break;
-                case (int)EnumPaperSize.StatusChoukei3Envelope:
-                    PaperSizeWidth = 120;
-                    PaperSizeHeight = 235;
-                    break;
-                case (int)EnumPaperSize.StatusDLEnvelope:
-                    PaperSizeWidth = 220;
-                    PaperSizeHeight = 110;
-                    break;
-                case (int)EnumPaperSize.StatusJISB5:
-                    PaperSizeWidth = 176;
-                    PaperSizeHeight = 276;
-                    break;
-                case (int)EnumPaperSize.StatusROC16K:
-                    PaperSizeWidth = 197;
-                    PaperSizeHeight = 273;
-                    break;
-                case (int)EnumPaperSize.StatusExtraLargeBA3:
-                    PaperSizeWidth = 330;
-                    PaperSizeHeight = 483;
-                    break;
-                case (int)EnumPaperSize.StatusTabloid:
-                    PaperSizeWidth = 431;
-                    PaperSizeHeight = 279;
-                    break;
-                case (int)EnumPaperSize.StatusExraLargeTabloid:
-                    PaperSizeWidth = 305;
-                    PaperSizeHeight = 457;
-                    break;
-                case (int)EnumPaperSize.StatusAmericanLegal:
-                    PaperSizeWidth = 216;
-                    PaperSizeHeight = 356;
-                    break;
-                case (int)EnumPaperSize.StatusAmericanLetter:
-                    PaperSizeWidth = 216;
-                    PaperSizeHeight = 279;
-                    break;
-                case (int)EnumPaperSize.StatusCustomized:
-                    IsPageSizeStackPanelsVisible = Visibility.Visible;
-                    break;
-                default:
-                    break;
-            }
-        }
-
-        public void ConfirmSetPageSize()
-        {
-            var dialogResult = new DialogResult(ButtonResult.OK);
-            dialogResult.Parameters.Add("LeftMargin", LeftMargin);
-            dialogResult.Parameters.Add("TopMargin", TopMargin);
-            dialogResult.Parameters.Add("RightMargin", RightMargin);
-            dialogResult.Parameters.Add("BottomMargin", BottomMargin);
-            dialogResult.Parameters.Add("PaperWidth", PaperSizeWidth);
-            dialogResult.Parameters.Add("PaperHeight", PaperSizeHeight);
-            dialogResult.Parameters.Add("PaperSizeIndex", PaperSizeIndex);
-            RequestClose.Invoke(dialogResult);
-        }
-
-        public void CancelSetPageSize()
-        {
-            var dialogResult = new DialogResult(ButtonResult.Cancel);
-            RequestClose.Invoke(dialogResult);
-        }
-
-        public event Action<IDialogResult> RequestClose;
-
-        public string Title => "";
-
-
-        public bool CanCloseDialog()
-        {
-            return true;
-        }
-
-        public void OnDialogClosed()
-        {
-
-        }
-
-        public void OnDialogOpened(IDialogParameters parameters)
-        {
-        }
-    }
-}

+ 237 - 0
PDF Office/ViewModels/Dialog/HomePageToolsDialogs/HomePagePrinter/HomePagePrinterPaperSettingsDialogViewModel.cs

@@ -0,0 +1,237 @@
+using Microsoft.Xaml.Behaviors;
+using PDF_Office.Model;
+using PDF_Office.CustomControl;
+using Prism.Commands;
+using Prism.Mvvm;
+using Prism.Services.Dialogs;
+using System;
+using System.Collections.Generic;
+using System.Linq;
+using System.Printing;
+using System.Text;
+using System.Threading.Tasks;
+using System.Windows;
+using System.Windows.Controls;
+
+namespace PDF_Office.ViewModels.Dialog.HomePageToolsDialogs.HomePagePrinter
+{
+    public class HomePagePrinterPaperSettingsDialogViewModel : BindableBase, IDialogAware
+    {
+        public string Title => "PaperSettings";
+        public event Action<IDialogResult> RequestClose;
+
+        private PrintQueue printQueue;
+        string Unicode = null;
+        private Visibility _isPageSizeStackPanelsVisible = Visibility.Hidden;
+        public Visibility IsPageSizeStackPanelsVisible
+        {
+            get { return _isPageSizeStackPanelsVisible; }
+            set { SetProperty(ref _isPageSizeStackPanelsVisible, value); }
+        }
+
+        /// <summary>
+        /// 是否自定义纸张
+        /// </summary>
+        private bool _isCustomSize;
+        public bool IsCustomSize
+        {
+            get => _isCustomSize;
+            set
+            {
+                if (value)
+                {
+                    IsPageSizeStackPanelsVisible = Visibility.Visible;
+                }
+                else
+                {
+                    IsPageSizeStackPanelsVisible = Visibility.Hidden;
+                }
+                _isCustomSize = value;
+            }
+        }
+
+        private int? _customPaperSizeWidth;
+        /// <summary>
+        /// 自定义页面尺寸:宽度
+        /// </summary>
+        public int? CustomPaperSizeWidth
+        {
+            get => _customPaperSizeWidth;
+            set => _customPaperSizeWidth = value;
+        }
+
+        private int? _customPaperSizeHeight;
+        /// <summary>
+        /// 自定义页面尺寸:高度
+        /// </summary>
+        public int? CustomPaperSizeHeight
+        {
+            get => _customPaperSizeHeight;
+            set => _customPaperSizeHeight = value;
+        }
+
+        /// <summary>
+        /// 当前选中的纸张尺寸
+        /// </summary>
+        public PageMediaSize currentPageMediaSize;
+
+        /// <summary>
+        /// 打印机支持的纸张
+        /// </summary>
+        public List<PageMediaSize> PageMediaSizeList = new List<PageMediaSize>();
+
+        /// <summary>
+        /// 纸张大小列表
+        /// </summary>
+        private List<string> _pageMediaSizeNameList = new List<string>();
+        public List<string> PageMediaSizeNameList
+        {
+            get => _pageMediaSizeNameList;
+            set => _pageMediaSizeNameList = value;
+        }
+
+        private List<int> _margin = new List<int>();
+        public List<int> Margin
+        {
+            get => _margin;
+            set => _margin = value;
+        }
+
+        private int _pageMediaSizeIndex = 0;
+        public int PageMediaSizeIndex
+        {
+            get=> _pageMediaSizeIndex;
+            set => SetProperty(ref _pageMediaSizeIndex, value);
+        }
+
+        /// <summary>
+        /// 页边距
+        /// </summary>
+        private int _marginTop;
+        public int MarginTop
+        {
+            get => _marginTop;
+            set => SetProperty(ref _marginTop, value);
+        }
+
+        private int _marginBottom;
+        public int MarginBottom
+        {
+            get => _marginBottom;
+            set => SetProperty(ref _marginBottom, value);
+        }
+
+        private int _marginLeft;
+        public int MarginLeft
+        {
+            get => _marginLeft; 
+            set => SetProperty(ref _marginLeft, value);
+        }
+
+        private int _marginRight;
+        public int MarginRight
+        {
+            get => _marginRight;
+            set => SetProperty(ref _marginRight, value);
+        }
+
+        public DelegateCommand CancelCommand { get; set; }
+        public DelegateCommand<object> SetPaperSizeCommand { get; set; }
+        public DelegateCommand ConfirmPaperSettingsCommand { get; set; }
+
+        HomePagePrinterPaperSettingsDialogViewModel()
+        {
+            CancelCommand = new DelegateCommand(Cancel);
+            SetPaperSizeCommand = new DelegateCommand<object>(SetPaperSize);
+            ConfirmPaperSettingsCommand = new DelegateCommand(ConfirmPaperSettings);
+        }
+
+        private void InitPaperSizeList()
+        {
+            PageMediaSizeList.Clear();
+            PageMediaSizeNameList.Clear();
+            foreach (PageMediaSize size in printQueue.GetPrintCapabilities().PageMediaSizeCapability)
+            {
+                if (size == null || size.PageMediaSizeName == null)
+                {
+                    continue;
+                }
+                PageMediaSizeList.Add(size);
+                PageMediaSizeNameList.Add(size.PageMediaSizeName.ToString());
+            }
+            PageMediaSizeNameList.Add("自定义");
+            if (PageMediaSizeNameList.Contains("ISOA4"))
+            {
+                PageMediaSizeIndex = PageMediaSizeNameList.IndexOf("ISOA4");
+            }
+            else
+            {
+                PageMediaSizeIndex = 0;
+            }
+            currentPageMediaSize = PageMediaSizeList[PageMediaSizeIndex];
+        }
+
+        public void SetPaperSize(object e)
+        {
+            var cmb = e as ComboBox;
+            if (cmb.SelectedIndex < PageMediaSizeNameList.Count - 1)
+            {
+                IsCustomSize = false;
+                currentPageMediaSize = PageMediaSizeList[PageMediaSizeNameList.IndexOf(cmb.SelectedItem.ToString())];
+            }
+            else
+            {
+                IsCustomSize = true;
+            }
+        }
+
+        public void ConfirmPaperSettings ()
+        {
+            if (IsCustomSize)
+            {
+                if (CustomPaperSizeHeight!=null&&CustomPaperSizeWidth!=null)
+                {
+                    currentPageMediaSize = new PageMediaSize((double)CustomPaperSizeWidth/25.4*96, (double)CustomPaperSizeHeight / 25.4 * 96);
+                }
+                else
+                {
+                    MessageBoxEx.Show("纸张尺寸缺失");
+                    return;
+                }
+            }
+            Margin.Add(MarginLeft);
+            Margin.Add(MarginTop);
+            Margin.Add(MarginRight);
+            Margin.Add(MarginBottom);
+            var dialogResult = new DialogResult(ButtonResult.OK);
+            dialogResult.Parameters.Add("PageMediaSize", currentPageMediaSize);
+            dialogResult.Parameters.Add("MarginLeft", MarginLeft);
+            dialogResult.Parameters.Add("MarginTop", MarginTop);
+            dialogResult.Parameters.Add("MarginRight", MarginRight);
+            dialogResult.Parameters.Add("MarginBottom", MarginBottom);
+            RequestClose.Invoke(dialogResult);
+        }
+
+        public void Cancel()
+        {
+            var dialogResult = new DialogResult(ButtonResult.Cancel);
+            RequestClose.Invoke(dialogResult);
+        }
+
+        public bool CanCloseDialog()
+        {
+            return true;
+        }
+
+        public void OnDialogClosed()
+        {
+        }
+
+        public void OnDialogOpened(IDialogParameters parameters)
+        {
+            parameters.TryGetValue<PrintQueue>(ParameterNames.PrintQueue, out printQueue);
+            parameters.TryGetValue<string>("Unicode", out Unicode);
+            InitPaperSizeList();
+        }
+    }
+}

+ 0 - 14
PDF Office/ViewModels/Dialog/HomePageToolsDialogs/HomePagePrinter/ModInfoSendEvent.cs

@@ -1,14 +0,0 @@
-using PDF_Office.Model.Dialog.HomePageToolsDialogs.HomePagePrinter;
-using Prism.Events;
-using System;
-using System.Collections.Generic;
-using System.Linq;
-using System.Text;
-using System.Threading.Tasks;
-
-namespace PDF_Office.ViewModels.Dialog.HomePageToolsDialogs.HomePagePrinter
-{
-    internal class ModInfoSendEvent : PubSubEvent<PrintMod>
-    {
-    }
-}

+ 25 - 1
PDF Office/ViewModels/EditTools/Background/BackgroundContentViewModel.cs

@@ -14,6 +14,7 @@ using ComPDFKitViewer.PdfViewer;
 using PDF_Office.Model;
 using PDF_Office.Model.EditTools.Background;
 using PDFSettings;
+using PDF_Office.CustomControl;
 
 namespace PDF_Office.ViewModels.EditTools.Background
 {
@@ -97,7 +98,7 @@ namespace PDF_Office.ViewModels.EditTools.Background
         public DelegateCommand CloseEditToolCommand { get; set; }
         public DelegateCommand ConfirmEditToolCommand { get; set; }
         public DelegateCommand<string> EnterSelectedContentCommand { get; set; }
-
+        public DelegateCommand DeleteBackgroundCommand { get; set; }
 
         public string Unicode = null;
 
@@ -113,6 +114,7 @@ namespace PDF_Office.ViewModels.EditTools.Background
             CloseEditToolCommand = new DelegateCommand(CloseEditTool);
             ConfirmEditToolCommand = new DelegateCommand(ConfirmEditTool);
             EnterSelectedContentCommand = new DelegateCommand<string>(EnterSelectedContent);
+            DeleteBackgroundCommand = new DelegateCommand(DeleteBackground);
 
             eventAggregator.GetEvent<EnterTemplateListOrCreateEvent>().Subscribe(EnterTemplateListOrCreate, e => e.Unicode == Unicode);
             eventAggregator.GetEvent<SetCurrentCreateModEvent>().Subscribe(SetCurrentCreateMod, e => e.Unicode == Unicode);
@@ -197,6 +199,28 @@ namespace PDF_Office.ViewModels.EditTools.Background
             BackgroundSettingsVisible = Visibility.Visible;
         }
 
+        private void DeleteBackground()
+        {
+            AlertsMessage alertsMessage = new AlertsMessage();
+                alertsMessage.ShowDialog("确定要删除背景吗?", "", "取消", "删除");
+                if (alertsMessage.result == ContentResult.Ok)
+                {
+                    this.eventAggregator.GetEvent<DeleteBackgroundEvent>().Publish(new EnumDeleteUnicode
+                    {
+                        Unicode = Unicode,
+                        Status = EnumDelete.StatusDeleteAll
+                    });
+                }
+                else
+                {
+                    this.eventAggregator.GetEvent<DeleteBackgroundEvent>().Publish(new EnumDeleteUnicode
+                    {
+                        Unicode = Unicode,
+                        Status = EnumDelete.StatusCreate
+                    });
+                }
+        }
+
         public void EnterDocumentContent()
         {
             NavigationParameters param = new NavigationParameters();

+ 96 - 18
PDF Office/ViewModels/EditTools/Background/BackgroundCreateColorContentViewModel.cs

@@ -54,6 +54,27 @@ namespace PDF_Office.ViewModels.EditTools.Background
             }
         }
 
+        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
         {
@@ -87,7 +108,7 @@ namespace PDF_Office.ViewModels.EditTools.Background
             set
             {
                 SetProperty(ref _opacityValue, value);
-                BackgroundInfo.Opacity = (byte)(((float)value / 100) * 255);
+                BackgroundInfo.Opacity = (byte)value;
                 eventAggregator.GetEvent<SetBackgroundEvent>().Publish(new BackgroundInfoUnicode
                 {
                     Unicode = Unicode,
@@ -96,14 +117,19 @@ namespace PDF_Office.ViewModels.EditTools.Background
             }
         }
 
-        private int _relativeRatioValue = 0;
+        private int _relativeRatioValue = 50;
         public int RelativeRatioValue
         {
             get { return _relativeRatioValue; }
             set
             {
                 SetProperty(ref _rotationValue, value);
-                BackgroundInfo.RelativeRatio = value;
+                BackgroundInfo.Scale = value;
+                eventAggregator.GetEvent<SetBackgroundEvent>().Publish(new BackgroundInfoUnicode
+                {
+                    Unicode = Unicode,
+                    Status = BackgroundInfo
+                });
             }
         }
 
@@ -202,6 +228,37 @@ namespace PDF_Office.ViewModels.EditTools.Background
             }
         }
 
+        private bool _isRelativeScaleValue = false;
+        public bool IsRelativeScaleValue
+        {
+            get { return _isRelativeScaleValue; }
+            set
+            {
+                SetProperty(ref _isRelativeScaleValue, value);
+                BackgroundInfo.IsRelativeScale = IsRelativeScaleValue;
+                eventAggregator.GetEvent<SetBackgroundEvent>().Publish(new BackgroundInfoUnicode
+                {
+                    Unicode = Unicode,
+                    Status = BackgroundInfo
+                });
+            }
+        }
+
+        private string _relativeScaleText = "50 %";
+        public string RelativeScaleText
+        {
+            get { return _relativeScaleText; }
+            set
+            {
+                SetProperty(ref _relativeScaleText, value);
+                eventAggregator.GetEvent<SetBackgroundEvent>().Publish(new BackgroundInfoUnicode
+                {
+                    Unicode = Unicode,
+                    Status = BackgroundInfo
+                });
+            }
+        }
+
 
 
         public DelegateCommand<object> ChangeLocationCommand { get; set; }
@@ -227,8 +284,8 @@ namespace PDF_Office.ViewModels.EditTools.Background
 
         public void InitComponent()
         {
-            InitOpacityList();
             InitRotationList();
+            InitOpacityList();
             InitRelativeRatioList();
         }
 
@@ -290,7 +347,7 @@ namespace PDF_Office.ViewModels.EditTools.Background
             }
         }
 
-
+        
         public void ChangeColor(object e)
         {
             if (e != null)
@@ -307,7 +364,7 @@ namespace PDF_Office.ViewModels.EditTools.Background
         {
             if (backgroundItem != null)
             {
-                backgroundItem.type = backgroundInfo.BackgroundType;
+                backgroundItem.type = C_Background_Type.BG_TYPE_COLOR;
                 backgroundItem.bgColor = backgroundInfo.Color;
                 backgroundItem.horizalign = backgroundInfo.Horizalign;
                 backgroundItem.vertalign = backgroundInfo.Vertalign;
@@ -315,9 +372,9 @@ namespace PDF_Office.ViewModels.EditTools.Background
                 backgroundItem.horizalign = backgroundInfo.Horizalign;
                 backgroundItem.opacity = backgroundInfo.Opacity;
                 backgroundItem.rotation = backgroundInfo.Rotation;
-                backgroundItem.scale = backgroundInfo.Scale;
                 backgroundItem.PageRangeIndex = backgroundInfo.PageRangeIndex;
                 backgroundItem.pageRange = backgroundInfo.PageRange;
+                backgroundItem.isRelativeScale = backgroundInfo.IsRelativeScale;
                 backgroundItem.scale = backgroundInfo.Scale;
             }
 
@@ -327,7 +384,7 @@ namespace PDF_Office.ViewModels.EditTools.Background
         {
             var backgroundItem = new BackgroundItem();
             ConvertInfoToItem(ref backgroundItem, BackgroundInfo);
-            backgroundItem.templateName += Settings.Default.WatermarkIndex.ToString();
+            backgroundItem.templateName += Settings.Default.BackgroundIndex.ToString();
             try
             {
                 //创建缓存文件夹
@@ -356,14 +413,21 @@ namespace PDF_Office.ViewModels.EditTools.Background
                     var tempBackground = tempDocument.GetBackground();
                     tempBackground.SetBackgroundType(BackgroundInfo.BackgroundType);
                     tempBackground.SetColor(BackgroundInfo.Color);
-                    tempBackground.SetScale(1);
-                    tempBackground.SetRotation(BackgroundInfo.Rotation);
-                    tempBackground.SetOpacity(BackgroundInfo.Opacity);
+                    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(BackgroundInfo.PageRange);
+                    tempBackground.SetPages("0");
                     tempBackground.SetAllowsPrint(true);
                     tempBackground.SetAllowsView(true);
                     tempBackground.Update();
@@ -398,7 +462,7 @@ namespace PDF_Office.ViewModels.EditTools.Background
         {
             if (backgroundItem != null)
             {
-                backgroundInfo.BackgroundType = backgroundItem.type;
+                backgroundInfo.BackgroundType = C_Background_Type.BG_TYPE_COLOR;
                 backgroundInfo.Color = backgroundItem.bgColor;
                 backgroundInfo.Horizalign = backgroundItem.horizalign;
                 backgroundInfo.Vertalign = backgroundItem.vertalign;
@@ -406,6 +470,7 @@ namespace PDF_Office.ViewModels.EditTools.Background
                 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;
@@ -419,10 +484,13 @@ namespace PDF_Office.ViewModels.EditTools.Background
         {
             ConvertItemToInfo(TemplateBackgroundItem, ref BackgroundInfo);
             Color = EditToolsHelper.ConvertColor(BackgroundInfo.Color);
-            RotationValue = (int)BackgroundInfo.Rotation;
+            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)
@@ -460,14 +528,22 @@ namespace PDF_Office.ViewModels.EditTools.Background
                         var tempBackground = tempDocument.GetBackground();
                         tempBackground.SetBackgroundType(BackgroundInfo.BackgroundType);
                         tempBackground.SetColor(BackgroundInfo.Color);
-                        tempBackground.SetScale(1);
-                        tempBackground.SetRotation(BackgroundInfo.Rotation);
-                        tempBackground.SetOpacity(BackgroundInfo.Opacity);
+                        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(BackgroundInfo.PageRange);
+                        tempBackground.SetPages("0");
                         tempBackground.SetAllowsPrint(true);
                         tempBackground.SetAllowsView(true);
                         tempBackground.Update();
@@ -507,6 +583,7 @@ namespace PDF_Office.ViewModels.EditTools.Background
                 SaveCurrentTemplate();
             }
         }
+
         public bool IsNavigationTarget(NavigationContext navigationContext)
         {
             return true;
@@ -520,6 +597,7 @@ namespace PDF_Office.ViewModels.EditTools.Background
         {
 
             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();

+ 121 - 16
PDF Office/ViewModels/EditTools/Background/BackgroundCreateFileContentViewModel.cs

@@ -67,7 +67,7 @@ namespace PDF_Office.ViewModels.EditTools.Background
             set
             {
                 SetProperty(ref _rotationValue, value);
-                BackgroundInfo.Rotation = ((float)RotationValue / 180) * 3.1415926f;
+                BackgroundInfo.Rotation = value;
                 eventAggregator.GetEvent<SetBackgroundEvent>().Publish(new BackgroundInfoUnicode
                 {
                     Unicode = Unicode,
@@ -84,7 +84,7 @@ namespace PDF_Office.ViewModels.EditTools.Background
             set
             {
                 SetProperty(ref _opacityValue, value);
-                BackgroundInfo.Opacity = (byte)(((float)OpacityValue / 100) * 225);
+                BackgroundInfo.Opacity = (byte)(value);
                 eventAggregator.GetEvent<SetBackgroundEvent>().Publish(new BackgroundInfoUnicode
                 {
                     Unicode = Unicode,
@@ -93,11 +93,20 @@ namespace PDF_Office.ViewModels.EditTools.Background
             }
         }
 
-        private int _relativeRatioValue = 0;
+        private int _relativeRatioValue = 50;
         public int RelativeRatioValue
         {
             get { return _relativeRatioValue; }
-            set { SetProperty(ref _relativeRatioValue, value); }
+            set
+            {
+                SetProperty(ref _rotationValue, value);
+                BackgroundInfo.Scale = value;
+                eventAggregator.GetEvent<SetBackgroundEvent>().Publish(new BackgroundInfoUnicode
+                {
+                    Unicode = Unicode,
+                    Status = BackgroundInfo
+                });
+            }
         }
 
         private string _verticalOffsetValue = "0";
@@ -116,6 +125,22 @@ namespace PDF_Office.ViewModels.EditTools.Background
             }
         }
 
+        private string _relativeScaleText = "50 %";
+        public string RelativeScaleText
+        {
+            get { return _relativeScaleText; }
+            set
+            {
+                SetProperty(ref _relativeScaleText, value);
+                eventAggregator.GetEvent<SetBackgroundEvent>().Publish(new BackgroundInfoUnicode
+                {
+                    Unicode = Unicode,
+                    Status = BackgroundInfo
+                });
+            }
+        }
+
+
         private string _horizOffsetValue = "0";
         public string HorizontalOffsetValue
         {
@@ -132,7 +157,26 @@ namespace PDF_Office.ViewModels.EditTools.Background
             }
         }
 
+        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
@@ -164,6 +208,23 @@ namespace PDF_Office.ViewModels.EditTools.Background
             set => SetProperty(ref _createModFileVisible, value);
         }
 
+        private bool _isRelativeScaleValue = false;
+        public bool IsRelativeScaleValue
+        {
+            get { return _isRelativeScaleValue; }
+            set
+            {
+                SetProperty(ref _isRelativeScaleValue, value);
+                BackgroundInfo.IsRelativeScale = IsRelativeScaleValue;
+                eventAggregator.GetEvent<SetBackgroundEvent>().Publish(new BackgroundInfoUnicode
+                {
+                    Unicode = Unicode,
+                    Status = BackgroundInfo
+                });
+            }
+        }
+
+
 
         public DelegateCommand OpenFileCommand { get; set; }
         public DelegateCommand<object> ChangeLocationCommand { get; set; }
@@ -221,7 +282,7 @@ namespace PDF_Office.ViewModels.EditTools.Background
 
         private void InitRotationList()
         {
-            OpacityList.Clear();
+            RotationList.Clear();
             for (int defaultRotation = -45; defaultRotation <= 45; defaultRotation += 15)
             {
                 RotationList.Add(defaultRotation.ToString());
@@ -264,7 +325,15 @@ namespace PDF_Office.ViewModels.EditTools.Background
 
         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)
@@ -325,9 +394,28 @@ namespace PDF_Office.ViewModels.EditTools.Background
             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 = backgroundInfo.BackgroundType;
+            backgroundItem.type =  C_Background_Type.BG_TYPE_IMAGE;
             backgroundItem.imageArray = backgroundInfo.ImageArray;
             backgroundItem.imageWidth = backgroundInfo.ImageWidth;
             backgroundItem.imageHeight = backgroundInfo.ImageHeight;
@@ -337,6 +425,7 @@ namespace PDF_Office.ViewModels.EditTools.Background
             backgroundItem.horizalign = backgroundInfo.Horizalign;
             backgroundItem.opacity = backgroundInfo.Opacity;
             backgroundItem.rotation = backgroundInfo.Rotation;
+            backgroundItem.isRelativeScale = backgroundInfo.IsRelativeScale;
             backgroundItem.scale = backgroundInfo.Scale;
             //backgroundItem.pagRangeMode = backgroundInfo.PageRange;
         }
@@ -345,7 +434,7 @@ namespace PDF_Office.ViewModels.EditTools.Background
         {
             var backgroundItem = new BackgroundItem();
             ConvertInfoToItem(ref backgroundItem, BackgroundInfo);
-            backgroundItem.templateName += Settings.Default.WatermarkIndex.ToString();
+            backgroundItem.templateName += Settings.Default.BackgroundIndex.ToString();
             try
             {
                 //创建缓存文件夹
@@ -374,14 +463,22 @@ namespace PDF_Office.ViewModels.EditTools.Background
                     var tempBackground = tempDocument.GetBackground();
                     tempBackground.SetBackgroundType(BackgroundInfo.BackgroundType);
                     tempBackground.SetImage(BackgroundInfo.ImageArray, BackgroundInfo.ImageWidth, BackgroundInfo.ImageHeight, ComPDFKit.Import.C_Scale_Type.fitCenter);
-                    tempBackground.SetScale(1);
-                    tempBackground.SetRotation(BackgroundInfo.Rotation);
-                    tempBackground.SetOpacity(BackgroundInfo.Opacity);
+                    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(BackgroundInfo.PageRange);
+                    tempBackground.SetPages("0");
                     tempBackground.SetAllowsPrint(true);
                     tempBackground.SetAllowsView(true);
                     tempBackground.Update();
@@ -449,14 +546,22 @@ namespace PDF_Office.ViewModels.EditTools.Background
                         var tempBackground = tempDocument.GetBackground();
                         tempBackground.SetBackgroundType(BackgroundInfo.BackgroundType);
                         tempBackground.SetImage(BackgroundInfo.ImageArray, BackgroundInfo.ImageWidth, BackgroundInfo.ImageHeight, ComPDFKit.Import.C_Scale_Type.fitCenter);
-                        tempBackground.SetScale(1);
-                        tempBackground.SetRotation(BackgroundInfo.Rotation);
-                        tempBackground.SetOpacity(BackgroundInfo.Opacity);
+                        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(BackgroundInfo.PageRange);
+                        tempBackground.SetPages("0");
                         tempBackground.SetAllowsPrint(true);
                         tempBackground.SetAllowsView(true);
                         tempBackground.Update();

+ 37 - 11
PDF Office/ViewModels/EditTools/Background/BackgroundDocumentContentViewModel.cs

@@ -34,7 +34,8 @@ namespace PDF_Office.ViewModels.EditTools.Background
         public CPDFViewer PDFViewer;
         public CPDFDocument Document;
         private ViewContentViewModel viewContentViewModel;
-        CPDFViewer pdfViewer;
+        public EnumDelete EnumDelete = EnumDelete.StatusCreate;
+        public CPDFViewer pdfViewer;
 
         private CPDFBackground background;
         private BackgroundInfo backgroundInfo;
@@ -60,6 +61,7 @@ namespace PDF_Office.ViewModels.EditTools.Background
             set
             {
                 SetProperty(ref _currentPageIndex, value);
+
             }
         }
 
@@ -90,6 +92,7 @@ namespace PDF_Office.ViewModels.EditTools.Background
 
             eventAggregator.GetEvent<ConfirmEditToolsBackgroundEvent>().Subscribe(ConfirmEditToolsBackground);
             eventAggregator.GetEvent<SetBackgroundEvent>().Subscribe(SetBackground, e => e.Unicode == Unicode);
+            eventAggregator.GetEvent<DeleteBackgroundEvent>().Subscribe(DeleteBackground, e => e.Unicode == Unicode);
             ViewerRegionName = RegionNames.BackgroundViewerRegionName;
         }
 
@@ -121,20 +124,37 @@ namespace PDF_Office.ViewModels.EditTools.Background
 
         public void ConfirmEditToolsBackground()
         {
+            if (EnumDelete == EnumDelete.StatusDeleteAll)
+            {
+                PDFViewer.Document.GetBackground().Clear();
+            }
+
             if (backgroundInfo != null)
             {
                 CreateBackground(viewContentViewModel.PDFViewer.Document);
             }
+            viewContentViewModel.PDFViewer.UndoManager.CanSave = true;
         }
 
+        public void DeleteBackground(EnumDeleteUnicode enumDeleteunicode)
+        {
+            if(enumDeleteunicode.Status == EnumDelete.StatusDeleteAll)
+            {
+                EnumDelete enumDelete = enumDeleteunicode.Status;
+                EnumDelete = enumDelete;
+                PDFViewer.Document.GetBackground().Clear();
+                PDFViewer.Document.ReleasePages();
+                PDFViewer.ReloadDocument();
+            }
+        }
+        
+
         public void SetBackground(BackgroundInfoUnicode backgroundInfounicode)
         {
+            EnumDelete = EnumDelete.StatusCreate;
             BackgroundInfo backgroundInfo = backgroundInfounicode.Status;
             this.backgroundInfo = backgroundInfo;
-            CreateBackground(PDFViewer.Document);
             PDFViewer.InvalidChildVisual(false);
-            PDFViewer.Document.ReleasePages();
-            PDFViewer.ReloadDocument();
         }
 
         public void CreateBackground(CPDFDocument document, bool IsNewDoc = false)
@@ -152,10 +172,16 @@ namespace PDF_Office.ViewModels.EditTools.Background
                     background.SetBackgroundType(C_Background_Type.BG_TYPE_IMAGE);
                     background.SetImage(backgroundInfo.ImageArray, backgroundInfo.ImageWidth, backgroundInfo.ImageHeight, ComPDFKit.Import.C_Scale_Type.fitCenter);
                 }
-
-                background.SetScale(1);
-                background.SetRotation(backgroundInfo.Rotation);
-                background.SetOpacity(backgroundInfo.Opacity);
+                if (!backgroundInfo.IsRelativeScale)
+                {
+                    background.SetScale(1);
+                }
+                else
+                {
+                    background.SetScale((float)(backgroundInfo.Scale / 100));
+                }
+                background.SetRotation((float)((backgroundInfo.Rotation / 180) * Math.PI ));
+                background.SetOpacity((byte)(((float)backgroundInfo.Opacity / 100) * 255));
                 background.SetVertalign(backgroundInfo.Vertalign);
                 background.SetHorizalign(backgroundInfo.Horizalign);
                 background.SetXOffset(backgroundInfo.HorizOffset);
@@ -211,10 +237,10 @@ namespace PDF_Office.ViewModels.EditTools.Background
             CreateBackground(newDoc, true);
             CPDFPage newPage = newDoc.PageAtIndex(0);
             double scale = 96.0 / 72.0;
-            zoom = zoom * scale;
+            zoom = zoom * 1.5;
             Rect renderRect = new Rect(0, 0, (int)(pageSize.Width * scale), (int)(pageSize.Height * scale));
             byte[] imageArray = new byte[(int)(renderRect.Width * renderRect.Height * 4)];
-            newPage.RenderPageBitmapWithMatrix((float)zoom, renderRect, 0x00FFFFFF, imageArray, 1, true);
+            newPage.RenderPageBitmapWithMatrix(1/(float)zoom, renderRect, 0x00FFFFFF, imageArray, 1, true);
             WriteableBitmap WirteBitmap = new WriteableBitmap((int)renderRect.Width, (int)renderRect.Height, 96, 96, PixelFormats.Bgra32, null);
             WirteBitmap.WritePixels(new Int32Rect(0, 0, (int)renderRect.Width, (int)renderRect.Height), imageArray, WirteBitmap.BackBufferStride, 0);
             return WirteBitmap;
@@ -234,7 +260,6 @@ namespace PDF_Office.ViewModels.EditTools.Background
         {
             navigationContext.Parameters.TryGetValue<CPDFViewer>(ParameterNames.PDFViewer, out pdfViewer);
             navigationContext.Parameters.TryGetValue<ViewContentViewModel>(ParameterNames.ViewContentViewModel, out viewContentViewModel);
-            navigationContext.Parameters.TryGetValue<string>("UniCode", out unicode);
             if (pdfViewer != null)
             {
                 if (!regionManager.Regions[ViewerRegionName].Views.Contains(PDFViewer))
@@ -250,6 +275,7 @@ namespace PDF_Office.ViewModels.EditTools.Background
                     PDFViewer.ChangeViewMode(ViewMode.Single);
                     PDFViewer.SetMouseMode(MouseModes.Default);
                     PageRangeNumber = PDFViewer.Document.PageCount;
+                    PDFViewer.Zoom(0.5);
                 }
             }
         }

+ 0 - 2
PDF Office/ViewModels/EditTools/Background/BackgroundTemplateListColorContentViewModel.cs

@@ -241,8 +241,6 @@ namespace PDF_Office.ViewModels.EditTools.Background
 
         public void OnNavigatedTo(NavigationContext navigationContext)
         {
-
-            navigationContext.Parameters.TryGetValue<string>("UniCode", out unicode);
             InitBackgroundTemplateList();
         }
     }

+ 1 - 0
PDF Office/ViewModels/EditTools/Background/BackgroundTemplateListFileContentViewModel.cs

@@ -231,6 +231,7 @@ namespace PDF_Office.ViewModels.EditTools.Background
             SendTemplateItemToDocument(BackgroundItem);
         }
 
+
         public bool IsNavigationTarget(NavigationContext navigationContext)
         {
             return true;

+ 27 - 1
PDF Office/ViewModels/EditTools/Bates/BatesContentViewModel.cs

@@ -10,6 +10,7 @@ using System.Linq;
 using ComPDFKitViewer.PdfViewer;
 using PDF_Office.Model;
 using PDFSettings;
+using PDF_Office.CustomControl;
 
 namespace PDF_Office.ViewModels.EditTools.Bates
 {
@@ -71,6 +72,7 @@ namespace PDF_Office.ViewModels.EditTools.Bates
 
         public DelegateCommand CloseEditToolCommand { get; set; }
         public DelegateCommand ConfirmEditToolCommand { get; set; }
+        public DelegateCommand DeleteBatesCommand { get; set; }
 
         public string Unicode = null;
 
@@ -84,6 +86,7 @@ namespace PDF_Office.ViewModels.EditTools.Bates
 
             CloseEditToolCommand = new DelegateCommand(CloseEditTool);
             ConfirmEditToolCommand = new DelegateCommand(ConfirmEditTool);
+            DeleteBatesCommand = new DelegateCommand(DeleteBates);
             eventAggregator.GetEvent<EditBatesHeaderFooterTemplateItemEvent>().Subscribe(EditBatesTemplateItem, e => e.Unicode == Unicode&&e.Type== BatesType);
             eventAggregator.GetEvent<EnterTemplateListOrCreateEvent>().Subscribe(EnterTemplateListOrCreate, e => e.Unicode == Unicode);
 
@@ -95,8 +98,31 @@ namespace PDF_Office.ViewModels.EditTools.Bates
         public void ConfirmEditTool()
         {
 
-            this.eventAggregator.GetEvent<CloseEditToolEvent>().Publish(new EnumCloseModeUnicode { Unicode = Unicode, Status = EnumCloseMode.StatusCancel });
+            this.eventAggregator.GetEvent<ConfirmEditToolsBatesEvent>().Publish(Unicode);
+            this.eventAggregator.GetEvent<CloseEditToolEvent>().Publish(new EnumCloseModeUnicode { Unicode = Unicode, Status = EnumCloseMode.StatusConfirm });
+
+        }
 
+        private void DeleteBates()
+        {
+            AlertsMessage alertsMessage = new AlertsMessage();
+            alertsMessage.ShowDialog("确定要删除背景吗?", "", "取消", "删除");
+            if (alertsMessage.result == ContentResult.Ok)
+            {
+                this.eventAggregator.GetEvent<DeleteBatesEvent>().Publish(new EnumDeleteUnicode
+                {
+                    Unicode = Unicode,
+                    Status = EnumDelete.StatusDeleteAll
+                });
+            }
+            else
+            {
+                this.eventAggregator.GetEvent<DeleteBatesEvent>().Publish(new EnumDeleteUnicode
+                {
+                    Unicode = Unicode,
+                    Status = EnumDelete.StatusCreate
+                });
+            }
         }
 
         public void EnterSelectedContent(string SelectedContentName)

+ 732 - 1
PDF Office/ViewModels/EditTools/Bates/BatesCreateContentViewModel.cs

@@ -1,24 +1,740 @@
-using Prism.Commands;
+using ComPDFKitViewer.PdfViewer;
+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;
+using PDFSettings;
+using PDF_Office.Model.EditTools.Watermark;
+using PDF_Office.Helper;
+using System.Windows.Media;
+using System.Diagnostics;
+using ComPDFKit.PDFDocument;
+using PDF_Office.Model.EditTools.Background;
+using PDF_Office.Model.EditTools.Bates;
+using PDF_Office.Model.EditTools.HeaderFooter;
+using PDF_Office.Properties;
+using System.IO;
 
 namespace PDF_Office.ViewModels.EditTools.Bates
 {
     public class BatesCreateContentViewModel : BindableBase, INavigationAware
     {
+        private CPDFViewer PDFViewer;
+
+        public BatesInfo BatesInfo = new BatesInfo();
+
+        public BatesHeaderFooterItem TemplateBatesItem;
+
+        public enum EnumCreateOrEdit
+        {
+            None,
+            StatusCreate,
+            StatusEdit
+        }
+
+        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 int _fontNameSelectedIndex = 0;
+        public int FontNameSelectedIndex
+        {
+            get { return _fontNameSelectedIndex; }
+            set
+            {
+                SetProperty(ref _fontNameSelectedIndex, value);
+                SetFontName(FontNameSelectedIndex);
+                eventAggregator.GetEvent<SetBatesEvent>().Publish(new BatesInfoUnicode
+                {
+                    Unicode = Unicode,
+                    Status = BatesInfo
+                });
+
+            }
+        }
+
+        private List<string> _fontSizeList = new List<string>();
+        public List<string> FontSizeList
+        {
+            get { return _fontSizeList; }
+            set
+            {
+                SetProperty(ref _fontSizeList, value);
+            }
+        }
+
+        private void InitFontSizeList()
+        {
+            FontSizeList.Clear();
+            for (int temp = 10; temp <= 15; temp += 1)
+            {
+                FontSizeList.Add(temp.ToString() + "pt");
+            }
+        }
+
+        private int _fontSizeSelectedIndex = 0;
+        public int FontSizeSelectedIndex
+        {
+            get { return _fontSizeSelectedIndex; }
+            set
+            {
+                SetProperty(ref _fontSizeSelectedIndex, value);
+                SetFontSize(FontSizeSelectedIndex);
+                eventAggregator.GetEvent<SetBatesEvent>().Publish(new BatesInfoUnicode
+                {
+                    Unicode = Unicode,
+                    Status = BatesInfo
+                });
+            }
+        }
+
+        private List<string> _starPagetNumberList = new List<string>();
+        public List<string> StarPagetNumberList
+        {
+            get { return _starPagetNumberList; }
+            set
+            {
+                SetProperty(ref _starPagetNumberList, value);
+            }
+        }
+
+        private void InitStarPagetNumberList()
+        {
+            StarPagetNumberList.Clear();
+            for (int temp = 10; temp <= 15; temp += 1)
+            {
+                StarPagetNumberList.Add(temp.ToString());
+            }
+        }
+
+        private int _starPagetNumberIndex = 0;
+        public int StarPagetNumberIndex
+        {
+            get { return _starPagetNumberIndex; }
+            set
+            {
+                SetProperty(ref _starPagetNumberIndex, value);
+                SetStarPagetNumber(StarPagetNumberIndex);
+            }
+        }
+
+        public string _pageRangeText = "0";
+        public string PageRangeText
+        {
+            get { return _pageRangeText; }
+            set
+            {
+                _pageRangeText = value;
+                EditToolsHelper.GetPageRange(PageRangeSelectIndex, PDFViewer.Document, ref BatesInfo.PageRange, PageRangeText);
+                eventAggregator.GetEvent<SetBatesEvent>().Publish(new BatesInfoUnicode
+                {
+                    Unicode = Unicode,
+                    Status = BatesInfo
+                });
+            }
+        }
+
+        private int _pageRangeSelectIndex = 0;
+        public int PageRangeSelectIndex
+        {
+            get { return _pageRangeSelectIndex; }
+            set
+            {
+                SetProperty(ref _pageRangeSelectIndex, value);
+                BatesInfo.PageRangeIndex = PageRangeSelectIndex;
+                EditToolsHelper.GetPageRange(PageRangeSelectIndex, PDFViewer.Document, ref BatesInfo.PageRange, PageRangeText);
+                eventAggregator.GetEvent<SetBatesEvent>().Publish(new BatesInfoUnicode
+                {
+                    Unicode = Unicode,
+                    Status = BatesInfo
+                });
+            }
+        }
+
+        private SolidColorBrush _solidColorBrush = new SolidColorBrush(Color.FromArgb(0xFF, 0xFF, 0x00, 0x00));
+        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);
+                SolidColorBrush = new SolidColorBrush(StringColor);
+                for (int i = 0; i <= 5; i++)
+                {
+                    BatesInfo.TextData[i].Color = EditToolsHelper.ConvertColor(value);
+                }
+                eventAggregator.GetEvent<SetBatesEvent>().Publish(new BatesInfoUnicode
+                {
+                    Unicode = Unicode,
+                    Status = BatesInfo
+                });
+
+            }
+        }
+
+
+        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 _createBaseVisible;
+        public Visibility CreateBaseVisible
+        {
+            get => _createBaseVisible;
+            set => SetProperty(ref _createBaseVisible, value);
+        }
+
+        private Visibility _editBaseVisible;
+        public Visibility EditBaseVisible
+        {
+            get => _editBaseVisible;
+            set => SetProperty(ref _editBaseVisible, value);
+        }
+
+        private string _marginTopValue = "3";
+        public string MarginTopValue
+        {
+            get { return _marginTopValue; }
+            set
+            {
+                SetProperty(ref _marginTopValue, value);
+                bool ValueEQ = true;
+                if (BatesInfo.margin[1] == float.Parse(MarginTopValue))
+                {
+                    ValueEQ = false;
+                }
+                BatesInfo.margin[1] = float.Parse(MarginTopValue);
+                if (ValueEQ)
+                {
+                    eventAggregator.GetEvent<SetBatesEvent>().Publish(new BatesInfoUnicode
+                    {
+                        Unicode = Unicode,
+                        Status = BatesInfo
+                    });
+                }
+            }
+        }
+
+        private string _marginDownValue = "3";
+        public string MarginDownValue
+        {
+            get { return _marginDownValue; }
+            set
+            {
+                SetProperty(ref _marginDownValue, value);
+                bool ValueEQ = true;
+                if (BatesInfo.margin[3] == float.Parse(MarginTopValue))
+                {
+                    ValueEQ = false;
+                }
+                BatesInfo.margin[3] = float.Parse(MarginDownValue);
+                if (ValueEQ)
+                {
+                    eventAggregator.GetEvent<SetBatesEvent>().Publish(new BatesInfoUnicode
+                    {
+                        Unicode = Unicode,
+                        Status = BatesInfo
+                    });
+                }
+            }
+        }
+
+        private string _marginLeftValue = "3";
+        public string MarginLeftValue
+        {
+            get { return _marginLeftValue; }
+            set
+            {
+                SetProperty(ref _marginLeftValue, value);
+                bool ValueEQ = true;
+                if (BatesInfo.margin[0] == float.Parse(MarginTopValue))
+                {
+                    ValueEQ = false;
+                }
+                BatesInfo.margin[0] = float.Parse(MarginLeftValue);
+                if (ValueEQ)
+                {
+                    eventAggregator.GetEvent<SetBatesEvent>().Publish(new BatesInfoUnicode
+                    {
+                        Unicode = Unicode,
+                        Status = BatesInfo
+                    });
+                }
+            }
+        }
+
+        private string _marginRightValue = "3";
+        public string MarginRightValue
+        {
+            get { return _marginRightValue; }
+            set
+            {
+                SetProperty(ref _marginRightValue, value);
+                bool ValueEQ = true;
+                if (BatesInfo.margin[2] == float.Parse(MarginTopValue))
+                {
+                    ValueEQ = false;
+                }
+                if (ValueEQ)
+                {
+                    BatesInfo.margin[2] = float.Parse(MarginRightValue);
+                    eventAggregator.GetEvent<SetBatesEvent>().Publish(new BatesInfoUnicode
+                    {
+                        Unicode = Unicode,
+                        Status = BatesInfo
+                    });
+                }
+            }
+        }
+
+        private string _digitNumberValue = "1";
+        public string DigitNumberValue
+        {
+            get { return _digitNumberValue; }
+            set
+            {
+                SetProperty(ref _digitNumberValue, value);
+                BatesInfo.DigitNumber = int.Parse(DigitNumberValue);
+            }
+        }
+
+
+        private string _textValue = "";
+        public string TextValue
+        {
+            get { return _textValue; }
+            set
+            {
+                SetProperty(ref _textValue, value);
+            }
+        }
+
+
+        private string _prefixTextValue = "";
+        public string PrefixTextValue
+        {
+            get { return _prefixTextValue; }
+            set
+            {
+
+                _prefixTextValue = value;
+
+            }
+        }
+
+        private string _surfixTextValue = "";
+        public string SurfixTextValue
+        {
+            get { return _surfixTextValue; }
+            set
+            {
+                _surfixTextValue = value;
+            }
+        }
+
+        public int GetLocationIndex = 0;
+
+        private Dictionary<string, string> _getTextValueFromNumber = new Dictionary<string, string>();
+        public Dictionary<string, string> GetTextValueFromNumber
+        {
+            get { return _getTextValueFromNumber; }
+            set
+            {
+                _getTextValueFromNumber = value;
+            }
+        }
+
         public IEventAggregator eventAggregator;
+
+        public DelegateCommand<object> ChangeLocationCommand { get; set; }
+        public DelegateCommand EnterTemplateListCommand { get; set; }
+        public DelegateCommand SaveToTemplateListCommand { get; set; }
+        public DelegateCommand SaveToCurrentTemplateListCommand { get; set; }
+        public DelegateCommand<object> SelectedColorChangedCommand { get; set; }
+        public DelegateCommand<object> TextValueChangedCommand { get; set; }
+        public DelegateCommand ADDBatesCommand { get; set; }
+
         public string Unicode = null;
 
         public BatesCreateContentViewModel(IEventAggregator eventAggregator)
         {
             this.eventAggregator = eventAggregator;
             Unicode = App.mainWindowViewModel.SelectedItem.Unicode;
+            for (int i = 0; i <= 5; i++)
+            {
+                BatesInfo.TextData[i].Color = EditToolsHelper.ConvertColor(Color.FromArgb(0xFF, 0xFF, 0x00, 0x00));
+            }
+            InitList();
+            InitBatesInfo();
+            ChangeLocationCommand = new DelegateCommand<object>(ChangeLocation);
+            SelectedColorChangedCommand = new DelegateCommand<object>(ChangedColor);
+            EnterTemplateListCommand = new DelegateCommand(EnterTemplateList);
+            SaveToTemplateListCommand = new DelegateCommand(SaveToTemplateList);
+            SaveToCurrentTemplateListCommand = new DelegateCommand(SaveToCurrentTemplateList);
+            TextValueChangedCommand = new DelegateCommand<object>(TextValueChanged);
+            ADDBatesCommand = new DelegateCommand(ADDBates);
+        }
+
+        private void InitList()
+        {
+
+            InitFontNameList();
+            InitFontSizeList();
+            InitStarPagetNumberList();
+            InitLocationButtonMatrix();
+
+        }
+
+        private void InitLocationButtonMatrix()
+        {
+            GetTextValueFromNumber.Clear();
+            for (var temp = 0; temp <= 5; temp++)
+            {
+                GetTextValueFromNumber.Add(temp.ToString(), temp.ToString());
+            }
+        }
+
+        private void InitBatesInfo()
+        {
+            for (int i = 0; i <= 5; i++)
+            {
+                BatesInfo.TextData[i].text = GetTextValueFromNumber[i.ToString()];
+            }
+            BatesInfo.margin[0] = float.Parse(MarginTopValue);
+            BatesInfo.margin[1] = float.Parse(MarginRightValue);
+            BatesInfo.margin[2] = float.Parse(MarginDownValue);
+            BatesInfo.margin[3] = float.Parse(MarginLeftValue);
+            BatesInfo.Prefix = PrefixTextValue;
+            BatesInfo.Suffix = SurfixTextValue;
+            BatesInfo.DigitNumber = int.Parse(DigitNumberValue);
+            SetFontName(FontNameSelectedIndex);
+            SetFontSize(FontSizeSelectedIndex);
+            SetStarPagetNumber(StarPagetNumberIndex);
+            StringColor = Color.FromArgb(0xFF, 0xFF, 0x00, 0x00);
+        }
+
+        private void SetFontName(int Index)
+        {
+            for (int i = 0; i <= 5; i++) { BatesInfo.TextData[i].fontName = FontNameList[Index]; }
+        }
+
+        private void SetFontSize(int Index)
+        {
+            for (int i = 0; i <= 5; i++) { BatesInfo.TextData[i].fontSize = (Index + 7) * 1.33f; }
+        }
+
+        private void SetStarPagetNumber(int Index)
+        {
+            BatesInfo.StarPagetNumber = Index;
+        }
+
+
+        public void ChangeLocation(object e)
+        {
+            string args = e as string;
+            if (args != null)
+            {
+                GetLocationIndex = int.Parse(args);
+                TextValue = GetTextValueFromNumber[args];
+
+            }
+        }
+
+        private void ChangedColor(object obj)
+        {
+            if (obj != null)
+            {
+                var colorValue = (Color)obj;
+                if (colorValue != null)
+                {
+
+                    StringColor = colorValue;
+                }
+            }
+        }
+
+        public void EnterTemplateList()
+        {
+            this.eventAggregator.GetEvent<EnterTemplateListOrCreateEvent>().Publish(new EnumTemplateListOrCreateUnicode { Unicode = Unicode, Status = EnumTemplateListOrCreate.StatusTemplate });
+        }
+
+        public void SaveToTemplateList()
+        {
+            SaveCurrentTemplate();
+        }
+
+        public void SaveToCurrentTemplateList()
+        {
+            ConfirmEditBackgroundTemplateItem();
+        }
+
+        private void TextValueChanged(object obj)
+        {
+            if (obj != null)
+            {
+                var textValue = obj as System.Windows.Controls.TextBox;
+                if (textValue != null)
+                {
+                    bool TextEQ = true;
+                    switch (textValue.Name)
+                    {
+                        case "TextValueTextBox":
+
+                            if (GetTextValueFromNumber[GetLocationIndex.ToString()] == textValue.Text)
+                            {
+                                TextEQ = false;
+                            }
+                            GetTextValueFromNumber[GetLocationIndex.ToString()] = textValue.Text;
+                            BatesInfo.TextData[GetLocationIndex].text = GetTextValueFromNumber[GetLocationIndex.ToString()];
+
+                            break;
+                        case "PrefixTextValueTextBox":
+                            if (BatesInfo.Prefix == textValue.Text)
+                            {
+                                TextEQ = false;
+                            }
+                            BatesInfo.Prefix = textValue.Text;
+
+                            break;
+                        case "SuffixTextValueTextBox":
+                            if (BatesInfo.Suffix == textValue.Text)
+                            {
+                                TextEQ = false;
+                            }
+                            BatesInfo.Suffix = textValue.Text;
+                            break;
+                        default:
+                            break;
+                    }
+                    if (TextEQ)
+                    {
+                        eventAggregator.GetEvent<SetBatesEvent>().Publish(new BatesInfoUnicode
+                        {
+                            Unicode = Unicode,
+                            Status = BatesInfo
+                        });
+                    }
+
+                }
+            }
+        }
+
+        public void ADDBates()
+        {
+            if (PrefixTextValue == "" || SurfixTextValue == "")
+            {
+                if (SurfixTextValue == "" && PrefixTextValue == "")
+                {
+                    GetTextValueFromNumber[GetLocationIndex.ToString()] = GetTextValueFromNumber[GetLocationIndex.ToString()] + "<<" + "#" + DigitNumberValue + "#" + (StarPagetNumberIndex + 1).ToString() + ">>";
+                }
+                else if (SurfixTextValue == "")
+                {
+                    GetTextValueFromNumber[GetLocationIndex.ToString()] = GetTextValueFromNumber[GetLocationIndex.ToString()] + "<<" + "#" + DigitNumberValue + "#" + (StarPagetNumberIndex + 1).ToString() + "#" + PrefixTextValue + ">>";
+                }
+                else
+                {
+                    GetTextValueFromNumber[GetLocationIndex.ToString()] = GetTextValueFromNumber[GetLocationIndex.ToString()] + "<<" + "#" + DigitNumberValue + "#" + (StarPagetNumberIndex + 1).ToString() + "#" + "#" + SurfixTextValue + ">>";
+                }
+            }
+            else
+            {
+                GetTextValueFromNumber[GetLocationIndex.ToString()] = GetTextValueFromNumber[GetLocationIndex.ToString()] + "<<" + "#" + DigitNumberValue + "#" + (StarPagetNumberIndex + 1).ToString() + "#" + PrefixTextValue + "#" + SurfixTextValue + ">>";
+            }
+            BatesInfo.TextData[GetLocationIndex].text = GetTextValueFromNumber[GetLocationIndex.ToString()];
+            eventAggregator.GetEvent<SetBatesEvent>().Publish(new BatesInfoUnicode
+            {
+                Unicode = Unicode,
+                Status = BatesInfo
+            });
+        }
+
+        public void ConvertInfoToItem(ref BatesHeaderFooterItem batesItem, BatesInfo batesInfo)
+        {
+            batesItem.TextData = batesInfo.TextData;
+            batesItem.DigitNumber = batesInfo.DigitNumber;
+            batesItem.ItemName = batesInfo.ItemName;
+            batesItem.Prefix = batesInfo.Prefix;
+            batesItem.Suffix = batesInfo.Suffix;
+            batesItem.StarPagetNumber = batesInfo.StarPagetNumber;
+            batesItem.margin = batesInfo.margin;
+            batesItem.PageRange = batesInfo.PageRange;
+            batesItem.PageRangeIndex = batesInfo.PageRangeIndex;
+
+        }
+
+        public void ConvertItemToInfo(BatesHeaderFooterItem batesItem, ref BatesInfo batesInfo)
+        {
+            batesInfo.TextData = batesItem.TextData;
+            batesInfo.ItemName = batesItem.ItemName;
+            batesInfo.DigitNumber = batesItem.DigitNumber;
+            batesInfo.Prefix = batesItem.Prefix;
+            batesInfo.Suffix = batesItem.Suffix;
+            batesInfo.StarPagetNumber = batesItem.StarPagetNumber;
+            batesInfo.margin = batesItem.margin;
+            batesInfo.PageRangeIndex = batesItem.PageRangeIndex;
+            EditToolsHelper.GetPageRange(batesInfo.PageRangeIndex, PDFViewer.Document, ref batesInfo.PageRange, batesItem.PageRange);
+
         }
 
+        public void SaveCurrentTemplate()
+        {
+            var batesItem = new BatesHeaderFooterItem();
+            ConvertInfoToItem(ref batesItem, BatesInfo);
+            batesItem.ItemName += Settings.Default.BatesTemplateList.Count().ToString();
+            try
+            {
+                //创建缓存文件夹
+                string folderPath = Path.Combine(App.CurrentPath, "Bates");
+                //有可能因为其他原因存在同名文件,导致创建文件夹失败,需要先删除同名文件
+                //保险措施(猜测)
+                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);
+                Settings.Default.BatesTemplateList.Add(batesItem);
+                Settings.Default.Save();
+            }
+            catch
+            {
+
+            }
+
+            this.eventAggregator.GetEvent<EnterTemplateListOrCreateEvent>().Publish(new EnumTemplateListOrCreateUnicode
+            {
+                Unicode = Unicode,
+                Status = EnumTemplateListOrCreate.StatusTemplate
+            });
+        }
+
+        public void ConfirmEditBackgroundTemplateItem()
+        {
+
+            var batesItem = new BatesHeaderFooterItem();
+            ConvertInfoToItem(ref batesItem, BatesInfo);
+            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();
+                }
+                Settings.Default.BatesTemplateList[TemplateBatesItem.listIndex] = batesItem;
+                Settings.Default.Save();
+            }
+            catch
+            {
+
+            }
+            this.eventAggregator.GetEvent<EnterTemplateListOrCreateEvent>().Publish(new EnumTemplateListOrCreateUnicode
+            {
+                Unicode = Unicode,
+                Status = EnumTemplateListOrCreate.StatusTemplate
+            });
+
+        }
+
+        public void InitComponentBySelectedInfo()
+        {
+            ConvertItemToInfo(TemplateBatesItem, ref BatesInfo);
+            for (int i = 0; i <= 5; i++)
+            {
+                GetTextValueFromNumber[i.ToString()] = BatesInfo.TextData[i].text;
+            }
+            MarginTopValue = BatesInfo.margin[0].ToString();
+            MarginRightValue = BatesInfo.margin[1].ToString();
+            MarginDownValue = BatesInfo.margin[2].ToString();
+            MarginLeftValue = BatesInfo.margin[3].ToString();
+            PrefixTextValue = BatesInfo.Prefix;
+            SurfixTextValue = BatesInfo.Suffix;
+            DigitNumberValue = BatesInfo.DigitNumber.ToString();
+            FontNameSelectedIndex = FontNameList.IndexOf(BatesInfo.TextData[0].fontName);
+            FontSizeSelectedIndex = FontSizeList.IndexOf(BatesInfo.TextData[0].fontSize.ToString());
+            StarPagetNumberIndex = StarPagetNumberList.IndexOf(BatesInfo.StarPagetNumber.ToString());
+            StringColor = EditToolsHelper.ConvertColor(BatesInfo.TextData[0].Color);
+            SolidColorBrush = new SolidColorBrush(StringColor);
+            PageRangeSelectIndex = BatesInfo.PageRangeIndex;
+        }
         public bool IsNavigationTarget(NavigationContext navigationContext)
         {
             return true;
@@ -30,6 +746,21 @@ namespace PDF_Office.ViewModels.EditTools.Bates
 
         public void OnNavigatedTo(NavigationContext navigationContext)
         {
+
+            navigationContext.Parameters.TryGetValue<CPDFViewer>(ParameterNames.PDFViewer, out PDFViewer);
+            EditToolsHelper.GetPageRange(PageRangeSelectIndex, PDFViewer.Document, ref BatesInfo.PageRange, PageRangeText);
+
+            if (navigationContext.Parameters.TryGetValue<BatesHeaderFooterItem>("BatesItem", out TemplateBatesItem))
+            {
+                CreateOrEdit = EnumCreateOrEdit.StatusEdit;
+                InitComponentBySelectedInfo();
+            }
+            else
+            {
+                CreateOrEdit = EnumCreateOrEdit.StatusCreate;
+            }
         }
+
+
     }
 }

+ 230 - 2
PDF Office/ViewModels/EditTools/Bates/BatesDocumentContentViewModel.cs

@@ -1,22 +1,233 @@
-using Prism.Commands;
+using ComPDFKit.PDFDocument;
+using ComPDFKit.PDFPage;
+using ComPDFKitViewer;
+using ComPDFKitViewer.PdfViewer;
+using PDF_Office.EventAggregators;
+using PDF_Office.Helper;
+using PDF_Office.Model.EditTools.Bates;
+using Prism.Commands;
 using Prism.Events;
 using Prism.Mvvm;
 using Prism.Regions;
 using System;
 using System.Collections.Generic;
 using System.Linq;
+using System.Text.RegularExpressions;
+using System.Windows;
+using System.Windows.Media.Imaging;
+using System.Windows.Media;
+using System.Windows.Controls;
+using PDF_Office.Model;
+using PDF_Office.Model.EditTools.HeaderFooter;
+using PDF_Office.Model.EditTools.Background;
 
 namespace PDF_Office.ViewModels.EditTools.Bates
 {
     public class BatesDocumentContentViewModel : BindableBase, INavigationAware
     {
         public IEventAggregator eventAggregator;
+        public IRegionManager regionManager;
+        public CPDFViewer PDFViewer;
+        public CPDFDocument Document;
+        private ViewContentViewModel viewContentViewModel;
+        public EnumDelete EnumDelete = EnumDelete.StatusCreate;
+        public CPDFViewer pdfViewer;
+
+        private CPDFBates bates;
+        private BatesInfo batesInfo;
+
+        public bool firstin = true;
+
+        public string ViewerRegionName { get; set; }
+
+        public string unicode = null;
         public string Unicode = null;
 
-        public BatesDocumentContentViewModel(IEventAggregator eventAggregator)
+        private int _pageSize;
+        public int PageRangeNumber
+        {
+            get { return _pageSize; }
+            set { SetProperty(ref _pageSize, value); }
+        }
+
+        private int _currentPageIndex;
+        public int CurrentPageIndex
         {
+            get { return _currentPageIndex; }
+            set
+            {
+                SetProperty(ref _currentPageIndex, value);
+
+            }
+        }
+
+        private Visibility _inputIndexBoxVisible = Visibility.Collapsed;
+        public Visibility InputIndexBoxVisible
+        {
+            get
+            {
+                return _inputIndexBoxVisible;
+            }
+            set
+            {
+                SetProperty(ref _inputIndexBoxVisible, value);
+            }
+        }
+
+        public DelegateCommand<object> ShowInputIndexBoxCommand { set; get; }
+        public DelegateCommand<object> GoToPageCommand { set; get; }
+
+        public BatesDocumentContentViewModel(IEventAggregator eventAggregator, IRegionManager regionManager)
+        {
+            this.regionManager = regionManager;
             this.eventAggregator = eventAggregator;
+            ShowInputIndexBoxCommand = new DelegateCommand<object>(ShowInputIndexBox);
+            GoToPageCommand = new DelegateCommand<object>(GoToPage);
             Unicode = App.mainWindowViewModel.SelectedItem.Unicode;
+            ViewerRegionName = RegionNames.BatesViewerRegionName;
+            eventAggregator.GetEvent<SetBatesEvent>().Subscribe(SetBates, e => e.Unicode == Unicode);
+            eventAggregator.GetEvent<ConfirmEditToolsBatesEvent>().Subscribe(ConfirmEditToolsBates, e => e == Unicode);
+            eventAggregator.GetEvent<DeleteBatesEvent>().Subscribe(DeleteBates, e => e.Unicode == Unicode);
+        }
+
+        public void ShowInputIndexBox(object obj)
+        {
+            if (obj != null)
+            {
+                InputIndexBoxVisible = Visibility.Visible;
+            }
+        }
+
+        public void GoToPage(object obj)
+        {
+
+            if (obj != null)
+            {
+                var args = obj as TextBox;
+                if (args.Text == null)
+                {
+                    return;
+                }
+                if (int.Parse(args.Text) > 0 && int.Parse(args.Text) <= PDFViewer.Document.PageCount && Regex.Match(args.Text, "^\\d+$").Success)
+                {
+                    PDFViewer.GoToPage(int.Parse(args.Text) - 1);
+                    InputIndexBoxVisible = Visibility.Collapsed;
+                }
+            }
+        }
+
+        public void ConfirmEditToolsBates(string unicode)
+        {
+            if (EnumDelete == EnumDelete.StatusDeleteAll)
+            {
+                PDFViewer.Document.GetBates().Clear();
+            }
+            else
+            {
+                if (batesInfo != null)
+                {
+                    CreateBates(viewContentViewModel.PDFViewer.Document);
+                }
+            }
+
+            viewContentViewModel.PDFViewer.UndoManager.CanSave = true;
+        }
+
+        public void DeleteBates(EnumDeleteUnicode enumDeleteunicode)
+        {
+            if (enumDeleteunicode.Status == EnumDelete.StatusDeleteAll)
+            {
+                EnumDelete enumDelete = enumDeleteunicode.Status;
+                EnumDelete = enumDelete;
+                PDFViewer.Document.GetBates().Clear();
+                PDFViewer.Document.ReleasePages();
+                PDFViewer.ReloadDocument();
+            }
+        }
+
+
+        public void SetBates(BatesInfoUnicode batesInfoUnicode)
+        {
+            EnumDelete = EnumDelete.StatusCreate;
+            BatesInfo batesInfo = batesInfoUnicode.Status;
+            this.batesInfo = batesInfo;
+            PDFViewer.InvalidChildVisual(false);
+        }
+
+        public void CreateBates(CPDFDocument document, bool IsNewDoc = false)
+        {
+            if (batesInfo != null)
+            {
+                if (bates != null) { bates.Release(); }
+                bates = document.GetBates();
+                for (int i = 0; i < 6; i++)
+                {
+                    bates.SetText(i, batesInfo.TextData[i].text);
+
+                    bates.SetFontName(i, batesInfo.TextData[i].fontName);
+                    bates.SetFontSize(i, batesInfo.TextData[i].fontSize);
+
+                    bates.SetTextColor(i, batesInfo.TextData[i].Color);
+                }
+                bates.SetPageOffset(batesInfo.StarPagetNumber + 1);
+                if (IsNewDoc) { bates.SetPages("0"); }
+                else
+                {
+                    bates.SetPages(batesInfo.PageRange);
+                }
+                bates.SetMargin(batesInfo.margin);
+                bates.Update();
+                
+            }
+        }
+
+
+        private void UndoManager_PropertyChanged(object sender, System.ComponentModel.PropertyChangedEventArgs e)
+        {
+
+        }
+
+        private void CurrentViewer_CustomDrawHandler(object sender, CustomDrawData e)
+        {
+            if (e.DrawPages.Count > 0 && e.DrawContext != null)
+            {
+                List<int> PageIndexLists = new List<int>();
+                foreach (DrawPageData drawPageData in e.DrawPages)
+                {
+                    if (batesInfo != null)
+                    {
+                        char[] enumerationSeparator = new char[] { ',' };
+                        char[] rangeSeparator = new char[] { '-' };
+                        if (CommonHelper.GetPagesInRange(ref PageIndexLists, batesInfo.PageRange, Document.PageCount, enumerationSeparator, rangeSeparator, true))
+                        { //TODO
+                            if (PageIndexLists.Contains(drawPageData.PageIndex - 1))
+                            {
+                                WriteableBitmap backgroundBitmap = GetBates(PDFViewer.Document, e.Zoom, drawPageData.PageIndex);
+                                e.DrawContext.DrawImage(backgroundBitmap, drawPageData.PageBound);
+                            }
+                        }
+                    }
+                }
+            }
+            CurrentPageIndex = PDFViewer.CurrentIndex + 1;
+        }
+
+        private WriteableBitmap GetBates(CPDFDocument oldDoc, double zoom, int pageIndex)
+        {
+            Size pageSize = oldDoc.GetPageSize(pageIndex);
+
+            CPDFDocument newDoc = CPDFDocument.CreateDocument();
+            newDoc.InsertPage(0, pageSize.Width, pageSize.Height, null);
+            CreateBates(newDoc, true);
+            CPDFPage newPage = newDoc.PageAtIndex(0);
+            double scale = 96.0 / 72.0;
+            zoom = zoom * 1.5;
+            Rect renderRect = new Rect(0, 0, (int)(pageSize.Width * scale), (int)(pageSize.Height * scale));
+            byte[] imageArray = new byte[(int)(renderRect.Width * renderRect.Height * 4)];
+            newPage.RenderPageBitmapWithMatrix(1 / (float)zoom, renderRect, 0x00FFFFFF, imageArray, 1, true);
+            WriteableBitmap WirteBitmap = new WriteableBitmap((int)renderRect.Width, (int)renderRect.Height, 96, 96, PixelFormats.Bgra32, null);
+            WirteBitmap.WritePixels(new Int32Rect(0, 0, (int)renderRect.Width, (int)renderRect.Height), imageArray, WirteBitmap.BackBufferStride, 0);
+            return WirteBitmap;
         }
 
         public bool IsNavigationTarget(NavigationContext navigationContext)
@@ -30,6 +241,23 @@ namespace PDF_Office.ViewModels.EditTools.Bates
 
         public void OnNavigatedTo(NavigationContext navigationContext)
         {
+            navigationContext.Parameters.TryGetValue<CPDFViewer>(ParameterNames.PDFViewer, out pdfViewer);
+            navigationContext.Parameters.TryGetValue<ViewContentViewModel>(ParameterNames.ViewContentViewModel, out viewContentViewModel);
+            if (pdfViewer != null)
+            {
+                PDFViewer = new CPDFViewer();
+                PDFViewer.InitDocument(pdfViewer.Document);
+                Document = PDFViewer.Document;
+                PDFViewer.CustomDrawHandler += CurrentViewer_CustomDrawHandler;
+                PDFViewer.UndoManager.PropertyChanged += UndoManager_PropertyChanged;
+                regionManager.AddToRegion(ViewerRegionName, PDFViewer);
+                PDFViewer.SetAnnotInteraction(!PDFViewer.GetAnnotInteraction());
+                PDFViewer.Load();
+                PDFViewer.ChangeViewMode(ViewMode.Single);
+                PDFViewer.SetMouseMode(MouseModes.Default);
+                PageRangeNumber = PDFViewer.Document.PageCount;
+                PDFViewer.Zoom(0.5);
+            }
         }
     }
 }

+ 194 - 2
PDF Office/ViewModels/EditTools/Bates/BatesTemplateListContentViewModel.cs

@@ -1,19 +1,59 @@
-using PDF_Office.EventAggregators;
+using ComPDFKitViewer.PdfViewer;
+using PDF_Office.EventAggregators;
+using PDF_Office.Helper;
+using PDF_Office.Model;
+using PDF_Office.Model.EditTools.Bates;
+using PDF_Office.Model.EditTools.Bates;
+using PDF_Office.Model.EditTools.HeaderFooter;
+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.EditTools.Bates
 {
     public class BatesTemplateListContentViewModel : BindableBase, INavigationAware
     {
 
-        public DelegateCommand EnterCreateCommand { get; set; }
+        private CPDFViewer PDFViewer;
         public IEventAggregator eventAggregator;
+        public BatesInfo BatesInfo = new BatesInfo();
+        public BatesHeaderFooterItem BatesItem = new BatesHeaderFooterItem();
+        public int TemplateIndex = 0;
+
+        private ObservableCollection<BatesHeaderFooterItem> batesModCollection = new ObservableCollection<BatesHeaderFooterItem>();
+        public ObservableCollection<BatesHeaderFooterItem> BatesModCollection
+        {
+            get { return batesModCollection; }
+            set
+            {
+                batesModCollection = 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 DelegateCommand EnterCreateCommand { get; set; }
+
         public string Unicode = null;
 
         public BatesTemplateListContentViewModel(IEventAggregator eventAggregator)
@@ -21,6 +61,20 @@ namespace PDF_Office.ViewModels.EditTools.Bates
             this.eventAggregator = eventAggregator;
             Unicode = App.mainWindowViewModel.SelectedItem.Unicode;
             EnterCreateCommand = new DelegateCommand(EnterCreate);
+            AddTemplateCommand = new DelegateCommand(AddTemplate);
+            EditTemplateItemCommand = new DelegateCommand<object>(RequestEditTemplateItem);
+            DeleteTemplateItemCommand = new DelegateCommand<object>(DeleteTemplateItem);
+            DeleteAllTemplateItemCommand = new DelegateCommand(DeleteAllTemplateItem);
+            SelectTemplateItemCommand = new DelegateCommand<object>(SelectTemplateItem);
+        }
+
+        private void InitBackgroundTemplateList()
+        {
+            if (Settings.Default.BatesTemplateList == null)
+            {
+                Settings.Default.BatesTemplateList = new BatesTemplateList();
+            }
+            GetBatesSource();
         }
 
         public void EnterCreate()
@@ -28,6 +82,142 @@ namespace PDF_Office.ViewModels.EditTools.Bates
             this.eventAggregator.GetEvent<EnterTemplateListOrCreateEvent>().Publish(new EnumTemplateListOrCreateUnicode { Unicode = Unicode, Status = EnumTemplateListOrCreate.StatusCreate });
         }
 
+        public void AddTemplate()
+        {
+            this.eventAggregator.GetEvent<EnterTemplateListOrCreateEvent>().Publish(new EnumTemplateListOrCreateUnicode
+            {
+                Unicode = Unicode,
+                Status = EnumTemplateListOrCreate.StatusCreate
+            });
+        }
+
+        public void SaveEditedBatesTemplateItem(BatesHeaderFooterItemUnicode BatesItemunicode)
+        {
+            BatesHeaderFooterItem batesItem = BatesItemunicode.Status;
+
+            Settings.Default.BatesTemplateList[TemplateIndex] = batesItem;
+            Settings.Default.Save();
+
+            GetBatesSource();
+        }
+
+        public void RequestEditTemplateItem(object e)
+        {
+            var control = e as Control;
+            if (control == null)
+            {
+                return;
+            }
+            var template = control.DataContext as BatesHeaderFooterItem;
+            if (template == null)
+            {
+                return;
+            }
+            TemplateIndex = Settings.Default.BatesTemplateList.IndexOf(template);
+            template.listIndex = TemplateIndex;
+            ConvertItemToInfo(template, ref BatesInfo);
+            this.eventAggregator.GetEvent<EditBatesHeaderFooterTemplateItemEvent>().Publish(new BatesHeaderFooterItemUnicode
+            {
+                Unicode = Unicode,
+                Type = "BatesType",
+                Status = template
+            });
+        }
+
+        public void DeleteTemplateItem(object e)
+        {
+            var btn = e as System.Windows.Controls.Button;
+            if (btn == null)
+            {
+                return;
+            }
+            BatesItem = btn.DataContext as BatesHeaderFooterItem;
+            if (BatesItem == null)
+            {
+                return;
+            }
+
+            Settings.Default.BatesTemplateList.Remove(BatesItem);
+            Settings.Default.Save();
+            BatesModCollection.Remove(BatesItem);
+            GetBatesSource();
+        }
+
+        public void DeleteAllTemplateItem()
+        {
+            while (Settings.Default.BatesTemplateList.Count != 0)
+            {
+                int temp = 0;
+                var template = Settings.Default.BatesTemplateList[temp];
+
+                Settings.Default.BatesTemplateList.Remove(template);
+                Settings.Default.Save();
+
+                BatesModCollection.Remove(template);
+
+            }
+            GetBatesSource();
+        }
+
+        public void SelectTemplateItem(object e)
+        {
+            var listBox = e as ListBox;
+            BatesHeaderFooterItem BatesItem = listBox.SelectedItem as BatesHeaderFooterItem;
+            SendTemplateItemToDocument(BatesItem);
+        }
+
+        public void SendTemplateItemToDocument(BatesHeaderFooterItem template)
+        {
+            if (template != null)
+            {
+                ConvertItemToInfo(template, ref BatesInfo);
+                eventAggregator.GetEvent<SetBatesEvent>().Publish(new BatesInfoUnicode
+                {
+                    Unicode = Unicode,
+                    Status = BatesInfo
+                });
+            }
+
+        }
+
+        private void GetBatesSource()
+        {
+            List<BatesHeaderFooterItem> batesModColorTemplateList = new List<BatesHeaderFooterItem>();
+            for (int temp = 0; temp < Settings.Default.BatesTemplateList.Count; temp++)
+            {
+                Settings.Default.BatesTemplateList[temp].ItemName = (temp + 1).ToString();
+                batesModColorTemplateList.Add(Settings.Default.BatesTemplateList[temp]);
+
+            }
+            BatesModCollection = new ObservableCollection<BatesHeaderFooterItem>(batesModColorTemplateList);
+            CheckTemplateListIsEmpty(batesModColorTemplateList);
+        }
+
+        public void ConvertItemToInfo(BatesHeaderFooterItem batesItem, ref BatesInfo batesInfo)
+        {
+            batesInfo.TextData = batesItem.TextData;
+            batesInfo.ItemName = batesItem.ItemName;
+            batesInfo.DigitNumber = batesItem.DigitNumber;
+            batesInfo.Prefix=batesItem.Prefix;
+            batesInfo.Suffix=batesItem.Suffix;
+            batesInfo.StarPagetNumber = batesItem.StarPagetNumber;
+            batesInfo.margin = batesItem.margin;
+            batesInfo.PageRangeIndex = batesItem.PageRangeIndex;
+            EditToolsHelper.GetPageRange(batesInfo.PageRangeIndex, PDFViewer.Document, ref batesInfo.PageRange, batesItem.PageRange);
+
+        }
+        private void CheckTemplateListIsEmpty(List<BatesHeaderFooterItem> batesTemplateList)
+        {
+            if (batesTemplateList.Count() == 0)
+            {
+                CreateTemplateVisible = Visibility.Visible;
+            }
+            else
+            {
+                CreateTemplateVisible = Visibility.Collapsed;
+            }
+        }
+
         public bool IsNavigationTarget(NavigationContext navigationContext)
         {
             return true;
@@ -39,6 +229,8 @@ namespace PDF_Office.ViewModels.EditTools.Bates
 
         public void OnNavigatedTo(NavigationContext navigationContext)
         {
+            navigationContext.Parameters.TryGetValue<CPDFViewer>(ParameterNames.PDFViewer, out PDFViewer);
+            InitBackgroundTemplateList();
         }
     }
 }

+ 27 - 3
PDF Office/ViewModels/EditTools/HeaderFooter/HeaderFooterContentViewModel.cs

@@ -10,6 +10,7 @@ using System.Linq;
 using ComPDFKitViewer.PdfViewer;
 using PDF_Office.Model;
 using PDFSettings;
+using PDF_Office.CustomControl;
 
 namespace PDF_Office.ViewModels.EditTools.HeaderFooter
 {
@@ -71,6 +72,7 @@ namespace PDF_Office.ViewModels.EditTools.HeaderFooter
 
         public DelegateCommand CloseEditToolCommand { get; set; }
         public DelegateCommand ConfirmEditToolCommand { get; set; }
+        public DelegateCommand DeleteHeaderFooterCommand { get; set; }
 
         public string Unicode = null;
 
@@ -84,6 +86,7 @@ namespace PDF_Office.ViewModels.EditTools.HeaderFooter
             Unicode = App.mainWindowViewModel.SelectedItem.Unicode;
             CloseEditToolCommand = new DelegateCommand(CloseEditTool);
             ConfirmEditToolCommand = new DelegateCommand(ConfirmEditTool);
+            DeleteHeaderFooterCommand = new DelegateCommand(DeleteHeaderFooter);
             eventAggregator.GetEvent<EditBatesHeaderFooterTemplateItemEvent>().Subscribe(EditHeaderFooterTemplateItem, e => e.Unicode == Unicode&&e.Type== HeaderFooterType);
             eventAggregator.GetEvent<EnterTemplateListOrCreateEvent>().Subscribe(EnterTemplateListOrCreate, e => e.Unicode == Unicode);
         }
@@ -94,16 +97,37 @@ namespace PDF_Office.ViewModels.EditTools.HeaderFooter
         }
         public void ConfirmEditTool()
         {
+            this.eventAggregator.GetEvent<ConfirmEditToolsHeaderFooterEvent>().Publish(Unicode);
+            this.eventAggregator.GetEvent<CloseEditToolEvent>().Publish(new EnumCloseModeUnicode { Unicode = Unicode, Status = EnumCloseMode.StatusConfirm });
 
-            this.eventAggregator.GetEvent<CloseEditToolEvent>().Publish(new EnumCloseModeUnicode { Unicode = Unicode, Status = EnumCloseMode.StatusCancel });
+        }
 
+        private void DeleteHeaderFooter()
+        {
+            AlertsMessage alertsMessage = new AlertsMessage();
+            alertsMessage.ShowDialog("确定要删除背景吗?", "", "取消", "删除");
+            if (alertsMessage.result == ContentResult.Ok)
+            {
+                this.eventAggregator.GetEvent<DeleteHeaderFooterEvent>().Publish(new EnumDeleteUnicode
+                {
+                    Unicode = Unicode,
+                    Status = EnumDelete.StatusDeleteAll
+                });
+            }
+            else
+            {
+                this.eventAggregator.GetEvent<DeleteHeaderFooterEvent>().Publish(new EnumDeleteUnicode
+                {
+                    Unicode = Unicode,
+                    Status = EnumDelete.StatusCreate
+                });
+            }
         }
 
         public void EnterSelectedContent(string SelectedContentName)
         {
             NavigationParameters param = new NavigationParameters();
             param.Add(ParameterNames.PDFViewer, PDFViewer);
-           
             headerFooterRegion.RequestNavigate(HeaderFooterSettingsRegionName, SelectedContentName, param);
             HeaderFooterSettingsVisible = Visibility.Visible;
         }
@@ -134,7 +158,7 @@ namespace PDF_Office.ViewModels.EditTools.HeaderFooter
             BatesHeaderFooterItem headerfooterItem = headerfooterItemunicode.Status;
             NavigationParameters param = new NavigationParameters();
             param.Add(ParameterNames.PDFViewer, PDFViewer);
-            param.Add("BatesItem", headerfooterItem);
+            param.Add("HeaderFooterItem", headerfooterItem);
             headerFooterRegion.RequestNavigate(HeaderFooterSettingsRegionName, CreateName, param);
             HeaderFooterSettingsVisible = Visibility.Visible;
         }

+ 756 - 1
PDF Office/ViewModels/EditTools/HeaderFooter/HeaderFooterCreateContentViewModel.cs

@@ -1,22 +1,766 @@
-using Prism.Commands;
+using ComPDFKit.PDFWatermark;
+using ComPDFKitViewer.PdfViewer;
+using Microsoft.Office.Interop.Word;
+using PDF_Office.EventAggregators;
+using PDF_Office.Helper;
+using PDF_Office.Model;
+using PDF_Office.Model.EditTools.Background;
+using PDF_Office.Model.EditTools.Bates;
+using PDF_Office.Model.EditTools.HeaderFooter;
+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.Diagnostics;
+using System.IO;
 using System.Linq;
+using System.Windows;
+using System.Windows.Controls;
+using System.Windows.Media;
 
 namespace PDF_Office.ViewModels.EditTools.HeaderFooter
 {
     public class HeaderFooterCreateContentViewModel : BindableBase, INavigationAware
     {
+
+        private CPDFViewer PDFViewer;
+
+        public HeaderFooterInfo HeaderFooterInfo = new HeaderFooterInfo();
+
+        public BatesHeaderFooterItem TemplateHeaderFooterItem;
+
+        public enum EnumCreateOrEdit
+        {
+            None,
+            StatusCreate,
+            StatusEdit
+        }
+
+        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 int _fontNameSelectedIndex = 0;
+        public int FontNameSelectedIndex
+        {
+            get { return _fontNameSelectedIndex; }
+            set
+            {
+                SetProperty(ref _fontNameSelectedIndex, value);
+                SetFontName(FontNameSelectedIndex);
+                eventAggregator.GetEvent<SetHeaderFooterEvent>().Publish(new HeaderFooterInfoUnicode
+                {
+                    Unicode = Unicode,
+                    Status = HeaderFooterInfo
+                });
+            }
+        }
+
+        private List<string> _fontSizeList = new List<string>();
+        public List<string> FontSizeList
+        {
+            get { return _fontSizeList; }
+            set
+            {
+                SetProperty(ref _fontSizeList, value);
+            }
+        }
+
+        private void InitFontSizeList()
+        {
+            FontSizeList.Clear();
+            for (int temp = 10; temp <= 15; temp += 1)
+            {
+                FontSizeList.Add(temp.ToString() + "pt");
+            }
+        }
+
+        private int _fontSizeSelectedIndex = 0;
+        public int FontSizeSelectedIndex
+        {
+            get { return _fontSizeSelectedIndex; }
+            set
+            {
+                SetProperty(ref _fontSizeSelectedIndex, value);
+                SetFontSize(FontSizeSelectedIndex);
+                eventAggregator.GetEvent<SetHeaderFooterEvent>().Publish(new HeaderFooterInfoUnicode
+                {
+                    Unicode = Unicode,
+                    Status = HeaderFooterInfo
+                });
+            }
+        }
+
+        private List<string> _starPagetNumberList = new List<string>();
+        public List<string> StarPagetNumberList
+        {
+            get { return _starPagetNumberList; }
+            set
+            {
+                SetProperty(ref _starPagetNumberList, value);
+            }
+        }
+
+        private void InitStarPagetNumberList()
+        {
+            StarPagetNumberList.Clear();
+            for (int temp = 10; temp <= 15; temp += 1)
+            {
+                StarPagetNumberList.Add(temp.ToString());
+            }
+        }
+
+        private int _starPagetNumberIndex = 0;
+        public int StarPagetNumberIndex
+        {
+            get { return _starPagetNumberIndex; }
+            set
+            {
+                SetProperty(ref _starPagetNumberIndex, value);
+                SetStarPagetNumber(StarPagetNumberIndex);
+                eventAggregator.GetEvent<SetHeaderFooterEvent>().Publish(new HeaderFooterInfoUnicode
+                {
+                    Unicode = Unicode,
+                    Status = HeaderFooterInfo
+                });
+            }
+        }
+
+        private List<string> _pageNumberFormatList = new List<string>();
+        public List<string> PageNumberFormatList
+        {
+            get { return _pageNumberFormatList; }
+            set
+            {
+                SetProperty(ref _pageNumberFormatList, value);
+            }
+        }
+
+        private void InitPageNumberFormatList()
+        {
+            PageNumberFormatList.Clear();
+            PageNumberFormatList.Add("1");
+            PageNumberFormatList.Add("1 of n");
+            PageNumberFormatList.Add("1/n");
+            PageNumberFormatList.Add("Page 1");
+            PageNumberFormatList.Add("Page 1 of n");
+        }
+
+        private int _pageNumberFormatIndex = 0;
+        public int PageNumberFormatIndex
+        {
+            get { return _pageNumberFormatIndex; }
+            set
+            {
+                SetProperty(ref _pageNumberFormatIndex, value);
+                SetPageNumberFormat(PageNumberFormatIndex);
+            }
+        }
+
+        private List<string> _dateTimeFormatList = new List<string>();
+        public List<string> DateTimeFormatList
+        {
+            get { return _dateTimeFormatList; }
+            set
+            {
+                SetProperty(ref _dateTimeFormatList, value);
+            }
+        }
+
+        private void InitDateTimeFormatList()
+        {
+            DateTimeFormatList.Clear();
+            DateTimeFormatList.Add("m/d");
+            DateTimeFormatList.Add("m/d/yy");
+            DateTimeFormatList.Add("m/d/yyyy");
+            DateTimeFormatList.Add("mm/dd/yy");
+            DateTimeFormatList.Add("mm/dd/yyyy");
+            DateTimeFormatList.Add("d/m/yy");
+            DateTimeFormatList.Add("d/m/yyyy");
+            DateTimeFormatList.Add("dd/mm/yy");
+            DateTimeFormatList.Add("dd/mm/yyyy");
+            DateTimeFormatList.Add("mm/yy");
+            DateTimeFormatList.Add("mm/yyyy");
+            DateTimeFormatList.Add("m.d.yy");
+            DateTimeFormatList.Add("m.d.yyyy");
+            DateTimeFormatList.Add("mm.dd.yy");
+            DateTimeFormatList.Add("mm.dd.yyyy");
+            DateTimeFormatList.Add("mm.yy");
+            DateTimeFormatList.Add("mm.yyyy");
+            DateTimeFormatList.Add("d.m.yy");
+            DateTimeFormatList.Add("dd.mm.yy");
+            DateTimeFormatList.Add("dd.mm.yyyy");
+            DateTimeFormatList.Add("yy-mm-dd");
+            DateTimeFormatList.Add("yyyy-mm-dd");
+        }
+
+        private int _dateTimeFormatIndex = 0;
+        public int DateTimeFormatIndex
+        {
+            get { return _dateTimeFormatIndex; }
+            set
+            {
+                SetProperty(ref _dateTimeFormatIndex, value);
+                SetDateTimeFormat(DateTimeFormatIndex);
+            }
+        }
+
+        public string _pageRangeText = "0";
+        public string PageRangeText
+        {
+            get { return _pageRangeText; }
+            set
+            {
+                _pageRangeText = value;
+                EditToolsHelper.GetPageRange(PageRangeSelectIndex, PDFViewer.Document, ref HeaderFooterInfo.PageRange, PageRangeText);
+                eventAggregator.GetEvent<SetHeaderFooterEvent>().Publish(new HeaderFooterInfoUnicode
+                {
+                    Unicode = Unicode,
+                    Status = HeaderFooterInfo
+                });
+            }
+        }
+
+        private int _pageRangeSelectIndex = 0;
+        public int PageRangeSelectIndex
+        {
+            get { return _pageRangeSelectIndex; }
+            set
+            {
+                SetProperty(ref _pageRangeSelectIndex, value);
+                HeaderFooterInfo.PageRangeIndex = PageRangeSelectIndex;
+                EditToolsHelper.GetPageRange(PageRangeSelectIndex, PDFViewer.Document, ref HeaderFooterInfo.PageRange, PageRangeText);
+                eventAggregator.GetEvent<SetHeaderFooterEvent>().Publish(new HeaderFooterInfoUnicode
+                {
+                    Unicode = Unicode,
+                    Status = HeaderFooterInfo
+                });
+            }
+        }
+
+        private SolidColorBrush _solidColorBrush = new SolidColorBrush(Color.FromArgb(0xFF, 0xFF, 0x00, 0x00));
+        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);
+                SolidColorBrush = new SolidColorBrush(StringColor);
+                for (int i = 0; i <= 5; i++)
+                {
+                    HeaderFooterInfo.TextData[i].Color = EditToolsHelper.ConvertColor(value);
+                }
+                eventAggregator.GetEvent<SetHeaderFooterEvent>().Publish(new HeaderFooterInfoUnicode
+                {
+                    Unicode = Unicode,
+                    Status = HeaderFooterInfo
+                });
+            }
+        }
+
+        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 _createBaseVisible;
+        public Visibility CreateBaseVisible
+        {
+            get => _createBaseVisible;
+            set => SetProperty(ref _createBaseVisible, value);
+        }
+
+        private Visibility _editBaseVisible;
+        public Visibility EditBaseVisible
+        {
+            get => _editBaseVisible;
+            set => SetProperty(ref _editBaseVisible, value);
+        }
+
+        private string _marginTopValue = "3";
+        public string MarginTopValue
+        {
+            get { return _marginTopValue; }
+            set
+            {
+                SetProperty(ref _marginTopValue, value);
+                bool ValueEQ = true;
+                if (HeaderFooterInfo.margin[1] == float.Parse(MarginTopValue))
+                {
+                    ValueEQ = false;
+                }
+                HeaderFooterInfo.margin[1] = float.Parse(MarginTopValue);
+                if (ValueEQ)
+                {
+                    eventAggregator.GetEvent<SetHeaderFooterEvent>().Publish(new HeaderFooterInfoUnicode
+                    {
+                        Unicode = Unicode,
+                        Status = HeaderFooterInfo
+                    });
+                }
+            }
+        }
+
+        private string _marginDownValue = "3";
+        public string MarginDownValue
+        {
+            get { return _marginDownValue; }
+            set
+            {
+                SetProperty(ref _marginDownValue, value);
+                bool ValueEQ = true;
+                if (HeaderFooterInfo.margin[3] == float.Parse(MarginTopValue))
+                {
+                    ValueEQ = false;
+                }
+                HeaderFooterInfo.margin[3] = float.Parse(MarginDownValue);
+                if (ValueEQ)
+                {
+                    eventAggregator.GetEvent<SetHeaderFooterEvent>().Publish(new HeaderFooterInfoUnicode
+                    {
+                        Unicode = Unicode,
+                        Status = HeaderFooterInfo
+                    });
+                }
+            }
+        }
+
+        private string _marginLeftValue = "3";
+        public string MarginLeftValue
+        {
+            get { return _marginLeftValue; }
+            set
+            {
+                SetProperty(ref _marginLeftValue, value);
+                bool ValueEQ = true;
+                if (HeaderFooterInfo.margin[0] == float.Parse(MarginTopValue))
+                {
+                    ValueEQ = false;
+                }
+                HeaderFooterInfo.margin[0] = float.Parse(MarginLeftValue);
+                if (ValueEQ)
+                {
+                    eventAggregator.GetEvent<SetHeaderFooterEvent>().Publish(new HeaderFooterInfoUnicode
+                    {
+                        Unicode = Unicode,
+                        Status = HeaderFooterInfo
+                    });
+                }
+            }
+        }
+
+        private string _marginRightValue = "3";
+        public string MarginRightValue
+        {
+            get { return _marginRightValue; }
+            set
+            {
+                SetProperty(ref _marginRightValue, value);
+                bool ValueEQ = true;
+                if (HeaderFooterInfo.margin[2] == float.Parse(MarginTopValue))
+                {
+                    ValueEQ = false;
+                }
+                HeaderFooterInfo.margin[2] = float.Parse(MarginRightValue);
+                eventAggregator.GetEvent<SetHeaderFooterEvent>().Publish(new HeaderFooterInfoUnicode
+                {
+                    Unicode = Unicode,
+                    Status = HeaderFooterInfo
+                });
+            }
+        }
+
+        private string _textValue = "";
+        public string TextValue
+        {
+            get { return _textValue; }
+            set
+            {
+                SetProperty(ref _textValue, value);
+
+            }
+        }
+
+        public int GetLocationIndex = 0;
+
+        private Dictionary<string, string> _getTextValueFromNumber = new Dictionary<string, string>();
+        public Dictionary<string, string> GetTextValueFromNumber
+        {
+            get { return _getTextValueFromNumber; }
+            set
+            {
+                _getTextValueFromNumber = value;
+            }
+        }
+
         public IEventAggregator eventAggregator;
+
+        public DelegateCommand<object> ChangeLocationCommand { get; set; }
+        public DelegateCommand EnterTemplateListCommand { get; set; }
+        public DelegateCommand SaveToTemplateListCommand { get; set; }
+        public DelegateCommand SaveToCurrentTemplateListCommand { get; set; }
+        public DelegateCommand<object> SelectedColorChangedCommand { get; set; }
+        public DelegateCommand<object> TextValueChangedCommand { get; set; }
+        public DelegateCommand ADDDateCommand { get; set; }
+        public DelegateCommand ADDPagesCommand { get; set; }
         public string Unicode = null;
         public HeaderFooterCreateContentViewModel(IEventAggregator eventAggregator)
         {
             this.eventAggregator = eventAggregator;
             Unicode = App.mainWindowViewModel.SelectedItem.Unicode;
+            for (int i = 0; i <= 5; i++)
+            {
+                HeaderFooterInfo.TextData[i].Color = EditToolsHelper.ConvertColor(Color.FromArgb(0xFF, 0xFF, 0x00, 0x00));
+            }
+            InitList();
+            InitHeaderFooterInfo();
+            ChangeLocationCommand = new DelegateCommand<object>(ChangeLocation);
+            SelectedColorChangedCommand = new DelegateCommand<object>(ChangedColor);
+            EnterTemplateListCommand = new DelegateCommand(EnterTemplateList);
+            SaveToTemplateListCommand = new DelegateCommand(SaveToTemplateList);
+            SaveToCurrentTemplateListCommand = new DelegateCommand(SaveToCurrentTemplateList);
+            TextValueChangedCommand = new DelegateCommand<object>(TextValueChanged);
+            ADDDateCommand = new DelegateCommand(ADDDate);
+            ADDPagesCommand = new DelegateCommand(ADDPages);
+        }
+
+        private void InitList()
+        {
+
+            InitFontNameList();
+            InitFontSizeList();
+            InitStarPagetNumberList();
+            InitDateTimeFormatList();
+            InitPageNumberFormatList();
+            InitLocationButtonMatrix();
+
+        }
+
+        private void InitLocationButtonMatrix()
+        {
+            GetTextValueFromNumber.Clear();
+            for (var temp = 0; temp <= 5; temp++)
+            {
+                GetTextValueFromNumber.Add(temp.ToString(), "");
+            }
+        }
+
+        private void InitHeaderFooterInfo()
+        {
+            for (int i = 0; i <= 5; i++)
+            {
+                HeaderFooterInfo.TextData[i].text = GetTextValueFromNumber[i.ToString()];
+            }
+            HeaderFooterInfo.margin[0] = float.Parse(MarginTopValue);
+            HeaderFooterInfo.margin[1] = float.Parse(MarginRightValue);
+            HeaderFooterInfo.margin[2] = float.Parse(MarginDownValue);
+            HeaderFooterInfo.margin[3] = float.Parse(MarginLeftValue);
+            SetFontName(FontNameSelectedIndex);
+            SetFontSize(FontSizeSelectedIndex);
+            SetDateTimeFormat(DateTimeFormatIndex);
+            SetPageNumberFormat(PageNumberFormatIndex);
+            SetStarPagetNumber(StarPagetNumberIndex);
+            StringColor = Color.FromArgb(0xFF, 0xFF, 0x00, 0x00);
+        }
+
+        private void SetFontName(int Index)
+        {
+            for (int i = 0; i <= 5; i++) { HeaderFooterInfo.TextData[i].fontName = FontNameList[Index]; }
+        }
+
+        private void SetFontSize(int Index)
+        {
+            for (int i = 0; i <= 5; i++) { HeaderFooterInfo.TextData[i].fontSize = (Index + 7) * 1.33f; }
+        }
+
+        private void SetDateTimeFormat(int Index)
+        {
+            HeaderFooterInfo.DateTimeFormat = DateTimeFormatList[Index];
+        }
+
+        private void SetPageNumberFormat(int Index)
+        {
+            HeaderFooterInfo.PageNumberFormat = PageNumberFormatList[Index];
+        }
+
+        private void SetStarPagetNumber(int Index)
+        {
+            HeaderFooterInfo.StarPagetNumber = Index;
+        }
+
+        public void ChangeLocation(object e)
+        {
+            string args = e as string;
+            if (args != null)
+            {
+                GetLocationIndex = int.Parse(args);
+                TextValue = GetTextValueFromNumber[args];
+
+            }
+        }
+        private void ChangedColor(object obj)
+        {
+            if (obj != null)
+            {
+                var colorValue = (Color)obj;
+                if (colorValue != null)
+                {
+
+                    StringColor = colorValue;
+                }
+            }
+        }
+
+        public void EnterTemplateList()
+        {
+            this.eventAggregator.GetEvent<EnterTemplateListOrCreateEvent>().Publish(new EnumTemplateListOrCreateUnicode { Unicode = Unicode, Status = EnumTemplateListOrCreate.StatusTemplate });
+        }
+
+        public void SaveToTemplateList()
+        {
+            SaveCurrentTemplate();
+            this.eventAggregator.GetEvent<EnterTemplateListOrCreateEvent>().Publish(new EnumTemplateListOrCreateUnicode { Unicode = Unicode, Status = EnumTemplateListOrCreate.StatusTemplate });
+        }
+
+        public void SaveToCurrentTemplateList()
+        {
+            ConfirmEditBackgroundTemplateItem();
+            this.eventAggregator.GetEvent<EnterTemplateListOrCreateEvent>().Publish(new EnumTemplateListOrCreateUnicode { Unicode = Unicode, Status = EnumTemplateListOrCreate.StatusTemplate });
+        }
+
+        private void TextValueChanged(object obj)
+        {
+            if (obj != null)
+            {
+                var textValue = obj as System.Windows.Controls.TextBox;
+                if (textValue != null)
+                {
+                    bool TextEQ = true;
+                    if (GetTextValueFromNumber[GetLocationIndex.ToString()] == textValue.Text)
+                    {
+                        TextEQ = false;
+                    }
+                    GetTextValueFromNumber[GetLocationIndex.ToString()] = textValue.Text;
+                    HeaderFooterInfo.TextData[GetLocationIndex].text = GetTextValueFromNumber[GetLocationIndex.ToString()];
+                    if (TextEQ)
+                    {
+                        eventAggregator.GetEvent<SetHeaderFooterEvent>().Publish(new HeaderFooterInfoUnicode
+                        {
+                            Unicode = Unicode,
+                            Status = HeaderFooterInfo
+                        });
+                    }
+
+                }
+            }
+
+        }
+
+        public void ADDDate()
+        {
+            GetTextValueFromNumber[GetLocationIndex.ToString()] = GetTextValueFromNumber[GetLocationIndex.ToString()] + "<<" + DateTimeFormatList[DateTimeFormatIndex] + ">>";
+            TextValue = GetTextValueFromNumber[GetLocationIndex.ToString()];
+            HeaderFooterInfo.TextData[GetLocationIndex].text = GetTextValueFromNumber[GetLocationIndex.ToString()];
+            eventAggregator.GetEvent<SetHeaderFooterEvent>().Publish(new HeaderFooterInfoUnicode
+            {
+                Unicode = Unicode,
+                Status = HeaderFooterInfo
+            });
         }
+        public void ADDPages()
+        {
+            GetTextValueFromNumber[GetLocationIndex.ToString()] = GetTextValueFromNumber[GetLocationIndex.ToString()] + "<<" + PageNumberFormatList[PageNumberFormatIndex] + ">>";
+            TextValue = GetTextValueFromNumber[GetLocationIndex.ToString()];
+            HeaderFooterInfo.TextData[GetLocationIndex].text = GetTextValueFromNumber[GetLocationIndex.ToString()];
+            eventAggregator.GetEvent<SetHeaderFooterEvent>().Publish(new HeaderFooterInfoUnicode
+            {
+                Unicode = Unicode,
+                Status = HeaderFooterInfo
+            });
+        }
+
+        public void ConvertInfoToItem(ref BatesHeaderFooterItem headerFooterItem, HeaderFooterInfo headerFooterInfo)
+        {
+            headerFooterItem.TextData = headerFooterInfo.TextData;
+            headerFooterItem.ItemName = headerFooterInfo.ItemName;
+            headerFooterItem.DateTimeFormat = headerFooterInfo.DateTimeFormat;
+            headerFooterItem.StarPagetNumber = headerFooterInfo.StarPagetNumber;
+            headerFooterItem.PageNumberFormat = headerFooterInfo.PageNumberFormat;
+            headerFooterItem.margin = headerFooterInfo.margin;
+            headerFooterItem.PageRange = headerFooterInfo.PageRange;
+            headerFooterItem.PageRangeIndex = headerFooterInfo.PageRangeIndex;
+        }
+
+        public void ConvertItemToInfo(BatesHeaderFooterItem headerFooterItem, ref HeaderFooterInfo headerFooterInfo)
+        {
+            headerFooterInfo.TextData = headerFooterItem.TextData;
+            headerFooterInfo.ItemName = headerFooterItem.ItemName;
+            headerFooterInfo.DateTimeFormat = headerFooterItem.DateTimeFormat;
+            headerFooterInfo.StarPagetNumber = headerFooterItem.StarPagetNumber;
+            headerFooterInfo.PageNumberFormat = headerFooterItem.PageNumberFormat;
+            headerFooterInfo.margin = headerFooterItem.margin;
+            headerFooterInfo.PageRangeIndex = headerFooterItem.PageRangeIndex;
+            EditToolsHelper.GetPageRange(headerFooterInfo.PageRangeIndex, PDFViewer.Document, ref headerFooterInfo.PageRange, headerFooterItem.PageRange);
+        }
+
+        public void SaveCurrentTemplate()
+        {
+            var headerFooterItem = new BatesHeaderFooterItem();
+
+            ConvertInfoToItem(ref headerFooterItem, HeaderFooterInfo);
+            headerFooterItem.ItemName += Settings.Default.HeaderFooterTemplateList.Count().ToString();
+            try
+            {
+                //创建缓存文件夹
+                string folderPath = Path.Combine(App.CurrentPath, "HeaderFooter");
+                //有可能因为其他原因存在同名文件,导致创建文件夹失败,需要先删除同名文件
+                //保险措施(猜测)
+                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);
+                Settings.Default.HeaderFooterTemplateList.Add(headerFooterItem);
+                Settings.Default.Save();
+            }
+            catch
+            {
+
+            }
+
+            this.eventAggregator.GetEvent<EnterTemplateListOrCreateEvent>().Publish(new EnumTemplateListOrCreateUnicode
+            {
+                Unicode = Unicode,
+                Status = EnumTemplateListOrCreate.StatusTemplate
+            });
+        }
+
+        public void ConfirmEditBackgroundTemplateItem()
+        {
+
+            var headerFooterItem = new BatesHeaderFooterItem();
+            ConvertInfoToItem(ref headerFooterItem, HeaderFooterInfo);
+            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();
+                }
+                Settings.Default.HeaderFooterTemplateList[TemplateHeaderFooterItem.listIndex] = headerFooterItem;
+                Settings.Default.Save();
+            }
+            catch
+            {
+
+            }
+            this.eventAggregator.GetEvent<EnterTemplateListOrCreateEvent>().Publish(new EnumTemplateListOrCreateUnicode
+            {
+                Unicode = Unicode,
+                Status = EnumTemplateListOrCreate.StatusTemplate
+            });
+
+        }
+
+        public void InitComponentBySelectedInfo()
+        {
+            ConvertItemToInfo(TemplateHeaderFooterItem, ref HeaderFooterInfo);
+            for (int i = 0; i <= 5; i++)
+            {
+                GetTextValueFromNumber[i.ToString()] = HeaderFooterInfo.TextData[i].text;
+            }
+            MarginTopValue = HeaderFooterInfo.margin[0].ToString();
+            MarginRightValue = HeaderFooterInfo.margin[1].ToString();
+            MarginDownValue = HeaderFooterInfo.margin[2].ToString();
+            MarginLeftValue = HeaderFooterInfo.margin[3].ToString();
+            DateTimeFormatIndex = DateTimeFormatList.IndexOf(HeaderFooterInfo.DateTimeFormat);
+            PageNumberFormatIndex = PageNumberFormatList.IndexOf(HeaderFooterInfo.PageNumberFormat);
+            FontNameSelectedIndex = FontNameList.IndexOf(HeaderFooterInfo.TextData[0].fontName);
+            FontSizeSelectedIndex = FontSizeList.IndexOf(HeaderFooterInfo.TextData[0].fontSize.ToString());
+            StarPagetNumberIndex = StarPagetNumberList.IndexOf(HeaderFooterInfo.StarPagetNumber.ToString());
+            StringColor = EditToolsHelper.ConvertColor(HeaderFooterInfo.TextData[0].Color);
+            SolidColorBrush = new SolidColorBrush(StringColor);
+            PageRangeSelectIndex = HeaderFooterInfo.PageRangeIndex;
+
+        }
+
         public bool IsNavigationTarget(NavigationContext navigationContext)
         {
             return true;
@@ -28,6 +772,17 @@ namespace PDF_Office.ViewModels.EditTools.HeaderFooter
 
         public void OnNavigatedTo(NavigationContext navigationContext)
         {
+            navigationContext.Parameters.TryGetValue<CPDFViewer>(ParameterNames.PDFViewer, out PDFViewer);
+            EditToolsHelper.GetPageRange(PageRangeSelectIndex, PDFViewer.Document, ref HeaderFooterInfo.PageRange, PageRangeText);
+            if (navigationContext.Parameters.TryGetValue<BatesHeaderFooterItem>("HeaderFooterItem", out TemplateHeaderFooterItem))
+            {
+                CreateOrEdit = EnumCreateOrEdit.StatusEdit;
+                InitComponentBySelectedInfo();
+            }
+            else
+            {
+                CreateOrEdit = EnumCreateOrEdit.StatusCreate;
+            }
         }
     }
 }

+ 283 - 2
PDF Office/ViewModels/EditTools/HeaderFooter/HeaderFooterDocumentContentViewModel.cs

@@ -1,22 +1,283 @@
-using Prism.Commands;
+using ComPDFKit.PDFDocument;
+using ComPDFKit.PDFPage;
+using ComPDFKitViewer;
+using ComPDFKitViewer.PdfViewer;
+using PDF_Office.EventAggregators;
+using PDF_Office.Helper;
+using PDF_Office.Model.EditTools.HeaderFooter;
+using Prism.Commands;
 using Prism.Events;
 using Prism.Mvvm;
 using Prism.Regions;
 using System;
 using System.Collections.Generic;
 using System.Linq;
+using System.Text.RegularExpressions;
+using System.Windows;
+using System.Windows.Media.Imaging;
+using System.Windows.Media;
+using System.Windows.Controls;
+using PDF_Office.Model;
+using System.Diagnostics;
+using System.Drawing.Printing;
+using static System.Windows.Forms.VisualStyles.VisualStyleElement.TrayNotify;
+using ComPDFKit.PDFWatermark;
+using PDF_Office.Model.EditTools.Watermark;
+using Microsoft.Office.Core;
 
 namespace PDF_Office.ViewModels.EditTools.HeaderFooter
 {
     public class HeaderFooterDocumentContentViewModel : BindableBase, INavigationAware
     {
         public IEventAggregator eventAggregator;
+        public IRegionManager regionManager;
+        public CPDFViewer PDFViewer;
+        public CPDFDocument Document;
+        private ViewContentViewModel viewContentViewModel;
+        public EnumDelete EnumDelete = EnumDelete.StatusCreate;
+        public CPDFViewer pdfViewer;
+
+        private CPDFHeaderFooter headerFooter;
+        private HeaderFooterInfo headerFooterInfo;
+
+        public bool firstin = true;
+
+        public string ViewerRegionName { get; set; }
+
+        public string unicode = null;
         public string Unicode = null;
-        public HeaderFooterDocumentContentViewModel(IEventAggregator eventAggregator)
+
+        private int _pageSize;
+        public int PageRangeNumber
+        {
+            get { return _pageSize; }
+            set { SetProperty(ref _pageSize, value); }
+        }
+
+        private int _currentPageIndex;
+        public int CurrentPageIndex
+        {
+            get { return _currentPageIndex; }
+            set
+            {
+                SetProperty(ref _currentPageIndex, value);
+
+            }
+        }
+
+        private Visibility _inputIndexBoxVisible = Visibility.Collapsed;
+        public Visibility InputIndexBoxVisible
+        {
+            get
+            {
+                return _inputIndexBoxVisible;
+            }
+            set
+            {
+                SetProperty(ref _inputIndexBoxVisible, value);
+            }
+        }
+
+        public DelegateCommand<object> ShowInputIndexBoxCommand { set; get; }
+        public DelegateCommand<object> GoToPageCommand { set; get; }
+        public HeaderFooterDocumentContentViewModel(IEventAggregator eventAggregator, IRegionManager regionManager)
         {
             this.eventAggregator = eventAggregator;
+            this.regionManager = regionManager;
+            ShowInputIndexBoxCommand = new DelegateCommand<object>(ShowInputIndexBox);
+            GoToPageCommand = new DelegateCommand<object>(GoToPage);
             Unicode = App.mainWindowViewModel.SelectedItem.Unicode;
+            ViewerRegionName = RegionNames.HeaderFooterViewerRegionName;
+            eventAggregator.GetEvent<SetHeaderFooterEvent>().Subscribe(SetHeaderFooter, e => e.Unicode == Unicode);
+            eventAggregator.GetEvent<ConfirmEditToolsHeaderFooterEvent>().Subscribe(ConfirmEditToolsHeaderFooter, e => e == Unicode);
+            eventAggregator.GetEvent<DeleteHeaderFooterEvent>().Subscribe(DeleteHeaderFooter, e => e.Unicode == Unicode);
+
+        }
+        public string ReverseDate(string str)
+        {
+            string yyyy = DateTime.Now.ToString("yyyy");
+            string yy = DateTime.Now.ToString("yy");
+            string mm = DateTime.Now.ToString("MM");
+            string m = DateTime.Now.ToString("%M");
+            string dd = DateTime.Now.ToString("dd");
+            string d = DateTime.Now.ToString("%d");
+            str = str.Replace("<<m/d>>", m + "/" + d)
+            .Replace("<<m/d/yy>>", m + "/" + d + "/" + yy)
+            .Replace("<<m/d/yyyy>>", m + "/" + d + "/" + yyyy)
+            .Replace("<<mm/dd/yy>>", mm + "/" + dd + "/" + yy)
+            .Replace("<<mm/dd/yyyy>>", mm + "/" + dd + "/" + yyyy)
+            .Replace("<<d/m/yy>>", d + "/" + m + "/" + yy)
+            .Replace("<<d/m/yyyy>>", d + "/" + m + "/" + yyyy)
+            .Replace("<<dd/mm/yy>>", dd + "/" + mm + "/" + yy)
+            .Replace("<<dd/mm/yyyy>>", dd + "/" + mm + "/" + yyyy)
+            .Replace("<<mm/yy>>", mm + "/" + yy)
+            .Replace("<<mm/yyyy>>", mm + "/" + yyyy)
+            .Replace("<<m.d.yy>>", m + "." + d + "." + yy)
+            .Replace("<<m.d.yyyy>>", m + "." + d + "." + yyyy)
+            .Replace("<<mm.dd.yy>>", mm + "." + dd + "." + yy)
+            .Replace("<<mm.dd.yyyy>>", mm + "." + dd + "." + yyyy)
+            .Replace("<<mm.yy>>", mm + "." + yy)
+            .Replace("<<mm.yyyy>>", mm + "." + yyyy)
+            .Replace("<<d.m.yy>>", d + "." + m + "." + yy)
+            .Replace("<<d.m.yyyy>>", d + "." + m + "." + yyyy)
+            .Replace("<<dd.mm.yy>>", dd + "." + mm + "." + yy)
+            .Replace("<<dd.mm.yyyy>>", dd + "." + mm + "." + yyyy)
+            .Replace("<<yy-mm-dd>>", yy + "-" + mm + "-" + dd)
+            .Replace("<<yyyy-mm-dd>>", yyyy + "-" + mm + "-" + dd)
+            .Replace("<<1 of n>>", "<<1>>" + " of " + Document.PageCount)
+            .Replace("<<1/n>>", "<<1>>" + "/" + Document.PageCount)
+            .Replace("<<Page 1>>", "Page" + "<<1>>")
+            .Replace("<<Page 1 of n>>", "Page " + "<<1>>" + " of " + Document.PageCount);
+            return str;
+        }
+
+        public void ShowInputIndexBox(object obj)
+        {
+            if (obj != null)
+            {
+                InputIndexBoxVisible = Visibility.Visible;
+            }
+        }
+
+        public void GoToPage(object obj)
+        {
+
+            if (obj != null)
+            {
+                var args = obj as TextBox;
+                if (args.Text == null)
+                {
+                    return;
+                }
+                if (int.Parse(args.Text) > 0 && int.Parse(args.Text) <= PDFViewer.Document.PageCount && Regex.Match(args.Text, "^\\d+$").Success)
+                {
+                    PDFViewer.GoToPage(int.Parse(args.Text) - 1);
+                    InputIndexBoxVisible = Visibility.Collapsed;
+                }
+            }
         }
+
+        public void ConfirmEditToolsHeaderFooter(string unicode)
+        {
+            if (EnumDelete == EnumDelete.StatusDeleteAll)
+            {
+                PDFViewer.Document.GetHeaderFooter().Clear();
+            }
+            else
+            {
+                if (headerFooterInfo != null)
+                {
+                    CreateHeaderFooter(viewContentViewModel.PDFViewer.Document);
+                }
+            }
+
+
+            viewContentViewModel.PDFViewer.UndoManager.CanSave = true;
+        }
+
+        public void DeleteHeaderFooter(EnumDeleteUnicode enumDeleteunicode)
+        {
+            if (enumDeleteunicode.Status == EnumDelete.StatusDeleteAll)
+            {
+                EnumDelete enumDelete = enumDeleteunicode.Status;
+                EnumDelete = enumDelete;
+                PDFViewer.Document.ReleasePages();
+                PDFViewer.ReloadDocument();
+            }
+        }
+
+
+        public void SetHeaderFooter(HeaderFooterInfoUnicode headerFooterInfoUnicode)
+        {
+            EnumDelete = EnumDelete.StatusCreate;
+            HeaderFooterInfo headerFooterInfo = headerFooterInfoUnicode.Status;
+            this.headerFooterInfo = headerFooterInfo;
+            //CreateHeaderFooter(PDFViewer.Document);
+            PDFViewer.InvalidChildVisual(false);
+        }
+
+        public void CreateHeaderFooter(CPDFDocument document, bool IsNewDoc = false)
+        {
+            if (headerFooterInfo != null)
+            {
+
+                //document.(headerFooterInfo.TextData, headerFooterInfo.margin, headerFooterInfo.PageRange, headerFooterInfo.StarPagetNumber + 1);
+                headerFooter = document.GetHeaderFooter();
+                for (int i = 0; i < 6; i++)
+                {
+                    headerFooter.SetText(i, ReverseDate(headerFooterInfo.TextData[i].text));
+
+                    headerFooter.SetFontName(i, headerFooterInfo.TextData[i].fontName);
+                    headerFooter.SetFontSize(i, headerFooterInfo.TextData[i].fontSize);
+
+                    headerFooter.SetTextColor(i, headerFooterInfo.TextData[i].Color);
+                }
+
+                if (IsNewDoc)
+                {
+                    headerFooter.SetPageOffset(1);
+                    headerFooter.SetPages("0");
+                }
+                else
+                {
+                    headerFooter.SetPages(headerFooterInfo.PageRange);
+                    headerFooter.SetPageOffset(headerFooterInfo.StarPagetNumber + 1);
+                }
+                headerFooter.SetMargin(headerFooterInfo.margin);
+                headerFooter.Update();
+            }
+        }
+
+
+        private void UndoManager_PropertyChanged(object sender, System.ComponentModel.PropertyChangedEventArgs e)
+        {
+
+        }
+
+        private void CurrentViewer_CustomDrawHandler(object sender, CustomDrawData e)
+        {
+            if (e.DrawPages.Count > 0 && e.DrawContext != null)
+            {
+                List<int> PageIndexLists = new List<int>();
+                foreach (DrawPageData drawPageData in e.DrawPages)
+                {
+                    if (headerFooterInfo != null)
+                    {
+                        char[] enumerationSeparator = new char[] { ',' };
+                        char[] rangeSeparator = new char[] { '-' };
+                        if (CommonHelper.GetPagesInRange(ref PageIndexLists, headerFooterInfo.PageRange, Document.PageCount, enumerationSeparator, rangeSeparator, true))
+                        { //TODO
+                            
+                            if (PageIndexLists.Contains(drawPageData.PageIndex-1))
+                            {
+                                WriteableBitmap headerFooterBitmap = GetHeaderFooter(PDFViewer.Document, e.Zoom, drawPageData.PageIndex);
+                                e.DrawContext.DrawImage(headerFooterBitmap, drawPageData.PageBound);
+                            }
+                        }
+                    }
+                }
+            }
+            CurrentPageIndex = PDFViewer.CurrentIndex + 1;
+        }
+
+        private WriteableBitmap GetHeaderFooter(CPDFDocument oldDoc, double zoom, int pageIndex)
+        {
+            Size pageSize = oldDoc.GetPageSize(pageIndex);
+
+            CPDFDocument newDoc = CPDFDocument.CreateDocument();
+            newDoc.InsertPage(0, pageSize.Width, pageSize.Height, null);
+            CreateHeaderFooter(newDoc, true);
+            CPDFPage newPage = newDoc.PageAtIndex(0);
+            double scale = 96.0 / 72.0;
+            zoom = zoom * 1.5;
+            Rect renderRect = new Rect(0, 0, (int)(pageSize.Width * scale), (int)(pageSize.Height * scale));
+            byte[] imageArray = new byte[(int)(renderRect.Width * renderRect.Height * 4)];
+            newPage.RenderPageBitmapWithMatrix(1 / (float)zoom, renderRect, 0x00FFFFFF, imageArray, 1, true);
+            WriteableBitmap WirteBitmap = new WriteableBitmap((int)renderRect.Width, (int)renderRect.Height, 96, 96, PixelFormats.Bgra32, null);
+            WirteBitmap.WritePixels(new Int32Rect(0, 0, (int)renderRect.Width, (int)renderRect.Height), imageArray, WirteBitmap.BackBufferStride, 0);
+            return WirteBitmap;
+        }
+
         public bool IsNavigationTarget(NavigationContext navigationContext)
         {
             return true;
@@ -28,6 +289,26 @@ namespace PDF_Office.ViewModels.EditTools.HeaderFooter
 
         public void OnNavigatedTo(NavigationContext navigationContext)
         {
+            navigationContext.Parameters.TryGetValue<CPDFViewer>(ParameterNames.PDFViewer, out pdfViewer);
+            navigationContext.Parameters.TryGetValue<ViewContentViewModel>(ParameterNames.ViewContentViewModel, out viewContentViewModel);
+            if (pdfViewer != null)
+            {
+                if (!regionManager.Regions[ViewerRegionName].Views.Contains(PDFViewer))
+                {
+                    PDFViewer = new CPDFViewer();
+                    PDFViewer.InitDocument(pdfViewer.Document);
+                    Document = PDFViewer.Document;
+                    PDFViewer.CustomDrawHandler += CurrentViewer_CustomDrawHandler;
+                    PDFViewer.UndoManager.PropertyChanged += UndoManager_PropertyChanged;
+                    regionManager.AddToRegion(ViewerRegionName, PDFViewer);
+                    PDFViewer.SetAnnotInteraction(!PDFViewer.GetAnnotInteraction());
+                    PDFViewer.Load();
+                    PDFViewer.ChangeViewMode(ViewMode.Single);
+                    PDFViewer.SetMouseMode(MouseModes.Default);
+                    PageRangeNumber = PDFViewer.Document.PageCount;
+                    PDFViewer.Zoom(0.5);
+                }
+            }
         }
     }
 }

+ 190 - 1
PDF Office/ViewModels/EditTools/HeaderFooter/HeaderFooterTemplateListContentViewModel.cs

@@ -1,17 +1,55 @@
-using PDF_Office.EventAggregators;
+using ComPDFKitViewer.PdfViewer;
+using PDF_Office.EventAggregators;
+using PDF_Office.Helper;
+using PDF_Office.Model;
+using PDF_Office.Model.EditTools.Bates;
+using PDF_Office.Model.EditTools.HeaderFooter;
+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.EditTools.HeaderFooter
 {
     public class HeaderFooterTemplateListContentViewModel : BindableBase, INavigationAware
     {
         public IEventAggregator eventAggregator;
+        private CPDFViewer PDFViewer;
+        public HeaderFooterInfo HeaderFooterInfo = new HeaderFooterInfo();
+        public BatesHeaderFooterItem HeaderFooterItem = new BatesHeaderFooterItem();
+        public int TemplateIndex = 0;
+
+        private ObservableCollection<BatesHeaderFooterItem> headerFooterModCollection = new ObservableCollection<BatesHeaderFooterItem>();
+        public ObservableCollection<BatesHeaderFooterItem> HeaderFooterModCollection
+        {
+            get { return headerFooterModCollection; }
+            set
+            {
+                headerFooterModCollection = 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 DelegateCommand EnterCreateCommand { get; set; }
 
         public string Unicode = null;
@@ -20,6 +58,20 @@ namespace PDF_Office.ViewModels.EditTools.HeaderFooter
             this.eventAggregator = eventAggregator;
             Unicode = App.mainWindowViewModel.SelectedItem.Unicode;
             EnterCreateCommand = new DelegateCommand(EnterCreate);
+            AddTemplateCommand = new DelegateCommand(AddTemplate);
+            EditTemplateItemCommand = new DelegateCommand<object>(RequestEditTemplateItem);
+            DeleteTemplateItemCommand = new DelegateCommand<object>(DeleteTemplateItem);
+            DeleteAllTemplateItemCommand = new DelegateCommand(DeleteAllTemplateItem);
+            SelectTemplateItemCommand = new DelegateCommand<object>(SelectTemplateItem);
+        }
+
+        private void InitBackgroundTemplateList()
+        {
+            if (Settings.Default.HeaderFooterTemplateList == null)
+            {
+                Settings.Default.HeaderFooterTemplateList = new HeaderFooterTemplateList();
+            }
+            GetHeaderFooterSource();
         }
 
         public void EnterCreate()
@@ -27,6 +79,140 @@ namespace PDF_Office.ViewModels.EditTools.HeaderFooter
             this.eventAggregator.GetEvent<EnterTemplateListOrCreateEvent>().Publish(new EnumTemplateListOrCreateUnicode { Unicode = Unicode, Status = EnumTemplateListOrCreate.StatusCreate });
         }
 
+        public void AddTemplate()
+        {
+            this.eventAggregator.GetEvent<EnterTemplateListOrCreateEvent>().Publish(new EnumTemplateListOrCreateUnicode
+            {
+                Unicode = Unicode,
+                Status = EnumTemplateListOrCreate.StatusCreate
+            });
+        }
+
+        public void SaveEditedBatesTemplateItem(BatesHeaderFooterItemUnicode HeaderFooterItemunicode)
+        {
+            BatesHeaderFooterItem headerFooterItem = HeaderFooterItemunicode.Status;
+
+            Settings.Default.HeaderFooterTemplateList[TemplateIndex] = headerFooterItem;
+            Settings.Default.Save();
+
+            GetHeaderFooterSource();
+        }
+
+        public void RequestEditTemplateItem(object e)
+        {
+            var control = e as Control;
+            if (control == null)
+            {
+                return;
+            }
+            var template = control.DataContext as BatesHeaderFooterItem;
+            if (template == null)
+            {
+                return;
+            }
+            TemplateIndex = Settings.Default.HeaderFooterTemplateList.IndexOf(template);
+            template.listIndex = TemplateIndex;
+            ConvertItemToInfo(template, ref HeaderFooterInfo);
+            this.eventAggregator.GetEvent<EditBatesHeaderFooterTemplateItemEvent>().Publish(new BatesHeaderFooterItemUnicode
+            {
+                Unicode = Unicode,
+                Type = "HeaderFooterType",
+                Status = template
+            });
+        }
+
+        public void DeleteTemplateItem(object e)
+        {
+            var btn = e as System.Windows.Controls.Button;
+            if (btn == null)
+            {
+                return;
+            }
+            HeaderFooterItem = btn.DataContext as BatesHeaderFooterItem;
+            if (HeaderFooterItem == null)
+            {
+                return;
+            }
+
+            Settings.Default.HeaderFooterTemplateList.Remove(HeaderFooterItem);
+            Settings.Default.Save();
+            HeaderFooterModCollection.Remove(HeaderFooterItem);
+            GetHeaderFooterSource();
+        }
+
+        public void DeleteAllTemplateItem()
+        {
+            while (Settings.Default.HeaderFooterTemplateList.Count != 0)
+            {
+                int temp = 0;
+                var template = Settings.Default.HeaderFooterTemplateList[temp];
+
+                Settings.Default.HeaderFooterTemplateList.Remove(template);
+                Settings.Default.Save();
+
+                HeaderFooterModCollection.Remove(template);
+
+            }
+            GetHeaderFooterSource();
+        }
+
+        public void SelectTemplateItem(object e)
+        {
+            var listBox = e as ListBox;
+            BatesHeaderFooterItem HeaderFooterItem = listBox.SelectedItem as BatesHeaderFooterItem;
+            SendTemplateItemToDocument(HeaderFooterItem);
+        }
+
+        public void SendTemplateItemToDocument(BatesHeaderFooterItem template)
+        {
+            if (template != null)
+            {
+                ConvertItemToInfo(template, ref HeaderFooterInfo);
+                eventAggregator.GetEvent<SetHeaderFooterEvent>().Publish(new HeaderFooterInfoUnicode
+                {
+                    Unicode = Unicode,
+                    Status = HeaderFooterInfo
+                });
+            }
+
+        }
+
+        private void GetHeaderFooterSource()
+        {
+            List<BatesHeaderFooterItem> headerFooterModColorTemplateList = new List<BatesHeaderFooterItem>();
+            for (int temp = 0; temp < Settings.Default.HeaderFooterTemplateList.Count; temp++)
+            {
+                Settings.Default.HeaderFooterTemplateList[temp].ItemName = (temp + 1).ToString();
+                headerFooterModColorTemplateList.Add(Settings.Default.HeaderFooterTemplateList[temp]);
+
+            }
+            HeaderFooterModCollection = new ObservableCollection<BatesHeaderFooterItem>(headerFooterModColorTemplateList);
+            CheckTemplateListIsEmpty(headerFooterModColorTemplateList);
+        }
+
+        public void ConvertItemToInfo(BatesHeaderFooterItem headerFooterItem, ref HeaderFooterInfo headerFooterInfo)
+        {
+            headerFooterInfo.TextData = headerFooterItem.TextData;
+            headerFooterInfo.ItemName=headerFooterItem.ItemName;
+            headerFooterInfo.DateTimeFormat = headerFooterItem.DateTimeFormat;
+            headerFooterInfo.StarPagetNumber = headerFooterItem.StarPagetNumber;
+            headerFooterInfo.PageNumberFormat = headerFooterItem.PageNumberFormat;
+            headerFooterInfo.margin = headerFooterItem.margin;
+            headerFooterInfo.PageRangeIndex = headerFooterItem.PageRangeIndex;
+            EditToolsHelper.GetPageRange(headerFooterInfo.PageRangeIndex, PDFViewer.Document, ref headerFooterInfo.PageRange, headerFooterItem.PageRange);
+        }
+        private void CheckTemplateListIsEmpty(List<BatesHeaderFooterItem> headerFooterTemplateList)
+        {
+            if (headerFooterTemplateList.Count() == 0)
+            {
+                CreateTemplateVisible = Visibility.Visible;
+            }
+            else
+            {
+                CreateTemplateVisible = Visibility.Collapsed;
+            }
+        }
+
         public bool IsNavigationTarget(NavigationContext navigationContext)
         {
             return true;
@@ -38,6 +224,9 @@ namespace PDF_Office.ViewModels.EditTools.HeaderFooter
 
         public void OnNavigatedTo(NavigationContext navigationContext)
         {
+            navigationContext.Parameters.TryGetValue<CPDFViewer>(ParameterNames.PDFViewer, out PDFViewer);
+            InitBackgroundTemplateList();
+           
         }
     }
 }

+ 0 - 1
PDF Office/ViewModels/EditTools/Watermark/WatermarkContentViewModel.cs

@@ -226,7 +226,6 @@ namespace PDF_Office.ViewModels.EditTools.Watermark
                 }
             }
             else {
-
                 alertsMessage.ShowDialog("无法在本文件中找到可删除的水印。如果您看到水印,其不是使用PDF Office添加的,因此无法被检测到。", "", "取消", "确定");
             }
             

+ 1 - 0
PDF Office/ViewModels/EditTools/Watermark/WatermarkCreateBaseContentViewModel.cs

@@ -139,6 +139,7 @@ namespace PDF_Office.ViewModels.EditTools.Watermark
 
         public void SaveToCurrentTemplateList()
         {
+
             if (CurrentCreateModName == "WatermarkCreateTextContent")
             {
                 eventAggregator.GetEvent<ConfirmEditWatermarkTemplateItemEvent>().Publish(new EnumTextOrFileUnicode

+ 40 - 11
PDF Office/ViewModels/EditTools/Watermark/WatermarkCreateFileContentViewModel.cs

@@ -118,7 +118,7 @@ namespace PDF_Office.ViewModels.EditTools.Watermark
             set
             {
                 SetProperty(ref _rotationValue, value);
-                WatermarkInfo.Rotation = ((float)RotationValue / 180) * 3.1415926f;
+                WatermarkInfo.Rotation = RotationValue;
                 eventAggregator.GetEvent<SetWatermarkEvent>().Publish(new WatermarkInfoUnicode
                 {
                     Unicode = Unicode,
@@ -134,7 +134,7 @@ namespace PDF_Office.ViewModels.EditTools.Watermark
             set
             {
                 SetProperty(ref _opacityValue, value);
-                WatermarkInfo.Opacity = (byte)(((float)OpacityValue / 100) * 225);
+                WatermarkInfo.Opacity = (byte)OpacityValue;
                 eventAggregator.GetEvent<SetWatermarkEvent>().Publish(new WatermarkInfoUnicode
                 {
                     Unicode = Unicode,
@@ -183,6 +183,12 @@ namespace PDF_Office.ViewModels.EditTools.Watermark
             set
             {
                 SetProperty(ref _relativeScaleValue, value);
+                WatermarkInfo.ImageSize=RelativeScaleValue;
+                eventAggregator.GetEvent<SetWatermarkEvent>().Publish(new WatermarkInfoUnicode
+                {
+                    Unicode = Unicode,
+                    Status = WatermarkInfo
+                });
             }
         }
 
@@ -282,6 +288,22 @@ namespace PDF_Office.ViewModels.EditTools.Watermark
             }
         }
 
+        private bool _isRelativeScaleValue = false;
+        public bool IsRelativeScaleValue
+        {
+            get { return _isRelativeScaleValue; }
+            set
+            {
+                SetProperty(ref _isRelativeScaleValue, value);
+                WatermarkInfo.IsRelativeScale = IsRelativeScaleValue;
+                eventAggregator.GetEvent<SetWatermarkEvent>().Publish(new WatermarkInfoUnicode
+                {
+                    Unicode = Unicode,
+                    Status = WatermarkInfo
+                });
+            }
+        }
+
         private int _pageRangeSelectIndex = 0;
         public int PageRangeSelectIndex
         {
@@ -382,6 +404,7 @@ namespace PDF_Office.ViewModels.EditTools.Watermark
                 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;
@@ -422,6 +445,7 @@ namespace PDF_Office.ViewModels.EditTools.Watermark
                 }
                 watermarkInfo.WatermarkHorizalign = watermarkItem.horizalign;
                 watermarkInfo.WatermarkVertalign = watermarkItem.vertalign;
+                watermarkInfo.IsRelativeScale = watermarkItem.isRelativeScale;
                 watermarkInfo.Isfull = watermarkItem.isFullScreen;
                 watermarkInfo.IsFront = watermarkItem.isfront;
                 watermarkInfo.ImageSize = watermarkItem.imageSize;
@@ -515,14 +539,16 @@ namespace PDF_Office.ViewModels.EditTools.Watermark
         private void InitWatermarkInfo()
         {
 
-            WatermarkInfo.Rotation = ((float)RotationValue / 180) * 3.1415926f;
-            WatermarkInfo.Opacity = (byte)(((float)OpacityValue / 100) * 225);
+            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);
         }
@@ -582,6 +608,7 @@ namespace PDF_Office.ViewModels.EditTools.Watermark
                     watermark.SetText(watermarkInfo.Text);
                     watermark.SetFontName(watermarkInfo.FontName);
                     watermark.SetFontSize(watermarkInfo.TextSize);
+                    //watermark.SetScale(watermarkInfo.TextSize);
                     watermark.SetTextRGBColor(watermarkInfo.TextColor);
                 }
                 else
@@ -591,10 +618,10 @@ namespace PDF_Office.ViewModels.EditTools.Watermark
                     {
                         watermark.SetImage(watermarkInfo.ImageArray, watermarkInfo.ImageWidth, watermarkInfo.ImageHeight);
                     }
-                    watermark.SetScale(0.1f);
+                    watermark.SetScale(watermarkInfo.ImageSize/100);
                 }
-                watermark.SetRotation(watermarkInfo.Rotation);
-                watermark.SetOpacity(watermarkInfo.Opacity);
+                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);
@@ -612,7 +639,7 @@ namespace PDF_Office.ViewModels.EditTools.Watermark
         public void ConfirmEditWatermarkTemplateItem(EnumTextOrFileUnicode enumTextOrFileunicode)
         {
             EnumTextOrFile enumTextOrFile = enumTextOrFileunicode.Status;
-            if (enumTextOrFile == EnumTextOrFile.StatusFile)
+            if (enumTextOrFile == EnumTextOrFile.StatusFile && FileNameText != "")
             {
                 var watermarkItem = new WatermarkItem();
                 ConvertInfoToItem(ref watermarkItem, WatermarkInfo);
@@ -682,12 +709,14 @@ namespace PDF_Office.ViewModels.EditTools.Watermark
             HorizontalSpacingValue = WatermarkInfo.HorizontalSpacing.ToString();
             PageRangeSelectIndex = WatermarkInfo.PageRangeIndex;
             IsFrontSelectedIndex = Convert.ToInt32(!WatermarkInfo.IsFront);
-            RotationText = ((int)((WatermarkInfo.Rotation / Math.PI) * 180)).ToString();
-            OpacityText = ((((float)WatermarkInfo.Opacity) / 225) * 100).ToString() + " %";
+            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()

+ 124 - 101
PDF Office/ViewModels/EditTools/Watermark/WatermarkCreateTextContentViewModel.cs

@@ -175,7 +175,7 @@ namespace PDF_Office.ViewModels.EditTools.Watermark
             set
             {
                 SetProperty(ref _rotationValue, value);
-                WatermarkInfo.Rotation = ((float)RotationValue / 180) * 3.1415926f;
+                WatermarkInfo.Rotation = RotationValue;
                 eventAggregator.GetEvent<SetWatermarkEvent>().Publish(new WatermarkInfoUnicode
                 {
                     Unicode = Unicode,
@@ -191,7 +191,7 @@ namespace PDF_Office.ViewModels.EditTools.Watermark
             set
             {
                 SetProperty(ref _opacityValue, value);
-                WatermarkInfo.Opacity = (byte)(((float)OpacityValue / 100) * 225);
+                WatermarkInfo.Opacity = (byte)OpacityValue;
                 eventAggregator.GetEvent<SetWatermarkEvent>().Publish(new WatermarkInfoUnicode
                 {
                     Unicode = Unicode,
@@ -368,6 +368,23 @@ namespace PDF_Office.ViewModels.EditTools.Watermark
                 });
             }
         }
+
+        private bool _isRelativeScaleValue = false;
+        public bool IsRelativeScaleValue
+        {
+            get { return _isRelativeScaleValue; }
+            set
+            {
+                SetProperty(ref _isRelativeScaleValue, value);
+                WatermarkInfo.IsRelativeScale = IsRelativeScaleValue;
+                eventAggregator.GetEvent<SetWatermarkEvent>().Publish(new WatermarkInfoUnicode
+                {
+                    Unicode = Unicode,
+                    Status = WatermarkInfo
+                });
+            }
+        }
+
         private SolidColorBrush _solidColorBrush = null;
         public SolidColorBrush SolidColorBrush
         {
@@ -486,6 +503,7 @@ namespace PDF_Office.ViewModels.EditTools.Watermark
                 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;
@@ -509,6 +527,7 @@ namespace PDF_Office.ViewModels.EditTools.Watermark
                 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;
@@ -696,14 +715,15 @@ namespace PDF_Office.ViewModels.EditTools.Watermark
         {
 
             WatermarkInfo.Text = TextValue;
-            WatermarkInfo.Rotation = (float)(((float)RotationValue / 180) * Math.PI);
-            WatermarkInfo.Opacity = (byte)(((float)OpacityValue / 100) * 225);
+            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);
@@ -718,6 +738,7 @@ namespace PDF_Office.ViewModels.EditTools.Watermark
         {
             ConvertItemToInfo(TemplateWatermarkItem, ref WatermarkInfo);
             TextValue = WatermarkInfo.Text;
+            StringColor = EditToolsHelper.ConvertColor(WatermarkInfo.TextColor);
             VertOffsetValue = WatermarkInfo.VertOffset.ToString();
             HorizOffsetValue = WatermarkInfo.HorizOffset.ToString();
             VerticalSpacingValue = WatermarkInfo.VerticalSpacing.ToString();
@@ -726,130 +747,132 @@ namespace PDF_Office.ViewModels.EditTools.Watermark
             FontNameSelectedIndex = FontNameList.IndexOf(WatermarkInfo.FontName);
             FontSizeSelectedIndex = FontSizeList.IndexOf(((int)(WatermarkInfo.TextSize / 1.33f)).ToString() + "pt");
             IsFrontSelectedIndex = Convert.ToInt32(!WatermarkInfo.IsFront);
-            RotationText = ((int)((WatermarkInfo.Rotation/ Math.PI) *180)).ToString();
-            OpacityText = ((((float)WatermarkInfo.Opacity)/225)*100).ToString() + " %";
+            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)
+        public void CreateWatermark(CPDFDocument document, WatermarkInfo watermarkInfo)
+        {
+            if (watermarkInfo != null)
             {
-                if (watermarkInfo != null)
+                document.DeleteWatermarks();
+                CPDFWatermark watermark;
+                if (watermarkInfo.WatermarkType == C_Watermark_Type.WATERMARK_TYPE_TEXT)
                 {
-                    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_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 = document.InitWatermark(C_Watermark_Type.WATERMARK_TYPE_IMG);
-                        if (watermarkInfo.ImageArray != null)
-                        {
-                            watermark.SetImage(watermarkInfo.ImageArray, watermarkInfo.ImageWidth, watermarkInfo.ImageHeight);
-                        }
-                        watermark.SetScale(0.1f);
+                        watermark.SetImage(watermarkInfo.ImageArray, watermarkInfo.ImageWidth, watermarkInfo.ImageHeight);
                     }
-                    watermark.SetRotation(watermarkInfo.Rotation);
-                    watermark.SetOpacity(watermarkInfo.Opacity);
-                    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());
+                    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)
+        public void ConfirmEditWatermarkTemplateItem(EnumTextOrFileUnicode enumTextOrFileunicode)
+        {
+            EnumTextOrFile enumTextOrFile = enumTextOrFileunicode.Status;
+            if (enumTextOrFile == EnumTextOrFile.StatusText)
             {
-                EnumTextOrFile enumTextOrFile = enumTextOrFileunicode.Status;
-                if (enumTextOrFile == EnumTextOrFile.StatusText)
+                var watermarkItem = new WatermarkItem();
+                ConvertInfoToItem(ref watermarkItem, WatermarkInfo);
+                try
                 {
-                    var watermarkItem = new WatermarkItem();
-                    ConvertInfoToItem(ref watermarkItem, WatermarkInfo);
-                    try
+                    //创建缓存文件夹
+                    string folderPath = Path.Combine(App.CurrentPath, "Watermark");
+                    //有可能因为其他原因存在同名文件,导致创建文件夹失败,需要先删除同名文件
+                    //保险措施(猜测)
+                    if (File.Exists(folderPath))
                     {
-                        //创建缓存文件夹
-                        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);
+                        File.Delete(folderPath);
+                    }
 
-                            //获取透明背景的图片
-                            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);
-                            }
+                    DirectoryInfo tempfolder = new DirectoryInfo(folderPath);
+                    if (!tempfolder.Exists)
+                    {
+                        tempfolder.Create();
+                    }
 
-                            watermarkItem.previewImagePath = savePath;
-                            tempDocument.Release();
+                    //预览图缓存
+                    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);
 
-                            Settings.Default.WatermarkTemplateList[TemplateWatermarkItem.listIndex] = watermarkItem;
-                            Settings.Default.Save();
+                        //获取透明背景的图片
+                        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);
                         }
-                    }
-                    catch
-                    {
 
+                        watermarkItem.previewImagePath = savePath;
+                        tempDocument.Release();
+
+                        Settings.Default.WatermarkTemplateList[TemplateWatermarkItem.listIndex] = watermarkItem;
+                        Settings.Default.Save();
                     }
-                    this.eventAggregator.GetEvent<EnterTemplateListOrCreateEvent>().Publish(new EnumTemplateListOrCreateUnicode
-                    {
-                        Unicode = Unicode,
-                        Status = EnumTemplateListOrCreate.StatusTemplate
-                    });
+                }
+                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 bool IsNavigationTarget(NavigationContext navigationContext)
+        {
+            return true;
+        }
 
-            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();
-                }
+        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();
             }
+
         }
     }
+}

+ 94 - 25
PDF Office/ViewModels/EditTools/Watermark/WatermarkDocumentContentViewModel.cs

@@ -27,6 +27,8 @@ using System.Windows.Controls;
 using ComPDFKit.Import;
 using PDF_Office.ViewModels.Tools;
 using static System.Windows.Forms.VisualStyles.VisualStyleElement;
+using System.Text.RegularExpressions;
+using TextBox = System.Windows.Controls.TextBox;
 
 namespace PDF_Office.ViewModels.EditTools.Watermark
 {
@@ -48,12 +50,47 @@ namespace PDF_Office.ViewModels.EditTools.Watermark
 
         public string ViewerRegionName { get; set; }
 
+        private int _pageRangeNumber;
+        public int PageRangeNumber
+        {
+            get { return _pageRangeNumber; }
+            set { SetProperty(ref _pageRangeNumber, value); }
+        }
+
+        private Visibility _inputIndexBoxVisible = Visibility.Collapsed;
+        public Visibility InputIndexBoxVisible
+        {
+            get
+            {
+                return _inputIndexBoxVisible;
+            }
+            set
+            {
+                SetProperty(ref _inputIndexBoxVisible, value);
+            }
+        }
+
+        private int _currentPageIndex;
+        public int CurrentPageIndex
+        {
+            get { return _currentPageIndex; }
+            set
+            {
+                SetProperty(ref _currentPageIndex, value);
+
+            }
+        }
+        public DelegateCommand<object> ShowInputIndexBoxCommand { set; get; }
+        public DelegateCommand<object> GoToPageCommand { set; get; }
+
         public string Unicode = null;
 
         public WatermarkDocumentContentViewModel(IEventAggregator eventAggregator, IRegionManager regionManager)
         {
             this.regionManager = regionManager;
             this.eventAggregator = eventAggregator;
+            ShowInputIndexBoxCommand = new DelegateCommand<object>(ShowInputIndexBox);
+            GoToPageCommand = new DelegateCommand<object>(GoToPage);
             Unicode = App.mainWindowViewModel.SelectedItem.Unicode;
             eventAggregator.GetEvent<SetWatermarkEvent>().Subscribe(SetWatermark, e => e.Unicode == Unicode);
             ViewerRegionName = RegionNames.WatermarkViwerRegionName;
@@ -61,47 +98,76 @@ namespace PDF_Office.ViewModels.EditTools.Watermark
             eventAggregator.GetEvent<DeleteWatermarkEvent>().Subscribe(DeleteWatermark, e => e.Unicode == Unicode);
         }
 
-        public void ConfirmEditToolsWatermark()
+        public void ShowInputIndexBox(object obj)
         {
-            if (EnumDelete == EnumDelete.StatusDeleteAll)
+            if (obj != null)
             {
-                viewContentViewModel.PDFViewer.Document.DeleteWatermarks();
+                InputIndexBoxVisible = Visibility.Visible;
             }
+        }
 
-            if (watermarkInfo != null)
-            {
+        public void GoToPage(object obj)
+        {
 
-                if (EnumDelete == EnumDelete.StatusDeleteInitial)
+            if (obj != null)
+            {
+                var args = obj as TextBox;
+                if (args.Text == null || !Regex.Match(args.Text, "^\\d+$").Success)
                 {
-                    viewContentViewModel.PDFViewer.Document.DeleteWatermarks();
-                    CreateWatermark(viewContentViewModel.PDFViewer.Document);
+                    return;
                 }
-                else
+                if (int.Parse(args.Text) > 0 && int.Parse(args.Text) <= PDFViewer.Document.PageCount)
                 {
-                    CreateWatermark(viewContentViewModel.PDFViewer.Document);
+                    PDFViewer.GoToPage(int.Parse(args.Text) - 1);
+                    InputIndexBoxVisible = Visibility.Collapsed;
                 }
-                viewContentViewModel.PDFViewer.UndoManager.CanSave = true;
             }
         }
 
+        public void ConfirmEditToolsWatermark()
+        {
+            if (EnumDelete == EnumDelete.StatusDeleteAll)
+            {
+                viewContentViewModel.PDFViewer.Document.DeleteWatermarks();
+            }
+            else
+            {
+                if (watermarkInfo != null)
+                {
+
+                    if (EnumDelete == EnumDelete.StatusDeleteInitial)
+                    {
+                        viewContentViewModel.PDFViewer.Document.DeleteWatermarks();
+                        CreateWatermark(viewContentViewModel.PDFViewer.Document);
+                    }
+                    else
+                    {
+                        CreateWatermark(viewContentViewModel.PDFViewer.Document);
+                    }
+                }
+            }
+
+            viewContentViewModel.PDFViewer.UndoManager.CanSave = true;
+        }
+
         public void DeleteWatermark(EnumDeleteUnicode enumDeleteunicode)
         {
-            EnumDelete enumDelete = enumDeleteunicode.Status;
-            EnumDelete = enumDelete;
-            PDFViewer.Document.DeleteWatermarks();
-            PDFViewer.Document.ReleasePages();
-            PDFViewer.ReloadDocument();
+            if (enumDeleteunicode.Status == EnumDelete.StatusDeleteAll || enumDeleteunicode.Status == EnumDelete.StatusDeleteInitial)
+            {
+                EnumDelete enumDelete = enumDeleteunicode.Status;
+                EnumDelete = enumDelete;
+                PDFViewer.Document.DeleteWatermarks();
+                PDFViewer.Document.ReleasePages();
+                PDFViewer.ReloadDocument();
+            }
         }
 
         public void SetWatermark(WatermarkInfoUnicode watermarkInfounicode)
         {
             WatermarkInfo watermarkInfo = watermarkInfounicode.Status;
             this.watermarkInfo = watermarkInfo;
-            //CreateWatermark(viewContentViewModel.PDFViewer.Document);
-            // PDFViewer.Document.PdfToImage("0-1", "C:\\Users\\kdanmobile\\Desktop\\888\\");
-            viewContentViewModel.PDFViewer.Document.WriteToFilePath("C:\\Users\\kdanmobile\\Desktop\\888\\sb22222_.pdf");
+            EnumDelete = EnumDelete.StatusCreate;
             PDFViewer.InvalidChildVisual(false);
-
         }
 
         public void CreateWatermark(CPDFDocument document, bool IsNewDoc = false)
@@ -126,10 +192,10 @@ namespace PDF_Office.ViewModels.EditTools.Watermark
                     {
                         watermark.SetImage(watermarkInfo.ImageArray, watermarkInfo.ImageWidth, watermarkInfo.ImageHeight);
                     }
-                    watermark.SetScale(0.1f);
+                    watermark.SetScale(watermarkInfo.ImageSize / 100);
                 }
-                watermark.SetRotation(watermarkInfo.Rotation);
-                watermark.SetOpacity(watermarkInfo.Opacity);
+                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);
@@ -187,6 +253,7 @@ namespace PDF_Office.ViewModels.EditTools.Watermark
                     }
                 }
             }
+            CurrentPageIndex = PDFViewer.CurrentIndex + 1;
         }
         private WriteableBitmap GetWatermark(CPDFDocument oldDoc, double zoom, int pageIndex)
         {
@@ -197,10 +264,10 @@ namespace PDF_Office.ViewModels.EditTools.Watermark
             CreateWatermark(newDoc, true);
             CPDFPage newPage = newDoc.PageAtIndex(0);
             double scale = 96.0 / 72.0;
-            zoom = zoom * scale;
+            zoom = zoom * 1.5;
             Rect renderRect = new Rect(0, 0, (int)(pageSize.Width * scale), (int)(pageSize.Height * scale));
             byte[] imageArray = new byte[(int)(renderRect.Width * renderRect.Height * 4)];
-            newPage.RenderPageBitmapWithMatrix((float)zoom, renderRect, 0x00FFFFFF, imageArray, 1, true);
+            newPage.RenderPageBitmapWithMatrix(1 / (float)zoom, renderRect, 0x00FFFFFF, imageArray, 1, true);
             WriteableBitmap WirteBitmap = new WriteableBitmap((int)renderRect.Width, (int)renderRect.Height, 96, 96, PixelFormats.Bgra32, null);
             WirteBitmap.WritePixels(new Int32Rect(0, 0, (int)renderRect.Width, (int)renderRect.Height), imageArray, WirteBitmap.BackBufferStride, 0);
             return WirteBitmap;
@@ -240,6 +307,8 @@ namespace PDF_Office.ViewModels.EditTools.Watermark
                         Unicode = Unicode,
                         Status = PDFViewer
                     });
+                    PageRangeNumber = PDFViewer.Document.PageCount;
+                    PDFViewer.Zoom(0.5);
                 }
             }
         }

+ 1 - 0
PDF Office/ViewModels/EditTools/Watermark/WatermarkTemplateListFileContentViewModel.cs

@@ -263,6 +263,7 @@ namespace PDF_Office.ViewModels.EditTools.Watermark
                 }
                 watermarkInfo.WatermarkHorizalign = watermarkItem.horizalign;
                 watermarkInfo.WatermarkVertalign = watermarkItem.vertalign;
+                watermarkInfo.IsRelativeScale = watermarkItem.isRelativeScale;
                 watermarkInfo.Isfull = watermarkItem.isFullScreen;
                 watermarkInfo.IsFront = watermarkItem.isfront;
                 watermarkInfo.ImageSize = watermarkItem.imageSize;

+ 1 - 0
PDF Office/ViewModels/EditTools/Watermark/WatermarkTemplateListTextContentViewModel.cs

@@ -231,6 +231,7 @@ namespace PDF_Office.ViewModels.EditTools.Watermark
                 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;

+ 263 - 223
PDF Office/ViewModels/HomePanel/PDFTools/QuickToolsContentViewModel.cs

@@ -1,223 +1,263 @@
-using ComPDFKitViewer.PdfViewer;
-using PDF_Office.Helper;
-using PDF_Office.Model;
-using PDF_Office.Model.Dialog.HomePageToolsDialogs.HomePageBatchProcessing;
-using PDF_Office.Model.PDFTool;
-using PDFSettings;
-using Prism.Commands;
-using Prism.Mvvm;
-using Prism.Regions;
-using Prism.Services.Dialogs;
-using System;
-using System.Collections.Generic;
-using System.Linq;
-using System.Text;
-using System.Threading.Tasks;
-using System.Windows.Controls;
-
-namespace PDF_Office.ViewModels.HomePanel.PDFTools
-{
-    public class QuickToolsContentViewModel : BindableBase
-    {
-        #region 属性
-        /// <summary>
-        /// 扩展/收缩
-        /// </summary>
-        private bool _isExpendTools = false;
-        public bool IsExpendTools
-        {
-            get { return _isExpendTools; }
-            set { SetProperty(ref _isExpendTools, value); }
-        }
-
-        private string regionName;
-
-        public string ToolRegionName
-        {
-            get { return regionName; }
-            set { SetProperty(ref regionName, value); }
-        }
-
-        #endregion
-
-        #region Command and Event
-        public IDialogService dialogs;
-        public DelegateCommand<ToolItem> QuickToolsCommand { get; set; }
-        public DelegateCommand<object> OpenMenuCommand { get; set; }
-        public DelegateCommand ExpendCommand { get; set; }
-        public DelegateCommand ShowToolCommand { get; set; }
-
-        public IRegionManager toolregion;
-        public event EventHandler<bool> ExpendToolsHanlder;
-        #endregion
-
-        public QuickToolsContentViewModel(IDialogService dialogService, IRegionManager regionManager)
-        {
-            toolregion = regionManager;
-            ToolRegionName = RegionNames.ToolRegionName;
-            System.Windows.Application.Current.Dispatcher.BeginInvoke(System.Windows.Threading.DispatcherPriority.Send, new Action(() =>
-            {
-                toolregion.RequestNavigate(ToolRegionName, "Guid");
-            }));
-
-            dialogs = dialogService;
-
-            InitVariable();
-            InitCommand();
-            
-        }
-
-        #region 初始化和绑定
-        private void InitVariable()
-        {
-
-        }
-
-        private void InitCommand()
-        {
-            QuickToolsCommand = new DelegateCommand<ToolItem>(QuickTools_Click);
-            OpenMenuCommand = new DelegateCommand<object>(OpenMenu);
-            ExpendCommand = new DelegateCommand(Expend);
-            ShowToolCommand = new DelegateCommand(ShowTool);
-        }
-
-        #endregion
-
-        private void ShowTool()
-        {
-            toolregion.RequestNavigate(ToolRegionName, "Tools");
-        }
-
-
-        public void QuickTools_Click(ToolItem toolItem)
-        {
-            /*
-             *设置这个对话框的起始保存路径
-             */
-            System.Windows.Forms.OpenFileDialog dlg = new System.Windows.Forms.OpenFileDialog();
-            dlg.Multiselect = false;
-            dlg.Filter = "PDF|*.pdf;*.PDF;";
-            if (toolItem.FnType == PDFFnType.Compress || toolItem.FnType == PDFFnType.Security)
-            {
-                dlg.Multiselect = true;
-            }
-            if (toolItem.FnType == PDFFnType.Merge)
-            {
-                dlg.Multiselect = true;
-                dlg.Filter = "Picture|*.png;*.PNG;*.jpg;*.JPG;*bmp;*jpeg;*gif;*tiff;";
-            }
-            if (dlg.ShowDialog() == System.Windows.Forms.DialogResult.OK)
-            {
-                CPDFViewer viewer = new CPDFViewer();
-
-                switch ((PDFFnType)toolItem.FnType)
-                {
-                    case PDFFnType.Split:
-
-                        viewer.InitDocument(dlg.FileName);
-                        DialogParameters splitvalue = new DialogParameters();
-                        splitvalue.Add(ParameterNames.PDFViewer, viewer);
-                        splitvalue.Add(ParameterNames.FilePath, dlg.FileName);
-                        dialogs.ShowDialog(DialogNames.HomePageSplitDialog, splitvalue, e => { });
-                        break;
-
-                    case PDFFnType.Extract:
-                        viewer.InitDocument(dlg.FileName);
-                        DialogParameters extractvalue = new DialogParameters();
-                        extractvalue.Add(ParameterNames.PDFViewer, viewer);
-                        extractvalue.Add(ParameterNames.FilePath, dlg.FileName);
-                        dialogs.ShowDialog(DialogNames.HomePageExtractDialog, extractvalue, e => { });
-                        break;
-
-                    case PDFFnType.Insert:
-                        viewer.InitDocument(dlg.FileName);
-                        DialogParameters insertvalue = new DialogParameters();
-                        insertvalue.Add(ParameterNames.PDFViewer, viewer);
-                        insertvalue.Add(ParameterNames.FilePath, dlg.FileName);
-                        dialogs.ShowDialog(DialogNames.HomePageInsertDialog, insertvalue, e => { });
-                        break;
-
-                    case PDFFnType.Compress:
-                        DialogParameters compresspdf = new DialogParameters();
-                        compresspdf.Add(ParameterNames.BatchProcessing_Name, "1");
-                        HomePageBatchProcessingDialogModel.FilePaths = dlg.FileNames.ToList();
-                        HomePageBatchProcessingDialogModel.BatchProcessingIndex = 1;
-                        compresspdf.Add(ParameterNames.FilePath, dlg.FileNames);
-                        dialogs.ShowDialog(DialogNames.HomePageBatchProcessingDialog, compresspdf, e => { });
-                        break;
-
-                    case PDFFnType.Merge:
-                        DialogParameters picturetopdf = new DialogParameters();
-                        picturetopdf.Add(ParameterNames.FilePath, dlg.FileNames);
-                        dialogs.ShowDialog(DialogNames.HomePagePictureToPDFDialog, picturetopdf, e => { });
-                        break;
-
-                    case PDFFnType.Print:
-                        viewer.InitDocument(dlg.FileName);
-                        DialogParameters printvalue = new DialogParameters();
-                        printvalue.Add(ParameterNames.PDFViewer, viewer);
-                        printvalue.Add(ParameterNames.FilePath, dlg.FileName);
-                        dialogs.ShowDialog(DialogNames.HomePagePrinterDialog, printvalue, e => { });
-                        break;
-
-                    case PDFFnType.Security:
-                        DialogParameters securitypdf = new DialogParameters();
-                        securitypdf.Add(ParameterNames.BatchProcessing_Name, "2");
-                        HomePageBatchProcessingDialogModel.FilePaths = dlg.FileNames.ToList();
-                        HomePageBatchProcessingDialogModel.BatchProcessingIndex = 2;
-                        securitypdf.Add(ParameterNames.FilePath, dlg.FileNames);
-                        dialogs.ShowDialog(DialogNames.HomePageBatchProcessingDialog, securitypdf, e => { });
-
-                        break;
-                    case PDFFnType.ConvertPDF:
-                        DialogParameters convertpdf = new DialogParameters();
-                        convertpdf.Add(ParameterNames.BatchProcessing_Name, "0");
-                        HomePageBatchProcessingDialogModel.FilePaths = dlg.FileNames.ToList();
-                        HomePageBatchProcessingDialogModel.BatchProcessingIndex = 0;
-                        convertpdf.Add(ParameterNames.FilePath, dlg.FileNames);
-                        dialogs.ShowDialog(DialogNames.HomePageBatchProcessingDialog, convertpdf, e => { });
-
-                        break;
-                }
-
-            }
-        }
-
-
-
-        private void Expend()
-        {
-            IsExpendTools = !IsExpendTools;
-            ExpendToolsHanlder?.Invoke(null, IsExpendTools);
-        }
-
-        private void OpenMenu(object obj)
-        {
-            var menu = App.Current.FindResource("ExpendToolsContextMenu") as ContextMenu;
-            var btn = obj as Button;
-            if (menu != null && btn != null)
-            {
-                if(menu.Items.Count == 1)
-                {
-                  var item = menu.Items[0] as MenuItem;
-                    if(_isExpendTools)
-                    {
-                        item.Header = "收缩";
-                    }
-                    else
-                    {
-                        item.Header = "展开";
-                    }
-
-                    item.Command = ExpendCommand;
-                    //btn.ContextMenu = menu;
-                    menu.PlacementTarget = btn;
-                    menu.IsOpen = true;
-                }
-            }
-        }
-
-
-
-    }
-}
+using ComPDFKitViewer.PdfViewer;
+using PDF_Office.Helper;
+using PDF_Office.Model;
+using PDF_Office.Model.Dialog.HomePageToolsDialogs.HomePageBatchProcessing;
+using PDF_Office.Model.PDFTool;
+using PDFSettings;
+using Prism.Commands;
+using Prism.Mvvm;
+using Prism.Regions;
+using Prism.Services.Dialogs;
+using System;
+using System.Collections.Generic;
+using System.Linq;
+using System.Text;
+using System.Threading.Tasks;
+using System.Windows.Controls;
+
+namespace PDF_Office.ViewModels.HomePanel.PDFTools
+{
+    public class QuickToolsContentViewModel : BindableBase
+    {
+        #region 属性
+        /// <summary>
+        /// 扩展/收缩
+        /// </summary>
+        private bool _isExpendTools = false;
+        public bool IsExpendTools
+        {
+            get { return _isExpendTools; }
+            set { SetProperty(ref _isExpendTools, value); }
+        }
+
+        private string regionName;
+
+        public string ToolRegionName
+        {
+            get { return regionName; }
+            set { SetProperty(ref regionName, value); }
+        }
+
+        #endregion
+
+        #region Command and Event
+        public IDialogService dialogs;
+        public DelegateCommand<ToolItem> QuickToolsCommand { get; set; }
+        public DelegateCommand<object> OpenMenuCommand { get; set; }
+        public DelegateCommand ExpendCommand { get; set; }
+        public DelegateCommand ShowToolCommand { get; set; }
+
+        public IRegionManager toolregion;
+        public event EventHandler<bool> ExpendToolsHanlder;
+        #endregion
+
+        public QuickToolsContentViewModel(IDialogService dialogService, IRegionManager regionManager)
+        {
+            toolregion = regionManager;
+            ToolRegionName = RegionNames.ToolRegionName;
+            System.Windows.Application.Current.Dispatcher.BeginInvoke(System.Windows.Threading.DispatcherPriority.Send, new Action(() =>
+            {
+                toolregion.RequestNavigate(ToolRegionName, "Guid");
+            }));
+
+            dialogs = dialogService;
+
+            InitVariable();
+            InitCommand();
+            
+        }
+
+        #region 初始化和绑定
+        private void InitVariable()
+        {
+
+        }
+
+        private void InitCommand()
+        {
+            QuickToolsCommand = new DelegateCommand<ToolItem>(QuickTools_Click);
+            OpenMenuCommand = new DelegateCommand<object>(OpenMenu);
+            ExpendCommand = new DelegateCommand(Expend);
+            ShowToolCommand = new DelegateCommand(ShowTool);
+        }
+
+        #endregion
+
+        private void ShowTool()
+        {
+            toolregion.RequestNavigate(ToolRegionName, "Tools");
+        }
+
+
+        public void QuickTools_Click(ToolItem toolItem)
+        {
+            /*
+             *设置这个对话框的起始保存路径
+             */
+            System.Windows.Forms.OpenFileDialog dlg = new System.Windows.Forms.OpenFileDialog();
+            dlg.Multiselect = false;
+            dlg.Filter = "PDF|*.pdf;*.PDF;";
+            if (toolItem.FnType == PDFFnType.Compress || toolItem.FnType == PDFFnType.Security||toolItem.FnType ==PDFFnType.BatchRemove||toolItem.FnType==PDFFnType.ConvertPDF)
+            {
+                dlg.Multiselect = true;
+            }
+            if (toolItem.FnType == PDFFnType.ImageToPDF)
+            {
+                dlg.Multiselect = true;
+                dlg.Filter = "Picture|*.png;*.PNG;*.jpg;*.JPG;*bmp;*jpeg;*gif;*tiff;";
+            }
+            if (dlg.ShowDialog() == System.Windows.Forms.DialogResult.OK)
+            {
+                CPDFViewer viewer = new CPDFViewer();
+
+                switch ((PDFFnType)toolItem.FnType)
+                {
+                    case PDFFnType.Split:
+
+                        viewer.InitDocument(dlg.FileName);
+                        DialogParameters splitvalue = new DialogParameters();
+                        splitvalue.Add(ParameterNames.PDFViewer, viewer);
+                        splitvalue.Add(ParameterNames.FilePath, dlg.FileName);
+                        dialogs.ShowDialog(DialogNames.HomePageSplitDialog, splitvalue, e => { });
+                        break;
+
+                    case PDFFnType.Extract:
+                        viewer.InitDocument(dlg.FileName);
+                        DialogParameters extractvalue = new DialogParameters();
+                        extractvalue.Add(ParameterNames.PDFViewer, viewer);
+                        extractvalue.Add(ParameterNames.FilePath, dlg.FileName);
+                        dialogs.ShowDialog(DialogNames.HomePageExtractDialog, extractvalue, e => { });
+                        break;
+
+                    case PDFFnType.Insert:
+                        viewer.InitDocument(dlg.FileName);
+                        DialogParameters insertvalue = new DialogParameters();
+                        insertvalue.Add(ParameterNames.PDFViewer, viewer);
+                        insertvalue.Add(ParameterNames.FilePath, dlg.FileName);
+                        dialogs.ShowDialog(DialogNames.HomePageInsertDialog, insertvalue, e => { });
+                        break;
+
+                    case PDFFnType.Compress:
+                        DialogParameters compresspdf = new DialogParameters();
+                        compresspdf.Add(ParameterNames.BatchProcessing_Name, "1");
+                        HomePageBatchProcessingDialogModel.FilePaths = dlg.FileNames.ToList();
+                        HomePageBatchProcessingDialogModel.BatchProcessingIndex = 1;
+                        compresspdf.Add(ParameterNames.FilePath, dlg.FileNames);
+                        dialogs.ShowDialog(DialogNames.HomePageBatchProcessingDialog, compresspdf, e => { });
+                        break;
+
+                    case PDFFnType.ImageToPDF:
+                        DialogParameters picturetopdf = new DialogParameters();
+                        picturetopdf.Add(ParameterNames.FilePath, dlg.FileNames);
+                        dialogs.ShowDialog(DialogNames.HomePagePictureToPDFDialog, picturetopdf, e => { });
+                        break;
+
+                    case PDFFnType.Print:
+                        viewer.InitDocument(dlg.FileName);
+                        DialogParameters printvalue = new DialogParameters();
+                        printvalue.Add(ParameterNames.PDFViewer, viewer);
+                        printvalue.Add(ParameterNames.FilePath, dlg.FileName);
+                        dialogs.ShowDialog(DialogNames.HomePagePrinterDialog, printvalue, e => { });
+                        break;
+
+                    case PDFFnType.Security:
+                        DialogParameters securitypdf = new DialogParameters();
+                        securitypdf.Add(ParameterNames.BatchProcessing_Name, "2");
+                        HomePageBatchProcessingDialogModel.FilePaths = dlg.FileNames.ToList();
+                        HomePageBatchProcessingDialogModel.BatchProcessingIndex = 2;
+                        securitypdf.Add(ParameterNames.FilePath, dlg.FileNames);
+                        dialogs.ShowDialog(DialogNames.HomePageBatchProcessingDialog, securitypdf, e => { });
+
+                        break;
+                    case PDFFnType.ConvertPDF:
+                        DialogParameters convertpdf = new DialogParameters();
+                        convertpdf.Add(ParameterNames.BatchProcessing_Name, "0");
+                        HomePageBatchProcessingDialogModel.FilePaths = dlg.FileNames.ToList();
+                        HomePageBatchProcessingDialogModel.BatchProcessingIndex = 0;
+                        convertpdf.Add(ParameterNames.FilePath, dlg.FileNames);
+                        dialogs.ShowDialog(DialogNames.HomePageBatchProcessingDialog, convertpdf, e => { });
+
+                        break;
+                    case PDFFnType.BatchRemove:
+                        DialogParameters batchremovepdf = new DialogParameters();
+                        batchremovepdf.Add(ParameterNames.BatchProcessing_Name, "7");
+                        HomePageBatchProcessingDialogModel.FilePaths = dlg.FileNames.ToList();
+                        HomePageBatchProcessingDialogModel.BatchProcessingIndex = 7;
+                        batchremovepdf.Add(ParameterNames.FilePath, dlg.FileNames);
+                        dialogs.ShowDialog(DialogNames.HomePageBatchProcessingDialog, batchremovepdf, e => { });
+                        break;
+                    case PDFFnType.HeaderFooter:
+                        DialogParameters headerFooterpdf = new DialogParameters();
+                        headerFooterpdf.Add(ParameterNames.BatchProcessing_Name, "6");
+                        HomePageBatchProcessingDialogModel.FilePaths = dlg.FileNames.ToList();
+                        HomePageBatchProcessingDialogModel.BatchProcessingIndex = 5;
+                        headerFooterpdf.Add(ParameterNames.FilePath, dlg.FileNames);
+                        dialogs.ShowDialog(DialogNames.HomePageBatchProcessingDialog, headerFooterpdf, e => { });
+                        break;
+                    case PDFFnType.BatesNumbers:
+                        DialogParameters batesNumberspdf = new DialogParameters();
+                        batesNumberspdf.Add(ParameterNames.BatchProcessing_Name, "6");
+                        HomePageBatchProcessingDialogModel.FilePaths = dlg.FileNames.ToList();
+                        HomePageBatchProcessingDialogModel.BatchProcessingIndex = 6;
+                        batesNumberspdf.Add(ParameterNames.FilePath, dlg.FileNames);
+                        dialogs.ShowDialog(DialogNames.HomePageBatchProcessingDialog, batesNumberspdf, e => { });
+                        break;
+                    case PDFFnType.Background:
+                        DialogParameters backgroundpdf = new DialogParameters();
+                        backgroundpdf.Add(ParameterNames.BatchProcessing_Name, "4");
+                        HomePageBatchProcessingDialogModel.FilePaths = dlg.FileNames.ToList();
+                        HomePageBatchProcessingDialogModel.BatchProcessingIndex = 4;
+                        backgroundpdf.Add(ParameterNames.FilePath, dlg.FileNames);
+                        dialogs.ShowDialog(DialogNames.HomePageBatchProcessingDialog, backgroundpdf, e => { });
+                        break;
+                    case PDFFnType.WaterMark:
+                        DialogParameters watermarkpdf = new DialogParameters();
+                        watermarkpdf.Add(ParameterNames.BatchProcessing_Name, "3");
+                        HomePageBatchProcessingDialogModel.FilePaths = dlg.FileNames.ToList();
+                        HomePageBatchProcessingDialogModel.BatchProcessingIndex = 3;
+                        watermarkpdf.Add(ParameterNames.FilePath, dlg.FileNames);
+                        dialogs.ShowDialog(DialogNames.HomePageBatchProcessingDialog, watermarkpdf, e => { });
+                        break;
+                }
+
+            }
+        }
+
+
+
+        private void Expend()
+        {
+            IsExpendTools = !IsExpendTools;
+            ExpendToolsHanlder?.Invoke(null, IsExpendTools);
+        }
+
+        private void OpenMenu(object obj)
+        {
+            var menu = App.Current.FindResource("ExpendToolsContextMenu") as ContextMenu;
+            var btn = obj as Button;
+            if (menu != null && btn != null)
+            {
+                if(menu.Items.Count == 1)
+                {
+                  var item = menu.Items[0] as MenuItem;
+                    if(_isExpendTools)
+                    {
+                        item.Header = "收缩";
+                    }
+                    else
+                    {
+                        item.Header = "展开";
+                    }
+
+                    item.Command = ExpendCommand;
+                    //btn.ContextMenu = menu;
+                    menu.PlacementTarget = btn;
+                    menu.IsOpen = true;
+                }
+            }
+        }
+
+
+
+    }
+}

+ 1 - 1
PDF Office/Views/Dialog/ConverterDialogs/ConverterCSVDialog.xaml

@@ -54,7 +54,7 @@
                             <cus:WritableComboBox
                                 x:Name="PageRangeComboBox"
                                 Width="228"
-                                Height="28.55"
+                                Height="32"
                                 Margin="0,4,0,0"
                                 HorizontalAlignment="Left"
                                 IsCurrentPage="True"

+ 6 - 3
PDF Office/Views/Dialog/ConverterDialogs/ConverterExcelDialog.xaml

@@ -9,9 +9,9 @@
              xmlns:pageeditdialogs="clr-namespace:PDF_Office.ViewModels.Dialog.PageEditDialogs"
              xmlns:prism="http://prismlibrary.com/"           
              Width="529"
-             Height="416"
+             Height="482"
              d:DataContext="{d:DesignInstance Type=pageeditdialogs:ExtractDialogViewModel}"
-             d:DesignHeight="416"
+             d:DesignHeight="482"
              d:DesignWidth="529"
              prism:Dialog.WindowStyle="{StaticResource DialogWindowStyle}"
              prism:ViewModelLocator.AutoWireViewModel="True"
@@ -45,6 +45,9 @@
                                     <ComboBoxItem Content="支持按页面提取表格到单独的工作表"/>
                                     <ComboBoxItem Content="支持将所有表格提取到一个工作表"/>
                                 </ComboBox>
+                                <RadioButton Margin="0,10,0,0" Name="OnlyTextRadioBtn" Command="{Binding RadioButtonCommand}" CommandParameter="{Binding ElementName=OnlyTextRadioBtn,Path=Name}">
+                                    <TextBlock Text="只提取文字"></TextBlock>
+                                </RadioButton>
                             </StackPanel>
                         </StackPanel>
                         <StackPanel Orientation="Vertical"  Margin="0,16,0,0">
@@ -58,7 +61,7 @@
                             </StackPanel>
                             <StackPanel Orientation="Vertical" Margin="0,14,0,0">
                                 <TextBlock Text="页面范围" Height="20" Width="48" HorizontalAlignment="Left"/>
-                                <cus:WritableComboBox x:Name="PageRangeComboBox" Margin="0,4,0,0" Width="228" Height="28.55" HorizontalAlignment="Left" IsCurrentPage="True" Text="{Binding PageRangeText, Mode=TwoWay}"  SelectedIndex="{Binding PageRangeSelectIndex, Mode=TwoWay}" Loaded="PageRangeComboBox_Loaded">
+                                <cus:WritableComboBox x:Name="PageRangeComboBox" Margin="0,4,0,0" Width="228" Height="32" HorizontalAlignment="Left" IsCurrentPage="True" Text="{Binding PageRangeText, Mode=TwoWay}"  SelectedIndex="{Binding PageRangeSelectIndex, Mode=TwoWay}" Loaded="PageRangeComboBox_Loaded">
                                     <i:Interaction.Triggers>
                                         <i:EventTrigger EventName="SelectionChanged">
                                             <i:InvokeCommandAction Command="{Binding CmbPageSelectionChanged}" CommandParameter="{Binding ElementName=ConverterPreview}" />

+ 1 - 1
PDF Office/Views/Dialog/ConverterDialogs/ConverterHTMLDialog.xaml

@@ -38,7 +38,7 @@
                         </StackPanel>
                         <StackPanel Orientation="Vertical" Margin="0,14,0,0">
                             <TextBlock Text="页面范围" Height="20" Width="48" HorizontalAlignment="Left"/>
-                            <cus:WritableComboBox x:Name="PageRangeComboBox" Margin="0,4,0,0" Width="228" Height="28.55" HorizontalAlignment="Left" IsCurrentPage="True" Text="{Binding PageRangeText, Mode=TwoWay}"  SelectedIndex="{Binding PageRangeSelectIndex, Mode=TwoWay}" Loaded="PageRangeComboBox_Loaded">
+                            <cus:WritableComboBox x:Name="PageRangeComboBox" Margin="0,4,0,0" Width="228" Height="32" HorizontalAlignment="Left" IsCurrentPage="True" Text="{Binding PageRangeText, Mode=TwoWay}"  SelectedIndex="{Binding PageRangeSelectIndex, Mode=TwoWay}" Loaded="PageRangeComboBox_Loaded">
                                 <i:Interaction.Triggers>
                                     <i:EventTrigger EventName="SelectionChanged">
                                         <i:InvokeCommandAction Command="{Binding CmbPageSelectionChanged}" CommandParameter="{Binding ElementName=ConverterPreview}" />

+ 1 - 1
PDF Office/Views/Dialog/ConverterDialogs/ConverterPPTDialog.xaml

@@ -38,7 +38,7 @@
                         </StackPanel>
                         <StackPanel Orientation="Vertical" Margin="0,14,0,0">
                             <TextBlock Text="页面范围" Height="20" Width="48" HorizontalAlignment="Left"/>
-                            <cus:WritableComboBox x:Name="PageRangeComboBox" Margin="0,4,0,0" Width="228" Height="28.55" HorizontalAlignment="Left" IsCurrentPage="True" Text="{Binding PageRangeText, Mode=TwoWay}"  SelectedIndex="{Binding PageRangeSelectIndex, Mode=TwoWay}" Loaded="PageRangeComboBox_Loaded">
+                            <cus:WritableComboBox x:Name="PageRangeComboBox" Margin="0,4,0,0" Width="228" Height="32" HorizontalAlignment="Left" IsCurrentPage="True" Text="{Binding PageRangeText, Mode=TwoWay}"  SelectedIndex="{Binding PageRangeSelectIndex, Mode=TwoWay}" Loaded="PageRangeComboBox_Loaded">
                                 <i:Interaction.Triggers>
                                     <i:EventTrigger EventName="SelectionChanged">
                                         <i:InvokeCommandAction Command="{Binding CmbPageSelectionChanged}" CommandParameter="{Binding ElementName=ConverterPreview}" />

+ 1 - 1
PDF Office/Views/Dialog/ConverterDialogs/ConverterRTFDialog.xaml

@@ -38,7 +38,7 @@
                         </StackPanel>
                         <StackPanel Orientation="Vertical" Margin="0,14,0,0">
                             <TextBlock Text="页面范围" Height="20" Width="48" HorizontalAlignment="Left"/>
-                            <cus:WritableComboBox x:Name="PageRangeComboBox" Margin="0,4,0,0" Width="228" Height="28.55" HorizontalAlignment="Left" IsCurrentPage="True" Text="{Binding PageRangeText, Mode=TwoWay}"  SelectedIndex="{Binding PageRangeSelectIndex, Mode=TwoWay}" Loaded="PageRangeComboBox_Loaded">
+                            <cus:WritableComboBox x:Name="PageRangeComboBox" Margin="0,4,0,0" Width="228" Height="32" HorizontalAlignment="Left" IsCurrentPage="True" Text="{Binding PageRangeText, Mode=TwoWay}"  SelectedIndex="{Binding PageRangeSelectIndex, Mode=TwoWay}" Loaded="PageRangeComboBox_Loaded">
                                 <i:Interaction.Triggers>
                                     <i:EventTrigger EventName="SelectionChanged">
                                         <i:InvokeCommandAction Command="{Binding CmbPageSelectionChanged}" CommandParameter="{Binding ElementName=ConverterPreview}" />

+ 1 - 1
PDF Office/Views/Dialog/ConverterDialogs/ConverterTextDialog.xaml

@@ -38,7 +38,7 @@
                         </StackPanel>
                         <StackPanel Orientation="Vertical" Margin="0,14,0,0">
                             <TextBlock Text="页面范围" Height="20" Width="48" HorizontalAlignment="Left"/>
-                            <cus:WritableComboBox x:Name="PageRangeComboBox" Margin="0,4,0,0" Width="228" Height="28.55" HorizontalAlignment="Left" IsCurrentPage="True" Text="{Binding PageRangeText, Mode=TwoWay}"  SelectedIndex="{Binding PageRangeSelectIndex, Mode=TwoWay}" Loaded="PageRangeComboBox_Loaded">
+                            <cus:WritableComboBox x:Name="PageRangeComboBox" Margin="0,4,0,0" Width="228" Height="32" HorizontalAlignment="Left" IsCurrentPage="True" Text="{Binding PageRangeText, Mode=TwoWay}"  SelectedIndex="{Binding PageRangeSelectIndex, Mode=TwoWay}" Loaded="PageRangeComboBox_Loaded">
                                 <i:Interaction.Triggers>
                                     <i:EventTrigger EventName="SelectionChanged">
                                         <i:InvokeCommandAction Command="{Binding CmbPageSelectionChanged}" CommandParameter="{Binding ElementName=ConverterPreview}" />

+ 1 - 1
PDF Office/Views/Dialog/ConverterDialogs/ConverterWordDialog.xaml

@@ -50,7 +50,7 @@
                             </StackPanel>
                             <StackPanel Orientation="Vertical" Margin="0,14,0,0">
                                 <TextBlock Text="页面范围" Height="20" Width="48" HorizontalAlignment="Left"/>
-                                <cus:WritableComboBox x:Name="PageRangeComboBox" Margin="0,4,0,0" Width="228" Height="28.55" HorizontalAlignment="Left" IsCurrentPage="True" Text="{Binding PageRangeText, Mode=TwoWay}"  SelectedIndex="{Binding PageRangeSelectIndex, Mode=TwoWay}" Loaded="PageRangeComboBox_Loaded">
+                                <cus:WritableComboBox x:Name="PageRangeComboBox" Margin="0,4,0,0" Width="228" Height="32" HorizontalAlignment="Left" IsCurrentPage="True" Text="{Binding PageRangeText, Mode=TwoWay}"  SelectedIndex="{Binding PageRangeSelectIndex, Mode=TwoWay}" Loaded="PageRangeComboBox_Loaded">
                                     <i:Interaction.Triggers>
                                         <i:EventTrigger EventName="SelectionChanged">
                                             <i:InvokeCommandAction Command="{Binding CmbPageSelectionChanged}" CommandParameter="{Binding ElementName=ConverterPreview}" />

+ 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>

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


Vissa filer visades inte eftersom för många filer har ändrats