Преглед изворни кода

打印-自动/手动双面打印

liuaoran пре 2 година
родитељ
комит
f7a7956be5
18 измењених фајлова са 1016 додато и 360 уклоњено
  1. 16 3
      PDF Office/EventAggregators/SendPrintInfoEvent.cs
  2. 50 11
      PDF Office/Model/Dialog/HomePageToolsDialogs/HomePagePrinter/HomePagePrinterDialogModel.cs
  3. 82 81
      PDF Office/Model/ParameterNames.cs
  4. 6 7
      PDF Office/SDKLisence.xml
  5. 1 1
      PDF Office/ViewModels/BottomToolContentViewModel.cs
  6. 162 42
      PDF Office/ViewModels/Dialog/HomePageToolsDialogs/HomePagePrinter/HomePagePrinterDialogViewModel.cs
  7. 459 156
      PDF Office/ViewModels/Dialog/HomePageToolsDialogs/HomePagePrinter/HomePagePrinterDocumentContentViewModel.cs
  8. 58 4
      PDF Office/ViewModels/Dialog/HomePageToolsDialogs/HomePagePrinter/HomePagePrinterModMultipleContentViewModel.cs
  9. 60 4
      PDF Office/ViewModels/Dialog/HomePageToolsDialogs/HomePagePrinter/HomePagePrinterModSizeContentViewModel.cs
  10. 13 0
      PDF Office/ViewModels/ViewContentViewModel.cs
  11. 11 7
      PDF Office/Views/Dialog/HomePageToolsDialogs/HomePagePrinter/HomePagePrinterDialog.xaml
  12. 18 2
      PDF Office/Views/Dialog/HomePageToolsDialogs/HomePagePrinter/HomePagePrinterDialog.xaml.cs
  13. 0 3
      PDF Office/Views/Dialog/HomePageToolsDialogs/HomePagePrinter/HomePagePrinterDocumentContent.xaml
  14. 2 3
      PDF Office/Views/Dialog/HomePageToolsDialogs/HomePagePrinter/HomePagePrinterModBookletContent.xaml
  15. 28 9
      PDF Office/Views/Dialog/HomePageToolsDialogs/HomePagePrinter/HomePagePrinterModMultipleContent.xaml
  16. 1 1
      PDF Office/Views/Dialog/HomePageToolsDialogs/HomePagePrinter/HomePagePrinterModPosterContent.xaml
  17. 48 25
      PDF Office/Views/Dialog/HomePageToolsDialogs/HomePagePrinter/HomePagePrinterModSizeContent.xaml
  18. 1 1
      PDF Office/Views/ViewContent.xaml

+ 16 - 3
PDF Office/EventAggregators/SendPrintInfoEvent.cs

@@ -27,23 +27,32 @@ namespace PDF_Office.EventAggregators
     public class PrintQueueWithUnicode
     {
         public PrintQueue printQueue;
+        public EnumBothSidesStage EnumBothSidesStage;
         public string Unicode;
     }
 
     public class LabelWithUnicode
     {
-        public string Unicode;
         public string Label;
+        public string Unicode;
     }
 
-    public class SendPrintSettingsInfoEvent:PubSubEvent<PrintSettingsInfoWithUnicode>
+    public class EnumDuplexPrintModWithUnicode
     {
+        public EnumDuplexPrintMod enumDuplexPrintMod;
+        public string Unicode;
+    }
 
+    public class GetCurrentViewEvent
+    {
     }
 
-    public class SendPrintSettingsModInfoEvent:PubSubEvent<PrintModInfoWithUnicode>
+    public class SendPrintSettingsInfoEvent : PubSubEvent<PrintSettingsInfoWithUnicode>
     {
+    }
 
+    public class SendPrintSettingsModInfoEvent : PubSubEvent<PrintModInfoWithUnicode>
+    {
     }
 
     public class SendPrintQueueEvent : PubSubEvent<PrintQueueWithUnicode>
@@ -53,4 +62,8 @@ namespace PDF_Office.EventAggregators
     public class SendLabelEvent : PubSubEvent<LabelWithUnicode>
     {
     }
+
+    public class SendDuplexPrintModEvent : PubSubEvent<EnumDuplexPrintModWithUnicode>
+    {
+    }
 }

+ 50 - 11
PDF Office/Model/Dialog/HomePageToolsDialogs/HomePagePrinter/HomePagePrinterDialogModel.cs

@@ -7,6 +7,7 @@ using System.Printing;
 using System.Runtime.Remoting.Channels;
 using System.Text;
 using System.Threading.Tasks;
+using System.Windows.Forms;
 using static PDF_Office.Model.Dialog.HomePageToolsDialogs.HomePagePrinter.HomePagePrinterDialogModel;
 
 namespace PDF_Office.Model.Dialog.HomePageToolsDialogs.HomePagePrinter
@@ -24,7 +25,7 @@ namespace PDF_Office.Model.Dialog.HomePageToolsDialogs.HomePagePrinter
         /// <summary>
         /// 页码范围
         /// </summary>
-        public EnumPageRange EnumPageRange = EnumPageRange.StatusAllRange;
+        public int EnumPageRange = 0;
         /// <summary>
         /// 逆页序
         /// </summary>
@@ -66,14 +67,25 @@ namespace PDF_Office.Model.Dialog.HomePageToolsDialogs.HomePagePrinter
         /// <summary>
         /// 打印Mod
         /// </summary>
-        public PrintModInfo PrintModInfo  = new SizeInfo();
-
-      public  PrintDocument PrintDocument = new PrintDocument();
-
+        public PrintModInfo PrintModInfo = new SizeInfo();
+        /// <summary>
+        /// Document对象,用于打印
+        /// </summary>
+        public PrintDocument PrintDocument = new PrintDocument();
+        /// <summary>
+        /// 是否双面打印 
+        /// </summary>
         public bool IsBothSides = false;
-
+        /// <summary>
+        /// 边距
+        /// </summary>
         public List<int> Margin = new List<int>();
 
+        /// <summary>
+        /// 需要重新渲染?
+        /// </summary>
+        public bool needRerendering = true;
+
         public PrintSettingsInfo()
         {
             PrintDocument.DefaultPageSettings.Landscape = false;
@@ -83,7 +95,7 @@ namespace PDF_Office.Model.Dialog.HomePageToolsDialogs.HomePagePrinter
     public class HomePagePrinterDialogModel
     {
 
-    } 
+    }
 
 
     public enum EnumSizeType
@@ -92,13 +104,31 @@ namespace PDF_Office.Model.Dialog.HomePageToolsDialogs.HomePagePrinter
         StatusActural,
         StatusCustomized,
     }
+    /// <summary>
+    /// 双面打印阶段
+    /// </summary>
+    public enum EnumBothSidesStage
+    {
+        StatusNone,
+        StatusFrontSide,
+        StatusBackSide
+    }
+
+    public enum EnumPageRangeWithoutCurrentPage
+    {
+        StatusAllRange,
+        StatusOddRange,
+        StatusEvenRange,
+        StatusCustomizedRange,
+    }
 
-    public enum EnumPageRange
+    public enum EnumPageRangeWithCurrentPage
     {
         StatusAllRange,
+        StatusCurrentPage,
         StatusOddRange,
         StatusEvenRange,
-        StatusCustomizedRange
+        StatusCustomizedRange,
     }
 
     public enum EnumPrintOrientation
@@ -160,10 +190,20 @@ namespace PDF_Office.Model.Dialog.HomePageToolsDialogs.HomePagePrinter
         StatusRight
     }
 
