Browse Source

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

# Conflicts:
#	PDF Office/App.xaml.cs
#	PDF Office/Helper/CacheFilePath.cs
#	PDF Office/Properties/Settings.Designer.cs
#	PDF Office/Properties/Settings.settings
zhuyi 2 năm trước cách đây
mục cha
commit
ece36f1bea
100 tập tin đã thay đổi với 9688 bổ sung558 xóa
  1. 28 15
      PDF Office/App.config
  2. 1 0
      PDF Office/App.xaml
  3. 52 16
      PDF Office/App.xaml.cs
  4. 16 9
      PDF Office/CustomControl/CommonWritableComboBox.xaml
  5. 18 3
      PDF Office/CustomControl/CommonWritableComboBox.xaml.cs
  6. 6 1
      PDF Office/CustomControl/CompositeControl/ColorContent.xaml
  7. 25 0
      PDF Office/CustomControl/CompositeControl/ColorSubContent.xaml
  8. 58 0
      PDF Office/CustomControl/CompositeControl/ColorSubContent.xaml.cs
  9. 69 0
      PDF Office/CustomControl/CompositeControl/SlidComboControl.xaml
  10. 92 0
      PDF Office/CustomControl/CompositeControl/SlidComboControl.xaml.cs
  11. 1 1
      PDF Office/CustomControl/NumericUpDown.xaml
  12. 1 1
      PDF Office/CustomControl/NumericUpDown.xaml.cs
  13. 33 0
      PDF Office/CustomControl/PageControl.xaml
  14. 28 0
      PDF Office/CustomControl/PageControl.xaml.cs
  15. 1 0
      PDF Office/CustomControl/WritableComboBox.xaml
  16. 1 1
      PDF Office/CustomControl/WritableComboBox.xaml.cs
  17. 211 28
      PDF Office/EventAggregators/EditToolsEvent.cs
  18. 84 17
      PDF Office/Helper/CacheFilePath.cs
  19. 163 0
      PDF Office/Helper/EditToolsHelper.cs
  20. 186 0
      PDF Office/Helper/ObservableDictionary.cs
  21. 0 2
      PDF Office/Helper/ToolMethod.cs
  22. 107 0
      PDF Office/Model/EditTools/Background/BackgroundCreateModel.cs
  23. 12 0
      PDF Office/Model/EditTools/Background/BackgroundTemplateListModel.cs
  24. 133 0
      PDF Office/Model/EditTools/Watermark/WatermarkCreateModel.cs
  25. 13 0
      PDF Office/Model/EditTools/Watermark/WatermarkTemplateListModel.cs
  26. 45 0
      PDF Office/Model/PropertyPanel/AnnotPanel/FontStyleItem.cs
  27. 27 0
      PDF Office/Model/RegionNames.cs
  28. 129 0
      PDF Office/PDF Office.csproj
  29. 46 0
      PDF Office/Properties/Settings.Designer.cs
  30. 12 0
      PDF Office/Properties/Settings.settings
  31. BIN
      PDF Office/Resources/EditTools/watermark_bg.png
  32. 2 2
      PDF Office/SDKLisence.xml
  33. 28 0
      PDF Office/Settings.cs
  34. 33 0
      PDF Office/StyleAndTemplateList.txt
  35. 5 1
      PDF Office/Styles/CheckBoxStyle.xaml
  36. 383 0
      PDF Office/Styles/ContextMenuTextEditStyle.xaml
  37. 41 0
      PDF Office/Styles/ListBoxStyle.xaml
  38. 3 0
      PDF Office/ViewModels/Dialog/ConverterDialogs/ConverterCSVDialogViewModel.cs
  39. 1 0
      PDF Office/ViewModels/Dialog/ConverterDialogs/ConverterExcelDialogViewModel.cs
  40. 1 0
      PDF Office/ViewModels/Dialog/ConverterDialogs/ConverterHTMLDialogViewModel.cs
  41. 1 0
      PDF Office/ViewModels/Dialog/ConverterDialogs/ConverterImgDialogViewModel.cs
  42. 1 0
      PDF Office/ViewModels/Dialog/ConverterDialogs/ConverterPPTDialogViewModel.cs
  43. 1 0
      PDF Office/ViewModels/Dialog/ConverterDialogs/ConverterRTFDialogViewModel.cs
  44. 1 0
      PDF Office/ViewModels/Dialog/ConverterDialogs/ConverterTextDialogViewModel.cs
  45. 1 0
      PDF Office/ViewModels/Dialog/ConverterDialogs/ConverterWordDialogViewModel.cs
  46. 1 0
      PDF Office/ViewModels/Dialog/HomePageToolsDialogs/HomePageExtractDialogViewModel.cs
  47. 3 2
      PDF Office/ViewModels/Dialog/HomePageToolsDialogs/HomePageSplitDialogViewModel.cs
  48. 226 95
      PDF Office/ViewModels/EditTools/Background/BackgroundContentViewModel.cs
  49. 160 11
      PDF Office/ViewModels/EditTools/Background/BackgroundCreateBaseContentViewModel.cs
  50. 506 2
      PDF Office/ViewModels/EditTools/Background/BackgroundCreateColorContentViewModel.cs
  51. 495 2
      PDF Office/ViewModels/EditTools/Background/BackgroundCreateFileContentViewModel.cs
  52. 268 0
      PDF Office/ViewModels/EditTools/Background/BackgroundDocumentContentViewModel.cs
  53. 141 92
      PDF Office/ViewModels/EditTools/Background/BackgroundTemplateListBaseContentViewModel.cs
  54. 249 25
      PDF Office/ViewModels/EditTools/Background/BackgroundTemplateListColorContentViewModel.cs
  55. 225 2
      PDF Office/ViewModels/EditTools/Background/BackgroundTemplateListFileContentViewModel.cs
  56. 159 0
      PDF Office/ViewModels/EditTools/Bates/BatesContentViewModel.cs
  57. 35 0
      PDF Office/ViewModels/EditTools/Bates/BatesCreateContentViewModel.cs
  58. 35 0
      PDF Office/ViewModels/EditTools/Bates/BatesDocumentContentViewModel.cs
  59. 44 0
      PDF Office/ViewModels/EditTools/Bates/BatesTemplateListContentViewModel.cs
  60. 160 0
      PDF Office/ViewModels/EditTools/HeaderFooter/HeaderFooterContentViewModel.cs
  61. 33 0
      PDF Office/ViewModels/EditTools/HeaderFooter/HeaderFooterCreateContentViewModel.cs
  62. 33 0
      PDF Office/ViewModels/EditTools/HeaderFooter/HeaderFooterDocumentContentViewModel.cs
  63. 43 0
      PDF Office/ViewModels/EditTools/HeaderFooter/HeaderFooterTemplateListContentViewModel.cs
  64. 64 0
      PDF Office/ViewModels/EditTools/Redaction/RedactionContentViewModel.cs
  65. 90 0
      PDF Office/ViewModels/EditTools/Redaction/RedactionDocumentContentViewModel.cs
  66. 230 4
      PDF Office/ViewModels/EditTools/Watermark/WatermarkContentViewModel.cs
  67. 235 3
      PDF Office/ViewModels/EditTools/Watermark/WatermarkCreateBaseContentViewModel.cs
  68. 742 3
      PDF Office/ViewModels/EditTools/Watermark/WatermarkCreateFileContentViewModel.cs
  69. 843 4
      PDF Office/ViewModels/EditTools/Watermark/WatermarkCreateTextContentViewModel.cs
  70. 247 0
      PDF Office/ViewModels/EditTools/Watermark/WatermarkDocumentContentViewModel.cs
  71. 162 3
      PDF Office/ViewModels/EditTools/Watermark/WatermarkTemplateListBaseContentViewModel.cs
  72. 307 3
      PDF Office/ViewModels/EditTools/Watermark/WatermarkTemplateListFileContentViewModel.cs
  73. 258 3
      PDF Office/ViewModels/EditTools/Watermark/WatermarkTemplateListTextContentViewModel.cs
  74. 1 35
      PDF Office/ViewModels/PropertyPanel/AnnotPanel/FreetextAnnotPropertyViewModel.cs
  75. 648 1
      PDF Office/ViewModels/PropertyPanel/TextEditPropertyViewModel.cs
  76. 70 3
      PDF Office/ViewModels/Tools/TextEditToolContentViewModel.cs
  77. 4 1
      PDF Office/ViewModels/Tools/ToolsBarContentViewModel.cs
  78. 53 18
      PDF Office/ViewModels/ViewContentViewModel.cs
  79. 1 1
      PDF Office/Views/BottomToolContent.xaml
  80. 0 1
      PDF Office/Views/Dialog/HomePageToolsDialogs/HomePageInsertDialog.xaml
  81. 1 1
      PDF Office/Views/Dialog/ToolsDialogs/CompressDialogs/CompressDialog.xaml
  82. 4 4
      PDF Office/Views/Dialog/ToolsDialogs/SaftyDialogs/SetPasswordDialog.xaml
  83. 7 26
      PDF Office/Views/EditTools/Background/BackgroundContent.xaml
  84. 17 3
      PDF Office/Views/EditTools/Background/BackgroundCreateBaseContent.xaml
  85. 44 27
      PDF Office/Views/EditTools/Background/BackgroundCreateColorContent.xaml
  86. 15 1
      PDF Office/Views/EditTools/Background/BackgroundCreateColorContent.xaml.cs
  87. 76 76
      PDF Office/Views/EditTools/Background/BackgroundCreateFileContent.xaml
  88. 36 0
      PDF Office/Views/EditTools/Background/BackgroundDocumentContent.xaml
  89. 25 0
      PDF Office/Views/EditTools/Background/BackgroundDocumentContent.xaml.cs
  90. 78 4
      PDF Office/Views/EditTools/Background/BackgroundTemplateListColorContent.xaml
  91. 63 1
      PDF Office/Views/EditTools/Background/BackgroundTemplateListColorContent.xaml.cs
  92. 76 3
      PDF Office/Views/EditTools/Background/BackgroundTemplateListFileContent.xaml
  93. 61 1
      PDF Office/Views/EditTools/Background/BackgroundTemplateListFileContent.xaml.cs
  94. 78 0
      PDF Office/Views/EditTools/Bates/BatesContent.xaml
  95. 15 0
      PDF Office/Views/EditTools/Bates/BatesContent.xaml.cs
  96. 153 0
      PDF Office/Views/EditTools/Bates/BatesCreateContent.xaml
  97. 15 0
      PDF Office/Views/EditTools/Bates/BatesCreateContent.xaml.cs
  98. 38 0
      PDF Office/Views/EditTools/Bates/BatesDocumentContent.xaml
  99. 15 0
      PDF Office/Views/EditTools/Bates/BatesDocumentContent.xaml.cs
  100. 0 0
      PDF Office/Views/EditTools/Bates/BatesTemplateListContent.xaml

+ 28 - 15
PDF Office/App.config

@@ -1,16 +1,29 @@
-<?xml version="1.0" encoding="utf-8"?>
-<configuration>
-    <configSections>
-    </configSections>
-    <startup> 
-        <supportedRuntime version="v4.0" sku=".NETFramework,Version=v4.6.2" />
-    </startup>
-  <runtime>
-    <assemblyBinding xmlns="urn:schemas-microsoft-com:asm.v1">
-      <dependentAssembly>
-        <assemblyIdentity name="Newtonsoft.Json" publicKeyToken="30ad4fe6b2a6aeed" culture="neutral" />
-        <bindingRedirect oldVersion="0.0.0.0-13.0.0.0" newVersion="13.0.0.0" />
-      </dependentAssembly>
-    </assemblyBinding>
-  </runtime>
+<?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" >
+            <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>
+    <startup> 
+        <supportedRuntime version="v4.0" sku=".NETFramework,Version=v4.6.2" />
+    </startup>
+  <runtime>
+    <assemblyBinding xmlns="urn:schemas-microsoft-com:asm.v1">
+      <dependentAssembly>
+        <assemblyIdentity name="Newtonsoft.Json" publicKeyToken="30ad4fe6b2a6aeed" culture="neutral" />
+        <bindingRedirect oldVersion="0.0.0.0-13.0.0.0" newVersion="13.0.0.0" />
+      </dependentAssembly>
+    </assemblyBinding>
+  </runtime>
+  <userSettings>
+    <PDF_Office.Properties.Settings>
+      <setting name="BackgroundIndex" serializeAs="String">
+        <value>0</value>
+      </setting>
+      <setting name="WatermarkIndex" serializeAs="String">
+        <value>0</value>
+      </setting>
+    </PDF_Office.Properties.Settings>
+  </userSettings>
 </configuration>

+ 1 - 0
PDF Office/App.xaml

@@ -16,6 +16,7 @@
                 <ResourceDictionary Source="pack://application:,,,/PDF Office;component/Styles/CustomBtnStyle.xaml" />
                 <ResourceDictionary Source="pack://application:,,,/PDF Office;component/Styles/ContainerStyles/ComboxStyle/ComboxItemStyle.xaml" />
                 <ResourceDictionary Source="pack://application:,,,/PDF Office;component/Styles/PathButtonStyle.xaml"/>
+                <ResourceDictionary Source="pack://application:,,,/PDF Office;component/Styles/ContextMenuTextEditStyle.xaml"/>
                 <!--  Enable show customctrol's correctly UI in Xaml Designer  -->
                 <ResourceDictionary Source="pack://application:,,,/PDF Office;component/Themes/Generic.xaml" />
             </ResourceDictionary.MergedDictionaries>

+ 52 - 16
PDF Office/App.xaml.cs

@@ -42,6 +42,11 @@ using PDF_Office.Helper;
 using PDF_Office.Views.Dialog.HomePageToolsDialogs.HomePageBatchProcessing.HomePageConverter;
 using PDF_Office.Views.EditTools.Watermark; 
 using PDF_Office.Views.EditTools.Background;
+using PDF_Office.Views.EditTools.Bates;
+using PDF_Office.Views.EditTools.HeaderFooter;
+using PDF_Office.Views.EditTools.Redaction;
+
+
 
 namespace PDF_Office
 {
@@ -70,15 +75,42 @@ namespace PDF_Office
         var countryCode = RegionInfo.CurrentRegion.TwoLetterISORegionName;//上传国家信息
         AppCenter.SetCountryCode(countryCode);
 #endif
+        }
+
+        private void InitSettings()
+        {
+            if (Settings.Default.RecentOpenFiles == null)
+                Settings.Default.RecentOpenFiles = new RecentOpenFiles();
+
+            if (Settings.Default.AppProperties == null)
+                Settings.Default.AppProperties = new PDFSettings.APPSettingProperties();
+
+            if (Settings.Default.AllPDFToolsList == null)
+                Settings.Default.AllPDFToolsList = new PDFSettings.AllPDFToolsList();
+
+            if (Settings.Default.QuickPDFToolsList == null)
+                Settings.Default.QuickPDFToolsList = new PDFSettings.QuickPDFToolsList();
+
+        }
+
+        protected override void OnStartup(StartupEventArgs e)
+        {
             LicenseVerify();
 
             InitSettings();
+
             CachePath = CacheFilePath.Instance;
+            //清除临时文件
+            CacheFilePath.Instance.ClearDeleteFiles();
+
             try
             {
                 DirectoryInfo info = new DirectoryInfo(CurrentPath);
+                //避免因存在同名文件,导致无法创建文件夹
                 if (File.Exists(CurrentPath))
+                {
                     File.Delete(CurrentPath);
+                }
                 if (!info.Exists)
                 {
                     info.Create();
@@ -87,22 +119,8 @@ namespace PDF_Office
             catch (Exception ex)
             {
             }
-        }
-
-        private void InitSettings()
-        {
-            if (Settings.Default.RecentOpenFiles == null)
-                Settings.Default.RecentOpenFiles = new RecentOpenFiles();
-
-            if (Settings.Default.AppProperties == null)
-                Settings.Default.AppProperties = new PDFSettings.APPSettingProperties();
-
-            if (Settings.Default.AllPDFToolsList == null)
-                Settings.Default.AllPDFToolsList = new PDFSettings.AllPDFToolsList();
-
-            if (Settings.Default.QuickPDFToolsList == null)
-                Settings.Default.QuickPDFToolsList = new PDFSettings.QuickPDFToolsList();
 
+            base.OnStartup(e);
         }
 
         /// <summary>
@@ -139,6 +157,7 @@ namespace PDF_Office
             containerRegistry.RegisterForNavigation<ThemesContent>();
             containerRegistry.RegisterForNavigation<ReadModeContent>();
 
+
             containerRegistry.RegisterForNavigation<HomePagePrinterModSizeContent>();
             containerRegistry.RegisterForNavigation<HomePagePrinterModPosterContent>();
             containerRegistry.RegisterForNavigation<HomePagePrinterModMultipleContent>();
@@ -153,13 +172,20 @@ namespace PDF_Office
             containerRegistry.RegisterForNavigation<HomePageConverterExcel>();
             containerRegistry.RegisterForNavigation<WatermarkContent>();
             containerRegistry.RegisterForNavigation<BackgroundContent>();
-            containerRegistry.RegisterForNavigation<BackgroundContent>();
             containerRegistry.RegisterForNavigation<BackgroundTemplateListBaseContent>();
             containerRegistry.RegisterForNavigation<BackgroundTemplateListColorContent>();
             containerRegistry.RegisterForNavigation<BackgroundTemplateListFileContent>();
             containerRegistry.RegisterForNavigation<BackgroundCreateBaseContent>();
             containerRegistry.RegisterForNavigation<BackgroundCreateColorContent>();
             containerRegistry.RegisterForNavigation<BackgroundCreateFileContent>();
+            containerRegistry.RegisterForNavigation<BackgroundDocumentContent>();
+            containerRegistry.RegisterForNavigation<WatermarkTemplateListBaseContent>();
+            containerRegistry.RegisterForNavigation<WatermarkTemplateListTextContent>();
+            containerRegistry.RegisterForNavigation<WatermarkTemplateListFileContent>();
+            containerRegistry.RegisterForNavigation<WatermarkCreateBaseContent>();
+            containerRegistry.RegisterForNavigation<WatermarkCreateTextContent>();
+            containerRegistry.RegisterForNavigation<WatermarkCreateFileContent>();
+            containerRegistry.RegisterForNavigation<WatermarkDocumentContent>();
             containerRegistry.RegisterForNavigation<HomePagePrinterModMultipleContent>();
             containerRegistry.RegisterForNavigation<FreehandAnnotProperty>();
             containerRegistry.RegisterForNavigation<FreetextAnnotProperty>();
@@ -169,6 +195,16 @@ namespace PDF_Office
             containerRegistry.RegisterForNavigation<StampAnnotProperty>();
             containerRegistry.RegisterForNavigation<TextAnnotProperty>();
             containerRegistry.RegisterForNavigation<TextEditProperty>();
+            containerRegistry.RegisterForNavigation<BatesContent>();
+            containerRegistry.RegisterForNavigation<BatesTemplateListContent>();
+            containerRegistry.RegisterForNavigation<BatesCreateContent>();
+            containerRegistry.RegisterForNavigation<BatesDocumentContent>();
+            containerRegistry.RegisterForNavigation<HeaderFooterContent>();
+            containerRegistry.RegisterForNavigation<HeaderFooterTemplateListContent>();
+            containerRegistry.RegisterForNavigation<HeaderFooterCreateContent>();
+            containerRegistry.RegisterForNavigation<HeaderFooterDocumentContent>();
+            containerRegistry.RegisterForNavigation<RedactionContent>();
+            containerRegistry.RegisterForNavigation<RedactionDocumentContent>();
             //填写与签名
             containerRegistry.RegisterForNavigation<FillAndSignContent>();
             containerRegistry.RegisterForNavigation<DateFillProperty>();

+ 16 - 9
PDF Office/CustomControl/CommonWritableComboBox.xaml

@@ -6,27 +6,34 @@
              xmlns:local="clr-namespace:PDF_Office.CustomControl"
              mc:Ignorable="d" 
               d:DesignHeight="32" d:DesignWidth="66">
+    <Border CornerRadius="1" BorderBrush="Black" BorderThickness="1,1,1,1" Panel.ZIndex="2">
     <Grid>
         <Grid.ColumnDefinitions>
             <ColumnDefinition Width="*"></ColumnDefinition>
             <ColumnDefinition Width="16"></ColumnDefinition>
         </Grid.ColumnDefinitions>
-        <TextBox Name="TextBox_Num"
-                MinHeight="32"
+            <TextBox Name="TextBox_Num"
+                MinHeight="28"
                 Grid.Column="0"
                 Padding="16,0,0,0"
                 VerticalContentAlignment="Center"
-                Background="Transparent"
+                Background="#F3F3F3"
                 BorderThickness="0"
-                FontFamily="{Binding RelativeSource={RelativeSource Mode=FindAncestor, AncestorType=local:NumericUpDown}, Path=FontFamily}"
-                FontSize="{Binding RelativeSource={RelativeSource Mode=FindAncestor, AncestorType=local:NumericUpDown}, Path=FontSize}"
-                Foreground="{Binding RelativeSource={RelativeSource Mode=FindAncestor, AncestorType=local:NumericUpDown}, Path=Foreground}"
+                FontFamily="{Binding RelativeSource={RelativeSource Mode=FindAncestor, AncestorType=local:CommonWritableComboBox}, Path=FontFamily}"
+                FontSize="{Binding RelativeSource={RelativeSource Mode=FindAncestor, AncestorType=local:CommonWritableComboBox}, Path=FontSize}"
+                Foreground="{Binding RelativeSource={RelativeSource Mode=FindAncestor, AncestorType=local:CommonWritableComboBox}, Path=Foreground}"
                 InputMethod.IsInputMethodEnabled="False"
                 PreviewTextInput="CountTextBox_PreviewTextInput"
-                Text="1"
+                Text="{Binding RelativeSource={RelativeSource Mode=FindAncestor, AncestorType=local:CommonWritableComboBox}, Path=Text}"
                 TextAlignment="Left"
                 KeyDown="CurrentPage_KeyDown"
-                TextChanged="TextBox_Num_TextChanged" />
-        <ComboBox Name="ComboBox_Type" MinHeight="32" Width="16" HorizontalAlignment="Right" BorderBrush="Transparent" BorderThickness="00" Grid.Column="1" SelectionChanged="ComboBox_SelectionChanged"></ComboBox>
+                TextChanged="TextBox_Num_TextChanged"
+                 Panel.ZIndex="1">
+         
+            </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>
+
     </Grid>
+    </Border>
 </UserControl>

+ 18 - 3
PDF Office/CustomControl/CommonWritableComboBox.xaml.cs

@@ -14,6 +14,7 @@ using System.Windows.Media;
 using System.Windows.Media.Imaging;
 using System.Windows.Navigation;
 using System.Windows.Shapes;
+using static ImTools.ImMap;
 
 namespace PDF_Office.CustomControl
 {
@@ -33,7 +34,7 @@ namespace PDF_Office.CustomControl
         }
 
         public static readonly DependencyProperty TextProperty =
-            DependencyProperty.Register("Text", typeof(string), typeof(CommonWritableComboBox), new PropertyMetadata(""));
+            DependencyProperty.Register("Text", typeof(string), typeof(CommonWritableComboBox), new PropertyMetadata("0"));
 
 
         /// <summary>
@@ -51,11 +52,11 @@ namespace PDF_Office.CustomControl
                 else if (value < Minimum)
                 {
                     SetValue(ValueProperty, Minimum);
+                    
                 }
                 else
                 {
                     SetValue(ValueProperty, value);
-                    //TextBox_Num.Text = Value.ToString();
                 }
             }
         }
@@ -117,7 +118,7 @@ namespace PDF_Office.CustomControl
                 this.TextBox_Num.Text ="0";
             }
 
-            if (!int.TryParse(this.TextBox_Num.Text, out _)&&!int.TryParse(this.TextBox_Num.Text.Replace(Unit, ""), out _)) { this.TextBox_Num.Text = "0"; }
+            if (!int.TryParse(this.TextBox_Num.Text, out _)&&!int.TryParse(this.TextBox_Num.Text.Replace(Unit, ""), out _)) { this.TextBox_Num.Text = Text; }
             else{ 
             Text = this.TextBox_Num.Text;
             Value = int.Parse(this.TextBox_Num.Text.Replace(" ", "").Replace(Unit, ""));
@@ -140,8 +141,22 @@ namespace PDF_Office.CustomControl
         {
             if (e.Key == Key.Enter)
             {
+                if (Value > Maximum)
+                {
+                    this.TextBox_Num.Text = Maximum.ToString();
+                }
+                else if (Value < Minimum)
+                {
+                    this.TextBox_Num.Text = Minimum.ToString();
+
+                }
+                else
+                {
+                    this.TextBox_Num.Text=Value.ToString();
+                }
                 this.TextBox_Num.Text = this.TextBox_Num.Text.Replace(" " , "").Replace(Unit,"")+" "+Unit;
                 
+
             }
         }
     }

+ 6 - 1
PDF Office/CustomControl/CompositeControl/ColorContent.xaml

@@ -47,7 +47,12 @@
         <Border Width="56" Height="32" Grid.Column="1" Margin="0,0,5,0" BorderThickness="1" CornerRadius="4" BorderBrush="#E2E3E6"  HorizontalAlignment="Right" >
             <StackPanel Orientation="Horizontal">
 
-                <Ellipse x:Name="ElcustomColor" Fill="Transparent" Width="20" Height="20" PreviewMouseLeftButtonDown="ElcustomColor_PreviewMouseLeftButtonDown"></Ellipse>
+                <Ellipse x:Name="ElcustomColor" Fill="Transparent" Width="20" Height="20" StrokeThickness="1"
+                         PreviewMouseLeftButtonDown="ElcustomColor_PreviewMouseLeftButtonDown">
+                    <Ellipse.Stroke>
+                        <SolidColorBrush Color="#000000" Opacity="0.1"/>
+                    </Ellipse.Stroke>
+                </Ellipse>
                 <cus:ColorDropBox x:Name="ColorDropPicker" SelectedColorChanged="ColorDropPicker_SelectedColorChanged">
                 </cus:ColorDropBox>
             </StackPanel>

+ 25 - 0
PDF Office/CustomControl/CompositeControl/ColorSubContent.xaml

@@ -0,0 +1,25 @@
+<UserControl x:Class="PDF_Office.CustomControl.CompositeControl.ColorSubContent"
+             xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
+             xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
+             xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006" 
+             xmlns:d="http://schemas.microsoft.com/expression/blend/2008" 
+             xmlns:cus="clr-namespace:PDF_Office.CustomControl"
+             xmlns:local="clr-namespace:PDF_Office.CustomControl.CompositeControl"
+             mc:Ignorable="d" 
+             d:DesignHeight="450" d:DesignWidth="800">
+    <Grid>
+        <Border Width="56" Height="32" Grid.Column="1" Margin="0,0,5,0" BorderThickness="1" CornerRadius="4" BorderBrush="#E2E3E6"  HorizontalAlignment="Right" >
+            <StackPanel Orientation="Horizontal">
+
+                <Ellipse x:Name="ElcustomColor" Fill="Transparent" Width="20" Height="20" StrokeThickness="1"
+                         PreviewMouseLeftButtonDown="ElcustomColor_PreviewMouseLeftButtonDown">
+                    <Ellipse.Stroke>
+                        <SolidColorBrush Color="#000000" Opacity="0.1"/>
+                    </Ellipse.Stroke>
+                </Ellipse>
+                <cus:ColorDropBox x:Name="ColorDropPicker" SelectedColorChanged="ColorDropPicker_SelectedColorChanged">
+                </cus:ColorDropBox>
+            </StackPanel>
+        </Border>
+    </Grid>
+</UserControl>

+ 58 - 0
PDF Office/CustomControl/CompositeControl/ColorSubContent.xaml.cs

@@ -0,0 +1,58 @@
+using System;
+using System.Collections.Generic;
+using System.Linq;
+using System.Text;
+using System.Threading.Tasks;
+using System.Windows;
+using System.Windows.Controls;
+using System.Windows.Data;
+using System.Windows.Documents;
+using System.Windows.Input;
+using System.Windows.Media;
+using System.Windows.Media.Imaging;
+using System.Windows.Navigation;
+using System.Windows.Shapes;
+
+namespace PDF_Office.CustomControl.CompositeControl
+{
+    /// <summary>
+    /// ColorSubContent.xaml 的交互逻辑
+    /// </summary>
+    public partial class ColorSubContent : UserControl
+    {
+        /// <summary>
+        /// 改变颜色后,触发事件
+        /// </summary>
+        public event EventHandler<Color> SelectedColorHandler;
+        public ColorSubContent()
+        {
+            InitializeComponent();
+        }
+
+        private void ElcustomColor_PreviewMouseLeftButtonDown(object sender, MouseButtonEventArgs e)
+        {
+            CurrentColor = (ElcustomColor.Fill as SolidColorBrush).Color;
+            SelectedColorHandler?.Invoke(this, (ElcustomColor.Fill as SolidColorBrush).Color);
+        }
+
+        private void ColorDropPicker_SelectedColorChanged(object sender, Color? e)
+        {
+           
+            SelectedColorHandler?.Invoke(this, e.Value);
+            ElcustomColor.Fill = new SolidColorBrush(e.Value);
+            CurrentColor = e.Value;
+        }
+
+        /// <summary>
+        /// 当前选择的颜色,默认为透明色
+        /// </summary>
+        public Color CurrentColor
+        {
+            get { return (Color)GetValue(CurrentColorProperty); }
+            set { SetValue(CurrentColorProperty, value); }
+        }
+        public static readonly DependencyProperty CurrentColorProperty =
+           DependencyProperty.Register("CurrentColor", typeof(Color), typeof(ColorSubContent), new PropertyMetadata(Colors.Transparent));
+
+    }
+}

+ 69 - 0
PDF Office/CustomControl/CompositeControl/SlidComboControl.xaml

@@ -0,0 +1,69 @@
+<UserControl x:Class="PDF_Office.CustomControl.CompositeControl.SlidComboControl"
+             xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
+             xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
+             xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006" 
+             xmlns:d="http://schemas.microsoft.com/expression/blend/2008" 
+             xmlns:local="clr-namespace:PDF_Office.CustomControl.CompositeControl"
+             mc:Ignorable="d" 
+             x:Name="usercontrol"
+             d:DesignHeight="450" d:DesignWidth="800"
+             Loaded="UserControl_Loaded"
+             >
+    <UserControl.Resources>
+        <ResourceDictionary>
+            <ResourceDictionary.MergedDictionaries>
+                <ResourceDictionary Source="../../Styles/SliderStyle.xaml"></ResourceDictionary>
+                <ResourceDictionary Source="../../Styles/CustomBtnStyle.xaml"/>
+            </ResourceDictionary.MergedDictionaries>
+
+        </ResourceDictionary>
+    </UserControl.Resources>
+    <Grid>
+        <Grid.RowDefinitions>
+            <RowDefinition Height="Auto"/>
+            <RowDefinition />
+        </Grid.RowDefinitions>
+        <TextBlock x:Name="thicknessText" FontFamily="Segoe UI Semibold" FontWeight="SemiBold" FontSize="14" LineHeight="20" Margin="12,14,0,0" >Thickness</TextBlock>
+
+        <Grid Grid.Row="1">
+            <Grid.ColumnDefinitions>
+                <ColumnDefinition Width="*"></ColumnDefinition>
+                <ColumnDefinition Width="auto"></ColumnDefinition>
+            </Grid.ColumnDefinitions>
+
+            <Slider Name="ThicknessSlider" VerticalAlignment="Center" Margin="12,0,0,0" Width="148"  Minimum="0" Maximum="24" IsSelectionRangeEnabled="True" IsMoveToPointEnabled="True" 
+                    Style="{StaticResource RoundThumbSlider}"  TickFrequency="1" IsSnapToTickEnabled="True" Value="{Binding ElementName=usercontrol,Path=Value}" >
+                <Slider.Resources>
+                    <SolidColorBrush x:Key="{x:Static SystemColors.HighlightBrushKey}" Color="#477EDE" />
+                    <SolidColorBrush x:Key="{x:Static SystemColors.ControlDarkDarkBrushKey}" Color="#E2E3E6" />
+                </Slider.Resources>
+            </Slider>
+
+            <Border Grid.Column="1" BorderBrush="#E2E3E6"  Width="80" Height="32" Margin="0,0,11,0"  BorderThickness="0">
+                <Grid>
+                    <ComboBox Name="ThicknessBox" BorderThickness="1" Padding="10" Background="Transparent" BorderBrush="#FFE2E3E6" 
+                                  MaxDropDownHeight="200">
+                        <ComboBox.ItemContainerStyle>
+                            <Style TargetType="{x:Type ComboBoxItem}">
+                                <Setter Property="Padding" Value="10 0 0 0"/>
+                            </Style>
+                        </ComboBox.ItemContainerStyle>
+                        <ComboBoxItem Content="1" Height="32" VerticalContentAlignment="Center" Template="{StaticResource comboxitem}"/>
+                        <ComboBoxItem Content="3" Height="32" VerticalContentAlignment="Center" Template="{StaticResource comboxitem}"/>
+                        <ComboBoxItem Content="6" Height="32" VerticalContentAlignment="Center" Template="{StaticResource comboxitem}"/>
+                        <ComboBoxItem Content="9" Height="32" VerticalContentAlignment="Center" Template="{StaticResource comboxitem}"/>
+                        <ComboBoxItem Content="12" Height="32" VerticalContentAlignment="Center" Template="{StaticResource comboxitem}"/>
+                        <ComboBoxItem Content="15" Height="32" VerticalContentAlignment="Center" Template="{StaticResource comboxitem}"/>
+                        <ComboBoxItem Content="18" Height="32" VerticalContentAlignment="Center" Template="{StaticResource comboxitem}"/>
+                        <ComboBoxItem Content="21" Height="32" VerticalContentAlignment="Center" Template="{StaticResource comboxitem}"/>
+                        <ComboBoxItem Content="24" Height="32" VerticalContentAlignment="Center" Template="{StaticResource comboxitem}"/>
+                    </ComboBox>
+                    <TextBox Name="ThicknessText" Background="White" FontFamily="Segoe UI" FontSize="14"  Height="20" Margin="10,0,35,0" IsReadOnly="True"
+                             BorderThickness="0" VerticalAlignment="Center" TextAlignment="Left" >
+                    </TextBox>
+                </Grid>
+            </Border>
+        </Grid>
+    </Grid>
+   
+</UserControl>

+ 92 - 0
PDF Office/CustomControl/CompositeControl/SlidComboControl.xaml.cs

