liyijie vor 2 Jahren
Ursprung
Commit
068532123c
43 geänderte Dateien mit 1959 neuen und 443 gelöschten Zeilen
  1. 12 0
      PDF Office/App.xaml.cs
  2. 11 0
      PDF Office/EventAggregators/EditToolsEvent.cs
  3. 64 0
      PDF Office/PDF Office.csproj
  4. 0 5
      PDF Office/ViewModels/EditTools/Background/BackgroundContentViewModel.cs
  5. 0 6
      PDF Office/ViewModels/EditTools/Background/BackgroundCreateColorContentViewModel.cs
  6. 0 1
      PDF Office/ViewModels/EditTools/Background/BackgroundCreateFileContentViewModel.cs
  7. 198 198
      PDF Office/ViewModels/EditTools/Background/BackgroundDocumentContentViewModel.cs
  8. 129 129
      PDF Office/ViewModels/EditTools/Background/BackgroundTemplateListBaseContentViewModel.cs
  9. 145 0
      PDF Office/ViewModels/EditTools/Bates/BatesContentViewModel.cs
  10. 35 0
      PDF Office/ViewModels/EditTools/Bates/BatesCreateContentViewModel.cs
  11. 35 0
      PDF Office/ViewModels/EditTools/Bates/BatesDocumentContentViewModel.cs
  12. 44 0
      PDF Office/ViewModels/EditTools/Bates/BatesTemplateListContentViewModel.cs
  13. 147 0
      PDF Office/ViewModels/EditTools/HeaderFooter/HeaderFooterContentViewModel.cs
  14. 33 0
      PDF Office/ViewModels/EditTools/HeaderFooter/HeaderFooterCreateContentViewModel.cs
  15. 33 0
      PDF Office/ViewModels/EditTools/HeaderFooter/HeaderFooterDocumentContentViewModel.cs
  16. 43 0
      PDF Office/ViewModels/EditTools/HeaderFooter/HeaderFooterTemplateListContentViewModel.cs
  17. 131 4
      PDF Office/ViewModels/EditTools/Watermark/WatermarkCreateFileContentViewModel.cs
  18. 131 5
      PDF Office/ViewModels/EditTools/Watermark/WatermarkCreateTextContentViewModel.cs
  19. 6 72
      PDF Office/ViewModels/EditTools/Watermark/WatermarkTemplateListFileContentViewModel.cs
  20. 6 4
      PDF Office/ViewModels/EditTools/Watermark/WatermarkTemplateListTextContentViewModel.cs
  21. 2 0
      PDF Office/ViewModels/ViewContentViewModel.cs
  22. 78 0
      PDF Office/Views/EditTools/Bates/BatesContent.xaml
  23. 15 0
      PDF Office/Views/EditTools/Bates/BatesContent.xaml.cs
  24. 153 0
      PDF Office/Views/EditTools/Bates/BatesCreateContent.xaml
  25. 15 0
      PDF Office/Views/EditTools/Bates/BatesCreateContent.xaml.cs
  26. 38 0
      PDF Office/Views/EditTools/Bates/BatesDocumentContent.xaml
  27. 15 0
      PDF Office/Views/EditTools/Bates/BatesDocumentContent.xaml.cs
  28. 24 0
      PDF Office/Views/EditTools/Bates/BatesTemplateListContent.xaml
  29. 15 0
      PDF Office/Views/EditTools/Bates/BatesTemplateListContent.xaml.cs
  30. 78 0
      PDF Office/Views/EditTools/HeaderFooter/HeaderFooterContent.xaml
  31. 15 0
      PDF Office/Views/EditTools/HeaderFooter/HeaderFooterContent.xaml.cs
  32. 149 0
      PDF Office/Views/EditTools/HeaderFooter/HeaderFooterCreateContent.xaml
  33. 15 0
      PDF Office/Views/EditTools/HeaderFooter/HeaderFooterCreateContent.xaml.cs
  34. 37 0
      PDF Office/Views/EditTools/HeaderFooter/HeaderFooterDocumentContent.xaml
  35. 15 0
      PDF Office/Views/EditTools/HeaderFooter/HeaderFooterDocumentContent.xaml.cs
  36. 24 0
      PDF Office/Views/EditTools/HeaderFooter/HeaderFooterTemplateListContent.xaml
  37. 15 0
      PDF Office/Views/EditTools/HeaderFooter/HeaderFooterTemplateListContent.xaml.cs
  38. 3 8
      PDF Office/Views/EditTools/Watermark/WatermarkTemplateListFileContent.xaml
  39. 20 0
      PDF Office/Views/EditTools/Watermark/WatermarkTemplateListFileContent.xaml.cs
  40. 3 8
      PDF Office/Views/EditTools/Watermark/WatermarkTemplateListTextContent.xaml
  41. 21 0
      PDF Office/Views/EditTools/Watermark/WatermarkTemplateListTextContent.xaml.cs
  42. 2 2
      PDF Office/Views/Tools/ToolsBarContent.xaml
  43. 4 1
      PDFSettings/WatermarkTemplateList.cs

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

@@ -42,6 +42,10 @@ using PDF_Office.Helper;
 using PDF_Office.Views.Dialog.HomePageToolsDialogs.HomePageBatchProcessing.HomePageConverter;
 using PDF_Office.Views.EditTools.Watermark; 
 using PDF_Office.Views.EditTools.Background;
+using PDF_Office.Views.EditTools.Bates;
+using PDF_Office.Views.EditTools.HeaderFooter;
+
+
 
 namespace PDF_Office
 {
@@ -171,6 +175,14 @@ namespace PDF_Office
             containerRegistry.RegisterForNavigation<StampAnnotProperty>();
             containerRegistry.RegisterForNavigation<TextAnnotProperty>();
             containerRegistry.RegisterForNavigation<TextEditProperty>();
+            containerRegistry.RegisterForNavigation<BatesContent>();
+            containerRegistry.RegisterForNavigation<BatesTemplateListContent>();
+            containerRegistry.RegisterForNavigation<BatesCreateContent>();
+            containerRegistry.RegisterForNavigation<BatesDocumentContent>();
+            containerRegistry.RegisterForNavigation<HeaderFooterContent>();
+            containerRegistry.RegisterForNavigation<HeaderFooterTemplateListContent>();
+            containerRegistry.RegisterForNavigation<HeaderFooterCreateContent>();
+            containerRegistry.RegisterForNavigation<HeaderFooterDocumentContent>();
             //填写与签名
             containerRegistry.RegisterForNavigation<FillAndSignContent>();
             containerRegistry.RegisterForNavigation<DateFillProperty>();

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

@@ -115,6 +115,13 @@ namespace PDF_Office.EventAggregators
         public WatermarkItem Status;
     }
 