+    public enum EnumDuplexPrintMod
+    {
+        StatusNone,
+        StatusFlipLongEdge,
+        StatusFlipShortEdge
+    }
 
     public class PrintModInfo
     {
         public EnumPrintMod EnumPrintMod = EnumPrintMod.StatusSize;
+        /// <summary>
+        /// 双面打印
+        /// </summary>
+        public EnumDuplexPrintMod EnumDuplexPrintMod = EnumDuplexPrintMod.StatusNone;
     }
 
     public class SizeInfo : PrintModInfo
@@ -185,7 +225,6 @@ namespace PDF_Office.Model.Dialog.HomePageToolsDialogs.HomePagePrinter
         public int TileRatio { get; set; }
 
         public string Label;
-
     }
 
     public class MultipleInfo : PrintModInfo
@@ -194,7 +233,7 @@ namespace PDF_Office.Model.Dialog.HomePageToolsDialogs.HomePagePrinter
         public EnumDisplayPageNumber EnumDisplayPageNumber = EnumDisplayPageNumber.StatusTwo;
         public int HorizontalPageNumber = 2;
         public int VerticalPageNumber = 1;
-        public bool IsAutoRotate  = false;
+        public bool IsAutoRotate = false;
     }
 
     public class BookletInfo : PrintModInfo

+ 82 - 81
PDF Office/Model/ParameterNames.cs

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

+ 6 - 7
PDF Office/SDKLisence.xml

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

+ 1 - 1
PDF Office/ViewModels/BottomToolContentViewModel.cs

@@ -124,7 +124,7 @@ namespace PDF_Office.ViewModels
                 }
             }
         }
-
+        
         private int pageCount;
 
         public int PageCount

+ 162 - 42
PDF Office/ViewModels/Dialog/HomePageToolsDialogs/HomePagePrinter/HomePagePrinterDialogViewModel.cs

@@ -111,6 +111,13 @@ namespace PDF_Office.ViewModels.Dialog.HomePageToolsDialogs.HomePagePrinter
             set => SetProperty(ref _maxCopiesNumber, value);
         }
 
+        private Visibility _printPageBorderVisibility = Visibility.Collapsed;
+        public Visibility PrintPageBorderVisibility
+        {
+            get => _printPageBorderVisibility;
+            set => SetProperty(ref _printPageBorderVisibility, value);
+        }
+
         /// <summary>
         /// 打印机支持的颜色
         /// </summary>
@@ -174,16 +181,13 @@ namespace PDF_Office.ViewModels.Dialog.HomePageToolsDialogs.HomePagePrinter
             set => _isBothSides = value;
         }
 
-        public enum EnumBothSidesStage
-        {
-            StatusFrontSide,
-            StatusBackSide
-        }
+        public int printCurrentPageIndex;
+        public bool isCurrentPage;
 
         /// <summary>
         /// 双面打印阶段:正面或背面
         /// </summary>
-        public EnumBothSidesStage BothSidesStage;
+        public EnumBothSidesStage BothSidesStage = EnumBothSidesStage.StatusNone;
 
         #endregion
 
@@ -263,8 +267,22 @@ namespace PDF_Office.ViewModels.Dialog.HomePageToolsDialogs.HomePagePrinter
             InitComponent();
             InitDictionary();
             InitParams();
-
+            PageSetupDialog pageSetupDialog = new PageSetupDialog();
+            PrintSettingsInfo.PrintDocument.PrinterSettings.PrinterName = PrinterName;
+            PrintSettingsInfo.PrintDocument.DefaultPageSettings.Margins = new Margins(0, 0, 0, 0);
+            PrintSettingsInfo.PrintDocument.DefaultPageSettings.Landscape = false;
+            pageSetupDialog.Document = PrintSettingsInfo.PrintDocument;
+            PrintSettingsInfo.PrintDocument.DefaultPageSettings = pageSetupDialog.PageSettings;
+            if (!PrintSettingsInfo.PrintDocument.DefaultPageSettings.Landscape)
+            {
+                PrintOrientationIndex = 0;
+            }
+            else
+            {
+                PrintOrientationIndex = 1;
+            }
             printEvent.GetEvent<SendPrintSettingsModInfoEvent>().Subscribe(RecvPrintSettingsModInfo, e => e.Unicode == Unicode);
+            printEvent.GetEvent<SendDuplexPrintModEvent>().Subscribe(RecvDuplexPrintMod, e => e.Unicode == Unicode);
         }
 
         private void InitComponent()
@@ -283,10 +301,7 @@ namespace PDF_Office.ViewModels.Dialog.HomePageToolsDialogs.HomePagePrinter
         {
             printQueue = localDefaultPrintServer.GetPrintQueue(PrinterName);
             List<PageMediaSize> PageMediaSizeList = new List<PageMediaSize>();
-            PageSetupDialog pageSetupDialog = new PageSetupDialog();
-            PrintSettingsInfo.PrintDocument.PrinterSettings.PrinterName = PrinterName;
-            pageSetupDialog.Document = PrintSettingsInfo.PrintDocument;
-            PrintSettingsInfo.PrintDocument.DefaultPageSettings = pageSetupDialog.PageSettings;
+
         }
 
         private void InitPrinterNameList()
