liyijie 2 سال پیش
والد
کامیت
003186f362
23فایلهای تغییر یافته به همراه684 افزوده شده و 195 حذف شده
  1. 39 0
      PDF Office/Helper/HomePageEditHelper.cs
  2. 7 6
      PDF Office/SDKLisence.xml
  3. 137 22
      PDF Office/ViewModels/Dialog/HomePageToolsDialogs/HomePageBatchProcessing/HomePageBackground/HomePageBackgroundDialogViewModel.cs
  4. 3 4
      PDF Office/ViewModels/Dialog/HomePageToolsDialogs/HomePageBatchProcessing/HomePageBackground/HomePageBackgroundTemplateListBaseContentViewModel.cs
  5. 2 0
      PDF Office/ViewModels/Dialog/HomePageToolsDialogs/HomePageBatchProcessing/HomePageBackground/HomePageBackgroundTemplateListColorContentViewModel.cs
  6. 10 3
      PDF Office/ViewModels/Dialog/HomePageToolsDialogs/HomePageBatchProcessing/HomePageBackground/HomePageBackgroundTemplateListFileContentViewModel.cs
  7. 119 14
      PDF Office/ViewModels/Dialog/HomePageToolsDialogs/HomePageBatchProcessing/HomePageBates/HomePageBatesDialogViewModel.cs
  8. 4 2
      PDF Office/ViewModels/Dialog/HomePageToolsDialogs/HomePageBatchProcessing/HomePageBates/HomePageBatesTemplateListContentViewModel.cs
  9. 10 3
      PDF Office/ViewModels/Dialog/HomePageToolsDialogs/HomePageBatchProcessing/HomePageConverter/HomePageConverterDialogViewModel.cs
  10. 113 11
      PDF Office/ViewModels/Dialog/HomePageToolsDialogs/HomePageBatchProcessing/HomePageHeaderFooter/HomePageHeaderFooterDialogViewModel.cs
  11. 4 1
      PDF Office/ViewModels/Dialog/HomePageToolsDialogs/HomePageBatchProcessing/HomePageHeaderFooter/HomePageHeaderFooterTemplateListContentViewModel.cs
  12. 0 1
      PDF Office/ViewModels/Dialog/HomePageToolsDialogs/HomePageBatchProcessing/HomePageRemoveDialogViewModel.cs
  13. 133 14
      PDF Office/ViewModels/Dialog/HomePageToolsDialogs/HomePageBatchProcessing/HomePageWatermark/HomePageWatermarkDialogViewModel.cs
  14. 5 0
      PDF Office/ViewModels/Dialog/HomePageToolsDialogs/HomePageBatchProcessing/HomePageWatermark/HomePageWatermarkTemplateListBaseContentViewModel.cs
  15. 8 2
      PDF Office/ViewModels/Dialog/HomePageToolsDialogs/HomePageBatchProcessing/HomePageWatermark/HomePageWatermarkTemplateListFileContentViewModel.cs
  16. 8 2
      PDF Office/ViewModels/Dialog/HomePageToolsDialogs/HomePageBatchProcessing/HomePageWatermark/HomePageWatermarkTemplateListTextContentViewModel.cs
  17. 2 38
      PDF Office/ViewModels/EditTools/HeaderFooter/HeaderFooterDocumentContentViewModel.cs
  18. 63 63
      PDF Office/Views/Dialog/HomePageToolsDialogs/HomePageBatchProcessing/HomePageBackground/HomePageBackgroundCreateBaseContent.xaml
  19. 2 2
      PDF Office/Views/Dialog/HomePageToolsDialogs/HomePageBatchProcessing/HomePageBackground/HomePageBackgroundDialog.xaml
  20. 3 3
      PDF Office/Views/Dialog/HomePageToolsDialogs/HomePageBatchProcessing/HomePageBates/HomePageBatesDialog.xaml
  21. 8 0
      PDF Office/Views/Dialog/HomePageToolsDialogs/HomePageBatchProcessing/HomePageConverter/HomePageConverterDialog.xaml
  22. 2 2
      PDF Office/Views/Dialog/HomePageToolsDialogs/HomePageBatchProcessing/HomePageHeaderFooter/HomePageHeaderFooterDialog.xaml
  23. 2 2
      PDF Office/Views/Dialog/HomePageToolsDialogs/HomePageBatchProcessing/HomePageWatermark/HomePageWatermarkDialog.xaml

+ 39 - 0
PDF Office/Helper/HomePageEditHelper.cs

@@ -8,6 +8,7 @@ using System.Text;
 using System.Threading.Tasks;
 using System.Windows.Documents;
 using static System.Windows.Forms.VisualStyles.VisualStyleElement;
+using ComPDFKit.PDFDocument;
 
 namespace PDF_Office.Helper
 {
@@ -148,6 +149,44 @@ namespace PDF_Office.Helper
 
             }
         }
+
+        public static string ReverseDate(string str,CPDFDocument Document)
+        {
+            string yyyy = DateTime.Now.ToString("yyyy");
+            string yy = DateTime.Now.ToString("yy");
+            string mm = DateTime.Now.ToString("MM");
+            string m = DateTime.Now.ToString("%M");
+            string dd = DateTime.Now.ToString("dd");
+            string d = DateTime.Now.ToString("%d");
+            str = str.Replace("<<m/d>>", m + "/" + d)
+            .Replace("<<m/d/yy>>", m + "/" + d + "/" + yy)
+            .Replace("<<m/d/yyyy>>", m + "/" + d + "/" + yyyy)
+            .Replace("<<mm/dd/yy>>", mm + "/" + dd + "/" + yy)
+            .Replace("<<mm/dd/yyyy>>", mm + "/" + dd + "/" + yyyy)
+            .Replace("<<d/m/yy>>", d + "/" + m + "/" + yy)
+            .Replace("<<d/m/yyyy>>", d + "/" + m + "/" + yyyy)
+            .Replace("<<dd/mm/yy>>", dd + "/" + mm + "/" + yy)
+            .Replace("<<dd/mm/yyyy>>", dd + "/" + mm + "/" + yyyy)
+            .Replace("<<mm/yy>>", mm + "/" + yy)
+            .Replace("<<mm/yyyy>>", mm + "/" + yyyy)
+            .Replace("<<m.d.yy>>", m + "." + d + "." + yy)
+            .Replace("<<m.d.yyyy>>", m + "." + d + "." + yyyy)
+            .Replace("<<mm.dd.yy>>", mm + "." + dd + "." + yy)
+            .Replace("<<mm.dd.yyyy>>", mm + "." + dd + "." + yyyy)
+            .Replace("<<mm.yy>>", mm + "." + yy)
+            .Replace("<<mm.yyyy>>", mm + "." + yyyy)
+            .Replace("<<d.m.yy>>", d + "." + m + "." + yy)
+            .Replace("<<d.m.yyyy>>", d + "." + m + "." + yyyy)
+            .Replace("<<dd.mm.yy>>", dd + "." + mm + "." + yy)
+            .Replace("<<dd.mm.yyyy>>", dd + "." + mm + "." + yyyy)
+            .Replace("<<yy-mm-dd>>", yy + "-" + mm + "-" + dd)
+            .Replace("<<yyyy-mm-dd>>", yyyy + "-" + mm + "-" + dd)
+            .Replace("<<1 of n>>", "<<1>>" + " of " + Document.PageCount)
+            .Replace("<<1/n>>", "<<1>>" + "/" + Document.PageCount)
+            .Replace("<<Page 1>>", "Page" + "<<1>>")
+            .Replace("<<Page 1 of n>>", "Page " + "<<1>>" + " of " + Document.PageCount);
+            return str;
+        }
     }
 
 }

+ 7 - 6
PDF Office/SDKLisence.xml

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

+ 137 - 22
PDF Office/ViewModels/Dialog/HomePageToolsDialogs/HomePageBatchProcessing/HomePageBackground/HomePageBackgroundDialogViewModel.cs

@@ -18,6 +18,9 @@ using Prism.Events;
 using ComPDFKitViewer.PdfViewer;
 using PDF_Office.EventAggregators;
 using PDFSettings;
+using PDF_Office.Model.EditTools.Bates;
+using PDF_Office.Model.EditTools.Background;
+using static System.Windows.Forms.VisualStyles.VisualStyleElement.TrayNotify;
 
 namespace PDF_Office.ViewModels.Dialog.HomePageToolsDialogs.HomePageBatchProcessing.HomePageBackground
 {
@@ -26,11 +29,14 @@ namespace PDF_Office.ViewModels.Dialog.HomePageToolsDialogs.HomePageBatchProcess
         #region 参数和属性
         private List<string> fileNames;
 
+        public BackgroundInfo BackgroundInfo;
 
         private CPDFDocument tempDocument;
 
         public string PageNumber = "";
 
+        private CPDFBackground background;
+
         public IRegionManager backgroundRegion;
         public IEventAggregator eventAggregator;
 
@@ -184,6 +190,30 @@ namespace PDF_Office.ViewModels.Dialog.HomePageToolsDialogs.HomePageBatchProcess
 
             }
         }
+
+        private string createGridSpan = "1";
+        public string CreateGridSpan
+        {
+            get { return createGridSpan; }
+            set
+            {
+                SetProperty(ref createGridSpan, value);
+                RaisePropertyChanged();
+
+            }
+        }
+
+        private Visibility createGridSpanVisibility = Visibility.Visible;
+        public Visibility CreateGridSpanVisibility
+        {
+            get { return createGridSpanVisibility; }
+            set
+            {
+                SetProperty(ref createGridSpanVisibility, value);
+                RaisePropertyChanged();
+
+            }
+        }
         #endregion
 
         #region 委托声明