+    public class BatesHeaderFooterItemUnicode
+    {
+        public string Unicode;
+        public string Type;
+        public BatesHeaderFooterItem Status;
+    }
+
     public class CPDFViewerUnicode
     {
         public string Unicode;
@@ -181,6 +188,10 @@ namespace PDF_Office.EventAggregators
     {
     }
 
+    public class EditBatesHeaderFooterTemplateItemEvent : PubSubEvent<BatesHeaderFooterItemUnicode>
+    {
+    }
+
     public class ConfirmEditBackgroundTemplateItemEvent : PubSubEvent<EnumColorOrFileUnicode>
     {
     }

+ 64 - 0
PDF Office/PDF Office.csproj

@@ -303,6 +303,10 @@
       <AutoGen>True</AutoGen>
     </Compile>
     <Compile Include="Settings.cs" />
+    <Compile Include="ViewModels\EditTools\Bates\BatesContentViewModel.cs" />
+    <Compile Include="ViewModels\EditTools\Bates\BatesCreateContentViewModel.cs" />
+    <Compile Include="ViewModels\EditTools\Bates\BatesDocumentContentViewModel.cs" />
+    <Compile Include="ViewModels\EditTools\Bates\BatesTemplateListContentViewModel.cs" />
     <Compile Include="ViewModels\BOTA\BookmarkContentViewModel.cs" />
     <Compile Include="ViewModels\Dialog\BOTA\AddBookmarkDialogViewModel.cs" />
     <Compile Include="ViewModels\Dialog\BOTA\BookmarkInfoDialogViewModel.cs" />
@@ -330,6 +334,10 @@
     <Compile Include="ViewModels\EditTools\Background\BackgroundTemplateListBaseContentViewModel.cs" />
     <Compile Include="ViewModels\EditTools\Background\BackgroundTemplateListColorContentViewModel.cs" />
     <Compile Include="ViewModels\EditTools\Background\BackgroundTemplateListFileContentViewModel.cs" />
+    <Compile Include="ViewModels\EditTools\HeaderFooter\HeaderFooterContentViewModel.cs" />
+    <Compile Include="ViewModels\EditTools\HeaderFooter\HeaderFooterCreateContentViewModel.cs" />
+    <Compile Include="ViewModels\EditTools\HeaderFooter\HeaderFooterDocumentContentViewModel.cs" />
+    <Compile Include="ViewModels\EditTools\HeaderFooter\HeaderFooterTemplateListContentViewModel.cs" />
     <Compile Include="ViewModels\HomePanel\RecentFiles\RecentFilesContentViewModel.cs" />
     <Compile Include="ViewModels\Tools\ConverterBarContentViewModel.cs" />
     <Compile Include="ViewModels\Dialog\ExtractDialogViewModel.cs" />
@@ -524,6 +532,30 @@
     <Compile Include="Views\Dialog\VerifyPassWordDialog.xaml.cs">
       <DependentUpon>VerifyPassWordDialog.xaml</DependentUpon>
     </Compile>
+    <Compile Include="Views\EditTools\Bates\BatesContent.xaml.cs">
+      <DependentUpon>BatesContent.xaml</DependentUpon>
+    </Compile>
+    <Compile Include="Views\EditTools\Bates\BatesCreateContent.xaml.cs">
+      <DependentUpon>BatesCreateContent.xaml</DependentUpon>
+    </Compile>
+    <Compile Include="Views\EditTools\Bates\BatesDocumentContent.xaml.cs">
+      <DependentUpon>BatesDocumentContent.xaml</DependentUpon>
+    </Compile>
+    <Compile Include="Views\EditTools\Bates\BatesTemplateListContent.xaml.cs">
+      <DependentUpon>BatesTemplateListContent.xaml</DependentUpon>
+    </Compile>
+    <Compile Include="Views\EditTools\HeaderFooter\HeaderFooterContent.xaml.cs">
+      <DependentUpon>HeaderFooterContent.xaml</DependentUpon>
+    </Compile>
+    <Compile Include="Views\EditTools\HeaderFooter\HeaderFooterCreateContent.xaml.cs">
+      <DependentUpon>HeaderFooterCreateContent.xaml</DependentUpon>
+    </Compile>
+    <Compile Include="Views\EditTools\HeaderFooter\HeaderFooterDocumentContent.xaml.cs">
+      <DependentUpon>HeaderFooterDocumentContent.xaml</DependentUpon>
+    </Compile>
+    <Compile Include="Views\EditTools\HeaderFooter\HeaderFooterTemplateListContent.xaml.cs">
+      <DependentUpon>HeaderFooterTemplateListContent.xaml</DependentUpon>
+    </Compile>
     <Compile Include="Views\FillAndSign\FillAndSignContent.xaml.cs">
       <DependentUpon>FillAndSignContent.xaml</DependentUpon>
     </Compile>
@@ -899,6 +931,38 @@
       <SubType>Designer</SubType>
       <Generator>MSBuild:Compile</Generator>
     </Page>
+    <Page Include="Views\EditTools\Bates\BatesContent.xaml">
+      <SubType>Designer</SubType>
+      <Generator>MSBuild:Compile</Generator>
+    </Page>
+    <Page Include="Views\EditTools\Bates\BatesCreateContent.xaml">
+      <SubType>Designer</SubType>
+      <Generator>MSBuild:Compile</Generator>
+    </Page>
+    <Page Include="Views\EditTools\Bates\BatesDocumentContent.xaml">
+      <SubType>Designer</SubType>
+      <Generator>MSBuild:Compile</Generator>
+    </Page>
+    <Page Include="Views\EditTools\Bates\BatesTemplateListContent.xaml">
+      <SubType>Designer</SubType>
+      <Generator>MSBuild:Compile</Generator>
+    </Page>
+    <Page Include="Views\EditTools\HeaderFooter\HeaderFooterContent.xaml">
+      <SubType>Designer</SubType>
+      <Generator>MSBuild:Compile</Generator>
+    </Page>
+    <Page Include="Views\EditTools\HeaderFooter\HeaderFooterCreateContent.xaml">
+      <SubType>Designer</SubType>
+      <Generator>MSBuild:Compile</Generator>
+    </Page>
+    <Page Include="Views\EditTools\HeaderFooter\HeaderFooterDocumentContent.xaml">
+      <SubType>Designer</SubType>
+      <Generator>MSBuild:Compile</Generator>
+    </Page>
+    <Page Include="Views\EditTools\HeaderFooter\HeaderFooterTemplateListContent.xaml">
+      <SubType>Designer</SubType>
+      <Generator>MSBuild:Compile</Generator>
+    </Page>
     <Page Include="Views\FillAndSign\FillAndSignContent.xaml">
       <SubType>Designer</SubType>
       <Generator>MSBuild:Compile</Generator>

+ 0 - 5
PDF Office/ViewModels/EditTools/Background/BackgroundContentViewModel.cs

@@ -98,7 +98,6 @@ namespace PDF_Office.ViewModels.EditTools.Background
         public DelegateCommand ConfirmEditToolCommand { get; set; }
         public DelegateCommand<string> EnterSelectedContentCommand { get; set; }
 
-        public string unicode = null;
 
         public string Unicode = null;
 
@@ -166,7 +165,6 @@ namespace PDF_Office.ViewModels.EditTools.Background
             param.Add(ParameterNames.PDFViewer, PDFViewer);
             param.Add("CurrentTemplateListModName", CurrentTemplateListMod);
             param.Add("BackgroundItem", backgroundItem);
-            param.Add("UniCode", unicode);
             backgroundRegion.RequestNavigate(BackgroundSettingsRegionName, CreateBaseName, param);
             BackgroundSettingsVisible = Visibility.Visible;
         }
@@ -188,7 +186,6 @@ namespace PDF_Office.ViewModels.EditTools.Background
         {
             NavigationParameters param = new NavigationParameters();
             param.Add(ParameterNames.PDFViewer, PDFViewer);
-            param.Add("UniCode", unicode);
             if (SelectedContentName == TemplateListBaseName)
             {
                 param.Add("CurrentCreateModName", CurrentCreateMod);
@@ -206,7 +203,6 @@ namespace PDF_Office.ViewModels.EditTools.Background
             NavigationParameters param = new NavigationParameters();
             param.Add(ParameterNames.PDFViewer, PDFViewer);
             param.Add(ParameterNames.ViewContentViewModel, viewContentViewModel);
-            param.Add("UniCode", unicode);
             backgroundRegion.RequestNavigate(BackgroundDocumentRegionName, BackgroundDocumentName, param);
             BackgroundDocumentVisible = Visibility.Visible;
         }
@@ -215,7 +211,6 @@ namespace PDF_Office.ViewModels.EditTools.Background
         {
             navigationContext.Parameters.TryGetValue<ViewContentViewModel>(ParameterNames.ViewContentViewModel, out viewContentViewModel);
             navigationContext.Parameters.TryGetValue<CPDFViewer>(ParameterNames.PDFViewer, out PDFViewer);
-            navigationContext.Parameters.TryGetValue<string>("UniCode",out unicode);
             EnterSelectedContent(TemplateListBaseName);
             EnterDocumentContent();
         }

+ 0 - 6
PDF Office/ViewModels/EditTools/Background/BackgroundCreateColorContentViewModel.cs

@@ -432,12 +432,6 @@ namespace PDF_Office.ViewModels.EditTools.Background
             {
                 var backgroundItem = new BackgroundItem();
                 ConvertInfoToItem(ref backgroundItem, BackgroundInfo);
-                this.eventAggregator.GetEvent<EnterTemplateListOrCreateEvent>().Publish(new EnumTemplateListOrCreateUnicode
-                {
-                    Unicode = Unicode,
-                    Status = EnumTemplateListOrCreate.StatusTemplate
-                });
-
                 try
                 {
                     //创建缓存文件夹

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

@@ -513,7 +513,6 @@ namespace PDF_Office.ViewModels.EditTools.Background
             {
                 InitComponentBySelectedInfo();
             }
-            InitOpacityList();
         }
     }
 }

+ 198 - 198
PDF Office/ViewModels/EditTools/Background/BackgroundDocumentContentViewModel.cs