@@ -396,6 +411,14 @@ namespace PDF_Office.ViewModels.Dialog.HomePageToolsDialogs.HomePagePrinter
         {
             var rdo = e as System.Windows.Controls.RadioButton;
             CurrentHomePagePrinterModName = GetPrintModNameFromRadioButton[rdo.Name];
+            if (CurrentHomePagePrinterModName == "HomePagePrinterModMultipleContent" || CurrentHomePagePrinterModName == "HomePagePrinterModBookletContent")
+            {
+                PrintPageBorderVisibility = Visibility.Visible;
+            }
+            else
+            {
+                PrintPageBorderVisibility = Visibility.Collapsed;
+            }
             NavigationParameters param = new NavigationParameters();
             param.Add("document", PDFViewer.Document);
             param.Add("Unicode", Unicode);
@@ -466,49 +489,94 @@ namespace PDF_Office.ViewModels.Dialog.HomePageToolsDialogs.HomePagePrinter
         {
             var cmb = e as WritableComboBox;
             PrintSettingsInfo.PageRangeList.Clear();
-            PrintSettingsInfo.EnumPageRange = (EnumPageRange)int.Parse(cmb.SelectedIndex);
             if (int.Parse(cmb.SelectedIndex) < cmb.Items.Count - 1)
             {
-                PrintSettingsInfo.EnumPageRange = (EnumPageRange)int.Parse(cmb.SelectedIndex);
-                if (PrintSettingsInfo.EnumPageRange == EnumPageRange.StatusAllRange)
+                if (!isCurrentPage)
                 {
-                    for (int temp = 0; temp < PDFViewer.Document.PageCount; temp++)
+                    PrintSettingsInfo.EnumPageRange = int.Parse(cmb.SelectedIndex);
+                    if (PrintSettingsInfo.EnumPageRange == (int)EnumPageRangeWithoutCurrentPage.StatusAllRange)
+                    {
+                        for (int temp = 0; temp < PDFViewer.Document.PageCount; temp++)
+                        {
+                            PrintSettingsInfo.PageRangeList.Add(temp);
+                        }
+                    }
+                    else if (PrintSettingsInfo.EnumPageRange == (int)EnumPageRangeWithoutCurrentPage.StatusOddRange)
                     {
-                        PrintSettingsInfo.PageRangeList.Add(temp);
+                        for (int temp = 0; temp < PDFViewer.Document.PageCount; temp += 2)
+                        {
+                            PrintSettingsInfo.PageRangeList.Add(temp);
+                        }
                     }
-                }
-                else if (PrintSettingsInfo.EnumPageRange == EnumPageRange.StatusOddRange)
-                {
-                    for (int temp = 0; temp < PDFViewer.Document.PageCount; temp += 2)
+                    else if (PrintSettingsInfo.EnumPageRange == (int)EnumPageRangeWithoutCurrentPage.StatusEvenRange)
                     {
-                        PrintSettingsInfo.PageRangeList.Add(temp);
+                        //TODO: 偶数页页数不够异常
+                        if (PDFViewer.Document.PageCount <= 1)
+                        {
+                            for (int temp = 0; temp < PDFViewer.Document.PageCount; temp++)
+                            {
+                                PrintSettingsInfo.PageRangeList.Add(temp);
+                            }
+                        }
+                        else
+                        {
+                            for (int temp = 1; temp < PDFViewer.Document.PageCount; temp += 2)
+                            {
+                                PrintSettingsInfo.PageRangeList.Add(temp);
+                            }
+                        }
                     }
                 }
-                else if (PrintSettingsInfo.EnumPageRange == EnumPageRange.StatusEvenRange)
+                else
                 {
-                    //TODO: 偶数页页数不够异常
-                    if (PDFViewer.Document.PageCount <= 1)
+                    PrintSettingsInfo.EnumPageRange = int.Parse(cmb.SelectedIndex);
+                    if (PrintSettingsInfo.EnumPageRange == (int)EnumPageRangeWithCurrentPage.StatusAllRange)
                     {
                         for (int temp = 0; temp < PDFViewer.Document.PageCount; temp++)
                         {
                             PrintSettingsInfo.PageRangeList.Add(temp);
                         }
                     }
-                    else
+
+                    else if (PrintSettingsInfo.EnumPageRange == (int)EnumPageRangeWithCurrentPage.StatusCurrentPage)
+                    {
+                        PrintSettingsInfo.PageRangeList.Add(printCurrentPageIndex);
+                    }
+
+                    else if (PrintSettingsInfo.EnumPageRange == (int)EnumPageRangeWithCurrentPage.StatusOddRange)
                     {
-                        for (int temp = 1; temp < PDFViewer.Document.PageCount; temp += 2)
+                        for (int temp = 0; temp < PDFViewer.Document.PageCount; temp += 2)
                         {
                             PrintSettingsInfo.PageRangeList.Add(temp);
                         }
                     }
+                    else if (PrintSettingsInfo.EnumPageRange == (int)EnumPageRangeWithCurrentPage.StatusEvenRange)
+                    {
+                        //TODO: 偶数页页数不够异常
+                        if (PDFViewer.Document.PageCount <= 1)
+                        {
+                            for (int temp = 0; temp < PDFViewer.Document.PageCount; temp++)
+                            {
+                                PrintSettingsInfo.PageRangeList.Add(temp);
+                            }
+                        }
+                        else
+                        {
+                            for (int temp = 1; temp < PDFViewer.Document.PageCount; temp += 2)
+                            {
+                                PrintSettingsInfo.PageRangeList.Add(temp);
+                            }
+                        }
+                    }
                 }
+
                 this.printEvent.GetEvent<SendPrintSettingsInfoEvent>().Publish(new PrintSettingsInfoWithUnicode { printSettingsInfo = this.PrintSettingsInfo, Unicode = this.Unicode });
             }
         }
 
         public void SetCustomPageRange(object e)
         {
-            if (PrintSettingsInfo.EnumPageRange == EnumPageRange.StatusCustomizedRange)
+            if (PrintSettingsInfo.EnumPageRange == (int)EnumPageRangeWithCurrentPage.StatusCustomizedRange)
             {
                 var cmb = e as WritableComboBox;
                 if (cmb == null)
@@ -598,6 +666,10 @@ namespace PDF_Office.ViewModels.Dialog.HomePageToolsDialogs.HomePagePrinter
             }
         }
 
+        public void RecvDuplexPrintMod(EnumDuplexPrintModWithUnicode enumDuplexPrintModWithUnicode)
+        {
+            PrintSettingsInfo.PrintModInfo.EnumDuplexPrintMod = enumDuplexPrintModWithUnicode.enumDuplexPrintMod;
+        }
         #endregion
         public void Cancel()
         {
@@ -619,11 +691,30 @@ namespace PDF_Office.ViewModels.Dialog.HomePageToolsDialogs.HomePagePrinter
             NavigationParameters param = new NavigationParameters();
             param.Add(ParameterNames.PDFViewer, PDFViewer);
             param.Add("Unicode", Unicode);
-            printRegion.RequestNavigate(HomePagePrinterModRegionName, HomePagePrinterModSizeName);
+            printRegion.RequestNavigate(HomePagePrinterModRegionName, HomePagePrinterModSizeName, param);
         }
 
         /// <summary>
-        /// 确认打印,单面或手动双面
+        /// 确认打印,单面,双面或手动双面
+        /// 大小模式支持单面,双面
+        /// 海报模式只支持单面
+        /// 多页模式支持单面,双面
+        /// 小册子模式只支持双面
+        /// 
+        /// 单面打印:正常传参
+        /// 
+        /// 双面打印:
+        /// 长边翻页,短边翻页
+        /// 
+        /// 自动双面打印
+        /// 传值给打印机就行
+        /// 
+        /// 手动双面打印
+        /// 长边翻页 先打印奇数页,进入二阶段,正向打印偶数页
+        /// 短边翻页 先打印奇数页,进入二阶段,反向打印偶数页
+        /// 
+        /// 异常退出是否要挂起打印机线程?
+        /// 
         /// </summary>
         public void ConfirmPrint()
         {
@@ -631,7 +722,6 @@ namespace PDF_Office.ViewModels.Dialog.HomePageToolsDialogs.HomePagePrinter
             {
                 printQueue = localDefaultPrintServer.GetPrintQueue(PrinterName);
                 LoadPrinterSettings();
-                this.printEvent.GetEvent<SendPrintQueueEvent>().Publish(new PrintQueueWithUnicode { printQueue = this.printQueue, Unicode = this.Unicode });
             }
 
 
@@ -645,13 +735,35 @@ namespace PDF_Office.ViewModels.Dialog.HomePageToolsDialogs.HomePagePrinter
                     list.Add(printQueue.GetPrintCapabilities().DuplexingCapability[temp]);
                 }
             }
-            if (!IsBothSides)
+
+            ///单面打印的情况:直接执行
+            if (PrintSettingsInfo.PrintModInfo.EnumDuplexPrintMod == EnumDuplexPrintMod.StatusNone)
             {
-                RequestClose.Invoke(new Prism.Services.Dialogs.DialogResult(ButtonResult.OK));
+               this.printEvent.GetEvent<SendPrintQueueEvent>().Publish(new PrintQueueWithUnicode { printQueue = this.printQueue, EnumBothSidesStage = EnumBothSidesStage.StatusNone, Unicode = this.Unicode });
             }