@@ -228,10 +258,14 @@ namespace PDF_Office.ViewModels.Dialog.HomePageToolsDialogs.HomePageBatchProcess
             EnumTemplateListOrCreate enumTemplateListOrCreate = enumTemplateListOrCreateunicode.Status;
             if (enumTemplateListOrCreate == EnumTemplateListOrCreate.StatusTemplate)
             {
+                CreateGridSpan = "1";
+                CreateGridSpanVisibility = Visibility.Visible;
                 EnterSelectedContent(TemplateListBaseName);
             }
             else
             {
+                CreateGridSpan = "2";
+                CreateGridSpanVisibility = Visibility.Collapsed;
                 EnterSelectedContent(CreateBaseName);
             }
         }
@@ -239,6 +273,7 @@ namespace PDF_Office.ViewModels.Dialog.HomePageToolsDialogs.HomePageBatchProcess
         {
             NavigationParameters param = new NavigationParameters();
             param.Add(ParameterNames.PDFViewer, PDFViewer);
+            param.Add("ViewModel", this);
             if (SelectedContentName == TemplateListBaseName)
             {
                 param.Add("CurrentCreateModName", CurrentCreateMod);
@@ -286,6 +321,8 @@ namespace PDF_Office.ViewModels.Dialog.HomePageToolsDialogs.HomePageBatchProcess
             param.Add("BackgroundItem", backgroundItem);
             backgroundRegion.RequestNavigate(BackgroundSettingsRegionName, CreateBaseName, param);
             BackgroundSettingsVisible = Visibility.Visible;
+            CreateGridSpan = "2";
+            CreateGridSpanVisibility = Visibility.Collapsed;
         }
 
         private void create()
@@ -295,34 +332,72 @@ namespace PDF_Office.ViewModels.Dialog.HomePageToolsDialogs.HomePageBatchProcess
             BackgroundGridIsEnabled = "False";
             foreach (var filename in fileNames)
             {
-            //    FileInfo fileinfo = new FileInfo(filename);
-            //    string OutputPath = fileinfo.DirectoryName;
-            //    char[] enumerationSeparator = new char[] { ',' };
-            //    char[] rangeSeparator = new char[] { '-' };
-            //    List<int> PageIndexLists = new List<int>();
-            //    CPDFDocument document = CPDFDocument.InitWithFilePath(filename);
-            //    if (document == null)
-            //    {
-            //        PDFDataTable.Rows[fileNamesIndex]["FileState"] = "文件出错";
-            //        continue;
-            //    }
-            //    if (!CommonHelper.GetPagesInRange(ref PageIndexLists, "1-" + document.PageCount.ToString(), document.PageCount, enumerationSeparator, rangeSeparator))
-            //    { //TODO
-            //        Trace.WriteLine("输入不对");
-            //        MessageBoxEx.Show("输入不对");
-            //        return;
-            //    }
-
-            //    document.Release();
-                PDFDataTable.Rows[fileNamesIndex]["FilePageRangeSelectIndex"] = "2";
+                FileInfo fileinfo = new FileInfo(filename);
+                string OutputPath = fileinfo.DirectoryName;
+                char[] enumerationSeparator = new char[] { ',' };
+                char[] rangeSeparator = new char[] { '-' };
+                List<int> PageIndexLists = new List<int>();
+                CPDFDocument document = CPDFDocument.InitWithFilePath(filename);
+                if (document == null)
+                {
+                    PDFDataTable.Rows[fileNamesIndex]["FileState"] = "文件出错";
+                    continue;
+                }
+                CreateBackground(document);
+                document.WriteToFilePath(filename + "_Background.pdf");
+                //    if (!CommonHelper.GetPagesInRange(ref PageIndexLists, "1-" + document.PageCount.ToString(), document.PageCount, enumerationSeparator, rangeSeparator))
+                //    { //TODO
+                //        Trace.WriteLine("输入不对");
+                //        MessageBoxEx.Show("输入不对");
+                //        return;
+                //    }
+
+                //    document.Release();
+                //PDFDataTable.Rows[fileNamesIndex]["FilePageRangeSelectIndex"] = "2";
                 PDFDataTable.Rows[fileNamesIndex]["FileState"] = "完成";
-                PDFCurrentDataTable.Rows[fileNamesIndex]["FilePageRangeText"] = "2";
-                PDFCurrentDataTable.Rows[fileNamesIndex]["FilePageRangeSelectIndex"] = "2";
+                //PDFCurrentDataTable.Rows[fileNamesIndex]["FilePageRangeText"] = "2";
+                //PDFCurrentDataTable.Rows[fileNamesIndex]["FilePageRangeSelectIndex"] = "2";
                 PDFCurrentDataTable.Rows[fileNamesIndex]["FileState"] = "完成";
                 fileNamesIndex++;
             }
             BackgroundGridIsEnabled = "True";
         }
+
+        public void CreateBackground(CPDFDocument document)
+        {
+            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);
+                }
+                if (!BackgroundInfo.IsRelativeScale)
+                {
+                    background.SetScale(1);
+                }
+                else
+                {
+                    background.SetScale((float)(BackgroundInfo.Scale / 100));
+                }
+                background.SetRotation((float)((BackgroundInfo.Rotation / 180) * Math.PI));
+                background.SetOpacity((byte)(((float)BackgroundInfo.Opacity / 100) * 255));
+                background.SetVertalign(BackgroundInfo.Vertalign);
+                background.SetHorizalign(BackgroundInfo.Horizalign);
+                background.SetXOffset(BackgroundInfo.HorizOffset);
+                background.SetYOffset(BackgroundInfo.VertOffset);
+                background.SetAllowsPrint(true);
+                background.SetAllowsView(true);
+                background.SetPages(getFilePageRange(document, PDFCurrentDataTable.Rows[fileNamesIndex]["FilePageRangeText"].ToString(), PDFCurrentDataTable.Rows[fileNamesIndex]["FilePageRangeSelectIndex"].ToString()));
+                background.Update();
+            }
+        }
         #endregion
 
         #region 批量处理逻辑函数
@@ -450,6 +525,46 @@ namespace PDF_Office.ViewModels.Dialog.HomePageToolsDialogs.HomePageBatchProcess
             }
         }
 
+        /// <summary>
+        /// 更新Currentlistview显示
+        /// pagerangetext 自定义页面范围字符串  pagerangeselectindex combobox下拉索引(0全部页面 1奇数页 2偶数页 3自定义页面)
+        /// </summary>
+        public void updateFilesPageRange(string pagerangetext = "1", string pagerangeselectindex = "0")
+        {
+            for (int i = 0; fileNames.Count > i; i++)
+            {
+
+                PDFDataTable.Rows[i]["FilePageRangeText"] = pagerangetext;
+                PDFDataTable.Rows[i]["FilePageRangeSelectIndex"] = pagerangeselectindex;
+                PDFCurrentDataTable.Rows[i]["FilePageRangeText"] = pagerangetext;
+                PDFCurrentDataTable.Rows[i]["FilePageRangeSelectIndex"] = pagerangeselectindex;
+            }
+        }
+        /// <summary>
+        /// 获取文件列表单个文件对应的页码范围
+        /// document 文档对象 pagerangetext 自定义页面范围字符串  pagerangeselectindex combobox下拉索引(0全部页面 1奇数页 2偶数页 3自定义页面)
+        /// </summary>
+        public string getFilePageRange(CPDFDocument document, string pagerangetext = "1", string pagerangeselectindex = "0")
+        {
+            string filePageRange = "1";
+            EditToolsHelper.GetPageRange(int.Parse(pagerangeselectindex), document, ref filePageRange, pagerangetext);
+            return filePageRange;
+        }
+
+        /// <summary>
+        /// 获取文件列表单个文件对应的页码范围
+        /// document 文档对象 pagerangetext 自定义页面范围字符串  pagerangeselectindex combobox下拉索引(0全部页面 1奇数页 2偶数页 3自定义页面)
+        /// </summary>
+        public bool isEvenPage(CPDFDocument document)
+        {
+            bool isevenpage = false;
+            if (document.PageCount > 1)
+            {
+                isevenpage = true;
+            }
+            return isevenpage;
+        }
+
         /// <summary>
         /// 逆序int类型集合
         /// </summary>

+ 3 - 4
PDF Office/ViewModels/Dialog/HomePageToolsDialogs/HomePageBatchProcessing/HomePageBackground/HomePageBackgroundTemplateListBaseContentViewModel.cs

