liuaoran 2 лет назад
Родитель
Сommit
bda459334d

+ 5 - 1
PDF Office/Model/Dialog/HomePageToolsDialogs/HomePagePrinter/HomePagePrinterDialogModel.cs

@@ -1,5 +1,6 @@
 using System;
 using System.Collections.Generic;
+using System.Drawing.Printing;
 using System.Linq;
 using System.Numerics;
 using System.Runtime.Remoting.Channels;
@@ -27,10 +28,11 @@ namespace PDF_Office.Model.Dialog.HomePageToolsDialogs.HomePagePrinter
 
     public class HomePagePrinterDialogModel
     {
+      
     }
 
     public enum EnumPaperSize
-    {
+    { 
         StatusA3,
         StatusA4,
         StatusA5,
@@ -48,6 +50,8 @@ namespace PDF_Office.Model.Dialog.HomePageToolsDialogs.HomePagePrinter
         StatusCustomized
     }
 
+
+
     public enum EnumSizeType
     {
         StatusAdaptive,

+ 145 - 63
PDF Office/ViewModels/Dialog/HomePageToolsDialogs/HomePagePrinter/HomePagePrinterDialogViewModel.cs

@@ -1,39 +1,26 @@
-using PDF_Office.Views.Dialog.HomePageToolsDialogs.HomePagePrinter;
 using Prism.Commands;
 using Prism.Mvvm;
 using Prism.Regions;
 using Prism.Services.Dialogs;
 using System;
 using System.Collections.Generic;
-using System.Windows.Controls;
 using System.Windows;
-using System.Diagnostics;
 using System.Drawing.Printing;
-using PDFSettings;
 using ComPDFKit.PDFDocument;
 using PDF_Office.Model;
 using System.Drawing;
 using System.Reflection;
 using PDF_Office.Model.Dialog.HomePageToolsDialogs.HomePagePrinter;
 using System.Threading.Tasks;
-using static PDF_Office.Model.Dialog.ToolsDialogs.SaftyDialogs.SetPasswordDialogModel;
 using ComPDFKit.PDFPage;
 using PDF_Office.Helper;
 using System.Drawing.Drawing2D;
-using static PDF_Office.Model.Dialog.HomePageToolsDialogs.HomePagePrinter.HomePagePrinterDialogModel;
 using ComPDFKitViewer.PdfViewer;
 using System.Windows.Media.Imaging;
 using System.Drawing.Imaging;
-using System.Text.RegularExpressions;
 using PDF_Office.CustomControl;
-using System.IO;
 using Prism.Events;
-using PrintMod = PDF_Office.Model.Dialog.HomePageToolsDialogs.HomePagePrinter.PrintMod;
-using FastExpressionCompiler.LightExpression;
 using ImTools;
-using DryIoc;
-using System.Windows.Annotations;
-using System.Windows.Forms;
 
 namespace PDF_Office.ViewModels.Dialog.HomePageToolsDialogs.HomePagePrinter
 {
@@ -45,7 +32,34 @@ namespace PDF_Office.ViewModels.Dialog.HomePageToolsDialogs.HomePagePrinter
         public IRegionManager PrintModRegion;
         private Object locker = new Object();
         private CPDFViewer currentViewer;
-        private string currentPrintModName;
+
+        private string _currentPrintModName;
+        public string CurrentPrintModName
+        {
+            get { return _currentPrintModName; }
+            set
+            {
+                if (value == "ModSize")
+                {
+                    IsEnableForModBooklet = true;
+                    IsEnableForModMultiple = true;
+                    IsEnableForModSize = false;
+                }
+                else if (value == "ModMultiple")
+                {
+                    IsEnableForModBooklet = true;
+                    IsEnableForModMultiple = false;
+                    IsEnableForModSize = true;
+                }
+                else if (value == "ModBooklet")
+                {
+                    IsEnableForModBooklet = false;
+                    IsEnableForModMultiple = true;
+                    IsEnableForModSize = true;
+                }
+                _currentPrintModName = value;
+            }
+        }
 
         public HomePagePrinterDialogModel homePagePrinterDialogModel;
         public HomePagePrinterPageSetDialogViewModel homePagePrinterPageSetDialogViewModel { get; set; }
@@ -86,7 +100,10 @@ namespace PDF_Office.ViewModels.Dialog.HomePageToolsDialogs.HomePagePrinter
         public List<string> PrintOrientationList
         {
             get { return _printerOrientationList; }
-            set { _printerOrientationList = value; }
+            set
+            {
+                _printerOrientationList = value;
+            }
         }
 
         private bool _isEnableForGetNextPage = true;
@@ -110,6 +127,40 @@ namespace PDF_Office.ViewModels.Dialog.HomePageToolsDialogs.HomePagePrinter
                 RaisePropertyChanged();
             }
         }
+
+        private bool _isEnableForModSize = false;
+        public bool IsEnableForModSize
+        {
+            get { return _isEnableForModSize; }
+            set
+            {
+                SetProperty(ref _isEnableForModSize, value);
+            }
+        }
+
+        private bool _isEnableForModPoster = false;
+        public bool IsEnableForModPoster
+        {
+            get { return _isEnableForModPoster; }
+            set { _isEnableForModPoster = value; }
+        }
+
+        private bool _isEnableForModMultiple = true;
+        public bool IsEnableForModMultiple
+        {
+            get { return _isEnableForModMultiple; }
+            set { SetProperty(ref _isEnableForModMultiple, value); }
+        }
+
+        private bool _isEnableForModBooklet = true;
+        public bool IsEnableForModBooklet
+        {
+            get { return _isEnableForModBooklet; }
+            set
+            {
+                SetProperty(ref _isEnableForModBooklet, value);
+            }
+        }
         #endregion
 
         #region 属性设置
@@ -181,7 +232,7 @@ namespace PDF_Office.ViewModels.Dialog.HomePageToolsDialogs.HomePagePrinter
             set { _enumPaperSize = value; }
         }
 