-            else if (IsBothSides)
+            ///双面打印的情况
+            else if ((int)PrintSettingsInfo.PrintModInfo.EnumDuplexPrintMod > 0)
             {
-                MessageBoxEx.Show("翻页");
+                ///支持自动双面
+                if (list.Count > 0)
+                {
+                   this.printEvent.GetEvent<SendPrintQueueEvent>().Publish(new PrintQueueWithUnicode { printQueue = this.printQueue, EnumBothSidesStage = EnumBothSidesStage.StatusNone, Unicode = this.Unicode });
+                    RequestClose.Invoke(new Prism.Services.Dialogs.DialogResult(ButtonResult.OK));
+                }
+                ///手动翻面
+                else
+                {
+                    this.printEvent.GetEvent<SendPrintQueueEvent>().Publish(new PrintQueueWithUnicode { printQueue = this.printQueue, EnumBothSidesStage = EnumBothSidesStage.StatusFrontSide, Unicode = this.Unicode });
+                    if(MessageBoxEx.Show("Printing on the front side of the paper is complete. Please reverse the paper, click 'OK' to print the reverse side", "", MessageBoxButtons.OKCancel) == System.Windows.Forms.DialogResult.OK)
+                    {
+                       this.printEvent.GetEvent<SendPrintQueueEvent>().Publish(new PrintQueueWithUnicode { printQueue = this.printQueue, EnumBothSidesStage = EnumBothSidesStage.StatusBackSide, Unicode = this.Unicode });
+                        RequestClose.Invoke(new Prism.Services.Dialogs.DialogResult(ButtonResult.OK));
+                    }
+                    else
+                    {
+                        RequestClose.Invoke(new Prism.Services.Dialogs.DialogResult(ButtonResult.Cancel));
+                    }
+                }
             }
         }
 
@@ -670,15 +782,23 @@ namespace PDF_Office.ViewModels.Dialog.HomePageToolsDialogs.HomePagePrinter
         public void OnDialogOpened(IDialogParameters parameters)
         {
             parameters.TryGetValue<CPDFViewer>(ParameterNames.PDFViewer, out PDFViewer);
-            if (PDFViewer != null&&PDFViewer.Document!=null)
+            if (PDFViewer != null && PDFViewer.Document != null)
             {
-                    for (int temp = 0; temp < PDFViewer.Document.PageCount; temp++)
-                    {
-                        PrintSettingsInfo.PageRangeList.Add(temp);
-                    }
-                    NavigationParameters param = new NavigationParameters();
-                    NavigateDocumentRegion();
-                    NavigateModRegion();
+                for (int temp = 0; temp < PDFViewer.Document.PageCount; temp++)
+                {
+                    PrintSettingsInfo.PageRangeList.Add(temp);
+                }
+                if (parameters.TryGetValue<int>(ParameterNames.PrintCurrentPage, out printCurrentPageIndex))
+                {
+                    isCurrentPage = true;
+                }
+                else
+                {
+                    isCurrentPage = false;
+                }
+                NavigationParameters param = new NavigationParameters();
+                NavigateDocumentRegion();
+                NavigateModRegion();
             }
         }
     }

Разлика између датотеке није приказан због своје велике величине
+ 459 - 156
PDF Office/ViewModels/Dialog/HomePageToolsDialogs/HomePagePrinter/HomePagePrinterDocumentContentViewModel.cs


+ 58 - 4
PDF Office/ViewModels/Dialog/HomePageToolsDialogs/HomePagePrinter/HomePagePrinterModMultipleContentViewModel.cs

@@ -7,6 +7,7 @@ using Prism.Regions;
 using System;
 using System.Collections.Generic;
 using System.Linq;
+using System.Windows.Controls;
 
 namespace PDF_Office.ViewModels.Dialog.HomePageToolsDialogs.HomePagePrinter
 {
@@ -115,10 +116,26 @@ namespace PDF_Office.ViewModels.Dialog.HomePageToolsDialogs.HomePagePrinter
             set { _multipleInfo = value; }
         }
 
+        private bool _isDuplexModLongEdge = true;
+        public bool IsDuplexModLongEdge
+        {
+            get { return _isDuplexModLongEdge; }
+            set { _isDuplexModLongEdge = value; }
+        }
+
+        private bool _isDuplexModShortEdge = false;
+        public bool IsDuplexModShortEdge
+        {
+            get { return _isDuplexModShortEdge; }
+            set { _isDuplexModShortEdge = value; }
+        }
+
         public DelegateCommand<object> SetPageMatrixCommand { get; set; }
         public DelegateCommand<object> SetCustomMatrixCommand { get; set; }
         public DelegateCommand SetPageOrderCommand { get; set; }
         public DelegateCommand SetAutoRotateCommand { get; set; }
+        public DelegateCommand<object> UnlockDuplexCommand { get; set; }
+        public DelegateCommand<object> ChangeDuplexModCommand { get; set; }
 
         public HomePagePrinterModMultipleContentViewModel(IEventAggregator eventAggregator)
         {
@@ -135,7 +152,8 @@ namespace PDF_Office.ViewModels.Dialog.HomePageToolsDialogs.HomePagePrinter
             SetCustomMatrixCommand = new DelegateCommand<object>(SetCustomMatrix);
             SetPageOrderCommand = new DelegateCommand(SetPageOrder);
             SetAutoRotateCommand = new DelegateCommand(SetAutoRotate);
-
+            UnlockDuplexCommand = new DelegateCommand<object>(UnlockDuplex);
+            ChangeDuplexModCommand = new DelegateCommand<object>(ChangeDuplexMod);
             MultipleInfo = new MultipleInfo();
             MultipleInfo.EnumPrintMod = EnumPrintMod.StatusMultiple;
         }
@@ -172,6 +190,44 @@ namespace PDF_Office.ViewModels.Dialog.HomePageToolsDialogs.HomePagePrinter
 
             }
         }
+        public void UnlockDuplex(object e)
+        {
+            var chk = e as CheckBox;
+            if (chk != null)
+            {
+                if (chk.IsChecked == false)
+                {
+                    this.eventAggregator.GetEvent<SendDuplexPrintModEvent>().Publish(new EnumDuplexPrintModWithUnicode { enumDuplexPrintMod = EnumDuplexPrintMod.StatusNone, Unicode = this.Unicode });
+                }
+                else
+                {
+                    if (IsDuplexModLongEdge)
+                    {
+                        this.eventAggregator.GetEvent<SendDuplexPrintModEvent>().Publish(new EnumDuplexPrintModWithUnicode { enumDuplexPrintMod = EnumDuplexPrintMod.StatusFlipLongEdge, Unicode = this.Unicode });
+                    }
+                    else
+                    {
+                        this.eventAggregator.GetEvent<SendDuplexPrintModEvent>().Publish(new EnumDuplexPrintModWithUnicode { enumDuplexPrintMod = EnumDuplexPrintMod.StatusFlipShortEdge, Unicode = this.Unicode });
+                    }
+                }
+            }
+        }
+
+        public void ChangeDuplexMod(object e)
+        {
+            var rdo = e as RadioButton;
+            if (rdo != null)
+            {
+                if (rdo.Name == "DuplexModLongEdgeRdo")
+                {
+                    this.eventAggregator.GetEvent<SendDuplexPrintModEvent>().Publish(new EnumDuplexPrintModWithUnicode { enumDuplexPrintMod = EnumDuplexPrintMod.StatusFlipLongEdge, Unicode = this.Unicode });
+                }
+                else
+                {
+                    this.eventAggregator.GetEvent<SendDuplexPrintModEvent>().Publish(new EnumDuplexPrintModWithUnicode { enumDuplexPrintMod = EnumDuplexPrintMod.StatusFlipShortEdge, Unicode = this.Unicode });
+                }
+            }
+        }
 
         private void InitPageMatrixList()
         {
@@ -245,9 +301,7 @@ namespace PDF_Office.ViewModels.Dialog.HomePageToolsDialogs.HomePagePrinter
 
                     break;
             }