@@ -0,0 +1,92 @@
+using System;
+using System.Collections.Generic;
+using System.Linq;
+using System.Text;
+using System.Threading.Tasks;
+using System.Windows;
+using System.Windows.Controls;
+using System.Windows.Data;
+using System.Windows.Documents;
+using System.Windows.Input;
+using System.Windows.Media;
+using System.Windows.Media.Imaging;
+using System.Windows.Navigation;
+using System.Windows.Shapes;
+
+namespace PDF_Office.CustomControl.CompositeControl
+{
+    /// <summary>
+    /// SlidComboControl.xaml 的交互逻辑
+    /// </summary>
+    public partial class SlidComboControl : UserControl
+    {
+        public event EventHandler<double> ValueChanged;
+        public SlidComboControl()
+        {
+            InitializeComponent();
+        }
+
+        private void UserControl_Loaded(object sender, RoutedEventArgs e)
+        {
+            ThicknessBox.SelectionChanged -= ThicknessBox_SelectionChanged;
+            ThicknessBox.SelectionChanged += ThicknessBox_SelectionChanged;
+            ThicknessSlider.ValueChanged += ThicknessSlider_ValueChanged;
+            ThicknessBox.SelectedIndex = 0;
+        }
+
+        private void ThicknessSlider_ValueChanged(object sender, RoutedPropertyChangedEventArgs<double> e)
+        {
+            foreach(var item in ThicknessBox.Items)
+            {
+                var itemData = item as ComboBoxItem;
+                if(itemData != null)
+                {
+                   var doubleItem = double.Parse(itemData.Content.ToString());
+                    if(doubleItem == Value)
+                    {
+                        ThicknessBox.SelectedItem = itemData;
+                        break;
+                    }
+                }
+            }
+            ThicknessText.Text = Value.ToString();
+        }
+
+        private void ThicknessBox_SelectionChanged(object sender, SelectionChangedEventArgs e)
+        {
+            var listItem = ThicknessBox.ItemContainerGenerator.ContainerFromItem(ThicknessBox.SelectedItem) as ComboBoxItem;
+            if (listItem != null)
+            {
+                Value = double.Parse(listItem.Content.ToString());
+                ThicknessText.Text = listItem.Content.ToString();
+            }
+            else
+            {
+                ThicknessText.Text = "1";
+                Value = 1.0;
+            }
+                
+
+            
+
+        }
+
+        public double Value
+        {
+            get { return (double)GetValue(ValueProperty); }
+            set { SetValue(ValueProperty, value); }
+        }
+        public static readonly DependencyProperty ValueProperty =
+           DependencyProperty.Register("Value", typeof(double), typeof(SlidComboControl), new PropertyMetadata(1.0, SelectedValuePropertyChanged));
+
+        private static void SelectedValuePropertyChanged(DependencyObject d, DependencyPropertyChangedEventArgs e)
+        {
+            var control = d as SlidComboControl;
+            var value = (double)e.NewValue;
+            if (control != null)
+            {
+                control.ValueChanged?.Invoke(control, value);
+            }
+        }
+    }
+}

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

@@ -29,7 +29,7 @@
                 Foreground="{Binding RelativeSource={RelativeSource Mode=FindAncestor, AncestorType=local:NumericUpDown}, Path=Foreground}"
                 InputMethod.IsInputMethodEnabled="False"
                 PreviewTextInput="CountTextBox_PreviewTextInput"
-                Text="1"
+                Text="{Binding RelativeSource={RelativeSource Mode=FindAncestor, AncestorType=local:NumericUpDown}, Path=Text}"
                 TextAlignment="Left"
                 TextChanged="TextBox_Num_TextChanged" />
             <Grid Grid.Column="1" Width="20">

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

@@ -30,7 +30,7 @@ namespace PDF_Office.CustomControl
         }
 
         public static readonly DependencyProperty TextProperty =
-            DependencyProperty.Register("Text", typeof(string), typeof(NumericUpDown), new PropertyMetadata(""));
+            DependencyProperty.Register("Text", typeof(string), typeof(NumericUpDown), new PropertyMetadata("1"));
 
 
         /// <summary>

+ 33 - 0
PDF Office/CustomControl/PageControl.xaml

@@ -0,0 +1,33 @@
+<UserControl x:Class="PDF_Office.CustomControl.PageControl"
+             xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
+             xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
+             xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006" 
+             xmlns:d="http://schemas.microsoft.com/expression/blend/2008" 
+             xmlns:local="clr-namespace:PDF_Office.CustomControl"
+             mc:Ignorable="d" 
+             d:DesignHeight="450" d:DesignWidth="800">
+    <Grid>
+        <Border  Height="64" Width="293" HorizontalAlignment="Center"  VerticalAlignment="Bottom"  Panel.ZIndex="1" Margin="9" Background="#323232" CornerRadius="4">
+
+            <Grid>
+                <StackPanel Orientation="Horizontal"  VerticalAlignment="Center">
+                    <StackPanel Orientation="Horizontal">
+
+                        <TextBlock Text="-" FontSize="20" Foreground="White" Margin="20,0,20,0"></TextBlock>
+                        <TextBlock Text="+" FontSize="20" Foreground="White" Margin="0,0,39,0"></TextBlock>
+                    </StackPanel>
+                    <StackPanel Orientation="Horizontal">
+                        <TextBlock Text="1" FontSize="20" Foreground="White" Margin="0,0,24,0"></TextBlock>
+                        <TextBlock Text="/" FontSize="20" Foreground="White" Margin="0,0,24,0"></TextBlock>
+                        <TextBlock Text="20" FontSize="20" Foreground="White" Margin="0,0,24,0"></TextBlock>
+                    </StackPanel>
+                    <StackPanel Orientation="Horizontal">
+                        <TextBlock Text="↑" FontSize="20" Foreground="White" Margin="20,0,20,0"></TextBlock>
+                        <TextBlock Text="↓" FontSize="20" Foreground="White"></TextBlock>
+
+                    </StackPanel>
+                </StackPanel>
+            </Grid>
+        </Border>
+    </Grid>
+</UserControl>

+ 28 - 0
PDF Office/CustomControl/PageControl.xaml.cs

@@ -0,0 +1,28 @@
+using System;
+using System.Collections.Generic;
+using System.Linq;
+using System.Text;
+using System.Threading.Tasks;
+using System.Windows;
+using System.Windows.Controls;
+using System.Windows.Data;
+using System.Windows.Documents;
+using System.Windows.Input;
+using System.Windows.Media;
+using System.Windows.Media.Imaging;
+using System.Windows.Navigation;
+using System.Windows.Shapes;
+
+namespace PDF_Office.CustomControl
+{
+    /// <summary>
+    /// PageControl.xaml 的交互逻辑
+    /// </summary>
+    public partial class PageControl : UserControl
+    {
+        public PageControl()
+        {
+            InitializeComponent();
+        }
+    }
+}

+ 1 - 0
PDF Office/CustomControl/WritableComboBox.xaml

@@ -18,6 +18,7 @@
             MinHeight="32"
             VerticalContentAlignment="Center"
             SelectionChanged="writableComboBox_SelectionChanged"
+            SelectedIndex="{Binding RelativeSource={RelativeSource Mode=FindAncestor, AncestorType=local:WritableComboBox}, Path=SelectedIndex}"
             Visibility="Visible">
             <ComboBoxItem Visibility="{Binding RelativeSource={RelativeSource Mode=FindAncestor, AncestorType=local:WritableComboBox}, Path=IsAllPageVisible}">全部页面</ComboBoxItem>
             <ComboBoxItem>奇数页</ComboBoxItem>

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

@@ -76,7 +76,7 @@ namespace PDF_Office.CustomControl
 
         // Using a DependencyProperty as the backing store for MyProperty.  This enables animation, styling, binding, etc...
         public static readonly DependencyProperty SelectedIndexProperty =
-            DependencyProperty.Register("SelectedIndex", typeof(string), typeof(WritableComboBox), new PropertyMetadata(""));
+            DependencyProperty.Register("SelectedIndex", typeof(string), typeof(WritableComboBox), new PropertyMetadata("0"));
 
         public string Text
         {

+ 211 - 28
PDF Office/EventAggregators/EditToolsEvent.cs

@@ -1,28 +1,211 @@
-using Prism.Events;
-using System;
-using System.Collections.Generic;
-using System.Linq;
-using System.Text;
-using System.Threading.Tasks;
-
-namespace PDF_Office.EventAggregators
-{
-
-    public enum EnumTemplateListOrCreate
-    {
-        StatusTemplate,
-        StatusCreate
-    }
-
-    public class EnterSelectedEditToolEvent : PubSubEvent<string>
-    {
-    }
-
-    public class CloseEditToolEvent : PubSubEvent
-    {
-    }
-    public class EnterTemplateListOrCreateEvent : PubSubEvent<EnumTemplateListOrCreate>
-    {
-
-    }
-}
+using ComPDFKitViewer.PdfViewer;
+using PDF_Office.Model.EditTools.Background;
+using PDF_Office.Model.EditTools.Watermark;
+using PDFSettings;
+using Prism.Commands;
+using Prism.Events;
+using System;
+using System.Collections.Generic;
+using System.Linq;
+using System.Runtime.CompilerServices;
+using System.Text;
+using System.Threading.Tasks;
+
+namespace PDF_Office.EventAggregators
+{
+
+    public enum EnumCloseMode
+    {
+        StatusConfirm,
+        StatusCancel,
+    }
+
+    public enum EnumTemplateListOrCreate
+    {
+        StatusNone = -1,
+        StatusTemplate,
+        StatusCreate
+    }
+
+    public enum EnumColorOrFile
+    {
+        StatusNone = -1,
+        StatusColor,
+        StatusFile
+    }
+
+    public enum EnumTextOrFile
+    {
+        StatusNone = -1,
+        StatusText,
+        StatusFile
+    }
+    public enum EnumDelete
+    {
+        StatusCreate,
+        StatusDeleteAll,
+        StatusDeleteInitial
+    }
+
+    
+
+    public class StringWithUnicode
+    {
+        public string Unicode;
+        public string EditToolsContentName;
+    }
+
+    public class EnumCloseModeUnicode
+    {
+        public string Unicode;
+        public EnumCloseMode Status;
+    }
+
+    public class EnumTemplateListOrCreateUnicode
+    {
+        public string Unicode;
+        public EnumTemplateListOrCreate Status;
+    }
+
+    public class EnumColorOrFileUnicode
+    {
+        public string Unicode;
+        public EnumColorOrFile Status;
+    }
+
+    public class EnumTextOrFileUnicode
+    {
+        public string Unicode;
+        public EnumTextOrFile Status;
+    }
+
+    public class EnumDeleteUnicode
+    {
+        public string Unicode;
+        public EnumDelete Status;
+    }
+
+    public class stringUnicode
+    {
+        public string Unicode;
+        public string Status;
+    }
+
+    public class BackgroundInfoUnicode
+    {
+        public string Unicode;
+        public BackgroundInfo Status;
+    }
+
+    public class WatermarkInfoUnicode
+    {
+        public string Unicode;
+        public WatermarkInfo Status;
+    }
+
+    public class BackgroundItemUnicode
+    {
+        public string Unicode;
+        public BackgroundItem Status;
+    }
+
+    public class WatermarkItemUnicode
+    {
+        public string Unicode;
+        public WatermarkItem Status;
+    }
+
+    public class BatesHeaderFooterItemUnicode
+    {
+        public string Unicode;
+        public string Type;
+        public BatesHeaderFooterItem Status;
+    }
+
+    public class CPDFViewerUnicode
+    {
+        public string Unicode;
+        public CPDFViewer Status;
+    }
+
+    public class EnterSelectedEditToolEvent : PubSubEvent<StringWithUnicode>
+    {
+    }
+
+    public class CloseEditToolEvent : PubSubEvent<EnumCloseModeUnicode>
+    {
+    }
+
+    public class EnterTemplateListOrCreateEvent : PubSubEvent<EnumTemplateListOrCreateUnicode>
+    {
+    }
+
+
+    public class ConfirmEditToolsBackgroundEvent : PubSubEvent
+    {
+    }
+
+    public class ConfirmEditToolsWatermarkEvent : PubSubEvent
+    {
+    }
+
+    public class SetCurrentCreateModEvent : PubSubEvent<stringUnicode>
+    {
+    }
+
+    public class SetCurrentTemplateListModEvent : PubSubEvent<stringUnicode>
+    {
+    }
+
+    public class SetBackgroundEvent : PubSubEvent<BackgroundInfoUnicode>
+    {
+    }
+
+    public class SetWatermarkEvent : PubSubEvent<WatermarkInfoUnicode>
+    {
+    }
+
+    public class SaveBackgroundTemplateEvent : PubSubEvent<EnumColorOrFileUnicode>
+    {
+    }
+
+    public class SaveWatermarkTemplateEvent : PubSubEvent<EnumTextOrFileUnicode>
+    {
+    }
+
+    public class DeleteWatermarkEvent : PubSubEvent<EnumDeleteUnicode>
+    {
+    }
+
+    public class CurrentWatermarkPDFViewerEvent : PubSubEvent<CPDFViewerUnicode>
+    {
+    }
+    public class EditBackgroundTemplateItemEvent : PubSubEvent<BackgroundItemUnicode>
+    {
+    }
+
+    public class EditWatermarkTemplateItemEvent : PubSubEvent<WatermarkItemUnicode>
+    {
+    }
+
+    public class EditBatesHeaderFooterTemplateItemEvent : PubSubEvent<BatesHeaderFooterItemUnicode>
+    {
+    }
+
+    public class ConfirmEditBackgroundTemplateItemEvent : PubSubEvent<EnumColorOrFileUnicode>
+    {
+    }
+
+    public class ConfirmEditWatermarkTemplateItemEvent : PubSubEvent<EnumTextOrFileUnicode>
+    {
+    }
+
+    public class SaveEditedBackgroundTemplateItemEvent : PubSubEvent<BackgroundItemUnicode>
+    {
+    }
+
+    public class SaveEditedWatermarkTemplateItemEvent : PubSubEvent<WatermarkItemUnicode>
+    {
+
+    }
+}

+ 84 - 17
PDF Office/Helper/CacheFilePath.cs

@@ -1,46 +1,113 @@
-using System;
+using PDF_Office.Properties;
+using System;
 using System.Collections.Generic;
+using System.IO;
 using System.Linq;
 using System.Text;
 using System.Threading.Tasks;
 
 namespace PDF_Office.Helper
 {
+    /// <summary>
+    /// 用于创建、获取、删除缓存文件的辅助类
+    /// 功能模块需要创建缓存文件夹时,统一在此类里处理
+    /// 临时文件在app启动时进行删除
+    /// </summary>
     public class CacheFilePath
     {
         private static readonly CacheFilePath instance = new CacheFilePath();
+
+        public static CacheFilePath Instance => instance;
+
         private CacheFilePath()
         {
 
         }
-        public static CacheFilePath Instance => instance;
 
+        /// <summary>
+        /// 自定图章缓存文件夹
+        /// </summary>
         public string CustomStampPath
         {
             get
             {
-                try
+               return CreateCacheDirectory("CustomStamp");
+            }
+        }
+
+        /// <summary>
+        /// 在“文档”路径下创建缓存文件夹,传C:\Users\kdan\Documents\PDF Office 以后的文件夹名
+        /// </summary>
+        /// <returns></returns>
+        private string CreateCacheDirectory(string directoryName)
+        {
+            try
+            {
+                string Path = System.IO.Path.Combine(App.CurrentPath, directoryName);
+                System.IO.DirectoryInfo directoryInfo = System.IO.Directory.CreateDirectory(Path);
+                if (directoryInfo.Exists
+                   && (directoryInfo.Attributes & System.IO.FileAttributes.ReadOnly) != System.IO.FileAttributes.ReadOnly
+                   && (directoryInfo.Attributes & System.IO.FileAttributes.Hidden) != System.IO.FileAttributes.Hidden
+                    )
                 {
-                    string Path = System.IO.Path.Combine(App.CurrentPath, "CustomStamp");
-                    System.IO.DirectoryInfo directoryInfo = System.IO.Directory.CreateDirectory(Path);
-                    if (directoryInfo.Exists
-                       &&(directoryInfo.Attributes & System.IO.FileAttributes.ReadOnly) != System.IO.FileAttributes.ReadOnly
-                       &&(directoryInfo.Attributes & System.IO.FileAttributes.Hidden) != System.IO.FileAttributes.Hidden
-                        )
-                    {
-                        return Path;
-                    }
-                    else
-                    {
-                        return "";
-                    }
+                    return Path;
                 }
-                catch (Exception)
+                else
                 {
                     return "";
                 }
+            }
+            catch (Exception)
+            {
+                return "";
+            }
+        }
 
+        /// <summary>
+        /// 将临时文件添加到待删除列表,app下次启动时删除
+        /// </summary>
+        /// <param name="file"></param>
+        public void AddToDeleteFiles(string file)
+        {
+            //添加时不做是否存在判断,考虑可能每个人调用的顺序不一样,在删除时再做判断
+            try
+            {
+                if (!Settings.Default.AppProperties.NeedToDeletePath.Contains(file))
+                {
+                    Settings.Default.AppProperties.NeedToDeletePath.Add(file);
+                }
+                Settings.Default.Save();
+                //Save后,需要调用reload 防止互相占用文件,引起崩溃,具体效果待验证
+                Settings.Default.Reload();
+            }
+            catch { }
+        }
+
+        public void AddToDeleteFiles(List<string> files)
+        {
+            foreach(string file in files)
+            {
+                AddToDeleteFiles(file);
+            }
+        }
+
+        /// <summary>
+        /// 启动时删除临时文件
+        /// </summary>
+        public void ClearDeleteFiles()
+        {
+            try
+            {
+                foreach (string file in Settings.Default.AppProperties.NeedToDeletePath)
+                {
+                    if (File.Exists(file))
+                    {
+                        File.Delete(file);
+                    }
+                }
+                Settings.Default.AppProperties.NeedToDeletePath.Clear();
             }
+            catch { }
         }
 
     }

+ 163 - 0
PDF Office/Helper/EditToolsHelper.cs

@@ -0,0 +1,163 @@
+using System;
+using System.Collections.Generic;
+using System.Diagnostics;
+using System.IO;
+using System.Linq;
+using System.Text;
+using System.Threading.Tasks;
+using System.Windows.Media.Imaging;
+using System.Windows;
+using PDF_Office.Model.EditTools.Background;
+using PDF_Office.Model.EditTools.Watermark;
+using ComPDFKit.PDFDocument;
+using System.Windows.Controls;
+using ComPDFKit.PDFPage;
+using static Dropbox.Api.TeamLog.PaperDownloadFormat;
+using Microsoft.Office.Interop.Word;
+using Task = System.Threading.Tasks.Task;
+using System.Drawing.Imaging;
+using System.Windows.Media;
+
+namespace PDF_Office.Helper
+{
+    public static class EditToolsHelper
+    {
+
+        public static byte[] ConvertColor(Color color)
+        {
+            byte[] rgb_array = new byte[] { 0, 0, 0 };
+            rgb_array[0] = color.R;
+            rgb_array[1] = color.G;
+            rgb_array[2] = color.B;
+
+            return rgb_array;
+        }
+
+        public static Color ConvertColor(byte[] rgb_array)
+        {
+            Color color = new Color();
+            color.R = rgb_array[0];
+            color.G = rgb_array[1];
+            color.B = rgb_array[2];
+
+            return color;
+        }
+
+        public static void ChooseFile(string filePath, ref BackgroundInfo backgroundInfo)
+        {
+            using (FileStream fileData = File.OpenRead(filePath))
+            {
+                string fileExt = Path.GetExtension(filePath).ToLower();
+                BitmapFrame frame = null;
+                BitmapDecoder decoder = BitmapDecoder.Create(fileData, BitmapCreateOptions.None, BitmapCacheOption.Default);
+                if (decoder != null && decoder.Frames.Count > 0)
+                {
+                    frame = decoder.Frames[0];
+                }
+                if (frame != null)
+                {
+                    backgroundInfo.ImageArray = new byte[frame.PixelWidth * frame.PixelHeight * 4];
+                    backgroundInfo.ImageWidth = frame.PixelWidth;
+                    backgroundInfo.ImageHeight = frame.PixelHeight;
+                    frame.CopyPixels(backgroundInfo.ImageArray, frame.PixelWidth * 4, 0);
+#if DEBUG
+                    Trace.WriteLine("width :" + backgroundInfo.ImageWidth);
+                    Trace.WriteLine("height :" + backgroundInfo.ImageHeight);
+#endif
+                }
+            }
+        }
+
+        public static void ChooseFile(string filePath, ref WatermarkInfo watermarkInfo)
+        {
+            using (FileStream fileData = File.OpenRead(filePath))
+            {
+                string fileExt = Path.GetExtension(filePath).ToLower();
+                BitmapFrame frame = null;
+                BitmapDecoder decoder = BitmapDecoder.Create(fileData, BitmapCreateOptions.None, BitmapCacheOption.Default);
+                if (decoder != null && decoder.Frames.Count > 0)
+                {
+                    frame = decoder.Frames[0];
+                }
+                if (frame != null)
+                {
+                    watermarkInfo.ImageArray = new byte[frame.PixelWidth * frame.PixelHeight * 4];
+                    watermarkInfo.ImageWidth = frame.PixelWidth;
+                    watermarkInfo.ImageHeight = frame.PixelHeight;
+                    frame.CopyPixels(watermarkInfo.ImageArray, frame.PixelWidth * 4, 0);
+#if DEBUG
+                    Trace.WriteLine("width :" + watermarkInfo.ImageWidth);
+                    Trace.WriteLine("height :" + watermarkInfo.ImageHeight);
+#endif
+                }
+            }
+        }
+
+
+        public static string ParseRange(string str)
+        {
+            try
+            {
+                string strTemp = "";
+                string strParse = "";
+                for (int i = 0; i < str.Length; i++)
+                {
+                    if (Int32.TryParse(str.Substring(i, 1), out _))
+                    {
+                        strTemp += str[i];
+                    }
+                    else
+                    {
+                        strParse += int.Parse(strTemp) - 1;
+                        strTemp = "";
+                        strParse += str.Substring(i, 1);
+                    }
+                }
+                strParse += int.Parse(strTemp) - 1;
+                return strParse;
+            }
+            catch (Exception e)
+            {
+                return " ";
+            }
+        }
+
+        public static void GetPageRange(int SelectedIndex, CPDFDocument document, ref string PageRange, string pageRangeText)
+        {
+
+            switch (SelectedIndex)
+            {
+                case 0:
+                    {
+                        PageRange = "0-" + (document.PageCount - 1);
+                    }
+                    break;
+                case 1:
+                    {
+                        PageRange = "0";
+                        for (int i = 2; i <= (document.PageCount - 1); i += 2)
+                            PageRange = PageRange + "," + i;
+                    }
+                    break;
+                case 2:
+                    if (document.PageCount >= 2)
+                    {
+                        PageRange = "1";
+                        for (int i = 3; i <= (document.PageCount - 1); i += 2)
+                            PageRange = PageRange + "," + i;
+                    }
+                    else
+                    {
+                        MessageBox.Show("超出页面");
+                    }
+                    break;
+                case 3:
+                    PageRange = ParseRange(pageRangeText);
+                    Trace.WriteLine("PageRange : " + PageRange);
+                    break;
+                default:
+                    break;
+            }
+        }
+    }
+}

+ 186 - 0
PDF Office/Helper/ObservableDictionary.cs

@@ -0,0 +1,186 @@
+using System;
+using System.Collections.Generic;
+using System.Collections.Specialized;
+using System.ComponentModel;
+using System.Linq;
+using System.Text;
+using System.Threading.Tasks;
+
+namespace PDF_Office.Helper
+{
+    public class ObservableDictionary<TKey, TValue> : Dictionary<TKey, TValue>, INotifyCollectionChanged, INotifyPropertyChanged
+    {
+        public ObservableDictionary()
+            : base()
+        { }
+
+        private int _index;
+        public event NotifyCollectionChangedEventHandler CollectionChanged;
+        public event PropertyChangedEventHandler PropertyChanged;
+
+        public new KeyCollection Keys
+        {
+            get { return base.Keys; }
+        }
+
+        public new ValueCollection Values
+        {
+            get { return base.Values; }
+        }
+
+        public new int Count
+        {
+            get { return base.Count; }
+        }
+
+        public new TValue this[TKey key]
+        {
+            get { return this.GetValue(key); }
+            set { this.SetValue(key, value); }
+        }
+
+        public TValue this[int index]
+        {
+            get { return this.GetIndexValue(index); }
+            set { this.SetIndexValue(index, value); }
+        }
+
+        public new void Add(TKey key, TValue value)
+        {
+            base.Add(key, value);
+            this.OnCollectionChanged(new NotifyCollectionChangedEventArgs(NotifyCollectionChangedAction.Add, this.FindPair(key), _index));
+            OnPropertyChanged("Keys");
+            OnPropertyChanged("Values");
+            OnPropertyChanged("Count");
+        }
+
+        public new void Clear()
+        {
+            base.Clear();
+            this.OnCollectionChanged(new NotifyCollectionChangedEventArgs(NotifyCollectionChangedAction.Reset));
+            OnPropertyChanged("Keys");
+            OnPropertyChanged("Values");
+            OnPropertyChanged("Count");
+        }
+
+        public new bool Remove(TKey key)
+        {
+            var pair = this.FindPair(key);
+            if (base.Remove(key))
+            {
+                this.OnCollectionChanged(new NotifyCollectionChangedEventArgs(NotifyCollectionChangedAction.Remove, pair, _index));
+                OnPropertyChanged("Keys");
+                OnPropertyChanged("Values");
+                OnPropertyChanged("Count");
+                return true;
+            }
+            return false;
+        }
+
+        protected void OnCollectionChanged(NotifyCollectionChangedEventArgs e)
+        {
+            if (this.CollectionChanged != null)
+            {
+                this.CollectionChanged(this, e);
+            }
+        }
+
+        protected void OnPropertyChanged(string propertyName)
+        {
+            if (this.PropertyChanged != null)
+            {
+                this.PropertyChanged(this, new PropertyChangedEventArgs(propertyName));
+            }
+        }
+
+        #region private method
+        private TValue GetIndexValue(int index)
+        {
+            for (int i = 0; i < this.Count; i++)
+            {
+                if (i == index)
+                {
+                    var pair = this.ElementAt(i);
+                    return pair.Value;
+                }
+            }
+
+            return default(TValue);
+        }
+
+        private void SetIndexValue(int index, TValue value)
+        {
+            try
+            {
+                var pair = this.ElementAtOrDefault(index);
+                SetValue(pair.Key, value);
+            }
+            catch (Exception)
+            {
+
+            }
+        }
+
+        private TValue GetValue(TKey key)
+        {
+            if (base.ContainsKey(key))
+            {
+                return base[key];
+            }
+            else
+            {
+                return default(TValue);
+            }
+        }
+
+        private void SetValue(TKey key, TValue value)
+        {
+            if (base.ContainsKey(key))
+            {
+                var pair = this.FindPair(key);
+                int index = _index;
+                base[key] = value;
+                var newpair = this.FindPair(key);
+                this.OnCollectionChanged(new NotifyCollectionChangedEventArgs(NotifyCollectionChangedAction.Replace, newpair, pair, index));
+                OnPropertyChanged("Values");
+                OnPropertyChanged("Item[]");
+            }
+            else
+            {
+                this.Add(key, value);
+            }
+        }
+
+        private KeyValuePair<TKey, TValue> FindPair(TKey key)
+        {
+            _index = 0;
+            foreach (var item in this)
+            {
+                if (item.Key.Equals(key))
+                {
+                    return item;
+                }
+                _index++;
+            }
+            return default(KeyValuePair<TKey, TValue>);
+        }
+
+        private int IndexOf(TKey key)
+        {
+            int index = 0;
+            foreach (var item in this)
+            {
+                if (item.Key.Equals(key))
+                {
+                    return index;
+                }
+                index++;
+
+            }
+            return -1;
+        }
+
+        #endregion
+
+    }
+}

+ 0 - 2
PDF Office/Helper/ToolMethod.cs

@@ -132,8 +132,6 @@ namespace PDF_Office.Helper
                                 fileInfo.ThumbImgPath = imagePath;
                             }
                         }
-
-
                     }
                     else//解锁文件覆盖了加密文件的情况 或者本地缩略图文件被删除
                     {

+ 107 - 0
PDF Office/Model/EditTools/Background/BackgroundCreateModel.cs

@@ -0,0 +1,107 @@
+using ComPDFKit.PDFDocument;
+using System;
+using System.Collections.Generic;
+using System.Linq;
+using System.Text;
+using System.Threading.Tasks;
+
+namespace PDF_Office.Model.EditTools.Background
+{
+    public class BackgroundCreateModel
+    {
+    }
+
+    public enum EnumBackgroundType
+    {
+        StatusColor,
+        StatusFile
+    }
+
+    public class BackgroundInfo
+    {
+        /// <summary>
+        /// 背景类型
+        /// </summary>
+        public C_Background_Type BackgroundType = C_Background_Type.BG_TYPE_COLOR; 
+
+        /// <summary>
+        /// 纯色背景颜色
+        /// </summary>
+        public byte[] Color;
+
+        /// <summary>
+        /// 图片背景数据
+        /// </summary>
+        public byte[] ImageArray;
+
+        /// <summary>
+        /// 背景旋转角度
+        /// </summary>
+        public float Rotation;
+        
+        /// <summary>
+        /// 背景透明度
+        /// </summary>
+        public byte Opacity;
+        
+        /// <summary>
+        /// 是否相对比例
+        /// </summary>
+        public bool IsRelativeRatio;
+        
+        /// <summary>
+        ///相对比例大小 
+        /// </summary>
+        public int RelativeRatio;
+
+        /// <summary>
+        /// 
+        /// </summary>
+        public float Scale;
+
+        /// <summary>
+        /// 背景相对垂直距离;
+        /// </summary>
+        public float VertOffset = 0;
+
+        /// <summary>
+        /// 背景相对水平距离;
+        /// </summary>
+        public float HorizOffset = 0;
+
+        /// <summary>
+        /// 图片背景:宽度
+        /// </summary>
+        public int ImageWidth;
+            
+        /// <summary>
+        /// 图片背景:长度
+        /// </summary>
+        public int ImageHeight;
+
+        /// <summary>
+        ///垂直位置
+        /// </summary>
+        public C_Background_Vertalign Vertalign;
+
+        /// <summary>
+        /// 水平位置
+        /// </summary>
+        public C_Background_Horizalign Horizalign;
+
+
+        /// <summary>
+        /// 页码范围
+        /// </summary>
+        public string PageRange = "0";
+
+        /// <summary>
+        /// 页面范围索引;
+        /// 0:全部页面
+        /// 1:奇数页
+        /// 2;偶数页
+        /// 3:自定义页
+        /// </summary>
+        public int PageRangeIndex = 0;
+    }
+}

+ 12 - 0
PDF Office/Model/EditTools/Background/BackgroundTemplateListModel.cs

@@ -0,0 +1,12 @@
+using System;
+using System.Collections.Generic;
+using System.Linq;
+using System.Text;
+using System.Threading.Tasks;
+
+namespace PDF_Office.Model.EditTools.Background
+{
+    internal class BackgroundTemplateListModel
+    {
+    }
+}

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

@@ -0,0 +1,133 @@
+using ComPDFKit.PDFWatermark;
+using System;
+using System.Collections.Generic;
+using System.Linq;
+using System.Text;
+using System.Threading.Tasks;
+
+namespace PDF_Office.Model.EditTools.Watermark
+{
+
+    public class WatermarkCreateModel
+    {
+       
+    }
+
+    public class WatermarkInfo {
+
+        /// <summary>
+        /// 水印类型;
+        /// </summary>
+        public C_Watermark_Type WatermarkType  = C_Watermark_Type.WATERMARK_TYPE_TEXT;
+
+        /// <summary>
+        /// 文本水印内容;
+        /// </summary>
+        public string Text  = "";
+
+        /// <summary>
+        /// 文本水印内容;
+        /// </summary>
+        public string FontName  = "";
+
+        /// <summary>
+        /// 文本水印颜色;
+        /// </summary>
+        public byte[] TextColor=null;
+
+        /// <summary>
+        /// 文本水印大小;
+        /// </summary>
+        public float TextSize  = 5;
+
+        /// <summary>
+        /// 图片水印内容;
+        /// </summary>
+        public byte[] ImageArray = null;
+
+        /// <summary>
+        /// 图片水印路径;
+        /// </summary>
+        public string ImagePath  = "";
+
+        /// <summary>
+        /// 图片水印大小;
+        /// </summary>
+        public float ImageSize = 5;
+
+        /// <summary>
+        /// 图片水印宽度;
+        /// </summary>
+        public int ImageWidth = 100;
+
+        /// <summary>
+        /// 图片水印高度;
+        /// </summary>
+        public int ImageHeight = 100;
+
+        /// <summary>
+        /// 水印页面范围;
+        /// </summary>
+        public string PageRange  = "0";
+
+        /// <summary>
+        /// 水印页面范围索引;
+        /// 0:全部页面
+        /// 1:奇数页
+        /// 2;偶数页
+        /// 3:自定义页
+        /// </summary>
+        public int PageRangeIndex = 0;
+
+        /// <summary>
+        /// 水印垂直位置;
+        /// </summary>
+        public C_Watermark_Vertalign WatermarkVertalign = C_Watermark_Vertalign.WATERMARK_VERTALIGN_CENTER;
+
+        /// <summary>
+        /// 水印水平位置;
+        /// </summary>
+        public C_Watermark_Horizalign WatermarkHorizalign  = C_Watermark_Horizalign.WATERMARK_HORIZALIGN_CENTER;
+
+        /// <summary>
+        /// 水印相对垂直距离;
+        /// </summary>
+        public float VertOffset = 0;
+
+        /// <summary>
+        /// 水印相对水平距离;
+        /// </summary>
+        public float HorizOffset  = 0;
+
+        /// <summary>
+        /// 水印石否平铺;
+        /// </summary>
+        public bool Isfull  = false;
+
+        /// <summary>
+        /// 水印平铺水平间距;
+        /// </summary>
+        public float HorizontalSpacing  = 0;
+
+        /// <summary>
+        /// 水印平铺垂直间距;
+        /// </summary>
+        public float VerticalSpacing  = 0;
+
+        /// <summary>
+        /// 水印旋转角度;
+        /// </summary>
+        public float Rotation = 0;
+
+        /// <summary>
+        /// 水印透明度;
+        /// </summary>
+        public byte Opacity  = 100;
+
+        /// <summary>
+        /// 水印是否在页面上方;
+        /// </summary>
+        public bool IsFront = false;
+
+    }
+}

+ 13 - 0
PDF Office/Model/EditTools/Watermark/WatermarkTemplateListModel.cs

@@ -0,0 +1,13 @@
+using System;
+using System.Collections.Generic;
+using System.Linq;
+using System.Text;
+using System.Threading.Tasks;
+
+namespace PDF_Office.Model.EditTools.Watermark
+{
+    public class WatermarkTemplateListModel
+    {
+
+    }
+}

+ 45 - 0
PDF Office/Model/PropertyPanel/AnnotPanel/FontStyleItem.cs

@@ -17,4 +17,49 @@ namespace PDF_Office.Model.PropertyPanel.AnnotPanel
         public FontWeight mFontWeight { get; set; }
 
     }