@@ -1,201 +1,201 @@
-using ComPDFKit.PDFDocument;
-using ComPDFKit.PDFPage;
-using ComPDFKit.PDFWatermark;
-using ComPDFKitViewer;
-using ComPDFKitViewer.PdfViewer;
-using PDF_Office.EventAggregators;
-using PDF_Office.Helper;
-using PDF_Office.Model;
-using PDF_Office.Model.EditTools.Background;
-using PDF_Office.Model.EditTools.Watermark;
-using Prism.Commands;
-using Prism.Events;
-using Prism.Mvvm;
-using Prism.Regions;
-using System;
-using System.Collections.Generic;
-using System.Diagnostics;
-using System.Drawing;
-using System.Linq;
-using System.Threading.Tasks;
-using System.Windows;
-using System.Windows.Media;
-using System.Windows.Media.Imaging;
-using Size = System.Windows.Size;
-
-namespace PDF_Office.ViewModels.EditTools.Background
-{
-    public class BackgroundDocumentContentViewModel : BindableBase, INavigationAware
-    {
-        public IEventAggregator eventAggregator;
-        public IRegionManager regionManager;
-        public CPDFViewer PDFViewer;
-        public CPDFDocument Document;
-        private ViewContentViewModel viewContentViewModel;
-        CPDFViewer pdfViewer;
-
-        private CPDFBackground background;
-        private BackgroundInfo backgroundInfo;
-
-
-        public bool firstin = true;
-
+using ComPDFKit.PDFDocument;
+using ComPDFKit.PDFPage;
+using ComPDFKit.PDFWatermark;
+using ComPDFKitViewer;
+using ComPDFKitViewer.PdfViewer;
+using PDF_Office.EventAggregators;
+using PDF_Office.Helper;
+using PDF_Office.Model;
+using PDF_Office.Model.EditTools.Background;
+using PDF_Office.Model.EditTools.Watermark;
+using Prism.Commands;
+using Prism.Events;
+using Prism.Mvvm;
+using Prism.Regions;
+using System;
+using System.Collections.Generic;
+using System.Diagnostics;
+using System.Drawing;
+using System.Linq;
+using System.Threading.Tasks;
+using System.Windows;
+using System.Windows.Media;
+using System.Windows.Media.Imaging;
+using Size = System.Windows.Size;
+
+namespace PDF_Office.ViewModels.EditTools.Background
+{
+    public class BackgroundDocumentContentViewModel : BindableBase, INavigationAware
+    {
+        public IEventAggregator eventAggregator;
+        public IRegionManager regionManager;
+        public CPDFViewer PDFViewer;
+        public CPDFDocument Document;
+        private ViewContentViewModel viewContentViewModel;
+        CPDFViewer pdfViewer;
+
+        private CPDFBackground background;
+        private BackgroundInfo backgroundInfo;
+
+
+        public bool firstin = true;
+
         public string ViewerRegionName { get; set; }
 
-        public string unicode = null;
-        public string Unicode = null;
-
-        public BackgroundDocumentContentViewModel(IEventAggregator eventAggregator, IRegionManager regionManager)
-        {
-            this.regionManager = regionManager;
-            this.eventAggregator = eventAggregator;
-            Unicode = App.mainWindowViewModel.SelectedItem.Unicode;
-            eventAggregator.GetEvent<ConfirmEditToolsBackgroundEvent>().Subscribe(ConfirmEditToolsBackground);
-            eventAggregator.GetEvent<SetBackgroundEvent>().Subscribe(SetBackground, e => e.Unicode == Unicode);
-            ViewerRegionName = RegionNames.BackgroundViewRegionName;
-        }
-
-        public void ConfirmEditToolsBackground()
-        {
-            if (backgroundInfo != null)
-            {
-                CreateBackground(viewContentViewModel.PDFViewer.Document);
-            }
-        }
-
-        public void SetBackground(BackgroundInfoUnicode backgroundInfounicode)
-        {
-            BackgroundInfo backgroundInfo=backgroundInfounicode.Status;
-            this.backgroundInfo = backgroundInfo;
-            CreateBackground(PDFViewer.Document);
-            PDFViewer.InvalidChildVisual(false);
-            PDFViewer.Document.ReleasePages();
-            PDFViewer.ReloadDocument();
-        }
-
-        public void CreateBackground(CPDFDocument document, bool IsNewDoc = false)
-        {
-            if (backgroundInfo != null)
-            {
-                background = document.GetBackground();
-                if (backgroundInfo.BackgroundType == C_Background_Type.BG_TYPE_COLOR)
-                {
-                    background.SetBackgroundType(C_Background_Type.BG_TYPE_COLOR);
-                    background.SetColor(backgroundInfo.Color);
-                }
-                else
-                {
-                    background.SetBackgroundType(C_Background_Type.BG_TYPE_IMAGE);
-                    background.SetImage(backgroundInfo.ImageArray, backgroundInfo.ImageWidth, backgroundInfo.ImageHeight, ComPDFKit.Import.C_Scale_Type.fitCenter);
-                }
-
-                background.SetScale(1);
-                background.SetRotation(backgroundInfo.Rotation);
-                background.SetOpacity(backgroundInfo.Opacity);
-                background.SetVertalign(backgroundInfo.Vertalign);
-                background.SetHorizalign(backgroundInfo.Horizalign);
-                background.SetXOffset(backgroundInfo.HorizOffset);
-                background.SetYOffset(backgroundInfo.VertOffset);
-                background.SetAllowsPrint(true);
-                background.SetAllowsView(true);
-                if (IsNewDoc) { background.SetPages("0"); }
-                else
-                {
-                    background.SetPages(backgroundInfo.PageRange);
-                }
-                background.Update();
-            }
-        }
-
-
-        private void UndoManager_PropertyChanged(object sender, System.ComponentModel.PropertyChangedEventArgs e)
-        {
-        }
-
-        private void CurrentViewer_CustomDrawHandler(object sender, CustomDrawData e)
-        {
-            if (e.DrawPages.Count > 0 && e.DrawContext != null)
-            {
-                List<int> PageIndexLists = new List<int>();
-                foreach (DrawPageData drawPageData in e.DrawPages)
-                {
-                    if (backgroundInfo != null)
-                    {
-                        char[] enumerationSeparator = new char[] { ',' };
-                        char[] rangeSeparator = new char[] { '-' };
-                        if (CommonHelper.GetPagesInRange(ref PageIndexLists, backgroundInfo.PageRange, Document.PageCount, enumerationSeparator, rangeSeparator, true))
-                        { //TODO
-                            if (PageIndexLists.Contains(drawPageData.PageIndex - 1))
-                            {
-                                WriteableBitmap backgroundBitmap = GetBackground(PDFViewer.Document, e.Zoom, drawPageData.PageIndex);
-                                e.DrawContext.DrawImage(backgroundBitmap, drawPageData.PageBound);
-                            }
-                        }
-                    }
-                }
-            }
-        }
-
-        private WriteableBitmap GetBackground(CPDFDocument oldDoc, double zoom, int pageIndex)
-        {
-            Size pageSize = oldDoc.GetPageSize(pageIndex);
-
-            CPDFDocument newDoc = CPDFDocument.CreateDocument();
-            newDoc.InsertPage(0, pageSize.Width, pageSize.Height, null);
-            CreateBackground(newDoc, true);
-            CPDFPage newPage = newDoc.PageAtIndex(0);
-            double scale = 96.0 / 72.0;
-            zoom = zoom * scale;
-            Rect renderRect = new Rect(0, 0, (int)(pageSize.Width * scale), (int)(pageSize.Height * scale));
-            byte[] imageArray = new byte[(int)(renderRect.Width * renderRect.Height * 4)];
-            newPage.RenderPageBitmapWithMatrix((float)zoom, renderRect, 0x00FFFFFF, imageArray, 1, true);
-            WriteableBitmap WirteBitmap = new WriteableBitmap((int)renderRect.Width, (int)renderRect.Height, 96, 96, PixelFormats.Bgra32, null);
-            WirteBitmap.WritePixels(new Int32Rect(0, 0, (int)renderRect.Width, (int)renderRect.Height), imageArray, WirteBitmap.BackBufferStride, 0);
-            return WirteBitmap;
-        }
-
-        public bool IsNavigationTarget(NavigationContext navigationContext)
-        {
-            return true;
-        }
-
-        public void OnNavigatedFrom(NavigationContext navigationContext)
-        {
-
-        }
-
-        public void OnNavigatedTo(NavigationContext navigationContext)
-        {
-            navigationContext.Parameters.TryGetValue<CPDFViewer>(ParameterNames.PDFViewer, out pdfViewer);
+        public string unicode = null;
+        public string Unicode = null;
+
+        public BackgroundDocumentContentViewModel(IEventAggregator eventAggregator, IRegionManager regionManager)
+        {
+            this.regionManager = regionManager;
+            this.eventAggregator = eventAggregator;
+            Unicode = App.mainWindowViewModel.SelectedItem.Unicode;
+            eventAggregator.GetEvent<ConfirmEditToolsBackgroundEvent>().Subscribe(ConfirmEditToolsBackground);
+            eventAggregator.GetEvent<SetBackgroundEvent>().Subscribe(SetBackground, e => e.Unicode == Unicode);
+            ViewerRegionName = RegionNames.BackgroundViewRegionName;
+        }
+
+        public void ConfirmEditToolsBackground()
+        {
+            if (backgroundInfo != null)
+            {
+                CreateBackground(viewContentViewModel.PDFViewer.Document);
+            }
+        }
+
+        public void SetBackground(BackgroundInfoUnicode backgroundInfounicode)
+        {
+            BackgroundInfo backgroundInfo=backgroundInfounicode.Status;
+            this.backgroundInfo = backgroundInfo;
+            CreateBackground(PDFViewer.Document);
+            PDFViewer.InvalidChildVisual(false);
+            PDFViewer.Document.ReleasePages();
+            PDFViewer.ReloadDocument();
+        }
+
+        public void CreateBackground(CPDFDocument document, bool IsNewDoc = false)
+        {
+            if (backgroundInfo != null)
+            {
+                background = document.GetBackground();
+                if (backgroundInfo.BackgroundType == C_Background_Type.BG_TYPE_COLOR)
+                {
+                    background.SetBackgroundType(C_Background_Type.BG_TYPE_COLOR);
+                    background.SetColor(backgroundInfo.Color);
+                }
+                else
+                {
+                    background.SetBackgroundType(C_Background_Type.BG_TYPE_IMAGE);
+                    background.SetImage(backgroundInfo.ImageArray, backgroundInfo.ImageWidth, backgroundInfo.ImageHeight, ComPDFKit.Import.C_Scale_Type.fitCenter);
+                }
+
+                background.SetScale(1);
+                background.SetRotation(backgroundInfo.Rotation);
+                background.SetOpacity(backgroundInfo.Opacity);
+                background.SetVertalign(backgroundInfo.Vertalign);
+                background.SetHorizalign(backgroundInfo.Horizalign);
+                background.SetXOffset(backgroundInfo.HorizOffset);
+                background.SetYOffset(backgroundInfo.VertOffset);
+                background.SetAllowsPrint(true);
+                background.SetAllowsView(true);
+                if (IsNewDoc) { background.SetPages("0"); }
+                else
+                {
+                    background.SetPages(backgroundInfo.PageRange);
+                }
+                background.Update();
+            }
+        }
+
+
+        private void UndoManager_PropertyChanged(object sender, System.ComponentModel.PropertyChangedEventArgs e)
+        {
+        }
+
+        private void CurrentViewer_CustomDrawHandler(object sender, CustomDrawData e)
+        {
+            if (e.DrawPages.Count > 0 && e.DrawContext != null)
+            {
+                List<int> PageIndexLists = new List<int>();
+                foreach (DrawPageData drawPageData in e.DrawPages)
+                {
+                    if (backgroundInfo != null)
+                    {
+                        char[] enumerationSeparator = new char[] { ',' };
+                        char[] rangeSeparator = new char[] { '-' };
+                        if (CommonHelper.GetPagesInRange(ref PageIndexLists, backgroundInfo.PageRange, Document.PageCount, enumerationSeparator, rangeSeparator, true))
+                        { //TODO
+                            if (PageIndexLists.Contains(drawPageData.PageIndex - 1))
+                            {
+                                WriteableBitmap backgroundBitmap = GetBackground(PDFViewer.Document, e.Zoom, drawPageData.PageIndex);
+                                e.DrawContext.DrawImage(backgroundBitmap, drawPageData.PageBound);
+                            }
+                        }
+                    }
+                }
+            }
+        }
+
+        private WriteableBitmap GetBackground(CPDFDocument oldDoc, double zoom, int pageIndex)
+        {
+            Size pageSize = oldDoc.GetPageSize(pageIndex);
+
+            CPDFDocument newDoc = CPDFDocument.CreateDocument();
+            newDoc.InsertPage(0, pageSize.Width, pageSize.Height, null);
+            CreateBackground(newDoc, true);
+            CPDFPage newPage = newDoc.PageAtIndex(0);
+            double scale = 96.0 / 72.0;
+            zoom = zoom * scale;
+            Rect renderRect = new Rect(0, 0, (int)(pageSize.Width * scale), (int)(pageSize.Height * scale));
+            byte[] imageArray = new byte[(int)(renderRect.Width * renderRect.Height * 4)];
+            newPage.RenderPageBitmapWithMatrix((float)zoom, renderRect, 0x00FFFFFF, imageArray, 1, true);
+            WriteableBitmap WirteBitmap = new WriteableBitmap((int)renderRect.Width, (int)renderRect.Height, 96, 96, PixelFormats.Bgra32, null);
+            WirteBitmap.WritePixels(new Int32Rect(0, 0, (int)renderRect.Width, (int)renderRect.Height), imageArray, WirteBitmap.BackBufferStride, 0);
+            return WirteBitmap;
+        }
+
+        public bool IsNavigationTarget(NavigationContext navigationContext)
+        {
+            return true;
+        }
+
+        public void OnNavigatedFrom(NavigationContext navigationContext)
+        {
+
+        }
+
+        public void OnNavigatedTo(NavigationContext navigationContext)
+        {
+            navigationContext.Parameters.TryGetValue<CPDFViewer>(ParameterNames.PDFViewer, out pdfViewer);
             navigationContext.Parameters.TryGetValue<ViewContentViewModel>(ParameterNames.ViewContentViewModel, out viewContentViewModel);
-            navigationContext.Parameters.TryGetValue<string>("UniCode", out unicode);
-            if (pdfViewer != null)
-            {
-                if (!regionManager.Regions[ViewerRegionName].Views.Contains(PDFViewer))
-                {
-                    PDFViewer = new CPDFViewer();
-                    PDFViewer.InitDocument(pdfViewer.Document);
-                    Document = PDFViewer.Document;
-                    PDFViewer.CustomDrawHandler += CurrentViewer_CustomDrawHandler;
-                    PDFViewer.UndoManager.PropertyChanged += UndoManager_PropertyChanged;
-                    regionManager.AddToRegion(ViewerRegionName, PDFViewer);
-                    PDFViewer.SetAnnotInteraction(!PDFViewer.GetAnnotInteraction());
-                    PDFViewer.Load();
-                    PDFViewer.ChangeViewMode(ViewMode.Single);
-                    PDFViewer.SetMouseMode(MouseModes.Default);
-                }
-            }
-        }
-    }
-}
-
-
-
-
-
-
-
-
-
-
-
+            navigationContext.Parameters.TryGetValue<string>("UniCode", out unicode);
+            if (pdfViewer != null)
+            {
+                if (!regionManager.Regions[ViewerRegionName].Views.Contains(PDFViewer))
+                {
+                    PDFViewer = new CPDFViewer();
+                    PDFViewer.InitDocument(pdfViewer.Document);
+                    Document = PDFViewer.Document;
+                    PDFViewer.CustomDrawHandler += CurrentViewer_CustomDrawHandler;
+                    PDFViewer.UndoManager.PropertyChanged += UndoManager_PropertyChanged;
+                    regionManager.AddToRegion(ViewerRegionName, PDFViewer);
+                    PDFViewer.SetAnnotInteraction(!PDFViewer.GetAnnotInteraction());
+                    PDFViewer.Load();
+                    PDFViewer.ChangeViewMode(ViewMode.Single);
+                    PDFViewer.SetMouseMode(MouseModes.Default);
+                }
+            }
+        }
+    }
+}
+
+
+
+
+
+
+
+
+
+
+