-        }
-
-
+        } 
 
         private void SetMultipleInfo()
         {

+ 60 - 4
PDF Office/ViewModels/Dialog/HomePageToolsDialogs/HomePagePrinter/HomePagePrinterModSizeContentViewModel.cs

@@ -32,11 +32,26 @@ namespace PDF_Office.ViewModels.Dialog.HomePageToolsDialogs.HomePagePrinter
             set { _sizeInfo = value; }
         }
 
-        public DelegateCommand<object> SetModSizeStatusCommand { get; set; }
+        private bool _isDuplexModLongEdge = true;
+        public bool IsDuplexModLongEdge
+        {
+            get { return _isDuplexModLongEdge;}
+            set { _isDuplexModLongEdge = value; }
+        }
+
+        private bool _isDuplexModShortEdge = false;
+        public bool IsDuplexModShortEdge
+        {
+            get { return _isDuplexModShortEdge;}
+            set { _isDuplexModShortEdge = value;}
+        }
+
+    public DelegateCommand<object> SetModSizeStatusCommand { get; set; }
         public DelegateCommand SetDisplayRatioCommand { get; set; }
+        public DelegateCommand<object> UnlockDuplexCommand { get; set; }
+        public DelegateCommand<object> ChangeDuplexModCommand { get; set; }
 
-        //public DelegateCommand sendSizeInfoCommand;
-        //public DelegateCommand SendSizeInfoCommand => this.SendSizeInfoCommand ?? (this.sendSizeInfoCommand = new DelegateCommand(() => this.eventAggregator.GetEvent<ModInfoSendEvent>().Publish(PrintMod)));
+ 
 
         public DelegateCommand SendSizeInfoCommand { get; set; }
 
@@ -45,9 +60,50 @@ namespace PDF_Office.ViewModels.Dialog.HomePageToolsDialogs.HomePagePrinter
             this.eventAggregator = eventAggregator;
             SizeInfo = new SizeInfo();
             SizeInfo.EnumPrintMod = EnumPrintMod.StatusSize;
-            SetModSizeStatusCommand = new DelegateCommand<object>(SetModSizeStatus);
 
+            SetModSizeStatusCommand = new DelegateCommand<object>(SetModSizeStatus);
             SetDisplayRatioCommand = new DelegateCommand(SetDisplayRatio);
+            UnlockDuplexCommand = new DelegateCommand<object>(UnlockDuplex);   
+            ChangeDuplexModCommand = new DelegateCommand<object>(ChangeDuplexMod);
+        }
+
+        public void UnlockDuplex(object e)
+        {
+            var chk = e as CheckBox;
+            if (chk != null)
+            {
+                if (chk.IsChecked == false)
+                {
+                    this.eventAggregator.GetEvent<SendDuplexPrintModEvent>().Publish(new EnumDuplexPrintModWithUnicode { enumDuplexPrintMod = EnumDuplexPrintMod.StatusNone, Unicode = this.Unicode });
+                }
+                else
+                {
+                    if (IsDuplexModLongEdge)
+                    {
+                        this.eventAggregator.GetEvent<SendDuplexPrintModEvent>().Publish(new EnumDuplexPrintModWithUnicode { enumDuplexPrintMod = EnumDuplexPrintMod.StatusFlipLongEdge, Unicode = this.Unicode });
+                    }
+                    else
+                    {
+                        this.eventAggregator.GetEvent<SendDuplexPrintModEvent>().Publish(new EnumDuplexPrintModWithUnicode { enumDuplexPrintMod = EnumDuplexPrintMod.StatusFlipShortEdge, Unicode = this.Unicode });
+                    }
+                }
+            }
+        }
+
+        public void ChangeDuplexMod(object e)
+        {
+            var rdo = e as RadioButton;
+            if (rdo != null)
+            {
+                if (rdo.Name == "DuplexModLongEdgeRdo")
+                {
+                    this.eventAggregator.GetEvent<SendDuplexPrintModEvent>().Publish(new EnumDuplexPrintModWithUnicode { enumDuplexPrintMod = EnumDuplexPrintMod.StatusFlipLongEdge, Unicode = this.Unicode });
+                }
+                else
+                {
+                    this.eventAggregator.GetEvent<SendDuplexPrintModEvent>().Publish(new EnumDuplexPrintModWithUnicode { enumDuplexPrintMod = EnumDuplexPrintMod.StatusFlipShortEdge, Unicode = this.Unicode });
+                }
+            }
         }
 
         public void SendSizeInfo()

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

@@ -391,6 +391,8 @@ namespace PDF_Office.ViewModels
         public DelegateCommand RedoCommand { get; set; }
         public DelegateCommand<object> MenuEnterReadMode { get; set; }
 
+        public DelegateCommand PrintCommand { get; set; }
+
         #endregion 命令
 
         public ViewContentViewModel(IRegionManager regionManager, IDialogService dialogService, IEventAggregator eventAggregator)
@@ -414,6 +416,8 @@ namespace PDF_Office.ViewModels
             ReadModeRegionName = RegionNames.ReadModeRegionName;
             MenuEnterReadMode = new DelegateCommand<object>(MenuEnterReadModeEvent);
 
+            PrintCommand = new DelegateCommand(ShowPrintDialog);
+
             //未显示时无法注册上Region名称
             ToolContentVisible = Visibility.Visible;
             ToolsBarContentVisible = Visibility.Visible;
@@ -440,6 +444,15 @@ namespace PDF_Office.ViewModels
         {
         }
 