@@ -14,7 +14,7 @@ namespace PDF_Office.ViewModels.Dialog.HomePageToolsDialogs.HomePageBatchProcess
     {
         public IRegionManager backgroundTemplateListRegion;
         private readonly IEventAggregator eventAggregator;
-
+        private HomePageBackgroundDialogViewModel homePageBackgroundDialogViewModel;
         private string BackgroundTemplateListColorContentName = "HomePageBackgroundTemplateListColorContent";
         private string BackgroundTemplateListFileContentName = "HomePageBackgroundTemplateListFileContent";
 
@@ -75,7 +75,7 @@ namespace PDF_Office.ViewModels.Dialog.HomePageToolsDialogs.HomePageBatchProcess
         public void EnterSelectedTemplateListMod(string currentTemplateListName)
         {
             NavigationParameters param = new NavigationParameters();
-            param.Add("UniCode", unicode);
+            param.Add("ViewModel", homePageBackgroundDialogViewModel);
             backgroundTemplateListRegion.RequestNavigate(BackgroundTemplateListRegionName, currentTemplateListName);
             backgroundTemplateListVisible = System.Windows.Visibility.Visible;
         }
@@ -106,8 +106,7 @@ namespace PDF_Office.ViewModels.Dialog.HomePageToolsDialogs.HomePageBatchProcess
 
         public void OnNavigatedTo(NavigationContext navigationContext)
         {
-
-            navigationContext.Parameters.TryGetValue<string>("UniCode", out unicode);
+            navigationContext.Parameters.TryGetValue<HomePageBackgroundDialogViewModel>("ViewModel", out homePageBackgroundDialogViewModel);
             if (IsFirstEnter)
             {
                 CurrentTemplateListModName = BackgroundTemplateListColorContentName;

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

@@ -21,6 +21,7 @@ namespace PDF_Office.ViewModels.Dialog.HomePageToolsDialogs.HomePageBatchProcess
         private readonly IEventAggregator eventAggregator;
         public BackgroundInfo BackgroundInfo = new BackgroundInfo();
         public BackgroundItem BackgroundItem = new BackgroundItem();
+        private HomePageBackgroundDialogViewModel homePageBackgroundDialogViewModel;
         public int TemplateIndex = 0;
 
         private ObservableCollection<BackgroundItem> backgroundModcolorCollection = new ObservableCollection<BackgroundItem>();
@@ -231,6 +232,7 @@ namespace PDF_Office.ViewModels.Dialog.HomePageToolsDialogs.HomePageBatchProcess
 
         public void OnNavigatedTo(NavigationContext navigationContext)
         {
+            navigationContext.Parameters.TryGetValue<HomePageBackgroundDialogViewModel>("ViewModel", out homePageBackgroundDialogViewModel);
             InitBackgroundTemplateList();
         }
     }

+ 10 - 3
PDF Office/ViewModels/Dialog/HomePageToolsDialogs/HomePageBatchProcessing/HomePageBackground/HomePageBackgroundTemplateListFileContentViewModel.cs

@@ -1,4 +1,5 @@
-using PDF_Office.EventAggregators;
+using Microsoft.Office.Interop.Word;
+using PDF_Office.EventAggregators;
 using PDF_Office.Model.EditTools.Background;
 using PDF_Office.Properties;
 using PDFSettings;
@@ -21,6 +22,7 @@ namespace PDF_Office.ViewModels.Dialog.HomePageToolsDialogs.HomePageBatchProcess
         private readonly IEventAggregator eventAggregator;
         public BackgroundInfo BackgroundInfo = new BackgroundInfo();
         public BackgroundItem BackgroundItem = new BackgroundItem();
+        private HomePageBackgroundDialogViewModel homePageBackgroundDialogViewModel;
         public int TemplateIndex = 0;
 
         public ObservableCollection<BackgroundItem> backgroundModFileCollection = new ObservableCollection<BackgroundItem>();
@@ -211,9 +213,13 @@ namespace PDF_Office.ViewModels.Dialog.HomePageToolsDialogs.HomePageBatchProcess
             }
         }
 
-        public void SendTemplateItemToDocument(BackgroundItem BackgroundItem)
+        public void SendTemplateItemToDocument(BackgroundItem template)
         {
-            ConvertItemToInfo(BackgroundItem, ref BackgroundInfo);
+            if (template != null)
+            {
+                ConvertItemToInfo(template, ref BackgroundInfo);
+                homePageBackgroundDialogViewModel.BackgroundInfo = BackgroundInfo;
+            }
         }
 
         public void SelectTemplateItem(object e)
@@ -235,6 +241,7 @@ namespace PDF_Office.ViewModels.Dialog.HomePageToolsDialogs.HomePageBatchProcess
 
         public void OnNavigatedTo(NavigationContext navigationContext)
         {
+            navigationContext.Parameters.TryGetValue<HomePageBackgroundDialogViewModel>("ViewModel", out homePageBackgroundDialogViewModel);
             InitBackgroundTemplateList();
         }
     }

+ 119 - 14
PDF Office/ViewModels/Dialog/HomePageToolsDialogs/HomePageBatchProcessing/HomePageBates/HomePageBatesDialogViewModel.cs

@@ -19,6 +19,8 @@ using Prism.Events;
 using PDF_Office.EventAggregators;
 using PDFSettings;
 using ImTools;
+using PDF_Office.Model.EditTools.Watermark;
+using PDF_Office.Model.EditTools.Bates;
 
 namespace PDF_Office.ViewModels.Dialog.HomePageToolsDialogs.HomePageBatchProcessing.HomePageBates
 {
@@ -32,6 +34,10 @@ namespace PDF_Office.ViewModels.Dialog.HomePageToolsDialogs.HomePageBatchProcess
 
         public string PageNumber = "";
 
+        private CPDFBates bates;
+
+        public BatesInfo BatesInfo;
+
         public IEventAggregator eventAggregator;
         public IRegionManager batesRegion;
 
@@ -156,6 +162,30 @@ namespace PDF_Office.ViewModels.Dialog.HomePageToolsDialogs.HomePageBatchProcess
 
             }
         }
+
+        private string createGridSpan = "1";
+        public string CreateGridSpan
+        {
+            get { return createGridSpan; }
+            set
+            {
+                SetProperty(ref createGridSpan, value);
+                RaisePropertyChanged();
+
+            }
+        }
+
+        private Visibility createGridSpanVisibility = Visibility.Visible;
+        public Visibility CreateGridSpanVisibility
+        {
+            get { return createGridSpanVisibility; }
+            set
+            {
+                SetProperty(ref createGridSpanVisibility, value);
+                RaisePropertyChanged();
+
+            }
+        }
         #endregion
 
         #region 委托声明
@@ -200,6 +230,8 @@ namespace PDF_Office.ViewModels.Dialog.HomePageToolsDialogs.HomePageBatchProcess
             param.Add("BatesItem", batesItem);
             batesRegion.RequestNavigate(BatesSettingsRegionName, CreateName, param);
             BatesSettingsVisible = Visibility.Visible;
+            CreateGridSpan = "2";
+            CreateGridSpanVisibility = Visibility.Collapsed;
         }
 
         public void EnterTemplateListOrCreate(EnumTemplateListOrCreateUnicode enumTemplateListOrCreateunicode)
@@ -207,10 +239,14 @@ namespace PDF_Office.ViewModels.Dialog.HomePageToolsDialogs.HomePageBatchProcess
             EnumTemplateListOrCreate enumTemplateListOrCreate = enumTemplateListOrCreateunicode.Status;
             if (enumTemplateListOrCreate == EnumTemplateListOrCreate.StatusTemplate)
             {
+                CreateGridSpan = "1";
+                CreateGridSpanVisibility = Visibility.Visible;
                 EnterSelectedContent(TemplateListName);
             }
             else
             {
+                CreateGridSpan = "2";
+                CreateGridSpanVisibility = Visibility.Collapsed;
                 EnterSelectedContent(CreateName);
             }
         }
@@ -219,6 +255,7 @@ namespace PDF_Office.ViewModels.Dialog.HomePageToolsDialogs.HomePageBatchProcess
         {
             NavigationParameters param = new NavigationParameters();
             param.Add(ParameterNames.PDFViewer, PDFViewer);
+            param.Add("ViewModel", this);
             batesRegion.RequestNavigate(BatesSettingsRegionName, SelectedContentName, param);
             BatesSettingsVisible = Visibility.Visible;
         }
@@ -230,17 +267,19 @@ namespace PDF_Office.ViewModels.Dialog.HomePageToolsDialogs.HomePageBatchProcess
             BatesGridIsEnabled = "False";
             foreach (var filename in fileNames)
             {
-                //FileInfo fileinfo = new FileInfo(filename);
-                //string OutputPath = fileinfo.DirectoryName;
-                //char[] enumerationSeparator = new char[] { ',' };
-                //char[] rangeSeparator = new char[] { '-' };
-                //List<int> PageIndexLists = new List<int>();
-                //CPDFDocument document = CPDFDocument.InitWithFilePath(filename);
-                //if (document == null)
-                //{
-                //    PDFDataTable.Rows[fileNamesIndex]["FileState"] = "文件出错";
-                //    continue;
-                //}
+                FileInfo fileinfo = new FileInfo(filename);
+                string OutputPath = fileinfo.DirectoryName;
+                char[] enumerationSeparator = new char[] { ',' };
+                char[] rangeSeparator = new char[] { '-' };
+                List<int> PageIndexLists = new List<int>();
+                CPDFDocument document = CPDFDocument.InitWithFilePath(filename);
+                if (document == null)
+                {
+                    PDFDataTable.Rows[fileNamesIndex]["FileState"] = "文件出错";
+                    continue;
+                }
+                CreateBates(document);
+                document.WriteToFilePath(filename + "_Bates.pdf");
                 //if (!CommonHelper.GetPagesInRange(ref PageIndexLists, "1-" + document.PageCount.ToString(), document.PageCount, enumerationSeparator, rangeSeparator))
                 //{ //TODO
                 //    Trace.WriteLine("输入不对");
@@ -249,15 +288,40 @@ namespace PDF_Office.ViewModels.Dialog.HomePageToolsDialogs.HomePageBatchProcess
                 //}
 
                 //document.Release();
-                PDFDataTable.Rows[fileNamesIndex]["FilePageRangeSelectIndex"] = "2";
+                //PDFDataTable.Rows[fileNamesIndex]["FilePageRangeSelectIndex"] = "2";
                 PDFDataTable.Rows[fileNamesIndex]["FileState"] = "完成";
-                PDFCurrentDataTable.Rows[fileNamesIndex]["FilePageRangeText"] = "2";
-                PDFCurrentDataTable.Rows[fileNamesIndex]["FilePageRangeSelectIndex"] = "2";
+                //PDFCurrentDataTable.Rows[fileNamesIndex]["FilePageRangeText"] = "2";
+                //PDFCurrentDataTable.Rows[fileNamesIndex]["FilePageRangeSelectIndex"] = "2";
                 PDFCurrentDataTable.Rows[fileNamesIndex]["FileState"] = "完成";
                 fileNamesIndex++;
             }
             BatesGridIsEnabled = "True";
         }