+ 129 - 129
PDF Office/ViewModels/EditTools/Background/BackgroundTemplateListBaseContentViewModel.cs

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

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

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

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

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

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

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

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

@@ -0,0 +1,44 @@
+using PDF_Office.EventAggregators;
+using Prism.Commands;
+using Prism.Events;
+using Prism.Mvvm;
+using Prism.Regions;
+using System;
+using System.Collections.Generic;
+using System.Linq;
+
+namespace PDF_Office.ViewModels.EditTools.Bates
+{
+    public class BatesTemplateListContentViewModel : BindableBase, INavigationAware
+    {
+
+        public DelegateCommand EnterCreateCommand { get; set; }
+        public IEventAggregator eventAggregator;
+        public string Unicode = null;
+
+        public BatesTemplateListContentViewModel(IEventAggregator eventAggregator)
+        {
+            this.eventAggregator = eventAggregator;
+            Unicode = App.mainWindowViewModel.SelectedItem.Unicode;
+            EnterCreateCommand = new DelegateCommand(EnterCreate);
+        }
+
+        public void EnterCreate()
+        {
+            this.eventAggregator.GetEvent<EnterTemplateListOrCreateEvent>().Publish(new EnumTemplateListOrCreateUnicode { Unicode = Unicode, Status = EnumTemplateListOrCreate.StatusCreate });
+        }
+
+        public bool IsNavigationTarget(NavigationContext navigationContext)
+        {
+            return true;
+        }
+
+        public void OnNavigatedFrom(NavigationContext navigationContext)
+        {
+        }
+
+        public void OnNavigatedTo(NavigationContext navigationContext)
+        {
+        }
+    }
+}

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

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

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

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

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

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

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