-        private int _leftMargin;
+        private int _leftMargin = 0;
         /// <summary>
         /// 纸张左边距
         /// </summary>
@@ -191,7 +242,7 @@ namespace PDF_Office.ViewModels.Dialog.HomePageToolsDialogs.HomePagePrinter
             set { _leftMargin = value; }
         }
 
-        private int _rightMargin;
+        private int _rightMargin = 0;
         /// <summary>
         /// 纸张右边距
         /// </summary>
@@ -201,7 +252,7 @@ namespace PDF_Office.ViewModels.Dialog.HomePageToolsDialogs.HomePagePrinter
             set { _rightMargin = value; }
         }
 
-        private int _bottomMargin;
+        private int _bottomMargin = 0;
         /// <summary>
         /// 纸张下边距
         /// </summary>
@@ -211,7 +262,7 @@ namespace PDF_Office.ViewModels.Dialog.HomePageToolsDialogs.HomePagePrinter
             set { _bottomMargin = value; }
         }
 
-        private int _topMargin;
+        private int _topMargin = 0;
         /// <summary>
         /// 纸张上边距
         /// </summary>
@@ -377,12 +428,24 @@ namespace PDF_Office.ViewModels.Dialog.HomePageToolsDialogs.HomePagePrinter
             get { return _printOrientationIndex; }
             set
             {
+                if (value != _printOrientationIndex)
+                {
+                    if(value == 0)
+                    {
+                        RotatePreviewPaperWhenPortrait();
+                    }
+                    if (value == 1)
+                    {
+                        RotatePreviewPaperWhenLandscape();
+                    }
+                }
                 _printOrientationIndex = value;
                 if (flagIsAutoOrientation == true)
                 {
                     flagIsAutoOrientation = false;
                 }
                 RaisePropertyChanged(nameof(PrintOrientationIndex));
+
             }
         }
         #endregion
@@ -596,8 +659,6 @@ namespace PDF_Office.ViewModels.Dialog.HomePageToolsDialogs.HomePagePrinter
 
         }
 