+
+        public void CreateBates(CPDFDocument document)
+        {
+            if (BatesInfo != null)
+            {
+                if (bates != null) { bates.Release(); }
+                bates = document.GetBates();
+                for (int i = 0; i < 6; i++)
+                {
+                    bates.SetText(i, BatesInfo.TextData[i].text);
+
+                    bates.SetFontName(i, BatesInfo.TextData[i].fontName);
+                    bates.SetFontSize(i, BatesInfo.TextData[i].fontSize);
+
+                    bates.SetTextColor(i, BatesInfo.TextData[i].Color);
+                }
+                bates.SetPageOffset(BatesInfo.StarPagetNumber + 1);
+
+                bates.SetPages(getFilePageRange(document, PDFCurrentDataTable.Rows[fileNamesIndex]["FilePageRangeText"].ToString(), PDFCurrentDataTable.Rows[fileNamesIndex]["FilePageRangeSelectIndex"].ToString()));
+
+                bates.SetMargin(BatesInfo.margin);
+                bates.Update();
+
+            }
+        }
         #endregion
 
         #region 批量处理逻辑函数
@@ -392,6 +456,47 @@ namespace PDF_Office.ViewModels.Dialog.HomePageToolsDialogs.HomePageBatchProcess
                 }
             }
         }
+
+        /// <summary>
+        /// 更新Currentlistview显示
+        /// pagerangetext 自定义页面范围字符串  pagerangeselectindex combobox下拉索引(0全部页面 1奇数页 2偶数页 3自定义页面)
+        /// </summary>
+        public void updateFilesPageRange(string pagerangetext = "1", string pagerangeselectindex = "0")
+        {
+            for (int i = 0; fileNames.Count > i; i++)
+            {
+
+                PDFDataTable.Rows[i]["FilePageRangeText"] = pagerangetext;
+                PDFDataTable.Rows[i]["FilePageRangeSelectIndex"] = pagerangeselectindex;
+                PDFCurrentDataTable.Rows[i]["FilePageRangeText"] = pagerangetext;
+                PDFCurrentDataTable.Rows[i]["FilePageRangeSelectIndex"] = pagerangeselectindex;
+            }
+        }
+        /// <summary>
+        /// 获取文件列表单个文件对应的页码范围
+        /// document 文档对象 pagerangetext 自定义页面范围字符串  pagerangeselectindex combobox下拉索引(0全部页面 1奇数页 2偶数页 3自定义页面)
+        /// </summary>
+        public string getFilePageRange(CPDFDocument document, string pagerangetext = "1", string pagerangeselectindex = "0")
+        {
+            string filePageRange = "1";
+            EditToolsHelper.GetPageRange(int.Parse(pagerangeselectindex), document, ref filePageRange, pagerangetext);
+            return filePageRange;
+        }
+
+        /// <summary>
+        /// 获取文件列表单个文件对应的页码范围
+        /// document 文档对象 pagerangetext 自定义页面范围字符串  pagerangeselectindex combobox下拉索引(0全部页面 1奇数页 2偶数页 3自定义页面)
+        /// </summary>
+        public bool isEvenPage(CPDFDocument document)
+        {
+            bool isevenpage = false;
+            if (document.PageCount > 1)
+            {
+                isevenpage = true;
+            }
+            return isevenpage;
+        }
+
         /// <summary>
         /// 逆序int类型集合
         /// </summary>

+ 4 - 2
PDF Office/ViewModels/Dialog/HomePageToolsDialogs/HomePageBatchProcessing/HomePageBates/HomePageBatesTemplateListContentViewModel.cs

@@ -15,11 +15,13 @@ using System.Collections.ObjectModel;
 using System.Linq;
 using System.Windows.Controls;
 using System.Windows;
+using Prism.Common;
 
 namespace PDF_Office.ViewModels.Dialog.HomePageToolsDialogs.HomePageBatchProcessing.HomePageBates
 {
     public class HomePageBatesTemplateListContentViewModel : BindableBase, INavigationAware
     {
+        private HomePageBatesDialogViewModel homePageBatesDialogViewModel;
         private CPDFViewer PDFViewer;
         public IEventAggregator eventAggregator;
         public BatesInfo BatesInfo = new BatesInfo();
@@ -168,9 +170,8 @@ namespace PDF_Office.ViewModels.Dialog.HomePageToolsDialogs.HomePageBatchProcess
             if (template != null)
             {
                 ConvertItemToInfo(template, ref BatesInfo);
-                
+                homePageBatesDialogViewModel.BatesInfo = BatesInfo;
             }
-
         }
 
         private void GetBatesSource()
@@ -223,6 +224,7 @@ namespace PDF_Office.ViewModels.Dialog.HomePageToolsDialogs.HomePageBatchProcess
         public void OnNavigatedTo(NavigationContext navigationContext)
         {
             navigationContext.Parameters.TryGetValue<CPDFViewer>(ParameterNames.PDFViewer, out PDFViewer);
+            navigationContext.Parameters.TryGetValue<HomePageBatesDialogViewModel>("ViewModel", out homePageBatesDialogViewModel);
             InitBackgroundTemplateList();
         }
     }

+ 10 - 3
PDF Office/ViewModels/Dialog/HomePageToolsDialogs/HomePageBatchProcessing/HomePageConverter/HomePageConverterDialogViewModel.cs

@@ -179,8 +179,13 @@ namespace PDF_Office.ViewModels.Dialog.HomePageToolsDialogs.HomePageBatchProcess
         {
 
             SetImageTypeOrigin();
+
+            PDFCurrentDataTable.Columns.Add("FilePageRangeText");
+            PDFCurrentDataTable.Columns.Add("FilePageRangeSelectIndex");
             PDFCurrentDataTable.Columns.Add("FileState");
             PDFDataTable.Columns.Add("FileName");
+            PDFDataTable.Columns.Add("FilePageRangeText");
+            PDFDataTable.Columns.Add("FilePageRangeSelectIndex");
             PDFDataTable.Columns.Add("FileSize");
             PDFDataTable.Columns.Add("FileState");
             ADDPDFCommand = new DelegateCommand(addpicture);
@@ -385,6 +390,8 @@ namespace PDF_Office.ViewModels.Dialog.HomePageToolsDialogs.HomePageBatchProcess
             updateCurrentListview();
             DataTable pdfdatatable = new DataTable();
             pdfdatatable.Columns.Add("FileName");
+            pdfdatatable.Columns.Add("FilePageRangeText");
+            pdfdatatable.Columns.Add("FilePageRangeSelectIndex");
             pdfdatatable.Columns.Add("FileSize");
             pdfdatatable.Columns.Add("FileState");
             int datatableindex = 0;
@@ -393,7 +400,7 @@ namespace PDF_Office.ViewModels.Dialog.HomePageToolsDialogs.HomePageBatchProcess
                 string file_all = fileName;
                 FileInfo f = new FileInfo(file_all);
                 string file_size = (((float)f.Length) / 1024).ToString() + " K";
-                pdfdatatable.Rows.Add(f.Name, file_size, PDFCurrentDataTable.Rows[datatableindex]["FileState"]);
+                pdfdatatable.Rows.Add(f.Name, PDFCurrentDataTable.Rows[datatableindex]["FilePageRangeText"], PDFCurrentDataTable.Rows[datatableindex]["FilePageRangeSelectIndex"], file_size, PDFCurrentDataTable.Rows[datatableindex]["FileState"]);
                 datatableindex++;
             }
             PDFDataTable = pdfdatatable;
@@ -405,13 +412,13 @@ namespace PDF_Office.ViewModels.Dialog.HomePageToolsDialogs.HomePageBatchProcess
         /// 更新Currentlistview显示
         /// state 状态显示字符串
         /// </summary>