+
+    public class LoadFontStyle
+    {
+        public static List<FontStyleItem> Load()
+        {
+            List<FontStyleItem> fontStyleList = new List<FontStyleItem>();
+            FontStyleItem custom = new FontStyleItem();
+            custom.mFontSize = 32;
+            custom.mFontStyleName = "自定义";
+
+            FontStyleItem h1 = new FontStyleItem();
+            h1.mFontSize = 24;
+            h1.mFontStyleName = "H1大标题";
+
+            FontStyleItem h2 = new FontStyleItem();
+            h2.mFontSize = 16;
+            h2.mFontStyleName = "h2(标准)";
+
+            FontStyleItem h3 = new FontStyleItem();
+            h3.mFontSize = 10;
+            h3.mFontStyleName = "H3小标题";
+
+            FontStyleItem b1 = new FontStyleItem();
+            b1.mFontSize = 8;
+            b1.mFontStyleName = "B1标题";
+
+            FontStyleItem b2 = new FontStyleItem();
+            b2.mFontSize = 6;
+            b2.mFontStyleName = "B2标题";
+
+            FontStyleItem b3 = new FontStyleItem();
+            b3.mFontSize = 4;
+            b3.mFontStyleName = "B3标题";
+
+            fontStyleList.Add(custom);
+            fontStyleList.Add(h1);
+            fontStyleList.Add(h2);
+            fontStyleList.Add(h3);
+            fontStyleList.Add(b1);
+            fontStyleList.Add(b2);
+            fontStyleList.Add(b3);
+
+            return fontStyleList;
+        }
+    }
 }

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

@@ -39,6 +39,33 @@ namespace PDF_Office.Model
             }
         }
 
+        /// <summary>
+        /// 阅读页PDFViewer 对应的Content RegionName
+        /// </summary>
+        public static string WatermarkViwerRegionName
+        {
+            get
+            {
+                return GetRegionName("WatermarkViwerRegionName");
+            }
+        }
+
+        public static string BackgroundViewerRegionName
+        {
+            get
+            {
+                return GetRegionName("BackgroundViewerRegionName");
+            }
+        }
+
+        public static string RedactionViewerRegionName
+        {
+            get
+            {
+                return GetRegionName("RedactionViewerRegionName");
+            }
+        }
+
         /// <summary>
         /// BOTA内容项 对应的Content RegionName
         /// </summary>

+ 129 - 0
PDF Office/PDF Office.csproj

@@ -198,6 +198,12 @@
     <Compile Include="CustomControl\CommonWritableComboBox.xaml.cs">
       <DependentUpon>CommonWritableComboBox.xaml</DependentUpon>
     </Compile>
+    <Compile Include="CustomControl\CompositeControl\ColorSubContent.xaml.cs">
+      <DependentUpon>ColorSubContent.xaml</DependentUpon>
+    </Compile>
+    <Compile Include="CustomControl\CompositeControl\SlidComboControl.xaml.cs">
+      <DependentUpon>SlidComboControl.xaml</DependentUpon>
+    </Compile>
     <Compile Include="CustomControl\CustomIconToggleBtn.cs" />
     <Compile Include="CustomControl\CustomImageControl.cs" />
     <Compile Include="CustomControl\DialogContent.cs" />
@@ -207,6 +213,9 @@
     <Compile Include="CustomControl\NumericUpDown.xaml.cs">
       <DependentUpon>NumericUpDown.xaml</DependentUpon>
     </Compile>
+    <Compile Include="CustomControl\PageControl.xaml.cs">
+      <DependentUpon>PageControl.xaml</DependentUpon>
+    </Compile>
     <Compile Include="CustomControl\PageTurningPreview.xaml.cs">
       <DependentUpon>PageTurningPreview.xaml</DependentUpon>
     </Compile>
@@ -232,10 +241,12 @@
     <Compile Include="EventAggregators\PageEditRefreshEvent.cs" />
     <Compile Include="Helper\CacheFilePath.cs" />
     <Compile Include="Helper\ConverterHelper.cs" />
+    <Compile Include="Helper\EditToolsHelper.cs" />
     <Compile Include="Helper\AdvancedInvokeCommandAction.cs" />
     <Compile Include="Helper\ArrowHelper.cs" />
     <Compile Include="Helper\DragDropHelper.cs" />
     <Compile Include="Helper\HomePageEditHelper.cs" />
+    <Compile Include="Helper\ObservableDictionary.cs" />
     <Compile Include="Helper\PasswordBoxHelper.cs" />
     <Compile Include="Helper\RichTextBoxHelper.cs" />
     <Compile Include="Helper\SDKLisenceHelper.cs" />
@@ -282,6 +293,10 @@
     <Compile Include="Model\Dialog\HomePageToolsDialogs\HomePageInsertDialogModel.cs" />
     <Compile Include="Model\Dialog\HomePageToolsDialogs\HomePagePrinter\HomePagePrinterDialogModel.cs" />
     <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\Watermark\WatermarkCreateModel.cs" />
+    <Compile Include="Model\EditTools\Watermark\WatermarkTemplateListModel.cs" />
     <Compile Include="Model\PageEdit\CustomInsertModel.cs" />
     <Compile Include="Model\PageEdit\CustomPageItem.cs" />
     <Compile Include="Model\PageEdit\ExtractModel.cs" />
@@ -304,6 +319,11 @@
       <DesignTime>True</DesignTime>
       <AutoGen>True</AutoGen>
     </Compile>
+    <Compile Include="Settings.cs" />
+    <Compile Include="ViewModels\EditTools\Bates\BatesContentViewModel.cs" />
+    <Compile Include="ViewModels\EditTools\Bates\BatesCreateContentViewModel.cs" />
+    <Compile Include="ViewModels\EditTools\Bates\BatesDocumentContentViewModel.cs" />
+    <Compile Include="ViewModels\EditTools\Bates\BatesTemplateListContentViewModel.cs" />
     <Compile Include="ViewModels\BOTA\BookmarkContentViewModel.cs" />
     <Compile Include="ViewModels\BOTA\OutLineControlViewModel.cs" />
     <Compile Include="ViewModels\BOTA\SearchContentViewModel.cs" />
@@ -329,9 +349,16 @@
     <Compile Include="ViewModels\EditTools\Background\BackgroundCreateBaseContentViewModel.cs" />
     <Compile Include="ViewModels\EditTools\Background\BackgroundCreateColorContentViewModel.cs" />
     <Compile Include="ViewModels\EditTools\Background\BackgroundCreateFileContentViewModel.cs" />
+    <Compile Include="ViewModels\EditTools\Background\BackgroundDocumentContentViewModel.cs" />
     <Compile Include="ViewModels\EditTools\Background\BackgroundTemplateListBaseContentViewModel.cs" />
     <Compile Include="ViewModels\EditTools\Background\BackgroundTemplateListColorContentViewModel.cs" />
     <Compile Include="ViewModels\EditTools\Background\BackgroundTemplateListFileContentViewModel.cs" />
+    <Compile Include="ViewModels\EditTools\HeaderFooter\HeaderFooterContentViewModel.cs" />
+    <Compile Include="ViewModels\EditTools\HeaderFooter\HeaderFooterCreateContentViewModel.cs" />
+    <Compile Include="ViewModels\EditTools\HeaderFooter\HeaderFooterDocumentContentViewModel.cs" />
+    <Compile Include="ViewModels\EditTools\HeaderFooter\HeaderFooterTemplateListContentViewModel.cs" />
+    <Compile Include="ViewModels\EditTools\Redaction\RedactionContentViewModel.cs" />
+    <Compile Include="ViewModels\EditTools\Redaction\RedactionDocumentContentViewModel.cs" />
     <Compile Include="ViewModels\HomePanel\RecentFiles\RecentFilesContentViewModel.cs" />
     <Compile Include="ViewModels\PropertyPanel\AnnotPanel\CustomCreateDialogViewModel.cs" />
     <Compile Include="ViewModels\PropertyPanel\AnnotPanel\DynamicPropertyDialogViewModel.cs" />
@@ -405,6 +432,7 @@
     <Compile Include="Views\BOTA\BookmarkContent.xaml.cs">
       <DependentUpon>BookmarkContent.xaml</DependentUpon>
     </Compile>
+    <Compile Include="ViewModels\EditTools\Watermark\WatermarkDocumentContentViewModel.cs" />
     <Compile Include="Views\BOTA\BOTAContent.xaml.cs">
       <DependentUpon>BOTAContent.xaml</DependentUpon>
     </Compile>
@@ -534,6 +562,36 @@
     <Compile Include="Views\Dialog\VerifyPassWordDialog.xaml.cs">
       <DependentUpon>VerifyPassWordDialog.xaml</DependentUpon>
     </Compile>
+    <Compile Include="Views\EditTools\Redaction\RedactionContent.xaml.cs">
+      <DependentUpon>RedactionContent.xaml</DependentUpon>
+    </Compile>
+    <Compile Include="Views\EditTools\Redaction\RedactionDocumentContent.xaml.cs">
+      <DependentUpon>RedactionDocumentContent.xaml</DependentUpon>
+    </Compile>
+    <Compile Include="Views\EditTools\Bates\BatesContent.xaml.cs">
+      <DependentUpon>BatesContent.xaml</DependentUpon>
+    </Compile>
+    <Compile Include="Views\EditTools\Bates\BatesCreateContent.xaml.cs">
+      <DependentUpon>BatesCreateContent.xaml</DependentUpon>
+    </Compile>
+    <Compile Include="Views\EditTools\Bates\BatesDocumentContent.xaml.cs">
+      <DependentUpon>BatesDocumentContent.xaml</DependentUpon>
+    </Compile>
+    <Compile Include="Views\EditTools\Bates\BatesTemplateListContent.xaml.cs">
+      <DependentUpon>BatesTemplateListContent.xaml</DependentUpon>
+    </Compile>
+    <Compile Include="Views\EditTools\HeaderFooter\HeaderFooterContent.xaml.cs">
+      <DependentUpon>HeaderFooterContent.xaml</DependentUpon>
+    </Compile>
+    <Compile Include="Views\EditTools\HeaderFooter\HeaderFooterCreateContent.xaml.cs">
+      <DependentUpon>HeaderFooterCreateContent.xaml</DependentUpon>
+    </Compile>
+    <Compile Include="Views\EditTools\HeaderFooter\HeaderFooterDocumentContent.xaml.cs">
+      <DependentUpon>HeaderFooterDocumentContent.xaml</DependentUpon>
+    </Compile>
+    <Compile Include="Views\EditTools\HeaderFooter\HeaderFooterTemplateListContent.xaml.cs">
+      <DependentUpon>HeaderFooterTemplateListContent.xaml</DependentUpon>
+    </Compile>
     <Compile Include="Views\FillAndSign\FillAndSignContent.xaml.cs">
       <DependentUpon>FillAndSignContent.xaml</DependentUpon>
     </Compile>
@@ -552,6 +610,9 @@
     <Compile Include="Views\EditTools\Background\BackgroundContent.xaml.cs">
       <DependentUpon>BackgroundContent.xaml</DependentUpon>
     </Compile>
+    <Compile Include="Views\EditTools\Background\BackgroundDocumentContent.xaml.cs">
+      <DependentUpon>BackgroundDocumentContent.xaml</DependentUpon>
+    </Compile>
     <Compile Include="Views\EditTools\Watermark\WatermarkContent.xaml.cs">
       <DependentUpon>WatermarkContent.xaml</DependentUpon>
     </Compile>
@@ -564,6 +625,9 @@
     <Compile Include="Views\EditTools\Watermark\WatermarkCreateTextContent.xaml.cs">
       <DependentUpon>WatermarkCreateTextContent.xaml</DependentUpon>
     </Compile>
+    <Compile Include="Views\EditTools\Watermark\WatermarkDocumentContent.xaml.cs">
+      <DependentUpon>WatermarkDocumentContent.xaml</DependentUpon>
+    </Compile>
     <Compile Include="Views\EditTools\Watermark\WatermarkTemplateListBaseContent.xaml.cs">
       <DependentUpon>WatermarkTemplateListBaseContent.xaml</DependentUpon>
     </Compile>
@@ -716,6 +780,14 @@
       <Generator>MSBuild:Compile</Generator>
       <SubType>Designer</SubType>
     </Page>
+    <Page Include="CustomControl\CompositeControl\ColorSubContent.xaml">
+      <Generator>MSBuild:Compile</Generator>
+      <SubType>Designer</SubType>
+    </Page>
+    <Page Include="CustomControl\CompositeControl\SlidComboControl.xaml">
+      <Generator>MSBuild:Compile</Generator>
+      <SubType>Designer</SubType>
+    </Page>
     <Page Include="CustomControl\LoadingControl.xaml">
       <SubType>Designer</SubType>
       <Generator>MSBuild:Compile</Generator>
@@ -724,6 +796,10 @@
       <SubType>Designer</SubType>
       <Generator>MSBuild:Compile</Generator>
     </Page>
+    <Page Include="CustomControl\PageControl.xaml">
+      <SubType>Designer</SubType>
+      <Generator>MSBuild:Compile</Generator>
+    </Page>
     <Page Include="CustomControl\PageTurningPreview.xaml">
       <SubType>Designer</SubType>
       <Generator>MSBuild:Compile</Generator>
@@ -752,6 +828,10 @@
       <SubType>Designer</SubType>
       <Generator>MSBuild:Compile</Generator>
     </Page>
+    <Page Include="Styles\ContextMenuTextEditStyle.xaml">
+      <SubType>Designer</SubType>
+      <Generator>MSBuild:Compile</Generator>
+    </Page>
     <Page Include="Styles\CustomBtnStyle.xaml">
       <Generator>MSBuild:Compile</Generator>
       <SubType>Designer</SubType>
@@ -924,6 +1004,46 @@
       <SubType>Designer</SubType>
       <Generator>MSBuild:Compile</Generator>
     </Page>
+    <Page Include="Views\EditTools\Bates\BatesContent.xaml">
+      <SubType>Designer</SubType>
+      <Generator>MSBuild:Compile</Generator>
+    </Page>
+    <Page Include="Views\EditTools\Bates\BatesCreateContent.xaml">
+      <SubType>Designer</SubType>
+      <Generator>MSBuild:Compile</Generator>
+    </Page>
+    <Page Include="Views\EditTools\Bates\BatesDocumentContent.xaml">
+      <SubType>Designer</SubType>
+      <Generator>MSBuild:Compile</Generator>
+    </Page>
+    <Page Include="Views\EditTools\Bates\BatesTemplateListContent.xaml">
+      <SubType>Designer</SubType>
+      <Generator>MSBuild:Compile</Generator>
+    </Page>
+    <Page Include="Views\EditTools\HeaderFooter\HeaderFooterContent.xaml">
+      <SubType>Designer</SubType>
+      <Generator>MSBuild:Compile</Generator>
+    </Page>
+    <Page Include="Views\EditTools\HeaderFooter\HeaderFooterCreateContent.xaml">
+      <SubType>Designer</SubType>
+      <Generator>MSBuild:Compile</Generator>
+    </Page>
+    <Page Include="Views\EditTools\HeaderFooter\HeaderFooterDocumentContent.xaml">
+      <SubType>Designer</SubType>
+      <Generator>MSBuild:Compile</Generator>
+    </Page>
+    <Page Include="Views\EditTools\HeaderFooter\HeaderFooterTemplateListContent.xaml">
+      <SubType>Designer</SubType>
+      <Generator>MSBuild:Compile</Generator>
+    </Page>
+    <Page Include="Views\EditTools\Redaction\RedactionContent.xaml">
+      <SubType>Designer</SubType>
+      <Generator>MSBuild:Compile</Generator>
+    </Page>
+    <Page Include="Views\EditTools\Redaction\RedactionDocumentContent.xaml">
+      <SubType>Designer</SubType>
+      <Generator>MSBuild:Compile</Generator>
+    </Page>
     <Page Include="Views\FillAndSign\FillAndSignContent.xaml">
       <SubType>Designer</SubType>
       <Generator>MSBuild:Compile</Generator>
@@ -1055,6 +1175,10 @@
       <SubType>Designer</SubType>
       <Generator>MSBuild:Compile</Generator>
     </Page>
+    <Page Include="Views\EditTools\Background\BackgroundDocumentContent.xaml">
+      <SubType>Designer</SubType>
+      <Generator>MSBuild:Compile</Generator>
+    </Page>
     <Page Include="Views\PropertyPanel\AnnotPanel\SharpsAnnotProperty.xaml">
       <SubType>Designer</SubType>
       <Generator>MSBuild:Compile</Generator>
@@ -1083,6 +1207,10 @@
       <SubType>Designer</SubType>
       <Generator>MSBuild:Compile</Generator>
     </Page>
+    <Page Include="Views\EditTools\Watermark\WatermarkDocumentContent.xaml">
+      <SubType>Designer</SubType>
+      <Generator>MSBuild:Compile</Generator>
+    </Page>
     <Page Include="Views\EditTools\Watermark\WatermarkTemplateListBaseContent.xaml">
       <SubType>Designer</SubType>
       <Generator>MSBuild:Compile</Generator>
@@ -1305,6 +1433,7 @@
     <Content Include="Resources\PageEdit\Staff.jpg">
       <CopyToOutputDirectory>Always</CopyToOutputDirectory>
     </Content>
+    <Resource Include="Resources\EditTools\watermark_bg.png" />
     <Content Include="source\AnalysisWord\Res\_rels\.rels">
       <CopyToOutputDirectory>Always</CopyToOutputDirectory>
     </Content>

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

@@ -78,6 +78,52 @@ namespace PDF_Office.Properties {
             }
         }
         