-
-
         #region 组件初始化
         private void InitComponent()
         {
@@ -625,7 +686,7 @@ namespace PDF_Office.ViewModels.Dialog.HomePageToolsDialogs.HomePagePrinter
 
             lock (locker)
             {
-                switch (currentPrintModName)
+                switch (CurrentPrintModName)
                 {
                     case "ModPoster":
                         PreviewModPoster(CurrentPreviewIndex);
@@ -732,12 +793,31 @@ namespace PDF_Office.ViewModels.Dialog.HomePageToolsDialogs.HomePagePrinter
         #endregion
 
         #region 打印预览
+
+        public void RotatePreviewPaperWhenLandscape()
+        {
+                RotateAngle = 90;
+                RotateCenterX = ViewBoxWidth / 2;
+                RotateCenterY = ViewBoxHeight / 2;
+                int temp;
+                temp = PaperWidth;
+                PaperWidth = PaperHeight;
+                PaperHeight = temp;
+        }
+        public void RotatePreviewPaperWhenPortrait()
+        {
+                RotateAngle = 0;
+                RotateCenterX = 0;
+                RotateCenterY = 0;
+        }
+
+
         /// <summary>
         /// 翻页刷新
         /// </summary>
         public void GetPagePreviewWhenIndexChanged()
         {
-            if (currentPrintModName == "ModSize" && currentPrintModName == "ModPoster")
+            if (CurrentPrintModName == "ModSize" && CurrentPrintModName == "ModPoster")
             {
                 CurrentPreviewIndex = TargetPages[currentListIndex];
             }
@@ -890,9 +970,9 @@ namespace PDF_Office.ViewModels.Dialog.HomePageToolsDialogs.HomePagePrinter
             {
                 double left = 0;
                 double top = 0;
-                double rate = 0.55;
+                double ratio = 0.55;
                 int dpi = (int)GetDpiByGraphics();
-                Bitmap bitmap = await ToolMethod.RenderPageBitmap(document, (int)(cPDFPage.PageSize.Width * rate * 1.4), (int)(cPDFPage.PageSize.Height * rate * 1.4), paperIndex, printSettingsInfo.PrintWithAnnot, printSettingsInfo.PrintWithForm);
+                Bitmap bitmap = await ToolMethod.RenderPageBitmap(document, (int)(cPDFPage.PageSize.Width * ratio * 1.4), (int)(cPDFPage.PageSize.Height * ratio * 1.4), paperIndex, printSettingsInfo.PrintWithAnnot, printSettingsInfo.PrintWithForm);
                 var pageBound = printDocument.DefaultPageSettings.Bounds;
 
                 if (printSettingsInfo.IsBlackAndWhite)
@@ -905,9 +985,9 @@ namespace PDF_Office.ViewModels.Dialog.HomePageToolsDialogs.HomePagePrinter
                 if (printSettingsInfo.EnumPrintOrientation == EnumPrintOrientation.StatusLandscape)
                 {
                     bitmap.RotateFlip(RotateFlipType.Rotate270FlipNone);
-                    bitmap = (Bitmap)ResizeImage(bitmap, new System.Drawing.Size((int)(pageBound.Width * rate), (int)(pageBound.Height * rate)));
+                    bitmap = (Bitmap)ResizeImage(bitmap, new System.Drawing.Size((int)(pageBound.Width * ratio), (int)(pageBound.Height * ratio)));
                 }
-                else { }
+
                 System.Drawing.Size newSize = new System.Drawing.Size();
 
                 if (sizeInfo.EnumSizeType == EnumSizeType.StatusAdaptive)
@@ -915,8 +995,8 @@ namespace PDF_Office.ViewModels.Dialog.HomePageToolsDialogs.HomePagePrinter
                     float zoompercent = 0;
                     float percentW = 0;
                     float percentH = 0;
-                    percentW = ((float)(pageBound.Width * rate) / (float)bitmap.Width);
-                    percentH = ((float)(pageBound.Height * rate) / (float)bitmap.Height);
+                    percentW = ((float)(pageBound.Width * ratio) / (float)bitmap.Width);
+                    percentH = ((float)(pageBound.Height * ratio) / (float)bitmap.Height);
                     zoompercent = percentH > percentW ? percentW : percentH;
 
                     newSize = new System.Drawing.Size((int)(bitmap.Width * zoompercent), (int)(bitmap.Height * zoompercent));
@@ -933,11 +1013,11 @@ namespace PDF_Office.ViewModels.Dialog.HomePageToolsDialogs.HomePagePrinter
 
                 bitmap = (Bitmap)ResizeImage(bitmap, newSize);
 
-                left = (pageBound.Width * rate - bitmap.Width) / 2;
-                top = (pageBound.Height * rate - bitmap.Height) / 2;
+                left = (pageBound.Width * ratio - bitmap.Width) / 2;
+                top = (pageBound.Height * ratio - bitmap.Height) / 2;
 
-                int pwidth = (int)(pageBound.Width * rate);
-                int pheight = (int)(pageBound.Height * rate);
+                int pwidth = (int)(pageBound.Width * ratio);
+                int pheight = (int)(pageBound.Height * ratio);
 
                 Bitmap bmp = new Bitmap(pwidth, pheight);
                 Graphics g = Graphics.FromImage(bmp);
@@ -995,16 +1075,17 @@ namespace PDF_Office.ViewModels.Dialog.HomePageToolsDialogs.HomePagePrinter
         private async void PreviewModMultiple(int currentPreviewIndex)
         {
             MultipleInfo multipleInfo = (MultipleInfo)this.printSettingsInfo.printMod;
+
             int pageCount = multipleInfo.HorizontalPageNumber * multipleInfo.VerticalPageNumber;
-            printDocument.DefaultPageSettings.PaperSize = new PaperSize("CustomisePaperSize", PaperHeight * 4, PaperWidth * 4);
+            printDocument.DefaultPageSettings.PaperSize = new PaperSize("CustomisePaperSize", PaperWidth * 4, PaperHeight * 4);
             Rectangle pageBound = printDocument.DefaultPageSettings.Bounds;
 
             double ratio = 0.5;
             double adjustRatio = 0.25;
 
             //每个区域的大小
-            double eachPageWidth = pageBound.Width  * 1.0 / multipleInfo.HorizontalPageNumber;
-            double eachPageHeight = pageBound.Height  * 1.0 / multipleInfo.VerticalPageNumber;
+            double eachPageWidth = pageBound.Width * 1.0 * ratio / multipleInfo.HorizontalPageNumber;
+            double eachPageHeight = pageBound.Height * 1.0 * ratio / multipleInfo.VerticalPageNumber;
             System.Drawing.Size newSize = new System.Drawing.Size(Convert.ToInt32(eachPageWidth), Convert.ToInt32(eachPageHeight));
 
             int indexOfList = currentPreviewIndex;
@@ -1047,7 +1128,12 @@ namespace PDF_Office.ViewModels.Dialog.HomePageToolsDialogs.HomePagePrinter
 
                             if (printSettingsInfo.IsBlackAndWhite == true)
                             {
-                                bitmapWhenDefault = ToGray(bitmapWhenDefault, 0);
+                                bitmapWhenSuccessful = ToGray(bitmapWhenSuccessful, 0);
+                            }
+
+                            if (printSettingsInfo.EnumPrintOrientation == EnumPrintOrientation.StatusLandscape)
+                            {
+                                bitmapWhenSuccessful.RotateFlip(RotateFlipType.Rotate270FlipNone);
                             }
 
                             if (multipleInfo.IsAutoRotate &&
@@ -1155,7 +1241,7 @@ namespace PDF_Office.ViewModels.Dialog.HomePageToolsDialogs.HomePagePrinter
         {
             BookletInfo bookletInfo = (BookletInfo)printSettingsInfo.printMod;
 
-            printDocument.DefaultPageSettings.PaperSize = new PaperSize("CustomisePaperSize", PaperHeight * 4, PaperWidth * 4);
+            printDocument.DefaultPageSettings.PaperSize = new PaperSize("CustomisePaperSize", PaperWidth * 4, PaperHeight * 4);
             Rectangle pageBound = printDocument.DefaultPageSettings.Bounds;
             double ratio = 0.5;
 
@@ -1202,7 +1288,7 @@ namespace PDF_Office.ViewModels.Dialog.HomePageToolsDialogs.HomePagePrinter
                 }
             }
 
-            Bitmap bmp = new Bitmap(pageBound.Width, pageBound.Height);
+            Bitmap bmp = new Bitmap(pageBound.Height, pageBound.Width);
             if (!printDocument.DefaultPageSettings.Landscape)
                 bmp.RotateFlip(RotateFlipType.Rotate270FlipNone);
             Graphics g = Graphics.FromImage(bmp);
@@ -1293,7 +1379,7 @@ namespace PDF_Office.ViewModels.Dialog.HomePageToolsDialogs.HomePagePrinter
             try
             {
                 printerSettings.PrinterName = PrinterNameList[PrinterIndex];
-                if (currentPrintModName == "ModBooklet")
+                if (CurrentPrintModName == "ModBooklet")
                 {
                     BookletInfo bookletInfo = (BookletInfo)printSettingsInfo.printMod;
                     pageSettings.Landscape = true;
@@ -1306,10 +1392,6 @@ namespace PDF_Office.ViewModels.Dialog.HomePageToolsDialogs.HomePagePrinter
                     currentListIndex = 0;
                     CurrentPreviewIndex = 0;
                     printListIndex = 0;
-
-
-
-
                 }
                 await Task.Run(() =>
                 {
@@ -1333,7 +1415,7 @@ namespace PDF_Office.ViewModels.Dialog.HomePageToolsDialogs.HomePagePrinter
 
         private void PrintDocument_PrintPage(object sender, PrintPageEventArgs e)
         {
-            switch (currentPrintModName)
+            switch (CurrentPrintModName)
             {
                 case "ModPoster":
                     PrintDocumentModPoster(e);
@@ -1446,7 +1528,7 @@ namespace PDF_Office.ViewModels.Dialog.HomePageToolsDialogs.HomePagePrinter
             {
 
                 //一张纸的页面数
-                int h =multipleInfo.VerticalPageNumber;//行
+                int h = multipleInfo.VerticalPageNumber;//行
                 int v = multipleInfo.HorizontalPageNumber;//列
                 int num = h * v;
                 //纸张大小
@@ -1505,8 +1587,8 @@ namespace PDF_Office.ViewModels.Dialog.HomePageToolsDialogs.HomePagePrinter
                                 int top = 0;
                                 int left = 0;
 
-                                    left = (int)(new_size.Width - pagewidth) / 2;
-                                    top = (int)(new_size.Height - pageheight) / 2;
+                                left = (int)(new_size.Width - pagewidth) / 2;
+                                top = (int)(new_size.Height - pageheight) / 2;
 
                                 if (multipleInfo.EnumPageOrder == EnumPageOrder.StatusHorizontalOrder)
                                 {
@@ -1560,8 +1642,8 @@ namespace PDF_Office.ViewModels.Dialog.HomePageToolsDialogs.HomePagePrinter
                                 int top = 0;
                                 int left = 0;
 
-                                    left = (new_size.Width - (int)pagewidth) / 2;
-                                    top = (new_size.Height - (int)pageheight) / 2;
+                                left = (new_size.Width - (int)pagewidth) / 2;
+                                top = (new_size.Height - (int)pageheight) / 2;
 
                                 if (multipleInfo.EnumPageOrder == EnumPageOrder.StatusVerticalOrder)//纵向
                                 {
@@ -1655,10 +1737,10 @@ namespace PDF_Office.ViewModels.Dialog.HomePageToolsDialogs.HomePagePrinter
                     int top = 0;
                     int left = 0;
 
-                        left = (new_size.Width - (int)pagewidth) / 2;
-                        top = (new_size.Height - (int)pageheight) / 2;
-                    
-                    if (bookletInfo.EnumBookletBinding ==  EnumBookletBinding.StatusLeft)//左装订
+                    left = (new_size.Width - (int)pagewidth) / 2;
+                    top = (new_size.Height - (int)pageheight) / 2;
+
+                    if (bookletInfo.EnumBookletBinding == EnumBookletBinding.StatusLeft)//左装订
                     {
                         if ((int)bookletInfo.EnumBookletSubset < 2 || TargetPages.Count == 2)//仅双面打印的时候需要左右装订的方式交替打印,单面打印的时候不不需要
                         {
@@ -1704,7 +1786,7 @@ namespace PDF_Office.ViewModels.Dialog.HomePageToolsDialogs.HomePagePrinter
                     bitmap.Dispose();
                 }
             }
-            int MaxPageIndex =( (document.PageCount%4==0)?(document.PageCount/4):(document.PageCount/4+1))*2;
+            int MaxPageIndex = ((document.PageCount % 4 == 0) ? (document.PageCount / 4) : (document.PageCount / 4 + 1)) * 2;
             if (printListIndex + 1 < MaxPageIndex)
             {
                 e.HasMorePages = true;
@@ -1778,12 +1860,12 @@ namespace PDF_Office.ViewModels.Dialog.HomePageToolsDialogs.HomePagePrinter
         private void SubscribeEvent(Model.Dialog.HomePageToolsDialogs.HomePagePrinter.PrintMod printMod)
         {
             this.printSettingsInfo.printMod = printMod;
-            if (currentPrintModName == "ModMultiple")
+            if (CurrentPrintModName == "ModMultiple")
             {
                 MultipleInfo multipleInfo = (MultipleInfo)this.printSettingsInfo.printMod;
                 MaxPageNumber = ((TargetPages.Count % (multipleInfo.HorizontalPageNumber * multipleInfo.VerticalPageNumber) == 0) ? (TargetPages.Count / (multipleInfo.HorizontalPageNumber * multipleInfo.VerticalPageNumber)) : (TargetPages.Count / (multipleInfo.HorizontalPageNumber * multipleInfo.VerticalPageNumber) + 1)).ToString();
             }
-            else if (currentPrintModName == "ModBooklet")
+            else if (CurrentPrintModName == "ModBooklet")
             {
                 if (TargetPages.Count < 2)
                 {
@@ -2004,8 +2086,8 @@ namespace PDF_Office.ViewModels.Dialog.HomePageToolsDialogs.HomePagePrinter
             var args = e as System.Windows.Controls.Button;
             if (args != null)
             {
-                currentPrintModName = args.Name;
-                EnterSelectedMod(currentPrintModName);
+                CurrentPrintModName = args.Name;
+                EnterSelectedMod(CurrentPrintModName);
                 //TODO:
             }
         }
@@ -2025,7 +2107,7 @@ namespace PDF_Office.ViewModels.Dialog.HomePageToolsDialogs.HomePagePrinter
         {
             if (ExistentPrintModName != "ModSize")
             {
-                currentPrintModName = "ModSize";
+                CurrentPrintModName = "ModSize";
                 NavigationParameters param = new NavigationParameters();
                 PrintModVisible = Visibility.Collapsed;
                 NavigationParameters keyValuePairs = param;
@@ -2046,11 +2128,11 @@ namespace PDF_Office.ViewModels.Dialog.HomePageToolsDialogs.HomePagePrinter
             {
                 currentViewer = viewer;
                 document = currentViewer.Document;
-                if (currentPrintModName == null)
+                if (CurrentPrintModName == null)
                 {
-                    currentPrintModName = "ModSize";
+                    CurrentPrintModName = "ModSize";
                 }
-                PrintModRegion.RequestNavigate(PrintModRegionName, GetContentByPrintMod[currentPrintModName]);
+                PrintModRegion.RequestNavigate(PrintModRegionName, GetContentByPrintMod[CurrentPrintModName]);
                 InitPrintParams();
                 GetTargetPageIndexFromAll();
                 InitRender();

+ 23 - 13
PDF Office/ViewModels/Dialog/HomePageToolsDialogs/HomePagePrinter/HomePagePrinterModBookletContentViewModel.cs

@@ -34,11 +34,11 @@ namespace PDF_Office.ViewModels.Dialog.HomePageToolsDialogs.HomePagePrinter
             }
             set
             {
-                if(PaperTo == null)
+                if (PaperTo == null)
                 {
                     SetProperty(ref _paperFrom, 1);
                 }
-               else if (value < PaperTo)
+                else if (value < PaperTo)
                 {
                     SetProperty(ref _paperFrom, value);
                 }
@@ -76,11 +76,16 @@ namespace PDF_Office.ViewModels.Dialog.HomePageToolsDialogs.HomePagePrinter
             set { _subsetList = value; }
         }
 
-        private int _subsetIndex=0;
+        private int _subsetIndex = 0;
         public int SubsetIndex
         {
             get { return _subsetIndex; }
-            set { _subsetIndex = value; }
+            set
+            {
+                _subsetIndex = value;
+                InitBookletInfo();
+                SendBookletInfo();
+            }
         }
 
         private List<string> _bindingList;
@@ -90,11 +95,16 @@ namespace PDF_Office.ViewModels.Dialog.HomePageToolsDialogs.HomePagePrinter
             set { _bindingList = value; }
         }
 
-        private int _bindingIndex=0;
+        private int _bindingIndex = 0;
         public int BindingIndex
         {
             get { return _bindingIndex; }
-            set { _bindingIndex = value; }
+            set
+            {
+                _bindingIndex = value;
+                InitBookletInfo();
+                SendBookletInfo();
+            }
         }
 
         private BookletInfo _bookletInfo;
@@ -138,11 +148,11 @@ namespace PDF_Office.ViewModels.Dialog.HomePageToolsDialogs.HomePagePrinter
             BindingList.Add("右");
         }
 
-        private void InitBookletInfo ()
+        private void InitBookletInfo()
         {
             BookletInfo.EnumBookletSubset = (EnumBookletSubset)SubsetIndex;
             BookletInfo.EnumBookletBinding = (EnumBookletBinding)BindingIndex;
-            if(PaperFrom!=null)
+            if (PaperFrom != null)
             {
                 BookletInfo.BeginPaperIndex = (int)PaperFrom;
             }
@@ -150,7 +160,7 @@ namespace PDF_Office.ViewModels.Dialog.HomePageToolsDialogs.HomePagePrinter
             {
                 BookletInfo.BeginPaperIndex = 1;
             }
-            if(PaperTo!=null)
+            if (PaperTo != null)
             {
                 BookletInfo.EndPaperIndex = (int)PaperTo;
             }
@@ -158,12 +168,12 @@ namespace PDF_Office.ViewModels.Dialog.HomePageToolsDialogs.HomePagePrinter
             {
                 BookletInfo.EndPaperIndex = MaxPaperNumber;
             }
-            BookletInfo.IsAutoRotate= IsAutoRotate;
+            BookletInfo.IsAutoRotate = IsAutoRotate;
         }
 
         public void SendBookletInfo()
         {
-            if(BookletInfo!=null)
+            if (BookletInfo != null)
             {
                 this.eventAggregator.GetEvent<ModInfoSendEvent>().Publish(BookletInfo);
             }
@@ -184,13 +194,13 @@ namespace PDF_Office.ViewModels.Dialog.HomePageToolsDialogs.HomePagePrinter
             {
                 document = navigationContext.Parameters.GetValue<CPDFDocument>("document");
                 MaxPaperNumber = (document.PageCount % 4 == 0) ? (document.PageCount / 4) : (document.PageCount / 4 + 1);
-                if(PaperFrom == null)
+                if (PaperFrom == null)
                 {
                     PaperFrom = 1;
                 }
                 if (PaperTo == null)
                 {
-                    PaperTo= MaxPaperNumber;
+                    PaperTo = MaxPaperNumber;
                 }
                 InitBookletInfo();
                 SendBookletInfo();

+ 39 - 10
PDF Office/ViewModels/Dialog/HomePageToolsDialogs/HomePagePrinter/HomePagePrinterModMultipleContentViewModel.cs

@@ -85,7 +85,12 @@ namespace PDF_Office.ViewModels.Dialog.HomePageToolsDialogs.HomePagePrinter
         public int PageOrderIndex
         {
             get { return _pageOrderIndex; }
-            set { _pageOrderIndex = value; }
+            set
+            {
+                _pageOrderIndex = value; 
+                InitMultipleInfo();
+                SendMultipleInfo();
+            }
         }
 
         private bool _enableCustomiseMatrix;
@@ -110,7 +115,7 @@ namespace PDF_Office.ViewModels.Dialog.HomePageToolsDialogs.HomePagePrinter
 
         public HomePagePrinterModMultipleContentViewModel(IEventAggregator eventAggregator)
         {
-            this.eventAggregator= eventAggregator;
+            this.eventAggregator = eventAggregator;
 
             PageMatrixIndex = 0;
             PageOrderIndex = 0;
@@ -157,29 +162,49 @@ namespace PDF_Office.ViewModels.Dialog.HomePageToolsDialogs.HomePagePrinter
                 case 0:
                     HorizontalPageNumber = 1;
                     VerticalPageNumber = 2;
+                    InitMultipleInfo();
+                    SendMultipleInfo();
+
                     break;
 
                 case 1:
                     HorizontalPageNumber = 2;
                     VerticalPageNumber = 2;
+                    InitMultipleInfo();
+
+                    SendMultipleInfo();
+
                     break;
 
                 case 2:
                     HorizontalPageNumber = 3;
                     VerticalPageNumber = 2;
+                    InitMultipleInfo();
+
+                    SendMultipleInfo();
+
                     break;
 
                 case 3:
                     HorizontalPageNumber = 3;
                     VerticalPageNumber = 3;
+                    InitMultipleInfo();
+
+                    SendMultipleInfo();
+
                     break;
                 case 4:
                     HorizontalPageNumber = 4;
                     VerticalPageNumber = 4;
+                    InitMultipleInfo();
+
+                    SendMultipleInfo();
+
                     break;
-                    case 5:
+                case 5:
                     HorizontalPageNumber = null;
                     VerticalPageNumber = null;
+
                     break;
             }
         }
@@ -191,15 +216,19 @@ namespace PDF_Office.ViewModels.Dialog.HomePageToolsDialogs.HomePagePrinter
                 HorizontalPageNumber = 1;
             }
 
-            if (VerticalPageNumber==null)
+            if (VerticalPageNumber == null)
             {
-                VerticalPageNumber= 1;
+                VerticalPageNumber = 1;
             }
-            MultipleInfo.VerticalPageNumber = (int)VerticalPageNumber;
-            MultipleInfo.HorizontalPageNumber = (int)HorizontalPageNumber;
-            MultipleInfo.EnumDisplayPageNumber = EnumDisplayPageNumber.StatusTwo;
-            MultipleInfo.IsAutoRotate= IsAutoRotate;
-            MultipleInfo.EnumPageOrder = (EnumPageOrder)PageOrderIndex;
+            if (MultipleInfo != null)
+            {
+                MultipleInfo.VerticalPageNumber = (int)VerticalPageNumber;
+                MultipleInfo.HorizontalPageNumber = (int)HorizontalPageNumber;
+                MultipleInfo.EnumDisplayPageNumber = EnumDisplayPageNumber.StatusTwo;
+                MultipleInfo.IsAutoRotate = IsAutoRotate;
+                MultipleInfo.EnumPageOrder = (EnumPageOrder)PageOrderIndex;
+            }
+
         }
 
         public bool IsNavigationTarget(NavigationContext navigationContext)

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

@@ -1,17 +1,17 @@
 using PDF_Office.Model.Dialog.HomePageToolsDialogs.HomePagePrinter;
-using Prism.Commands;
+using Prism.Commands;
 using Prism.Events;
-using Prism.Mvvm;
-using Prism.Regions;
-using System;
-using System.Collections.Generic;
-using System.Linq;
+using Prism.Mvvm;
+using Prism.Regions;
+using System;
+using System.Collections.Generic;
+using System.Linq;
 using System.Management.Instrumentation;
-
-namespace PDF_Office.ViewModels.Dialog.HomePageToolsDialogs.HomePagePrinter
-{
-    public class HomePagePrinterModSizeContentViewModel : BindableBase, INavigationAware
-    {
+
+namespace PDF_Office.ViewModels.Dialog.HomePageToolsDialogs.HomePagePrinter
+{
+    public class HomePagePrinterModSizeContentViewModel : BindableBase, INavigationAware
+    {
         private IEventAggregator eventAggregator;
 
         private bool _isStatusAdaptive = true;
@@ -138,21 +138,21 @@ namespace PDF_Office.ViewModels.Dialog.HomePageToolsDialogs.HomePagePrinter
                 SizeInfo.EnumSizeType = EnumSizeType.StatusCustomized;
             }
             SizeInfo.DisplayRatio = int.Parse(DisplayRatio);
-        }
-
-        public bool IsNavigationTarget(NavigationContext navigationContext)
-        {
-            return true;
-        }
-
-        public void OnNavigatedFrom(NavigationContext navigationContext)
-        {
-        }
-
-        public void OnNavigatedTo(NavigationContext navigationContext)
+        }
+
+        public bool IsNavigationTarget(NavigationContext navigationContext)
+        {
+            return true;
+        }
+
+        public void OnNavigatedFrom(NavigationContext navigationContext)
+        {
+        }
+
+        public void OnNavigatedTo(NavigationContext navigationContext)
         {
             InitSizeInfo();
             SendSizeInfo();
-        }
-    }
-}
+        }
+    }
+}

+ 2 - 0
PDF Office/ViewModels/HomePanel/HomeGuidContentViewModel.cs

@@ -92,7 +92,9 @@ namespace PDF_Office.ViewModels.HomePanel
                         break;
 
                     case PDFToolType.Print:
+                        viewer.InitDocument(dlg.FileName);
                         DialogParameters printvalue = new DialogParameters();
+                        printvalue.Add(ParameterNames.PDFViewer, viewer);
                         printvalue.Add(ParameterNames.FilePath, dlg.FileName);
                         dialogs.ShowDialog(DialogNames.HomePagePrinterDialog, printvalue, e => { });
                         break;

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

@@ -42,11 +42,11 @@
                                     <TextBlock Text="mm"></TextBlock>
                                 </StackPanel>
                             </Grid>
-                            <Grid Grid.Row="1">
+                            <Grid Grid.Row="1"   Width="{Binding ViewBoxWidth}" Height="{Binding ViewBoxHeight}">
                                 <Grid.RenderTransform>
                                     <RotateTransform Angle="{Binding RotateAngle}" CenterX="{Binding RotateCenterX}" CenterY="{Binding RotateCenterY}"></RotateTransform>
                                 </Grid.RenderTransform>
-                                <Border BorderBrush="Black" BorderThickness="1" Background="White" CornerRadius="1"   Width="{Binding CanvasWidth, Mode=OneWay}" Height="{Binding CanvasHeight,Mode=OneWay}" >
+                                <Border Background="White" CornerRadius="1"   Width="{Binding CanvasWidth, Mode=OneWay}" Height="{Binding CanvasHeight,Mode=OneWay}" >
                                     <Viewbox  Width="{Binding ViewBoxWidth}" Height="{Binding ViewBoxHeight}" Margin="{Binding ViewBoxMargin}">
                                         <Image  Name="Image" Source="{Binding BitmapSource}"></Image>
                                     </Viewbox>
@@ -131,23 +131,23 @@
                                 <Button  Content="?" FontSize="6" Width="16" Height="16" Margin="7,0,0,0"></Button>
                             </StackPanel>
                             <StackPanel Orientation="Horizontal" Margin="0,10,0,0">
-                                <Button x:Name="ModSize" Background="WhiteSmoke" Width="126" Height="32" Command="{Binding ChangePrintModCommand}" CommandParameter="{Binding ElementName=ModSize}">
+                                <Button x:Name="ModSize" Background="WhiteSmoke" Width="126" Height="32" IsEnabled="{Binding IsEnableForModSize, Mode=OneWay}" Command="{Binding ChangePrintModCommand}" CommandParameter="{Binding ElementName=ModSize}">
                                     <Border>
                                         <TextBlock Text="大小"/>
                                     </Border>
                                 </Button>
                                 <!--Button Name="ModPoster" Background="WhiteSmoke" Width="126" Height="32" Margin="25,0,25,0" Command="{Binding ChangePrintModCommand}" CommandParameter="{Binding ElementName=ModPoster}"-->
-                                    <Button Name="ModPoster" Background="WhiteSmoke" Width="126" Height="32" Margin="25,0,25,0">
+                                    <Button Name="ModPoster" Background="WhiteSmoke" Width="126" Height="32" Margin="25,0,25,0" IsEnabled="{Binding IsEnableForModPoster, Mode=OneWay}">
                                         <Border>
                                         <TextBlock Text="海报"></TextBlock>
                                     </Border>
                                 </Button>
-                                <Button Name="ModMultiple" Background="WhiteSmoke" Width="126" Height="32" Margin="0,0,25,0" Command="{Binding ChangePrintModCommand}" CommandParameter="{Binding ElementName=ModMultiple}">
+                                <Button Name="ModMultiple" Background="WhiteSmoke" Width="126" Height="32" Margin="0,0,25,0" IsEnabled="{Binding IsEnableForModMultiple, Mode=OneWay}" Command="{Binding ChangePrintModCommand}" CommandParameter="{Binding ElementName=ModMultiple}">
                                     <Border>
                                         <TextBlock Text="多页"></TextBlock>
                                     </Border>
                                 </Button>
-                                <Button Name="ModBooklet" Background="WhiteSmoke" Width="126" Height="32" Margin="0,0,10,0" Command="{Binding ChangePrintModCommand}" CommandParameter="{Binding ElementName=ModBooklet}">
+                                <Button Name="ModBooklet" Background="WhiteSmoke" Width="126" Height="32" Margin="0,0,10,0" IsEnabled="{Binding IsEnableForModBooklet, Mode=OneWay}" Command="{Binding ChangePrintModCommand}" CommandParameter="{Binding ElementName=ModBooklet}">
                                     <Border>
                                         <TextBlock Text="小册子"></TextBlock>
                                     </Border>