Bladeren bron

页眉页脚,Bates

liyijie 2 jaren geleden
bovenliggende
commit
5cb9501eb6
42 gewijzigde bestanden met toevoegingen van 3259 en 219 verwijderingen
  1. 12 6
      PDF Office/App.config
  2. 0 1
      PDF Office/App.xaml.cs
  3. 37 0
      PDF Office/EventAggregators/EditToolsEvent.cs
  4. 88 0
      PDF Office/Model/EditTools/Bates/BatesCreateModel.cs
  5. 82 0
      PDF Office/Model/EditTools/HeaderFooter/HeaderFooterCreateModel.cs
  6. 15 0
      PDF Office/Model/RegionNames.cs
  7. 2 0
      PDF Office/PDF Office.csproj
  8. 47 1
      PDF Office/Properties/Settings.Designer.cs
  9. 12 0
      PDF Office/Properties/Settings.settings
  10. 67 0
      PDF Office/Styles/RadioButtonStyle.xaml
  11. 1 1
      PDF Office/ViewModels/EditTools/Background/BackgroundCreateColorContentViewModel.cs
  12. 1 1
      PDF Office/ViewModels/EditTools/Background/BackgroundCreateFileContentViewModel.cs
  13. 0 1
      PDF Office/ViewModels/EditTools/Background/BackgroundDocumentContentViewModel.cs
  14. 0 2
      PDF Office/ViewModels/EditTools/Background/BackgroundTemplateListColorContentViewModel.cs
  15. 1 0
      PDF Office/ViewModels/EditTools/Background/BackgroundTemplateListFileContentViewModel.cs
  16. 27 1
      PDF Office/ViewModels/EditTools/Bates/BatesContentViewModel.cs
  17. 616 2
      PDF Office/ViewModels/EditTools/Bates/BatesCreateContentViewModel.cs
  18. 231 2
      PDF Office/ViewModels/EditTools/Bates/BatesDocumentContentViewModel.cs
  19. 188 1
      PDF Office/ViewModels/EditTools/Bates/BatesTemplateListContentViewModel.cs
  20. 26 1
      PDF Office/ViewModels/EditTools/HeaderFooter/HeaderFooterContentViewModel.cs
  21. 641 4
      PDF Office/ViewModels/EditTools/HeaderFooter/HeaderFooterCreateContentViewModel.cs
  22. 283 2
      PDF Office/ViewModels/EditTools/HeaderFooter/HeaderFooterDocumentContentViewModel.cs
  23. 182 0
      PDF Office/ViewModels/EditTools/HeaderFooter/HeaderFooterTemplateListContentViewModel.cs
  24. 1 0
      PDF Office/ViewModels/EditTools/Watermark/WatermarkCreateTextContentViewModel.cs
  25. 1 2
      PDF Office/ViewModels/EditTools/Watermark/WatermarkDocumentContentViewModel.cs
  26. 1 1
      PDF Office/Views/EditTools/Bates/BatesContent.xaml
  27. 49 24
      PDF Office/Views/EditTools/Bates/BatesCreateContent.xaml
  28. 27 1
      PDF Office/Views/EditTools/Bates/BatesCreateContent.xaml.cs
  29. 30 20
      PDF Office/Views/EditTools/Bates/BatesDocumentContent.xaml
  30. 10 1
      PDF Office/Views/EditTools/Bates/BatesDocumentContent.xaml.cs
  31. 105 1
      PDF Office/Views/EditTools/Bates/BatesTemplateListContent.xaml
  32. 71 1
      PDF Office/Views/EditTools/Bates/BatesTemplateListContent.xaml.cs
  33. 72 75
      PDF Office/Views/EditTools/HeaderFooter/HeaderFooterContent.xaml
  34. 45 24
      PDF Office/Views/EditTools/HeaderFooter/HeaderFooterCreateContent.xaml
  35. 34 1
      PDF Office/Views/EditTools/HeaderFooter/HeaderFooterCreateContent.xaml.cs
  36. 29 20
      PDF Office/Views/EditTools/HeaderFooter/HeaderFooterDocumentContent.xaml
  37. 10 1
      PDF Office/Views/EditTools/HeaderFooter/HeaderFooterDocumentContent.xaml.cs
  38. 106 2
      PDF Office/Views/EditTools/HeaderFooter/HeaderFooterTemplateListContent.xaml
  39. 73 1
      PDF Office/Views/EditTools/HeaderFooter/HeaderFooterTemplateListContent.xaml.cs
  40. 10 1
      PDF Office/Views/EditTools/Watermark/WatermarkDocumentContent.xaml
  41. 25 16
      PDFSettings/BatesHeaderFooterList.cs
  42. 1 1
      PDFSettings/PDFSettings.csproj

+ 12 - 6
PDF Office/App.config

@@ -18,12 +18,18 @@
   </runtime>
   <userSettings>
     <PDF_Office.Properties.Settings>
-        <setting name="BackgroundIndex" serializeAs="String">
-            <value>0</value>
-        </setting>
-        <setting name="WatermarkIndex" serializeAs="String">
-            <value>0</value>
-        </setting>
+      <setting name="BackgroundIndex" serializeAs="String">
+        <value>0</value>
+      </setting>
+      <setting name="WatermarkIndex" serializeAs="String">
+        <value>0</value>
+      </setting>
+      <setting name="BatesIndex" serializeAs="String">
+        <value>0</value>
+      </setting>
+      <setting name="HeaderFooterIndex" serializeAs="String">
+        <value>0</value>
+      </setting>
     </PDF_Office.Properties.Settings>
   </userSettings>
 </configuration>

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

@@ -38,7 +38,6 @@ using PDF_Office.Views.FillAndSign.PropertyPanel;
 using PDF_Office.Views.PropertyPanel.ViewModular;
 using PDF_Office.Views.Dialog.HomePageToolsDialogs.HomePageBatchProcessing;
 using PDF_Office.Views.Dialog.ConverterDialogs;
-using PDF_Office.Helper;
 using PDF_Office.Views.Dialog.HomePageToolsDialogs.HomePageBatchProcessing.HomePageConverter;
 using PDF_Office.Views.EditTools.Watermark; 
 using PDF_Office.Views.EditTools.Background;

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

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

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

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

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

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

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

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

+ 2 - 0
PDF Office/PDF Office.csproj

@@ -281,6 +281,8 @@
     <Compile Include="Model\Dialog\HomePageToolsDialogs\HomePageSplitDialogModel.cs" />
     <Compile Include="Model\EditTools\Background\BackgroundCreateModel.cs" />
     <Compile Include="Model\EditTools\Background\BackgroundTemplateListModel.cs" />
+    <Compile Include="Model\EditTools\Bates\BatesCreateModel.cs" />
+    <Compile Include="Model\EditTools\HeaderFooter\HeaderFooterCreateModel.cs" />
     <Compile Include="Model\EditTools\Watermark\WatermarkCreateModel.cs" />
     <Compile Include="Model\EditTools\Watermark\WatermarkTemplateListModel.cs" />
     <Compile Include="Model\PageEdit\CustomInsertModel.cs" />

+ 47 - 1
PDF Office/Properties/Settings.Designer.cs

@@ -12,7 +12,7 @@ namespace PDF_Office.Properties {
     
     
     [global::System.Runtime.CompilerServices.CompilerGeneratedAttribute()]
-    [global::System.CodeDom.Compiler.GeneratedCodeAttribute("Microsoft.VisualStudio.Editors.SettingsDesigner.SettingsSingleFileGenerator", "16.8.1.0")]
+    [global::System.CodeDom.Compiler.GeneratedCodeAttribute("Microsoft.VisualStudio.Editors.SettingsDesigner.SettingsSingleFileGenerator", "17.3.0.0")]
     internal sealed partial class Settings : global::System.Configuration.ApplicationSettingsBase {
         
         private static Settings defaultInstance = ((Settings)(global::System.Configuration.ApplicationSettingsBase.Synchronized(new Settings())));
@@ -123,5 +123,51 @@ namespace PDF_Office.Properties {
                 this["WatermarkIndex"] = value;
             }
         }
+        
+        [global::System.Configuration.UserScopedSettingAttribute()]
+        [global::System.Diagnostics.DebuggerNonUserCodeAttribute()]
+        public global::PDFSettings.BatesTemplateList BatesTemplateList {
+            get {
+                return ((global::PDFSettings.BatesTemplateList)(this["BatesTemplateList"]));
+            }
+            set {
+                this["BatesTemplateList"] = value;
+            }
+        }
+        
+        [global::System.Configuration.UserScopedSettingAttribute()]
+        [global::System.Diagnostics.DebuggerNonUserCodeAttribute()]
+        [global::System.Configuration.DefaultSettingValueAttribute("0")]
+        public int BatesIndex {
+            get {
+                return ((int)(this["BatesIndex"]));
+            }
+            set {
+                this["BatesIndex"] = value;
+            }
+        }
+        
+        [global::System.Configuration.UserScopedSettingAttribute()]
+        [global::System.Diagnostics.DebuggerNonUserCodeAttribute()]
+        public global::PDFSettings.HeaderFooterTemplateList HeaderFooterTemplateList {
+            get {
+                return ((global::PDFSettings.HeaderFooterTemplateList)(this["HeaderFooterTemplateList"]));
+            }
+            set {
+                this["HeaderFooterTemplateList"] = value;
+            }
+        }
+        
+        [global::System.Configuration.UserScopedSettingAttribute()]
+        [global::System.Diagnostics.DebuggerNonUserCodeAttribute()]
+        [global::System.Configuration.DefaultSettingValueAttribute("0")]
+        public int HeaderFooterIndex {
+            get {
+                return ((int)(this["HeaderFooterIndex"]));
+            }
+            set {
+                this["HeaderFooterIndex"] = value;
+            }
+        }
     }
 }

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

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

+ 67 - 0
PDF Office/Styles/RadioButtonStyle.xaml

@@ -259,4 +259,71 @@
             </Setter.Value>
         </Setter>
     </Style>
+
+    <Style x:Key="LocationRadioBtnStyle"  TargetType="{x:Type RadioButton}">
+        <Setter Property="Background" Value="{StaticResource RadioButton.Static.Background}" />
+        <Setter Property="BorderBrush" Value="{StaticResource RadioButton.Static.Border}" />
+        <Setter Property="Foreground" Value="{DynamicResource {x:Static SystemColors.ControlTextBrushKey}}" />
+        <Setter Property="BorderThickness" Value="0" />
+        <Setter Property="Width" Value="72" />
+        <Setter Property="Height" Value="80" />
+        <Setter Property="HorizontalContentAlignment" Value="Center" />
+        <Setter Property="VerticalContentAlignment" Value="Center" />
+        <Setter Property="Template">
+            <Setter.Value>
+                <ControlTemplate TargetType="{x:Type RadioButton}">
+                    <Grid
+                        x:Name="templateRoot"
+                        Background="Transparent"
+                        SnapsToDevicePixels="True">
+                        <Border
+                            x:Name="radioButtonBorder"
+                            HorizontalAlignment="{TemplateBinding HorizontalContentAlignment}"
+                            VerticalAlignment="{TemplateBinding VerticalContentAlignment}"
+                            Background="{TemplateBinding Background}"
+                            BorderBrush="{TemplateBinding BorderBrush}"
+                            BorderThickness="{TemplateBinding BorderThickness}">
+                            <Rectangle
+                                x:Name="optionMark"
+                                Width="{TemplateBinding Width}"
+                                Height="{TemplateBinding Height}"
+                                Opacity="0" />
+                        </Border>
+                        <ContentPresenter
+                            x:Name="contentPresenter"
+                            Margin="{TemplateBinding Padding}"
+                            HorizontalAlignment="{TemplateBinding HorizontalContentAlignment}"
+                            VerticalAlignment="{TemplateBinding VerticalContentAlignment}"
+                            Focusable="False"
+                            RecognizesAccessKey="True"
+                            SnapsToDevicePixels="{TemplateBinding SnapsToDevicePixels}" />
+                    </Grid>
+                    <ControlTemplate.Triggers>
+                        <Trigger Property="IsMouseOver" Value="true">
+                            <Setter TargetName="radioButtonBorder" Property="Background" Value="{StaticResource RadioButton.MouseOver.Background}" />
+                            <Setter TargetName="radioButtonBorder" Property="BorderBrush" Value="{StaticResource RadioButton.MouseOver.Border}" />
+                            <Setter TargetName="optionMark" Property="Fill" Value="{StaticResource RadioButton.MouseOver.Glyph}" />
+                        </Trigger>
+                        <Trigger Property="IsEnabled" Value="false">
+                            <Setter TargetName="radioButtonBorder" Property="Background" Value="{StaticResource RadioButton.Disabled.Background}" />
+                            <Setter TargetName="radioButtonBorder" Property="BorderBrush" Value="{StaticResource RadioButton.Disabled.Border}" />
+                            <Setter TargetName="optionMark" Property="Fill" Value="{StaticResource RadioButton.Disabled.Glyph}" />
+                        </Trigger>
+                        <Trigger Property="IsPressed" Value="true">
+                            <Setter TargetName="radioButtonBorder" Property="Background" Value="{StaticResource RadioButton.Pressed.Background}" />
+                            <Setter TargetName="radioButtonBorder" Property="BorderBrush" Value="{StaticResource RadioButton.Pressed.Border}" />
+                            <Setter TargetName="optionMark" Property="Fill" Value="{StaticResource RadioButton.Pressed.Glyph}" />
+                        </Trigger>
+                        <Trigger Property="IsChecked" Value="true">
+                            <Setter TargetName="optionMark" Property="Opacity" Value="1" />
+                            <Setter TargetName="optionMark" Property="Fill" Value="Black" />
+                        </Trigger>
+                        <Trigger Property="IsChecked" Value="{x:Null}">
+                            <Setter TargetName="optionMark" Property="Opacity" Value="0.56" />
+                        </Trigger>
+                    </ControlTemplate.Triggers>
+                </ControlTemplate>
+            </Setter.Value>
+        </Setter>
+    </Style>
 </ResourceDictionary>

+ 1 - 1
PDF Office/ViewModels/EditTools/Background/BackgroundCreateColorContentViewModel.cs