+        [global::System.Configuration.UserScopedSettingAttribute()]
+        [global::System.Diagnostics.DebuggerNonUserCodeAttribute()]
+        public global::PDFSettings.BackgroundTemplateList BackgroundTemplateList {
+            get {
+                return ((global::PDFSettings.BackgroundTemplateList)(this["BackgroundTemplateList"]));
+            }
+            set {
+                this["BackgroundTemplateList"] = value;
+            }
+        }
+        
+        [global::System.Configuration.UserScopedSettingAttribute()]
+        [global::System.Diagnostics.DebuggerNonUserCodeAttribute()]
+        [global::System.Configuration.DefaultSettingValueAttribute("0")]
+        public int BackgroundIndex {
+            get {
+                return ((int)(this["BackgroundIndex"]));
+            }
+            set {
+                this["BackgroundIndex"] = value;
+            }
+        }
+        
+        [global::System.Configuration.UserScopedSettingAttribute()]
+        [global::System.Diagnostics.DebuggerNonUserCodeAttribute()]
+        public global::PDFSettings.WatermarkTemplateList WatermarkTemplateList {
+            get {
+                return ((global::PDFSettings.WatermarkTemplateList)(this["WatermarkTemplateList"]));
+            }
+            set {
+                this["WatermarkTemplateList"] = value;
+            }
+        }
+        
+        [global::System.Configuration.UserScopedSettingAttribute()]
+        [global::System.Diagnostics.DebuggerNonUserCodeAttribute()]
+        [global::System.Configuration.DefaultSettingValueAttribute("0")]
+        public int WatermarkIndex {
+            get {
+                return ((int)(this["WatermarkIndex"]));
+            }
+            set {
+                this["WatermarkIndex"] = value;
+            }
+        }
+        
         [global::System.Configuration.UserScopedSettingAttribute()]
         [global::System.Diagnostics.DebuggerNonUserCodeAttribute()]
         public global::PDFSettings.CustomStampList CustomStampList {

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

@@ -17,6 +17,18 @@
     <Setting Name="QuickPDFToolsList" Type="PDFSettings.QuickPDFToolsList" Scope="User">
       <Value Profile="(Default)" />
     </Setting>
+    <Setting Name="BackgroundTemplateList" Type="PDFSettings.BackgroundTemplateList" Scope="User">
+      <Value Profile="(Default)" />
+    </Setting>
+    <Setting Name="BackgroundIndex" Type="System.Int32" Scope="User">
+      <Value Profile="(Default)">0</Value>
+    </Setting>
+    <Setting Name="WatermarkTemplateList" Type="PDFSettings.WatermarkTemplateList" Scope="User">
+      <Value Profile="(Default)" />
+    </Setting>
+    <Setting Name="WatermarkIndex" Type="System.Int32" Scope="User">
+      <Value Profile="(Default)">0</Value>
+    </Setting>
     <Setting Name="CustomStampList" Type="PDFSettings.CustomStampList" Scope="User">
       <Value Profile="(Default)" />
     </Setting>

BIN
PDF Office/Resources/EditTools/watermark_bg.png


+ 2 - 2
PDF Office/SDKLisence.xml

@@ -1,6 +1,6 @@
 <Lisences
-	devKey = "MR+QexuegNeqiBQsqcIcFzDeioHWjwb2vjDGnbooRo2BeTSWnmGnqHt8tHPlZxRRinYCeuW5DqGFyKcFfMVXAsip0AFj42LhYS9KBFus5kgXzOn+ZcLVFm1an4fKnn6ShRXnUWaemHBeaMzLbFEPbz6jDFFoIizuCMHP6KFf/6o="
-	devSecret="mG0c3O3Mzeu5dkZJW3gpqq9uA7o7EGQveSC38Q8TK4iYSXB8erGstkUyaynN7k8ocNCYAAzc9CPxiym2TlqeSUWpLOaOv47bs7x+UqfQzn9hrp9sGpqfp0B228KI+IMTu4aGVjtYuk+Uxs/kosIBwyVLBY93oKLBB8UJg4t07605BGbaBKUlDopA0iGq1HSnkBnoGhqnvZdAqbtp5o0JTKDl1EzWv/F/0Gw7Q02pypAMFoEMtjKxkVmy+liLW9u9"
+	devKey = "sTHSivIW4YnZQavIYDLVw4vaFcN5DQTUtRGrVyv5p9aeaHX3GirG/MBxl6Wy9TJbNOwR4CU6LPjHmGe3Po3OtBCPqIRheam9+LomScw3AvoUTHFlG1134e2J4enF43WJQ6PyOnjwZqsG1kUdlBPNztkoPzDAE2pQKgZWf6V2i34="
+    devSecret = "mG0c3O3Mzeu5dkZJW3gpqq9uA7o7EGQveSC38Q8TK4gQurxTxGuBlGAhs0P1mD3X3bHT+AHfcLiymaqE4DY7kTFHoPs9I3tl5ErS+BHdzHRhrp9sGpqfp0B228KI+IMTu4aGVjtYuk+Uxs/kosIBw1367/WkJ00tM7U7tttD6cfaiHpW8pgW2aur3AxuQIBBLuJD5gcmNxTYW3KA32JLG8alfyXjKFVS3gka9bngvwfZ7GuNXybjKlmz1tnN6iVHpnbSj+xOHhWEperY4HHrSg=="
 	userKey = "iBPRM/Tz8b6Z1G2GQt52X7hiNCGfVYXztnPjalgrgARvqfKV6lFNH8QeScTzBRYI8GGFpwelfgh790Kd9JmL7V4adI1jCiFHUT2DLT7QucxY5Nkgys2aJItQS482Ck2G2Xf8gNgojxYxRt65o/MEzkj93foj8qIdfHagXsSorSs="
 	userSecret="mG0c3O3Mzeu5dkZJW3gpqq9uA7o7EGQveSC38Q8TK4ivEHOmPIqbfhpDnKKj+7Ymj2rXQvfZRmke06HMV+3tt064G64WjPW8+EbGCNZaAh1hrp9sGpqfp0B228KI+IMTu4aGVjtYuk+Uxs/kosIBw1FKJi6HYB+DuugQyaqI2prfej861QnJrU4s2T/npZK/"
 	ConverterDevKey="Eahwo7OZAYHJaCF7TJQYKSVqC62MzfBdllVXnC5BRR5BQFDKnQ1FJtCRVdug+VNg/ti+/DeA5Sq4IH2CBpQjAZst5705uk5Sz0ZwRu8Qdn9HFGwh2pG6dJEIrl7lOccoZS6+1IxgOTcTeHqYpym3NsmtbhBWE848Pvme3scpW28="

+ 28 - 0
PDF Office/Settings.cs

@@ -0,0 +1,28 @@
+namespace PDF_Office.Properties {
+    
+    
+    // 通过此类可以处理设置类的特定事件: 
+    //  在更改某个设置的值之前将引发 SettingChanging 事件。
+    //  在更改某个设置的值之后将引发 PropertyChanged 事件。
+    //  在加载设置值之后将引发 SettingsLoaded 事件。
+    //  在保存设置值之前将引发 SettingsSaving 事件。
+    internal sealed partial class Settings {
+        
+        public Settings() {
+            // // 若要为保存和更改设置添加事件处理程序,请取消注释下列行: 
+            //
+            // this.SettingChanging += this.SettingChangingEventHandler;
+            //
+            // this.SettingsSaving += this.SettingsSavingEventHandler;
+            //
+        }
+        
+        private void SettingChangingEventHandler(object sender, System.Configuration.SettingChangingEventArgs e) {
+            // 在此处添加用于处理 SettingChangingEvent 事件的代码。
+        }
+        
+        private void SettingsSavingEventHandler(object sender, System.ComponentModel.CancelEventArgs e) {
+            // 在此处添加用于处理 SettingsSaving 事件的代码。
+        }
+    }
+}

+ 33 - 0
PDF Office/StyleAndTemplateList.txt

@@ -7,6 +7,17 @@
 用途:用于调整HeaderPanel水平居中(不影响Content位置的前提下)
 目前用于:阅读页工具栏、BOTA多页签部分
 
+2.InsideBarBtnStyle
+样式位置:PDF Office\Styles\TabControlStyle.xaml
+用途:工具条的透明按钮
+示例:D:\PDF_Office\PDF Office\Views\Tools\ToolsBarContent.xaml
+
+3.CheckBoxStyle
+样式位置:PDF Office\Styles\TabControlStyle.xaml
+用途:是否设置相对目标页面比例的CheckBox,点击后变为黑底白勾
+示例:D:\PDF_Office\PDF Office\Views\EditTools\Background\BackgroundCreateColorContent.xaml
+备注:勾符号的Path可能需要重绘
+
 自定义控件
 1.LoadingContorl
 位置:PDF Office\CustomControl\LoadingControl.xaml
@@ -17,3 +28,25 @@
 位置:PDF Office\CustomControl\ToastControl.xaml
 用途:部分操作后,在界面中间显示提示,一段时候后自动渐隐消失
 使用方法:VM里绑定一个bool变量,设为True时,Toast开始显示,开始渐隐时间(beginTime),和渐隐时间(Duration)在xaml里设置
+
+3.WritableComboBox
+位置:PDF Office\CustomControl\WritableComboBox.xaml
+用途:设置页面范围
+提供可选项:全部页面,奇数页,偶数页,自定义页面,可在xaml.cs中用Loading方式添加当前页选项
+使用方法:绑定Text,搭配Helper/HomePageEditHelper.cs中的GetPagerange方法。
+
+4.NumericUpDown
+位置:PDF Office\CustomControl\NumericUpDown.xaml
+用途:一个TextBox和两个按钮,可以输入数字,并通过旁边的按钮调节数字,每次+1/-1
+使用方法:Text和后台属性绑定,按按钮或者输入数字时自动修改。
+
+5.CommonWritableComboBox
+位置:PDF Office\CustomControl\CommonWritableComboBox.xaml
+用途:设置带单位可输入的ComboBox
+提供可选项:绑定TypeSource设置可选项
+使用方法:设置Text设置初始值,绑定Value获得无单位的真值,Unit设置单位无单位为" "空格,其他单位为单个字符单位"%" 
+
+6.PageTurningPreview
+位置:PDF Office\CustomControl\PageTurningPreview.xaml
+用途:普通预览控件,可进行翻页
+使用方法:load自定义控件时设置PageIndexLists(负责控制页数),cpdfdocment(负责渲染的文件)

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

@@ -105,7 +105,7 @@
             </Trigger>
         </ControlTemplate.Triggers>
     </ControlTemplate>
-    <Style x:Key="CheckBoxStyle" TargetType="{x:Type CheckBox}">
+    <Style x:Key="EditToolsCheckBoxStyle" TargetType="{x:Type CheckBox}">
         <Setter Property="SnapsToDevicePixels" Value="true" />
         <Setter Property="OverridesDefaultStyle" Value="False" />
 
@@ -163,6 +163,10 @@
                             <Setter TargetName="CheckBoxRectangle" Property="Fill" Value="#FF00A8E0" />
                             <Setter TargetName="CheckBoxRectangle" Property="Opacity" Value="1" />
                             <Setter TargetName="CheckBoxRectangleOut" Property="Stroke" Value="Transparent" />
+                            <Setter TargetName="CheckedMark" Property="Visibility" Value="Visible"></Setter>
+                            <Setter TargetName="CheckBoxRectangle" Property="Fill" Value="#000000"></Setter>
+                            <Setter TargetName="CheckBoxRectangle" Property="Opacity" Value="1"></Setter>
+                            <Setter TargetName="CheckBoxRectangleOut" Property="Stroke" Value="Transparent"></Setter>
                         </Trigger>
                     </ControlTemplate.Triggers>
                 </ControlTemplate>

Những thai đổi đã bị hủy bỏ vì nó quá lớn
+ 383 - 0
PDF Office/Styles/ContextMenuTextEditStyle.xaml


+ 41 - 0
PDF Office/Styles/ListBoxStyle.xaml

@@ -47,4 +47,45 @@
             </Trigger>-->
         </ControlTemplate.Triggers>
     </ControlTemplate>
+
+    <ControlTemplate x:Key="EditToolsItemControlTemplate" TargetType="{x:Type ListBoxItem}">
+        <Border x:Name="EditToolsBorder"  
+            Padding="{TemplateBinding Padding}"
+            Background="{TemplateBinding Background}"
+            BorderBrush="{TemplateBinding BorderBrush}"
+            BorderThickness="{TemplateBinding BorderThickness}"
+            Height="{TemplateBinding Height}"
+            Width="{TemplateBinding Width}"
+            SnapsToDevicePixels="True"
+               >
+            <ContentPresenter   
+                Content="{TemplateBinding Content}"
+                ContentStringFormat="{TemplateBinding ContentStringFormat}"
+                ContentTemplate="{TemplateBinding ContentTemplate}"
+                SnapsToDevicePixels="{TemplateBinding SnapsToDevicePixels}"/>
+        </Border>
+        <ControlTemplate.Triggers>
+            <MultiTrigger>
+                <MultiTrigger.Conditions>
+                    <Condition Property="IsMouseOver" Value="True"></Condition>
+                </MultiTrigger.Conditions>
+                <Setter Property="Background" TargetName="EditToolsBorder" Value="#1A477EDE"/>
+                <Setter Property="BorderBrush" TargetName="EditToolsBorder" Value="Black"/>
+            </MultiTrigger>
+            <MultiTrigger>
+                <MultiTrigger.Conditions>
+                    <Condition Property="Selector.IsSelectionActive" Value="True"/>
+                    <Condition Property="IsSelected" Value="True"/>
+                </MultiTrigger.Conditions>
+                <Setter Property="Background" TargetName="EditToolsBorder" Value="#1A477EDE"/>
+                <Setter Property="BorderBrush" TargetName="EditToolsBorder" Value="Black"/>
+            </MultiTrigger>
+            <Trigger Property="IsEnabled" Value="False">
+                <Setter Property="TextElement.Foreground" TargetName="EditToolsBorder" Value="{DynamicResource {x:Static SystemColors.GrayTextBrushKey}}"/>
+            </Trigger>
+
+        </ControlTemplate.Triggers>
+
+    </ControlTemplate>
+
 </ResourceDictionary>

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

@@ -86,6 +86,7 @@ namespace PDF_Office.ViewModels.Dialog.ConverterDialogs
                     char[] rangeSeparator = new char[] { '-' };
                     if (!CommonHelper.GetPagesInRange(ref ConverterPreview.PageIndexLists, PageRange, currentViewer.Document.PageCount, enumerationSeparator, rangeSeparator))
                     { //TODO
+                        ConverterPreview.PageIndexLists.Add(0);
                         Trace.WriteLine("输入不对");
                         MessageBoxEx.Show("输入不对");
                         return;
@@ -98,6 +99,7 @@ namespace PDF_Office.ViewModels.Dialog.ConverterDialogs
                     char[] rangeSeparator = new char[] { '-' };
                     if (!CommonHelper.GetPagesInRange(ref ConverterPreview.PageIndexLists, (ConverterPreview.PageIndexLists[ConverterPreview.CurrentIndex] + 1).ToString(), currentViewer.Document.PageCount, enumerationSeparator, rangeSeparator))
                     { //TODO
+                        
                         Trace.WriteLine("输入不对");
                         MessageBoxEx.Show("输入不对");
                         return;
@@ -156,6 +158,7 @@ namespace PDF_Office.ViewModels.Dialog.ConverterDialogs
             char[] rangeSeparator = new char[] { '-' };
             if (!CommonHelper.GetPagesInRange(ref ConverterCSVModel.PageIndexLists, ConverterCSVModel.PageRange, currentViewer.Document.PageCount, enumerationSeparator, rangeSeparator))
             { //TODO
+
                 Trace.WriteLine("输入不对");
                 MessageBoxEx.Show("输入不对");
                 return;

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

@@ -115,6 +115,7 @@ namespace PDF_Office.ViewModels.Dialog.ConverterDialogs
                     char[] rangeSeparator = new char[] { '-' };
                     if (!CommonHelper.GetPagesInRange(ref ConverterPreview.PageIndexLists, PageRange, currentViewer.Document.PageCount, enumerationSeparator, rangeSeparator))
                     { //TODO
+                        ConverterPreview.PageIndexLists.Add(0);
                         Trace.WriteLine("输入不对");
                         MessageBoxEx.Show("输入不对");
                         return;

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

@@ -110,6 +110,7 @@ namespace PDF_Office.ViewModels.Dialog.ConverterDialogs
                     char[] rangeSeparator = new char[] { '-' };
                     if (!CommonHelper.GetPagesInRange(ref ConverterPreview.PageIndexLists, PageRange, currentViewer.Document.PageCount, enumerationSeparator, rangeSeparator))
                     { //TODO
+                        ConverterPreview.PageIndexLists.Add(0);
                         Trace.WriteLine("输入不对");
                         MessageBoxEx.Show("输入不对");
                         return;

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

@@ -219,6 +219,7 @@ namespace PDF_Office.ViewModels.Dialog.ConverterDialogs
                     char[] rangeSeparator = new char[] { '-' };
                     if (!CommonHelper.GetPagesInRange(ref ConverterPreview.PageIndexLists, PageRange, currentViewer.Document.PageCount, enumerationSeparator, rangeSeparator))
                     { //TODO
+                        ConverterPreview.PageIndexLists.Add(0);
                         Trace.WriteLine("输入不对");
                         MessageBoxEx.Show("输入不对");
                         return;

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

@@ -108,6 +108,7 @@ namespace PDF_Office.ViewModels.Dialog.ConverterDialogs
                     char[] rangeSeparator = new char[] { '-' };
                     if (!CommonHelper.GetPagesInRange(ref ConverterPreview.PageIndexLists, PageRange, currentViewer.Document.PageCount, enumerationSeparator, rangeSeparator))
                     { //TODO
+                        ConverterPreview.PageIndexLists.Add(0);
                         Trace.WriteLine("输入不对");
                         MessageBoxEx.Show("输入不对");
                         return;

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

@@ -107,6 +107,7 @@ namespace PDF_Office.ViewModels.Dialog.ConverterDialogs
                     char[] rangeSeparator = new char[] { '-' };
                     if (!CommonHelper.GetPagesInRange(ref ConverterPreview.PageIndexLists, PageRange, currentViewer.Document.PageCount, enumerationSeparator, rangeSeparator))
                     { //TODO
+                        ConverterPreview.PageIndexLists.Add(0);
                         Trace.WriteLine("输入不对");
                         MessageBoxEx.Show("输入不对");
                         return;

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

@@ -108,6 +108,7 @@ namespace PDF_Office.ViewModels.Dialog.ConverterDialogs
                     char[] rangeSeparator = new char[] { '-' };
                     if (!CommonHelper.GetPagesInRange(ref ConverterPreview.PageIndexLists, PageRange, currentViewer.Document.PageCount, enumerationSeparator, rangeSeparator))
                     { //TODO
+                        ConverterPreview.PageIndexLists.Add(0);
                         Trace.WriteLine("输入不对");
                         MessageBoxEx.Show("输入不对");
                         return;

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

@@ -109,6 +109,7 @@ namespace PDF_Office.ViewModels.Dialog.ConverterDialogs
                     char[] rangeSeparator = new char[] { '-' };
                     if (!CommonHelper.GetPagesInRange(ref ConverterPreview.PageIndexLists, PageRange, currentViewer.Document.PageCount, enumerationSeparator, rangeSeparator))
                     { //TODO
+                        ConverterPreview.PageIndexLists.Add(0);
                         Trace.WriteLine("输入不对");
                         MessageBoxEx.Show("输入不对");
                         return;

+ 1 - 0
PDF Office/ViewModels/Dialog/HomePageToolsDialogs/HomePageExtractDialogViewModel.cs

@@ -161,6 +161,7 @@ namespace PDF_Office.ViewModels.Dialog.HomePageToolsDialogs
                     char[] rangeSeparator = new char[] { '-' };
                     if (!CommonHelper.GetPagesInRange(ref ExtractPreview.PageIndexLists, PageRange, currentViewer.Document.PageCount, enumerationSeparator, rangeSeparator))
                     { //TODO
+                        ExtractPreview.PageIndexLists.Add(0);
                         Trace.WriteLine("输入不对");
                         MessageBoxEx.Show("输入不对");
                         return;

+ 3 - 2
PDF Office/ViewModels/Dialog/HomePageToolsDialogs/HomePageSplitDialogViewModel.cs

@@ -90,9 +90,9 @@ namespace PDF_Office.ViewModels.Dialog.HomePageToolsDialogs
             }
         }
 
-        public string AveragePagesText { set; get; } = "";
+        public string AveragePagesText { set; get; } = "1";
 
-        public string AverageFilesText { set; get; } = "";
+        public string AverageFilesText { set; get; } = "1";
 
 
         private string filePathName = "";
@@ -450,6 +450,7 @@ namespace PDF_Office.ViewModels.Dialog.HomePageToolsDialogs
                     char[] rangeSeparator = new char[] { '-' };
                     if (!CommonHelper.GetPagesInRange(ref SplitPreview.PageIndexLists, PageRange, currentViewer.Document.PageCount, enumerationSeparator, rangeSeparator))
                     { //TODO
+                        SplitPreview.PageIndexLists.Add(0);
                         Trace.WriteLine("输入不对");
                         MessageBoxEx.Show("输入不对");
                         return;

+ 226 - 95
PDF Office/ViewModels/EditTools/Background/BackgroundContentViewModel.cs

@@ -1,95 +1,226 @@
-using Dropbox.Api.Sharing;
-using PDF_Office.EventAggregators;
-using Prism.Commands;
-using Prism.Events;
-using Prism.Mvvm;
-using Prism.Regions;
-using System;
-using System.Windows;
-using System.Linq;
-using System.Windows.Controls;
-using Visibility = System.Windows.Visibility;
-using Dropbox.Api.FileProperties;
-
-namespace PDF_Office.ViewModels.EditTools.Background
-{
-    public class BackgroundContentViewModel : BindableBase,INavigationAware
-    {
-        public IEventAggregator eventAggregator;
-        public IRegionManager backgroundRegion;
-
-        public string TemplateListName = "BackgroundTemplateListBaseContent";
-        public string CreateName = "BackgroundCreateBaseContent";
-
-        private string _backgroundSettingsRegionName;
-        public string BackgroundSettingsRegionName
-        {
-            get { return _backgroundSettingsRegionName; }
-            set { _backgroundSettingsRegionName = value;}
-        }
-
-        private Visibility _backgroundSettingsVisible = Visibility.Collapsed;
-        public Visibility BackgroundSettingsVisible
-        {
-            get { return _backgroundSettingsVisible; }
-            set { _backgroundSettingsVisible = value; }
-        }
-
-        /// <summary>
-        /// 退出EditTool
-        /// </summary>
-        public DelegateCommand CloseEditToolCommand { get; set; }
-
-        public DelegateCommand<string> EnterSelectedContentCommand { get; set; }
-
-        public BackgroundContentViewModel( IRegionManager regionManager, IEventAggregator eventAggregator)
-        {
-            this.eventAggregator = eventAggregator;
-            this.backgroundRegion = regionManager;
-            BackgroundSettingsVisible = Visibility.Visible;
-            BackgroundSettingsRegionName = Guid.NewGuid().ToString();
-
-            CloseEditToolCommand = new DelegateCommand(CloseEditTool);
-            EnterSelectedContentCommand = new DelegateCommand<string>(EnterSelectedContent);
-
-            eventAggregator.GetEvent<EnterTemplateListOrCreateEvent>().Subscribe(EnterTemplateListOrCreate);
-        }
-
-        public void CloseEditTool()
-        {
-            this.eventAggregator.GetEvent<CloseEditToolEvent>().Publish();
-        }
-
-        public void EnterTemplateListOrCreate(EnumTemplateListOrCreate enumTemplateListOrCreate)
-        {
-            if(enumTemplateListOrCreate == EnumTemplateListOrCreate.StatusTemplate)
-            {
-                EnterSelectedContent(TemplateListName);
-            }
-            else
-            {
-                EnterSelectedContent(CreateName);
-            }
-        }
-
-        public void EnterSelectedContent(string SelectedContentName)
-        {
-            backgroundRegion.RequestNavigate(BackgroundSettingsRegionName, SelectedContentName);
-            BackgroundSettingsVisible = Visibility.Visible;
-        }
-
-        public void OnNavigatedTo(NavigationContext navigationContext)
-        {
-            EnterSelectedContent(TemplateListName);
-        }
-
-        public bool IsNavigationTarget(NavigationContext navigationContext)
-        {
-            return true;
-        }
-
-        public void OnNavigatedFrom(NavigationContext navigationContext)
-        {
-        }
-    }
-}
+using Dropbox.Api.Sharing;
+using PDF_Office.EventAggregators;
+using Prism.Commands;
+using Prism.Events;
+using Prism.Mvvm;
+using Prism.Regions;
+using System;
+using System.Windows;
+using System.Linq;
+using System.Windows.Controls;
+using Visibility = System.Windows.Visibility;
+using Dropbox.Api.FileProperties;
+using ComPDFKitViewer.PdfViewer;
+using PDF_Office.Model;
+using PDF_Office.Model.EditTools.Background;
+using PDFSettings;
+
+namespace PDF_Office.ViewModels.EditTools.Background
+{
+    public class BackgroundContentViewModel : BindableBase, INavigationAware
+    {
+        public IEventAggregator eventAggregator;
+        public IRegionManager backgroundRegion;
+
+        private CPDFViewer PDFViewer;
+
+        private ViewContentViewModel viewContentViewModel;
+
+        public string TemplateListBaseName = "BackgroundTemplateListBaseContent";
+        public string CreateBaseName = "BackgroundCreateBaseContent";
+
+        public string CreateModColorName = "BackgroundCreateColorContent";
+        public string CreateModFileName = "BackgroundCreateFileContent";
+
+        public string TemplateListModColorName = "BackgroundTemplateListColorContent";
+        public string TemplateListModFileName = "BackgroundTemplateListFileContent";
+
+        public string BackgroundDocumentName = "BackgroundDocumentContent";
+
+        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 string _backgroundDocumentRegionName;
+        /// <summary>
+        /// 持有Document的Region,负责渲染和保存
+        /// </summary>
+        public string BackgroundDocumentRegionName
+        {
+            get { return _backgroundDocumentRegionName; }
+            set { _backgroundDocumentRegionName = value; }
+        }
+
+        private Visibility _backgroundDocumentVisible = Visibility.Visible;
+        /// <summary>
+        /// 持有Document的Region可见
+        /// </summary>
+        public Visibility BackgroundDocumentVisible
+        {
+            get { return _backgroundDocumentVisible; }
+            set { _backgroundDocumentVisible = 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; }
+        }
+
+        /// <summary>
+        /// 退出EditTool
+        /// </summary>
+        public DelegateCommand CloseEditToolCommand { get; set; }
+        public DelegateCommand ConfirmEditToolCommand { get; set; }
+        public DelegateCommand<string> EnterSelectedContentCommand { get; set; }
+
+
+        public string Unicode = null;
+
+        public BackgroundContentViewModel(IRegionManager regionManager, IEventAggregator eventAggregator)
+        {
+            this.eventAggregator = eventAggregator;
+            this.backgroundRegion = regionManager;
+            Unicode = App.mainWindowViewModel.SelectedItem.Unicode;
+            BackgroundSettingsVisible = Visibility.Visible;
+            BackgroundSettingsRegionName = Guid.NewGuid().ToString();
+            BackgroundDocumentRegionName = Guid.NewGuid().ToString();
+
+            CloseEditToolCommand = new DelegateCommand(CloseEditTool);
+            ConfirmEditToolCommand = new DelegateCommand(ConfirmEditTool);
+            EnterSelectedContentCommand = new DelegateCommand<string>(EnterSelectedContent);
+
+            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);
+        }
+
+        public void CloseEditTool()
+        {
+            this.eventAggregator.GetEvent<CloseEditToolEvent>().Publish(new EnumCloseModeUnicode { Unicode = Unicode, Status = EnumCloseMode.StatusCancel });
+        }
+
+        public void ConfirmEditTool()
+        {
+            this.eventAggregator.GetEvent<ConfirmEditToolsBackgroundEvent>().Publish();
+            this.eventAggregator.GetEvent<CloseEditToolEvent>().Publish(new EnumCloseModeUnicode { Unicode=Unicode,Status= EnumCloseMode.StatusConfirm });
+        }
+
+        public void EnterTemplateListOrCreate(EnumTemplateListOrCreateUnicode enumTemplateListOrCreateunicode)
+        {
+            EnumTemplateListOrCreate enumTemplateListOrCreate= enumTemplateListOrCreateunicode.Status;
+            if (enumTemplateListOrCreate == EnumTemplateListOrCreate.StatusTemplate)
+            {
+                EnterSelectedContent(TemplateListBaseName);
+            }
+            else
+            {
+                EnterSelectedContent(CreateBaseName);
+            }
+        }
+
+        public void SetCurrentCreateMod(stringUnicode currentCreateModNameunicode)
+        {
+            string currentCreateModName = currentCreateModNameunicode.Status;
+            if (currentCreateModName == CreateModColorName)
+            {
+                CurrentCreateMod = EnumColorOrFile.StatusColor;
+            }
+            else if (currentCreateModName == CreateModFileName)
+            {
+                CurrentCreateMod = 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;
+        }
+
+        public void SetCurrentTemplateListMod(stringUnicode currentTemplateListModNameunicode)
+        {
+            string currentTemplateListModName = currentTemplateListModNameunicode.Status;
+            if (currentTemplateListModName == TemplateListModColorName)
+            {
+                CurrentTemplateListMod = EnumColorOrFile.StatusColor;
+            }
+            else if (currentTemplateListModName == TemplateListModFileName)
+            {
+                CurrentTemplateListMod = EnumColorOrFile.StatusFile;
+            }
+        }
+
+        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 EnterDocumentContent()
+        {
+            NavigationParameters param = new NavigationParameters();
+            param.Add(ParameterNames.PDFViewer, PDFViewer);
+            param.Add(ParameterNames.ViewContentViewModel, viewContentViewModel);
+            backgroundRegion.RequestNavigate(BackgroundDocumentRegionName, BackgroundDocumentName, param);
+            BackgroundDocumentVisible = Visibility.Visible;
+        }
+
+        public void OnNavigatedTo(NavigationContext navigationContext)
+        {
+            navigationContext.Parameters.TryGetValue<ViewContentViewModel>(ParameterNames.ViewContentViewModel, out viewContentViewModel);
+            navigationContext.Parameters.TryGetValue<CPDFViewer>(ParameterNames.PDFViewer, out PDFViewer);
+            EnterSelectedContent(TemplateListBaseName);
+            EnterDocumentContent();
+        }
+
+        public bool IsNavigationTarget(NavigationContext navigationContext)
+        {
+            return true;
+        }
+
+        public void OnNavigatedFrom(NavigationContext navigationContext)
+        {
+        }
+    }
+}

+ 160 - 11
PDF Office/ViewModels/EditTools/Background/BackgroundCreateBaseContentViewModel.cs

@@ -1,5 +1,12 @@
-using PDF_Office.EventAggregators;
+using ComPDFKitViewer.PdfViewer;
+using DryIoc;
+using PDF_Office.EventAggregators;
+using PDF_Office.Model;
+using PDF_Office.Model.EditTools.Background;
+using PDF_Office.Views.EditTools.Background;
+using PDFSettings;
 using Prism.Commands;
+using Prism.Common;
 using Prism.Events;
 using Prism.Mvvm;
 using Prism.Regions;
@@ -8,6 +15,7 @@ using System.Collections.Generic;
 using System.Linq;
 using System.Text;
 using System.Threading.Tasks;
+using System.Windows;
 using System.Windows.Controls;
 
 namespace PDF_Office.ViewModels.EditTools.Background
@@ -17,6 +25,35 @@ namespace PDF_Office.ViewModels.EditTools.Background
         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;
 
@@ -26,11 +63,11 @@ namespace PDF_Office.ViewModels.EditTools.Background
             set => SetProperty(ref backgroundCreateRegionName, value);
         }
 
-        private string _currentCreateName;
-        public string CurrentCreateName
+        private string _currentCreateModName;
+        public string CurrentCreateModName
         {
-            get => _currentCreateName;
-            set=>_currentCreateName= value;
+            get => _currentCreateModName;
+            set => _currentCreateModName = value;
         }
 
 
@@ -41,28 +78,100 @@ namespace PDF_Office.ViewModels.EditTools.Background
             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 BackgroundCreateBaseContentViewModel(IRegionManager regionManager,IEventAggregator eventAggregator)
+        public BackgroundCreateBaseContentViewModel(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);
-            EnterSelectedCreateMod("BackgroundCreateColorContent");
+            SaveToTemplateListCommand = new DelegateCommand(SaveToTemplateList);
+            SaveToCurrentTemplateListCommand = new DelegateCommand(SaveToCurrentTemplateList);
+        }
+
+        public void SaveToTemplateList()
+        {
+            if (CurrentCreateModName == "BackgroundCreateColorContent")
+            {
+                this.eventAggregator.GetEvent<SaveBackgroundTemplateEvent>().Publish(new EnumColorOrFileUnicode { Unicode = Unicode, Status = EnumColorOrFile.StatusColor });
+            }
+            if (CurrentCreateModName == "BackgroundCreateFileContent")
+            {
+                this.eventAggregator.GetEvent<SaveBackgroundTemplateEvent>().Publish(new EnumColorOrFileUnicode
+                {
+                    Unicode = Unicode,
+                    Status = EnumColorOrFile.StatusFile
+                });
+            }
+        }
+
+        public void SaveToCurrentTemplateList()
+        {
+            if (CurrentCreateModName == "BackgroundCreateColorContent")
+            {
+                eventAggregator.GetEvent<ConfirmEditBackgroundTemplateItemEvent>().Publish(new EnumColorOrFileUnicode {
+                    Unicode = Unicode, Status = EnumColorOrFile.StatusColor});
+            }
+            if (CurrentCreateModName == "BackgroundCreateFileContent")
+            {
+                eventAggregator.GetEvent<ConfirmEditBackgroundTemplateItemEvent>().Publish(new EnumColorOrFileUnicode {
+                    Unicode = Unicode, Status = EnumColorOrFile.StatusFile});
+            }
         }
 
         public void EnterTemplateList()
         {
-            this.eventAggregator.GetEvent<EnterTemplateListOrCreateEvent>().Publish(EnumTemplateListOrCreate.StatusTemplate);
+            this.eventAggregator.GetEvent<EnterTemplateListOrCreateEvent>().Publish(new EnumTemplateListOrCreateUnicode {Unicode = Unicode, Status = EnumTemplateListOrCreate.StatusTemplate});
         }
 
         public void EnterSelectedCreateMod(string currentCreateName)
         {
-            backgroundCreateRegion.RequestNavigate(BackgroundCreateRegionName, 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;
         }
 
@@ -71,8 +180,23 @@ namespace PDF_Office.ViewModels.EditTools.Background
             var args = e as Button;
             if (args != null)
             {
-                CurrentCreateName = args.Name;
-                EnterSelectedCreateMod(CurrentCreateName);
+                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
+                    });
+                }
             }
         }
 
@@ -87,6 +211,31 @@ namespace PDF_Office.ViewModels.EditTools.Background
 
         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 = "BackgroundCreateColorContent";
+            }
+            else
+            {
+                CurrentCreateModName = "BackgroundCreateFileContent";
+            }
+            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
+            });
         }
     }
 }

+ 506 - 2
PDF Office/ViewModels/EditTools/Background/BackgroundCreateColorContentViewModel.cs

@@ -1,14 +1,512 @@
-using Prism.Regions;
+using ComPDFKit.PDFDocument;
+using ComPDFKitViewer.PdfViewer;
+using PDF_Office.EventAggregators;
+using PDF_Office.Helper;
+using PDF_Office.Model;
+using PDF_Office.Model.EditTools.Background;
+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.ComponentModel;
+using System.IO;
 using System.Linq;
 using System.Text;
 using System.Threading.Tasks;
+using System.Windows.Forms;
+using System.Windows.Media;
+using static System.Windows.Forms.VisualStyles.VisualStyleElement;
 
 namespace PDF_Office.ViewModels.EditTools.Background
 {
-    internal class BackgroundCreateColorContentViewModel : INavigationAware
+
+    public class BackgroundCreateColorContentViewModel : 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 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;
+                eventAggregator.GetEvent<SetBackgroundEvent>().Publish(new BackgroundInfoUnicode
+                {
+                    Unicode = Unicode,
+                    Status = BackgroundInfo
+                });
+            }
+        }
+
+        private int _opacityValue = 100;
+        public int OpacityValue
+        {
+            get { return _opacityValue; }
+            set
+            {
+                SetProperty(ref _opacityValue, value);
+                BackgroundInfo.Opacity = (byte)(((float)value / 100) * 255);
+                eventAggregator.GetEvent<SetBackgroundEvent>().Publish(new BackgroundInfoUnicode
+                {
+                    Unicode = Unicode,
+                    Status = BackgroundInfo
+                });
+            }
+        }
+
+        private int _relativeRatioValue = 0;
+        public int RelativeRatioValue
+        {
+            get { return _relativeRatioValue; }
+            set
+            {
+                SetProperty(ref _rotationValue, value);
+                BackgroundInfo.RelativeRatio = value;
+            }
+        }
+
+        private string _verticalOffsetValue = "0";
+        public string VerticalOffsetValue
+        {
+            get { return _verticalOffsetValue; }
+            set
+            {
+                SetProperty(ref _verticalOffsetValue, value);
+                BackgroundInfo.VertOffset = float.Parse(VerticalOffsetValue);
+                eventAggregator.GetEvent<SetBackgroundEvent>().Publish(new BackgroundInfoUnicode
+                {
+                    Unicode = Unicode,
+                    Status = BackgroundInfo
+                });
+            }
+        }
+
+        private string _horizontalOffset = "0";
+        public string HorizontalOffsetValue
+        {
+            get { return _horizontalOffset; }
+            set
+            {
+                SetProperty(ref _horizontalOffset, value);
+                BackgroundInfo.HorizOffset = float.Parse(HorizontalOffsetValue);
+                eventAggregator.GetEvent<SetBackgroundEvent>().Publish(new BackgroundInfoUnicode
+                {
+                    Unicode = Unicode,
+                    Status = BackgroundInfo
+                });
+            }
+        }
+
+        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);
+                eventAggregator.GetEvent<SetBackgroundEvent>().Publish(new BackgroundInfoUnicode
+                {
+                    Unicode = Unicode,
+                    Status = BackgroundInfo
+                });
+            }
+        }
+
+        private string _pageRangeText { get; set; } = "0";
+        public string PageRangeText
+        {
+            get { return _pageRangeText; }
+            set
+            {
+                _pageRangeText = value;
+                EditToolsHelper.GetPageRange(PageRangeSelectIndex, PDFViewer.Document, ref BackgroundInfo.PageRange, PageRangeText);
+                eventAggregator.GetEvent<SetBackgroundEvent>().Publish(new BackgroundInfoUnicode
+                {
+                    Unicode = Unicode,
+                    Status = BackgroundInfo
+                });
+            }
+        }
+
+        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);
+                eventAggregator.GetEvent<SetBackgroundEvent>().Publish(new BackgroundInfoUnicode
+                {
+                    Unicode = Unicode,
+                    Status = BackgroundInfo
+                });
+            }
+        }
+
+
+
+        public DelegateCommand<object> ChangeLocationCommand { get; set; }
+        public DelegateCommand<object> ChangeColorCommand { get; set; }
+
+        public string unicode = null;
+        public string Unicode = null;
+
+        public BackgroundCreateColorContentViewModel(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()
+        {
+            InitOpacityList();
+            InitRotationList();
+            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);
+                eventAggregator.GetEvent<SetBackgroundEvent>().Publish(new BackgroundInfoUnicode
+                {
+                    Unicode = Unicode,
+                    Status = BackgroundInfo
+                });
+                InitLocationButtonMatrix();
+            }
+        }
+
+
+        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 = backgroundInfo.BackgroundType;
+                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.scale = backgroundInfo.Scale;
+                backgroundItem.PageRangeIndex = backgroundInfo.PageRangeIndex;
+                backgroundItem.pageRange = backgroundInfo.PageRange;
+                backgroundItem.scale = backgroundInfo.Scale;
+            }
+
+        }
+
+        public void SaveCurrentTemplate()
+        {
+            var backgroundItem = new BackgroundItem();
+            ConvertInfoToItem(ref backgroundItem, BackgroundInfo);
+            backgroundItem.templateName += Settings.Default.WatermarkIndex.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 = 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.SetColor(BackgroundInfo.Color);
+                    tempBackground.SetScale(1);
+                    tempBackground.SetRotation(BackgroundInfo.Rotation);
+                    tempBackground.SetOpacity(BackgroundInfo.Opacity);
+                    tempBackground.SetVertalign(BackgroundInfo.Vertalign);
+                    tempBackground.SetHorizalign(BackgroundInfo.Horizalign);
+                    tempBackground.SetXOffset(BackgroundInfo.HorizOffset);
+                    tempBackground.SetYOffset(BackgroundInfo.VertOffset);
+                    tempBackground.SetPages(BackgroundInfo.PageRange);
+                    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.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 = 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;
+                backgroundInfo.PageRangeIndex = backgroundItem.PageRangeIndex;
+                backgroundInfo.PageRange = backgroundItem.pageRange;
+            }
+        }
+
+        /// <summary>
+        /// 根据已知Info初始化
+        /// </summary>
+        public void InitComponentBySelectedInfo()
+        {
+            ConvertItemToInfo(TemplateBackgroundItem, ref BackgroundInfo);
+            Color = EditToolsHelper.ConvertColor(BackgroundInfo.Color);
+            RotationValue = (int)BackgroundInfo.Rotation;
+            InitLocationButtonMatrix();
+            HorizontalOffsetValue = (BackgroundInfo.HorizOffset).ToString();
+            VerticalOffsetValue = (BackgroundInfo.VertOffset).ToString();
+        }
+
+        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 = 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.SetColor(BackgroundInfo.Color);
+                        tempBackground.SetScale(1);
+                        tempBackground.SetRotation(BackgroundInfo.Rotation);
+                        tempBackground.SetOpacity(BackgroundInfo.Opacity);
+                        tempBackground.SetVertalign(BackgroundInfo.Vertalign);
+                        tempBackground.SetHorizalign(BackgroundInfo.Horizalign);
+                        tempBackground.SetXOffset(BackgroundInfo.HorizOffset);
+                        tempBackground.SetYOffset(BackgroundInfo.VertOffset);
+                        tempBackground.SetPages(BackgroundInfo.PageRange);
+                        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.StatusColor)
+            {
+                SaveCurrentTemplate();
+            }
+        }
         public bool IsNavigationTarget(NavigationContext navigationContext)
         {
             return true;
@@ -20,6 +518,12 @@ namespace PDF_Office.ViewModels.EditTools.Background
 
         public void OnNavigatedTo(NavigationContext navigationContext)
         {
+
+            navigationContext.Parameters.TryGetValue<CPDFViewer>(ParameterNames.PDFViewer, out PDFViewer);
+            if (navigationContext.Parameters.TryGetValue<BackgroundItem>("BackgroundItem", out TemplateBackgroundItem))
+            {
+                InitComponentBySelectedInfo();
+            }
         }
     }
 }

+ 495 - 2
PDF Office/ViewModels/EditTools/Background/BackgroundCreateFileContentViewModel.cs

@@ -1,14 +1,501 @@
-using Prism.Regions;
+using ComPDFKit.PDFDocument;
+using ComPDFKit.PDFPage;
+using ComPDFKitViewer.PdfViewer;
+using PDF_Office.EventAggregators;
+using PDF_Office.Helper;
+using PDF_Office.Model;
+using PDF_Office.Model.EditTools.Background;
+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.Drawing.Printing;
+using System.IO;
 using System.Linq;
 using System.Text;
 using System.Threading.Tasks;
+using System.Windows;
+using static System.Windows.Forms.VisualStyles.VisualStyleElement.TrayNotify;
 
 namespace PDF_Office.ViewModels.EditTools.Background
 {
-    internal class BackgroundCreateFileContentViewModel : INavigationAware
+    public class BackgroundCreateFileContentViewModel : 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 = ((float)RotationValue / 180) * 3.1415926f;
+                eventAggregator.GetEvent<SetBackgroundEvent>().Publish(new BackgroundInfoUnicode
+                {
+                    Unicode = Unicode,
+                    Status = BackgroundInfo
+                });
+            }
+        }
+
+
+        private int _opacityValue = 100;
+        public int OpacityValue
+        {
+            get { return _opacityValue; }
+            set
+            {
+                SetProperty(ref _opacityValue, value);
+                BackgroundInfo.Opacity = (byte)(((float)OpacityValue / 100) * 225);
+                eventAggregator.GetEvent<SetBackgroundEvent>().Publish(new BackgroundInfoUnicode
+                {
+                    Unicode = Unicode,
+                    Status = BackgroundInfo
+                });
+            }
+        }
+
+        private int _relativeRatioValue = 0;
+        public int RelativeRatioValue
+        {
+            get { return _relativeRatioValue; }
+            set { SetProperty(ref _relativeRatioValue, value); }
+        }
+
+        private string _verticalOffsetValue = "0";
+        public string VerticalOffsetValue
+        {
+            get { return _verticalOffsetValue; }
+            set
+            {
+                SetProperty(ref _verticalOffsetValue, value);
+                BackgroundInfo.VertOffset = float.Parse(VerticalOffsetValue);
+                eventAggregator.GetEvent<SetBackgroundEvent>().Publish(new BackgroundInfoUnicode
+                {
+                    Unicode = Unicode,
+                    Status = BackgroundInfo
+                });
+            }
+        }
+
+        private string _horizOffsetValue = "0";
+        public string HorizontalOffsetValue
+        {
+            get { return _horizOffsetValue; }
+            set
+            {
+                SetProperty(ref _horizOffsetValue, value);
+                BackgroundInfo.HorizOffset = float.Parse(HorizontalOffsetValue);
+                eventAggregator.GetEvent<SetBackgroundEvent>().Publish(new BackgroundInfoUnicode
+                {
+                    Unicode = Unicode,
+                    Status = BackgroundInfo
+                });
+            }
+        }
+
+
+
+        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);
+        }
+
+
+        public DelegateCommand OpenFileCommand { get; set; }
+        public DelegateCommand<object> ChangeLocationCommand { get; set; }
+
+        public string unicode = null;
+        public string Unicode = null;
+
+        public BackgroundCreateFileContentViewModel(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);
+                eventAggregator.GetEvent<SetBackgroundEvent>().Publish(new BackgroundInfoUnicode { Unicode=Unicode,Status=BackgroundInfo});
+            }
+        }
+
+        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()
+        {
+            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 InitComponentBySelectedInfo()
+        {
+
+        }
+
+        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);
+                eventAggregator.GetEvent<SetBackgroundEvent>().Publish(new BackgroundInfoUnicode
+                {
+                    Unicode = Unicode,
+                    Status = BackgroundInfo
+                });
+                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;
+                eventAggregator.GetEvent<SetBackgroundEvent>().Publish(new BackgroundInfoUnicode
+                {
+                    Unicode = Unicode,
+                    Status = BackgroundInfo
+                });
+            }
+        }
+
+        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 ConvertInfoToItem(ref BackgroundItem backgroundItem, BackgroundInfo backgroundInfo)
+        {
+            backgroundItem.type = backgroundInfo.BackgroundType;
+            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.scale = backgroundInfo.Scale;
+            //backgroundItem.pagRangeMode = backgroundInfo.PageRange;
+        }
+
+        public void SaveCurrentTemplate()
+        {
+            var backgroundItem = new BackgroundItem();
+            ConvertInfoToItem(ref backgroundItem, BackgroundInfo);
+            backgroundItem.templateName += Settings.Default.WatermarkIndex.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 = 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);
+                    tempBackground.SetScale(1);
+                    tempBackground.SetRotation(BackgroundInfo.Rotation);
+                    tempBackground.SetOpacity(BackgroundInfo.Opacity);
+                    tempBackground.SetVertalign(BackgroundInfo.Vertalign);
+                    tempBackground.SetHorizalign(BackgroundInfo.Horizalign);
+                    tempBackground.SetXOffset(BackgroundInfo.HorizOffset);
+                    tempBackground.SetYOffset(BackgroundInfo.VertOffset);
+                    tempBackground.SetPages(BackgroundInfo.PageRange);
+                    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.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);
+                        tempBackground.SetScale(1);
+                        tempBackground.SetRotation(BackgroundInfo.Rotation);
+                        tempBackground.SetOpacity(BackgroundInfo.Opacity);
+                        tempBackground.SetVertalign(BackgroundInfo.Vertalign);
+                        tempBackground.SetHorizalign(BackgroundInfo.Horizalign);
+                        tempBackground.SetXOffset(BackgroundInfo.HorizOffset);
+                        tempBackground.SetYOffset(BackgroundInfo.VertOffset);
+                        tempBackground.SetPages(BackgroundInfo.PageRange);
+                        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;
@@ -20,6 +507,12 @@ namespace PDF_Office.ViewModels.EditTools.Background
 
         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();
+            }
         }
     }
 }

+ 268 - 0
PDF Office/ViewModels/EditTools/Background/BackgroundDocumentContentViewModel.cs

@@ -0,0 +1,268 @@
+using ComPDFKit.PDFDocument;
+using ComPDFKit.PDFPage;
+using ComPDFKit.PDFWatermark;
+using ComPDFKitViewer;
+using ComPDFKitViewer.PdfViewer;
+using PDF_Office.EventAggregators;
+using PDF_Office.Helper;
+using PDF_Office.Model;
+using PDF_Office.Model.EditTools.Background;
+using PDF_Office.Model.EditTools.Watermark;
+using Prism.Commands;
+using Prism.Events;
+using Prism.Mvvm;
+using Prism.Regions;
+using System;
+using System.Collections.Generic;
+using System.Diagnostics;
+using System.Drawing;
+using System.Linq;
+using System.Text.RegularExpressions;
+using System.Threading.Tasks;
+using System.Windows;
+using System.Windows.Controls;
+using System.Windows.Media;
+using System.Windows.Media.Imaging;
+using Size = System.Windows.Size;
+
+namespace PDF_Office.ViewModels.EditTools.Background
+{
+    public class BackgroundDocumentContentViewModel : BindableBase, INavigationAware
+    {
+        public IEventAggregator eventAggregator;
+        public IRegionManager regionManager;
+        public CPDFViewer PDFViewer;
+        public CPDFDocument Document;
+        private ViewContentViewModel viewContentViewModel;
+        CPDFViewer pdfViewer;
+
+        private CPDFBackground background;
+        private BackgroundInfo backgroundInfo;
+
+        public bool firstin = true;
+
+        public string ViewerRegionName { get; set; }
+
+        public string unicode = null;
+        public string Unicode = null;
+
+        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 BackgroundDocumentContentViewModel(IEventAggregator eventAggregator, IRegionManager regionManager)
+        {
+            this.regionManager = regionManager;
+            this.eventAggregator = eventAggregator;
+            Unicode = App.mainWindowViewModel.SelectedItem.Unicode;
+
+           ShowInputIndexBoxCommand = new DelegateCommand<object>(ShowInputIndexBox);
+            GoToPageCommand = new DelegateCommand<object>(GoToPage);
+
+            eventAggregator.GetEvent<ConfirmEditToolsBackgroundEvent>().Subscribe(ConfirmEditToolsBackground);
+            eventAggregator.GetEvent<SetBackgroundEvent>().Subscribe(SetBackground, e => e.Unicode == Unicode);
+            ViewerRegionName = RegionNames.BackgroundViewerRegionName;
+        }
+
+        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 ConfirmEditToolsBackground()
+        {
+            if (backgroundInfo != null)
+            {
+                CreateBackground(viewContentViewModel.PDFViewer.Document);
+            }
+        }
+
+        public void SetBackground(BackgroundInfoUnicode backgroundInfounicode)
+        {
+            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)
+        {
+            if (backgroundInfo != null)
+            {
+                background = document.GetBackground();
+                if (backgroundInfo.BackgroundType == C_Background_Type.BG_TYPE_COLOR)
+                {
+                    background.SetBackgroundType(C_Background_Type.BG_TYPE_COLOR);
+                    background.SetColor(backgroundInfo.Color);
+                }
+                else
+                {
+                    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);
+                background.SetVertalign(backgroundInfo.Vertalign);
+                background.SetHorizalign(backgroundInfo.Horizalign);
+                background.SetXOffset(backgroundInfo.HorizOffset);
+                background.SetYOffset(backgroundInfo.VertOffset);
+                background.SetAllowsPrint(true);
+                background.SetAllowsView(true);
+                if (IsNewDoc) { background.SetPages("0"); }
+                else
+                {
+                    background.SetPages(backgroundInfo.PageRange);
+                }
+                background.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 (backgroundInfo != null)
+                    {
+                        char[] enumerationSeparator = new char[] { ',' };
+                        char[] rangeSeparator = new char[] { '-' };
+                        if (CommonHelper.GetPagesInRange(ref PageIndexLists, backgroundInfo.PageRange, Document.PageCount, enumerationSeparator, rangeSeparator, true))
+                        { //TODO
+                            if (PageIndexLists.Contains(drawPageData.PageIndex - 1))
+                            {
+                                WriteableBitmap backgroundBitmap = GetBackground(PDFViewer.Document, e.Zoom, drawPageData.PageIndex);
+                                e.DrawContext.DrawImage(backgroundBitmap, drawPageData.PageBound);
+                            }
+                        }
+                    }
+                }
+            }
+            CurrentPageIndex = PDFViewer.CurrentIndex + 1;
+        }
+
+        private WriteableBitmap GetBackground(CPDFDocument oldDoc, double zoom, int pageIndex)
+        {
+            Size pageSize = oldDoc.GetPageSize(pageIndex);
+
+            CPDFDocument newDoc = CPDFDocument.CreateDocument();
+            newDoc.InsertPage(0, pageSize.Width, pageSize.Height, null);
+            CreateBackground(newDoc, true);
+            CPDFPage newPage = newDoc.PageAtIndex(0);
+            double scale = 96.0 / 72.0;
+            zoom = zoom * scale;
+            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);
+            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;
+        }
+
+        public void OnNavigatedFrom(NavigationContext navigationContext)
+        {
+
+        }
+
+        public void OnNavigatedTo(NavigationContext navigationContext)
+        {
+            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))
+                {
+                    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;
+                }
+            }
+        }
+    }
+}
+
+
+
+
+
+
+
+
+
+
+