+        public void ShowPrintDialog()
+        {
+            DialogParameters printValue = new DialogParameters();
+            printValue.Add(ParameterNames.PDFViewer, PDFViewer);
+            printValue.Add(ParameterNames.FilePath, PDFViewer.Document.FileName);
+            printValue.Add(ParameterNames.PrintCurrentPage, PDFViewer.CurrentIndex);
+            dialogs.ShowDialog(DialogNames.HomePagePrinterDialog, printValue, e => { });
+        }
+
         private void InitialregionNameByTabItem(ref Dictionary<string, string> dictionary)
         {
             dictionary.Add("TabItemPageEdit", ToolContentRegionName);

+ 11 - 7
PDF Office/Views/Dialog/HomePageToolsDialogs/HomePagePrinter/HomePagePrinterDialog.xaml

@@ -41,8 +41,8 @@
             <Grid Grid.Column="1">
                 <Grid>
                     <Grid.RowDefinitions>
-                        <RowDefinition Height="318"></RowDefinition>
-                        <RowDefinition Height="188"></RowDefinition>
+                        <RowDefinition Height="310"></RowDefinition>
+                        <RowDefinition Height="216"></RowDefinition>
                     </Grid.RowDefinitions>
                     <Grid Grid.Row="0" Margin="0,0,0,0" >
                         <Grid.RowDefinitions>
@@ -72,7 +72,7 @@
                                 <CheckBox Name="GrayscaleChk" VerticalAlignment="Center" Margin="17,0,0,0" Command="{Binding SetGrayscaleCommand}" CommandParameter="{Binding ElementName=GrayscaleChk}">
                                     <TextBlock Text="Black and White"  Foreground="#252629" FontFamily="Segoe UI" FontSize="14"/>
                                 </CheckBox>
-                                <CheckBox Name="BothSidesChk" VerticalAlignment="Center" Margin="17,0,0,0" Command="{Binding SetDuplexCommand}" CommandParameter="{Binding ElementName=BothSidesChk}">
+                                <CheckBox Name="BothSidesChk" VerticalAlignment="Center" Margin="17,0,0,0" Command="{Binding SetDuplexCommand}" CommandParameter="{Binding ElementName=BothSidesChk}" Visibility="{Binding }">
                                     <TextBlock Text="Duplex printing" Foreground="#252629"  FontFamily="Segoe UI" FontSize="14"/>
                                 </CheckBox>
                             </StackPanel>
@@ -82,7 +82,7 @@
                             <StackPanel Orientation="Horizontal" Margin="0,10,0,0">
                                 <StackPanel Orientation="Horizontal">
                                     <TextBlock Text="Page range:" FontFamily="Segoe UI" FontSize="14" Height="22" Width="80"></TextBlock>
-                                    <cus:WritableComboBox  x:Name="PageRangeComboBox" Width="132" Height="32" Margin="16,0,0,0">
+                                    <cus:WritableComboBox  x:Name="PageRangeComboBox" Loaded="PageRangeComboBox_Loaded" Width="132" Height="32" Margin="16,0,0,0">
                                         <i:Interaction.Triggers>
                                             <i:EventTrigger EventName="SelectionChanged">
                                                 <i:InvokeCommandAction Command="{Binding SetPageRangeSelectionIndexCommand}" CommandParameter="{Binding ElementName=PageRangeComboBox}"></i:InvokeCommandAction>
@@ -121,7 +121,7 @@
                                 <CheckBox x:Name="ReversePageCbx" VerticalAlignment="Center"  Command="{Binding SetReversePageCommand}" CommandParameter="{Binding ElementName=ReversePageCbx}">
                                     <TextBlock Text="Reverse pages"  FontFamily="Segoe UI" FontSize="14"/>
                                 </CheckBox>
-                                <CheckBox x:Name="PrintBorderCbx" VerticalAlignment="Center" Margin="25,0,0,0" Command="{Binding SetPrintBorderCommand}" CommandParameter="{Binding ElementName=PrintBorderCbx}">
+                                <CheckBox x:Name="PrintBorderCbx" VerticalAlignment="Center" Margin="25,0,0,0" Command="{Binding SetPrintBorderCommand}" CommandParameter="{Binding ElementName=PrintBorderCbx}" Visibility="{Binding PrintPageBorderVisibility}">
                                     <TextBlock Text="Print page border"  FontFamily="Segoe UI" FontSize="14"/>
                                 </CheckBox>
                             </StackPanel>
@@ -156,8 +156,12 @@
                             </StackPanel>
                         </StackPanel>
                     </Grid>
-                    <Grid Grid.Row="1" Margin="0,0,16,0" VerticalAlignment="Top">
-                        <ContentControl prism:RegionManager.RegionName="{Binding HomePagePrinterModRegionName}"   Visibility="Visible"/>
+                    <Grid Grid.Row="1" Margin="0,0,8,0" VerticalAlignment="Top">
+                        <Grid.ColumnDefinitions>
+                            <ColumnDefinition Width="29*"/>
+                            <ColumnDefinition Width="213*"/>
+                        </Grid.ColumnDefinitions>
+                        <ContentControl prism:RegionManager.RegionName="{Binding HomePagePrinterModRegionName}"   Visibility="Visible" Grid.ColumnSpan="2"/>
                     </Grid>
                 </Grid>
             </Grid>

+ 18 - 2
PDF Office/Views/Dialog/HomePageToolsDialogs/HomePagePrinter/HomePagePrinterDialog.xaml.cs

@@ -1,6 +1,7 @@
-using Prism.Ioc;
+using PDF_Office.ViewModels.Dialog.HomePageToolsDialogs.HomePagePrinter;
+using Prism.Ioc;
 using Prism.Regions;
-
+using System.Windows.Controls;
 using UserControl = System.Windows.Controls.UserControl;
 
 namespace PDF_Office.Views.Dialog.HomePageToolsDialogs.HomePagePrinter
@@ -19,5 +20,20 @@ namespace PDF_Office.Views.Dialog.HomePageToolsDialogs.HomePagePrinter
             RegionManager.SetRegionManager(this, regionManager);
             RegionManager.UpdateRegions();
         }
+
+        private void PageRangeComboBox_Loaded(object sender, System.Windows.RoutedEventArgs e)
+        {
+            if (((HomePagePrinterDialogViewModel)this.DataContext).isCurrentPage)
+            {
+                PageRangeComboBox.CurrentPage = true;
+                if (PageRangeComboBox.CurrentPage)
+                {
+                    ComboBoxItem comboBoxItem = new ComboBoxItem();
+                    comboBoxItem.Content = "当前页面";
+                    PageRangeComboBox.writableComboBox.Items.Insert(1, comboBoxItem);
+
+                }
+            }
+        }
     }
 }

+ 0 - 3
PDF Office/Views/Dialog/HomePageToolsDialogs/HomePagePrinter/HomePagePrinterDocumentContent.xaml

@@ -33,9 +33,6 @@
                             <TextBlock Text="&lt;" VerticalAlignment="Center"></TextBlock>
                         </Button>
                         <TextBox x:Name="CurrentPageIndexTxt" Width="30" Height="25" HorizontalContentAlignment="Center" VerticalContentAlignment="Center" Margin="10,0,5,0" Text="{Binding TargetPaperIndex, UpdateSourceTrigger=PropertyChanged, Mode=TwoWay}"  >
-                            <!--<TextBox.InputBindings>
-                                <KeyBinding Command="{Binding JumpPageCommand}"  CommandParameter="{Binding ElementName=CurrentPageIndexTxt}"  Key="Return"></KeyBinding>
-                            </TextBox.InputBindings>-->
                             <i:Interaction.Triggers>
                                 <i:EventTrigger x:Name="PropertyChanged">
                                     <i:InvokeCommandAction Command="{Binding JumpPageCommand}" CommandParameter="{Binding ElementName=CurrentPageIndexTxt}"></i:InvokeCommandAction>

+ 2 - 3
PDF Office/Views/Dialog/HomePageToolsDialogs/HomePagePrinter/HomePagePrinterModBookletContent.xaml

@@ -14,7 +14,6 @@
             <RowDefinition Height="38*"></RowDefinition>
         </Grid.RowDefinitions>
         <Border Background="#F7F8FA" CornerRadius="4"  Height="128">
-
             <Grid Grid.Row="0">
                 <Grid.RowDefinitions>
                     <RowDefinition Height="1*"></RowDefinition>
@@ -27,13 +26,13 @@
                 </StackPanel>
                 <StackPanel Grid.Row="1" Orientation="Horizontal">
                     <TextBlock Text="Sheets from:" FontFamily="Segoe UI" FontSize="14"  Width="94" Margin="0,0,16,0"   VerticalAlignment="Center" ></TextBlock>
-                    <TextBox Name="PaperFromTxt" Height="32" Width="50"  HorizontalContentAlignment="Center" VerticalContentAlignment="Center" Text="{Binding PaperFrom, Mode=TwoWay}">
+                    <TextBox Name="PaperFromTxt" Height="32" Width="50"  HorizontalContentAlignment="Center" VerticalContentAlignment="Center" Text="{Binding PaperFrom,UpdateSourceTrigger=PropertyChanged, Mode=TwoWay}">
                         <TextBox.InputBindings>
                             <KeyBinding Command="{Binding SetSheetCommand}"  CommandParameter="{Binding ElementName=PaperFromTxt}"  Key="Return"></KeyBinding>
                         </TextBox.InputBindings>
                     </TextBox>
                     <TextBlock FontFamily="Segoe UI" FontSize="14" Text="to"  VerticalAlignment="Center" Margin="8,0,8,0" ></TextBlock>