@@ -384,7 +384,7 @@ namespace PDF_Office.ViewModels.EditTools.Background
         {
             var backgroundItem = new BackgroundItem();
             ConvertInfoToItem(ref backgroundItem, BackgroundInfo);
-            backgroundItem.templateName += Settings.Default.WatermarkIndex.ToString();
+            backgroundItem.templateName += Settings.Default.BackgroundIndex.ToString();
             try
             {
                 //创建缓存文件夹

+ 1 - 1
PDF Office/ViewModels/EditTools/Background/BackgroundCreateFileContentViewModel.cs

@@ -434,7 +434,7 @@ namespace PDF_Office.ViewModels.EditTools.Background
         {
             var backgroundItem = new BackgroundItem();
             ConvertInfoToItem(ref backgroundItem, BackgroundInfo);
-            backgroundItem.templateName += Settings.Default.WatermarkIndex.ToString();
+            backgroundItem.templateName += Settings.Default.BackgroundIndex.ToString();
             try
             {
                 //创建缓存文件夹

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

@@ -261,7 +261,6 @@ namespace PDF_Office.ViewModels.EditTools.Background
         {
             navigationContext.Parameters.TryGetValue<CPDFViewer>(ParameterNames.PDFViewer, out pdfViewer);
             navigationContext.Parameters.TryGetValue<ViewContentViewModel>(ParameterNames.ViewContentViewModel, out viewContentViewModel);
-            navigationContext.Parameters.TryGetValue<string>("UniCode", out unicode);
             if (pdfViewer != null)
             {
                 if (!regionManager.Regions[ViewerRegionName].Views.Contains(PDFViewer))

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

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

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

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

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

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

+ 616 - 2
PDF Office/ViewModels/EditTools/Bates/BatesCreateContentViewModel.cs

@@ -10,6 +10,16 @@ using System.Collections.Generic;
 using System.Linq;
 using System.Windows;
 using PDFSettings;
+using PDF_Office.Model.EditTools.Watermark;
+using PDF_Office.Helper;
+using System.Windows.Media;
+using System.Diagnostics;
+using ComPDFKit.PDFDocument;
+using PDF_Office.Model.EditTools.Background;
+using PDF_Office.Model.EditTools.Bates;
+using PDF_Office.Model.EditTools.HeaderFooter;
+using PDF_Office.Properties;
+using System.IO;
 
 namespace PDF_Office.ViewModels.EditTools.Bates
 {
@@ -17,7 +27,9 @@ namespace PDF_Office.ViewModels.EditTools.Bates
     {
         private CPDFViewer PDFViewer;
 
-        public BatesHeaderFooterItem BatesItem;
+        public BatesInfo BatesInfo = new BatesInfo();
+
+        public BatesHeaderFooterItem TemplateBatesItem;
 
         public enum EnumCreateOrEdit
         {
@@ -26,6 +38,193 @@ namespace PDF_Office.ViewModels.EditTools.Bates
             StatusEdit
         }
 
+        private List<string> _fontNameList = new List<string>();
+        public List<string> FontNameList
+        {
+            get { return _fontNameList; }
+            set
+            {
+                SetProperty(ref _fontNameList, value);
+            }
+        }
+
+        private void InitFontNameList()
+        {
+            FontNameList.Clear();
+            FontNameList.Add("Courier");
+            FontNameList.Add("Courier-Bold");
+            FontNameList.Add("Courier-Oblique");
+            FontNameList.Add("Courier-BoldOblique");
+            FontNameList.Add("Helvetica");
+            FontNameList.Add("Helvetica-Bold");
+            FontNameList.Add("Helvetica-Oblique");
+            FontNameList.Add("Helvetica-BoldOblique");
+            FontNameList.Add("Times-Roman");
+            FontNameList.Add("Times-Bold");
+            FontNameList.Add("Times-Italic");
+            FontNameList.Add("Times-BoldItalic");
+        }
+
+        private int _fontNameSelectedIndex = 0;
+        public int FontNameSelectedIndex
+        {
+            get { return _fontNameSelectedIndex; }
+            set
+            {
+                SetProperty(ref _fontNameSelectedIndex, value);
+                SetFontName(FontNameSelectedIndex);
+                eventAggregator.GetEvent<SetBatesEvent>().Publish(new BatesInfoUnicode
+                {
+                    Unicode = Unicode,
+                    Status = BatesInfo
+                });
+
+            }
+        }
+
+        private List<string> _fontSizeList = new List<string>();
+        public List<string> FontSizeList
+        {
+            get { return _fontSizeList; }
+            set
+            {
+                SetProperty(ref _fontSizeList, value);
+            }
+        }
+
+        private void InitFontSizeList()
+        {
+            FontSizeList.Clear();
+            for (int temp = 10; temp <= 15; temp += 1)
+            {
+                FontSizeList.Add(temp.ToString() + "pt");
+            }
+        }
+
+        private int _fontSizeSelectedIndex = 0;
+        public int FontSizeSelectedIndex
+        {
+            get { return _fontSizeSelectedIndex; }
+            set
+            {
+                SetProperty(ref _fontSizeSelectedIndex, value);
+                SetFontSize(FontSizeSelectedIndex);
+                eventAggregator.GetEvent<SetBatesEvent>().Publish(new BatesInfoUnicode
+                {
+                    Unicode = Unicode,
+                    Status = BatesInfo
+                });
+            }
+        }
+
+        private List<string> _starPagetNumberList = new List<string>();
+        public List<string> StarPagetNumberList
+        {
+            get { return _starPagetNumberList; }
+            set
+            {
+                SetProperty(ref _starPagetNumberList, value);
+            }
+        }
+
+        private void InitStarPagetNumberList()
+        {
+            StarPagetNumberList.Clear();
+            for (int temp = 10; temp <= 15; temp += 1)
+            {
+                StarPagetNumberList.Add(temp.ToString());
+            }
+        }
+
+        private int _starPagetNumberIndex = 0;
+        public int StarPagetNumberIndex
+        {
+            get { return _starPagetNumberIndex; }
+            set
+            {
+                SetProperty(ref _starPagetNumberIndex, value);
+                SetStarPagetNumber(StarPagetNumberIndex);
+                eventAggregator.GetEvent<SetBatesEvent>().Publish(new BatesInfoUnicode
+                {
+                    Unicode = Unicode,
+                    Status = BatesInfo
+                });
+            }
+        }
+
+        public string _pageRangeText = "0";
+        public string PageRangeText
+        {
+            get { return _pageRangeText; }
+            set
+            {
+                _pageRangeText = value;
+                EditToolsHelper.GetPageRange(PageRangeSelectIndex, PDFViewer.Document, ref BatesInfo.PageRange, PageRangeText);
+                eventAggregator.GetEvent<SetBatesEvent>().Publish(new BatesInfoUnicode
+                {
+                    Unicode = Unicode,
+                    Status = BatesInfo
+                });
+            }
+        }
+
+        private int _pageRangeSelectIndex = 0;
+        public int PageRangeSelectIndex
+        {
+            get { return _pageRangeSelectIndex; }
+            set
+            {
+                SetProperty(ref _pageRangeSelectIndex, value);
+                BatesInfo.PageRangeIndex = PageRangeSelectIndex;
+                EditToolsHelper.GetPageRange(PageRangeSelectIndex, PDFViewer.Document, ref BatesInfo.PageRange, PageRangeText);
+                eventAggregator.GetEvent<SetBatesEvent>().Publish(new BatesInfoUnicode
+                {
+                    Unicode = Unicode,
+                    Status = BatesInfo
+                });
+            }
+        }
+
+        private SolidColorBrush _solidColorBrush = new SolidColorBrush(Color.FromArgb(0xFF, 0xFF, 0x00, 0x00));
+        public SolidColorBrush SolidColorBrush
+        {
+            get
+            {
+                return _solidColorBrush;
+            }
+            set
+            {
+
+                SetProperty(ref _solidColorBrush, value);
+
+            }
+        }
+
+        private Color _stringColor = Color.FromArgb(0xFF, 0xFF, 0x00, 0x00);
+        public Color StringColor
+        {
+            get
+            {
+                return _stringColor;
+            }
+            set
+            {
+                SetProperty(ref _stringColor, value);
+                SolidColorBrush = new SolidColorBrush(StringColor);
+                for (int i = 0; i <= 5; i++)
+                {
+                    BatesInfo.TextData[i].Color = EditToolsHelper.ConvertColor(value);
+                }
+                eventAggregator.GetEvent<SetBatesEvent>().Publish(new BatesInfoUnicode
+                {
+                    Unicode = Unicode,
+                    Status = BatesInfo
+                });
+
+            }
+        }
+
+
         private EnumCreateOrEdit _createOrEdit;
         public EnumCreateOrEdit CreateOrEdit
         {
@@ -60,11 +259,136 @@ namespace PDF_Office.ViewModels.EditTools.Bates
             set => SetProperty(ref _editBaseVisible, value);
         }
 
+        private string _marginTopValue = "3";
+        public string MarginTopValue
+        {
+            get { return _marginTopValue; }
+            set
+            {
+                SetProperty(ref _marginTopValue, value);
+                BatesInfo.margin[1] = float.Parse(MarginTopValue);
+                eventAggregator.GetEvent<SetBatesEvent>().Publish(new BatesInfoUnicode
+                {
+                    Unicode = Unicode,
+                    Status = BatesInfo
+                });
+            }
+        }
+
+        private string _marginDownValue = "3";
+        public string MarginDownValue
+        {
+            get { return _marginDownValue; }
+            set
+            {
+                SetProperty(ref _marginDownValue, value);
+                BatesInfo.margin[3] = float.Parse(MarginDownValue);
+                eventAggregator.GetEvent<SetBatesEvent>().Publish(new BatesInfoUnicode
+                {
+                    Unicode = Unicode,
+                    Status = BatesInfo
+                });
+            }
+        }
+
+        private string _marginLeftValue = "3";
+        public string MarginLeftValue
+        {
+            get { return _marginLeftValue; }
+            set
+            {
+                SetProperty(ref _marginLeftValue, value);
+                BatesInfo.margin[0] = float.Parse(MarginLeftValue);
+                eventAggregator.GetEvent<SetBatesEvent>().Publish(new BatesInfoUnicode
+                {
+                    Unicode = Unicode,
+                    Status = BatesInfo
+                });
+            }
+        }
+
+        private string _marginRightValue = "3";
+        public string MarginRightValue
+        {
+            get { return _marginRightValue; }
+            set
+            {
+                SetProperty(ref _marginRightValue, value);
+                BatesInfo.margin[2] = float.Parse(MarginRightValue);
+                eventAggregator.GetEvent<SetBatesEvent>().Publish(new BatesInfoUnicode
+                {
+                    Unicode = Unicode,
+                    Status = BatesInfo
+                });
+            }
+        }
+
+        private string _digitNumberValue = "1";
+        public string DigitNumberValue
+        {
+            get { return _digitNumberValue; }
+            set
+            {
+                SetProperty(ref _digitNumberValue, value);
+                BatesInfo.DigitNumber = int.Parse(DigitNumberValue);
+            }
+        }
+
+
+        private string _textValue = "";
+        public string TextValue
+        {
+            get { return _textValue; }
+            set
+            {
+                SetProperty(ref _textValue, value);
+            }
+        }
+
+
+        private string _prefixTextValue = "";
+        public string PrefixTextValue
+        {
+            get { return _prefixTextValue; }
+            set
+            {
+
+                _prefixTextValue = value;
+
+            }
+        }
+
+        private string _surfixTextValue = "";
+        public string SurfixTextValue
+        {
+            get { return _surfixTextValue; }
+            set
+            {
+                _surfixTextValue = value;
+            }
+        }
+
+        public int GetLocationIndex = 0;
+
+        private Dictionary<string, string> _getTextValueFromNumber = new Dictionary<string, string>();
+        public Dictionary<string, string> GetTextValueFromNumber
+        {
+            get { return _getTextValueFromNumber; }
+            set
+            {
+                _getTextValueFromNumber = value;
+            }
+        }
+
         public IEventAggregator eventAggregator;
 
+        public DelegateCommand<object> ChangeLocationCommand { get; set; }
         public DelegateCommand EnterTemplateListCommand { get; set; }
         public DelegateCommand SaveToTemplateListCommand { get; set; }
         public DelegateCommand SaveToCurrentTemplateListCommand { get; set; }
+        public DelegateCommand<object> SelectedColorChangedCommand { get; set; }
+        public DelegateCommand<object> TextValueChangedCommand { get; set; }
+        public DelegateCommand ADDBatesCommand { get; set; }
 
         public string Unicode = null;
 
@@ -72,8 +396,294 @@ namespace PDF_Office.ViewModels.EditTools.Bates
         {
             this.eventAggregator = eventAggregator;
             Unicode = App.mainWindowViewModel.SelectedItem.Unicode;
+            for (int i = 0; i <= 5; i++)
+            {
+                BatesInfo.TextData[i].Color = EditToolsHelper.ConvertColor(Color.FromArgb(0xFF, 0xFF, 0x00, 0x00));
+            }
+            InitList();
+            InitBatesInfo();
+            ChangeLocationCommand = new DelegateCommand<object>(ChangeLocation);
+            SelectedColorChangedCommand = new DelegateCommand<object>(ChangedColor);
+            EnterTemplateListCommand = new DelegateCommand(EnterTemplateList);
+            SaveToTemplateListCommand = new DelegateCommand(SaveToTemplateList);
+            SaveToCurrentTemplateListCommand = new DelegateCommand(SaveToCurrentTemplateList);
+            TextValueChangedCommand = new DelegateCommand<object>(TextValueChanged);
+            ADDBatesCommand = new DelegateCommand(ADDBates);
+        }
+
+        private void InitList()
+        {
+
+            InitFontNameList();
+            InitFontSizeList();
+            InitStarPagetNumberList();
+            InitLocationButtonMatrix();
+
+        }
+
+        private void InitLocationButtonMatrix()
+        {
+            GetTextValueFromNumber.Clear();
+            for (var temp = 0; temp <= 5; temp++)
+            {
+                GetTextValueFromNumber.Add(temp.ToString(), temp.ToString());
+            }
+        }
+
+        private void InitBatesInfo()
+        {
+            for (int i = 0; i <= 5; i++)
+            {
+                BatesInfo.TextData[i].text = GetTextValueFromNumber[i.ToString()];
+            }
+            BatesInfo.margin[0] = float.Parse(MarginTopValue);
+            BatesInfo.margin[1] = float.Parse(MarginRightValue);
+            BatesInfo.margin[2] = float.Parse(MarginDownValue);
+            BatesInfo.margin[3] = float.Parse(MarginLeftValue);
+            BatesInfo.Prefix = PrefixTextValue;
+            BatesInfo.Suffix = SurfixTextValue;
+            BatesInfo.DigitNumber = int.Parse(DigitNumberValue);
+            SetFontName(FontNameSelectedIndex);
+            SetFontSize(FontSizeSelectedIndex);
+            SetStarPagetNumber(StarPagetNumberIndex);
+            StringColor = Color.FromArgb(0xFF, 0xFF, 0x00, 0x00);
+        }
+
+        private void SetFontName(int Index)
+        {
+            for (int i = 0; i <= 5; i++) { BatesInfo.TextData[i].fontName = FontNameList[Index]; }
+        }
+
+        private void SetFontSize(int Index)
+        {
+            for (int i = 0; i <= 5; i++) { BatesInfo.TextData[i].fontSize = (Index + 7) * 1.33f; }
+        }
+
+        private void SetStarPagetNumber(int Index)
+        {
+            BatesInfo.StarPagetNumber = Index;
+        }
+
+
+        public void ChangeLocation(object e)
+        {
+            string args = e as string;
+            if (args != null)
+            {
+                GetLocationIndex = int.Parse(args);
+                TextValue = GetTextValueFromNumber[args];
+
+            }
+        }
+
+        private void ChangedColor(object obj)
+        {
+            if (obj != null)
+            {
+                var colorValue = (Color)obj;
+                if (colorValue != null)
+                {
+
+                    StringColor = colorValue;
+                }
+            }
+        }
+
+        public void EnterTemplateList()
+        {
+            this.eventAggregator.GetEvent<EnterTemplateListOrCreateEvent>().Publish(new EnumTemplateListOrCreateUnicode { Unicode = Unicode, Status = EnumTemplateListOrCreate.StatusTemplate });
+        }
+
+        public void SaveToTemplateList()
+        {
+            SaveCurrentTemplate();
+        }
+
+        public void SaveToCurrentTemplateList()
+        {
+            ConfirmEditBackgroundTemplateItem();
         }
 
+        private void TextValueChanged(object obj)
+        {
+            if (obj != null)
+            {
+                var textValue = obj as System.Windows.Controls.TextBox;
+                if (textValue != null)
+                {
+                    switch (textValue.Name)
+                    {
+                        case "TextValueTextBox":
+                            Trace.WriteLine("111 :" + GetLocationIndex.ToString() + "-ppppp_" + textValue.Text);
+                            GetTextValueFromNumber[GetLocationIndex.ToString()] = textValue.Text;
+                            BatesInfo.TextData[GetLocationIndex].text = GetTextValueFromNumber[GetLocationIndex.ToString()];
+                            break;
+                        case "PrefixTextValueTextBox":
+                            Trace.WriteLine("211 :" + textValue.Text);
+                            BatesInfo.Prefix = textValue.Text;
+
+                            break;
+                        case "SuffixTextValueTextBox":
+                            Trace.WriteLine("311 :" + textValue.Text);
+                            BatesInfo.Suffix = textValue.Text;
+                            break;
+                        default:
+                            break;
+                    }
+                    eventAggregator.GetEvent<SetBatesEvent>().Publish(new BatesInfoUnicode
+                    {
+                        Unicode = Unicode,
+                        Status = BatesInfo
+                    });
+
+                }
+            }
+        }
+
+        public void ADDBates()
+        {
+            if (PrefixTextValue == "" || SurfixTextValue == "")
+            {
+                if (SurfixTextValue == "" && PrefixTextValue == "")
+                {
+                    GetTextValueFromNumber[GetLocationIndex.ToString()] = GetTextValueFromNumber[GetLocationIndex.ToString()] + "<<" + "#" + DigitNumberValue + "#" + (StarPagetNumberIndex + 1).ToString() + ">>";
+                }
+                else if (SurfixTextValue == "")
+                {
+                    GetTextValueFromNumber[GetLocationIndex.ToString()] = GetTextValueFromNumber[GetLocationIndex.ToString()] + "<<" + "#" + DigitNumberValue + "#" + (StarPagetNumberIndex + 1).ToString() + "#" + PrefixTextValue + ">>";
+                }
+                else
+                {
+                    GetTextValueFromNumber[GetLocationIndex.ToString()] = GetTextValueFromNumber[GetLocationIndex.ToString()] + "<<" + "#" + DigitNumberValue + "#" + (StarPagetNumberIndex + 1).ToString() + "#" + "#" + SurfixTextValue + ">>";
+                }
+            }
+            else
+            {
+                GetTextValueFromNumber[GetLocationIndex.ToString()] = GetTextValueFromNumber[GetLocationIndex.ToString()] + "<<" + "#" + DigitNumberValue + "#" + (StarPagetNumberIndex + 1).ToString() + "#" + PrefixTextValue + "#" + SurfixTextValue + ">>";
+            }
+            BatesInfo.TextData[GetLocationIndex].text = GetTextValueFromNumber[GetLocationIndex.ToString()];
+        }
+
+        public void ConvertInfoToItem(ref BatesHeaderFooterItem batesItem, BatesInfo batesInfo)
+        {
+            batesItem.TextData = batesInfo.TextData;
+            batesItem.DigitNumber = batesInfo.DigitNumber;
+            batesItem.Prefix = batesInfo.Prefix;
+            batesItem.Suffix = batesInfo.Suffix;
+            batesItem.StarPagetNumber = batesInfo.StarPagetNumber;
+            batesItem.margin = batesInfo.margin;
+            batesItem.PageRange = batesInfo.PageRange;
+            batesItem.PageRangeIndex = batesInfo.PageRangeIndex;
+
+        }
+
+        public void ConvertItemToInfo(BatesHeaderFooterItem batesItem, ref BatesInfo batesInfo)
+        {
+            batesInfo.TextData = batesItem.TextData;
+            batesInfo.DigitNumber = batesItem.DigitNumber;
+            batesInfo.Prefix = batesItem.Prefix;
+            batesInfo.Suffix = batesItem.Suffix;
+            batesInfo.StarPagetNumber = batesItem.StarPagetNumber;
+            batesInfo.margin = batesItem.margin;
+            batesInfo.PageRange = batesItem.PageRange;
+            batesInfo.PageRangeIndex = batesItem.PageRangeIndex;
+
+        }
+
+        public void SaveCurrentTemplate()
+        {
+            var batesItem = new BatesHeaderFooterItem();
+            ConvertInfoToItem(ref batesItem, BatesInfo);
+            batesItem.ItemName += Settings.Default.WatermarkIndex.ToString();
+            try
+            {
+                //创建缓存文件夹
+                string folderPath = Path.Combine(App.CurrentPath, "Bates");
+                //有可能因为其他原因存在同名文件,导致创建文件夹失败,需要先删除同名文件
+                //保险措施(猜测)
+                if (File.Exists(folderPath))
+                {
+                    File.Delete(folderPath);
+                }
+
+                DirectoryInfo tempfolder = new DirectoryInfo(folderPath);
+                if (!tempfolder.Exists)
+                {
+                    tempfolder.Create();
+                }
+                //预览图缓存
+                string saveName = Guid.NewGuid().ToString();
+                string savePath = Path.Combine(folderPath, saveName);
+                Settings.Default.BatesTemplateList.Add(batesItem);
+                Settings.Default.Save();
+            }
+            catch
+            {
+
+            }
+
+            this.eventAggregator.GetEvent<EnterTemplateListOrCreateEvent>().Publish(new EnumTemplateListOrCreateUnicode
+            {
+                Unicode = Unicode,
+                Status = EnumTemplateListOrCreate.StatusTemplate
+            });
+        }
+
+        public void ConfirmEditBackgroundTemplateItem()
+        {
+
+            var batesItem = new BatesHeaderFooterItem();
+            ConvertInfoToItem(ref batesItem, BatesInfo);
+            try
+            {
+                //创建缓存文件夹
+                string folderPath = Path.Combine(App.CurrentPath, "Background");
+                //有可能因为其他原因存在同名文件,导致创建文件夹失败,需要先删除同名文件
+                //保险措施(猜测)
+                if (File.Exists(folderPath))
+                {
+                    File.Delete(folderPath);
+                }
+
+                DirectoryInfo tempfolder = new DirectoryInfo(folderPath);
+                if (!tempfolder.Exists)
+                {
+                    tempfolder.Create();
+                }
+                Settings.Default.BatesTemplateList[TemplateBatesItem.listIndex] = batesItem;
+                Settings.Default.Save();
+            }
+            catch
+            {
+
+            }
+            this.eventAggregator.GetEvent<EnterTemplateListOrCreateEvent>().Publish(new EnumTemplateListOrCreateUnicode
+            {
+                Unicode = Unicode,
+                Status = EnumTemplateListOrCreate.StatusTemplate
+            });
+
+        }
+
+        public void InitComponentBySelectedInfo()
+        {
+            ConvertItemToInfo(TemplateBatesItem, ref BatesInfo);
+            for (int i = 0; i <= 5; i++)
+            {
+                GetTextValueFromNumber[i.ToString()] = BatesInfo.TextData[i].text;
+            }
+            MarginTopValue = BatesInfo.margin[0].ToString();
+            MarginRightValue = BatesInfo.margin[1].ToString();
+            MarginDownValue = BatesInfo.margin[2].ToString();
+            MarginLeftValue = BatesInfo.margin[3].ToString();
+            PrefixTextValue = BatesInfo.Prefix;
+            SurfixTextValue = BatesInfo.Suffix;
+            DigitNumberValue = BatesInfo.DigitNumber.ToString();
+            FontNameSelectedIndex = FontNameList.IndexOf(BatesInfo.TextData[0].fontName);
+            FontSizeSelectedIndex = FontSizeList.IndexOf(BatesInfo.TextData[0].fontSize.ToString());
+            StarPagetNumberIndex = StarPagetNumberList.IndexOf(BatesInfo.StarPagetNumber.ToString());
+            StringColor = EditToolsHelper.ConvertColor(BatesInfo.TextData[0].Color);
+        }
         public bool IsNavigationTarget(NavigationContext navigationContext)
         {
             return true;
@@ -85,10 +695,14 @@ namespace PDF_Office.ViewModels.EditTools.Bates
 
         public void OnNavigatedTo(NavigationContext navigationContext)
         {
+
             navigationContext.Parameters.TryGetValue<CPDFViewer>(ParameterNames.PDFViewer, out PDFViewer);
-            if (navigationContext.Parameters.TryGetValue<BatesHeaderFooterItem>("BatesItem", out BatesItem))
+            EditToolsHelper.GetPageRange(PageRangeSelectIndex, PDFViewer.Document, ref BatesInfo.PageRange, PageRangeText);
+
+            if (navigationContext.Parameters.TryGetValue<BatesHeaderFooterItem>("BatesItem", out TemplateBatesItem))
             {
                 CreateOrEdit = EnumCreateOrEdit.StatusEdit;
+                InitComponentBySelectedInfo();
             }
             else
             {

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

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

+ 188 - 1
PDF Office/ViewModels/EditTools/Bates/BatesTemplateListContentViewModel.cs

@@ -1,19 +1,56 @@
 using PDF_Office.EventAggregators;
+using PDF_Office.Model.EditTools.Bates;
+using PDF_Office.Model.EditTools.Bates;
+using PDF_Office.Model.EditTools.HeaderFooter;
+using PDF_Office.Properties;
+using PDFSettings;
 using Prism.Commands;
 using Prism.Events;
 using Prism.Mvvm;
 using Prism.Regions;
 using System;
 using System.Collections.Generic;
+using System.Collections.ObjectModel;
 using System.Linq;
+using System.Windows;
+using System.Windows.Controls;
 
 namespace PDF_Office.ViewModels.EditTools.Bates
 {
     public class BatesTemplateListContentViewModel : BindableBase, INavigationAware
     {
 
-        public DelegateCommand EnterCreateCommand { get; set; }
+
         public IEventAggregator eventAggregator;
+        public BatesInfo BatesInfo = new BatesInfo();
+        public BatesHeaderFooterItem BatesItem = new BatesHeaderFooterItem();
+        public int TemplateIndex = 0;
+
+        private ObservableCollection<BatesHeaderFooterItem> batesModCollection = new ObservableCollection<BatesHeaderFooterItem>();
+        public ObservableCollection<BatesHeaderFooterItem> BatesModCollection
+        {
+            get { return batesModCollection; }
+            set
+            {
+                batesModCollection = value;
+                RaisePropertyChanged();
+            }
+        }
+
+        private Visibility _createTemplateVisible;
+        public Visibility CreateTemplateVisible
+        {
+            get { return _createTemplateVisible; }
+            set { SetProperty(ref _createTemplateVisible, value); }
+        }
+
+        public DelegateCommand AddTemplateCommand { get; set; }
+        public DelegateCommand<object> DeleteTemplateItemCommand { get; set; }
+        public DelegateCommand<object> EditTemplateItemCommand { get; set; }
+        public DelegateCommand DeleteAllTemplateItemCommand { get; set; }
+        public DelegateCommand<object> SelectTemplateItemCommand { get; set; }
+        public DelegateCommand EnterCreateCommand { get; set; }
+
         public string Unicode = null;
 
         public BatesTemplateListContentViewModel(IEventAggregator eventAggregator)
@@ -21,6 +58,20 @@ namespace PDF_Office.ViewModels.EditTools.Bates
             this.eventAggregator = eventAggregator;
             Unicode = App.mainWindowViewModel.SelectedItem.Unicode;
             EnterCreateCommand = new DelegateCommand(EnterCreate);
+            AddTemplateCommand = new DelegateCommand(AddTemplate);
+            EditTemplateItemCommand = new DelegateCommand<object>(RequestEditTemplateItem);
+            DeleteTemplateItemCommand = new DelegateCommand<object>(DeleteTemplateItem);
+            DeleteAllTemplateItemCommand = new DelegateCommand(DeleteAllTemplateItem);
+            SelectTemplateItemCommand = new DelegateCommand<object>(SelectTemplateItem);
+        }
+
+        private void InitBackgroundTemplateList()
+        {
+            if (Settings.Default.BatesTemplateList == null)
+            {
+                Settings.Default.BatesTemplateList = new BatesTemplateList();
+            }
+            GetBatesSource();
         }
 
         public void EnterCreate()
@@ -28,6 +79,141 @@ namespace PDF_Office.ViewModels.EditTools.Bates
             this.eventAggregator.GetEvent<EnterTemplateListOrCreateEvent>().Publish(new EnumTemplateListOrCreateUnicode { Unicode = Unicode, Status = EnumTemplateListOrCreate.StatusCreate });
         }
 
+        public void AddTemplate()
+        {
+            this.eventAggregator.GetEvent<EnterTemplateListOrCreateEvent>().Publish(new EnumTemplateListOrCreateUnicode
+            {
+                Unicode = Unicode,
+                Status = EnumTemplateListOrCreate.StatusCreate
+            });
+        }
+
+        public void SaveEditedBatesTemplateItem(BatesHeaderFooterItemUnicode BatesItemunicode)
+        {
+            BatesHeaderFooterItem batesItem = BatesItemunicode.Status;
+
+            Settings.Default.BatesTemplateList[TemplateIndex] = batesItem;
+            Settings.Default.Save();
+
+            GetBatesSource();
+        }
+
+        public void RequestEditTemplateItem(object e)
+        {
+            var control = e as Control;
+            if (control == null)
+            {
+                return;
+            }
+            var template = control.DataContext as BatesHeaderFooterItem;
+            if (template == null)
+            {
+                return;
+            }
+            TemplateIndex = Settings.Default.BatesTemplateList.IndexOf(template);
+            template.listIndex = TemplateIndex;
+            ConvertItemToInfo(template, ref BatesInfo);
+            this.eventAggregator.GetEvent<EditBatesHeaderFooterTemplateItemEvent>().Publish(new BatesHeaderFooterItemUnicode
+            {
+                Unicode = Unicode,
+                Type = "BatesType",
+                Status = template
+            });
+        }
+
+        public void DeleteTemplateItem(object e)
+        {
+            var btn = e as System.Windows.Controls.Button;
+            if (btn == null)
+            {
+                return;
+            }
+            BatesItem = btn.DataContext as BatesHeaderFooterItem;
+            if (BatesItem == null)
+            {
+                return;
+            }
+
+            Settings.Default.BatesTemplateList.Remove(BatesItem);
+            Settings.Default.Save();
+            BatesModCollection.Remove(BatesItem);
+            GetBatesSource();
+        }
+
+        public void DeleteAllTemplateItem()
+        {
+            while (Settings.Default.BatesTemplateList.Count != 0)
+            {
+                int temp = 0;
+                var template = Settings.Default.BatesTemplateList[temp];
+
+                Settings.Default.BatesTemplateList.Remove(template);
+                Settings.Default.Save();
+
+                BatesModCollection.Remove(template);
+
+            }
+            GetBatesSource();
+        }
+
+        public void SelectTemplateItem(object e)
+        {
+            var listBox = e as ListBox;
+            BatesHeaderFooterItem BatesItem = listBox.SelectedItem as BatesHeaderFooterItem;
+            SendTemplateItemToDocument(BatesItem);
+        }
+
+        public void SendTemplateItemToDocument(BatesHeaderFooterItem template)
+        {
+            if (template != null)
+            {
+                ConvertItemToInfo(template, ref BatesInfo);
+                eventAggregator.GetEvent<SetBatesEvent>().Publish(new BatesInfoUnicode
+                {
+                    Unicode = Unicode,
+                    Status = BatesInfo
+                });
+            }
+
+        }
+
+        private void GetBatesSource()
+        {
+            List<BatesHeaderFooterItem> batesModColorTemplateList = new List<BatesHeaderFooterItem>();
+            for (int temp = 0; temp < Settings.Default.BatesTemplateList.Count; temp++)
+            {
+
+                batesModColorTemplateList.Add(Settings.Default.BatesTemplateList[temp]);
+
+            }
+            BatesModCollection = new ObservableCollection<BatesHeaderFooterItem>(batesModColorTemplateList);
+            CheckTemplateListIsEmpty(batesModColorTemplateList);
+        }
+
+        public void ConvertItemToInfo(BatesHeaderFooterItem batesItem, ref BatesInfo batesInfo)
+        {
+            batesInfo.TextData = batesItem.TextData;
+            batesInfo.DigitNumber = batesItem.DigitNumber;
+            batesInfo.Prefix=batesItem.Prefix;
+            batesInfo.Suffix=batesItem.Suffix;
+            batesInfo.StarPagetNumber = batesItem.StarPagetNumber;
+            batesInfo.margin = batesItem.margin;
+            batesInfo.PageRange = batesItem.PageRange;
+            batesInfo.PageRangeIndex = batesItem.PageRangeIndex;
+
+        }
+        private void CheckTemplateListIsEmpty(List<BatesHeaderFooterItem> batesTemplateList)
+        {
+            if (batesTemplateList.Count() == 0)
+            {
+                CreateTemplateVisible = Visibility.Visible;
+            }
+            else
+            {
+                CreateTemplateVisible = Visibility.Collapsed;
+            }
+        }
+
         public bool IsNavigationTarget(NavigationContext navigationContext)
         {
             return true;
@@ -39,6 +225,7 @@ namespace PDF_Office.ViewModels.EditTools.Bates
 
         public void OnNavigatedTo(NavigationContext navigationContext)
         {
+            InitBackgroundTemplateList();
         }
     }
 }

+ 26 - 1
PDF Office/ViewModels/EditTools/HeaderFooter/HeaderFooterContentViewModel.cs

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

+ 641 - 4
PDF Office/ViewModels/EditTools/HeaderFooter/HeaderFooterCreateContentViewModel.cs

@@ -1,6 +1,14 @@
-using ComPDFKitViewer.PdfViewer;
+using ComPDFKit.PDFWatermark;
+using ComPDFKitViewer.PdfViewer;
+using Microsoft.Office.Interop.Word;
 using PDF_Office.EventAggregators;
+using PDF_Office.Helper;
 using PDF_Office.Model;
+using PDF_Office.Model.EditTools.Background;
+using PDF_Office.Model.EditTools.Bates;
+using PDF_Office.Model.EditTools.HeaderFooter;
+using PDF_Office.Model.EditTools.Watermark;
+using PDF_Office.Properties;
 using PDFSettings;
 using Prism.Commands;
 using Prism.Events;
@@ -8,8 +16,11 @@ using Prism.Mvvm;
 using Prism.Regions;
 using System;
 using System.Collections.Generic;
+using System.Diagnostics;
+using System.IO;
 using System.Linq;
 using System.Windows;
+using System.Windows.Media;
 
 namespace PDF_Office.ViewModels.EditTools.HeaderFooter
 {
@@ -18,7 +29,9 @@ namespace PDF_Office.ViewModels.EditTools.HeaderFooter
 
         private CPDFViewer PDFViewer;
 
-        public BatesHeaderFooterItem HeaderFooterItem;
+        public HeaderFooterInfo HeaderFooterInfo = new HeaderFooterInfo();
+
+        public BatesHeaderFooterItem TemplateHeaderFooterItem;
 
         public enum EnumCreateOrEdit
         {
@@ -27,6 +40,284 @@ namespace PDF_Office.ViewModels.EditTools.HeaderFooter
             StatusEdit
         }
 
+        private List<string> _fontNameList = new List<string>();
+        public List<string> FontNameList
+        {
+            get { return _fontNameList; }
+            set
+            {
+                SetProperty(ref _fontNameList, value);
+            }
+        }
+
+        private void InitFontNameList()
+        {
+            FontNameList.Clear();
+            FontNameList.Add("Courier");
+            FontNameList.Add("Courier-Bold");
+            FontNameList.Add("Courier-Oblique");
+            FontNameList.Add("Courier-BoldOblique");
+            FontNameList.Add("Helvetica");
+            FontNameList.Add("Helvetica-Bold");
+            FontNameList.Add("Helvetica-Oblique");
+            FontNameList.Add("Helvetica-BoldOblique");
+            FontNameList.Add("Times-Roman");
+            FontNameList.Add("Times-Bold");
+            FontNameList.Add("Times-Italic");
+            FontNameList.Add("Times-BoldItalic");
+        }
+
+        private int _fontNameSelectedIndex = 0;
+        public int FontNameSelectedIndex
+        {
+            get { return _fontNameSelectedIndex; }
+            set
+            {
+                SetProperty(ref _fontNameSelectedIndex, value);
+                SetFontName(FontNameSelectedIndex);
+                eventAggregator.GetEvent<SetHeaderFooterEvent>().Publish(new HeaderFooterInfoUnicode
+                {
+                    Unicode = Unicode,
+                    Status = HeaderFooterInfo
+                });
+            }
+        }
+
+        private List<string> _fontSizeList = new List<string>();
+        public List<string> FontSizeList
+        {
+            get { return _fontSizeList; }
+            set
+            {
+                SetProperty(ref _fontSizeList, value);
+            }
+        }
+
+        private void InitFontSizeList()
+        {
+            FontSizeList.Clear();
+            for (int temp = 10; temp <= 15; temp += 1)
+            {
+                FontSizeList.Add(temp.ToString() + "pt");
+            }
+        }
+
+        private int _fontSizeSelectedIndex = 0;
+        public int FontSizeSelectedIndex
+        {
+            get { return _fontSizeSelectedIndex; }
+            set
+            {
+                SetProperty(ref _fontSizeSelectedIndex, value);
+                SetFontSize(FontSizeSelectedIndex);
+                eventAggregator.GetEvent<SetHeaderFooterEvent>().Publish(new HeaderFooterInfoUnicode
+                {
+                    Unicode = Unicode,
+                    Status = HeaderFooterInfo
+                });
+            }
+        }
+
+        private List<string> _starPagetNumberList = new List<string>();
+        public List<string> StarPagetNumberList
+        {
+            get { return _starPagetNumberList; }
+            set
+            {
+                SetProperty(ref _starPagetNumberList, value);
+            }
+        }
+
+        private void InitStarPagetNumberList()
+        {
+            StarPagetNumberList.Clear();
+            for (int temp = 10; temp <= 15; temp += 1)
+            {
+                StarPagetNumberList.Add(temp.ToString());
+            }
+        }
+
+        private int _starPagetNumberIndex = 0;
+        public int StarPagetNumberIndex
+        {
+            get { return _starPagetNumberIndex; }
+            set
+            {
+                SetProperty(ref _starPagetNumberIndex, value);
+                SetStarPagetNumber(StarPagetNumberIndex);
+                eventAggregator.GetEvent<SetHeaderFooterEvent>().Publish(new HeaderFooterInfoUnicode
+                {
+                    Unicode = Unicode,
+                    Status = HeaderFooterInfo
+                });
+            }
+        }
+
+        private List<string> _pageNumberFormatList = new List<string>();
+        public List<string> PageNumberFormatList
+        {
+            get { return _pageNumberFormatList; }
+            set
+            {
+                SetProperty(ref _pageNumberFormatList, value);
+            }
+        }
+
+        private void InitPageNumberFormatList()
+        {
+            PageNumberFormatList.Clear();
+            PageNumberFormatList.Add("1");
+            PageNumberFormatList.Add("1 of n");
+            PageNumberFormatList.Add("1/n");
+            PageNumberFormatList.Add("Page 1");
+            PageNumberFormatList.Add("Page 1 of n");
+        }
+
+        private int _pageNumberFormatIndex = 0;
+        public int PageNumberFormatIndex
+        {
+            get { return _pageNumberFormatIndex; }
+            set
+            {
+                SetProperty(ref _pageNumberFormatIndex, value);
+                SetPageNumberFormat(PageNumberFormatIndex);
+                eventAggregator.GetEvent<SetHeaderFooterEvent>().Publish(new HeaderFooterInfoUnicode
+                {
+                    Unicode = Unicode,
+                    Status = HeaderFooterInfo
+                });
+            }
+        }
+
+        private List<string> _dateTimeFormatList = new List<string>();
+        public List<string> DateTimeFormatList
+        {
+            get { return _dateTimeFormatList; }
+            set
+            {
+                SetProperty(ref _dateTimeFormatList, value);
+                SetDateTimeFormat(DateTimeFormatIndex);
+                eventAggregator.GetEvent<SetHeaderFooterEvent>().Publish(new HeaderFooterInfoUnicode
+                {
+                    Unicode = Unicode,
+                    Status = HeaderFooterInfo
+                });
+            }
+        }
+
+        private void InitDateTimeFormatList()
+        {
+            DateTimeFormatList.Clear();
+            DateTimeFormatList.Add("m/d");
+            DateTimeFormatList.Add("m/d/yy");
+            DateTimeFormatList.Add("m/d/yyyy");
+            DateTimeFormatList.Add("mm/dd/yy");
+            DateTimeFormatList.Add("mm/dd/yyyy");
+            DateTimeFormatList.Add("d/m/yy");
+            DateTimeFormatList.Add("d/m/yyyy");
+            DateTimeFormatList.Add("dd/mm/yy");
+            DateTimeFormatList.Add("dd/mm/yyyy");
+            DateTimeFormatList.Add("mm/yy");
+            DateTimeFormatList.Add("mm/yyyy");
+            DateTimeFormatList.Add("m.d.yy");
+            DateTimeFormatList.Add("m.d.yyyy");
+            DateTimeFormatList.Add("mm.dd.yy");
+            DateTimeFormatList.Add("mm.dd.yyyy");
+            DateTimeFormatList.Add("mm.yy");
+            DateTimeFormatList.Add("mm.yyyy");
+            DateTimeFormatList.Add("d.m.yy");
+            DateTimeFormatList.Add("dd.mm.yy");
+            DateTimeFormatList.Add("dd.mm.yyyy");
+            DateTimeFormatList.Add("yy-mm-dd");
+            DateTimeFormatList.Add("yyyy-mm-dd");
+        }
+
+        private int _dateTimeFormatIndex = 0;
+        public int DateTimeFormatIndex
+        {
+            get { return _dateTimeFormatIndex; }
+            set
+            {
+                SetProperty(ref _dateTimeFormatIndex, value);
+                SetDateTimeFormat(DateTimeFormatIndex);
+                eventAggregator.GetEvent<SetHeaderFooterEvent>().Publish(new HeaderFooterInfoUnicode
+                {
+                    Unicode = Unicode,
+                    Status = HeaderFooterInfo
+                });
+            }
+        }
+
+        public string _pageRangeText = "0";
+        public string PageRangeText
+        {
+            get { return _pageRangeText; }
+            set
+            {
+                _pageRangeText = value;
+                EditToolsHelper.GetPageRange(PageRangeSelectIndex, PDFViewer.Document, ref HeaderFooterInfo.PageRange, PageRangeText);
+                eventAggregator.GetEvent<SetHeaderFooterEvent>().Publish(new HeaderFooterInfoUnicode
+                {
+                    Unicode = Unicode,
+                    Status = HeaderFooterInfo
+                });
+            }
+        }
+
+        private int _pageRangeSelectIndex = 0;
+        public int PageRangeSelectIndex
+        {
+            get { return _pageRangeSelectIndex; }
+            set
+            {
+                SetProperty(ref _pageRangeSelectIndex, value);
+                HeaderFooterInfo.PageRangeIndex = PageRangeSelectIndex;
+                EditToolsHelper.GetPageRange(PageRangeSelectIndex, PDFViewer.Document, ref HeaderFooterInfo.PageRange, PageRangeText);
+                eventAggregator.GetEvent<SetHeaderFooterEvent>().Publish(new HeaderFooterInfoUnicode
+                {
+                    Unicode = Unicode,
+                    Status = HeaderFooterInfo
+                });
+            }
+        }
+
+        private SolidColorBrush _solidColorBrush = new SolidColorBrush(Color.FromArgb(0xFF, 0xFF, 0x00, 0x00));
+        public SolidColorBrush SolidColorBrush
+        {
+            get
+            {
+                return _solidColorBrush;
+            }
+            set
+            {
+
+                SetProperty(ref _solidColorBrush, value);
+            }
+        }
+
+        private Color _stringColor = Color.FromArgb(0xFF, 0xFF, 0x00, 0x00);
+        public Color StringColor
+        {
+            get
+            {
+                return _stringColor;
+            }
+            set
+            {
+                SetProperty(ref _stringColor, value);
+                SolidColorBrush = new SolidColorBrush(StringColor);
+                for (int i = 0; i <= 5; i++)
+                {
+                    HeaderFooterInfo.TextData[i].Color = EditToolsHelper.ConvertColor(value);
+                }
+                eventAggregator.GetEvent<SetHeaderFooterEvent>().Publish(new HeaderFooterInfoUnicode
+                {
+                    Unicode = Unicode,
+                    Status = HeaderFooterInfo
+                });
+            }
+        }
+
         private EnumCreateOrEdit _createOrEdit;
         public EnumCreateOrEdit CreateOrEdit
         {
@@ -61,20 +352,209 @@ namespace PDF_Office.ViewModels.EditTools.HeaderFooter
             set => SetProperty(ref _editBaseVisible, value);
         }
 
+        private string _marginTopValue = "3";
+        public string MarginTopValue
+        {
+            get { return _marginTopValue; }
+            set
+            {
+                SetProperty(ref _marginTopValue, value);
+                HeaderFooterInfo.margin[1] = float.Parse(MarginTopValue);
+                eventAggregator.GetEvent<SetHeaderFooterEvent>().Publish(new HeaderFooterInfoUnicode
+                {
+                    Unicode = Unicode,
+                    Status = HeaderFooterInfo
+                });
+            }
+        }
+
+        private string _marginDownValue = "3";
+        public string MarginDownValue
+        {
+            get { return _marginDownValue; }
+            set
+            {
+                SetProperty(ref _marginDownValue, value);
+                HeaderFooterInfo.margin[3] = float.Parse(MarginDownValue);
+                eventAggregator.GetEvent<SetHeaderFooterEvent>().Publish(new HeaderFooterInfoUnicode
+                {
+                    Unicode = Unicode,
+                    Status = HeaderFooterInfo
+                });
+            }
+        }
+
+        private string _marginLeftValue = "3";
+        public string MarginLeftValue
+        {
+            get { return _marginLeftValue; }
+            set
+            {
+                SetProperty(ref _marginLeftValue, value);
+                HeaderFooterInfo.margin[0] = float.Parse(MarginLeftValue);
+                eventAggregator.GetEvent<SetHeaderFooterEvent>().Publish(new HeaderFooterInfoUnicode
+                {
+                    Unicode = Unicode,
+                    Status = HeaderFooterInfo
+                });
+            }
+        }
+
+        private string _marginRightValue = "3";
+        public string MarginRightValue
+        {
+            get { return _marginRightValue; }
+            set
+            {
+                SetProperty(ref _marginRightValue, value);
+                HeaderFooterInfo.margin[2] = float.Parse(MarginRightValue);
+                eventAggregator.GetEvent<SetHeaderFooterEvent>().Publish(new HeaderFooterInfoUnicode
+                {
+                    Unicode = Unicode,
+                    Status = HeaderFooterInfo
+                });
+            }
+        }
+
+        private string _textValue = "";
+        public string TextValue
+        {
+            get { return _textValue; }
+            set
+            {
+                SetProperty(ref _textValue, value);
+
+            }
+        }
+
+        public int GetLocationIndex = 0;
+
+        private Dictionary<string, string> _getTextValueFromNumber = new Dictionary<string, string>();
+        public Dictionary<string, string> GetTextValueFromNumber
+        {
+            get { return _getTextValueFromNumber; }
+            set
+            {
+                _getTextValueFromNumber = value;
+            }
+        }
+
         public IEventAggregator eventAggregator;
 
+        public DelegateCommand<object> ChangeLocationCommand { get; set; }
         public DelegateCommand EnterTemplateListCommand { get; set; }
         public DelegateCommand SaveToTemplateListCommand { get; set; }
         public DelegateCommand SaveToCurrentTemplateListCommand { get; set; }
-
+        public DelegateCommand<object> SelectedColorChangedCommand { get; set; }
+        public DelegateCommand<object> TextValueChangedCommand { get; set; }
+        public DelegateCommand ADDDateCommand { get; set; }
+        public DelegateCommand ADDPagesCommand { get; set; }
         public string Unicode = null;
         public HeaderFooterCreateContentViewModel(IEventAggregator eventAggregator)
         {
             this.eventAggregator = eventAggregator;
             Unicode = App.mainWindowViewModel.SelectedItem.Unicode;
+            for (int i = 0; i <= 5; i++)
+            {
+                HeaderFooterInfo.TextData[i].Color = EditToolsHelper.ConvertColor(Color.FromArgb(0xFF, 0xFF, 0x00, 0x00));
+            }
+            InitList();
+            InitHeaderFooterInfo();
+            ChangeLocationCommand = new DelegateCommand<object>(ChangeLocation);
+            SelectedColorChangedCommand = new DelegateCommand<object>(ChangedColor);
             EnterTemplateListCommand = new DelegateCommand(EnterTemplateList);
             SaveToTemplateListCommand = new DelegateCommand(SaveToTemplateList);
             SaveToCurrentTemplateListCommand = new DelegateCommand(SaveToCurrentTemplateList);
+            TextValueChangedCommand = new DelegateCommand<object>(TextValueChanged);
+            ADDDateCommand = new DelegateCommand(ADDDate);
+            ADDPagesCommand = new DelegateCommand(ADDPages);
+        }
+
+        private void InitList()
+        {
+
+            InitFontNameList();
+            InitFontSizeList();
+            InitStarPagetNumberList();
+            InitDateTimeFormatList();
+            InitPageNumberFormatList();
+            InitLocationButtonMatrix();
+
+        }
+
+        private void InitLocationButtonMatrix()
+        {
+            GetTextValueFromNumber.Clear();
+            for (var temp = 0; temp <= 5; temp++)
+            {
+                GetTextValueFromNumber.Add(temp.ToString(), "");
+            }
+        }
+
+        private void InitHeaderFooterInfo()
+        {
+            for (int i = 0; i <= 5; i++)
+            {
+                HeaderFooterInfo.TextData[i].text = GetTextValueFromNumber[i.ToString()];
+            }
+            HeaderFooterInfo.margin[0] = float.Parse(MarginTopValue);
+            HeaderFooterInfo.margin[1] = float.Parse(MarginRightValue);
+            HeaderFooterInfo.margin[2] = float.Parse(MarginDownValue);
+            HeaderFooterInfo.margin[3] = float.Parse(MarginLeftValue);
+            SetFontName(FontNameSelectedIndex);
+            SetFontSize(FontSizeSelectedIndex);
+            SetDateTimeFormat(DateTimeFormatIndex);
+            SetPageNumberFormat(PageNumberFormatIndex);
+            SetStarPagetNumber(StarPagetNumberIndex);
+            StringColor = Color.FromArgb(0xFF, 0xFF, 0x00, 0x00);
+        }
+
+        private void SetFontName(int Index)
+        {
+            for (int i = 0; i <= 5; i++) { HeaderFooterInfo.TextData[i].fontName = FontNameList[Index]; }
+        }
+
+        private void SetFontSize(int Index)
+        {
+            for (int i = 0; i <= 5; i++) { HeaderFooterInfo.TextData[i].fontSize = (Index + 7) * 1.33f; }
+        }
+
+        private void SetDateTimeFormat(int Index)
+        {
+            HeaderFooterInfo.DateTimeFormat = DateTimeFormatList[Index];
+        }
+
+        private void SetPageNumberFormat(int Index)
+        {
+            HeaderFooterInfo.PageNumberFormat = PageNumberFormatList[Index];
+        }
+
+        private void SetStarPagetNumber(int Index)
+        {
+            HeaderFooterInfo.StarPagetNumber = Index;
+        }
+
+        public void ChangeLocation(object e)
+        {
+            string args = e as string;
+            if (args != null)
+            {
+                GetLocationIndex = int.Parse(args);
+                TextValue = GetTextValueFromNumber[args];
+
+            }
+        }
+        private void ChangedColor(object obj)
+        {
+            if (obj != null)
+            {
+                var colorValue = (Color)obj;
+                if (colorValue != null)
+                {
+
+                    StringColor = colorValue;
+                }
+            }
         }
 
         public void EnterTemplateList()
@@ -84,14 +564,169 @@ namespace PDF_Office.ViewModels.EditTools.HeaderFooter
 
         public void SaveToTemplateList()
         {
+            SaveCurrentTemplate();
             this.eventAggregator.GetEvent<EnterTemplateListOrCreateEvent>().Publish(new EnumTemplateListOrCreateUnicode { Unicode = Unicode, Status = EnumTemplateListOrCreate.StatusTemplate });
         }
 
         public void SaveToCurrentTemplateList()
         {
+            ConfirmEditBackgroundTemplateItem();
             this.eventAggregator.GetEvent<EnterTemplateListOrCreateEvent>().Publish(new EnumTemplateListOrCreateUnicode { Unicode = Unicode, Status = EnumTemplateListOrCreate.StatusTemplate });
         }
 
+        private void TextValueChanged(object obj)
+        {
+            if (obj != null)
+            {
+                var textValue = obj as System.Windows.Controls.TextBox;
+                if (textValue != null)
+                {
+                    bool TextEQ=true;
+                    if (GetTextValueFromNumber[GetLocationIndex.ToString()] == textValue.Text) {
+                        TextEQ = false;
+                    }
+                    GetTextValueFromNumber[GetLocationIndex.ToString()] = textValue.Text;
+                    HeaderFooterInfo.TextData[GetLocationIndex].text = GetTextValueFromNumber[GetLocationIndex.ToString()];
+                    if (TextEQ)
+                    {
+                        eventAggregator.GetEvent<SetHeaderFooterEvent>().Publish(new HeaderFooterInfoUnicode
+                        {
+                            Unicode = Unicode,
+                            Status = HeaderFooterInfo
+                        });
+                    }
+                   
+                }
+            }
+
+        }
+
+        public void ADDDate() {
+            GetTextValueFromNumber[GetLocationIndex.ToString()] = GetTextValueFromNumber[GetLocationIndex.ToString()] + "<<"+DateTimeFormatList[DateTimeFormatIndex]+">>";
+            TextValue = GetTextValueFromNumber[GetLocationIndex.ToString()];
+        }
+        public void ADDPages() {
+            GetTextValueFromNumber[GetLocationIndex.ToString()] = GetTextValueFromNumber[GetLocationIndex.ToString()] + "<<" + PageNumberFormatList[PageNumberFormatIndex] + ">>";
+            TextValue = GetTextValueFromNumber[GetLocationIndex.ToString()];
+        }
+
+        public void ConvertInfoToItem(ref BatesHeaderFooterItem headerFooterItem, HeaderFooterInfo headerFooterInfo)
+        {
+           headerFooterItem.TextData = headerFooterInfo.TextData ;
+           headerFooterItem.DateTimeFormat =  headerFooterInfo.DateTimeFormat;
+           headerFooterItem.StarPagetNumber=  headerFooterInfo.StarPagetNumber ;
+           headerFooterItem.PageNumberFormat= headerFooterInfo.PageNumberFormat  ;
+           headerFooterItem.margin= headerFooterInfo.margin  ;
+           headerFooterItem.PageRange=  headerFooterInfo.PageRange ;
+           headerFooterItem.PageRangeIndex=  headerFooterInfo.PageRangeIndex ;
+        }
+
+        public void ConvertItemToInfo(BatesHeaderFooterItem headerFooterItem, ref HeaderFooterInfo headerFooterInfo)
+        {
+            headerFooterInfo.TextData = headerFooterItem.TextData;
+            headerFooterInfo.DateTimeFormat = headerFooterItem.DateTimeFormat;
+            headerFooterInfo.StarPagetNumber = headerFooterItem.StarPagetNumber;
+            headerFooterInfo.PageNumberFormat = headerFooterItem.PageNumberFormat;
+            headerFooterInfo.margin = headerFooterItem.margin;
+            headerFooterInfo.PageRange = headerFooterItem.PageRange;
+            headerFooterInfo.PageRangeIndex = headerFooterItem.PageRangeIndex;
+        }
+
+        public void SaveCurrentTemplate()
+        {
+            var headerFooterItem = new BatesHeaderFooterItem();
+            ConvertInfoToItem(ref headerFooterItem, HeaderFooterInfo);
+            headerFooterItem.ItemName += Settings.Default.HeaderFooterIndex.ToString();
+            try
+            {
+                //创建缓存文件夹
+                string folderPath = Path.Combine(App.CurrentPath, "HeaderFooter");
+                //有可能因为其他原因存在同名文件,导致创建文件夹失败,需要先删除同名文件
+                //保险措施(猜测)
+                if (File.Exists(folderPath))
+                {
+                    File.Delete(folderPath);
+                }
+
+                DirectoryInfo tempfolder = new DirectoryInfo(folderPath);
+                if (!tempfolder.Exists)
+                {
+                    tempfolder.Create();
+                }
+                //预览图缓存
+                string saveName = Guid.NewGuid().ToString();
+                string savePath = Path.Combine(folderPath, saveName);
+                Settings.Default.HeaderFooterTemplateList.Add(headerFooterItem);
+                Settings.Default.Save();
+            }
+            catch
+            {
+
+            }
+
+            this.eventAggregator.GetEvent<EnterTemplateListOrCreateEvent>().Publish(new EnumTemplateListOrCreateUnicode
+            {
+                Unicode = Unicode,
+                Status = EnumTemplateListOrCreate.StatusTemplate
+            });
+        }
+
+        public void ConfirmEditBackgroundTemplateItem()
+        {
+
+            var headerFooterItem = new BatesHeaderFooterItem();
+            ConvertInfoToItem(ref headerFooterItem, HeaderFooterInfo);
+            try
+            {
+                //创建缓存文件夹
+                string folderPath = Path.Combine(App.CurrentPath, "Background");
+                //有可能因为其他原因存在同名文件,导致创建文件夹失败,需要先删除同名文件
+                //保险措施(猜测)
+                if (File.Exists(folderPath))
+                {
+                    File.Delete(folderPath);
+                }
+
+                DirectoryInfo tempfolder = new DirectoryInfo(folderPath);
+                if (!tempfolder.Exists)
+                {
+                    tempfolder.Create();
+                }
+                Settings.Default.HeaderFooterTemplateList[TemplateHeaderFooterItem.listIndex] = headerFooterItem;
+                Settings.Default.Save();
+            }
+            catch
+            {
+
+            }
+            this.eventAggregator.GetEvent<EnterTemplateListOrCreateEvent>().Publish(new EnumTemplateListOrCreateUnicode
+            {
+                Unicode = Unicode,
+                Status = EnumTemplateListOrCreate.StatusTemplate
+            });
+
+        }
+
+        public void InitComponentBySelectedInfo()
+        {
+            ConvertItemToInfo(TemplateHeaderFooterItem, ref HeaderFooterInfo);
+            for (int i = 0; i <= 5; i++)
+            {
+                GetTextValueFromNumber[i.ToString()] = HeaderFooterInfo.TextData[i].text;
+            }
+            MarginTopValue = HeaderFooterInfo.margin[0].ToString();
+            MarginRightValue = HeaderFooterInfo.margin[1].ToString();
+            MarginDownValue = HeaderFooterInfo.margin[2].ToString();
+            MarginLeftValue = HeaderFooterInfo.margin[3].ToString();
+            DateTimeFormatIndex=DateTimeFormatList.IndexOf(HeaderFooterInfo.DateTimeFormat);
+            PageNumberFormatIndex=PageNumberFormatList.IndexOf(HeaderFooterInfo.PageNumberFormat);
+            FontNameSelectedIndex = FontNameList.IndexOf(HeaderFooterInfo.TextData[0].fontName);
+            FontSizeSelectedIndex = FontSizeList.IndexOf(HeaderFooterInfo.TextData[0].fontSize.ToString());
+            StarPagetNumberIndex = StarPagetNumberList.IndexOf(HeaderFooterInfo.StarPagetNumber.ToString());
+            StringColor = EditToolsHelper.ConvertColor(HeaderFooterInfo.TextData[0].Color);
+
+        }
+
         public bool IsNavigationTarget(NavigationContext navigationContext)
         {
             return true;
@@ -104,9 +739,11 @@ namespace PDF_Office.ViewModels.EditTools.HeaderFooter
         public void OnNavigatedTo(NavigationContext navigationContext)
         {
             navigationContext.Parameters.TryGetValue<CPDFViewer>(ParameterNames.PDFViewer, out PDFViewer);
-            if (navigationContext.Parameters.TryGetValue<BatesHeaderFooterItem>("HeaderFooterItem", out HeaderFooterItem))
+            EditToolsHelper.GetPageRange(PageRangeSelectIndex, PDFViewer.Document, ref HeaderFooterInfo.PageRange, PageRangeText);
+            if (navigationContext.Parameters.TryGetValue<BatesHeaderFooterItem>("HeaderFooterItem", out TemplateHeaderFooterItem))
             {
                 CreateOrEdit = EnumCreateOrEdit.StatusEdit;
+                InitComponentBySelectedInfo();
             }
             else
             {

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

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

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

@@ -1,17 +1,51 @@
 using PDF_Office.EventAggregators;
+using PDF_Office.Model.EditTools.Bates;
+using PDF_Office.Model.EditTools.HeaderFooter;
+using PDF_Office.Properties;
+using PDFSettings;
 using Prism.Commands;
 using Prism.Events;
 using Prism.Mvvm;
 using Prism.Regions;
 using System;
 using System.Collections.Generic;
+using System.Collections.ObjectModel;
 using System.Linq;
+using System.Windows;
+using System.Windows.Controls;
 
 namespace PDF_Office.ViewModels.EditTools.HeaderFooter
 {
     public class HeaderFooterTemplateListContentViewModel : BindableBase, INavigationAware
     {
         public IEventAggregator eventAggregator;
+        public HeaderFooterInfo HeaderFooterInfo = new HeaderFooterInfo();
+        public BatesHeaderFooterItem HeaderFooterItem = new BatesHeaderFooterItem();
+        public int TemplateIndex = 0;
+
+        private ObservableCollection<BatesHeaderFooterItem> headerFooterModCollection = new ObservableCollection<BatesHeaderFooterItem>();
+        public ObservableCollection<BatesHeaderFooterItem> HeaderFooterModCollection
+        {
+            get { return headerFooterModCollection; }
+            set
+            {
+                headerFooterModCollection = value;
+                RaisePropertyChanged();
+            }
+        }
+
+        private Visibility _createTemplateVisible;
+        public Visibility CreateTemplateVisible
+        {
+            get { return _createTemplateVisible; }
+            set { SetProperty(ref _createTemplateVisible, value); }
+        }
+
+        public DelegateCommand AddTemplateCommand { get; set; }
+        public DelegateCommand<object> DeleteTemplateItemCommand { get; set; }
+        public DelegateCommand<object> EditTemplateItemCommand { get; set; }
+        public DelegateCommand DeleteAllTemplateItemCommand { get; set; }
+        public DelegateCommand<object> SelectTemplateItemCommand { get; set; }
         public DelegateCommand EnterCreateCommand { get; set; }
 
         public string Unicode = null;
@@ -20,6 +54,20 @@ namespace PDF_Office.ViewModels.EditTools.HeaderFooter
             this.eventAggregator = eventAggregator;
             Unicode = App.mainWindowViewModel.SelectedItem.Unicode;
             EnterCreateCommand = new DelegateCommand(EnterCreate);
+            AddTemplateCommand = new DelegateCommand(AddTemplate);
+            EditTemplateItemCommand = new DelegateCommand<object>(RequestEditTemplateItem);
+            DeleteTemplateItemCommand = new DelegateCommand<object>(DeleteTemplateItem);
+            DeleteAllTemplateItemCommand = new DelegateCommand(DeleteAllTemplateItem);
+            SelectTemplateItemCommand = new DelegateCommand<object>(SelectTemplateItem);
+        }
+
+        private void InitBackgroundTemplateList()
+        {
+            if (Settings.Default.HeaderFooterTemplateList == null)
+            {
+                Settings.Default.HeaderFooterTemplateList = new HeaderFooterTemplateList();
+            }
+            GetHeaderFooterSource();
         }
 
         public void EnterCreate()
@@ -27,6 +75,139 @@ namespace PDF_Office.ViewModels.EditTools.HeaderFooter
             this.eventAggregator.GetEvent<EnterTemplateListOrCreateEvent>().Publish(new EnumTemplateListOrCreateUnicode { Unicode = Unicode, Status = EnumTemplateListOrCreate.StatusCreate });
         }
 
+        public void AddTemplate()
+        {
+            this.eventAggregator.GetEvent<EnterTemplateListOrCreateEvent>().Publish(new EnumTemplateListOrCreateUnicode
+            {
+                Unicode = Unicode,
+                Status = EnumTemplateListOrCreate.StatusCreate
+            });
+        }
+
+        public void SaveEditedBatesTemplateItem(BatesHeaderFooterItemUnicode HeaderFooterItemunicode)
+        {
+            BatesHeaderFooterItem headerFooterItem = HeaderFooterItemunicode.Status;
+
+            Settings.Default.HeaderFooterTemplateList[TemplateIndex] = headerFooterItem;
+            Settings.Default.Save();
+
+            GetHeaderFooterSource();
+        }
+
+        public void RequestEditTemplateItem(object e)
+        {
+            var control = e as Control;
+            if (control == null)
+            {
+                return;
+            }
+            var template = control.DataContext as BatesHeaderFooterItem;
+            if (template == null)
+            {
+                return;
+            }
+            TemplateIndex = Settings.Default.HeaderFooterTemplateList.IndexOf(template);
+            template.listIndex = TemplateIndex;
+            ConvertItemToInfo(template, ref HeaderFooterInfo);
+            this.eventAggregator.GetEvent<EditBatesHeaderFooterTemplateItemEvent>().Publish(new BatesHeaderFooterItemUnicode
+            {
+                Unicode = Unicode,
+                Type = "HeaderFooterType",
+                Status = template
+            });
+        }
+
+        public void DeleteTemplateItem(object e)
+        {
+            var btn = e as System.Windows.Controls.Button;
+            if (btn == null)
+            {
+                return;
+            }
+            HeaderFooterItem = btn.DataContext as BatesHeaderFooterItem;
+            if (HeaderFooterItem == null)
+            {
+                return;
+            }
+
+            Settings.Default.HeaderFooterTemplateList.Remove(HeaderFooterItem);
+            Settings.Default.Save();
+            HeaderFooterModCollection.Remove(HeaderFooterItem);
+            GetHeaderFooterSource();
+        }
+
+        public void DeleteAllTemplateItem()
+        {
+            while (Settings.Default.HeaderFooterTemplateList.Count != 0)
+            {
+                int temp = 0;
+                var template = Settings.Default.HeaderFooterTemplateList[temp];
+
+                Settings.Default.HeaderFooterTemplateList.Remove(template);
+                Settings.Default.Save();
+
+                HeaderFooterModCollection.Remove(template);
+
+            }
+            GetHeaderFooterSource();
+        }
+
+        public void SelectTemplateItem(object e)
+        {
+            var listBox = e as ListBox;
+            BatesHeaderFooterItem HeaderFooterItem = listBox.SelectedItem as BatesHeaderFooterItem;
+            SendTemplateItemToDocument(HeaderFooterItem);
+        }
+
+        public void SendTemplateItemToDocument(BatesHeaderFooterItem template)
+        {
+            if (template != null)
+            {
+                ConvertItemToInfo(template, ref HeaderFooterInfo);
+                eventAggregator.GetEvent<SetHeaderFooterEvent>().Publish(new HeaderFooterInfoUnicode
+                {
+                    Unicode = Unicode,
+                    Status = HeaderFooterInfo
+                });
+            }
+
+        }
+
+        private void GetHeaderFooterSource()
+        {
+            List<BatesHeaderFooterItem> headerFooterModColorTemplateList = new List<BatesHeaderFooterItem>();
+            for (int temp = 0; temp < Settings.Default.HeaderFooterTemplateList.Count; temp++)
+            {
+
+                headerFooterModColorTemplateList.Add(Settings.Default.HeaderFooterTemplateList[temp]);
+
+            }
+            HeaderFooterModCollection = new ObservableCollection<BatesHeaderFooterItem>(headerFooterModColorTemplateList);
+            CheckTemplateListIsEmpty(headerFooterModColorTemplateList);
+        }
+
+        public void ConvertItemToInfo(BatesHeaderFooterItem headerFooterItem, ref HeaderFooterInfo headerFooterInfo)
+        {
+            headerFooterInfo.TextData = headerFooterItem.TextData;
+            headerFooterInfo.DateTimeFormat = headerFooterItem.DateTimeFormat;
+            headerFooterInfo.StarPagetNumber = headerFooterItem.StarPagetNumber;
+            headerFooterInfo.PageNumberFormat = headerFooterItem.PageNumberFormat;
+            headerFooterInfo.margin = headerFooterItem.margin;
+            headerFooterInfo.PageRange = headerFooterItem.PageRange;
+            headerFooterInfo.PageRangeIndex = headerFooterItem.PageRangeIndex;
+        }
+        private void CheckTemplateListIsEmpty(List<BatesHeaderFooterItem> headerFooterTemplateList)
+        {
+            if (headerFooterTemplateList.Count() == 0)
+            {
+                CreateTemplateVisible = Visibility.Visible;
+            }
+            else
+            {
+                CreateTemplateVisible = Visibility.Collapsed;
+            }
+        }
+
         public bool IsNavigationTarget(NavigationContext navigationContext)
         {
             return true;
@@ -38,6 +219,7 @@ namespace PDF_Office.ViewModels.EditTools.HeaderFooter
 
         public void OnNavigatedTo(NavigationContext navigationContext)
         {
+            InitBackgroundTemplateList();
         }
     }
 }

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

@@ -738,6 +738,7 @@ namespace PDF_Office.ViewModels.EditTools.Watermark
         {
             ConvertItemToInfo(TemplateWatermarkItem, ref WatermarkInfo);
             TextValue = WatermarkInfo.Text;
+            StringColor = EditToolsHelper.ConvertColor(WatermarkInfo.TextColor);
             VertOffsetValue = WatermarkInfo.VertOffset.ToString();
             HorizOffsetValue = WatermarkInfo.HorizOffset.ToString();
             VerticalSpacingValue = WatermarkInfo.VerticalSpacing.ToString();

+ 1 - 2
PDF Office/ViewModels/EditTools/Watermark/WatermarkDocumentContentViewModel.cs

@@ -166,9 +166,8 @@ namespace PDF_Office.ViewModels.EditTools.Watermark
         {
             WatermarkInfo watermarkInfo = watermarkInfounicode.Status;
             this.watermarkInfo = watermarkInfo;
+            EnumDelete = EnumDelete.StatusCreate;
             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);
 
         }

+ 1 - 1
PDF Office/Views/EditTools/Bates/BatesContent.xaml

@@ -32,7 +32,7 @@
                             <TextBlock Text="添加Bates" VerticalAlignment="Center"></TextBlock>
                         </StackPanel>
                     </Button>
-                    <Button Style="{StaticResource InsideBarBtnStyle }" >
+                    <Button Style="{StaticResource InsideBarBtnStyle }" Command="{Binding DeleteBatesCommand}">
 
                         <StackPanel Orientation="Horizontal" Margin="12 0 12 0">
                             <StackPanel Margin="0,0,8,0">

+ 49 - 24
PDF Office/Views/EditTools/Bates/BatesCreateContent.xaml

@@ -11,13 +11,20 @@
              mc:Ignorable="d"
              d:DesignHeight="720"
              d:DesignWidth="260" >
+    <UserControl.Resources>
+        <ResourceDictionary >
+            <ResourceDictionary.MergedDictionaries>
+                <ResourceDictionary Source="../../../Styles/RadioButtonStyle.xaml"></ResourceDictionary>
+            </ResourceDictionary.MergedDictionaries>
+        </ResourceDictionary>
+    </UserControl.Resources>
     <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}">
+            <Button  Height="24" Width="98" 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>
@@ -56,8 +63,8 @@
                 <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>
+                        <ComboBox Width="154" Height="32"  ItemsSource="{Binding FontNameList}" SelectedIndex="{Binding FontNameSelectedIndex}"></ComboBox>
+                        <ComboBox Width="66" Height="32" Margin="8,0,0,0" ItemsSource="{Binding FontSizeList}" SelectedIndex="{Binding FontSizeSelectedIndex}"></ComboBox>
                     </StackPanel>
                     <CompositeControl:ColorContent x:Name="cusColor" Height="32" Width="66"  Margin="0,8,0,0"  HorizontalAlignment="Left">
                     </CompositeControl:ColorContent>
@@ -70,21 +77,21 @@
                         <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>
+                                <cus:NumericUpDown Width="66" Height="32" Margin="9,0,0,0" Text="{Binding MarginTopValue,Mode=TwoWay}"></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>
+                                <cus:NumericUpDown Width="66" Height="32" Margin="9,0,0,0"  Text="{Binding MarginLeftValue,Mode=TwoWay}"></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>
+                                <cus:NumericUpDown Width="66" Height="32" Margin="9,0,0,0"  Text="{Binding MarginDownValue,Mode=TwoWay}"></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>
+                                <cus:NumericUpDown Width="66" Height="32" Margin="9,0,0,0"  Text="{Binding MarginRightValue,Mode=TwoWay}"></cus:NumericUpDown>
                             </StackPanel>
                         </StackPanel>
                     </StackPanel>
@@ -94,20 +101,28 @@
                 <StackPanel>
                     <StackPanel>
                         <TextBlock Text="前缀" FontSize="12" Foreground="#666666" Height="20" Width="24" HorizontalAlignment="Left"></TextBlock>
-                        <TextBlock  Height="32"></TextBlock>
+                        <TextBox Name="PrefixTextValueTextBox" Height="32"><i:Interaction.Triggers>
+                            <i:EventTrigger EventName="TextChanged">
+                                    <i:InvokeCommandAction Command="{Binding TextValueChangedCommand}" CommandParameter="{Binding ElementName=PrefixTextValueTextBox}" />
+                            </i:EventTrigger>
+                        </i:Interaction.Triggers></TextBox>
                     </StackPanel>
                     <StackPanel Margin="0,8,0,0">
                         <TextBlock Text="后缀" FontSize="12" Foreground="#666666" Height="20" Width="24" HorizontalAlignment="Left"></TextBlock>
-                        <TextBlock  Height="32"></TextBlock>
+                        <TextBox Name="SuffixTextValueTextBox" Height="32"><i:Interaction.Triggers>
+                            <i:EventTrigger EventName="TextChanged">
+                                    <i:InvokeCommandAction Command="{Binding TextValueChangedCommand}" CommandParameter="{Binding ElementName=SuffixTextValueTextBox}" />
+                            </i:EventTrigger>
+                        </i:Interaction.Triggers></TextBox>
                     </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>
+                            <cus:NumericUpDown Height="32" Width="110" Text="{Binding DigitNumberValue,Mode=TwoWay}"></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>
+                            <ComboBox Height="32" Width="110" ItemsSource="{Binding StarPagetNumberList}" SelectedIndex="{Binding StarPagetNumberIndex}"></ComboBox>
                         </StackPanel>
                     </StackPanel>
                 </StackPanel>
@@ -116,36 +131,46 @@
                 <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">
+                        <Button Width="22" Height="22" Margin="146,0,0,0" Click="Button_Click" >
                             <TextBlock Text="+" FontSize="19" HorizontalAlignment="Center" VerticalAlignment="Center"  Block.TextAlignment="Center" ></TextBlock>
+                            <Button.ContextMenu>
+                                <ContextMenu Name="contextMenu">
+                                    <MenuItem Name="ADDPages" Header="插入Bates" Click="ADDBates_Click" >
+                                    </MenuItem>
+                                </ContextMenu>
+                            </Button.ContextMenu>
                         </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>
+                            <ColumnDefinition Width="76"></ColumnDefinition>
+                            <ColumnDefinition Width="76"></ColumnDefinition>
+                            <ColumnDefinition Width="76"></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>
+                        <RadioButton Grid.Column="0" Grid.Row="0" Tag="0" GroupName="TextLocation" Height="23" Width="76" BorderThickness="1" BorderBrush="Black" Style="{StaticResource LocationRadioBtnStyle}" Command="{Binding ChangeLocationCommand}"  CommandParameter="{Binding RelativeSource={RelativeSource Self}, Path=Tag}" ></RadioButton>
+                        <RadioButton Grid.Column="1" Grid.Row="0" Tag="1" GroupName="TextLocation" Height="23" Width="76" BorderThickness="1" BorderBrush="Black" Style="{StaticResource LocationRadioBtnStyle}" Command="{Binding ChangeLocationCommand}" CommandParameter="{Binding RelativeSource={RelativeSource Self}, Path=Tag}" ></RadioButton>
+                        <RadioButton Grid.Column="2" Grid.Row="0" Tag="2" GroupName="TextLocation" Height="23" Width="76" BorderThickness="1" BorderBrush="Black" Style="{StaticResource LocationRadioBtnStyle}" Command="{Binding ChangeLocationCommand}" CommandParameter="{Binding RelativeSource={RelativeSource Self}, Path=Tag}" ></RadioButton>
+                        <RadioButton Grid.Column="0" Grid.Row="1" Tag="3" GroupName="TextLocation" Height="23" Width="76" BorderThickness="1" BorderBrush="Black" Style="{StaticResource LocationRadioBtnStyle}" Command="{Binding ChangeLocationCommand}"  CommandParameter="{Binding RelativeSource={RelativeSource Self}, Path=Tag}"></RadioButton>
+                        <RadioButton Grid.Column="1" Grid.Row="1" Tag="4" GroupName="TextLocation" Height="23" Width="76" BorderThickness="1" BorderBrush="Black" Style="{StaticResource LocationRadioBtnStyle}" Command="{Binding ChangeLocationCommand}"  CommandParameter="{Binding RelativeSource={RelativeSource Self}, Path=Tag}"  ></RadioButton>
+                        <RadioButton Grid.Column="2" Grid.Row="1" Tag="5" GroupName="TextLocation" Height="23" Width="76" BorderThickness="1" BorderBrush="Black" Style="{StaticResource LocationRadioBtnStyle}" Command="{Binding ChangeLocationCommand}"  CommandParameter="{Binding RelativeSource={RelativeSource Self}, Path=Tag}"></RadioButton>
                     </Grid>
-                    <TextBox Name="TextValueTextBox" Height="72" Margin="0,8,0,0"  FontSize="14"  AcceptsReturn="True">
-
+                    <TextBox Name="TextValueTextBox" Height="72" Margin="0,8,0,0" Text="{Binding TextValue}"  Foreground="{Binding SolidColorBrush}" FontSize="14"  AcceptsReturn="True">
+                        <i:Interaction.Triggers>
+                            <i:EventTrigger EventName="TextChanged">
+                                <i:InvokeCommandAction Command="{Binding TextValueChangedCommand}" CommandParameter="{Binding ElementName=TextValueTextBox}" />
+                            </i:EventTrigger>
+                        </i:Interaction.Triggers>
                     </TextBox>
                 </StackPanel>
             </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>
+                    <cus:WritableComboBox Height="32" Margin="0,8,0,0" Text="{Binding PageRangeText,Mode=TwoWay}" SelectedIndex="{Binding PageRangeSelectIndex,Mode=TwoWay}"></cus:WritableComboBox>
                 </StackPanel>
             </Grid>
         </Grid>

+ 27 - 1
PDF Office/Views/EditTools/Bates/BatesCreateContent.xaml.cs

@@ -1,4 +1,7 @@
-using System.Windows.Controls;
+using PDF_Office.ViewModels.EditTools.Bates;
+using PDF_Office.ViewModels.EditTools.HeaderFooter;
+using System.Windows.Controls;
+using System.Windows.Media;
 
 namespace PDF_Office.Views.EditTools.Bates
 {
@@ -7,9 +10,32 @@ namespace PDF_Office.Views.EditTools.Bates
     /// </summary>
     public partial class BatesCreateContent : UserControl
     {
+        private BatesCreateContentViewModel viewModel;
         public BatesCreateContent()
         {
+            viewModel=this.DataContext as BatesCreateContentViewModel;
             InitializeComponent();
+            cusColor.SelectedColorHandler += cusColor_SelectedColor;
+        }
+
+        private void cusColor_SelectedColor(object sender, Color e)
+        {
+            var data = this.DataContext as BatesCreateContentViewModel;
+            if (data != null)
+            {
+                data.SelectedColorChangedCommand?.Execute(e);
+
+            }
+        }
+
+        private void ADDBates_Click(object sender, System.Windows.RoutedEventArgs e)
+        {
+            viewModel.ADDBatesCommand?.Execute();
+        }
+
+        private void Button_Click(object sender, System.Windows.RoutedEventArgs e)
+        {
+            contextMenu.IsOpen = true;
         }
     }
 }

+ 30 - 20
PDF Office/Views/EditTools/Bates/BatesDocumentContent.xaml

@@ -1,37 +1,47 @@
 <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/"             
+             xmlns:prism="http://prismlibrary.com/"      
+             
              prism:ViewModelLocator.AutoWireViewModel="True"
              xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
+             xmlns:i="http://schemas.microsoft.com/xaml/behaviors" 
               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">
+    <UserControl.Resources>
+        <Style TargetType="Button" x:Key="btn">
+            <Style.Triggers>
+                <Trigger Property="IsMouseOver" Value="True">
+                    <Setter Property="Background" Value="Transparent"></Setter>
+                </Trigger>
+            </Style.Triggers>
+        </Style>
+    </UserControl.Resources>
+    <Grid 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>
+        <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" Style="{StaticResource btn}">
+                        <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">
 
-                    </StackPanel>
-                </StackPanel>
-            </Grid>
+                    </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>

+ 10 - 1
PDF Office/Views/EditTools/Bates/BatesDocumentContent.xaml.cs

@@ -1,4 +1,5 @@
-using System.Windows.Controls;
+using PDF_Office.ViewModels.EditTools.Bates;
+using System.Windows.Controls;
 
 namespace PDF_Office.Views.EditTools.Bates
 {
@@ -11,5 +12,13 @@ namespace PDF_Office.Views.EditTools.Bates
         {
             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 BatesDocumentContentViewModel;
+                data.GoToPageCommand?.Execute(sender);
+            }
+        }
     }
 }

+ 105 - 1
PDF Office/Views/EditTools/Bates/BatesTemplateListContent.xaml

@@ -1,13 +1,29 @@
 <UserControl x:Class="PDF_Office.Views.EditTools.Bates.BatesTemplateListContent"
             xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
              xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
-             xmlns:prism="http://prismlibrary.com/"             
+             xmlns:prism="http://prismlibrary.com/"      
+             xmlns:data ="clr-namespace:PDFSettings;assembly=PDFSettings"
              prism:ViewModelLocator.AutoWireViewModel="True"
               xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
              xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006" 
              mc:Ignorable="d"
              d:DesignHeight="720"
              d:DesignWidth="260" >
+    <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>
         <Grid.RowDefinitions>
             <RowDefinition Height="40"></RowDefinition>
@@ -20,5 +36,93 @@
                 <Button  Height="20" Width="20" Margin="16,0,16,0" Command="{Binding EnterCreateCommand}"></Button>
             </StackPanel>
         </Grid>
+        <Grid Background="#F3F3F3" Grid.Row="1">
+            <ListBox
+                                Width="260" 
+                                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 BatesModCollection}"  
+            SelectionChanged="ListBox_SelectionChanged">
+
+                <ListBox.ItemContainerStyle>
+                    <Style TargetType="ListBoxItem">
+                        <Setter Property="Margin" Value="11"/>
+                        <Setter Property="Padding" Value="0 0 0 0"/>
+                        <Setter Property="Width" Value="238"/>
+                        <Setter Property="ContextMenu" Value="{StaticResource FlyoutMenu}"/>
+                        <Setter Property="Template" Value="{DynamicResource EditToolsItemControlTemplate}"/>
+                    </Style>
+                </ListBox.ItemContainerStyle>
+                <ListBox.ItemTemplate>
+                    <DataTemplate DataType="{x:Type data:BatesHeaderFooterItem}">
+                        <StackPanel Name="itemPanel" Loaded="itemPanel_Loaded">
+                            <Border BorderThickness="1" BorderBrush="#A0A2AE">
+                                <Grid  Width="238" HorizontalAlignment="Left">
+                                    <StackPanel >
+                                        <StackPanel Orientation="Horizontal" Margin="0,12,0,0">
+                                            <TextBlock Text="Bates名称" Height="22" Width="98" FontSize="14" FontWeight="Black"></TextBlock>
+                                            <TextBlock Name="TemplateIndexTextBox"  FontSize="14" ></TextBlock>
+                                        </StackPanel>
+                                        <StackPanel Orientation="Horizontal" Margin="0,8,0,0">
+                                            <TextBlock Text="左侧页眉:"  FontSize="14" Height="22" Width="70"></TextBlock>
+                                            <TextBlock Name="LeftHeaderTextBox"  FontSize="14" Margin="8,0,0,0" Width="149" Height="22" ></TextBlock>
+                                        </StackPanel>
+                                        <StackPanel Orientation="Horizontal" Margin="0,4,0,0">
+                                            <TextBlock Text="右侧页眉:"  FontSize="14" Height="22" Width="70"></TextBlock>
+                                            <TextBlock Name="RightHeaderTextBox"  FontSize="14" Margin="8,0,0,0" Width="149" Height="22"></TextBlock>
+                                        </StackPanel>
+                                        <StackPanel Orientation="Horizontal" Margin="0,4,0,0">
+                                            <TextBlock Text="中间页眉:"  FontSize="14" Height="22" Width="70"></TextBlock>
+                                            <TextBlock Name="CenterHeaderTextBox"  FontSize="14" Margin="8,0,0,0" Width="149" Height="22"></TextBlock>
+                                        </StackPanel>
+                                        <StackPanel Orientation="Horizontal" Margin="0,4,0,0">
+                                            <TextBlock Text="左侧页脚:"  FontSize="14" Height="22" Width="70"></TextBlock>
+                                            <TextBlock Name="LeftFooterTextBox"  FontSize="14" Margin="8,0,0,0" Width="149" Height="22"></TextBlock>
+                                        </StackPanel>
+                                        <StackPanel Orientation="Horizontal" Margin="0,4,0,0">
+                                            <TextBlock Text="右侧页脚:"  FontSize="14" Height="22" Width="70"></TextBlock>
+                                            <TextBlock Name="RightFooterTextBox"  FontSize="14" Margin="8,0,0,0" Width="149" Height="22"></TextBlock>
+                                        </StackPanel>
+                                        <StackPanel Orientation="Horizontal" Margin="0,4,0,0">
+                                            <TextBlock Text="中间页脚:"  FontSize="14" Height="22" Width="70"></TextBlock>
+                                            <TextBlock Name="CenterFooterTextBox"  FontSize="14" Margin="8,0,0,0" Width="149" Height="22"></TextBlock>
+                                        </StackPanel>
+                                        
+                                    </StackPanel>
+                                    <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="请先创建一个Bates模板" 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>
     </Grid>
 </UserControl>

+ 71 - 1
PDF Office/Views/EditTools/Bates/BatesTemplateListContent.xaml.cs

@@ -1,4 +1,12 @@
-using System.Windows.Controls;
+using PDF_Office.ViewModels.EditTools.Background;
+using PDF_Office.ViewModels.EditTools.Bates;
+using PDFSettings;
+using System.Diagnostics;
+using System.Windows;
+using System;
+using System.Windows.Controls;
+using System.Windows.Media.Imaging;
+using System.IO;
 
 namespace PDF_Office.Views.EditTools.Bates
 {
@@ -7,9 +15,71 @@ namespace PDF_Office.Views.EditTools.Bates
     /// </summary>
     public partial class BatesTemplateListContent : UserControl
     {
+        private BatesTemplateListContentViewModel viewModel;
         public BatesTemplateListContent()
         {
             InitializeComponent();
+            viewModel = this.DataContext as BatesTemplateListContentViewModel;
+        }
+        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 BatesHeaderFooterItem;
+                var TemplateIndex = panel.FindName("TemplateIndexTextBox") as TextBlock;
+                var LeftHeader = panel.FindName("LeftHeaderTextBox") as TextBlock;
+                var RightHeader = panel.FindName("RightHeaderTextBox") as TextBlock;
+                var CenterHeader = panel.FindName("CenterHeaderTextBox") as TextBlock;
+                var LeftFooter = panel.FindName("LeftFooterTextBox") as TextBlock;
+                var RightFooter = panel.FindName("RightFooterTextBox") as TextBlock;
+                var CenterFooter = panel.FindName("CenterFooterTextBox") as TextBlock;
+                if (data.TextData != null)
+                {
+                    TemplateIndex.Text = data.ItemName;
+                    LeftHeader.Text = data.TextData[0].text;
+                    RightHeader.Text = data.TextData[2].text;
+                    CenterHeader.Text = data.TextData[1].text;
+                    LeftFooter.Text = data.TextData[3].text;
+                    RightFooter.Text = data.TextData[5].text;
+                    CenterFooter.Text = data.TextData[4].text;
+                }
+            }
+            catch { }
         }
     }
 }
+

+ 72 - 75
PDF Office/Views/EditTools/HeaderFooter/HeaderFooterContent.xaml

@@ -1,78 +1,75 @@
 <UserControl x:Class="PDF_Office.Views.EditTools.HeaderFooter.HeaderFooterContent"
-             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="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" xmlns:headerfooter="clr-namespace:PDF_Office.ViewModels.EditTools.HeaderFooter" d:DataContext="{d:DesignInstance Type=headerfooter:HeaderFooterContentViewModel}"
-             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="添加页眉页脚" 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 HeaderFooterDocumentRegionName}" Visibility="{Binding HeaderFooterDocumentVisible}"></ContentControl>
-
-
-            </Grid>
-
-            <Grid Grid.Column="1" Background="#F3F3F3">
-                <ContentControl prism:RegionManager.RegionName="{Binding HeaderFooterSettingsRegionName}" Visibility="{Binding HeaderFooterSettingsVisible}"></ContentControl>
-            </Grid>
-        </Grid>
-    </Grid>
+             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="添加页眉页脚" VerticalAlignment="Center"></TextBlock>
+                        </StackPanel>
+                    </Button>
+                    <Button Style="{StaticResource InsideBarBtnStyle }" Command="{Binding DeleteHeaderFooterCommand}">
+                        <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 HeaderFooterDocumentRegionName}" Visibility="{Binding HeaderFooterDocumentVisible}"></ContentControl>
+            </Grid>
+
+            <Grid Grid.Column="1" Background="#F3F3F3">
+                <ContentControl prism:RegionManager.RegionName="{Binding HeaderFooterSettingsRegionName}" Visibility="{Binding HeaderFooterSettingsVisible}"></ContentControl>
+            </Grid>
+        </Grid>
+    </Grid>
 </UserControl>

+ 45 - 24
PDF Office/Views/EditTools/HeaderFooter/HeaderFooterCreateContent.xaml

@@ -11,13 +11,20 @@
              mc:Ignorable="d"
              d:DesignHeight="720"
              d:DesignWidth="260" >
+    <UserControl.Resources>
+        <ResourceDictionary >
+            <ResourceDictionary.MergedDictionaries>
+                <ResourceDictionary Source="../../../Styles/RadioButtonStyle.xaml"></ResourceDictionary>
+            </ResourceDictionary.MergedDictionaries>
+        </ResourceDictionary>
+    </UserControl.Resources>
     <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}">
+            <Button  Height="24" Width="124" 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>
@@ -56,8 +63,8 @@
                 <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>
+                        <ComboBox Width="154" Height="32" ItemsSource="{Binding FontNameList}" SelectedIndex="{Binding FontNameSelectedIndex}"></ComboBox>
+                        <ComboBox Width="66" Height="32" Margin="8,0,0,0" ItemsSource="{Binding FontSizeList}" SelectedIndex="{Binding FontSizeSelectedIndex}"></ComboBox>
                     </StackPanel>
                     <CompositeControl:ColorContent x:Name="cusColor" Height="32" Width="66"  Margin="0,8,0,0"  HorizontalAlignment="Left">
                     </CompositeControl:ColorContent>
@@ -70,21 +77,21 @@
                         <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>
+                                <cus:NumericUpDown Width="66" Height="32" Margin="9,0,0,0" Text="{Binding MarginTopValue,Mode=TwoWay}"></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>
+                                <cus:NumericUpDown Width="66" Height="32" Margin="9,0,0,0"  Text="{Binding MarginLeftValue,Mode=TwoWay}"></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>
+                                <cus:NumericUpDown Width="66" Height="32" Margin="9,0,0,0"  Text="{Binding MarginDownValue,Mode=TwoWay}"></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>
+                                <cus:NumericUpDown Width="66" Height="32" Margin="9,0,0,0"  Text="{Binding MarginRightValue,Mode=TwoWay}"></cus:NumericUpDown>
                             </StackPanel>
                         </StackPanel>
                     </StackPanel>
@@ -94,16 +101,16 @@
                 <StackPanel>
                     <StackPanel>
                         <TextBlock Text="日期" FontSize="12" Foreground="#666666" Height="20" Width="24" HorizontalAlignment="Left"></TextBlock>
-                        <ComboBox  Height="32"></ComboBox>
+                        <ComboBox  Height="32" ItemsSource="{Binding DateTimeFormatList}" SelectedIndex="{Binding DateTimeFormatIndex}"></ComboBox>
                     </StackPanel>
                     <StackPanel Orientation="Horizontal" Margin="0,8,0,0">
                         <StackPanel>
                             <TextBlock Text="页面" FontSize="12" Foreground="#666666" Height="20" Width="24" HorizontalAlignment="Left"></TextBlock>
-                            <ComboBox Height="32" Width="110"></ComboBox>
+                            <ComboBox Height="32" Width="110" ItemsSource="{Binding PageNumberFormatList}" SelectedIndex="{Binding PageNumberFormatIndex}"></ComboBox>
                         </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>
+                            <ComboBox Height="32" Width="110" ItemsSource="{Binding StarPagetNumberList}" SelectedIndex="{Binding StarPagetNumberIndex}"></ComboBox>
                         </StackPanel>
                     </StackPanel>
                 </StackPanel>
@@ -111,37 +118,51 @@
             <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="布局&amp;内容" FontSize="12" Foreground="#666666" Height="20" Width="60"></TextBlock>
+                        <Button Width="22" Height="22" Margin="146,0,0,0"  Click="Button_Click">
                             <TextBlock Text="+" FontSize="19" HorizontalAlignment="Center" VerticalAlignment="Center"  Block.TextAlignment="Center" ></TextBlock>
+                            <Button.ContextMenu>
+                                <ContextMenu Name="contextMenu">
+                                    <MenuItem Name="ADDPages" Header="插入页码"  Click="ADDPages_Click" >
+                                   
+                                    </MenuItem>
+                                    <MenuItem Name="ADDDate" Header="插入日期"  Click="ADDDate_Click">
+                                        
+                                    </MenuItem>
+                                </ContextMenu>
+                            </Button.ContextMenu>
                         </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>
+                            <ColumnDefinition Width="76"></ColumnDefinition>
+                            <ColumnDefinition Width="76"></ColumnDefinition>
+                            <ColumnDefinition Width="76"></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>
+                        <RadioButton Grid.Column="0" Grid.Row="0" Tag="0" GroupName="TextLocation" Height="23" Width="76" BorderThickness="1" BorderBrush="Black" Style="{StaticResource LocationRadioBtnStyle}" Command="{Binding ChangeLocationCommand}"  CommandParameter="{Binding RelativeSource={RelativeSource Self}, Path=Tag}" ></RadioButton>
+                        <RadioButton Grid.Column="1" Grid.Row="0" Tag="1" GroupName="TextLocation" Height="23" Width="76" BorderThickness="1" BorderBrush="Black" Style="{StaticResource LocationRadioBtnStyle}" Command="{Binding ChangeLocationCommand}" CommandParameter="{Binding RelativeSource={RelativeSource Self}, Path=Tag}" ></RadioButton>
+                        <RadioButton Grid.Column="2" Grid.Row="0" Tag="2" GroupName="TextLocation" Height="23" Width="76" BorderThickness="1" BorderBrush="Black" Style="{StaticResource LocationRadioBtnStyle}" Command="{Binding ChangeLocationCommand}" CommandParameter="{Binding RelativeSource={RelativeSource Self}, Path=Tag}" ></RadioButton>
+                        <RadioButton Grid.Column="0" Grid.Row="1" Tag="3" GroupName="TextLocation" Height="23" Width="76" BorderThickness="1" BorderBrush="Black" Style="{StaticResource LocationRadioBtnStyle}" Command="{Binding ChangeLocationCommand}"  CommandParameter="{Binding RelativeSource={RelativeSource Self}, Path=Tag}"></RadioButton>
+                        <RadioButton Grid.Column="1" Grid.Row="1" Tag="4" GroupName="TextLocation" Height="23" Width="76" BorderThickness="1" BorderBrush="Black" Style="{StaticResource LocationRadioBtnStyle}" Command="{Binding ChangeLocationCommand}"  CommandParameter="{Binding RelativeSource={RelativeSource Self}, Path=Tag}"  ></RadioButton>
+                        <RadioButton Grid.Column="2" Grid.Row="1" Tag="5" GroupName="TextLocation" Height="23" Width="76" BorderThickness="1" BorderBrush="Black" Style="{StaticResource LocationRadioBtnStyle}" Command="{Binding ChangeLocationCommand}"  CommandParameter="{Binding RelativeSource={RelativeSource Self}, Path=Tag}"></RadioButton>
                     </Grid>
-                    <TextBox Name="TextValueTextBox" Height="72" Margin="0,8,0,0"  FontSize="14"  AcceptsReturn="True">
-                       
+                    <TextBox Name="TextValueTextBox" Height="72" Margin="0,8,0,0" Text="{Binding TextValue}"  Foreground="{Binding SolidColorBrush}" FontSize="14"  AcceptsReturn="True">
+                        <i:Interaction.Triggers>
+                            <i:EventTrigger EventName="TextChanged">
+                                <i:InvokeCommandAction Command="{Binding TextValueChangedCommand}" CommandParameter="{Binding ElementName=TextValueTextBox}" />
+                            </i:EventTrigger>
+                        </i:Interaction.Triggers>
                     </TextBox>
                 </StackPanel>
             </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>
+                    <cus:WritableComboBox Height="32" Margin="0,8,0,0" Text="{Binding PageRangeText,Mode=TwoWay}" SelectedIndex="{Binding PageRangeSelectIndex,Mode=TwoWay}"></cus:WritableComboBox>
                 </StackPanel>
             </Grid>
         </Grid>

+ 34 - 1
PDF Office/Views/EditTools/HeaderFooter/HeaderFooterCreateContent.xaml.cs

@@ -1,4 +1,6 @@
-using System.Windows.Controls;
+using PDF_Office.ViewModels.EditTools.HeaderFooter;
+using System.Windows.Controls;
+using System.Windows.Media;
 
 namespace PDF_Office.Views.EditTools.HeaderFooter
 {
@@ -7,9 +9,40 @@ namespace PDF_Office.Views.EditTools.HeaderFooter
     /// </summary>
     public partial class HeaderFooterCreateContent : UserControl
     {
+
+        private HeaderFooterCreateContentViewModel viewModel;
+
         public HeaderFooterCreateContent()
         {
             InitializeComponent();
+            viewModel = this.DataContext as HeaderFooterCreateContentViewModel;
+            cusColor.SelectedColorHandler += cusColor_SelectedColor;
+        }
+
+        private void cusColor_SelectedColor(object sender, Color e)
+        {
+            var data = this.DataContext as HeaderFooterCreateContentViewModel;
+            if (data != null)
+            {
+                data.SelectedColorChangedCommand?.Execute(e);
+
+            }
+        }
+
+        private void ADDDate_Click(object sender, System.Windows.RoutedEventArgs e)
+        {
+            viewModel.ADDDateCommand?.Execute();
+        }
+
+        private void ADDPages_Click(object sender, System.Windows.RoutedEventArgs e)
+        {
+            viewModel.ADDPagesCommand?.Execute();
+        }
+
+        private void Button_Click(object sender, System.Windows.RoutedEventArgs e)
+        {
+            contextMenu.IsOpen = true;
+           
         }
     }
 }

+ 29 - 20
PDF Office/Views/EditTools/HeaderFooter/HeaderFooterDocumentContent.xaml

@@ -4,34 +4,43 @@
              xmlns:prism="http://prismlibrary.com/"             
              prism:ViewModelLocator.AutoWireViewModel="True"
              xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
+             xmlns:i="http://schemas.microsoft.com/xaml/behaviors" 
               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">
+    <UserControl.Resources>
+        <Style TargetType="Button" x:Key="btn">
+            <Style.Triggers>
+                <Trigger Property="IsMouseOver" Value="True">
+                    <Setter Property="Background" Value="Transparent"></Setter>
+                </Trigger>
+            </Style.Triggers>
+        </Style>
+    </UserControl.Resources>
+    <Grid 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 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" Style="{StaticResource btn}">
+                        <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>

+ 10 - 1
PDF Office/Views/EditTools/HeaderFooter/HeaderFooterDocumentContent.xaml.cs

@@ -1,4 +1,5 @@
-using System.Windows.Controls;
+using PDF_Office.ViewModels.EditTools.HeaderFooter;
+using System.Windows.Controls;
 
 namespace PDF_Office.Views.EditTools.HeaderFooter
 {
@@ -11,5 +12,13 @@ namespace PDF_Office.Views.EditTools.HeaderFooter
         {
             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 HeaderFooterDocumentContentViewModel;
+                data.GoToPageCommand?.Execute(sender);
+            }
+        }
     }
 }

+ 106 - 2
PDF Office/Views/EditTools/HeaderFooter/HeaderFooterTemplateListContent.xaml

@@ -1,24 +1,128 @@
 <UserControl x:Class="PDF_Office.Views.EditTools.HeaderFooter.HeaderFooterTemplateListContent"
             xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
              xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
-             xmlns:prism="http://prismlibrary.com/"             
+             xmlns:prism="http://prismlibrary.com/"            
+             xmlns:data ="clr-namespace:PDFSettings;assembly=PDFSettings"
              prism:ViewModelLocator.AutoWireViewModel="True"
               xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
              xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006" 
              mc:Ignorable="d"
              d:DesignHeight="720"
              d:DesignWidth="260" >
+    <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>
         <Grid.RowDefinitions>
             <RowDefinition Height="40"></RowDefinition>
             <RowDefinition></RowDefinition>
         </Grid.RowDefinitions>
         <Grid Grid.Row="0">
-            <TextBlock Width="43" Height="24" Text="Bates" FontSize="16" Margin="16,0,16,0" HorizontalAlignment="Left"></TextBlock>
+            <TextBlock Width="64" Height="24" Text="页眉页脚" FontSize="16" Margin="16,0,16,0" HorizontalAlignment="Left"></TextBlock>
             <StackPanel Orientation="Horizontal" HorizontalAlignment="Right">
                 <Button  Height="20" Width="20"></Button>
                 <Button  Height="20" Width="20" Margin="16,0,16,0" Command="{Binding EnterCreateCommand}"></Button>
             </StackPanel>
         </Grid>
+        <Grid Background="#F3F3F3" Grid.Row="1">
+            <ListBox
+                                Width="260" 
+                                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 HeaderFooterModCollection}"  
+            SelectionChanged="ListBox_SelectionChanged">
+
+                <ListBox.ItemContainerStyle>
+                    <Style TargetType="ListBoxItem">
+                        <Setter Property="Margin" Value="11,0,0,0"/>
+                        <Setter Property="Padding" Value="0 0 0 0"/>
+                        <Setter Property="Width" Value="238"/>
+                        <Setter Property="ContextMenu" Value="{StaticResource FlyoutMenu}"/>
+                        <Setter Property="Template" Value="{DynamicResource EditToolsItemControlTemplate}"/>
+                    </Style>
+                </ListBox.ItemContainerStyle>
+                <ListBox.ItemTemplate>
+                    <DataTemplate DataType="{x:Type data:BatesHeaderFooterItem}">
+                        <StackPanel Name="itemPanel" Loaded="itemPanel_Loaded">
+                            <Border BorderThickness="1" BorderBrush="#A0A2AE">
+                                <Grid  Width="238" HorizontalAlignment="Left">
+                                    <StackPanel >
+                                        <StackPanel Orientation="Horizontal" Margin="0,12,0,0">
+                                            <TextBlock Text="页眉页脚名称" Height="22" Width="98" FontSize="14" FontWeight="Black"></TextBlock>
+                                            <TextBlock Name="TemplateIndexTextBox"  FontSize="14" ></TextBlock>
+                                        </StackPanel>
+                                        <StackPanel Orientation="Horizontal" Margin="0,8,0,0">
+                                            <TextBlock Text="左侧页眉:"  FontSize="14" Height="22" Width="70"></TextBlock>
+                                            <TextBlock Name="LeftHeaderTextBox"  FontSize="14" Margin="8,0,0,0" Width="149" Height="22" ></TextBlock>
+                                        </StackPanel>
+                                        <StackPanel Orientation="Horizontal" Margin="0,4,0,0">
+                                            <TextBlock Text="右侧页眉:"  FontSize="14" Height="22" Width="70"></TextBlock>
+                                            <TextBlock Name="RightHeaderTextBox"  FontSize="14" Margin="8,0,0,0" Width="149" Height="22"></TextBlock>
+                                        </StackPanel>
+                                        <StackPanel Orientation="Horizontal" Margin="0,4,0,0">
+                                            <TextBlock Text="中间页眉:"  FontSize="14" Height="22" Width="70"></TextBlock>
+                                            <TextBlock Name="CenterHeaderTextBox"  FontSize="14" Margin="8,0,0,0" Width="149" Height="22"></TextBlock>
+                                        </StackPanel>
+                                        <StackPanel Orientation="Horizontal" Margin="0,4,0,0">
+                                            <TextBlock Text="左侧页脚:"  FontSize="14" Height="22" Width="70"></TextBlock>
+                                            <TextBlock Name="LeftFooterTextBox"  FontSize="14" Margin="8,0,0,0" Width="149" Height="22"></TextBlock>
+                                        </StackPanel>
+                                        <StackPanel Orientation="Horizontal" Margin="0,4,0,0">
+                                            <TextBlock Text="右侧页脚:"  FontSize="14" Height="22" Width="70"></TextBlock>
+                                            <TextBlock Name="RightFooterTextBox"  FontSize="14" Margin="8,0,0,0" Width="149" Height="22"></TextBlock>
+                                        </StackPanel>
+                                        <StackPanel Orientation="Horizontal" Margin="0,4,0,0">
+                                            <TextBlock Text="中间页脚:"  FontSize="14" Height="22" Width="70"></TextBlock>
+                                            <TextBlock Name="CenterFooterTextBox"  FontSize="14" Margin="8,0,0,0" Width="149" Height="22"></TextBlock>
+                                        </StackPanel>
+
+                                    </StackPanel>
+                                    <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>
     </Grid>
 </UserControl>

+ 73 - 1
PDF Office/Views/EditTools/HeaderFooter/HeaderFooterTemplateListContent.xaml.cs

@@ -1,4 +1,12 @@
-using System.Windows.Controls;
+using PDF_Office.ViewModels.EditTools.Bates;
+using PDF_Office.ViewModels.EditTools.HeaderFooter;
+using PDFSettings;
+using System.Diagnostics;
+using System.Windows;
+using System;
+using System.Windows.Controls;
+using System.Windows.Media.Imaging;
+using System.IO;
 
 namespace PDF_Office.Views.EditTools.HeaderFooter
 {
@@ -7,9 +15,73 @@ namespace PDF_Office.Views.EditTools.HeaderFooter
     /// </summary>
     public partial class HeaderFooterTemplateListContent : UserControl
     {
+        private HeaderFooterTemplateListContentViewModel viewModel;
+
         public HeaderFooterTemplateListContent()
         {
             InitializeComponent();
+            viewModel = this.DataContext as HeaderFooterTemplateListContentViewModel;
+
+        }
+        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 BatesHeaderFooterItem;
+                var TemplateIndex = panel.FindName("TemplateIndexTextBox") as TextBlock;
+                var LeftHeader = panel.FindName("LeftHeaderTextBox") as TextBlock;
+                var RightHeader = panel.FindName("RightHeaderTextBox") as TextBlock;
+                var CenterHeader = panel.FindName("CenterHeaderTextBox") as TextBlock;
+                var LeftFooter = panel.FindName("LeftFooterTextBox") as TextBlock;
+                var RightFooter = panel.FindName("RightFooterTextBox") as TextBlock;
+                var CenterFooter = panel.FindName("CenterFooterTextBox") as TextBlock;
+                if (data.TextData != null)
+                {
+                    TemplateIndex.Text = data.ItemName;
+                    LeftHeader.Text = data.TextData[0].text;
+                    RightHeader.Text = data.TextData[2].text;
+                    CenterHeader.Text = data.TextData[1].text;
+                    LeftFooter.Text = data.TextData[3].text;
+                    RightFooter.Text = data.TextData[5].text;
+                    CenterFooter.Text = data.TextData[4].text;
+                }
+            }
+            catch { }
         }
     }
 }