+ 141 - 92
PDF Office/ViewModels/EditTools/Background/BackgroundTemplateListBaseContentViewModel.cs

@@ -1,92 +1,141 @@
-using Dropbox.Api.FileProperties;
-using PDF_Office.EventAggregators;
-using Prism.Commands;
-using Prism.Events;
-using Prism.Mvvm;
-using Prism.Regions;
-using System;
-using System.Collections.Generic;
-using System.Drawing.Printing;
-using System.Linq;
-using System.Text;
-using System.Threading.Tasks;
-using System.Windows.Controls;
-
-namespace PDF_Office.ViewModels.EditTools.Background
-{
-    public class BackgroundTemplateListBaseContentViewModel : BindableBase, INavigationAware
-    {
-        public IRegionManager backgroundTemplateListRegion;
-        private readonly IEventAggregator eventAggregator;
-
-        private string _currentTemplateListName;
-        public string CurrentTemplateListName
-        {
-            get { return _currentTemplateListName; }
-            set { _currentTemplateListName = 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);
-        }
-
-        public DelegateCommand<object> ChangeTemplateListModCommand { get; set; }
-        public DelegateCommand EnterCreateCommand { get; set; }
-
-        public BackgroundTemplateListBaseContentViewModel(IRegionManager backgroundTemplateListRegion, IEventAggregator eventAggregator)
-        {
-            this.backgroundTemplateListRegion = backgroundTemplateListRegion;
-            this.eventAggregator = eventAggregator;
-            BackgroundTemplateListRegionName = Guid.NewGuid().ToString();
-            ChangeTemplateListModCommand = new DelegateCommand<object>(ChangeTemplateListMod);
-            EnterCreateCommand = new DelegateCommand(EnterCreate);
-            EnterSelectedTemplateListMod("BackgroundTemplateListColorContent");
-        }
-
-        public void EnterCreate()
-        {
-            this.eventAggregator.GetEvent<EnterTemplateListOrCreateEvent>().Publish(EnumTemplateListOrCreate.StatusCreate);
-        }
-
-        public void EnterSelectedTemplateListMod(string currentTemplateListName)
-        {
-            backgroundTemplateListRegion.RequestNavigate(BackgroundTemplateListRegionName, currentTemplateListName);
-            backgroundTemplateListVisible = System.Windows.Visibility.Visible;
-        }
-
-        public void ChangeTemplateListMod(object e)
-        {
-            var args = e as Button;
-            if (args != null)
-            {
-                CurrentTemplateListName = args.Name;
-                EnterSelectedTemplateListMod(CurrentTemplateListName);
-            }
-        }
-
-        public bool IsNavigationTarget(NavigationContext navigationContext)
-        {
-            return true;
-        }
-
-        public void OnNavigatedFrom(NavigationContext navigationContext)
-        {
-        }
-
-        public void OnNavigatedTo(NavigationContext navigationContext)
-        {
-        }
-    }
-}
+using ComPDFKitViewer.PdfViewer;
+using Dropbox.Api.FileProperties;
+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.Drawing.Printing;
+using System.Linq;
+using System.Text;
+using System.Threading.Tasks;
+using System.Windows.Controls;
+
+namespace PDF_Office.ViewModels.EditTools.Background
+{
+    public class BackgroundTemplateListBaseContentViewModel : BindableBase, INavigationAware
+    {
+        public IRegionManager backgroundTemplateListRegion;
+        private readonly IEventAggregator eventAggregator;
+
+        private string BackgroundTemplateListColorContentName = "BackgroundTemplateListColorContent";
+        private string BackgroundTemplateListFileContentName = "BackgroundTemplateListFileContent";
+
+        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 BackgroundTemplateListBaseContentViewModel(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 = "BackgroundTemplateListColorContent";
+                }
+                else
+                {
+                    CurrentTemplateListModName = "BackgroundTemplateListFileContent";
+                }
+                EnterSelectedTemplateListMod(CurrentTemplateListModName);
+                eventAggregator.GetEvent<SetCurrentTemplateListModEvent>().Publish(new stringUnicode
+                {
+                    Unicode = Unicode,
+                    Status = CurrentTemplateListModName
+                });
+
+            }
+        }
+    }
+}

+ 249 - 25
PDF Office/ViewModels/EditTools/Background/BackgroundTemplateListColorContentViewModel.cs

@@ -1,25 +1,249 @@
-using Prism.Regions;
-using System;
-using System.Collections.Generic;
-using System.Linq;
-using System.Text;
-using System.Threading.Tasks;
-
-namespace PDF_Office.ViewModels.EditTools.Background
-{
-    internal class BackgroundTemplateListColorContentViewModel : INavigationAware
-    {
-        public bool IsNavigationTarget(NavigationContext navigationContext)
-        {
-            return true;
-        }
-
-        public void OnNavigatedFrom(NavigationContext navigationContext)
-        {
-        }
-
-        public void OnNavigatedTo(NavigationContext navigationContext)
-        {
-        }
-    }
-}
+using Microsoft.Office.Interop.Word;
+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.Security.Permissions;
+using System.Text;
+using System.Threading.Tasks;
+using System.Windows;
+using System.Windows.Controls;
+using static System.Windows.Forms.VisualStyles.VisualStyleElement;
+
+namespace PDF_Office.ViewModels.EditTools.Background
+{
+
+    public class BackgroundTemplateListColorContentViewModel : 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 BackgroundTemplateListColorContentViewModel(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);
+                eventAggregator.GetEvent<SetBackgroundEvent>().Publish(new BackgroundInfoUnicode
+                {
+                    Unicode = Unicode,
+                    Status = 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)
+        {
+
+            navigationContext.Parameters.TryGetValue<string>("UniCode", out unicode);
+            InitBackgroundTemplateList();
+        }
+    }
+}

+ 225 - 2
PDF Office/ViewModels/EditTools/Background/BackgroundTemplateListFileContentViewModel.cs

@@ -1,14 +1,236 @@
-using Prism.Regions;
+using PDF_Office.EventAggregators;
+using PDF_Office.Model.EditTools.Background;
+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.Text;
 using System.Threading.Tasks;
+using System.Windows;
+using System.Windows.Controls;
 
 namespace PDF_Office.ViewModels.EditTools.Background
 {
-    public class BackgroundTemplateListFileContentViewModel : INavigationAware
+    public class BackgroundTemplateListFileContentViewModel : 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 BackgroundTemplateListFileContentViewModel(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);
+            eventAggregator.GetEvent<SetBackgroundEvent>().Publish(new BackgroundInfoUnicode
+            {
+                Unicode = Unicode,
+                Status = 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;
@@ -20,6 +242,7 @@ namespace PDF_Office.ViewModels.EditTools.Background
 
         public void OnNavigatedTo(NavigationContext navigationContext)
         {
+            InitBackgroundTemplateList();
         }
     }
 }

+ 159 - 0
PDF Office/ViewModels/EditTools/Bates/BatesContentViewModel.cs

@@ -0,0 +1,159 @@
+using PDF_Office.EventAggregators;
+using Prism.Commands;
+using Prism.Events;
+using Prism.Mvvm;
+using Prism.Regions;
+using System.Windows;
+using System;
+using System.Collections.Generic;
+using System.Linq;
+using ComPDFKitViewer.PdfViewer;
+using PDF_Office.Model;
+using PDFSettings;
+
+namespace PDF_Office.ViewModels.EditTools.Bates
+{
+    public class BatesContentViewModel : BindableBase,INavigationAware
+    {
+        public IEventAggregator eventAggregator;
+        public IRegionManager batesRegion;
+
+        private CPDFViewer PDFViewer;
+
+        private ViewContentViewModel viewContentViewModel;
+
+        public string TemplateListName = "BatesTemplateListContent";
+        public string CreateName = "BatesCreateContent";
+
+        public string BatesDocumentName = "BatesDocumentContent";
+
+        public string BatesType = "BatesType";
+
+        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 _batesDocumentRegionName;
+        /// <summary>
+        /// 持有Document的Region,负责渲染和保存
+        /// </summary>
+        public string BatesDocumentRegionName
+        {
+            get { return _batesDocumentRegionName; }
+            set { _batesDocumentRegionName = value; }
+        }
+
+        private Visibility _batesDocumentVisible = Visibility.Visible;
+        /// <summary>
+        /// 持有Document的Region可见
+        /// </summary>
+        public Visibility BatesDocumentVisible
+        {
+            get { return _batesDocumentVisible; }
+            set { _batesDocumentVisible = value; }
+        }
+
+        public DelegateCommand CloseEditToolCommand { get; set; }
+        public DelegateCommand ConfirmEditToolCommand { get; set; }
+
+        public string Unicode = null;
+
+        public BatesContentViewModel(IRegionManager regionManager, IEventAggregator eventAggregator)
+        {
+            this.eventAggregator = eventAggregator;
+            this.batesRegion = regionManager;
+            BatesSettingsRegionName = Guid.NewGuid().ToString();
+            BatesDocumentRegionName = Guid.NewGuid().ToString();
+            Unicode = App.mainWindowViewModel.SelectedItem.Unicode;
+
+            CloseEditToolCommand = new DelegateCommand(CloseEditTool);
+            ConfirmEditToolCommand = new DelegateCommand(ConfirmEditTool);
+            eventAggregator.GetEvent<EditBatesHeaderFooterTemplateItemEvent>().Subscribe(EditBatesTemplateItem, e => e.Unicode == Unicode&&e.Type== BatesType);
+            eventAggregator.GetEvent<EnterTemplateListOrCreateEvent>().Subscribe(EnterTemplateListOrCreate, e => e.Unicode == Unicode);
+
+        }
+        public void CloseEditTool()
+        {
+            this.eventAggregator.GetEvent<CloseEditToolEvent>().Publish(new EnumCloseModeUnicode { Unicode = Unicode, Status = EnumCloseMode.StatusCancel });
+        }
+        public void ConfirmEditTool()
+        {
+
+            this.eventAggregator.GetEvent<CloseEditToolEvent>().Publish(new EnumCloseModeUnicode { Unicode = Unicode, Status = EnumCloseMode.StatusCancel });
+
+        }
+
+        public void EnterSelectedContent(string SelectedContentName)
+        {
+            NavigationParameters param = new NavigationParameters();
+            param.Add(ParameterNames.PDFViewer, PDFViewer);
+            batesRegion.RequestNavigate(BatesSettingsRegionName, SelectedContentName, param);
+            BatesSettingsVisible = Visibility.Visible;
+        }
+
+        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 EnterDocumentContent()
+        {
+            NavigationParameters param = new NavigationParameters();
+            param.Add(ParameterNames.PDFViewer, PDFViewer);
+            param.Add(ParameterNames.ViewContentViewModel, viewContentViewModel);
+            batesRegion.RequestNavigate(BatesDocumentRegionName, BatesDocumentName, param);
+            BatesDocumentVisible = Visibility.Visible;
+        }
+
+        public void EnterTemplateListOrCreate(EnumTemplateListOrCreateUnicode enumTemplateListOrCreateunicode)
+        {
+            EnumTemplateListOrCreate enumTemplateListOrCreate = enumTemplateListOrCreateunicode.Status;
+            if (enumTemplateListOrCreate == EnumTemplateListOrCreate.StatusTemplate)
+            {
+                EnterSelectedContent(TemplateListName);
+            }
+            else
+            {
+                EnterSelectedContent(CreateName);
+            }
+        }
+
+        public void OnNavigatedTo(NavigationContext navigationContext)
+        {
+            navigationContext.Parameters.TryGetValue<ViewContentViewModel>(ParameterNames.ViewContentViewModel, out viewContentViewModel);
+            navigationContext.Parameters.TryGetValue<CPDFViewer>(ParameterNames.PDFViewer, out PDFViewer);
+            EnterSelectedContent(TemplateListName);
+            EnterDocumentContent();
+        }
+
+        public bool IsNavigationTarget(NavigationContext navigationContext)
+        {
+            return true;
+        }
+
+        public void OnNavigatedFrom(NavigationContext navigationContext)
+        {
+        }
+    }
+}

+ 35 - 0
PDF Office/ViewModels/EditTools/Bates/BatesCreateContentViewModel.cs

@@ -0,0 +1,35 @@
+using Prism.Commands;
+using Prism.Events;
+using Prism.Mvvm;
+using Prism.Regions;
+using System;
+using System.Collections.Generic;
+using System.Linq;
+
+namespace PDF_Office.ViewModels.EditTools.Bates
+{
+    public class BatesCreateContentViewModel : BindableBase, INavigationAware
+    {
+        public IEventAggregator eventAggregator;
+        public string Unicode = null;
+
+        public BatesCreateContentViewModel(IEventAggregator eventAggregator)
+        {
+            this.eventAggregator = eventAggregator;
+            Unicode = App.mainWindowViewModel.SelectedItem.Unicode;
+        }
+
+        public bool IsNavigationTarget(NavigationContext navigationContext)
+        {
+            return true;
+        }
+
+        public void OnNavigatedFrom(NavigationContext navigationContext)
+        {
+        }
+
+        public void OnNavigatedTo(NavigationContext navigationContext)
+        {
+        }
+    }
+}

+ 35 - 0
PDF Office/ViewModels/EditTools/Bates/BatesDocumentContentViewModel.cs

@@ -0,0 +1,35 @@
+using Prism.Commands;
+using Prism.Events;
+using Prism.Mvvm;
+using Prism.Regions;
+using System;
+using System.Collections.Generic;
+using System.Linq;
+
+namespace PDF_Office.ViewModels.EditTools.Bates
+{
+    public class BatesDocumentContentViewModel : BindableBase, INavigationAware
+    {
+        public IEventAggregator eventAggregator;
+        public string Unicode = null;
+
+        public BatesDocumentContentViewModel(IEventAggregator eventAggregator)
+        {
+            this.eventAggregator = eventAggregator;
+            Unicode = App.mainWindowViewModel.SelectedItem.Unicode;
+        }
+
+        public bool IsNavigationTarget(NavigationContext navigationContext)
+        {
+            return true;
+        }
+
+        public void OnNavigatedFrom(NavigationContext navigationContext)
+        {
+        }
+
+        public void OnNavigatedTo(NavigationContext navigationContext)
+        {
+        }
+    }
+}

+ 44 - 0
PDF Office/ViewModels/EditTools/Bates/BatesTemplateListContentViewModel.cs

@@ -0,0 +1,44 @@
+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;
+
+namespace PDF_Office.ViewModels.EditTools.Bates
+{
+    public class BatesTemplateListContentViewModel : BindableBase, INavigationAware
+    {
+
+        public DelegateCommand EnterCreateCommand { get; set; }
+        public IEventAggregator eventAggregator;
+        public string Unicode = null;
+
+        public BatesTemplateListContentViewModel(IEventAggregator eventAggregator)
+        {
+            this.eventAggregator = eventAggregator;
+            Unicode = App.mainWindowViewModel.SelectedItem.Unicode;
+            EnterCreateCommand = new DelegateCommand(EnterCreate);
+        }
+
+        public void EnterCreate()
+        {
+            this.eventAggregator.GetEvent<EnterTemplateListOrCreateEvent>().Publish(new EnumTemplateListOrCreateUnicode { Unicode = Unicode, Status = EnumTemplateListOrCreate.StatusCreate });
+        }
+
+        public bool IsNavigationTarget(NavigationContext navigationContext)
+        {
+            return true;
+        }
+
+        public void OnNavigatedFrom(NavigationContext navigationContext)
+        {
+        }
+
+        public void OnNavigatedTo(NavigationContext navigationContext)
+        {
+        }
+    }
+}

+ 160 - 0
PDF Office/ViewModels/EditTools/HeaderFooter/HeaderFooterContentViewModel.cs

@@ -0,0 +1,160 @@
+using PDF_Office.EventAggregators;
+using Prism.Commands;
+using Prism.Events;
+using Prism.Mvvm;
+using Prism.Regions;
+using System.Windows;
+using System;
+using System.Collections.Generic;
+using System.Linq;
+using ComPDFKitViewer.PdfViewer;
+using PDF_Office.Model;
+using PDFSettings;
+
+namespace PDF_Office.ViewModels.EditTools.HeaderFooter
+{
+    public class HeaderFooterContentViewModel : BindableBase, INavigationAware
+    {
+        
+        public IEventAggregator eventAggregator;
+        public IRegionManager headerFooterRegion;
+
+        private CPDFViewer PDFViewer;
+
+        private ViewContentViewModel viewContentViewModel;
+
+        public string TemplateListName = "HeaderFooterTemplateListContent";
+        public string CreateName = "HeaderFooterCreateContent";
+        public string HeaderFooterDocumentName = "HeaderFooterDocumentContent";
+
+        public string HeaderFooterType = "HeaderFooterType";
+
+        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; }
+        }
+
+        private string _headerFooterDocumentRegionName;
+        /// <summary>
+        /// 持有Document的Region,负责渲染和保存
+        /// </summary>
+        public string HeaderFooterDocumentRegionName
+        {
+            get { return _headerFooterDocumentRegionName; }
+            set { _headerFooterDocumentRegionName = value; }
+        }
+
+        private Visibility _headerFooterDocumentVisible = Visibility.Visible;
+        /// <summary>
+        /// 持有Document的Region可见
+        /// </summary>
+        public Visibility HeaderFooterDocumentVisible
+        {
+            get { return _headerFooterDocumentVisible; }
+            set { _headerFooterDocumentVisible = value; }
+        }
+
+        public DelegateCommand CloseEditToolCommand { get; set; }
+        public DelegateCommand ConfirmEditToolCommand { get; set; }
+
+        public string Unicode = null;
+
+        public HeaderFooterContentViewModel(IRegionManager regionManager, IEventAggregator eventAggregator)
+        {
+            this.eventAggregator = eventAggregator;
+            this.headerFooterRegion = regionManager;
+
+            HeaderFooterSettingsRegionName = Guid.NewGuid().ToString();
+            HeaderFooterDocumentRegionName = Guid.NewGuid().ToString();
+            Unicode = App.mainWindowViewModel.SelectedItem.Unicode;
+            CloseEditToolCommand = new DelegateCommand(CloseEditTool);
+            ConfirmEditToolCommand = new DelegateCommand(ConfirmEditTool);
+            eventAggregator.GetEvent<EditBatesHeaderFooterTemplateItemEvent>().Subscribe(EditHeaderFooterTemplateItem, e => e.Unicode == Unicode&&e.Type== HeaderFooterType);
+            eventAggregator.GetEvent<EnterTemplateListOrCreateEvent>().Subscribe(EnterTemplateListOrCreate, e => e.Unicode == Unicode);
+        }
+
+        public void CloseEditTool()
+        {
+            this.eventAggregator.GetEvent<CloseEditToolEvent>().Publish(new EnumCloseModeUnicode { Unicode = Unicode, Status = EnumCloseMode.StatusCancel });
+        }
+        public void ConfirmEditTool()
+        {
+
+            this.eventAggregator.GetEvent<CloseEditToolEvent>().Publish(new EnumCloseModeUnicode { Unicode = Unicode, Status = EnumCloseMode.StatusCancel });
+
+        }
+
+        public void EnterSelectedContent(string SelectedContentName)
+        {
+            NavigationParameters param = new NavigationParameters();
+            param.Add(ParameterNames.PDFViewer, PDFViewer);
+           
+            headerFooterRegion.RequestNavigate(HeaderFooterSettingsRegionName, SelectedContentName, param);
+            HeaderFooterSettingsVisible = Visibility.Visible;
+        }
+
+        public void EnterDocumentContent()
+        {
+            NavigationParameters param = new NavigationParameters();
+            param.Add(ParameterNames.PDFViewer, PDFViewer);
+            param.Add(ParameterNames.ViewContentViewModel, viewContentViewModel);
+            headerFooterRegion.RequestNavigate(HeaderFooterDocumentRegionName, HeaderFooterDocumentName, param);
+            HeaderFooterDocumentVisible = Visibility.Visible;
+        }
+        public void EnterTemplateListOrCreate(EnumTemplateListOrCreateUnicode enumTemplateListOrCreateunicode)
+        {
+            EnumTemplateListOrCreate enumTemplateListOrCreate = enumTemplateListOrCreateunicode.Status;
+            if (enumTemplateListOrCreate == EnumTemplateListOrCreate.StatusTemplate)
+            {
+                EnterSelectedContent(TemplateListName);
+            }
+            else
+            {
+                EnterSelectedContent(CreateName);
+            }
+        }
+
+        public void EditHeaderFooterTemplateItem(BatesHeaderFooterItemUnicode headerfooterItemunicode)
+        {
+            BatesHeaderFooterItem headerfooterItem = headerfooterItemunicode.Status;
+            NavigationParameters param = new NavigationParameters();
+            param.Add(ParameterNames.PDFViewer, PDFViewer);
+            param.Add("BatesItem", headerfooterItem);
+            headerFooterRegion.RequestNavigate(HeaderFooterSettingsRegionName, CreateName, param);
+            HeaderFooterSettingsVisible = Visibility.Visible;
+        }
+
+        public void OnNavigatedTo(NavigationContext navigationContext)
+        {
+            navigationContext.Parameters.TryGetValue<ViewContentViewModel>(ParameterNames.ViewContentViewModel, out viewContentViewModel);
+            navigationContext.Parameters.TryGetValue<CPDFViewer>(ParameterNames.PDFViewer, out PDFViewer);
+            EnterSelectedContent(TemplateListName);
+            EnterDocumentContent();
+        }
+
+        public bool IsNavigationTarget(NavigationContext navigationContext)
+        {
+            return true;
+        }
+
+        public void OnNavigatedFrom(NavigationContext navigationContext)
+        {
+
+        }
+    }
+}

+ 33 - 0
PDF Office/ViewModels/EditTools/HeaderFooter/HeaderFooterCreateContentViewModel.cs

@@ -0,0 +1,33 @@
+using Prism.Commands;
+using Prism.Events;
+using Prism.Mvvm;
+using Prism.Regions;
+using System;
+using System.Collections.Generic;
+using System.Linq;
+
+namespace PDF_Office.ViewModels.EditTools.HeaderFooter
+{
+    public class HeaderFooterCreateContentViewModel : BindableBase, INavigationAware
+    {
+        public IEventAggregator eventAggregator;
+        public string Unicode = null;
+        public HeaderFooterCreateContentViewModel(IEventAggregator eventAggregator)
+        {
+            this.eventAggregator = eventAggregator;
+            Unicode = App.mainWindowViewModel.SelectedItem.Unicode;
+        }
+        public bool IsNavigationTarget(NavigationContext navigationContext)
+        {
+            return true;
+        }
+
+        public void OnNavigatedFrom(NavigationContext navigationContext)
+        {
+        }
+
+        public void OnNavigatedTo(NavigationContext navigationContext)
+        {
+        }
+    }
+}

+ 33 - 0
PDF Office/ViewModels/EditTools/HeaderFooter/HeaderFooterDocumentContentViewModel.cs

@@ -0,0 +1,33 @@
+using Prism.Commands;
+using Prism.Events;
+using Prism.Mvvm;
+using Prism.Regions;
+using System;
+using System.Collections.Generic;
+using System.Linq;
+
+namespace PDF_Office.ViewModels.EditTools.HeaderFooter
+{
+    public class HeaderFooterDocumentContentViewModel : BindableBase, INavigationAware
+    {
+        public IEventAggregator eventAggregator;
+        public string Unicode = null;
+        public HeaderFooterDocumentContentViewModel(IEventAggregator eventAggregator)
+        {
+            this.eventAggregator = eventAggregator;
+            Unicode = App.mainWindowViewModel.SelectedItem.Unicode;
+        }
+        public bool IsNavigationTarget(NavigationContext navigationContext)
+        {
+            return true;
+        }
+
+        public void OnNavigatedFrom(NavigationContext navigationContext)
+        {
+        }
+
+        public void OnNavigatedTo(NavigationContext navigationContext)
+        {
+        }
+    }
+}

+ 43 - 0
PDF Office/ViewModels/EditTools/HeaderFooter/HeaderFooterTemplateListContentViewModel.cs

@@ -0,0 +1,43 @@
+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;
+
+namespace PDF_Office.ViewModels.EditTools.HeaderFooter
+{
+    public class HeaderFooterTemplateListContentViewModel : BindableBase, INavigationAware
+    {
+        public IEventAggregator eventAggregator;
+        public DelegateCommand EnterCreateCommand { get; set; }
+
+        public string Unicode = null;
+        public HeaderFooterTemplateListContentViewModel(IEventAggregator eventAggregator)
+        {
+            this.eventAggregator = eventAggregator;
+            Unicode = App.mainWindowViewModel.SelectedItem.Unicode;
+            EnterCreateCommand = new DelegateCommand(EnterCreate);
+        }
+
+        public void EnterCreate()
+        {
+            this.eventAggregator.GetEvent<EnterTemplateListOrCreateEvent>().Publish(new EnumTemplateListOrCreateUnicode { Unicode = Unicode, Status = EnumTemplateListOrCreate.StatusCreate });
+        }
+
+        public bool IsNavigationTarget(NavigationContext navigationContext)
+        {
+            return true;
+        }
+
+        public void OnNavigatedFrom(NavigationContext navigationContext)
+        {
+        }
+
+        public void OnNavigatedTo(NavigationContext navigationContext)
+        {
+        }
+    }
+}

+ 64 - 0
PDF Office/ViewModels/EditTools/Redaction/RedactionContentViewModel.cs

@@ -0,0 +1,64 @@
+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;
+
+namespace PDF_Office.ViewModels.EditTools.Redaction
+{
+    public class RedactionContentViewModel : BindableBase,INavigationAware
+    {
+        public IEventAggregator eventAggregator;
+
+        public IRegionManager redactionRegion;
+
+        private CPDFViewer PDFViewer;
+
+        public string RedactionDocumentRegionName { get; set; }
+        public string RedactionBottomBarRegionName { get; set; }
+
+        public string RedactionDocumentName = "RedactionDocumentContent";
+
+        public string Unicode = null;
+
+        public DelegateCommand CloseEditToolCommand { get; set; }
+
+        public RedactionContentViewModel(IRegionManager regionManager, IEventAggregator eventAggregator)
+        {
+            this.redactionRegion = regionManager;
+            this.eventAggregator = eventAggregator;
+
+            RedactionDocumentRegionName = Guid.NewGuid().ToString();
+            Unicode = App.mainWindowViewModel.SelectedItem.Unicode;
+            CloseEditToolCommand = new DelegateCommand(CloseEditTool);
+        }
+
+        public void CloseEditTool()
+        {
+            this.eventAggregator.GetEvent<CloseEditToolEvent>().Publish(new EnumCloseModeUnicode { Unicode = this.Unicode, Status = EnumCloseMode.StatusCancel });
+        }
+
+        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);
+            NavigationParameters param = new NavigationParameters();
+            param.Add(ParameterNames.PDFViewer, PDFViewer);
+            redactionRegion.RequestNavigate(RedactionDocumentRegionName, RedactionDocumentName, param);
+        }
+    }
+}

+ 90 - 0
PDF Office/ViewModels/EditTools/Redaction/RedactionDocumentContentViewModel.cs

@@ -0,0 +1,90 @@
+using ComPDFKit.PDFDocument;
+using ComPDFKitViewer;
+using ComPDFKitViewer.PdfViewer;
+using PDF_Office.Helper;
+using PDF_Office.Model;
+using PDF_Office.Model.EditTools.Background;
+using Prism.Mvvm;
+using Prism.Regions;
+using System;
+using System.Collections.Generic;
+using System.Drawing.Printing;
+using System.Linq;
+using System.Text;
+using System.Threading.Tasks;
+using System.Windows.Media.Imaging;
+
+namespace PDF_Office.ViewModels.EditTools.Redaction
+{
+    public class RedactionDocumentContentViewModel : BindableBase, INavigationAware
+    {
+        private CPDFViewer pdfViewer;
+        public IRegionManager regionManager;
+        public CPDFViewer PDFViewer;
+        public CPDFDocument Document;
+
+        public string ViewerRegionName { get; set; }
+
+        private int _currentPageIndex;
+        public int CurrentPageIndex
+        {
+            get { return _currentPageIndex; }
+            set
+            {
+                SetProperty(ref _currentPageIndex, PDFViewer.CurrentIndex);
+            }
+        }
+
+        private int _pageSize;
+        public int PageRangeNumber
+        {
+            get { return _pageSize; }
+            set { SetProperty(ref _pageSize, value); }
+        }
+
+        public RedactionDocumentContentViewModel(IRegionManager regionManager)
+        {
+            this.regionManager = regionManager;
+            PageRangeNumber = PDFViewer.Document.PageCount;
+            ViewerRegionName = RegionNames.BackgroundViewerRegionName;
+        }
+
+        private void CurrentViewer_CustomDrawHandler(object sender, CustomDrawData e)
+        {
+        }
+
+        private void UndoManager_PropertyChanged(object sender, System.ComponentModel.PropertyChangedEventArgs e)
+        {
+        }
+
+        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);
+            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.SingleContinuous);
+                    PDFViewer.SetMouseMode(MouseModes.AnnotCreate);
+                }
+            }
+        }
+    }
+}

+ 230 - 4
PDF Office/ViewModels/EditTools/Watermark/WatermarkContentViewModel.cs

@@ -1,28 +1,254 @@
-using PDF_Office.EventAggregators;
+using ComPDFKitViewer.PdfViewer;
+using PDF_Office.CustomControl;
+using PDF_Office.EventAggregators;
+using PDF_Office.Model;
+using PDF_Office.Model.EditTools.Background;
+using PDF_Office.Model.EditTools.Watermark;
+using PDF_Office.ViewModels.Tools;
+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 static System.Windows.Forms.VisualStyles.VisualStyleElement;
 
 namespace PDF_Office.ViewModels.EditTools.Watermark
 {
-    public class WatermarkContentViewModel : BindableBase
+    public class WatermarkContentViewModel : BindableBase, INavigationAware
     {
         public IEventAggregator eventAggregator;
+        public IRegionManager watermarkRegion;
 
+        private CPDFViewer PDFViewer;
+
+        private CPDFViewer CurrentPDFViewer;
+
+        private ViewContentViewModel viewContentViewModel;
+
+        public string TemplateListName = "WatermarkTemplateListBaseContent";
+        public string CreateBaseName = "WatermarkCreateBaseContent";
+        public string CreateModTextName = "WatermarkCreateTextContent";
+        public string CreateModFileName = "WatermarkCreateFileContent";
+
+        public string TemplateListModTextName = "WatermarkTemplateListTextContent";
+        public string TemplateListModFileName = "WatermarkTemplateListFileContent";
+
+        public string WatermarkDocumentName = "WatermarkDocumentContent";
+
+        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 string _watermarkDocumentRegionName;
+        /// <summary>
+        /// 持有Document的Region,负责渲染和保存
+        /// </summary>
+        public string WatermarkDocumentRegionName
+        {
+            get { return _watermarkDocumentRegionName; }
+            set { _watermarkDocumentRegionName = value; }
+        }
+
+        private Visibility _watermarkDocumentVisible = Visibility.Visible;
+        /// <summary>
+        /// 持有Document的Region可见
+        /// </summary>
+        public Visibility WatermarkDocumentVisible
+        {
+            get { return _watermarkDocumentVisible; }
+            set { _watermarkDocumentVisible = 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 DelegateCommand CloseEditToolCommand { get; set; }
-        public WatermarkContentViewModel(IEventAggregator eventAggregator)
+
+        public DelegateCommand DeleteWatermarkCommand { get; set; }
+
+        public DelegateCommand ConfirmEditToolCommand { get; set; }
+
+        public DelegateCommand<string> EnterSelectedContentCommand { get; set; }
+
+        public string Unicode = null;
+
+        public WatermarkContentViewModel(IRegionManager regionManager, IEventAggregator eventAggregator)
         {
             this.eventAggregator = eventAggregator;
+            this.watermarkRegion = regionManager;
+            Unicode = App.mainWindowViewModel.SelectedItem.Unicode;
+            WatermarkSettingsVisible = Visibility.Visible;
+            WatermarkSettingsRegionName = Guid.NewGuid().ToString();
+            WatermarkDocumentRegionName = Guid.NewGuid().ToString();
             CloseEditToolCommand = new DelegateCommand(CloseEditTool);
+            ConfirmEditToolCommand = new DelegateCommand(ConfirmEditTool);
+            EnterSelectedContentCommand = new DelegateCommand<string>(EnterSelectedContent);
+            DeleteWatermarkCommand = new DelegateCommand(DeleteWatermark);
+
+            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);
+
+        }
+        public void CurrentWatermarkPDFViewer(CPDFViewerUnicode cPDFViewerunicod)
+        {
+            CurrentPDFViewer = cPDFViewerunicod.Status;
+
         }
         public void CloseEditTool()
         {
-            this.eventAggregator.GetEvent<CloseEditToolEvent>().Publish();
+            this.eventAggregator.GetEvent<CloseEditToolEvent>().Publish(new EnumCloseModeUnicode { Unicode = Unicode, Status = EnumCloseMode.StatusCancel });
 
         }
+
+        public void ConfirmEditTool()
+        {
+            this.eventAggregator.GetEvent<ConfirmEditToolsWatermarkEvent>().Publish();
+            this.eventAggregator.GetEvent<CloseEditToolEvent>().Publish(new EnumCloseModeUnicode { Unicode = Unicode, Status = EnumCloseMode.StatusConfirm });
+        }
+
+        public void EnterTemplateListOrCreate(EnumTemplateListOrCreateUnicode enumTemplateListOrCreateunicode)
+        {
+            EnumTemplateListOrCreate enumTemplateListOrCreate = enumTemplateListOrCreateunicode.Status;
+            if (enumTemplateListOrCreate == EnumTemplateListOrCreate.StatusTemplate)
+            {
+                EnterSelectedContent(TemplateListName);
+            }
+            else
+            {
+                EnterSelectedContent(CreateBaseName);
+            }
+        }
+
+        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;
+        }
+
+        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 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 EnterDocumentContent()
+        {
+            NavigationParameters param = new NavigationParameters();
+            param.Add(ParameterNames.PDFViewer, PDFViewer);
+            param.Add(ParameterNames.ViewContentViewModel, viewContentViewModel);
+            watermarkRegion.RequestNavigate(WatermarkDocumentRegionName, WatermarkDocumentName, param);
+            WatermarkDocumentVisible = Visibility.Visible;
+        }
+
+        private void DeleteWatermark() {
+            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.StatusDeleteAll});
+                }
+                else
+                {
+                    this.eventAggregator.GetEvent<DeleteWatermarkEvent>().Publish(new EnumDeleteUnicode {
+                            Unicode = Unicode, Status = EnumDelete.StatusCreate});
+                }
+            }
+            else {
+
+                alertsMessage.ShowDialog("无法在本文件中找到可删除的水印。如果您看到水印,其不是使用PDF Office添加的,因此无法被检测到。", "", "取消", "确定");
+            }
+            
+            
+        }
+
+        public void OnNavigatedTo(NavigationContext navigationContext)
+        {
+            navigationContext.Parameters.TryGetValue<ViewContentViewModel>(ParameterNames.ViewContentViewModel, out viewContentViewModel);
+            navigationContext.Parameters.TryGetValue<CPDFViewer>(ParameterNames.PDFViewer, out PDFViewer);
+            EnterSelectedContent(TemplateListName);
+            EnterDocumentContent();
+
+        }
+
+        public bool IsNavigationTarget(NavigationContext navigationContext)
+        {
+            return true;
+        }
+
+        public void OnNavigatedFrom(NavigationContext navigationContext)
+        {
+        }
     }
 }