-                    <TextBox Name="PaperToTxt" Height="32" Width="50"   HorizontalContentAlignment="Center" VerticalContentAlignment="Center" Text="{Binding PaperTo, Mode=TwoWay}">
+                    <TextBox Name="PaperToTxt" Height="32" Width="50"   HorizontalContentAlignment="Center" VerticalContentAlignment="Center" Text="{Binding PaperTo,UpdateSourceTrigger=PropertyChanged, Mode=TwoWay}">
                         <TextBox.InputBindings>
                             <KeyBinding Command="{Binding SetSheetCommand}"  CommandParameter="{Binding ElementName=PaperToTxt}"  Key="Return"></KeyBinding>
                         </TextBox.InputBindings>

+ 28 - 9
PDF Office/Views/Dialog/HomePageToolsDialogs/HomePagePrinter/HomePagePrinterModMultipleContent.xaml

@@ -9,15 +9,16 @@
              xmlns:homepageprinter="clr-namespace:PDF_Office.ViewModels.Dialog.HomePageToolsDialogs.HomePagePrinter" xmlns:i="http://schemas.microsoft.com/xaml/behaviors"
              d:DataContext="{d:DesignInstance Type=homepageprinter:HomePagePrinterModMultipleContentViewModel}"
              mc:Ignorable="d"
-             d:DesignHeight="126"
+             d:DesignHeight="216"
              d:DesignWidth="466">
-    <Grid VerticalAlignment="Top"   Height="126" >
+    <Grid VerticalAlignment="Top"   Height="216" >
         <Grid.RowDefinitions>
-            <RowDefinition Height="88*"></RowDefinition>
-            <RowDefinition Height="38*"></RowDefinition>
+            <RowDefinition Height="88"></RowDefinition>
+            <RowDefinition Height="68"></RowDefinition>
+            <RowDefinition Height="38"></RowDefinition>
         </Grid.RowDefinitions>
         <Border Background="#F7F8FA" CornerRadius="4"  Height="88">
-            <Grid Grid.Row="0">
+            <Grid>
                 <Grid.RowDefinitions>
                     <RowDefinition ></RowDefinition>
                     <RowDefinition  ></RowDefinition>
@@ -31,14 +32,15 @@
                             </i:EventTrigger>
                         </i:Interaction.Triggers>
                     </ComboBox>
-                    <StackPanel Grid.Row="0" Orientation="Horizontal" IsEnabled="{Binding EnableCustomiseMatrix, Mode=OneWay}">
-                        <TextBox Height="32" Width="53" Margin="16,0,8,0" Text="{Binding HorizontalPageNumber, Mode=TwoWay}">
+                    <StackPanel Grid.Row="0" Orientation="Horizontal" IsEnabled="{Binding EnableCustomiseMatrix,UpdateSourceTrigger=PropertyChanged, Mode=OneWay}">
+                        <TextBox Height="32" Width="53" Margin="16,0,8,0" Text="{Binding HorizontalPageNumber, UpdateSourceTrigger=PropertyChanged,Mode=TwoWay}">
                             <TextBox.InputBindings>
                                 <KeyBinding  Command="{Binding SetCustomMatrixCommand}" Key="Return"></KeyBinding>
                             </TextBox.InputBindings>
+
                         </TextBox>
                         <TextBlock Text="X" VerticalAlignment="Center"></TextBlock>
-                        <TextBox Height="32" Width="53"  Margin="8,0,0,0" Text="{Binding  VerticalPageNumber, Mode=TwoWay}">
+                        <TextBox Height="32" Width="53"  Margin="8,0,0,0" Text="{Binding  VerticalPageNumber, UpdateSourceTrigger=PropertyChanged, Mode=TwoWay}">
                             <TextBox.InputBindings>
                                 <KeyBinding  Command="{Binding SetCustomMatrixCommand}" Key="Return"></KeyBinding>
                             </TextBox.InputBindings>
@@ -57,7 +59,24 @@
                 </StackPanel>
             </Grid>
         </Border>
-        <Grid Grid.Row="1" Margin="0,16,0,0">
+        <Grid Grid.Row="1" Margin="0,8,0,0">
+            <Border Background="#F7F8FA" CornerRadius="4" Grid.Row="0">
+                <StackPanel Orientation="Vertical">
+                    <CheckBox Margin="9,12" Name="DuplexChk" Command="{Binding UnlockDuplexCommand}" CommandParameter="{Binding ElementName=DuplexChk}">
+                        <TextBlock Text="Duplex Printing"></TextBlock>
+                    </CheckBox>
+                    <StackPanel Orientation="Horizontal" IsEnabled="{Binding ElementName=DuplexChk, Path=IsChecked}">
+                        <RadioButton Name="DuplexModLongEdgeRdo" Margin="12,0,17,0" IsChecked="{Binding IsDuplexModLongEdge}" Command="{Binding ChangeDuplexModCommand}" CommandParameter="{Binding ElementName=DuplexModLongEdgeRdo}">
+                            <TextBlock Text="Flip On Long Edge"></TextBlock>
+                        </RadioButton>
+                        <RadioButton Name="DuplexModShortEdgeRdo" IsChecked="{Binding IsDuplexModShortEdge}"  Command="{Binding ChangeDuplexModCommand}" CommandParameter="{Binding ElementName=DuplexModShortEdgeRdo}">
+                            <TextBlock Text="Flip On Short Edge"></TextBlock>
+                        </RadioButton>
+                    </StackPanel>
+                </StackPanel>
+            </Border>
+        </Grid>
+        <Grid Grid.Row="2" Margin="0,16,0,0">
             <StackPanel Orientation="Horizontal">
                 <CheckBox Name="AutoRotationChk"  VerticalAlignment="Center" Command="{Binding SetAutoRotateCommand}" IsChecked="{Binding IsAutoRotate}">
                     <TextBlock Text="Auto-rotate pages in each sheet" FontFamily="Segoe UI" FontSize="14"></TextBlock>

+ 1 - 1
PDF Office/Views/Dialog/HomePageToolsDialogs/HomePagePrinter/HomePagePrinterModPosterContent.xaml

@@ -79,7 +79,7 @@
                 <StackPanel Orientation="Horizontal">
                     <CheckBox  Name="SetLabelChk" Margin="0,0,11,0" VerticalAlignment="Center" Command="{Binding SetLabelCommand}" CommandParameter="{Binding ElementName=SetLabelChk}"></CheckBox>
                     <TextBlock Text="Label" VerticalAlignment="Center" Margin="0,0,16,0" FontSize="14"></TextBlock>
-                    <TextBox Height="32" Width="361" Text="{Binding LabelString, UpdateSourceTrigger=PropertyChanged, Mode=TwoWay}" IsEnabled="{Binding ElementName=SetLabelChk, Path=IsChecked}">
+                    <TextBox Height="32" Width="361" Text="{Binding LabelString, UpdateSourceTrigger=PropertyChanged, Mode=TwoWay}" IsEnabled="{Binding ElementName=SetLabelChk, Path=IsChecked}" IsReadOnly="True">
                         <TextBox.Resources>
                             <VisualBrush x:Key="HelpBrush" TileMode ="None" Opacity="0.3" Stretch="None" AlignmentX="Left">
                                 <VisualBrush.Visual>

+ 48 - 25
PDF Office/Views/Dialog/HomePageToolsDialogs/HomePagePrinter/HomePagePrinterModSizeContent.xaml