+

+ 10 - 1
PDF Office/Views/EditTools/Watermark/WatermarkDocumentContent.xaml

@@ -9,6 +9,15 @@
              mc:Ignorable="d"
              d:DesignHeight="720"
              d:DesignWidth="1020" >
+    <UserControl.Resources>
+        <Style TargetType="Button" x:Key="btn">
+            <Style.Triggers>
+                <Trigger Property="IsMouseOver" Value="True">
+                    <Setter Property="Background" Value="Transparent"></Setter>
+                </Trigger>
+            </Style.Triggers>
+        </Style>
+    </UserControl.Resources>
     <Grid Background="SkyBlue">
         <ContentControl
                 x:Name="PDFViewerContent"
@@ -17,7 +26,7 @@
         <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">
+                    <Button  Name="ShowInputIndexBoxBtn" Background="Transparent" BorderThickness="0" Padding="0" Style="{StaticResource btn}">
                         <Label  Content="{Binding CurrentPageIndex, Mode=TwoWay}" Foreground="White" FontSize="20"></Label>
                         <i:Interaction.Triggers>
                             <i:EventTrigger EventName="MouseDoubleClick">

+ 25 - 16
PDFSettings/BatesHeaderFooterList.cs

@@ -7,12 +7,12 @@ using ComPDFKit.Import;
 
 namespace PDFSettings
 {
-    public class HeaderFooterList : List<BatesHeaderFooterItem>
+    public class HeaderFooterTemplateList: List<BatesHeaderFooterItem>
     {
 
     }
 
-    public class BatesList : List<BatesHeaderFooterItem>
+    public class BatesTemplateList : List<BatesHeaderFooterItem>
     {
 
     }
@@ -22,33 +22,35 @@ namespace PDFSettings
         /// <summary>
         /// 模板名称
         /// </summary>
-        public string FileName { get; set; } = "";
+        public string ItemName  = "";
         /// <summary>
         /// 内容
         /// </summary>
-        public contentItem[] TextData { get; set; }
+        public contentItem[] TextData = null;
         /// <summary>
         /// 间距
         /// </summary>
-        public float[] margin { get; set; }
+        /// 
+        public float[] margin = null;
         /// <summary>
         /// 页面范围
         /// </summary>
-        public string PageRange { get; set; } = "0";
+        public string PageRange  = "0";
+
         /// <summary>
         /// 起始页
         /// </summary>
-        public int StarPagetNumber { get; set; } = 1;
+        public int StarPagetNumber  = 1;
 
         /// <summary>
         /// 贝茨码:前缀
         /// </summary>
-        public string Prefix { get; set; } = "";
+        public string Prefix  = "";
 
         /// <summary>
         /// 贝茨码:后缀
         /// </summary>
-        public string Suffix { get; set; } = "";
+        public string Suffix = "";
         ///// <summary>
         ///// 贝茨码:起始页
         ///// </summary>
@@ -56,28 +58,35 @@ namespace PDFSettings
         /// <summary>
         /// 贝茨码:位数
         /// </summary>
-        public int DigitNumber { get; set; } = 1;
+        public int DigitNumber = 1;
         /// <summary>
         /// 页眉页脚:页码格式
         /// </summary>
-        public string PageNumberFormat { get; set; } = "1";
+        public string PageNumberFormat  = "1";
         /// <summary>
         /// 页眉页脚:日期格式
         /// </summary>
-        public string DateTimeFormat { get; set; } = "m/d";
+        public string DateTimeFormat  = "m/d";
 
         /// <summary>
-        /// 页面范围:显示标记
+        /// 页面范围索引;
+        /// 0:全部页面
+        /// 1:奇数页
+        /// 2;偶数页
+        /// 3:自定义页
         /// </summary>
-        public string PageRangeTag { get; set; } = "All";
+        public int PageRangeIndex = 0;
+
+        public int listIndex = 0;
     }
 
     public struct contentItem
     {
-        public string text { get; set; }
-        public BateHeaderFooter_ContentType textTag { get; set; }
+        public BateHeaderFooter_ContentType textTag;
+        public string text;
         public string fontName;
         public float fontSize;
+        public byte[] Color;
         public float fontColorR;
         public float fontColorG;
         public float fontColorB;

+ 1 - 1
PDFSettings/PDFSettings.csproj

@@ -55,7 +55,7 @@
   </ItemGroup>
   <ItemGroup>
     <Compile Include="APPSettingProperties.cs" />
-    <Compile Include="BatesHeaderFooterList.cs" />
+    <Compile Include="BatesHeaderFooterTemplateList.cs" />
     <Compile Include="CustomStampList.cs" />
     <Compile Include="DefaultAnnotProperty.cs" />
     <Compile Include="DialogCounter.cs" />