+ 235 - 3
PDF Office/ViewModels/EditTools/Watermark/WatermarkCreateBaseContentViewModel.cs

@@ -1,16 +1,248 @@
-using Prism.Commands;
+using ComPDFKitViewer.PdfViewer;
+using PDF_Office.EventAggregators;
+using PDF_Office.Model;
+using PDF_Office.Model.EditTools.Background;
+using PDF_Office.Model.EditTools.Watermark;
+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;
+using static PDF_Office.ViewModels.EditTools.Background.BackgroundCreateBaseContentViewModel;
 
 namespace PDF_Office.ViewModels.EditTools.Watermark
 {
-    public class WatermarkCreateBaseContentViewModel : BindableBase
+    public class WatermarkCreateBaseContentViewModel : BindableBase, INavigationAware
     {
-        public WatermarkCreateBaseContentViewModel()
+        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 WatermarkCreateBaseContentViewModel(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 == "WatermarkCreateTextContent")
+            {
+                this.eventAggregator.GetEvent<SaveWatermarkTemplateEvent>().Publish(new EnumTextOrFileUnicode
+                {
+                    Unicode = Unicode,
+                    Status = EnumTextOrFile.StatusText
+                });
+            }
+            if (CurrentCreateModName == "WatermarkCreateFileContent")
+            {
+                this.eventAggregator.GetEvent<SaveWatermarkTemplateEvent>().Publish(new EnumTextOrFileUnicode
+                {
+                    Unicode = Unicode,
+                    Status = EnumTextOrFile.StatusFile
+                });
+            }
+        }
+
+        public void SaveToCurrentTemplateList()
+        {
+            if (CurrentCreateModName == "WatermarkCreateTextContent")
+            {
+                eventAggregator.GetEvent<ConfirmEditWatermarkTemplateItemEvent>().Publish(new EnumTextOrFileUnicode
+                {
+                    Unicode = Unicode,
+                    Status = EnumTextOrFile.StatusText
+                });
+            }
+            if (CurrentCreateModName == "WatermarkCreateFileContent")
+            {
+                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 = "WatermarkCreateTextContent";
+            }
+            else
+            {
+                CurrentCreateModName = "WatermarkCreateFileContent";
+            }
+            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
+            });
         }
     }
 }

+ 742 - 3
PDF Office/ViewModels/EditTools/Watermark/WatermarkCreateFileContentViewModel.cs

@@ -1,16 +1,755 @@
-using Prism.Commands;
+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;
+using PDF_Office.Model.EditTools.Background;
+using PDF_Office.Model.EditTools.Watermark;
+using PDF_Office.Model.PageEdit;
+using PDF_Office.Properties;
+using PDF_Office.ViewModels.Tools;
+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.Drawing.Imaging;
+using System.IO;
 using System.Linq;
+using System.Threading.Tasks;
+using System.Windows;
 
 namespace PDF_Office.ViewModels.EditTools.Watermark
 {
-    public class WatermarkCreateFileContentViewModel : BindableBase
+    public class WatermarkCreateFileContentViewModel : BindableBase, INavigationAware
     {
-        public WatermarkCreateFileContentViewModel()
+        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 = ((float)RotationValue / 180) * 3.1415926f;
+                eventAggregator.GetEvent<SetWatermarkEvent>().Publish(new WatermarkInfoUnicode
+                {
+                    Unicode = Unicode,
+                    Status = WatermarkInfo
+                });
+            }
+        }
+
+        private int _opacityValue = 100;
+        public int OpacityValue
+        {
+            get { return _opacityValue; }
+            set
+            {
+                SetProperty(ref _opacityValue, value);
+                WatermarkInfo.Opacity = (byte)(((float)OpacityValue / 100) * 225);
+                eventAggregator.GetEvent<SetWatermarkEvent>().Publish(new WatermarkInfoUnicode
+                {
+                    Unicode = Unicode,
+                    Status = WatermarkInfo
+                });
+            }
+        }
+
+
+        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);
+            }
+        }
+
+        private string _vertOffsetValue = "0";
+        public string VertOffsetValue
+        {
+            get { return _vertOffsetValue; }
+            set
+            {
+                SetProperty(ref _vertOffsetValue, value);
+                WatermarkInfo.VertOffset = float.Parse(VertOffsetValue);
+                eventAggregator.GetEvent<SetWatermarkEvent>().Publish(new WatermarkInfoUnicode
+                {
+                    Unicode = Unicode,
+                    Status = WatermarkInfo
+                });
+            }
+        }
+
+        private string _horizOffsetValue = "0";
+        public string HorizOffsetValue
+        {
+            get { return _horizOffsetValue; }
+            set
+            {
+                SetProperty(ref _horizOffsetValue, value);
+                WatermarkInfo.HorizOffset = float.Parse(HorizOffsetValue);
+                eventAggregator.GetEvent<SetWatermarkEvent>().Publish(new WatermarkInfoUnicode
+                {
+                    Unicode = Unicode,
+                    Status = WatermarkInfo
+                });
+            }
+        }
+
+        private string _verticalSpacingValue = "6";
+        public string VerticalSpacingValue
+        {
+            get { return _verticalSpacingValue; }
+            set
+            {
+                SetProperty(ref _verticalSpacingValue, value);
+                WatermarkInfo.VerticalSpacing = float.Parse(VerticalSpacingValue);
+                eventAggregator.GetEvent<SetWatermarkEvent>().Publish(new WatermarkInfoUnicode
+                {
+                    Unicode = Unicode,
+                    Status = WatermarkInfo
+                });
+            }
+        }
+
+        private string _horizontalSpacingValue = "6";
+        public string HorizontalSpacingValue
+        {
+            get { return _horizontalSpacingValue; }
+            set
+            {
+                SetProperty(ref _horizontalSpacingValue, value);
+                WatermarkInfo.HorizontalSpacing = float.Parse(HorizontalSpacingValue);
+                eventAggregator.GetEvent<SetWatermarkEvent>().Publish(new WatermarkInfoUnicode
+                {
+                    Unicode = Unicode,
+                    Status = WatermarkInfo
+                });
+            }
+        }
+
+        public string _pageRangeText = "0";
+        public string PageRangeText
+        {
+            get { return _pageRangeText; }
+            set
+            {
+                _pageRangeText = value;
+                EditToolsHelper.GetPageRange(PageRangeSelectIndex, PDFViewer.Document, ref WatermarkInfo.PageRange, PageRangeText);
+                eventAggregator.GetEvent<SetWatermarkEvent>().Publish(new WatermarkInfoUnicode
+                {
+                    Unicode = Unicode,
+                    Status = WatermarkInfo
+                });
+            }
+        }
+
+        private bool _isFullValue = false;
+        public bool IsFullValue
+        {
+            get { return _isFullValue; }
+            set
+            {
+                SetProperty(ref _isFullValue, value);
+                WatermarkInfo.Isfull = IsFullValue;
+                eventAggregator.GetEvent<SetWatermarkEvent>().Publish(new WatermarkInfoUnicode
+                {
+                    Unicode = Unicode,
+                    Status = WatermarkInfo
+                });
+            }
+        }
+
+        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);
+                eventAggregator.GetEvent<SetWatermarkEvent>().Publish(new WatermarkInfoUnicode
+                {
+                    Unicode = Unicode,
+                    Status = WatermarkInfo
+                });
+
+            }
+        }
+
+        private int _isFrontSelectedIndex = 0;
+        public int IsFrontSelectedIndex
+        {
+            get { return _isFrontSelectedIndex; }
+            set
+            {
+                SetProperty(ref _isFrontSelectedIndex, value);
+                SetIsFront(IsFrontSelectedIndex);
+                eventAggregator.GetEvent<SetWatermarkEvent>().Publish(new WatermarkInfoUnicode
+                {
+                    Unicode = Unicode,
+                    Status = WatermarkInfo
+                });
+            }
+        }
+
+        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 WatermarkCreateFileContentViewModel(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.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.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 = ((float)RotationValue / 180) * 3.1415926f;
+            WatermarkInfo.Opacity = (byte)(((float)OpacityValue / 100) * 225);
+            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.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);
+                eventAggregator.GetEvent<SetWatermarkEvent>().Publish(new WatermarkInfoUnicode
+                {
+                    Unicode = Unicode,
+                    Status = WatermarkInfo
+                });
+                InitLocationButtonMatrix();
+            }
+        }
+
+        public void ConfirmEditToolsWatermark()
+        {
+
+            eventAggregator.GetEvent<SetWatermarkEvent>().Publish(new WatermarkInfoUnicode
+            {
+                Unicode = Unicode,
+                Status = WatermarkInfo
+            });
+
+        }
+
+        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(0.1f);
+                }
+                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());
+            }
+        }
+
+        public void ConfirmEditWatermarkTemplateItem(EnumTextOrFileUnicode enumTextOrFileunicode)
+        {
+            EnumTextOrFile enumTextOrFile = enumTextOrFileunicode.Status;
+            if (enumTextOrFile == EnumTextOrFile.StatusFile)
+            {
+                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 = ((int)((WatermarkInfo.Rotation / Math.PI) * 180)).ToString();
+            OpacityText = ((((float)WatermarkInfo.Opacity) / 225) * 100).ToString() + " %";
+            RelativeScaleText = WatermarkInfo.TextSize.ToString() + " %";
+            InitLocationButtonMatrix();
+            CreateFileVisible=Visibility.Visible;
+
+        }
+
+        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;
+                eventAggregator.GetEvent<SetWatermarkEvent>().Publish(new WatermarkInfoUnicode
+                {
+                    Unicode = Unicode,
+                    Status = WatermarkInfo
+                });
+            }
+        }
+
+        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();
+            }
         }
     }
 }

+ 843 - 4
PDF Office/ViewModels/EditTools/Watermark/WatermarkCreateTextContentViewModel.cs

@@ -1,16 +1,855 @@
-using Prism.Commands;
+using ComPDFKit.PDFDocument;
+using ComPDFKit.PDFWatermark;
+using ComPDFKitViewer.AnnotEvent;
+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.Watermark;
+using PDF_Office.Properties;
+using PDF_Office.ViewModels.Tools;
+using PDFSettings;
+using Prism.Commands;
+using Prism.Common;
+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.Forms;
+using System.Windows.Media;
 
 namespace PDF_Office.ViewModels.EditTools.Watermark
 {
-    public class WatermarkCreateTextContentViewModel : BindableBase
+    public class WatermarkCreateTextContentViewModel : BindableBase, INavigationAware
     {
-        public WatermarkCreateTextContentViewModel()
+        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 = ((float)RotationValue / 180) * 3.1415926f;
+                eventAggregator.GetEvent<SetWatermarkEvent>().Publish(new WatermarkInfoUnicode
+                {
+                    Unicode = Unicode,
+                    Status = WatermarkInfo
+                });
+            }
+        }
+
+        private int _opacityValue = 100;
+        public int OpacityValue
+        {
+            get { return _opacityValue; }
+            set
+            {
+                SetProperty(ref _opacityValue, value);
+                WatermarkInfo.Opacity = (byte)(((float)OpacityValue / 100) * 225);
+                eventAggregator.GetEvent<SetWatermarkEvent>().Publish(new WatermarkInfoUnicode
+                {
+                    Unicode = Unicode,
+                    Status = WatermarkInfo
+                });
+            }
+        }
+
+        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);
+                eventAggregator.GetEvent<SetWatermarkEvent>().Publish(new WatermarkInfoUnicode
+                {
+                    Unicode = Unicode,
+                    Status = WatermarkInfo
+                });
+            }
+        }
+
+        private string _horizOffsetValue = "0";
+        public string HorizOffsetValue
+        {
+            get { return _horizOffsetValue; }
+            set
+            {
+                SetProperty(ref _horizOffsetValue, value);
+                WatermarkInfo.HorizOffset = float.Parse(HorizOffsetValue);
+                eventAggregator.GetEvent<SetWatermarkEvent>().Publish(new WatermarkInfoUnicode
+                {
+                    Unicode = Unicode,
+                    Status = WatermarkInfo
+                });
+            }
+        }
+
+        private string _verticalSpacingValue = "6";
+        public string VerticalSpacingValue
+        {
+            get { return _verticalSpacingValue; }
+            set
+            {
+                SetProperty(ref _verticalSpacingValue, value);
+                WatermarkInfo.VerticalSpacing = float.Parse(VerticalSpacingValue);
+                eventAggregator.GetEvent<SetWatermarkEvent>().Publish(new WatermarkInfoUnicode
+                {
+                    Unicode = Unicode,
+                    Status = WatermarkInfo
+                });
+            }
+        }
+
+        private string _horizontalSpacingValue = "6";
+        public string HorizontalSpacingValue
+        {
+            get { return _horizontalSpacingValue; }
+            set
+            {
+                SetProperty(ref _horizontalSpacingValue, value);
+                WatermarkInfo.HorizontalSpacing = float.Parse(HorizontalSpacingValue);
+                eventAggregator.GetEvent<SetWatermarkEvent>().Publish(new WatermarkInfoUnicode
+                {
+                    Unicode = Unicode,
+                    Status = WatermarkInfo
+                });
+            }
+        }
+
+        private int _fontSizeSelectedIndex = 0;
+        public int FontSizeSelectedIndex
+        {
+            get { return _fontSizeSelectedIndex; }
+            set
+            {
+                SetProperty(ref _fontSizeSelectedIndex, value);
+                SetFontSize(FontSizeSelectedIndex);
+                eventAggregator.GetEvent<SetWatermarkEvent>().Publish(new WatermarkInfoUnicode
+                {
+                    Unicode = Unicode,
+                    Status = WatermarkInfo
+                });
+            }
+        }
+
+        private int _fontNameSelectedIndex = 0;
+        public int FontNameSelectedIndex
+        {
+            get { return _fontNameSelectedIndex; }
+            set
+            {
+                SetProperty(ref _fontNameSelectedIndex, value);
+                SetFontName(FontNameSelectedIndex);
+                eventAggregator.GetEvent<SetWatermarkEvent>().Publish(new WatermarkInfoUnicode
+                {
+                    Unicode = Unicode,
+                    Status = WatermarkInfo
+                });
+            }
+        }
+
+        private int _isFrontSelectedIndex = 0;
+        public int IsFrontSelectedIndex
+        {
+            get { return _isFrontSelectedIndex; }
+            set
+            {
+                SetProperty(ref _isFrontSelectedIndex, value);
+                SetIsFront(IsFrontSelectedIndex);
+                eventAggregator.GetEvent<SetWatermarkEvent>().Publish(new WatermarkInfoUnicode
+                {
+                    Unicode = Unicode,
+                    Status = WatermarkInfo
+                });
+            }
+        }
+
+        private bool _isFullValue = false;
+        public bool IsFullValue
+        {
+            get { return _isFullValue; }
+            set
+            {
+                SetProperty(ref _isFullValue, value);
+                WatermarkInfo.Isfull = IsFullValue;
+                eventAggregator.GetEvent<SetWatermarkEvent>().Publish(new WatermarkInfoUnicode
+                {
+                    Unicode = Unicode,
+                    Status = WatermarkInfo
+                });
+            }
+        }
+        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);
+                eventAggregator.GetEvent<SetWatermarkEvent>().Publish(new WatermarkInfoUnicode
+                {
+                    Unicode = Unicode,
+                    Status = WatermarkInfo
+                });
+            }
+        }
+        public string _pageRangeText = "0";
+        public string PageRangeText
+        {
+            get { return _pageRangeText; }
+            set
+            {
+                _pageRangeText = value;
+                EditToolsHelper.GetPageRange(PageRangeSelectIndex, PDFViewer.Document, ref WatermarkInfo.PageRange, PageRangeText);
+                eventAggregator.GetEvent<SetWatermarkEvent>().Publish(new WatermarkInfoUnicode
+                {
+                    Unicode = Unicode,
+                    Status = WatermarkInfo
+                });
+            }
+        }
+
+        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);
+                eventAggregator.GetEvent<SetWatermarkEvent>().Publish(new WatermarkInfoUnicode
+                {
+                    Unicode = Unicode,
+                    Status = WatermarkInfo
+                });
+            }
+        }
+
+        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 WatermarkCreateTextContentViewModel(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.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.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);
+                eventAggregator.GetEvent<SetWatermarkEvent>().Publish(new WatermarkInfoUnicode
+                {
+                    Unicode = Unicode,
+                    Status = WatermarkInfo
+                });
+                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;
+                    eventAggregator.GetEvent<SetWatermarkEvent>().Publish(new WatermarkInfoUnicode
+                    {
+                        Unicode = Unicode,
+                        Status = WatermarkInfo
+                    });
+                }
+            }
+
+        }
+
+        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()
+        {
+            eventAggregator.GetEvent<SetWatermarkEvent>().Publish(new WatermarkInfoUnicode
+            {
+                Unicode = Unicode,
+                Status = WatermarkInfo
+            });
+        }
+
+        private void InitList()
+        {
+            InitOpacityList();
+            InitFontNameList();
+            InitFontSizeList();
+            InitIsFrontList();
+            InitRotationList();
+            InitScaleList();
+        }
+
+        private void InitWatermarkInfo()
+        {
+
+            WatermarkInfo.Text = TextValue;
+            WatermarkInfo.Rotation = (float)(((float)RotationValue / 180) * Math.PI);
+            WatermarkInfo.Opacity = (byte)(((float)OpacityValue / 100) * 225);
+            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.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;
+            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 = ((int)((WatermarkInfo.Rotation/ Math.PI) *180)).ToString();
+            OpacityText = ((((float)WatermarkInfo.Opacity)/225)*100).ToString() + " %";
+            RelativeScaleText = WatermarkInfo.TextSize.ToString() + " %";
+            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(0.1f);
+                    }
+                    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());
+                }
+            }
+
+            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();
+                }
 
+            }
         }
     }
-}

+ 247 - 0
PDF Office/ViewModels/EditTools/Watermark/WatermarkDocumentContentViewModel.cs

@@ -0,0 +1,247 @@
+using ComPDFKitViewer.PdfViewer;
+using PDF_Office.EventAggregators;
+using PDF_Office.Model.EditTools.Background;
+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 PDF_Office.Model.EditTools.Watermark;
+using ComPDFKit.PDFDocument;
+using ComPDFKit.PDFPage;
+using System.Windows.Media.Imaging;
+using System.Windows.Media;
+using System.Threading.Tasks;
+using ComPDFKit.PDFWatermark;
+using PDF_Office.Helper;
+using PDF_Office.Model.Dialog.HomePageToolsDialogs.HomePagePrinter;
+using System.Drawing;
+using System.Windows;
+using ComPDFKitViewer;
+using Size = System.Windows.Size;
+using System.Diagnostics;
+using System.Windows.Controls;
+using ComPDFKit.Import;
+using PDF_Office.ViewModels.Tools;
+using static System.Windows.Forms.VisualStyles.VisualStyleElement;
+
+namespace PDF_Office.ViewModels.EditTools.Watermark
+{
+    public class WatermarkDocumentContentViewModel : BindableBase, INavigationAware
+    {
+
+        public IEventAggregator eventAggregator;
+        public IRegionManager regionManager;
+        public CPDFViewer PDFViewer;
+        public CPDFDocument Document;
+        private CPDFWatermark watermark;
+        private ViewContentViewModel viewContentViewModel;
+        private CPDFViewer pdfViewer;
+        private WatermarkInfo watermarkInfo;
+
+        public EnumDelete EnumDelete = EnumDelete.StatusCreate;
+
+        public bool firstin = true;
+
+        public string ViewerRegionName { get; set; }
+
+        public string Unicode = null;
+
+        public WatermarkDocumentContentViewModel(IEventAggregator eventAggregator, IRegionManager regionManager)
+        {
+            this.regionManager = regionManager;
+            this.eventAggregator = eventAggregator;
+            Unicode = App.mainWindowViewModel.SelectedItem.Unicode;
+            eventAggregator.GetEvent<SetWatermarkEvent>().Subscribe(SetWatermark, e => e.Unicode == Unicode);
+            ViewerRegionName = RegionNames.WatermarkViwerRegionName;
+            eventAggregator.GetEvent<ConfirmEditToolsWatermarkEvent>().Subscribe(ConfirmEditToolsWatermark);
+            eventAggregator.GetEvent<DeleteWatermarkEvent>().Subscribe(DeleteWatermark, e => e.Unicode == Unicode);
+        }
+
+        public void ConfirmEditToolsWatermark()
+        {
+            if (EnumDelete == EnumDelete.StatusDeleteAll)
+            {
+                viewContentViewModel.PDFViewer.Document.DeleteWatermarks();
+            }
+
+            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();
+        }
+
+        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");
+            PDFViewer.InvalidChildVisual(false);
+
+        }
+
+        public void CreateWatermark(CPDFDocument document, bool IsNewDoc = false)
+        {
+            if (watermarkInfo != null)
+            {
+                if (IsNewDoc) { document.DeleteWatermarks(); }
+
+                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(0.1f);
+                }
+                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);
+                if (IsNewDoc) { watermark.SetPages("0"); }
+                else { watermark.SetPages(watermarkInfo.PageRange); }
+                Trace.WriteLine("IsCreateWatermark: " + watermark.CreateWatermark());
+                Trace.WriteLine("IsUpdateWatermark: " + watermark.UpdateWatermark());
+            }
+        }
+
+
+        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 (watermarkInfo != null)
+                    {
+                        char[] enumerationSeparator = new char[] { ',' };
+                        char[] rangeSeparator = new char[] { '-' };
+                        if (CommonHelper.GetPagesInRange(ref PageIndexLists, watermarkInfo.PageRange, Document.PageCount, enumerationSeparator, rangeSeparator, true))
+                        { //TODO
+                            Trace.WriteLine(CommonHelper.GetPagesInRange(ref PageIndexLists, watermarkInfo.PageRange, Document.PageCount, enumerationSeparator, rangeSeparator, true));
+                            Trace.WriteLine(drawPageData.PageIndex);
+                            foreach (var abbb in PageIndexLists)
+                            {
+
+                                Trace.WriteLine("smgui _______" + abbb);
+                            }
+                            if (PageIndexLists.Contains(drawPageData.PageIndex - 1))
+                            {
+                                if (watermarkInfo.WatermarkType == C_Watermark_Type.WATERMARK_TYPE_TEXT && watermarkInfo.Text != "")
+                                {
+                                    WriteableBitmap waterMarkBitmap = GetWatermark(PDFViewer.Document, e.Zoom, drawPageData.PageIndex);
+                                    e.DrawContext.DrawImage(waterMarkBitmap, drawPageData.PageBound);
+                                }
+                                if (watermarkInfo.WatermarkType == C_Watermark_Type.WATERMARK_TYPE_IMG)
+                                {
+                                    WriteableBitmap waterMarkBitmap = GetWatermark(PDFViewer.Document, e.Zoom, drawPageData.PageIndex);
+                                    e.DrawContext.DrawImage(waterMarkBitmap, drawPageData.PageBound);
+                                }
+                            }
+                        }
+                    }
+                }
+            }
+        }
+        private WriteableBitmap GetWatermark(CPDFDocument oldDoc, double zoom, int pageIndex)
+        {
+            Size pageSize = oldDoc.GetPageSize(pageIndex);
+
+            CPDFDocument newDoc = CPDFDocument.CreateDocument();
+            newDoc.InsertPage(0, pageSize.Width, pageSize.Height, null);
+            CreateWatermark(newDoc, true);
+            CPDFPage newPage = newDoc.PageAtIndex(0);
+            double scale = 96.0 / 72.0;
+            zoom = zoom * scale;
+            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);
+            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;
+        }
+
+        public void OnNavigatedFrom(NavigationContext navigationContext)
+        {
+
+        }
+
+        public void OnNavigatedTo(NavigationContext navigationContext)
+        {
+
+            navigationContext.Parameters.TryGetValue<CPDFViewer>(ParameterNames.PDFViewer, out pdfViewer);
+            navigationContext.Parameters.TryGetValue<ViewContentViewModel>(ParameterNames.ViewContentViewModel, out viewContentViewModel);
+            if (pdfViewer != null && viewContentViewModel != null)
+            {
+                if (!regionManager.Regions[ViewerRegionName].Views.Contains(PDFViewer))
+                {
+                    PDFViewer = new CPDFViewer();
+                    PDFViewer.InitDocument(pdfViewer.Document.FilePath);
+                    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);
+                    eventAggregator.GetEvent<CurrentWatermarkPDFViewerEvent>().Publish(new CPDFViewerUnicode
+                    {
+                        Unicode = Unicode,
+                        Status = PDFViewer
+                    });
+                }
+            }
+        }
+    }
+}

+ 162 - 3
PDF Office/ViewModels/EditTools/Watermark/WatermarkTemplateListBaseContentViewModel.cs

@@ -1,16 +1,175 @@
-using Prism.Commands;
+using ComPDFKitViewer.PdfViewer;
+using PDF_Office.CustomControl;
+using PDF_Office.EventAggregators;
+using PDF_Office.Model;
+using PDF_Office.ViewModels.Tools;
+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;
+using static System.Windows.Forms.VisualStyles.VisualStyleElement;
+using Button = System.Windows.Controls.Button;
 
 namespace PDF_Office.ViewModels.EditTools.Watermark
 {
-    public class WatermarkTemplateListBaseContentViewModel : BindableBase
+    public class WatermarkTemplateListBaseContentViewModel : BindableBase, INavigationAware
     {
-        public WatermarkTemplateListBaseContentViewModel()
+        public IRegionManager watermarkTemplateListRegion;
+        private readonly IEventAggregator eventAggregator;
+
+        private CPDFViewer CurrentPDFViewer;
+
+        private string WatermarkTemplateListTextContentName = "WatermarkTemplateListTextContent";
+        private string WatermarkTemplateListFileContentName = "WatermarkTemplateListFileContent";
+
+        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 WatermarkTemplateListBaseContentViewModel(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("WatermarkTemplateListColorContent");
+            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
+                });
+
 
+            }
         }
     }
 }

+ 307 - 3
PDF Office/ViewModels/EditTools/Watermark/WatermarkTemplateListFileContentViewModel.cs

@@ -1,16 +1,320 @@
-using Prism.Commands;
+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;
+using PDF_Office.Model.EditTools.Background;
+using PDF_Office.Model.EditTools.Watermark;
+using PDF_Office.Properties;
+using PDF_Office.ViewModels.Tools;
+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.Diagnostics;
+using System.Drawing;
+using System.Drawing.Printing;
+using System.IO;
 using System.Linq;
+using System.Threading.Tasks;
+using System.Windows;
+using System.Windows.Controls;
+using System.Windows.Media;
+using System.Windows.Media.Imaging;
+using static System.Windows.Forms.VisualStyles.VisualStyleElement;
 
 namespace PDF_Office.ViewModels.EditTools.Watermark
 {
-    public class WatermarkTemplateListFileContentViewModel : BindableBase
+    public class WatermarkTemplateListFileContentViewModel : BindableBase, INavigationAware
     {
-        public WatermarkTemplateListFileContentViewModel()
+        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 WatermarkTemplateListFileContentViewModel(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.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);
+            eventAggregator.GetEvent<SetWatermarkEvent>().Publish(new WatermarkInfoUnicode
+            {
+                Unicode = Unicode,
+                Status = WatermarkInfo
+            });
+        }
+
+
+        public bool IsNavigationTarget(NavigationContext navigationContext)
+        {
+            return true;
+        }
+
+        public void OnNavigatedFrom(NavigationContext navigationContext)
+        {
+        }
+
+        public void OnNavigatedTo(NavigationContext navigationContext)
+        {
+            InitWatermarkTemplateList();
         }
     }
 }

+ 258 - 3
PDF Office/ViewModels/EditTools/Watermark/WatermarkTemplateListTextContentViewModel.cs

@@ -1,16 +1,271 @@
-using Prism.Commands;
+using PDFSettings;
+using Prism.Commands;
 using Prism.Mvvm;
+using Prism.Regions;
+using System.Windows;
 using System;
 using System.Collections.Generic;
+using System.Collections.ObjectModel;
 using System.Linq;
+using PDF_Office.Properties;
+using Prism.Events;
+using PDF_Office.EventAggregators;
+using PDF_Office.Model.EditTools.Watermark;
+using System.Windows.Controls;
+using ComPDFKitViewer.PdfViewer;
+using PDF_Office.CustomControl;
+using PDF_Office.Model;
+using PDF_Office.Helper;
+using PDF_Office.Model.EditTools.Background;
+using PDF_Office.ViewModels.Tools;
 
 namespace PDF_Office.ViewModels.EditTools.Watermark
 {
-    public class WatermarkTemplateListTextContentViewModel : BindableBase
+    public class WatermarkTemplateListTextContentViewModel : BindableBase, INavigationAware
     {
-        public WatermarkTemplateListTextContentViewModel()
+        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 WatermarkTemplateListTextContentViewModel(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.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);
+            eventAggregator.GetEvent<SetWatermarkEvent>().Publish(new WatermarkInfoUnicode
+            {
+                Unicode = Unicode,
+                Status = WatermarkInfo
+            });
+        }
+
+        public bool IsNavigationTarget(NavigationContext navigationContext)
+        {
+            return true;
+        }
+
+        public void OnNavigatedFrom(NavigationContext navigationContext)
+        {
+        }
+
+        public void OnNavigatedTo(NavigationContext navigationContext)
+        {
+            InitWatermarkTemplateList();
+        }
     }
 }

+ 1 - 35
PDF Office/ViewModels/PropertyPanel/AnnotPanel/FreetextAnnotPropertyViewModel.cs