-        public void updateCurrentListview(string state = "待完成")
+        public void updateCurrentListview(string pagerangetext = "1", string pagerangeselectindex = "0", string state = "待完成")
         {
             if (fileNames.Count >= FileNameNumber)
             {
                 for (int i = 0; fileNames.Count - FileNameNumber > i; i++)
                 {
-                    PDFCurrentDataTable.Rows.Add(state);
+                    PDFCurrentDataTable.Rows.Add(pagerangetext, pagerangeselectindex, state);
                 }
             }
             else

+ 113 - 11
PDF Office/ViewModels/Dialog/HomePageToolsDialogs/HomePageBatchProcessing/HomePageHeaderFooter/HomePageHeaderFooterDialogViewModel.cs

@@ -18,6 +18,7 @@ using Prism.Events;
 using ComPDFKitViewer.PdfViewer;
 using PDF_Office.EventAggregators;
 using PDFSettings;
+using PDF_Office.Model.EditTools.HeaderFooter;
 
 namespace PDF_Office.ViewModels.Dialog.HomePageToolsDialogs.HomePageBatchProcessing.HomePageHeaderFooter
 {
@@ -31,11 +32,15 @@ namespace PDF_Office.ViewModels.Dialog.HomePageToolsDialogs.HomePageBatchProcess
 
         public string PageNumber = "";
 
+        private CPDFHeaderFooter headerFooter;
+
         public IRegionManager headerFooterRegion;
         public IEventAggregator eventAggregator;
 
         private CPDFViewer PDFViewer;
 
+        public HeaderFooterInfo HeaderFooterInfo;
+
         private ViewContentViewModel viewContentViewModel;
 
         public string TemplateListName = "HomePageHeaderFooterTemplateListContent";
@@ -167,6 +172,30 @@ namespace PDF_Office.ViewModels.Dialog.HomePageToolsDialogs.HomePageBatchProcess
 
             }
         }
+
+        private string createGridSpan = "1";
+        public string CreateGridSpan
+        {
+            get { return createGridSpan; }
+            set
+            {
+                SetProperty(ref createGridSpan, value);
+                RaisePropertyChanged();
+
+            }
+        }
+
+        private Visibility createGridSpanVisibility = Visibility.Visible;
+        public Visibility CreateGridSpanVisibility
+        {
+            get { return createGridSpanVisibility; }
+            set
+            {
+                SetProperty(ref createGridSpanVisibility, value);
+                RaisePropertyChanged();
+
+            }
+        }
         #endregion
 
         #region 委托声明
@@ -213,6 +242,8 @@ namespace PDF_Office.ViewModels.Dialog.HomePageToolsDialogs.HomePageBatchProcess
             param.Add("HeaderFooterItem", headerfooterItem);
             headerFooterRegion.RequestNavigate(HeaderFooterSettingsRegionName, CreateName, param);
             HeaderFooterSettingsVisible = Visibility.Visible;
+            CreateGridSpan = "2";
+            CreateGridSpanVisibility = Visibility.Collapsed;
         }
 
         public void EnterTemplateListOrCreate(EnumTemplateListOrCreateUnicode enumTemplateListOrCreateunicode)
@@ -220,10 +251,14 @@ namespace PDF_Office.ViewModels.Dialog.HomePageToolsDialogs.HomePageBatchProcess
             EnumTemplateListOrCreate enumTemplateListOrCreate = enumTemplateListOrCreateunicode.Status;
             if (enumTemplateListOrCreate == EnumTemplateListOrCreate.StatusTemplate)
             {
+                CreateGridSpan = "1";
+                CreateGridSpanVisibility = Visibility.Visible;
                 EnterSelectedContent(TemplateListName);
             }
             else
             {
+                CreateGridSpan = "2";
+                CreateGridSpanVisibility = Visibility.Collapsed;
                 EnterSelectedContent(CreateName);
             }
         }
@@ -232,6 +267,7 @@ namespace PDF_Office.ViewModels.Dialog.HomePageToolsDialogs.HomePageBatchProcess
         {
             NavigationParameters param = new NavigationParameters();
             param.Add(ParameterNames.PDFViewer, PDFViewer);
+            param.Add("ViewModel", this);
             headerFooterRegion.RequestNavigate(HeaderFooterSettingsRegionName, SelectedContentName, param);
             HeaderFooterSettingsVisible = Visibility.Visible;
         }
@@ -243,17 +279,19 @@ namespace PDF_Office.ViewModels.Dialog.HomePageToolsDialogs.HomePageBatchProcess
             HeaderFooterGridIsEnabled = "False";
             foreach (var filename in fileNames)
             {
-                //FileInfo fileinfo = new FileInfo(filename);
-                //string OutputPath = fileinfo.DirectoryName;
-                //char[] enumerationSeparator = new char[] { ',' };
-                //char[] rangeSeparator = new char[] { '-' };
-                //List<int> PageIndexLists = new List<int>();
-                //CPDFDocument document = CPDFDocument.InitWithFilePath(filename);
-                //if (document == null)
-                //{
-                //    PDFDataTable.Rows[fileNamesIndex]["FileState"] = "文件出错";
-                //    continue;
-                //}
+                FileInfo fileinfo = new FileInfo(filename);
+                string OutputPath = fileinfo.DirectoryName;
+                char[] enumerationSeparator = new char[] { ',' };
+                char[] rangeSeparator = new char[] { '-' };
+                List<int> PageIndexLists = new List<int>();
+                CPDFDocument document = CPDFDocument.InitWithFilePath(filename);
+                if (document == null)
+                {
+                    PDFDataTable.Rows[fileNamesIndex]["FileState"] = "文件出错";
+                    continue;
+                }
+                CreateHeaderFooter(document);
+                document.WriteToFilePath(filename + "_HeaderFooter.pdf");
                 //if (!CommonHelper.GetPagesInRange(ref PageIndexLists, "1-" + document.PageCount.ToString(), document.PageCount, enumerationSeparator, rangeSeparator))
                 //{ //TODO
                 //    Trace.WriteLine("输入不对");
@@ -271,6 +309,30 @@ namespace PDF_Office.ViewModels.Dialog.HomePageToolsDialogs.HomePageBatchProcess
             }
             HeaderFooterGridIsEnabled = "True";
         }
+
+        public void CreateHeaderFooter(CPDFDocument document)
+        {
+            if (HeaderFooterInfo != null)
+            {
+
+                //document.(HeaderFooterInfo.TextData, HeaderFooterInfo.margin, HeaderFooterInfo.PageRange, HeaderFooterInfo.StarPagetNumber + 1);
+                headerFooter = document.GetHeaderFooter();
+                for (int i = 0; i < 6; i++)
+                {
+                    headerFooter.SetText(i, HomePageEditHelper.ReverseDate(HeaderFooterInfo.TextData[i].text, document));
+
+                    headerFooter.SetFontName(i, HeaderFooterInfo.TextData[i].fontName);
+                    headerFooter.SetFontSize(i, HeaderFooterInfo.TextData[i].fontSize);
+
+                    headerFooter.SetTextColor(i, HeaderFooterInfo.TextData[i].Color);
+                }
+                    headerFooter.SetPages(getFilePageRange(document, PDFCurrentDataTable.Rows[fileNamesIndex]["FilePageRangeText"].ToString(), PDFCurrentDataTable.Rows[fileNamesIndex]["FilePageRangeSelectIndex"].ToString()));
+                headerFooter.SetPageOffset(HeaderFooterInfo.StarPagetNumber + 1);
+                
+                headerFooter.SetMargin(HeaderFooterInfo.margin);
+                headerFooter.Update();
+            }
+        }
         #endregion
 
         #region 批量处理逻辑函数
@@ -398,6 +460,46 @@ namespace PDF_Office.ViewModels.Dialog.HomePageToolsDialogs.HomePageBatchProcess
             }
         }
 
+        /// <summary>
+        /// 更新Currentlistview显示
+        /// pagerangetext 自定义页面范围字符串  pagerangeselectindex combobox下拉索引(0全部页面 1奇数页 2偶数页 3自定义页面)
+        /// </summary>
+        public void updateFilesPageRange(string pagerangetext = "1", string pagerangeselectindex = "0")
+        {
+            for (int i = 0; fileNames.Count > i; i++)
+            {
+
+                PDFDataTable.Rows[i]["FilePageRangeText"] = pagerangetext;
+                PDFDataTable.Rows[i]["FilePageRangeSelectIndex"] = pagerangeselectindex;
+                PDFCurrentDataTable.Rows[i]["FilePageRangeText"] = pagerangetext;
+                PDFCurrentDataTable.Rows[i]["FilePageRangeSelectIndex"] = pagerangeselectindex;
+            }
+        }
+        /// <summary>
+        /// 获取文件列表单个文件对应的页码范围
+        /// document 文档对象 pagerangetext 自定义页面范围字符串  pagerangeselectindex combobox下拉索引(0全部页面 1奇数页 2偶数页 3自定义页面)
+        /// </summary>
+        public string getFilePageRange(CPDFDocument document, string pagerangetext = "1", string pagerangeselectindex = "0")
+        {
+            string filePageRange = "1";
+            EditToolsHelper.GetPageRange(int.Parse(pagerangeselectindex), document, ref filePageRange, pagerangetext);
+            return filePageRange;
+        }
+
+        /// <summary>
+        /// 获取文件列表单个文件对应的页码范围
+        /// document 文档对象 pagerangetext 自定义页面范围字符串  pagerangeselectindex combobox下拉索引(0全部页面 1奇数页 2偶数页 3自定义页面)
+        /// </summary>
+        public bool isEvenPage(CPDFDocument document)
+        {
+            bool isevenpage = false;
+            if (document.PageCount > 1)
+            {
+                isevenpage = true;
+            }
+            return isevenpage;
+        }
+
         /// <summary>
         /// 逆序int类型集合
         /// </summary>

+ 4 - 1
PDF Office/ViewModels/Dialog/HomePageToolsDialogs/HomePageBatchProcessing/HomePageHeaderFooter/HomePageHeaderFooterTemplateListContentViewModel.cs