@@ -9,31 +9,54 @@
              xmlns:homepageprinter="clr-namespace:PDF_Office.ViewModels.Dialog.HomePageToolsDialogs.HomePagePrinter" 
              d:DataContext="{d:DesignInstance Type=homepageprinter:HomePagePrinterModSizeContentViewModel}"
              mc:Ignorable="d"
-             d:DesignHeight="108"
+             d:DesignHeight="184"
              d:DesignWidth="466">
-    <Border Background="#F7F8FA" CornerRadius="4"  Height="108">
-        <Grid VerticalAlignment="Top"  Height="108">
-            <Grid.RowDefinitions>
-                <RowDefinition></RowDefinition>
-                <RowDefinition></RowDefinition>
-                <RowDefinition></RowDefinition>
-            </Grid.RowDefinitions>
-            <Grid Grid.Row="0" Margin="0,8,0,8">
-                <RadioButton Name="StatusAdaptiveRdo" VerticalAlignment="Center" GroupName="ModSize" IsChecked="True" Command="{Binding SetModSizeStatusCommand}" CommandParameter="{Binding ElementName=StatusAdaptiveRdo}">
-                    <TextBlock Text="Auto adapt" FontFamily="Segoe UI" FontSize="14"></TextBlock>
-                </RadioButton>
+    <Grid>
+        <Grid.RowDefinitions>
+            <RowDefinition   Height="108"></RowDefinition>
+            <RowDefinition></RowDefinition>
+        </Grid.RowDefinitions>
+            <Border Background="#F7F8FA" CornerRadius="4" Grid.Row="0">
+            <Grid VerticalAlignment="Top"  Height="108">
+                <Grid.RowDefinitions>
+                    <RowDefinition></RowDefinition>
+                    <RowDefinition></RowDefinition>
+                    <RowDefinition></RowDefinition>
+                </Grid.RowDefinitions>
+                <Grid Grid.Row="0" Margin="0,8,0,8">
+                    <RadioButton Name="StatusAdaptiveRdo" VerticalAlignment="Center" GroupName="ModSize" IsChecked="True" Command="{Binding SetModSizeStatusCommand}" CommandParameter="{Binding ElementName=StatusAdaptiveRdo}">
+                        <TextBlock Text="Auto adapt" FontFamily="Segoe UI" FontSize="14"></TextBlock>
+                    </RadioButton>
+                </Grid>
+                <Grid Grid.Row="1">
+                    <RadioButton Name="StatusActuralRdo" VerticalAlignment="Center" GroupName="ModSize" Command="{Binding SetModSizeStatusCommand}" CommandParameter="{Binding ElementName=StatusActuralRdo}">
+                        <TextBlock Text="Actual size" FontFamily="Segoe UI" FontSize="14"></TextBlock>
+                    </RadioButton>
+                </Grid>
+                <Grid Grid.Row="2"  Margin="0,0,0,8"  Height="40" VerticalAlignment="Center">
+                    <RadioButton Name="StatusCustomizedRdo" VerticalAlignment="Center" GroupName="ModSize" Command="{Binding SetModSizeStatusCommand}" CommandParameter="{Binding ElementName=StatusCustomizedRdo}">
+                        <TextBlock Text="Custom scale:" FontFamily="Segoe UI" FontSize="14"></TextBlock>
+                    </RadioButton>
+                    <cus:NumericUpDown x:Name="CustomRatioUpDown" Width="90" Height="32" Margin="15,0,0,0" Loaded="CustomRatioUpDown_Loaded" Text="{Binding DisplayRatio, Mode=TwoWay}" IsEnabled="{Binding ElementName=CustomRatioBtn, Path=IsChecked}"></cus:NumericUpDown>
+                </Grid>
             </Grid>
-            <Grid Grid.Row="1">
-                <RadioButton Name="StatusActuralRdo" VerticalAlignment="Center" GroupName="ModSize" Command="{Binding SetModSizeStatusCommand}" CommandParameter="{Binding ElementName=StatusActuralRdo}">
-                    <TextBlock Text="Actual size" FontFamily="Segoe UI" FontSize="14"></TextBlock>
-                </RadioButton>
-            </Grid>
-            <Grid Grid.Row="2"  Margin="0,0,0,8"  Height="40" VerticalAlignment="Center">
-                <RadioButton Name="StatusCustomizedRdo" VerticalAlignment="Center" GroupName="ModSize" Command="{Binding SetModSizeStatusCommand}" CommandParameter="{Binding ElementName=StatusCustomizedRdo}">
-                    <TextBlock Text="Custom scale:" FontFamily="Segoe UI" FontSize="14"></TextBlock>
-                </RadioButton>
-                <cus:NumericUpDown x:Name="CustomRatioUpDown" Width="90" Height="32" Margin="15,0,0,0" Loaded="CustomRatioUpDown_Loaded" Text="{Binding DisplayRatio, Mode=TwoWay}" IsEnabled="{Binding ElementName=CustomRatioBtn, Path=IsChecked}"></cus:NumericUpDown>
-            </Grid>
-        </Grid>
-    </Border>
+        </Border>
+        <Grid Grid.Row="1" Margin="0,8,0,0">
+            <Border Background="#F7F8FA" CornerRadius="4" Grid.Row="0">
+                <StackPanel Orientation="Vertical">
+                    <CheckBox Margin="9,12" Name="DuplexChk" Command="{Binding UnlockDuplexCommand}" CommandParameter="{Binding ElementName=DuplexChk}">
+                        <TextBlock Text="Duplex Printing"></TextBlock>
+                    </CheckBox>
+                    <StackPanel Orientation="Horizontal" IsEnabled="{Binding ElementName=DuplexChk, Path=IsChecked}">
+                        <RadioButton Name="DuplexModLongEdgeRdo" Margin="12,0,17,0" IsChecked="{Binding IsDuplexModLongEdge}" Command="{Binding ChangeDuplexModCommand}" CommandParameter="{Binding ElementName=DuplexModLongEdgeRdo}">
+                            <TextBlock Text="Flip On Long Edge"></TextBlock>
+                        </RadioButton>
+                        <RadioButton Name="DuplexModShortEdgeRdo" IsChecked="{Binding IsDuplexModShortEdge}"  Command="{Binding ChangeDuplexModCommand}" CommandParameter="{Binding ElementName=DuplexModShortEdgeRdo}">
+                            <TextBlock Text="Flip On Short Edge"></TextBlock>
+                        </RadioButton>
+                    </StackPanel>
+                </StackPanel>
+            </Border>
+        </Grid> 
+    </Grid>
 </UserControl>

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

@@ -89,7 +89,7 @@
                 <Button
                     Margin="8"
                     Style="{StaticResource MenuButtonStyle}"
-                    ToolTip="Print">
+                    ToolTip="Print" Command="{Binding PrintCommand}">
                     <Path Data="M12 6V0H4V6H1.5L1.35554 6.00687C0.594888 6.07955 0 6.7203 0 7.5V14H4V16H12V14H16V7.5L15.9931 7.35554C15.9204 6.59489 15.2797 6 14.5 6H12ZM4 10V13H1V7.5L1.00806 7.41012C1.05039 7.17688 1.25454 7 1.5 7H14.5L14.5899 7.00806C14.8231 7.05039 15 7.25454 15 7.5V13H12V10H4ZM11 6V1H5V6H11ZM11 11H5V15H11V11ZM3 8H2V9H3V8Z" Fill="#333333" />
                 </Button>
                 <Button