@@ -135,41 +135,7 @@ namespace PDF_Office.ViewModels.PropertyPanel.AnnotPanel
 
         private void InitFontStyles()
         {
-            FontStyleItem custom = new FontStyleItem();
-            custom.mFontSize = 32;
-            custom.mFontStyleName = "自定义";
-
-            FontStyleItem h1 = new FontStyleItem();
-            h1.mFontSize = 24;
-            h1.mFontStyleName = "H1大标题";
-
-            FontStyleItem h2 = new FontStyleItem();
-            h2.mFontSize = 16;
-            h2.mFontStyleName = "h2(标准)";
-
-            FontStyleItem h3 = new FontStyleItem();
-            h3.mFontSize = 10;
-            h3.mFontStyleName = "H3小标题";
-
-            FontStyleItem b1 = new FontStyleItem();
-            b1.mFontSize = 8;
-            b1.mFontStyleName = "B1标题";
-
-            FontStyleItem b2 = new FontStyleItem();
-            b2.mFontSize = 6;
-            b2.mFontStyleName = "B2标题";
-
-            FontStyleItem b3 = new FontStyleItem();
-            b3.mFontSize = 4;
-            b3.mFontStyleName = "B3标题";
-
-            FontStyleList.Add(custom);
-            FontStyleList.Add(h1);
-            FontStyleList.Add(h2);
-            FontStyleList.Add(h3);
-            FontStyleList.Add(b1);
-            FontStyleList.Add(b2);
-            FontStyleList.Add(b3);
+            FontStyleList = LoadFontStyle.Load();
         }
         private void TextAlign_Checked(object obj)
         {

+ 648 - 1
PDF Office/ViewModels/PropertyPanel/TextEditPropertyViewModel.cs

@@ -1,19 +1,521 @@
-using Prism.Mvvm;
+using ComPDFKitViewer;
+using ComPDFKitViewer.PdfViewer;
+using Microsoft.Win32;
+using PDF_Office.Model;
+using PDF_Office.Model.PropertyPanel.AnnotPanel;
+using Prism.Commands;
+using Prism.Mvvm;
 using Prism.Regions;
 using System;
 using System.Collections.Generic;
 using System.Linq;
 using System.Text;
 using System.Threading.Tasks;
+using System.Windows;
+using System.Windows.Controls;
+using System.Windows.Input;
+using System.Windows.Media;
 
 namespace PDF_Office.ViewModels.PropertyPanel
 {
     public class TextEditPropertyViewModel : BindableBase, INavigationAware
     {
+        #region 属性
+
+        #region 编辑PDF全局
+
+        private bool _isTextEdit = true;
+        public bool IsTextEdit
+        {
+            get { return _isTextEdit; }
+            set
+            {
+                SetProperty(ref _isTextEdit, value);
+
+            }
+        }
+
+
+        #endregion
+
+
+
+        #region 文本属性
+
+        private double _angle;
+        public double Angle
+        {
+            get { return _angle; }
+            set
+            {
+                SetProperty(ref _angle, value);
+
+            }
+        }
+
+        private Brush selectColor = new SolidColorBrush(Colors.Black);
+        public Brush SelectColor
+        {
+            get { return selectColor; }
+            set
+            {
+                SetProperty(ref selectColor, value);
+
+                if (TextEditEvent != null)
+                {
+                    bool isok = TextEditEvent.FontColor.A != (SelectColor as SolidColorBrush).Color.A ||
+                         TextEditEvent.FontColor.B != (SelectColor as SolidColorBrush).Color.B ||
+                         TextEditEvent.FontColor.G != (SelectColor as SolidColorBrush).Color.G ||
+                         TextEditEvent.FontColor.R != (SelectColor as SolidColorBrush).Color.R;
+
+                    if (isok)
+                    {
+                        TextEditEvent.FontColor = (SelectColor as SolidColorBrush).Color;
+                        TextEditEvent.UpdatePDFEditByEventArgs();
+                    }
+
+                }
+
+
+            }
+        }
+
+        private FontFamily fontFamily = new FontFamily("Courier");
+        public FontFamily TextFontFamily
+        {
+            get { return fontFamily; }
+            set
+            {
+                SetProperty(ref fontFamily, value);
+                if (TextEditEvent != null)
+                {
+                    TextEditEvent.FontFamily = fontFamily;
+                    TextEditEvent.UpdatePDFEditByEventArgs();
+                }
+            }
+        }
+
+        private FontWeight fontWeights = FontWeights.Normal;
+        public FontWeight TextFontWeights
+        {
+            get { return fontWeights; }
+            set
+            {
+                SetProperty(ref fontWeights, value);
+                if (TextEditEvent != null)
+                {
+                    TextEditEvent.FontWeight = fontWeights;
+                    TextEditEvent.UpdatePDFEditByEventArgs();
+                }
+            }
+        }
+
+        private FontStyle fontStyle = FontStyles.Normal;
+        public FontStyle TextFontStyle
+        {
+            get { return fontStyle; }
+            set
+            {
+                SetProperty(ref fontStyle, value);
+                if (TextEditEvent != null)
+                {
+                    TextEditEvent.FontStyle = fontStyle;
+                    TextEditEvent.UpdatePDFEditByEventArgs();
+                }
+            }
+        }
+
+
+        private int fontSize = 24;
+        public int TextFontSize
+        {
+            get { return fontSize; }
+            set
+            {
+                SetProperty(ref fontSize, value);
+                if (TextEditEvent != null)
+                {
+                    TextEditEvent.FontSize = fontSize;
+                    TextEditEvent.UpdatePDFEditByEventArgs();
+                }
+            }
+        }
+
+        private List<FontStyleItem> fontStyleList = new List<FontStyleItem>();
+        public List<FontStyleItem> FontStyleList
+        {
+            get { return fontStyleList; }
+            set
+            {
+                SetProperty(ref fontStyleList, value);
+            }
+        }
+        #endregion
+
+        #region 图像属性
+
+        private bool _isCrop = false;
+        public bool IsCrop
+        {
+            get { return _isCrop; }
+            set
+            {
+                SetProperty(ref _isCrop, value);
+
+            }
+        }
+
+
+        private System.Windows.Media.Imaging.BitmapSource _currentImg;
+        public System.Windows.Media.Imaging.BitmapSource CurrentImg
+        {
+            get { return _currentImg; }
+            set
+            {
+                SetProperty(ref _currentImg, value);
+               
+            }
+        }
+
+        #endregion
+
+        #endregion
+
+
+        #region Command
+
+        #region 文本Command
+        public DelegateCommand AddTextCommand { get; set; }
+        public DelegateCommand AddImgCommand { get; set; }
+
+        public DelegateCommand<object> SelectedColorCommand { get; set; }
+        public DelegateCommand<object> SelectedFontStyleCommand { get; set; }
+        public DelegateCommand<object> FontFamilyChangedCommand { get; set; }
+        public DelegateCommand<object> FontStyleChangedCommand { get; set; }
+        public DelegateCommand<object> FontSizeChangedCommand { get; set; }
+
+        public DelegateCommand<object> TextAlignCheckedCommand { get; set; }
+
+        #endregion
+
+        #region 图像Command
+        public DelegateCommand ReplaceImgCommand { get; set; }
+        public DelegateCommand ExportImgCommand { get; set; }
+        public DelegateCommand CropImgCommand { get; set; }
+        public DelegateCommand ImgAlignCheckedCommand { get; set; }
+        
+
+        /// <summary>
+        /// 逆时针旋转
+        /// </summary>
+        public DelegateCommand AntiClockwiseCommand { get; set; }
+        /// <summary>
+        /// 顺时针旋转
+        /// </summary>
+        public DelegateCommand ClockwiseCommand { get; set; }
+        public DelegateCommand CropModeCommand { get; set; }
+        public DelegateCommand CancelCropCommand { get; set; }
+
+        #endregion
+
+        #endregion
+
+        private ComPDFKitViewer.PDFEditEvent TextEditEvent;
         public TextEditPropertyViewModel()
         {
+            InitVariable();
+            InitCommand();
+        }
+
+        private void InitVariable()
+        {
+            InitFontStyles();
+        }
 
+        private void InitFontStyles()
+        {
+            FontStyleList = LoadFontStyle.Load();
         }
+
+        private void InitCommand()
+        {
+            AddTextCommand = new DelegateCommand(AddText);
+            AddImgCommand = new DelegateCommand(AddImg);
+            ReplaceImgCommand = new DelegateCommand(ReplaceImg);
+            ExportImgCommand = new DelegateCommand(ExportImg);
+            CropImgCommand = new DelegateCommand(CropImg);
+            ImgAlignCheckedCommand = new DelegateCommand(ImgAlignChecked);
+
+            SelectedColorCommand = new DelegateCommand<object>(SelectedColor);
+            SelectedFontStyleCommand = new DelegateCommand<object>(SelectedFontStyle);
+            FontFamilyChangedCommand = new DelegateCommand<object>(FontFamilyChanged);
+            FontStyleChangedCommand = new DelegateCommand<object>(FontStyleChanged);
+            FontSizeChangedCommand = new DelegateCommand<object>(FontSizeChanged);
+            TextAlignCheckedCommand = new DelegateCommand<object>(TextAlignChecked);
+
+            AntiClockwiseCommand = new DelegateCommand(AntiClockwise);
+            ClockwiseCommand = new DelegateCommand(Clockwise);
+            CropModeCommand = new DelegateCommand(CropMode);
+            CancelCropCommand = new DelegateCommand(CancelCropImg);
+        }
+
+        private void ImgAlignChecked()
+        {
+           
+        }
+
+        private void CancelCropImg()
+        {
+            if (TextEditEvent != null)
+            {
+                TextEditEvent.ClipImage = false;
+                TextEditEvent.CancelClip();
+                
+                TextEditEvent.UpdatePDFEditByEventArgs();
+                IsCrop = false;
+            }
+        }
+
+        private void CropImg()
+        {
+           if(TextEditEvent != null)
+            {
+                TextEditEvent.SaveClip();
+                TextEditEvent.ClipImage = false;
+                TextEditEvent.UpdatePDFEditByEventArgs();
+                IsCrop = false;
+            }
+        }
+
+        private void ExportImg()
+        {
+            if (PDFViewer == null || TextEditEvent == null || TextEditEvent.EditType != ComPDFKit.PDFPage.CPDFEditType.EditImage) return;
+
+            //SaveFileDialog saveFileDialog = new SaveFileDialog();
+            //saveFileDialog.Filter = "png|*.png;|Image|*.gif;*.jpg;*.jpeg;*.bmp;*.jfif;*.png;";
+            //saveFileDialog.FileName = "编辑PDF导出图片";
+
+            System.Windows.Forms.FolderBrowserDialog folder = new System.Windows.Forms.FolderBrowserDialog();
+            folder.SelectedPath = Environment.GetFolderPath(Environment.SpecialFolder.UserProfile);
+
+            if (folder.ShowDialog() == System.Windows.Forms.DialogResult.OK)
+            {
+                if (string.IsNullOrEmpty(folder.SelectedPath))
+                    return;
+
+                var keyValueList = PDFViewer.GetSelectedImages();
+                int i = 0;
+                foreach (var bitmap in keyValueList)
+                {
+                   foreach(var bitmapItem in bitmap.Value)
+                    {
+                        bitmapItem.Save(folder.SelectedPath + "\\" + i + ".png", System.Drawing.Imaging.ImageFormat.Png);
+                        i++;
+                    }
+                }
+
+
+                
+            }
+        }
+
+        private void AddImg()
+        {
+            OpenFileDialog openFileDialog = new OpenFileDialog();
+            openFileDialog.Filter = "png|*.png;|Image|*.gif;*.jpg;*.jpeg;*.bmp;*.jfif;*.png;";
+            openFileDialog.Multiselect = true;
+            if ((bool)openFileDialog.ShowDialog())
+            {
+                if (string.IsNullOrEmpty(openFileDialog.FileName) == false)
+                {
+                    PDFViewer.SetPDFEditCreateType(ComPDFKit.PDFPage.CPDFEditType.EditImage);
+                    PDFViewer.AddPDFEditImage(openFileDialog.FileName);
+                }
+            }
+        }
+
+        private void ReplaceImg()
+        {
+            OpenFileDialog openFileDialog = new OpenFileDialog();
+            openFileDialog.Filter = "png|*.png;|Image|*.gif;*.jpg;*.jpeg;*.bmp;*.jfif;*.png;";
+            openFileDialog.Multiselect = true;
+            if ((bool)openFileDialog.ShowDialog())
+            {
+                if (string.IsNullOrEmpty(openFileDialog.FileName) == false)
+                {
+                    PDFViewer.SetPDFEditCreateType(ComPDFKit.PDFPage.CPDFEditType.EditImage);
+                    TextEditEvent.ReplaceImagePath = openFileDialog.FileName;
+                    TextEditEvent.UpdatePDFEditByEventArgs();
+                }
+            }
+        }
+
+        private void AddText()
+        {
+            PDFViewer.SetPDFEditCreateType(ComPDFKit.PDFPage.CPDFEditType.EditText);
+        }
+
+        private void TextAlignChecked(object obj)
+        {
+           if((string)obj != null && TextEditEvent != null)
+            {
+                switch((string)obj)
+                {
+                    case "AlignLeft":
+                        TextEditEvent.TextAlign = ComPDFKit.PDFPage.Edit.TextAlignType.AlignLeft;
+                        break;
+
+                    case "AlignCenter":
+                        TextEditEvent.TextAlign = ComPDFKit.PDFPage.Edit.TextAlignType.AlignMiddle;
+                        break;
+
+                    case "AlignRight":
+                        TextEditEvent.TextAlign = ComPDFKit.PDFPage.Edit.TextAlignType.AlignRight;
+                        break;
+                        
+                    case "Align":
+                        TextEditEvent.TextAlign = ComPDFKit.PDFPage.Edit.TextAlignType.AlignNone;
+                        break;
+                }
+                TextEditEvent.UpdatePDFEditByEventArgs();
+            }
+        }
+
+        private void Clockwise()
+        {
+            Angle = TextEditEvent.Rotate = TextEditEvent.Rotate + 90;
+            TextEditEvent.UpdatePDFEditByEventArgs();
+        }
+
+        private void AntiClockwise()
+        {
+            Angle = TextEditEvent.Rotate = TextEditEvent.Rotate - 90;
+            TextEditEvent.UpdatePDFEditByEventArgs();
+        }
+
+
+        private void CropMode()
+        {
+            IsCrop = true;
+            if(TextEditEvent != null)
+            {
+                TextEditEvent.ClipImage = true;
+                TextEditEvent.UpdatePDFEditByEventArgs();
+            }
+        }
+
+        private void SelectedColor(object obj)
+        {
+            if (obj != null)
+            {
+                var colorValue = (Color)obj;
+                if (colorValue != null)
+                {
+
+                    SelectColor = new SolidColorBrush(colorValue);
+                }
+            }
+        }
+
+        private void SelectedFontStyle(object obj)
+        {
+            if (obj != null && (FontStyleItem)obj != null)
+            {
+                var item = (FontStyleItem)obj;
+
+            }
+        }
+
+
+        private void FontFamilyChanged(object obj)
+        {
+            if (obj != null)
+            {
+                if ((int)obj > -1)
+                {
+                    if ((int)obj == 0)
+                    {
+
+                        TextFontFamily = new FontFamily("Courier");
+                    }
+
+
+                    if ((int)obj == 1)
+                    {
+                        TextFontFamily = new FontFamily("Helvetica");
+
+                    }
+
+
+                    if ((int)obj == 2)
+                    {
+                        TextFontFamily = new FontFamily("Times");
+
+                    }
+
+                }
+            }
+
+        }
+
+
+
+        private void FontStyleChanged(object obj)
+        {
+            if (obj != null)
+            {
+                var item = (ComboBoxItem)obj;
+                var content = (string)item.Content;
+                if (content != null)
+                {
+                    if (content == "Regular")
+                    {
+                        TextFontWeights = FontWeights.Normal;
+                        TextFontStyle = FontStyles.Normal;
+                    }
+
+
+                    if (content == "Bold")
+                    {
+                        TextFontWeights = FontWeights.Bold;
+                        TextFontStyle = FontStyles.Normal;
+                    }
+
+
+                    if (content == "Italic")
+                    {
+                        TextFontWeights = FontWeights.Normal;
+                        TextFontStyle = FontStyles.Italic;
+                    }
+
+                    if (content == "Bold Italic")
+                    {
+                        TextFontWeights = FontWeights.Bold;
+                        TextFontStyle = FontStyles.Italic;
+                    }
+
+                }
+            }
+        }
+
+
+        private void FontSizeChanged(object obj)
+        {
+            if (obj != null)
+            {
+                var item = (ComboBoxItem)obj;
+                var content = (string)item.Content;
+                if (content != null)
+                {
+                    var intData = int.Parse(content);
+                    TextFontSize = intData;
+                }
+            }
+        }
+
+
+
+
         public void OnNavigatedTo(NavigationContext navigationContext)
         {
 
@@ -24,9 +526,154 @@ namespace PDF_Office.ViewModels.PropertyPanel
             return true;
         }
 
+        private CPDFViewer PDFViewer;
         public void OnNavigatedFrom(NavigationContext navigationContext)
         {
+            navigationContext.Parameters.TryGetValue<CPDFViewer>(ParameterNames.PDFViewer, out PDFViewer);
+            if(PDFViewer != null)
+            {
+                PDFViewer.PDFEditActiveHandler -= PDFViewer_PDFEditActiveHandler;
+                PDFViewer.PDFEditActiveHandler += PDFViewer_PDFEditActiveHandler; 
+
+                PDFViewer.PDFEditCommandHandler -= PDFViewer_PDFEditCommandHandler;
+                PDFViewer.PDFEditCommandHandler += PDFViewer_PDFEditCommandHandler;
+                
+            }
+        }
+
+        private void PDFViewer_PDFEditCommandHandler(object sender, PDFEditCommand e)
+        {
+           
+            ContextMenu popMenu = null;
+
+            switch (e.CommandType)
+            {
+                case CommandType.Context:
+                   
+                    if (e.EditType == ComPDFKit.PDFPage.CPDFEditType.None)
+                    {
+                        popMenu = App.Current.FindResource("NoneMenu") as ContextMenu;
+                        if(popMenu != null && popMenu.Items.Count == 4)
+                        {
+                            //复制
+                            MenuItem menuItem = popMenu.Items[0] as MenuItem;
+                            menuItem.CommandTarget = (UIElement)sender;
+                            menuItem.Command = ApplicationCommands.Copy;
+                            //添加文本
+                            menuItem = popMenu.Items[1] as MenuItem;
+                            menuItem.CommandTarget = (UIElement)sender;
+                            menuItem.Command = AddTextCommand; 
+                            //添加图像
+                             menuItem = popMenu.Items[2] as MenuItem;
+                            menuItem.CommandTarget = (UIElement)sender;
+                            menuItem.Command = AddImgCommand;
+                            //删除
+                            menuItem = popMenu.Items[3] as MenuItem;
+                            menuItem.CommandTarget = (UIElement)sender;
+                            menuItem.Command = ApplicationCommands.Delete;
+
+                            e.PopupMenu = popMenu;
+                            if (e.PopupMenu != null)
+                            {
+                                e.Handle = true;
+                            }
+                        }
+                    }
+                    else if(e.EditType == ComPDFKit.PDFPage.CPDFEditType.EditImage)
+                    {
+                        popMenu = App.Current.FindResource("SelectImgMenu") as ContextMenu;
+                        if (popMenu != null && popMenu.Items.Count == 8)
+                        {
+                            //复制
+                            MenuItem menuItem = popMenu.Items[0] as MenuItem;
+                            menuItem.CommandTarget = (UIElement)sender;
+                            menuItem.Command = ApplicationCommands.Copy;
+                            //剪切
+                            menuItem = popMenu.Items[1] as MenuItem;
+                            menuItem.CommandTarget = (UIElement)sender;
+                            menuItem.Command = ApplicationCommands.Cut;
+                            //粘贴
+                            menuItem = popMenu.Items[2] as MenuItem;
+                            menuItem.CommandTarget = (UIElement)sender;
+                            menuItem.Command = ApplicationCommands.Paste;
+                            //删除
+                            menuItem = popMenu.Items[3] as MenuItem;
+                            menuItem.CommandTarget = (UIElement)sender;
+                            menuItem.Command = ApplicationCommands.Delete;
+                            //裁剪
+                            menuItem = popMenu.Items[4] as MenuItem;
+                            menuItem.CommandTarget = (UIElement)sender;
+                            menuItem.Command = CropModeCommand;
+                            //替换
+                            menuItem = popMenu.Items[5] as MenuItem;
+                            menuItem.CommandTarget = (UIElement)sender;
+                            menuItem.Command = ReplaceImgCommand;
+                            //导出
+                            menuItem = popMenu.Items[6] as MenuItem;
+                            menuItem.CommandTarget = (UIElement)sender;
+                            menuItem.Command = ExportImgCommand;
+                            //排列
+                            menuItem = popMenu.Items[7] as MenuItem;
+                            menuItem.CommandTarget = (UIElement)sender;
+                            menuItem.Command = ApplicationCommands.Cut;
+                            e.PopupMenu = popMenu;
+                            if (e.PopupMenu != null)
+                            {
+                                e.Handle = true;
+                            }
+                        }
+                    }
+
+            break;
+
+                default:
+                    e.DoCommand();
+                    break;
+
+            }
+        }
+
+        private void PDFViewer_PDFEditActiveHandler(object sender, List<PDFEditEvent> e)
+        {
+            if(e != null && e.Count > 0)
+            {
+                IsTextEdit = (e[0].EditType == ComPDFKit.PDFPage.CPDFEditType.EditText);
+                TextEditEvent = e[0];
+                
+                if (IsTextEdit == false)
+                {
+
+                    var list = PDFViewer.GetSelectedImages();
+                    if(list != null && list.Count > 0)
+                    {
+                        System.Drawing.Bitmap bitmap = null;
+                        foreach (var item in list)
+                        {
+                            if(item.Value.Count>0)
+                            {
+                                bitmap = item.Value[0];
+                                break;
+                            }
+                        }
+
+                        if(bitmap != null)
+                        {
+                            IntPtr ip = bitmap.GetHbitmap();
+                            System.Windows.Media.Imaging.BitmapSource bitmapSource = System.Windows.Interop.Imaging.CreateBitmapSourceFromHBitmap(ip, IntPtr.Zero, Int32Rect.Empty,
+                            System.Windows.Media.Imaging.BitmapSizeOptions.FromEmptyOptions());
+                            CurrentImg = bitmapSource;
+                        }
+                       
+                    }
+                    
+
+                }
 
+            }
+            else
+            {
+                IsTextEdit = true;
+            }
         }
     }
 }

+ 70 - 3
PDF Office/ViewModels/Tools/TextEditToolContentViewModel.cs

@@ -5,22 +5,89 @@ using System.Collections.Generic;
 using System.Linq;
 using System.Text;
 using System.Threading.Tasks;
+using System.Windows.Media;
+using System.Windows;
+using PDF_Office.Model.PropertyPanel.AnnotPanel;
+using System.Windows.Controls;
+using Prism.Regions;
+using ComPDFKitViewer.PdfViewer;
+using PDF_Office.Model;
+using Microsoft.Win32;
+using PDF_Office.CustomControl;
 
 namespace PDF_Office.ViewModels.Tools
 {
-    public class TextEditToolContentViewModel: BindableBase
+    public class TextEditToolContentViewModel: BindableBase, INavigationAware
     {
-       private ComPDFKitViewer.PDFEditEvent TextEditEvent;
+        #region Command
         public DelegateCommand<object> AddContentCommand { get; set; }
+
+        #endregion
         public TextEditToolContentViewModel()
+        {
+            InitCommand();
+        }
+
+        private void InitCommand()
         {
             AddContentCommand = new DelegateCommand<object>(AddContent);
         }
 
         public void AddContent(object obj)
         {
-           if(TextEditEvent != null)
+            if (PDFViewer == null || obj == null || obj as CustomIconToggleBtn == null) return;
+
+            var btn = obj as CustomIconToggleBtn;
+
+            if(btn.IsChecked == true)
+            {
+                if (btn.Tag.ToString() == "Text")
+                {
+                    PDFViewer.SetPDFEditCreateType(ComPDFKit.PDFPage.CPDFEditType.EditText);
+                }
+                else
+                {
+                    OpenFileDialog openFileDialog = new OpenFileDialog();
+                    openFileDialog.Filter = "png|*.png;|Image|*.gif;*.jpg;*.jpeg;*.bmp;*.jfif;*.png;";
+                    openFileDialog.Multiselect = true;
+                    if ((bool)openFileDialog.ShowDialog())
+                    {
+                        if (string.IsNullOrEmpty(openFileDialog.FileName) == false)
+                        {
+                            PDFViewer.SetPDFEditCreateType(ComPDFKit.PDFPage.CPDFEditType.EditImage);
+                            PDFViewer.AddPDFEditImage(openFileDialog.FileName);
+                        }
+                    }
+                    btn.IsChecked = false;
+
+                }
+            }
+            else
+            {
+                PDFViewer.SetPDFEditCreateType(ComPDFKit.PDFPage.CPDFEditType.None);
+                PDFViewer.SetMouseMode(MouseModes.PDFEdit);
+            }
+
+
+        }
+
+        public void OnNavigatedTo(NavigationContext navigationContext)
+        {
+
+        }
+
+        public bool IsNavigationTarget(NavigationContext navigationContext)
+        {
+            return true;
+        }
+
+        private CPDFViewer PDFViewer;
+        public void OnNavigatedFrom(NavigationContext navigationContext)
+        {
+            navigationContext.Parameters.TryGetValue<CPDFViewer>(ParameterNames.PDFViewer, out PDFViewer);
+            if (PDFViewer != null)
             {
+             
 
             }
         }

+ 4 - 1
PDF Office/ViewModels/Tools/ToolsBarContentViewModel.cs

@@ -23,6 +23,8 @@ namespace PDF_Office.ViewModels.Tools
 
         public IEventAggregator eventAggregator;
 
+        public  string unicode = null;
+
         /// <summary>
         /// 是否是第一次加载
         /// </summary>
@@ -44,6 +46,7 @@ namespace PDF_Office.ViewModels.Tools
         {
             dialogs= dialogService;
             this.eventAggregator= eventAggregator;
+            unicode = App.mainWindowViewModel.SelectedItem.Unicode;
             CompressCommand = new DelegateCommand(OpenCompressDialog);
             SetPasswordCommand = new DelegateCommand(OpenSetPasswordDialog);
             CancelPasswordCommand = new DelegateCommand(OpenCancelPasswordDialog);
@@ -55,7 +58,7 @@ namespace PDF_Office.ViewModels.Tools
             var args = e as System.Windows.Controls.Button;
             if (args != null)
             {
-                this.eventAggregator.GetEvent<EnterSelectedEditToolEvent>().Publish(args.Name);
+                this.eventAggregator.GetEvent<EnterSelectedEditToolEvent>().Publish(new StringWithUnicode() { Unicode=unicode,EditToolsContentName=args.Name}) ;
             }
         }
 

+ 53 - 18
PDF Office/ViewModels/ViewContentViewModel.cs

@@ -30,7 +30,7 @@ namespace PDF_Office.ViewModels
     {
         #region 属性、变量
 
-        private CPDFViewer PDFViewer { get; set; }
+        public CPDFViewer PDFViewer { get; set; }
 
         private MainContentViewModel mainViewModel { get; set; }
 
@@ -67,13 +67,15 @@ namespace PDF_Office.ViewModels
         public bool isInPageEdit
         {
             get { return _isInPageEdit; }
-            set { _isInPageEdit = value;
+            set
+            {
+                _isInPageEdit = value;
                 if (!value)
                 {
                     CanRedo = PDFViewer.UndoManager.CanRedo;
                     CanUndo = PDFViewer.UndoManager.CanUndo;
                 }
-                }
+            }
         }
 
         public Action PageEditUndo { get; set; }
@@ -358,6 +360,8 @@ namespace PDF_Office.ViewModels
 
         public string CurrentBar = "";
 
+        public string unicode = null;
+
         /// <summary>
         /// 用来避免重复触发导航事件的标志符
         /// </summary>
@@ -394,7 +398,7 @@ namespace PDF_Office.ViewModels
         {
             region = regionManager;
             dialogs = dialogService;
-
+            unicode = App.mainWindowViewModel.SelectedItem.Unicode;
             LoadFile = new DelegateCommand(loadFile);
             Load = new DelegateCommand(LoadControl);
             SaveFile = new DelegateCommand(() => { saveFile(); });
@@ -425,8 +429,8 @@ namespace PDF_Office.ViewModels
             InitialregionNameByTabItem(ref regionNameByTabItem);
             InitialbarContentByTabItem(ref barContentByTabItem);
 
-            eventAggregator.GetEvent<EnterSelectedEditToolEvent>().Subscribe(EnterEditTools);
-            eventAggregator.GetEvent<CloseEditToolEvent>().Subscribe(CloseEditTool);
+            eventAggregator.GetEvent<EnterSelectedEditToolEvent>().Subscribe(EnterEditTools, e => e.Unicode == unicode);
+            eventAggregator.GetEvent<CloseEditToolEvent>().Subscribe(CloseEditTool, e => e.Unicode == unicode);
 
             //TODO:根据缓存 选择用户上次选择的菜单
             EnterSelectedBar("TabItemAnnotation");
@@ -467,7 +471,7 @@ namespace PDF_Office.ViewModels
             ToolsBarContentVisible = Visibility.Collapsed;
             ConverterBarContentVisible = Visibility.Collapsed;
             TextEditToolContentVisible = Visibility.Collapsed;
-
+        
             switch (currentBar)
             {
                 case "TabItemAnnotation":
@@ -478,25 +482,49 @@ namespace PDF_Office.ViewModels
                     break;
                 case "TabItemEdit":
                     TextEditToolContentVisible = Visibility.Visible;
-                    IsPropertyOpen = true;
-                    if (IsPropertyOpen == true)
-                    {
-                        PDFViewer.SetMouseMode(MouseModes.PDFEdit);
-                        SelectedPrpoertyPanel("TextEditProperty", null);
-                    }
                     break;
                 case "TabItemConvert":
                     ConverterBarContentVisible = Visibility.Visible;
                     break;
 
                 case "TabItemPageEdit":
+                case "HeaderFooterContent":
+                case "BatesContent":
                 case "WatermarkContent":
                 case "BackgroundContent":
+                case "RedactionContent":
                     ToolContentVisible = Visibility.Visible;
                     break;
                 default:
                     break;
             }
+
+            PDFEditMode(currentBar);
+        }
+
+        private void PDFEditMode(string currentBar)
+        {
+            if(currentBar == "TabItemEdit")
+            {
+                IsPropertyOpen = true;
+                if (IsPropertyOpen == true)
+                {
+                    if(PDFViewer != null)
+                    {
+                        PDFViewer.SetMouseMode(MouseModes.PDFEdit);
+                        SelectedPrpoertyPanel("TextEditProperty", null);
+                    }
+                   
+                }
+            }
+            else
+            {
+                if (PDFViewer != null && PDFViewer.MouseMode == MouseModes.PDFEdit)
+                {
+                    IsPropertyOpen = false;
+                    PDFViewer.SetMouseMode(MouseModes.None);
+                }
+            }
         }
 
         private void UndoManager_PropertyChanged(object sender, System.ComponentModel.PropertyChangedEventArgs e)
@@ -933,13 +961,20 @@ namespace PDF_Office.ViewModels
         /// 从二级工具栏进入需要修改界面布局的场景
         /// </summary>
         /// <param name="EditToolName"></param>
-        private void EnterEditTools(string EditToolName)
+        private void EnterEditTools(StringWithUnicode EditToolName)
         {
             EnterSelectedEditTool(EditToolName);
         }
 
-        private void CloseEditTool()
+        private void CloseEditTool(EnumCloseModeUnicode enumCloseModeunicode)
         {
+            EnumCloseMode enumCloseMode = enumCloseModeunicode.Status;
+            if (enumCloseMode == EnumCloseMode.StatusConfirm)
+            {
+                PDFViewer.Document.ReleasePages();
+                PDFViewer.ReloadDocument();
+            }
+
             CurrentBar = "TabItemTool";
             EnterSelectedBar(CurrentBar);
         }
@@ -948,10 +983,10 @@ namespace PDF_Office.ViewModels
         /// 二级菜单指定目标处理
         /// </summary>
         /// <param name="e"></param>
-        private void EnterSelectedEditTool(string EditToolName)
+        private void EnterSelectedEditTool(StringWithUnicode EditToolName)
         {
-            CurrentBar = EditToolName;
-            EnterToolMode(EditToolName);
+            CurrentBar = EditToolName.EditToolsContentName;
+            EnterToolMode(CurrentBar);
         }
 
         /// <summary>

+ 1 - 1
PDF Office/Views/BottomToolContent.xaml

@@ -182,7 +182,7 @@
                 Margin="4"
                 Command="{Binding SetViewModeCommand}"
                 IsChecked="{Binding IsDoubleView}"
-                Style="{StaticResource Radion_ButtonStyle}">
+                Style="{StaticResource Radion_ButtonStyle}" Cursor="Hand">
                 <Path Data="M0,15 L0,1 L11.807106,1 L16,5.39289312 L16,15 L0,15 Z M7.5,2 L1,2 L1,14 L7.5,14 L7.5,2 Z M10.999,2 L8.5,2 L8.5,14 L15,14 L15,5.999 L10.999999,6 L10.999,2 Z M11.999,2.64 L11.999,5 L14.236,4.999 L11.999,2.64 Z" Fill="Black" />
             </RadioButton>
             <RadioButton

+ 0 - 1
PDF Office/Views/Dialog/HomePageToolsDialogs/HomePageInsertDialog.xaml

@@ -83,7 +83,6 @@
                     HorizontalAlignment="Right"
                     Command="{Binding InsertCommand}"
                     Content="插入" />
-            <cus:CommonWritableComboBox HorizontalAlignment="Left" Width="66" Height="32"></cus:CommonWritableComboBox>
         </Grid>
     </Grid>
 </UserControl>

+ 1 - 1
PDF Office/Views/Dialog/ToolsDialogs/CompressDialogs/CompressDialog.xaml

@@ -3,7 +3,7 @@
              xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
              xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
              xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
-             xmlns:prism="http://prismlibrary.com/"             
+             xmlns:prism="http://prismlibrary.com/" xmlns:compressdialogs="clr-namespace:PDF_Office.ViewModels.Dialog.ToolsDialogs.CompressDialogs" 
              prism:ViewModelLocator.AutoWireViewModel="True">
     <UserControl.Resources>
         <ResourceDictionary>

+ 4 - 4
PDF Office/Views/Dialog/ToolsDialogs/SaftyDialogs/SetPasswordDialog.xaml

@@ -37,11 +37,11 @@
                                  GotFocus="TextBox_GotFocus" TextChanged="TextBox_TextChanged" >
                         </TextBox>
                         <Label x:Name="ShowOpenPasswordBoxEyeLabel" HorizontalAlignment="Right" Margin="0,3,0,3" 
-                               MouseLeftButtonUp="ShowPasswordBoxEyeLabel_MouseLeftButtonUp">
+                               MouseLeftButtonUp="ShowPasswordBoxEyeLabel_MouseLeftButtonUp" IsEnabled="{Binding ElementName=CanOpenCheckBox, Path=IsChecked}">
                             <Border Height="23" Width="27" Background="MediumVioletRed" ></Border>
                         </Label>
                         <Label x:Name="ShowOpenTextBoxEyeLabel" HorizontalAlignment="Right" Visibility="Hidden" Margin="0,3,0,3" 
-                               MouseLeftButtonUp="ShowTextBoxEyeLabel_MouseLeftButtonUp">
+                               MouseLeftButtonUp="ShowTextBoxEyeLabel_MouseLeftButtonUp" IsEnabled="{Binding ElementName=CanOpenCheckBox, Path=IsChecked}">
                             <Border Height="23" Width="27" Background="LightSeaGreen" ></Border>
                         </Label> 
                     </Grid>
@@ -58,13 +58,13 @@
                                  GotFocus="TextBox_GotFocus" TextChanged="TextBox_TextChanged">
                         </TextBox>
                         <Label x:Name="ShowEditPasswordBoxEyeLabel" HorizontalAlignment="Right" Margin="0,3,0,3" 
-                               MouseLeftButtonUp="ShowPasswordBoxEyeLabel_MouseLeftButtonUp">
+                               MouseLeftButtonUp="ShowPasswordBoxEyeLabel_MouseLeftButtonUp"  IsEnabled="{Binding ElementName=CanEditCheckBox, Path=IsChecked}">
                             <Border Height="23" Width="27" Background="MediumVioletRed" 
                                       ></Border>
                         </Label>
                         <Label x:Name="ShowEditTextBoxEyeLabel" HorizontalAlignment="Right" Visibility="Hidden" Margin="0,3,0,3"  
                                 MouseLeftButtonUp="ShowTextBoxEyeLabel_MouseLeftButtonUp">
-                            <Border Height="23" Width="27" Background="LightSeaGreen" ></Border>
+                            <Border Height="23" Width="27" Background="LightSeaGreen"  IsEnabled="{Binding ElementName=CanEditCheckBox, Path=IsChecked}"></Border>
                         </Label>
                     </Grid>
                 </StackPanel>

+ 7 - 26
PDF Office/Views/EditTools/Background/BackgroundContent.xaml

@@ -22,7 +22,7 @@
             <RowDefinition Height="40"></RowDefinition>
             <RowDefinition></RowDefinition>
         </Grid.RowDefinitions>
-        <Grid Grid.Row="0" Background="AntiqueWhite">
+        <Grid Grid.Row="0" Background="#FFFFFF">
             <Border x:Name="ToolsBorder" BorderBrush="#1A000000" BorderThickness="0,1,0,1" Height="40">
                 <WrapPanel HorizontalAlignment="Center" Height="40">
                     <Button Style="{StaticResource InsideBarBtnStyle }">
@@ -57,7 +57,7 @@
                 </WrapPanel>
             </Border>
             <StackPanel HorizontalAlignment="Right" Orientation="Horizontal">
-                <Button Content="应用" Height="24" Width="44" ></Button>
+                <Button Content="应用" Height="24" Width="44" Command="{Binding ConfirmEditToolCommand}"></Button>
                 <Button Content="关闭" Height="24" Width="44" Margin="16,0,16,0" Command="{Binding CloseEditToolCommand}"></Button>
             </StackPanel>
         </Grid>
@@ -66,32 +66,13 @@
                 <ColumnDefinition></ColumnDefinition>
                 <ColumnDefinition Width="260"></ColumnDefinition>
             </Grid.ColumnDefinitions>
-            <Grid Grid.Column="0" Background="BurlyWood" >
-                <Border  Height="64" Width="293" HorizontalAlignment="Center"  VerticalAlignment="Bottom"  Panel.ZIndex="1" Margin="9" Background="#323232" CornerRadius="4">
-
-                    <Grid>
-                        <StackPanel Orientation="Horizontal"  VerticalAlignment="Center">
-                            <StackPanel Orientation="Horizontal">
-
-                                <TextBlock Text="-" FontSize="20" Foreground="White" Margin="20,0,20,0"></TextBlock>
-                                <TextBlock Text="+" FontSize="20" Foreground="White" Margin="0,0,39,0"></TextBlock>
-                            </StackPanel>
-                            <StackPanel Orientation="Horizontal">
-                                <TextBlock Text="1" FontSize="20" Foreground="White" Margin="0,0,24,0"></TextBlock>
-                                <TextBlock Text="/" FontSize="20" Foreground="White" Margin="0,0,24,0"></TextBlock>
-                                <TextBlock Text="20" FontSize="20" Foreground="White" Margin="0,0,24,0"></TextBlock>
-                            </StackPanel>
-                            <StackPanel Orientation="Horizontal">
-                                <TextBlock Text="↑" FontSize="20" Foreground="White" Margin="20,0,20,0"></TextBlock>
-                                <TextBlock Text="↓" FontSize="20" Foreground="White"></TextBlock>
-
-                            </StackPanel>
-                        </StackPanel>
-                    </Grid>
-                </Border>
+            <Grid Grid.Column="0" Background="#E7E9EC" >
+                <ContentControl prism:RegionManager.RegionName="{Binding BackgroundDocumentRegionName}" Visibility="{Binding BackgroundDocumentVisible}"></ContentControl>
+                
+                
             </Grid>
 
-            <Grid Grid.Column="1" Background="Wheat">
+            <Grid Grid.Column="1" Background="#F3F3F3">
                 <ContentControl prism:RegionManager.RegionName="{Binding BackgroundSettingsRegionName}" Visibility="{Binding BackgroundSettingsVisible}"></ContentControl>
             </Grid>
         </Grid>

+ 17 - 3
PDF Office/Views/EditTools/Background/BackgroundCreateBaseContent.xaml

@@ -4,7 +4,7 @@
              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" 
+             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" >
@@ -14,20 +14,34 @@
             <RowDefinition Height="48"></RowDefinition>
             <RowDefinition></RowDefinition>
         </Grid.RowDefinitions>
-        <Grid Grid.Row="0">
+        <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">
+            <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>

+ 44 - 27
PDF Office/Views/EditTools/Background/BackgroundCreateColorContent.xaml

@@ -4,7 +4,7 @@
              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:mc="http://schemas.openxmlformats.org/markup-compatibility/2006" xmlns:cus="clr-namespace:PDF_Office.CustomControl" xmlns:background="clr-namespace:PDF_Office.ViewModels.EditTools.Background" xmlns:CompositeControl="clr-namespace:PDF_Office.CustomControl.CompositeControl" d:DataContext="{d:DesignInstance Type=background:BackgroundCreateColorContentViewModel}"
              mc:Ignorable="d"
              d:DesignHeight="632"
              d:DesignWidth="260">
@@ -26,13 +26,29 @@
         <Grid Grid.Row="0" >
             <StackPanel Orientation="Vertical">
                 <TextBlock Text="背景颜色" Height="20" Width="48" HorizontalAlignment="Left" Margin="0,16,16,8" Foreground="#666666"> </TextBlock>
-                <StackPanel Orientation="Horizontal">
-                    <Button Height="32" Width="32" Margin="0,0,8,0"></Button>
-                    <Button Height="32" Width="32" Margin="0,0,8,0"></Button>
+                <!--<StackPanel Orientation="Horizontal">
+                    <Button Name="RedColorBtn" Height="32" Width="32" Margin="0,0,8,0" Command="{Binding ChangeColorCommand}" CommandParameter="{Binding ElementName=RedColorBtn}">
+                        <Rectangle Height="22" Width="22" Fill="Red" RadiusX="20" RadiusY="20"></Rectangle>
+                    </Button>
+                    <Button Name="GreenColorBtn" Height="32" Width="32" Margin="0,0,8,0"  Command="{Binding ChangeColorCommand}" CommandParameter="{Binding ElementName=GreenColorBtn}">
+                        <Rectangle Height="22" Width="22" Fill="#008000" RadiusX="20" RadiusY="20"></Rectangle>
+
+                    </Button>
                     <Button Height="32" Width="32" Margin="0,0,8,0"></Button>
                     <Button Height="32" Width="32" Margin="0,0,8,0"></Button>
-                    <Button Height="32" Width="66"></Button>
-                </StackPanel>
+                    <Button Height="32" Width="66">
+                        <Grid Height="32" Width="66" HorizontalAlignment="Center" VerticalAlignment="Center">
+                            <Grid.ColumnDefinitions>
+                                <ColumnDefinition></ColumnDefinition>
+                                <ColumnDefinition></ColumnDefinition>
+                            </Grid.ColumnDefinitions>
+                            <Grid Grid.Column="0" Height="22" Width="22">
+                                <Rectangle Fill="{Binding StringColor, Mode=TwoWay}" RadiusX="20" RadiusY="20"></Rectangle>
+                            </Grid>
+                        </Grid>
+                    </Button>
+                </StackPanel>-->
+                <CompositeControl:ColorContent Grid.Row="1" Margin="0,-2,0,0"  x:Name="cusColor"/>
             </StackPanel>
         </Grid>
         <Grid Grid.Row="1">
@@ -40,21 +56,19 @@
                 <TextBlock Text="外观" Margin="0,16,0,8" Foreground="#666666"></TextBlock>
                 <StackPanel Orientation="Horizontal">
                     <TextBlock Height="24" Width="24" Background= "Bisque" Margin="0,0,8,0"></TextBlock>
-                    <ComboBox Height="32" Width=" 66" Margin="0,0,28,0"></ComboBox>
+                    <cus:CommonWritableComboBox HorizontalAlignment="Left" Width="66" Height="32" Margin="0,0,28,0" TypeSouce="{Binding RotationList, Mode=TwoWay}" Value="{Binding RotationValue, Mode=TwoWay}" Text="0" ></cus:CommonWritableComboBox>
+                    
                     <TextBlock Height="24" Width="24" Background="CadetBlue" Margin="0,0,8,0"></TextBlock>
-                    <ComboBox Height="32" Width=" 66"></ComboBox>
+                    <cus:CommonWritableComboBox HorizontalAlignment="Left" Width="66" Height="32" TypeSouce="{Binding OpacityList, Mode=TwoWay}" Value="{Binding OpacityValue, Mode=TwoWay}" Text="100 %"></cus:CommonWritableComboBox>
                 </StackPanel>
                 <StackPanel Orientation="Horizontal"></StackPanel>
                 <Grid Margin="0,19,0,0">
-                    <Grid.ColumnDefinitions>
-                        <ColumnDefinition  Width="30"></ColumnDefinition>
-                        <ColumnDefinition ></ColumnDefinition>
 
-                    </Grid.ColumnDefinitions>
-                    <CheckBox Grid.Column="0" Style="{StaticResource CheckBoxStyle}" Content="相对目标页面的比例" Margin="0,0,0,0" Height="22"></CheckBox>
-                    <TextBlock Grid.Column="1" Text="相对目标页面的比例" Height="22" ></TextBlock>
+                    <CheckBox Grid.Column="0" Style="{StaticResource EditToolsCheckBoxStyle}" Content="相对目标页面的比例" Margin="0,0,0,0" Height="22" ></CheckBox>
                 </Grid>
-                <ComboBox Height="32" Width="66" HorizontalAlignment="Left" Margin="0,11,0,0"></ComboBox>
+                <cus:CommonWritableComboBox HorizontalAlignment="Left" Width="66" Height="32" Margin="0,11,0,0" TypeSouce="{Binding RelativeRatioList,Mode=TwoWay}" Value="{Binding RelativeRatioValue, Mode=TwoWay}" Text="50 %"></cus:CommonWritableComboBox>
+
+
             </StackPanel>
             
         </Grid>
@@ -73,24 +87,25 @@
                             <RowDefinition></RowDefinition>
                             <RowDefinition></RowDefinition>
                         </Grid.RowDefinitions>
-                        <Button Grid.Column="0" Grid.Row="0"></Button>
-                        <Button Grid.Column="1" Grid.Row="0"></Button>
-                        <Button Grid.Column="2" Grid.Row="0"></Button>
-                        <Button Grid.Column="0" Grid.Row="1"></Button>
-                        <Button Grid.Column="1" Grid.Row="1" Background="Black"></Button>
-                        <Button Grid.Column="2" Grid.Row="1"></Button>
-                        <Button Grid.Column="0" Grid.Row="2"></Button>
-                        <Button Grid.Column="1" Grid.Row="2"></Button>
-                        <Button Grid.Column="2" Grid.Row="2"></Button>
+                        <Button Grid.Column="0" Grid.Row="0" Tag="0" Command="{Binding ChangeLocationCommand}" CommandParameter="{Binding RelativeSource={RelativeSource Self}, Path=Tag}" IsEnabled="{Binding GetLocationFromNumber[0],Mode=TwoWay}"></Button>
+                        <Button Grid.Column="1" Grid.Row="0" Tag="1" Command="{Binding ChangeLocationCommand}" CommandParameter="{Binding RelativeSource={RelativeSource Self}, Path=Tag}"  IsEnabled="{Binding GetLocationFromNumber[1], Mode=TwoWay}"></Button>
+                        <Button Grid.Column="2" Grid.Row="0" Tag="2" Command="{Binding ChangeLocationCommand}" CommandParameter="{Binding RelativeSource={RelativeSource Self}, Path=Tag}"  IsEnabled="{Binding GetLocationFromNumber[2], Mode=TwoWay}"></Button>
+                        <Button Grid.Column="0" Grid.Row="1" Tag="10" Command="{Binding ChangeLocationCommand}"  CommandParameter="{Binding RelativeSource={RelativeSource Self}, Path=Tag}"  IsEnabled="{Binding GetLocationFromNumber[10], Mode=TwoWay}"></Button>
+                        <Button Grid.Column="1" Grid.Row="1" Tag="11" Command="{Binding ChangeLocationCommand}"  CommandParameter="{Binding RelativeSource={RelativeSource Self}, Path=Tag}"  IsEnabled="{Binding GetLocationFromNumber[11], Mode=TwoWay}"></Button>
+                        <Button Grid.Column="2" Grid.Row="1" Tag="12" Command="{Binding ChangeLocationCommand}"  CommandParameter="{Binding RelativeSource={RelativeSource Self}, Path=Tag}"  IsEnabled="{Binding GetLocationFromNumber[12], Mode=TwoWay}"></Button>
+                        <Button Grid.Column="0" Grid.Row="2" Tag="20" Command="{Binding ChangeLocationCommand}"  CommandParameter="{Binding RelativeSource={RelativeSource Self}, Path=Tag}"  IsEnabled="{Binding GetLocationFromNumber[20], Mode=TwoWay}"></Button>
+                        <Button Grid.Column="1" Grid.Row="2" Tag="21" Command="{Binding ChangeLocationCommand}"  CommandParameter="{Binding RelativeSource={RelativeSource Self}, Path=Tag}"  IsEnabled="{Binding GetLocationFromNumber[21], Mode=TwoWay}"></Button>
+                        <Button Grid.Column="2" Grid.Row="2" Tag="22" Command="{Binding ChangeLocationCommand}"  CommandParameter="{Binding RelativeSource={RelativeSource Self}, Path=Tag}"  IsEnabled="{Binding GetLocationFromNumber[22], Mode=TwoWay}"></Button>
                     </Grid>
                     <StackPanel Orientation="Vertical" Margin="70,0,0,0">
                         <StackPanel Orientation="Horizontal">
                             <TextBlock Text="X"  Width="9" Height="20" VerticalAlignment="Center"/>
-                            <TextBox Width="66" Height="32" Margin="9,0,0,0"></TextBox>
+                            <cus:NumericUpDown Width="66" Height="32" Margin="9,0,0,0"  Text="{Binding HorizontalOffsetValue, Mode=TwoWay}" ></cus:NumericUpDown>
+
                         </StackPanel>
                         <StackPanel Orientation="Horizontal" Margin="0,8,0,0">
                             <TextBlock Text="Y" Width="9" Height="20" VerticalAlignment="Center"/>
-                            <TextBox Width="66" Height="32" Margin="9,0,0,0"></TextBox>
+                            <cus:NumericUpDown Width="66" Height="32" Margin="9,0,0,0"  Text="{Binding VerticalOffsetValue, Mode=TwoWay}"></cus:NumericUpDown>
                         </StackPanel>
                     </StackPanel>
 
@@ -113,8 +128,10 @@
         <Grid Grid.Row="3" Margin="0,16,0,0">
             <StackPanel Orientation="Vertical">
                 <TextBlock Text="页面范围" FontSize="12" Foreground="#666666" Height="20" Width="48" HorizontalAlignment="Left"></TextBlock>
-                <ComboBox Height="32" Width="228" Margin="0,8,0,0" HorizontalAlignment="Left"></ComboBox>
+                <cus:WritableComboBox  Height="32" Width="228" Margin="0,8,0,0" HorizontalAlignment="Left" Text="{Binding PageRangeText,Mode=TwoWay}" SelectedIndex="{Binding PageRangeSelectIndex,Mode=TwoWay}"></cus:WritableComboBox>
             </StackPanel>
         </Grid>
+        <Grid Grid.Row="4">
+        </Grid>
     </Grid>
 </UserControl>

+ 15 - 1
PDF Office/Views/EditTools/Background/BackgroundCreateColorContent.xaml.cs

@@ -1,4 +1,8 @@
-using System.Windows.Controls;
+using PDF_Office.ViewModels.EditTools.Background;
+using PDF_Office.ViewModels.EditTools.Watermark;
+using System;
+using System.Windows.Controls;
+using System.Windows.Media;
 
 namespace PDF_Office.Views.EditTools.Background
 {
@@ -10,6 +14,16 @@ namespace PDF_Office.Views.EditTools.Background
         public BackgroundCreateColorContent()
         {
             InitializeComponent();
+            cusColor.SelectedColorHandler += cusColor_SelectedColor;
+        }
+
+        private void cusColor_SelectedColor(object sender, Color e)
+        {
+            var data = this.DataContext as BackgroundCreateColorContentViewModel;
+            if (data != null)
+            {
+                data.ChangeColorCommand?.Execute(e);
+            }
         }
     }
 }

+ 76 - 76
PDF Office/Views/EditTools/Background/BackgroundCreateFileContent.xaml

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

+ 36 - 0
PDF Office/Views/EditTools/Background/BackgroundDocumentContent.xaml

@@ -0,0 +1,36 @@
+<UserControl x:Class="PDF_Office.Views.EditTools.Background.BackgroundDocumentContent"
+             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" xmlns:i="http://schemas.microsoft.com/xaml/behaviors" d:DataContext="{d:DesignInstance Type=background:BackgroundDocumentContentViewModel}"
+             mc:Ignorable="d"
+             d:DesignHeight="720"
+             d:DesignWidth="1020" >
+    <Grid Height="720" Width="1020">
+        <ContentControl
+                x:Name="PDFViewerContent"
+                HorizontalAlignment="Stretch"
+                prism:RegionManager.RegionName="{Binding ViewerRegionName}" />
+        <Border CornerRadius="4" Background="#323232"  HorizontalAlignment="Left" VerticalAlignment="Bottom" Margin="41,0,0,25" Height="53" Width="93"  Panel.ZIndex="1" >
+            <StackPanel Orientation="Horizontal" HorizontalAlignment="Center" VerticalAlignment="Center" >
+                <Grid>
+                    <Button  Name="ShowInputIndexBoxBtn" Background="Transparent" BorderThickness="0" Padding="0">
+                        <Label  Content="{Binding CurrentPageIndex, Mode=TwoWay}" Foreground="White" FontSize="20"></Label>
+                        <i:Interaction.Triggers>
+                            <i:EventTrigger EventName="MouseDoubleClick">
+                                <i:InvokeCommandAction Command="{Binding ShowInputIndexBoxCommand}" CommandParameter="{Binding ElementName=ShowInputIndexBoxBtn}"/>
+                            </i:EventTrigger>
+                        </i:Interaction.Triggers>
+                    </Button>
+                    <TextBox Name="CurrentPageIndexBox" Visibility="{Binding InputIndexBoxVisible}" KeyDown="CurrentPageIndexBox_KeyDown" VerticalContentAlignment="Center">
+                        
+                    </TextBox>
+                </Grid>
+                <TextBlock Text="/" Foreground="White" FontSize="20" VerticalAlignment="Center" Margin="2,0,2,0"></TextBlock>
+                <TextBlock  Text="{Binding PageRangeNumber, Mode=TwoWay}" FontSize="20"  Foreground="White" VerticalAlignment="Center"></TextBlock>
+            </StackPanel>
+        </Border>
+    </Grid>
+</UserControl>

+ 25 - 0
PDF Office/Views/EditTools/Background/BackgroundDocumentContent.xaml.cs

@@ -0,0 +1,25 @@
+using PDF_Office.ViewModels.EditTools.Background;
+using System.Windows.Controls;
+
+namespace PDF_Office.Views.EditTools.Background
+{
+    /// <summary>
+    /// Interaction logic for BackgroundDocumentContent
+    /// </summary>
+    public partial class BackgroundDocumentContent : UserControl
+    {
+        public BackgroundDocumentContent()
+        {
+            InitializeComponent();
+        }
+
+        private void CurrentPageIndexBox_KeyDown(object sender, System.Windows.Input.KeyEventArgs e)
+        {
+            if(e.Key == System.Windows.Input.Key.Enter)
+            {
+                var data = this.DataContext as BackgroundDocumentContentViewModel;
+                data.GoToPageCommand?.Execute(sender);
+            }
+        }
+    }
+}

+ 78 - 4
PDF Office/Views/EditTools/Background/BackgroundTemplateListColorContent.xaml

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

+ 63 - 1
PDF Office/Views/EditTools/Background/BackgroundTemplateListColorContent.xaml.cs

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

+ 76 - 3
PDF Office/Views/EditTools/Background/BackgroundTemplateListFileContent.xaml

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

+ 61 - 1
PDF Office/Views/EditTools/Background/BackgroundTemplateListFileContent.xaml.cs

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

+ 78 - 0
PDF Office/Views/EditTools/Bates/BatesContent.xaml

@@ -0,0 +1,78 @@
+<UserControl x:Class="PDF_Office.Views.EditTools.Bates.BatesContent"
+             xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
+             xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
+             xmlns:prism="http://prismlibrary.com/"             
+             xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
+             xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006" 
+             mc:Ignorable="d"
+             prism:ViewModelLocator.AutoWireViewModel="True"
+             d:DesignHeight="760"
+             d:DesignWidth="1280">
+    <UserControl.Resources>
+        <ResourceDictionary>
+            <ResourceDictionary.MergedDictionaries>
+                <ResourceDictionary Source="../../../Styles/CustomBtnStyle.xaml"/>
+            </ResourceDictionary.MergedDictionaries>
+        </ResourceDictionary>
+    </UserControl.Resources>
+    <Grid>
+        <Grid.RowDefinitions>
+            <RowDefinition Height="40"></RowDefinition>
+            <RowDefinition></RowDefinition>
+        </Grid.RowDefinitions>
+        <Grid Grid.Row="0" Background="#FFFFFF">
+            <Border x:Name="ToolsBorder" BorderBrush="#1A000000" BorderThickness="0,1,0,1" Height="40">
+                <WrapPanel HorizontalAlignment="Center" Height="40">
+                    <Button Style="{StaticResource InsideBarBtnStyle }">
+
+                        <StackPanel Orientation="Horizontal" Margin="12 0 12 0">
+                            <StackPanel Margin="0,0,8,0">
+                                <Border Height="30" Width="30" Background="LightSeaGreen" ></Border>
+                            </StackPanel >
+                            <TextBlock Text="添加Bates" VerticalAlignment="Center"></TextBlock>
+                        </StackPanel>
+                    </Button>
+                    <Button Style="{StaticResource InsideBarBtnStyle }" >
+
+                        <StackPanel Orientation="Horizontal" Margin="12 0 12 0">
+                            <StackPanel Margin="0,0,8,0">
+                                <Border Height="30" Width="30" Background="LightSeaGreen" ></Border>
+                            </StackPanel >
+                            <TextBlock Text="移除" VerticalAlignment="Center"></TextBlock>
+                        </StackPanel>
+                    </Button>
+
+                    <Label Height="10" Width="1" Background="LightGray"></Label>
+
+                    <Button Style="{StaticResource InsideBarBtnStyle }" >
+                        <StackPanel Orientation="Horizontal" Margin="12 0 12 0">
+                            <StackPanel Margin="0,0,8,0">
+                                <Border Height="30" Width="30" Background="LightSeaGreen" ></Border>
+                            </StackPanel >
+                            <TextBlock Text="批量" VerticalAlignment="Center"></TextBlock>
+                        </StackPanel>
+                    </Button>
+                </WrapPanel>
+            </Border>
+            <StackPanel HorizontalAlignment="Right" Orientation="Horizontal">
+                <Button Content="应用" Height="24" Width="44" Command="{Binding ConfirmEditToolCommand}"></Button>
+                <Button Content="关闭" Height="24" Width="44" Margin="16,0,16,0" Command="{Binding CloseEditToolCommand}"></Button>
+            </StackPanel>
+        </Grid>
+        <Grid Grid.Row="1" >
+            <Grid.ColumnDefinitions>
+                <ColumnDefinition></ColumnDefinition>
+                <ColumnDefinition Width="260"></ColumnDefinition>
+            </Grid.ColumnDefinitions>
+            <Grid Grid.Column="0" Background="#E7E9EC" >
+                <ContentControl prism:RegionManager.RegionName="{Binding BatesDocumentRegionName}" Visibility="{Binding BatesDocumentVisible}"></ContentControl>
+
+
+            </Grid>
+
+            <Grid Grid.Column="1" Background="#F3F3F3">
+                <ContentControl prism:RegionManager.RegionName="{Binding BatesSettingsRegionName}" Visibility="{Binding BatesSettingsVisible}"></ContentControl>
+            </Grid>
+        </Grid>
+    </Grid>
+</UserControl>

+ 15 - 0
PDF Office/Views/EditTools/Bates/BatesContent.xaml.cs

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

+ 153 - 0
PDF Office/Views/EditTools/Bates/BatesCreateContent.xaml

@@ -0,0 +1,153 @@
+<UserControl x:Class="PDF_Office.Views.EditTools.Bates.BatesCreateContent"
+              xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
+             xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
+             xmlns:prism="http://prismlibrary.com/"             
+             prism:ViewModelLocator.AutoWireViewModel="True"
+              xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
+             xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006" 
+             xmlns:cus="clr-namespace:PDF_Office.CustomControl"
+             xmlns:i="http://schemas.microsoft.com/xaml/behaviors"
+             xmlns:CompositeControl="clr-namespace:PDF_Office.CustomControl.CompositeControl"
+             mc:Ignorable="d"
+             d:DesignHeight="720"
+             d:DesignWidth="260" >
+    <Grid>
+        <Grid.RowDefinitions>
+            <RowDefinition Height="40"></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="创建Bates" 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">
+            <Grid.RowDefinitions>
+                <RowDefinition Height="116"></RowDefinition>
+                <RowDefinition Height="116"></RowDefinition>
+                <RowDefinition Height="189"></RowDefinition>
+                <RowDefinition Height="172"></RowDefinition>
+                <RowDefinition></RowDefinition>
+            </Grid.RowDefinitions>
+            <Grid Grid.Row="0" Margin="0,16,0,0" Width="228">
+                <StackPanel>
+                    <TextBlock Text="外观" FontSize="12" Foreground="#666666" Height="20" Width="24" HorizontalAlignment="Left"></TextBlock>
+                    <StackPanel Orientation="Horizontal" Margin="0,8,0,0">
+                        <ComboBox Width="154" Height="32" ></ComboBox>
+                        <ComboBox Width="66" Height="32" Margin="8,0,0,0" ></ComboBox>
+                    </StackPanel>
+                    <CompositeControl:ColorContent x:Name="cusColor" Height="32" Width="66"  Margin="0,8,0,0"  HorizontalAlignment="Left">
+                    </CompositeControl:ColorContent>
+                </StackPanel>
+            </Grid>
+            <Grid Grid.Row="1" Margin="0,16,0,0" Width="228">
+                <StackPanel>
+                    <TextBlock Text="页边距" FontSize="12" Foreground="#666666" Height="20" Width="36" HorizontalAlignment="Left"></TextBlock>
+                    <StackPanel Orientation="Horizontal" Margin="0,8,0,0">
+                        <StackPanel Orientation="Vertical" Margin="0,0,0,0">
+                            <StackPanel Orientation="Horizontal">
+                                <TextBlock Text="上"  Width="14" Height="20" VerticalAlignment="Center"/>
+                                <cus:NumericUpDown Width="66" Height="32" Margin="9,0,0,0" ></cus:NumericUpDown>
+                            </StackPanel>
+                            <StackPanel Orientation="Horizontal" Margin="0,8,0,0">
+                                <TextBlock Text="左" Width="14" Height="20" VerticalAlignment="Center"/>
+                                <cus:NumericUpDown Width="66" Height="32" Margin="9,0,0,0"  ></cus:NumericUpDown>
+                            </StackPanel>
+                        </StackPanel>
+                        <StackPanel Orientation="Vertical" Margin="51,0,0,0">
+                            <StackPanel Orientation="Horizontal">
+                                <TextBlock Text="下"  Width="14" Height="20" VerticalAlignment="Center"/>
+                                <cus:NumericUpDown Width="66" Height="32" Margin="9,0,0,0"  ></cus:NumericUpDown>
+                            </StackPanel>
+                            <StackPanel Orientation="Horizontal" Margin="0,8,0,0">
+                                <TextBlock Text="右" Width="14" Height="20" VerticalAlignment="Center"/>
+                                <cus:NumericUpDown Width="66" Height="32" Margin="9,0,0,0"  Text="{Binding VertOffsetValue,Mode=TwoWay}"></cus:NumericUpDown>
+                            </StackPanel>
+                        </StackPanel>
+                    </StackPanel>
+                </StackPanel>
+            </Grid>
+            <Grid Grid.Row="2" Margin="0,16,0,0" Width="228">
+                <StackPanel>
+                    <StackPanel>
+                        <TextBlock Text="前缀" FontSize="12" Foreground="#666666" Height="20" Width="24" HorizontalAlignment="Left"></TextBlock>
+                        <TextBlock  Height="32"></TextBlock>
+                    </StackPanel>
+                    <StackPanel Margin="0,8,0,0">
+                        <TextBlock Text="后缀" FontSize="12" Foreground="#666666" Height="20" Width="24" HorizontalAlignment="Left"></TextBlock>
+                        <TextBlock  Height="32"></TextBlock>
+                    </StackPanel>
+                    <StackPanel Orientation="Horizontal" Margin="0,8,0,0">
+                        <StackPanel>
+                            <TextBlock Text="位数" FontSize="12" Foreground="#666666" Height="20" Width="24" HorizontalAlignment="Left"></TextBlock>
+                            <cus:NumericUpDown Height="32" Width="110"></cus:NumericUpDown>
+                        </StackPanel>
+                        <StackPanel Margin="8,0,0,0">
+                            <TextBlock Text="起始页" FontSize="12" Foreground="#666666" Height="20" Width="36" HorizontalAlignment="Left"></TextBlock>
+                            <ComboBox Height="32" Width="110"></ComboBox>
+                        </StackPanel>
+                    </StackPanel>
+                </StackPanel>
+            </Grid>
+            <Grid Grid.Row="3" Margin="0,16,0,0" Width="228">
+                <StackPanel>
+                    <StackPanel Orientation="Horizontal">
+                        <TextBlock Text="布局&amp;内容" FontSize="12" Foreground="#666666" Height="20" Width="60"></TextBlock>
+                        <Button Width="22" Height="22" Margin="146,0,0,0">
+                            <TextBlock Text="+" FontSize="19" HorizontalAlignment="Center" VerticalAlignment="Center"  Block.TextAlignment="Center" ></TextBlock>
+                        </Button>
+                    </StackPanel>
+                    <Grid Width="228" Height="46" Margin="0,6,0,0">
+                        <Grid.ColumnDefinitions>
+                            <ColumnDefinition Width="75"></ColumnDefinition>
+                            <ColumnDefinition Width="75"></ColumnDefinition>
+                            <ColumnDefinition Width="75"></ColumnDefinition>
+                        </Grid.ColumnDefinitions>
+                        <Grid.RowDefinitions>
+                            <RowDefinition Height="23"></RowDefinition>
+                            <RowDefinition Height="23"></RowDefinition>
+                        </Grid.RowDefinitions>
+                        <Button Grid.Column="0" Grid.Row="0" Tag="0" Command="{Binding ChangeLocationCommand}" CommandParameter="{Binding RelativeSource={RelativeSource Self}, Path=Tag}" IsEnabled="{Binding GetLocationFromNumber[0],Mode=TwoWay}"></Button>
+                        <Button Grid.Column="1" Grid.Row="0" Tag="1" Command="{Binding ChangeLocationCommand}" CommandParameter="{Binding RelativeSource={RelativeSource Self}, Path=Tag}"  IsEnabled="{Binding GetLocationFromNumber[1], Mode=TwoWay}"></Button>
+                        <Button Grid.Column="2" Grid.Row="0" Tag="2" Command="{Binding ChangeLocationCommand}" CommandParameter="{Binding RelativeSource={RelativeSource Self}, Path=Tag}"  IsEnabled="{Binding GetLocationFromNumber[2], Mode=TwoWay}"></Button>
+                        <Button Grid.Column="0" Grid.Row="1" Tag="10" Command="{Binding ChangeLocationCommand}"  CommandParameter="{Binding RelativeSource={RelativeSource Self}, Path=Tag}"  IsEnabled="{Binding GetLocationFromNumber[10], Mode=TwoWay}"></Button>
+                        <Button Grid.Column="1" Grid.Row="1" Tag="11" Command="{Binding ChangeLocationCommand}"  CommandParameter="{Binding RelativeSource={RelativeSource Self}, Path=Tag}"  IsEnabled="{Binding GetLocationFromNumber[11], Mode=TwoWay}"></Button>
+                        <Button Grid.Column="2" Grid.Row="1" Tag="12" Command="{Binding ChangeLocationCommand}"  CommandParameter="{Binding RelativeSource={RelativeSource Self}, Path=Tag}"  IsEnabled="{Binding GetLocationFromNumber[12], Mode=TwoWay}"></Button>
+                    </Grid>
+                    <TextBox Name="TextValueTextBox" Height="72" Margin="0,8,0,0"  FontSize="14"  AcceptsReturn="True">
+
+                    </TextBox>
+                </StackPanel>
+            </Grid>
+            <Grid Grid.Row="4" Margin="0,16,0,0" Width="228">
+                <StackPanel>
+                    <TextBlock Text="页面范围" FontSize="12" Foreground="#666666" Height="20" Width="48" HorizontalAlignment="Left"></TextBlock>
+                    <cus:WritableComboBox Height="32" Margin="0,8,0,0"></cus:WritableComboBox>
+                </StackPanel>
+            </Grid>
+        </Grid>
+    </Grid>
+</UserControl>

+ 15 - 0
PDF Office/Views/EditTools/Bates/BatesCreateContent.xaml.cs

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

+ 38 - 0
PDF Office/Views/EditTools/Bates/BatesDocumentContent.xaml

@@ -0,0 +1,38 @@
+<UserControl x:Class="PDF_Office.Views.EditTools.Bates.BatesDocumentContent"
+              xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
+             xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
+             xmlns:prism="http://prismlibrary.com/"             
+             prism:ViewModelLocator.AutoWireViewModel="True"
+             xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
+              xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006" 
+             mc:Ignorable="d"
+             d:DesignHeight="720"
+             d:DesignWidth="1020" >
+    <Grid Height="720" Width="1020" Background="SkyBlue">
+        <ContentControl
+                x:Name="PDFViewerContent"
+                HorizontalAlignment="Stretch"
+                prism:RegionManager.RegionName="{Binding ViewerRegionName}" />
+        <Border  Height="64" Width="293" HorizontalAlignment="Center"  VerticalAlignment="Bottom"  Panel.ZIndex="1" Margin="9" Background="#323232" CornerRadius="4">
+            <Grid>
+                <StackPanel Orientation="Horizontal"  VerticalAlignment="Center">
+                    <StackPanel Orientation="Horizontal">
+                        <TextBlock Text="-" FontSize="20" Foreground="White" Margin="20,0,20,0"></TextBlock>
+                        <TextBlock Text="+" FontSize="20" Foreground="White" Margin="0,0,39,0"></TextBlock>
+                    </StackPanel>
+                    <StackPanel Orientation="Horizontal">
+                        <TextBlock Text="1" FontSize="20" Foreground="White" Margin="0,0,24,0"></TextBlock>
+                        <TextBlock Text="/" FontSize="20" Foreground="White" Margin="0,0,24,0"></TextBlock>
+                        <TextBlock Text="20" FontSize="20" Foreground="White" Margin="0,0,24,0"></TextBlock>
+                    </StackPanel>
+                    <StackPanel Orientation="Horizontal">
+                        <TextBlock Text="↑" FontSize="20" Foreground="White" Margin="20,0,20,0"></TextBlock>
+                        <TextBlock Text="↓" FontSize="20" Foreground="White"></TextBlock>
+
+                    </StackPanel>
+                </StackPanel>
+            </Grid>
+        </Border>
+    </Grid>
+</UserControl>
+

+ 15 - 0
PDF Office/Views/EditTools/Bates/BatesDocumentContent.xaml.cs

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

+ 0 - 0
PDF Office/Views/EditTools/Bates/BatesTemplateListContent.xaml


Một số tệp đã không được hiển thị bởi vì quá nhiều tập tin thay đổi trong này khác