@@ -24,6 +24,7 @@ namespace PDF_Office.ViewModels.Dialog.HomePageToolsDialogs.HomePageBatchProcess
         private CPDFViewer PDFViewer;
         public HeaderFooterInfo HeaderFooterInfo = new HeaderFooterInfo();
         public BatesHeaderFooterItem HeaderFooterItem = new BatesHeaderFooterItem();
+        private HomePageHeaderFooterDialogViewModel homePageHeaderFooterDialogViewModel;
         public int TemplateIndex = 0;
 
         private ObservableCollection<BatesHeaderFooterItem> headerFooterModCollection = new ObservableCollection<BatesHeaderFooterItem>();
@@ -167,6 +168,7 @@ namespace PDF_Office.ViewModels.Dialog.HomePageToolsDialogs.HomePageBatchProcess
             if (template != null)
             {
                 ConvertItemToInfo(template, ref HeaderFooterInfo);
+                homePageHeaderFooterDialogViewModel.HeaderFooterInfo = HeaderFooterInfo;
             }
 
         }
@@ -193,7 +195,7 @@ namespace PDF_Office.ViewModels.Dialog.HomePageToolsDialogs.HomePageBatchProcess
             headerFooterInfo.PageNumberFormat = headerFooterItem.PageNumberFormat;
             headerFooterInfo.margin = headerFooterItem.margin;
             headerFooterInfo.PageRangeIndex = headerFooterItem.PageRangeIndex;
-            EditToolsHelper.GetPageRange(headerFooterInfo.PageRangeIndex, PDFViewer.Document, ref headerFooterInfo.PageRange, headerFooterItem.PageRange);
+            //EditToolsHelper.GetPageRange(headerFooterInfo.PageRangeIndex, PDFViewer.Document, ref headerFooterInfo.PageRange, headerFooterItem.PageRange);
         }
         private void CheckTemplateListIsEmpty(List<BatesHeaderFooterItem> headerFooterTemplateList)
         {
@@ -219,6 +221,7 @@ namespace PDF_Office.ViewModels.Dialog.HomePageToolsDialogs.HomePageBatchProcess
         public void OnNavigatedTo(NavigationContext navigationContext)
         {
             navigationContext.Parameters.TryGetValue<CPDFViewer>(ParameterNames.PDFViewer, out PDFViewer);
+            navigationContext.Parameters.TryGetValue<HomePageHeaderFooterDialogViewModel>("ViewModel", out homePageHeaderFooterDialogViewModel);
             InitBackgroundTemplateList();
         }
     }

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

@@ -402,7 +402,6 @@ namespace PDF_Office.ViewModels.Dialog.HomePageToolsDialogs.HomePageBatchProcess
                 string file_all = fileName;
                 FileInfo f = new FileInfo(file_all);
                 string file_size = (((float)f.Length) / 1024).ToString() + " K";
-                pdfdatatable.Rows.Add(f.Name, file_size, state);
                 pdfdatatable.Rows.Add(f.Name, file_size, PDFCurrentDataTable.Rows[datatableindex]["FileState"]);
                 datatableindex++;
             }

+ 133 - 14
PDF Office/ViewModels/Dialog/HomePageToolsDialogs/HomePageBatchProcessing/HomePageWatermark/HomePageWatermarkDialogViewModel.cs

@@ -18,6 +18,8 @@ using ComPDFKitViewer.PdfViewer;
 using Prism.Events;
 using PDF_Office.EventAggregators;
 using PDFSettings;
+using PDF_Office.Model.EditTools.Watermark;
+using ComPDFKit.PDFWatermark;
 
 namespace PDF_Office.ViewModels.Dialog.HomePageToolsDialogs.HomePageBatchProcessing.HomePageWatermark
 {
@@ -35,6 +37,10 @@ namespace PDF_Office.ViewModels.Dialog.HomePageToolsDialogs.HomePageBatchProcess
 
         private CPDFViewer PDFViewer;
 
+        private CPDFWatermark watermark;
+
+        public WatermarkInfo WatermarkInfo;
+
         private CPDFViewer CurrentPDFViewer;
 
         private ViewContentViewModel viewContentViewModel;
@@ -178,6 +184,30 @@ namespace PDF_Office.ViewModels.Dialog.HomePageToolsDialogs.HomePageBatchProcess
 
             }
         }
+
+        private string createGridSpan = "1";
+        public string CreateGridSpan
+        {
+            get { return createGridSpan; }
+            set
+            {
+                SetProperty(ref createGridSpan, value);
+                RaisePropertyChanged();
+
+            }
+        }
+
+        private Visibility createGridSpanVisibility = Visibility.Visible;
+        public Visibility CreateGridSpanVisibility
+        {
+            get { return createGridSpanVisibility; }
+            set
+            {
+                SetProperty(ref createGridSpanVisibility, value);
+                RaisePropertyChanged();
+
+            }
+        }
         #endregion
 
         #region 委托声明
@@ -223,10 +253,14 @@ namespace PDF_Office.ViewModels.Dialog.HomePageToolsDialogs.HomePageBatchProcess
             EnumTemplateListOrCreate enumTemplateListOrCreate = enumTemplateListOrCreateunicode.Status;
             if (enumTemplateListOrCreate == EnumTemplateListOrCreate.StatusTemplate)
             {
+                CreateGridSpan = "1";
+                CreateGridSpanVisibility = Visibility.Visible;
                 EnterSelectedContent(TemplateListName);
             }
             else
             {
+                CreateGridSpan = "2";
+                CreateGridSpanVisibility = Visibility.Collapsed;
                 EnterSelectedContent(CreateBaseName);
             }
         }
@@ -235,6 +269,7 @@ namespace PDF_Office.ViewModels.Dialog.HomePageToolsDialogs.HomePageBatchProcess
         {
             NavigationParameters param = new NavigationParameters();
             param.Add(ParameterNames.PDFViewer, PDFViewer);
+            param.Add("ViewModel", this);
             if (SelectedContentName == TemplateListName)
             {
                 param.Add("CurrentCreateModName", CurrentCreateMod);
@@ -288,6 +323,8 @@ namespace PDF_Office.ViewModels.Dialog.HomePageToolsDialogs.HomePageBatchProcess
             param.Add("WatermarkItem", watermarkItem);
             watermarkRegion.RequestNavigate(WatermarkSettingsRegionName, CreateBaseName, param);
             WatermarkSettingsVisible = Visibility.Visible;
+            CreateGridSpan = "2";
+            CreateGridSpanVisibility = Visibility.Collapsed;
         }
 
         private void create()
@@ -297,17 +334,19 @@ namespace PDF_Office.ViewModels.Dialog.HomePageToolsDialogs.HomePageBatchProcess
             WatermarkGridIsEnabled = "False";
             foreach (var filename in fileNames)
             {
-                //FileInfo fileinfo = new FileInfo(filename);
-                //string OutputPath = fileinfo.DirectoryName;
-                //char[] enumerationSeparator = new char[] { ',' };
-                //char[] rangeSeparator = new char[] { '-' };
-                //List<int> PageIndexLists = new List<int>();
-                //CPDFDocument document = CPDFDocument.InitWithFilePath(filename);
-                //if (document == null)
-                //{
-                //    PDFDataTable.Rows[fileNamesIndex]["FileState"] = "文件出错";
-                //    continue;
-                //}
+                FileInfo fileinfo = new FileInfo(filename);
+                string OutputPath = fileinfo.DirectoryName;
+                char[] enumerationSeparator = new char[] { ',' };
+                char[] rangeSeparator = new char[] { '-' };
+                List<int> PageIndexLists = new List<int>();
+                CPDFDocument document = CPDFDocument.InitWithFilePath(filename);
+                if (document == null)
+                {
+                    PDFDataTable.Rows[fileNamesIndex]["FileState"] = "文件出错";
+                    continue;
+                }
+                CreateWatermark(document);
+                document.WriteToFilePath(filename + "_Watermark.pdf");
                 //if (!CommonHelper.GetPagesInRange(ref PageIndexLists, "1-" + document.PageCount.ToString(), document.PageCount, enumerationSeparator, rangeSeparator))
                 //{ //TODO
                 //    Trace.WriteLine("输入不对");
@@ -316,15 +355,55 @@ namespace PDF_Office.ViewModels.Dialog.HomePageToolsDialogs.HomePageBatchProcess
                 //}
 
                 //document.Release();
-                PDFDataTable.Rows[fileNamesIndex]["FilePageRangeSelectIndex"] = "2";
+                //PDFDataTable.Rows[fileNamesIndex]["FilePageRangeSelectIndex"] = "2";
                 PDFDataTable.Rows[fileNamesIndex]["FileState"] = "完成";
-                PDFCurrentDataTable.Rows[fileNamesIndex]["FilePageRangeText"] = "2";
-                PDFCurrentDataTable.Rows[fileNamesIndex]["FilePageRangeSelectIndex"] = "2";
+                //PDFCurrentDataTable.Rows[fileNamesIndex]["FilePageRangeText"] = "2";
+                //PDFCurrentDataTable.Rows[fileNamesIndex]["FilePageRangeSelectIndex"] = "2";
                 PDFCurrentDataTable.Rows[fileNamesIndex]["FileState"] = "完成";
                 fileNamesIndex++;
             }
             WatermarkGridIsEnabled = "True";
         }