@@ -0,0 +1,43 @@
+using PDF_Office.EventAggregators;
+using Prism.Commands;
+using Prism.Events;
+using Prism.Mvvm;
+using Prism.Regions;
+using System;
+using System.Collections.Generic;
+using System.Linq;
+
+namespace PDF_Office.ViewModels.EditTools.HeaderFooter
+{
+    public class HeaderFooterTemplateListContentViewModel : BindableBase, INavigationAware
+    {
+        public IEventAggregator eventAggregator;
+        public DelegateCommand EnterCreateCommand { get; set; }
+
+        public string Unicode = null;
+        public HeaderFooterTemplateListContentViewModel(IEventAggregator eventAggregator)
+        {
+            this.eventAggregator = eventAggregator;
+            Unicode = App.mainWindowViewModel.SelectedItem.Unicode;
+            EnterCreateCommand = new DelegateCommand(EnterCreate);
+        }
+
+        public void EnterCreate()
+        {
+            this.eventAggregator.GetEvent<EnterTemplateListOrCreateEvent>().Publish(new EnumTemplateListOrCreateUnicode { Unicode = Unicode, Status = EnumTemplateListOrCreate.StatusCreate });
+        }
+
+        public bool IsNavigationTarget(NavigationContext navigationContext)
+        {
+            return true;
+        }
+
+        public void OnNavigatedFrom(NavigationContext navigationContext)
+        {
+        }
+
+        public void OnNavigatedTo(NavigationContext navigationContext)
+        {
+        }
+    }
+}

+ 131 - 4
PDF Office/ViewModels/EditTools/Watermark/WatermarkCreateFileContentViewModel.cs

@@ -6,6 +6,7 @@ using PDF_Office.CustomControl;
 using PDF_Office.EventAggregators;
 using PDF_Office.Helper;
 using PDF_Office.Model;
+using PDF_Office.Model.EditTools.Background;
 using PDF_Office.Model.EditTools.Watermark;
 using PDF_Office.Model.PageEdit;
 using PDF_Office.Properties;
@@ -406,8 +407,51 @@ namespace PDF_Office.ViewModels.EditTools.Watermark
             var watermarkItem = new WatermarkItem();
             ConvertInfoToItem(ref watermarkItem, WatermarkInfo);
             watermarkItem.templateName += Settings.Default.WatermarkIndex.ToString();