+
+        public void CreateWatermark(CPDFDocument document)
+        {
+            if (WatermarkInfo != null)
+            {
+                 document.DeleteWatermarks(); 
+
+                if (WatermarkInfo.WatermarkType == C_Watermark_Type.WATERMARK_TYPE_TEXT)
+                {
+                    watermark = document.InitWatermark(C_Watermark_Type.WATERMARK_TYPE_TEXT);
+                    watermark.SetText(WatermarkInfo.Text);
+                    watermark.SetFontName(WatermarkInfo.FontName);
+                    watermark.SetFontSize(WatermarkInfo.TextSize);
+                    watermark.SetTextRGBColor(WatermarkInfo.TextColor);
+                }
+                else
+                {
+
+                    watermark = document.InitWatermark(C_Watermark_Type.WATERMARK_TYPE_IMG);
+                    if (WatermarkInfo.ImageArray != null)
+                    {
+                        watermark.SetImage(WatermarkInfo.ImageArray, WatermarkInfo.ImageWidth, WatermarkInfo.ImageHeight);
+                    }
+                    watermark.SetScale(WatermarkInfo.ImageSize / 100);
+                }
+                watermark.SetRotation((float)((WatermarkInfo.Rotation / 180) * Math.PI));
+                watermark.SetOpacity((byte)(((float)WatermarkInfo.Opacity / 100) * 255));
+                watermark.SetFront(WatermarkInfo.IsFront);
+                watermark.SetVertalign(WatermarkInfo.WatermarkVertalign);
+                watermark.SetHorizalign(WatermarkInfo.WatermarkHorizalign);
+                watermark.SetFullScreen(WatermarkInfo.Isfull);
+                watermark.SetVertOffset(WatermarkInfo.VertOffset);
+                watermark.SetHorizOffset(WatermarkInfo.HorizOffset);
+                watermark.SetHorizontalSpacing(WatermarkInfo.HorizontalSpacing);
+                watermark.SetVerticalSpacing(WatermarkInfo.VerticalSpacing);
+                watermark.SetPages(getFilePageRange(document, PDFCurrentDataTable.Rows[fileNamesIndex]["FilePageRangeText"].ToString(), PDFCurrentDataTable.Rows[fileNamesIndex]["FilePageRangeSelectIndex"].ToString()));
+                Trace.WriteLine("IsCreateWatermark: " + watermark.CreateWatermark());
+                Trace.WriteLine("IsUpdateWatermark: " + watermark.UpdateWatermark());
+            }
+        }
         #endregion
 
         #region 批量处理逻辑函数
@@ -452,6 +531,46 @@ namespace PDF_Office.ViewModels.Dialog.HomePageToolsDialogs.HomePageBatchProcess
             }
         }
 
+        /// <summary>
+        /// 更新Currentlistview显示
+        /// pagerangetext 自定义页面范围字符串  pagerangeselectindex combobox下拉索引(0全部页面 1奇数页 2偶数页 3自定义页面)
+        /// </summary>
+        public void updateFilesPageRange(string pagerangetext = "1", string pagerangeselectindex = "0")
+        {
+            for (int i = 0; fileNames.Count > i; i++)
+            {
+
+                PDFDataTable.Rows[i]["FilePageRangeText"] = pagerangetext;
+                PDFDataTable.Rows[i]["FilePageRangeSelectIndex"] = pagerangeselectindex;
+                PDFCurrentDataTable.Rows[i]["FilePageRangeText"] = pagerangetext;
+                PDFCurrentDataTable.Rows[i]["FilePageRangeSelectIndex"] = pagerangeselectindex;
+            }
+        }
+        /// <summary>
+        /// 获取文件列表单个文件对应的页码范围
+        /// document 文档对象 pagerangetext 自定义页面范围字符串  pagerangeselectindex combobox下拉索引(0全部页面 1奇数页 2偶数页 3自定义页面)
+        /// </summary>
+        public string getFilePageRange(CPDFDocument document, string pagerangetext = "1", string pagerangeselectindex = "0")
+        {
+            string filePageRange = "1";
+            EditToolsHelper.GetPageRange(int.Parse(pagerangeselectindex), document, ref filePageRange, pagerangetext);
+            return filePageRange;
+        }
+
+        /// <summary>
+        /// 获取文件列表单个文件对应的页码范围
+        /// document 文档对象 pagerangetext 自定义页面范围字符串  pagerangeselectindex combobox下拉索引(0全部页面 1奇数页 2偶数页 3自定义页面)
+        /// </summary>
+        public bool isEvenPage(CPDFDocument document)
+        {
+            bool isevenpage = false;
+            if (document.PageCount > 1)
+            {
+                isevenpage = true;
+            }
+            return isevenpage;
+        }
+
         /// <summary>
         /// 逆序int类型集合
         /// </summary>

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

@@ -2,6 +2,7 @@
 using PDF_Office.CustomControl;
 using PDF_Office.EventAggregators;
 using PDF_Office.Model;
+using PDF_Office.ViewModels.Dialog.HomePageToolsDialogs.HomePageBatchProcessing.HomePageBackground;
 using Prism.Commands;
 using Prism.Events;
 using Prism.Mvvm;
@@ -20,6 +21,8 @@ namespace PDF_Office.ViewModels.Dialog.HomePageToolsDialogs.HomePageBatchProcess
 
         private CPDFViewer CurrentPDFViewer;
 
+        private HomePageWatermarkDialogViewModel homePageWatermarkDialogViewModel;
+
         private string WatermarkTemplateListTextContentName = "HomePageWatermarkTemplateListTextContent";
         private string WatermarkTemplateListFileContentName = "HomePageWatermarkTemplateListFileContent";
 
@@ -106,6 +109,7 @@ namespace PDF_Office.ViewModels.Dialog.HomePageToolsDialogs.HomePageBatchProcess
         {
             NavigationParameters param = new NavigationParameters();
             param.Add(ParameterNames.PDFViewer, CurrentPDFViewer);
+            param.Add("ViewModel",homePageWatermarkDialogViewModel);
             watermarkTemplateListRegion.RequestNavigate(WatermarkTemplateListRegionName, currentTemplateListName, param);
             eventAggregator.GetEvent<CurrentWatermarkPDFViewerEvent>().Publish(new CPDFViewerUnicode
             {
@@ -141,6 +145,7 @@ namespace PDF_Office.ViewModels.Dialog.HomePageToolsDialogs.HomePageBatchProcess
 
         public void OnNavigatedTo(NavigationContext navigationContext)
         {
+            navigationContext.Parameters.TryGetValue<HomePageWatermarkDialogViewModel>("ViewModel", out homePageWatermarkDialogViewModel);
             if (IsFirstEnter)
             {
                 CurrentTemplateListModName = WatermarkTemplateListTextContentName;

+ 8 - 2
PDF Office/ViewModels/Dialog/HomePageToolsDialogs/HomePageBatchProcessing/HomePageWatermark/HomePageWatermarkTemplateListFileContentViewModel.cs

@@ -29,6 +29,8 @@ namespace PDF_Office.ViewModels.Dialog.HomePageToolsDialogs.HomePageBatchProcess
 
         private CPDFViewer CurrentPDFViewer;
 
+        private HomePageWatermarkDialogViewModel homePageWatermarkDialogViewModel;
+
         public WatermarkInfo WatermarkInfo = new WatermarkInfo();
 
         public WatermarkItem WatermarkItem = new WatermarkItem();
@@ -286,8 +288,11 @@ namespace PDF_Office.ViewModels.Dialog.HomePageToolsDialogs.HomePageBatchProcess
 
         public void SendTemplateItemToDocument(WatermarkItem WatermarkItem)
         {
-            ConvertItemToInfo(WatermarkItem, ref WatermarkInfo);
-            
+            if (WatermarkItem != null)
+            {
+                ConvertItemToInfo(WatermarkItem, ref WatermarkInfo);
+                homePageWatermarkDialogViewModel.WatermarkInfo = WatermarkInfo;
+            }
         }
 
 
@@ -302,6 +307,7 @@ namespace PDF_Office.ViewModels.Dialog.HomePageToolsDialogs.HomePageBatchProcess
 
         public void OnNavigatedTo(NavigationContext navigationContext)
         {
+            navigationContext.Parameters.TryGetValue<HomePageWatermarkDialogViewModel>("ViewModel",out homePageWatermarkDialogViewModel);
             InitWatermarkTemplateList();
         }
     }

+ 8 - 2
PDF Office/ViewModels/Dialog/HomePageToolsDialogs/HomePageBatchProcessing/HomePageWatermark/HomePageWatermarkTemplateListTextContentViewModel.cs

@@ -24,6 +24,8 @@ namespace PDF_Office.ViewModels.Dialog.HomePageToolsDialogs.HomePageBatchProcess
 
         private CPDFViewer CurrentPDFViewer;
 
+        private HomePageWatermarkDialogViewModel homePageWatermarkDialogViewModel;
+
         public WatermarkInfo WatermarkInfo = new WatermarkInfo();
 
         public WatermarkItem WatermarkItem = new WatermarkItem();
@@ -244,8 +246,11 @@ namespace PDF_Office.ViewModels.Dialog.HomePageToolsDialogs.HomePageBatchProcess
 
         public void SendTemplateItemToDocument(WatermarkItem WatermarkItem)
         {
-            ConvertItemToInfo(WatermarkItem, ref WatermarkInfo);
-            
+            if (WatermarkItem != null) {
+
+                ConvertItemToInfo(WatermarkItem, ref WatermarkInfo);
+                homePageWatermarkDialogViewModel.WatermarkInfo = WatermarkInfo;
+            }
         }
 
         public bool IsNavigationTarget(NavigationContext navigationContext)
@@ -259,6 +264,7 @@ namespace PDF_Office.ViewModels.Dialog.HomePageToolsDialogs.HomePageBatchProcess
 
         public void OnNavigatedTo(NavigationContext navigationContext)
         {
+            navigationContext.Parameters.TryGetValue<HomePageWatermarkDialogViewModel>("ViewModel", out homePageWatermarkDialogViewModel);
             InitWatermarkTemplateList();
         }
     }

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

@@ -93,43 +93,7 @@ namespace PDF_Office.ViewModels.EditTools.HeaderFooter
             eventAggregator.GetEvent<DeleteHeaderFooterEvent>().Subscribe(DeleteHeaderFooter, e => e.Unicode == Unicode);
 
         }
-        public string ReverseDate(string str)
-        {
-            string yyyy = DateTime.Now.ToString("yyyy");
-            string yy = DateTime.Now.ToString("yy");
-            string mm = DateTime.Now.ToString("MM");
-            string m = DateTime.Now.ToString("%M");
-            string dd = DateTime.Now.ToString("dd");
-            string d = DateTime.Now.ToString("%d");
-            str = str.Replace("<<m/d>>", m + "/" + d)
-            .Replace("<<m/d/yy>>", m + "/" + d + "/" + yy)
-            .Replace("<<m/d/yyyy>>", m + "/" + d + "/" + yyyy)
-            .Replace("<<mm/dd/yy>>", mm + "/" + dd + "/" + yy)
-            .Replace("<<mm/dd/yyyy>>", mm + "/" + dd + "/" + yyyy)
-            .Replace("<<d/m/yy>>", d + "/" + m + "/" + yy)
-            .Replace("<<d/m/yyyy>>", d + "/" + m + "/" + yyyy)
-            .Replace("<<dd/mm/yy>>", dd + "/" + mm + "/" + yy)
-            .Replace("<<dd/mm/yyyy>>", dd + "/" + mm + "/" + yyyy)
-            .Replace("<<mm/yy>>", mm + "/" + yy)
-            .Replace("<<mm/yyyy>>", mm + "/" + yyyy)
-            .Replace("<<m.d.yy>>", m + "." + d + "." + yy)
-            .Replace("<<m.d.yyyy>>", m + "." + d + "." + yyyy)
-            .Replace("<<mm.dd.yy>>", mm + "." + dd + "." + yy)
-            .Replace("<<mm.dd.yyyy>>", mm + "." + dd + "." + yyyy)
-            .Replace("<<mm.yy>>", mm + "." + yy)
-            .Replace("<<mm.yyyy>>", mm + "." + yyyy)
-            .Replace("<<d.m.yy>>", d + "." + m + "." + yy)
-            .Replace("<<d.m.yyyy>>", d + "." + m + "." + yyyy)
-            .Replace("<<dd.mm.yy>>", dd + "." + mm + "." + yy)
-            .Replace("<<dd.mm.yyyy>>", dd + "." + mm + "." + yyyy)
-            .Replace("<<yy-mm-dd>>", yy + "-" + mm + "-" + dd)
-            .Replace("<<yyyy-mm-dd>>", yyyy + "-" + mm + "-" + dd)
-            .Replace("<<1 of n>>", "<<1>>" + " of " + Document.PageCount)
-            .Replace("<<1/n>>", "<<1>>" + "/" + Document.PageCount)
-            .Replace("<<Page 1>>", "Page" + "<<1>>")
-            .Replace("<<Page 1 of n>>", "Page " + "<<1>>" + " of " + Document.PageCount);
-            return str;
-        }
+        
 
         public void ShowInputIndexBox(object obj)
         {
@@ -205,7 +169,7 @@ namespace PDF_Office.ViewModels.EditTools.HeaderFooter
                 headerFooter = document.GetHeaderFooter();
                 for (int i = 0; i < 6; i++)
                 {
-                    headerFooter.SetText(i, ReverseDate(headerFooterInfo.TextData[i].text));
+                    headerFooter.SetText(i, HomePageEditHelper.ReverseDate(headerFooterInfo.TextData[i].text, document));
 
                     headerFooter.SetFontName(i, headerFooterInfo.TextData[i].fontName);
                     headerFooter.SetFontSize(i, headerFooterInfo.TextData[i].fontSize);

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

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

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

@@ -126,10 +126,10 @@
                 <RowDefinition Height="*"/>
                 <RowDefinition Height="72"/>
             </Grid.RowDefinitions>
-            <Grid Grid.Row="0" Background="#F3F3F3">
+            <Grid Grid.Row="0" Grid.RowSpan="{Binding CreateGridSpan}" Background="#F3F3F3" >
                 <ContentControl prism:RegionManager.RegionName="{Binding BackgroundSettingsRegionName}" Visibility="{Binding BackgroundSettingsVisible}"></ContentControl>
             </Grid>
-            <Grid Grid.Row="1">
+            <Grid Grid.Row="1" Visibility="{Binding CreateGridSpanVisibility}">
                 <Button Height="40" Width="228" Background="Black" Command="{Binding CreateCommand}">
                     <TextBlock Text="Apply" FontSize="18" Foreground="White"/>
                 </Button>

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

@@ -126,10 +126,10 @@
                 <RowDefinition Height="*"/>
                 <RowDefinition Height="72"/>
             </Grid.RowDefinitions>
-            <Grid Grid.Row="0" Background="#F3F3F3">
-                <ContentControl prism:RegionManager.RegionName="{Binding BatesSettingsRegionName}" Visibility="{Binding BatesSettingsVisible}"></ContentControl>
+            <Grid Grid.Row="0" Grid.RowSpan="{Binding CreateGridSpan}" Background="#F3F3F3">
+                <ContentControl prism:RegionManager.RegionName="{Binding BatesSettingsRegionName}" Visibility="{Binding BatesSettingsVisible}" ></ContentControl>
             </Grid>
-            <Grid Grid.Row="1">
+            <Grid Grid.Row="1" Visibility="{Binding CreateGridSpanVisibility}">
                 <Button Height="40" Width="228" Background="Black" Command="{Binding CreateCommand}">
                     <TextBlock Text="Apply" FontSize="18" Foreground="White"/>
                 </Button>

+ 8 - 0
PDF Office/Views/Dialog/HomePageToolsDialogs/HomePageBatchProcessing/HomePageConverter/HomePageConverterDialog.xaml

@@ -2,6 +2,7 @@
             xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
              xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
              xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
+             xmlns:cus="clr-namespace:PDF_Office.CustomControl"
              xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
              xmlns:prism="http://prismlibrary.com/"
              prism:ViewModelLocator.AutoWireViewModel="True"
@@ -44,6 +45,13 @@
                     <ListView.View>
                         <GridView>
                             <GridViewColumn  Header="文档名"  Width="400" DisplayMemberBinding="{Binding FileName}"/>
+                            <GridViewColumn Header="页面范围" Width="170" >
+                                <GridViewColumn.CellTemplate>
+                                    <DataTemplate>
+                                        <cus:WritableComboBox Height="24" Width="140" Margin="0,8,0,0" Text="{Binding FilePageRangeText,Mode=TwoWay}" SelectedIndex="{Binding FilePageRangeSelectIndex,Mode=TwoWay}"></cus:WritableComboBox>
+                                    </DataTemplate>
+                                </GridViewColumn.CellTemplate>
+                            </GridViewColumn>
                             <GridViewColumn Header="大小" Width="100" DisplayMemberBinding="{Binding FileSize}"/>
                             <GridViewColumn Header="状态" Width="80" >
                                 <GridViewColumn.CellTemplate>

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

@@ -126,10 +126,10 @@
                 <RowDefinition Height="*"/>
                 <RowDefinition Height="72"/>
             </Grid.RowDefinitions>
-            <Grid Grid.Row="0" Background="#F3F3F3">
+            <Grid Grid.Row="0" Background="#F3F3F3"  Grid.RowSpan="{Binding CreateGridSpan}">
                 <ContentControl prism:RegionManager.RegionName="{Binding HeaderFooterSettingsRegionName}" Visibility="{Binding HeaderFooterSettingsVisible}"></ContentControl>
             </Grid>
-            <Grid Grid.Row="1">
+            <Grid Grid.Row="1" Visibility="{Binding CreateGridSpanVisibility}">
                 <Button Height="40" Width="228" Background="Black" Command="{Binding CreateCommand}">
                     <TextBlock Text="Apply" FontSize="18" Foreground="White"/>
                 </Button>

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

@@ -126,10 +126,10 @@
                 <RowDefinition Height="*"/>
                 <RowDefinition Height="72"/>
             </Grid.RowDefinitions>
-            <Grid  Grid.Row="0" Background="#F3F3F3">
+            <Grid  Grid.Row="0"  Grid.RowSpan="{Binding CreateGridSpan}" Background="#F3F3F3">
                 <ContentControl prism:RegionManager.RegionName="{Binding WatermarkSettingsRegionName}" Visibility="{Binding WatermarkSettingsVisible}"></ContentControl>
             </Grid>
-            <Grid Grid.Row="1">
+            <Grid Grid.Row="1" Visibility="{Binding CreateGridSpanVisibility}">
                 <Button Height="40" Width="228" Background="Black" Command="{Binding CreateCommand}">
                     <TextBlock Text="Apply" FontSize="18" Foreground="White"/>
                 </Button>