-            Settings.Default.WatermarkTemplateList.Add(watermarkItem);
-            Settings.Default.Save();
+            try
+            {
+                //创建缓存文件夹
+                string folderPath = Path.Combine(App.CurrentPath, "Watermark");
+                //有可能因为其他原因存在同名文件,导致创建文件夹失败,需要先删除同名文件
+                //保险措施(猜测)
+                if (File.Exists(folderPath))
+                {
+                    File.Delete(folderPath);
+                }
+
+                DirectoryInfo tempfolder = new DirectoryInfo(folderPath);
+                if (!tempfolder.Exists)
+                {
+                    tempfolder.Create();
+                }
+
+                //预览图缓存
+                string saveName = Guid.NewGuid().ToString();
+                string savePath = Path.Combine(folderPath, saveName);
+                System.Windows.Size pageSize = new Size { Width = 128, Height = 160 };
+                CPDFDocument tempDocument = CPDFDocument.CreateDocument();
+                if (tempDocument != null)
+                {
+                    tempDocument.InsertPage(0, pageSize.Width, pageSize.Height, null);
+                    CreateWatermark(tempDocument, WatermarkInfo);
+                    //获取透明背景的图片
+                    var bitmap = ToolMethod.RenderPageBitmapNoWait(tempDocument, (int)pageSize.Width, (int)pageSize.Height, 0, false, false, 0x00FFFFFF);
+                    using (FileStream stream = new FileStream(savePath, FileMode.Create))
+                    {
+                        bitmap.Save(stream, System.Drawing.Imaging.ImageFormat.Png);
+                    }
+
+                    watermarkItem.previewImagePath = savePath;
+                    tempDocument.Release();
+
+                    Settings.Default.WatermarkTemplateList.Add(watermarkItem);
+                    Settings.Default.Save();
+                }
+            }
+            catch
+            {
+
+            }
+           
             this.eventAggregator.GetEvent<EnterTemplateListOrCreateEvent>().Publish(new EnumTemplateListOrCreateUnicode
             {
                 Unicode = Unicode,
@@ -493,6 +537,45 @@ namespace PDF_Office.ViewModels.EditTools.Watermark
 
         }
 
+        public void CreateWatermark(CPDFDocument document, WatermarkInfo watermarkInfo)
+        {
+            if (watermarkInfo != null)
+            {
+                document.DeleteWatermarks();
+                CPDFWatermark watermark;
+                if (watermarkInfo.WatermarkType == C_Watermark_Type.WATERMARK_TYPE_TEXT)
+                {
+                    watermark = document.InitWatermark(C_Watermark_Type.WATERMARK_TYPE_TEXT);
+                    watermark.SetText(watermarkInfo.Text);
+                    watermark.SetFontName(watermarkInfo.FontName);
+                    watermark.SetFontSize(watermarkInfo.TextSize);
+                    watermark.SetTextRGBColor(watermarkInfo.TextColor);
+                }
+                else
+                {
+                    watermark = document.InitWatermark(C_Watermark_Type.WATERMARK_TYPE_IMG);
+                    if (watermarkInfo.ImageArray != null)
+                    {
+                        watermark.SetImage(watermarkInfo.ImageArray, watermarkInfo.ImageWidth, watermarkInfo.ImageHeight);
+                    }
+                    watermark.SetScale(0.1f);
+                }
+                watermark.SetRotation(watermarkInfo.Rotation);
+                watermark.SetOpacity(watermarkInfo.Opacity);
+                watermark.SetFront(watermarkInfo.IsFront);
+                watermark.SetVertalign(watermarkInfo.WatermarkVertalign);
+                watermark.SetHorizalign(watermarkInfo.WatermarkHorizalign);
+                watermark.SetFullScreen(watermarkInfo.Isfull);
+                watermark.SetVertOffset(watermarkInfo.VertOffset);
+                watermark.SetHorizOffset(watermarkInfo.HorizOffset);
+                watermark.SetHorizontalSpacing(watermarkInfo.HorizontalSpacing);
+                watermark.SetVerticalSpacing(watermarkInfo.VerticalSpacing);
+                watermark.SetPages("0");
+                Trace.WriteLine("IsCreateWatermark: " + watermark.CreateWatermark());
+                Trace.WriteLine("IsUpdateWatermark: " + watermark.UpdateWatermark());
+            }
+        }
+
         public void ConfirmEditWatermarkTemplateItem(EnumTextOrFileUnicode enumTextOrFileunicode)
         {
             EnumTextOrFile enumTextOrFile = enumTextOrFileunicode.Status;
@@ -500,8 +583,52 @@ namespace PDF_Office.ViewModels.EditTools.Watermark
             {
                 var watermarkItem = new WatermarkItem();
                 ConvertInfoToItem(ref watermarkItem, WatermarkInfo);
-                Settings.Default.WatermarkTemplateList[TemplateWatermarkItem.listIndex] = watermarkItem;
-                Settings.Default.Save();
+                try
+                {
+                    //创建缓存文件夹
+                    string folderPath = Path.Combine(App.CurrentPath, "Watermark");
+                    //有可能因为其他原因存在同名文件,导致创建文件夹失败,需要先删除同名文件
+                    //保险措施(猜测)
+                    if (File.Exists(folderPath))
+                    {
+                        File.Delete(folderPath);
+                    }
+
+                    DirectoryInfo tempfolder = new DirectoryInfo(folderPath);
+                    if (!tempfolder.Exists)
+                    {
+                        tempfolder.Create();
+                    }
+
+                    //预览图缓存
+                    string saveName = Guid.NewGuid().ToString();
+                    string savePath = Path.Combine(folderPath, saveName);
+                    System.Windows.Size pageSize = new Size { Width = 128, Height = 160 };
+                    CPDFDocument tempDocument = CPDFDocument.CreateDocument();
+                    if (tempDocument != null)
+                    {
+                        tempDocument.InsertPage(0, pageSize.Width/4, pageSize.Height, null);
+                        CreateWatermark(tempDocument, WatermarkInfo);
+                        //获取透明背景的图片
+                        var bitmap = ToolMethod.RenderPageBitmapNoWait(tempDocument, (int)pageSize.Width, (int)pageSize.Height, 0, false, false, 0x00FFFFFF);
+                        using (FileStream stream = new FileStream(savePath, FileMode.Create))
+                        {
+                            bitmap.Save(stream, System.Drawing.Imaging.ImageFormat.Png);
+                        }
+
+                        watermarkItem.previewImagePath = savePath;
+                        tempDocument.Release();
+
+                        Settings.Default.WatermarkTemplateList[TemplateWatermarkItem.listIndex] = watermarkItem;
+                        Settings.Default.Save();
+                    }
+                }
+                catch
+                {
+
+                }
+
+
                 this.eventAggregator.GetEvent<EnterTemplateListOrCreateEvent>().Publish(new EnumTemplateListOrCreateUnicode
                 {
                     Unicode = Unicode,

+ 131 - 5
PDF Office/ViewModels/EditTools/Watermark/WatermarkCreateTextContentViewModel.cs

@@ -18,6 +18,8 @@ using Prism.Mvvm;
 using Prism.Regions;
 using System;
 using System.Collections.Generic;
+using System.Diagnostics;
+using System.IO;
 using System.Linq;
 using System.Windows.Forms;
 using System.Windows.Media;
@@ -496,8 +498,50 @@ namespace PDF_Office.ViewModels.EditTools.Watermark
             var watermarkItem = new WatermarkItem();
             ConvertInfoToItem(ref watermarkItem, WatermarkInfo);
             watermarkItem.templateName += Settings.Default.WatermarkIndex.ToString();
-            Settings.Default.WatermarkTemplateList.Add(watermarkItem);
-            Settings.Default.Save();
+            try
+            {
+                //创建缓存文件夹
+                string folderPath = Path.Combine(App.CurrentPath, "Watermark");
+                //有可能因为其他原因存在同名文件,导致创建文件夹失败,需要先删除同名文件
+                //保险措施(猜测)
+                if (File.Exists(folderPath))
+                {
+                    File.Delete(folderPath);
+                }
+
+                DirectoryInfo tempfolder = new DirectoryInfo(folderPath);
+                if (!tempfolder.Exists)
+                {
+                    tempfolder.Create();
+                }
+
+                //预览图缓存
+                string saveName = Guid.NewGuid().ToString();
+                string savePath = Path.Combine(folderPath, saveName);
+                System.Windows.Size pageSize = new System.Windows.Size { Width = 128, Height = 160 };
+                CPDFDocument tempDocument = CPDFDocument.CreateDocument();
+                if (tempDocument != null)
+                {
+                    tempDocument.InsertPage(0, pageSize.Width, pageSize.Height, null);
+                    CreateWatermark(tempDocument, WatermarkInfo);
+                    //获取透明背景的图片
+                    var bitmap = ToolMethod.RenderPageBitmapNoWait(tempDocument, (int)pageSize.Width, (int)pageSize.Height, 0, false, false, 0x00FFFFFF);
+                    using (FileStream stream = new FileStream(savePath, FileMode.Create))
+                    {
+                        bitmap.Save(stream, System.Drawing.Imaging.ImageFormat.Png);
+                    }
+
+                    watermarkItem.previewImagePath = savePath;
+                    tempDocument.Release();
+
+                    Settings.Default.WatermarkTemplateList.Add(watermarkItem);
+                    Settings.Default.Save();
+                }
+            }
+            catch
+            {
+
+            }
             this.eventAggregator.GetEvent<EnterTemplateListOrCreateEvent>().Publish(new EnumTemplateListOrCreateUnicode
             {
                 Unicode = Unicode,
@@ -582,7 +626,7 @@ namespace PDF_Office.ViewModels.EditTools.Watermark
             }
             else
             {
-                WatermarkInfo.TextSize = Index + 7;
+                WatermarkInfo.TextSize = (Index + 7)*1.33f;
             }
         }
 
@@ -644,6 +688,45 @@ namespace PDF_Office.ViewModels.EditTools.Watermark
             ConvertItemToInfo(TemplateWatermarkItem, ref WatermarkInfo);
         }
 
+        public void CreateWatermark(CPDFDocument document, WatermarkInfo watermarkInfo)
+        {
+            if (watermarkInfo != null)
+            {
+                document.DeleteWatermarks();
+                CPDFWatermark watermark;
+                if (watermarkInfo.WatermarkType == C_Watermark_Type.WATERMARK_TYPE_TEXT)
+                {
+                    watermark = document.InitWatermark(C_Watermark_Type.WATERMARK_TYPE_TEXT);
+                    watermark.SetText(watermarkInfo.Text);
+                    watermark.SetFontName(watermarkInfo.FontName);
+                    watermark.SetFontSize(watermarkInfo.TextSize);
+                    watermark.SetTextRGBColor(watermarkInfo.TextColor);
+                }
+                else
+                {
+                    watermark = document.InitWatermark(C_Watermark_Type.WATERMARK_TYPE_IMG);
+                    if (watermarkInfo.ImageArray != null)
+                    {
+                        watermark.SetImage(watermarkInfo.ImageArray, watermarkInfo.ImageWidth, watermarkInfo.ImageHeight);
+                    }
+                    watermark.SetScale(0.1f);
+                }
+                watermark.SetRotation(watermarkInfo.Rotation);
+                watermark.SetOpacity(watermarkInfo.Opacity);
+                watermark.SetFront(watermarkInfo.IsFront);
+                watermark.SetVertalign(watermarkInfo.WatermarkVertalign);
+                watermark.SetHorizalign(watermarkInfo.WatermarkHorizalign);
+                watermark.SetFullScreen(watermarkInfo.Isfull);
+                watermark.SetVertOffset(watermarkInfo.VertOffset);
+                watermark.SetHorizOffset(watermarkInfo.HorizOffset);
+                watermark.SetHorizontalSpacing(watermarkInfo.HorizontalSpacing);
+                watermark.SetVerticalSpacing(watermarkInfo.VerticalSpacing);
+                watermark.SetPages("0");
+                Trace.WriteLine("IsCreateWatermark: " + watermark.CreateWatermark());
+                Trace.WriteLine("IsUpdateWatermark: " + watermark.UpdateWatermark());
+            }
+        }
+
         public void ConfirmEditWatermarkTemplateItem(EnumTextOrFileUnicode enumTextOrFileunicode)
         {
             EnumTextOrFile enumTextOrFile = enumTextOrFileunicode.Status;
@@ -651,8 +734,51 @@ namespace PDF_Office.ViewModels.EditTools.Watermark
             {
                 var watermarkItem = new WatermarkItem();
                 ConvertInfoToItem(ref watermarkItem, WatermarkInfo);
-                Settings.Default.WatermarkTemplateList[TemplateWatermarkItem.listIndex] = watermarkItem;
-                Settings.Default.Save();
+                try
+                {
+                    //创建缓存文件夹
+                    string folderPath = Path.Combine(App.CurrentPath, "Watermark");
+                    //有可能因为其他原因存在同名文件,导致创建文件夹失败,需要先删除同名文件
+                    //保险措施(猜测)
+                    if (File.Exists(folderPath))
+                    {
+                        File.Delete(folderPath);
+                    }
+
+                    DirectoryInfo tempfolder = new DirectoryInfo(folderPath);
+                    if (!tempfolder.Exists)
+                    {
+                        tempfolder.Create();
+                    }
+
+                    //预览图缓存
+                    string saveName = Guid.NewGuid().ToString();
+                    string savePath = Path.Combine(folderPath, saveName);
+                    System.Windows.Size pageSize = new System.Windows.Size { Width = 128, Height = 160 };
+                    CPDFDocument tempDocument = CPDFDocument.CreateDocument();
+                    if (tempDocument != null)
+                    {
+                        tempDocument.InsertPage(0, pageSize.Width, pageSize.Height, null);
+                        CreateWatermark(tempDocument, WatermarkInfo);
+
+                        //获取透明背景的图片
+                        var bitmap = ToolMethod.RenderPageBitmapNoWait(tempDocument, (int)pageSize.Width, (int)pageSize.Height, 0, false, false, 0x00FFFFFF);
+                        using (FileStream stream = new FileStream(savePath, FileMode.Create))
+                        {
+                            bitmap.Save(stream, System.Drawing.Imaging.ImageFormat.Png);
+                        }
+
+                        watermarkItem.previewImagePath = savePath;
+                        tempDocument.Release();
+
+                        Settings.Default.WatermarkTemplateList[TemplateWatermarkItem.listIndex] = watermarkItem;
+                        Settings.Default.Save();
+                    }
+                }
+                catch
+                {
+
+                }
                 this.eventAggregator.GetEvent<EnterTemplateListOrCreateEvent>().Publish(new EnumTemplateListOrCreateUnicode
                 {
                     Unicode = Unicode,

+ 6 - 72
PDF Office/ViewModels/EditTools/Watermark/WatermarkTemplateListFileContentViewModel.cs

@@ -171,10 +171,12 @@ namespace PDF_Office.ViewModels.EditTools.Watermark
             {
                 int temp = 0;
                 var template = Settings.Default.WatermarkTemplateList[temp];
-                Settings.Default.WatermarkTemplateList.Remove(template);
-                Settings.Default.Save();
-
-                WatermarkModFileCollection.Remove(template);
+                if (template.type == ComPDFKit.PDFWatermark.C_Watermark_Type.WATERMARK_TYPE_IMG)
+                {
+                    Settings.Default.WatermarkTemplateList.Remove(template);
+                    Settings.Default.Save();
+                    WatermarkModFileCollection.Remove(template);
+                }
             }
             GetWatermarkSource();
         }
@@ -300,74 +302,6 @@ namespace PDF_Office.ViewModels.EditTools.Watermark
             });
         }
 
-        public static BitmapSource ToBitmapSource(System.Drawing.Bitmap image)
-        {
-            IntPtr ptr = image.GetHbitmap();//obtain the Hbitmap
-            BitmapSource bs = System.Windows.Interop.Imaging.CreateBitmapSourceFromHBitmap
-            (
-                ptr,
-                IntPtr.Zero,
-                Int32Rect.Empty,
-                System.Windows.Media.Imaging.BitmapSizeOptions.FromEmptyOptions()
-            );
-            return bs;
-        }
-
-
-        public async Task RenderBitmap(WatermarkItem WatermarkItem)
-        {
-            CPDFDocument newDoc = CPDFDocument.CreateDocument();
-            newDoc.InsertPage(0, 595, 842, null);
-            WatermarkInfo watermarkInfo = new WatermarkInfo();
-            ConvertItemToInfo(WatermarkItem, ref watermarkInfo);
-            CreateWatermark(newDoc, watermarkInfo);
-            CPDFPage page = newDoc.PageAtIndex(0, true);
-
-            byte[] bmp_data = new byte[(int)page.PageSize.Width * (int)page.PageSize.Height * 4];
-            Bitmap bitmap = await ToolMethod.RenderPageBitmap(newDoc, (int)(page.PageSize.Width * 1.4), (int)(page.PageSize.Height * 1.4), 0, true, true);
-            ImageSource = ToBitmapSource(bitmap);
-            newDoc.ReleasePages();
-        }
-
-        public void CreateWatermark(CPDFDocument document, WatermarkInfo watermarkInfo)
-        {
-            if (watermarkInfo != null)
-            {
-                document.DeleteWatermarks();
-                CPDFWatermark watermark;
-                if (watermarkInfo.WatermarkType == C_Watermark_Type.WATERMARK_TYPE_TEXT)
-                {
-                    watermark = document.InitWatermark(C_Watermark_Type.WATERMARK_TYPE_TEXT);
-                    watermark.SetText(watermarkInfo.Text);
-                    watermark.SetFontName(watermarkInfo.FontName);
-                    watermark.SetFontSize(watermarkInfo.TextSize);
-                    watermark.SetTextRGBColor(watermarkInfo.TextColor);
-                }
-                else
-                {
-                    watermark = document.InitWatermark(C_Watermark_Type.WATERMARK_TYPE_IMG);
-                    if (watermarkInfo.ImageArray != null)
-                    {
-                        watermark.SetImage(watermarkInfo.ImageArray, watermarkInfo.ImageWidth, watermarkInfo.ImageHeight);
-                    }
-                    watermark.SetScale(0.1f);
-                }
-                watermark.SetRotation(watermarkInfo.Rotation);
-                watermark.SetOpacity(watermarkInfo.Opacity);
-                watermark.SetFront(watermarkInfo.IsFront);
-                watermark.SetVertalign(watermarkInfo.WatermarkVertalign);
-                watermark.SetHorizalign(watermarkInfo.WatermarkHorizalign);
-                watermark.SetFullScreen(watermarkInfo.Isfull);
-                watermark.SetVertOffset(watermarkInfo.VertOffset);
-                watermark.SetHorizOffset(watermarkInfo.HorizOffset);
-                watermark.SetHorizontalSpacing(watermarkInfo.HorizontalSpacing);
-                watermark.SetVerticalSpacing(watermarkInfo.VerticalSpacing);
-                watermark.SetPages("0");
-                Trace.WriteLine("IsCreateWatermark: " + watermark.CreateWatermark());
-                Trace.WriteLine("IsUpdateWatermark: " + watermark.UpdateWatermark());
-            }
-        }
-
 
         public bool IsNavigationTarget(NavigationContext navigationContext)
         {

+ 6 - 4
PDF Office/ViewModels/EditTools/Watermark/WatermarkTemplateListTextContentViewModel.cs

@@ -153,10 +153,12 @@ namespace PDF_Office.ViewModels.EditTools.Watermark
             {
                 int temp = 0;
                 var template = Settings.Default.WatermarkTemplateList[temp];
-                Settings.Default.WatermarkTemplateList.Remove(template);
-                Settings.Default.Save();
-
-                WatermarkModTextCollection.Remove(template);
+                if (template.type == ComPDFKit.PDFWatermark.C_Watermark_Type.WATERMARK_TYPE_IMG)
+                {
+                    Settings.Default.WatermarkTemplateList.Remove(template);
+                    Settings.Default.Save();
+                    WatermarkModTextCollection.Remove(template);
+                }
             }
             GetWatermarkSource();
         }

+ 2 - 0
PDF Office/ViewModels/ViewContentViewModel.cs

@@ -467,6 +467,8 @@ namespace PDF_Office.ViewModels
                     break;
 
                 case "TabItemPageEdit":
+                case "HeaderFooterContent":
+                case "BatesContent":
                 case "WatermarkContent":
                 case "BackgroundContent":
                     ToolContentVisible = Visibility.Visible;

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

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

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

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

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

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

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

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

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

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

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

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

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

@@ -0,0 +1,24 @@
+<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/"             
+             prism:ViewModelLocator.AutoWireViewModel="True"
+              xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
+             xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006" 
+             mc:Ignorable="d"
+             d:DesignHeight="720"
+             d:DesignWidth="260" >
+    <Grid>
+        <Grid.RowDefinitions>
+            <RowDefinition Height="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>
+            <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>
+</UserControl>

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

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

+ 78 - 0
PDF Office/Views/EditTools/HeaderFooter/HeaderFooterContent.xaml

@@ -0,0 +1,78 @@
+<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: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>
+</UserControl>

+ 15 - 0
PDF Office/Views/EditTools/HeaderFooter/HeaderFooterContent.xaml.cs

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

+ 149 - 0
PDF Office/Views/EditTools/HeaderFooter/HeaderFooterCreateContent.xaml

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

+ 15 - 0
PDF Office/Views/EditTools/HeaderFooter/HeaderFooterCreateContent.xaml.cs

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

+ 37 - 0
PDF Office/Views/EditTools/HeaderFooter/HeaderFooterDocumentContent.xaml

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

+ 15 - 0
PDF Office/Views/EditTools/HeaderFooter/HeaderFooterDocumentContent.xaml.cs

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

+ 24 - 0
PDF Office/Views/EditTools/HeaderFooter/HeaderFooterTemplateListContent.xaml

@@ -0,0 +1,24 @@
+<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/"             
+             prism:ViewModelLocator.AutoWireViewModel="True"
+              xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
+             xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006" 
+             mc:Ignorable="d"
+             d:DesignHeight="720"
+             d:DesignWidth="260" >
+    <Grid>
+        <Grid.RowDefinitions>
+            <RowDefinition Height="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>
+            <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>
+</UserControl>

+ 15 - 0
PDF Office/Views/EditTools/HeaderFooter/HeaderFooterTemplateListContent.xaml.cs

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

+ 3 - 8
PDF Office/Views/EditTools/Watermark/WatermarkTemplateListFileContent.xaml

@@ -53,14 +53,9 @@
             </ListBox.ItemContainerStyle>
             <ListBox.ItemTemplate>
                 <DataTemplate DataType="{x:Type data:WatermarkItem}">
-                    <StackPanel Name="itemPanel" >
+                    <StackPanel Name="itemPanel" Loaded="itemPanel_Loaded">
                         <Grid Height="160" Width=" 128" >
-                            <Label  Height="160" Width=" 128"  >
-                                <Image Source="pack://application:,,,/Resources/EditTools/watermark_bg.png"></Image>
-                            </Label>
-                            <Label  Height="160" Width=" 128">
-                                <Image Source="{Binding ImageSource}"></Image>
-                            </Label>
+                            <Image  Name="WatermarkPreview" Stretch="Fill" RenderOptions.BitmapScalingMode="HighQuality" />
                             <Button Name="EditTemplateBtn" Height="43" Width="63" HorizontalAlignment="Left" VerticalAlignment="Bottom" Click="EditTemplateBtn_Click"></Button>
                             <Button Name="DeleteTemplateBtn"  Height="43" Width="63" HorizontalAlignment="Right" VerticalAlignment="Bottom" Click="DeleteTemplateBtn_Click" >
                             </Button>
@@ -82,7 +77,7 @@
         <Grid Width="140" Margin="64,154,56,312" Visibility="{Binding CreateTemplateVisible, Mode=OneWay}">
             <StackPanel Orientation="Vertical">
                 <Label Height="87" Width="87" HorizontalAlignment="Center" Background="BlueViolet"></Label>
-                <TextBlock Height="24" FontSize="14" Text="请先创建一个背景模板" Margin="0,8,0,0" VerticalAlignment="Center" ></TextBlock>
+                <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>

+ 20 - 0
PDF Office/Views/EditTools/Watermark/WatermarkTemplateListFileContent.xaml.cs

@@ -1,10 +1,14 @@
 using ComPDFKitViewer;
 using PDF_Office.ViewModels.Dialog.HomePageToolsDialogs;
 using PDF_Office.ViewModels.EditTools.Watermark;
+using PDFSettings;
+using System;
 using System.Collections;
 using System.Diagnostics;
+using System.IO;
 using System.Windows;
 using System.Windows.Controls;
+using System.Windows.Media.Imaging;
 
 namespace PDF_Office.Views.EditTools.Watermark
 {
@@ -59,5 +63,21 @@ namespace PDF_Office.Views.EditTools.Watermark
         {
             viewModel.EditTemplateItemCommand?.Execute(sender);
         }
+        private void itemPanel_Loaded(object sender, RoutedEventArgs e)
+        {
+            try
+            {
+                StackPanel panel = sender as StackPanel;
+                var data = panel.DataContext as WatermarkItem;
+                var img = panel.FindName("WatermarkPreview") as Image;
+                Trace.WriteLine(data.previewImagePath);
+                if (!string.IsNullOrEmpty(data.previewImagePath) && File.Exists(data.previewImagePath))
+                {
+                    BitmapSource bmp = new BitmapImage(new Uri(data.previewImagePath));
+                    img.Source = bmp;
+                }
+            }
+            catch { }
+        }
     }
 }

+ 3 - 8
PDF Office/Views/EditTools/Watermark/WatermarkTemplateListTextContent.xaml

@@ -53,14 +53,9 @@
             </ListBox.ItemContainerStyle>
             <ListBox.ItemTemplate>
                 <DataTemplate DataType="{x:Type data:WatermarkItem}">
-                    <StackPanel Name="itemPanel" >
+                    <StackPanel Name="itemPanel" Loaded="itemPanel_Loaded">
                         <Grid Height="160" Width=" 128">
-                            <Label  Height="160" Width=" 128"  >
-                                <Image Source="pack://application:,,,/Resources/EditTools/watermark_bg.png"></Image>
-                            </Label>
-                            <Label  Height="160" Width=" 128">
-                                <Image Source="{Binding WatermarkImageSource}"></Image>
-                            </Label>
+                            <Image  Name="WatermarkPreview" Stretch="Fill" RenderOptions.BitmapScalingMode="HighQuality"/>
                             <Button Name="EditTemplateBtn" Height="43" Width="63" HorizontalAlignment="Left" VerticalAlignment="Bottom" Click="EditTemplateBtn_Click"></Button>
                             <Button Name="DeleteTemplateBtn"  Height="43" Width="63" HorizontalAlignment="Right" VerticalAlignment="Bottom" Click="DeleteTemplateBtn_Click" >
                             </Button>
@@ -82,7 +77,7 @@
         <Grid Width="140" Margin="64,154,56,312" Visibility="{Binding CreateTemplateVisible, Mode=OneWay}">
             <StackPanel Orientation="Vertical">
                 <Label Height="87" Width="87" HorizontalAlignment="Center" Background="BlueViolet"></Label>
-                <TextBlock Height="24" FontSize="14" Text="请先创建一个背景模板" Margin="0,8,0,0" VerticalAlignment="Center" ></TextBlock>
+                <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>

+ 21 - 0
PDF Office/Views/EditTools/Watermark/WatermarkTemplateListTextContent.xaml.cs

@@ -1,7 +1,12 @@
 using ComPDFKitViewer;
 using PDF_Office.ViewModels.EditTools.Watermark;
+using PDFSettings;
+using System.Diagnostics;
+using System;
 using System.Windows;
 using System.Windows.Controls;
+using System.Windows.Media.Imaging;
+using System.IO;
 
 namespace PDF_Office.Views.EditTools.Watermark
 {
@@ -50,5 +55,21 @@ namespace PDF_Office.Views.EditTools.Watermark
         {
             viewModel.EditTemplateItemCommand?.Execute(sender);
         }
+        private void itemPanel_Loaded(object sender, RoutedEventArgs e)
+        {
+            try
+            {
+                StackPanel panel = sender as StackPanel;
+                var data = panel.DataContext as WatermarkItem;
+                var img = panel.FindName("WatermarkPreview") as Image;
+                Trace.WriteLine(data.previewImagePath);
+                if (!string.IsNullOrEmpty(data.previewImagePath) && File.Exists(data.previewImagePath))
+                {
+                    BitmapSource bmp = new BitmapImage(new Uri(data.previewImagePath));
+                    img.Source = bmp;
+                }
+            }
+            catch { }
+        }
     }
 }

+ 2 - 2
PDF Office/Views/Tools/ToolsBarContent.xaml

@@ -110,7 +110,7 @@
                         </Path>
                     </StackPanel>
                 </Button>
-                <Button Style="{StaticResource InsideBarBtnStyle }" >
+                <Button Name="HeaderFooterContent" Style="{StaticResource InsideBarBtnStyle }" Command="{Binding SetEditToolsCommand }" CommandParameter="{Binding ElementName=HeaderFooterContent}">
 
                     <StackPanel Orientation="Horizontal" Margin="12 0 12 0">
                         <StackPanel Margin="0,0,8,0">
@@ -124,7 +124,7 @@
                         </Path>
                     </StackPanel>
                 </Button>
-                <Button Style="{StaticResource InsideBarBtnStyle }" >
+                <Button Name="BatesContent" Style="{StaticResource InsideBarBtnStyle }" Command="{Binding SetEditToolsCommand }" CommandParameter="{Binding ElementName=BatesContent}">
 
                     <StackPanel Orientation="Horizontal" Margin="12 0 12 0">
                         <StackPanel Margin="0,0,8,0">

+ 4 - 1
PDFSettings/WatermarkTemplateList.cs

@@ -73,7 +73,10 @@ namespace PDFSettings
         /// </summary>
         public float horizOffset = 0;
 
-        public string previeImagePath = "";
+        /// <summary>
+        /// 预览缓存路径
+        /// </summary>
+        public string previewImagePath = "";
 
         /// <summary>
         /// 图片数据缓存