Browse Source

Merge branch 'practice' into dev

ZhouJieSheng 2 years ago
parent
commit
d8eec9e4d0

+ 16 - 3
PDF Office/ViewModels/Dialog/HomePageToolsDialogs/HomePagePrinter/HomePagePrinterDialogViewModel.cs

@@ -583,11 +583,23 @@ namespace PDF_Office.ViewModels.Dialog.HomePageToolsDialogs.HomePagePrinter
 
                 this.printEvent.GetEvent<SendPrintSettingsInfoEvent>().Publish(new PrintSettingsInfoWithUnicode { printSettingsInfo = this.PrintSettingsInfo, Unicode = this.Unicode });
             }
+            else
+            {
+                if (!isCurrentPage)
+                {
+                    PrintSettingsInfo.EnumPageRange = (int)EnumPageRangeWithoutCurrentPage.StatusCustomizedRange;
+                }
+                else
+                {
+                    PrintSettingsInfo.EnumPageRange = (int)EnumPageRangeWithCurrentPage.StatusCustomizedRange;
+
+                }
+            }
         }
 
         public void SetCustomPageRange(object e)
         {
-            if (PrintSettingsInfo.EnumPageRange == (int)EnumPageRangeWithCurrentPage.StatusCustomizedRange)
+            if ((PrintSettingsInfo.EnumPageRange == (int)EnumPageRangeWithoutCurrentPage.StatusCustomizedRange&&!isCurrentPage)||(PrintSettingsInfo.EnumPageRange == (int)EnumPageRangeWithoutCurrentPage.StatusCustomizedRange && isCurrentPage))
             {
                 var cmb = e as WritableComboBox;
                 if (cmb == null)
@@ -600,8 +612,8 @@ namespace PDF_Office.ViewModels.Dialog.HomePageToolsDialogs.HomePagePrinter
                     MessageBoxEx.Show("输入不对");
                     return;
                 }
-                PrintSettingsInfo.PageRangeList.Clear();
                 PrintSettingsInfo.PageRangeList = DocumentTargetPages;
+                this.printEvent.GetEvent<SendPrintSettingsInfoEvent>().Publish(new PrintSettingsInfoWithUnicode { printSettingsInfo = this.PrintSettingsInfo, Unicode = this.Unicode });
             }
         }
 
@@ -805,7 +817,7 @@ namespace PDF_Office.ViewModels.Dialog.HomePageToolsDialogs.HomePagePrinter
                 }
                 ///手动翻面
                 ///手动翻面需要注意只有一页时和单面打印一致
-                ///那奇数页呢
+                ///那奇数页呢?
                 else
                 {
                     if ((PrintSettingsInfo.PrintModInfo.EnumPrintMod == EnumPrintMod.StatusSize && PrintSettingsInfo.PageRangeList.Count == 1) || (PrintSettingsInfo.PrintModInfo.EnumPrintMod == EnumPrintMod.StatusBooklet && PrintSettingsInfo.PageRangeList.Count == 1))
@@ -823,6 +835,7 @@ namespace PDF_Office.ViewModels.Dialog.HomePageToolsDialogs.HomePagePrinter
                         }
                         else
                         {
+                            ///z
                             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)
                             {

+ 39 - 14
PDF Office/ViewModels/Dialog/HomePageToolsDialogs/HomePagePrinter/HomePagePrinterDocumentContentViewModel.cs

@@ -184,7 +184,7 @@ namespace PDF_Office.ViewModels.Dialog.HomePageToolsDialogs.HomePagePrinter
         {
             this.printDocumentEvent = eventAggregator;
             printDocumentEvent.GetEvent<SendPrintSettingsInfoEvent>().Subscribe(RecvPrintSettingsInfo, e => e.Unicode == Unicode);
-            printDocumentEvent.GetEvent<SendPrintQueueEvent>().Subscribe(RecvPrintQueue , e => e.Unicode == Unicode);
+            printDocumentEvent.GetEvent<SendPrintQueueEvent>().Subscribe(RecvPrintQueue, e => e.Unicode == Unicode);
             printDocumentEvent.GetEvent<SendLabelEvent>().Subscribe(RecvLabel, e => e.Unicode == Unicode);
             TurnPageCommand = new DelegateCommand<object>(TurnPage);
             JumpPageCommand = new DelegateCommand<object>(JumpPage);
@@ -222,7 +222,6 @@ namespace PDF_Office.ViewModels.Dialog.HomePageToolsDialogs.HomePagePrinter
                 var printTicket = new PrintTicket();
                 printDocument.PrinterSettings.PrinterName = printQueueWithUnicode.printQueue.Name;
 
-                //TODO 这里要改,暂时禁用了海报模式的横向打印
                 if (PrintSettingsInfo.EnumPrintOrientation == EnumPrintOrientation.StatusPortrait)
                 {
                     printDocument.DefaultPageSettings.Landscape = false;
@@ -278,9 +277,34 @@ namespace PDF_Office.ViewModels.Dialog.HomePageToolsDialogs.HomePagePrinter
 
                 printQueueWithUnicode.printQueue.DefaultPrintTicket = printTicket;
                 printDocument.DefaultPageSettings.PaperSize = PrintSettingsInfo.PrintDocument.DefaultPageSettings.PaperSize;
+                PaperSource pkSource;
+                List<PaperSource> paperSources = new List<PaperSource>();
+                paperSources.Clear();
+                for (int i = 0; i < printDocument.PrinterSettings.PaperSources.Count; i++)
+                {
+                    pkSource = printDocument.PrinterSettings.PaperSources[i];
+                    paperSources.Add(pkSource);
+                }
+                ///纸盒不为空,实体打印机默认设置纸盒序号0(主纸盒)
+                if (paperSources.Count != 0)
+                {
+                    printDocument.DefaultPageSettings.PaperSource = paperSources[0];
+                }
+
+                if (PrintSettingsInfo.Copies <= printQueueWithUnicode.printQueue.GetPrintCapabilities().MaxCopyCount && PrintSettingsInfo.Copies > 0)
+                {
+                    printDocument.PrinterSettings.Copies = (short)PrintSettingsInfo.Copies;
+                }
+                else if(PrintSettingsInfo.Copies > printQueueWithUnicode.printQueue.GetPrintCapabilities().MaxCopyCount)
+                {
+                    PrintSettingsInfo.Copies = (int)printQueueWithUnicode.printQueue.GetPrintCapabilities().MaxCopyCount;
+                }
+                else
+                {
+                    PrintSettingsInfo.Copies = 1;
+                }
                 posterPrintPaperIndex = 0;
                 printDocument.PrintPage += PrintDocumentByCurrentSettings;
-
                 printDocument.Print();
             }
         }
@@ -347,7 +371,7 @@ namespace PDF_Office.ViewModels.Dialog.HomePageToolsDialogs.HomePagePrinter
                     startPoint.X = (blankPageBitmap.Width - resizedWidth) / 2;
                     startPoint.Y = (blankPageBitmap.Height - resizedHeight) / 2;
                     printBitmap = CombineBitmap(blankPageBitmap, bitmap, startPoint);
-                    if (IsManualDuplex && PrintIndex % 2 == 1&&sizeInfo.EnumDuplexPrintMod == EnumDuplexPrintMod.StatusFlipShortEdge)
+                    if (IsManualDuplex && PrintIndex % 2 == 1 && sizeInfo.EnumDuplexPrintMod == EnumDuplexPrintMod.StatusFlipShortEdge)
                     {
                         printBitmap.RotateFlip(RotateFlipType.Rotate180FlipNone);
                     }
@@ -362,7 +386,7 @@ namespace PDF_Office.ViewModels.Dialog.HomePageToolsDialogs.HomePagePrinter
                     {
                         printBitmap.RotateFlip(RotateFlipType.Rotate180FlipNone);
                     }
-                    e.Graphics.DrawImage(printBitmap, e.MarginBounds);
+                    e.Graphics.DrawImage(printBitmap, realBound);
                 }
                 else if (sizeInfo.EnumSizeType == EnumSizeType.StatusCustomized)
                 {
@@ -1070,7 +1094,7 @@ namespace PDF_Office.ViewModels.Dialog.HomePageToolsDialogs.HomePagePrinter
                 {
                     try
                     {
-                        leftPageIndex = PrintSettingsInfo.PageRangeList[maxPaperNumber * 4 - TargetPaperList[PrintIndex + 1 ] - 1];
+                        leftPageIndex = PrintSettingsInfo.PageRangeList[maxPaperNumber * 4 - TargetPaperList[PrintIndex + 1] - 1];
                         leftPage = PDFViewer.Document.PageAtIndex(leftPageIndex);
                     }
                     catch
@@ -1272,11 +1296,11 @@ namespace PDF_Office.ViewModels.Dialog.HomePageToolsDialogs.HomePagePrinter
                 ///奇数页:
                 ///右面为页面序号
                 ///左面为[(总打印纸数*4)+1-打印页右侧页序号]
-                if ((TargetPaperList[PrintIndex+1] + 1) % 2 == 0)
+                if ((TargetPaperList[PrintIndex + 1] + 1) % 2 == 0)
                 {
                     try
                     {
-                        leftPageIndex = PrintSettingsInfo.PageRangeList[maxPaperNumber * 4 - TargetPaperList[PrintIndex+1] - 1];
+                        leftPageIndex = PrintSettingsInfo.PageRangeList[maxPaperNumber * 4 - TargetPaperList[PrintIndex + 1] - 1];
                         leftPage = PDFViewer.Document.PageAtIndex(leftPageIndex);
                     }
                     catch
@@ -1789,7 +1813,7 @@ namespace PDF_Office.ViewModels.Dialog.HomePageToolsDialogs.HomePagePrinter
         /// <param name="foreground"></param>
         /// <param name="point"></param>
         /// <returns></returns>
-        public  Bitmap CombineBitmap(Bitmap background, Bitmap foreground, System.Drawing.Point point)
+        public Bitmap CombineBitmap(Bitmap background, Bitmap foreground, System.Drawing.Point point)
         {
             if (background == null)
             {
@@ -2729,7 +2753,8 @@ namespace PDF_Office.ViewModels.Dialog.HomePageToolsDialogs.HomePagePrinter
             {
                 TargetPaperList.Clear();
                 TargetPaperList.Add(0);
-                for (int temp = 0; temp < PrintedPageCount; temp++)
+                
+                for (int temp = 0; temp < PrintSettingsInfo.PageRangeList.Count;temp++)
                 {
                     TargetPaperList.Add(temp);
                 }
@@ -2786,10 +2811,10 @@ namespace PDF_Office.ViewModels.Dialog.HomePageToolsDialogs.HomePagePrinter
             navigationContext.Parameters.TryGetValue<string>("Unicode", out Unicode);
             if (PDFViewer != null && PrintSettingsInfo != null)
             {
-                documentSettingsInfo.DocumentWidth = 827;
-                documentSettingsInfo.DocumentHeight = 1169;
-                documentSettingsInfo.margins = new Margins(0,0,0,0);
-                documentSettingsInfo.DocumentBounds = new Rectangle(0,0,827,1169);
+                documentSettingsInfo.DocumentWidth = PrintSettingsInfo.PrintDocument.DefaultPageSettings.PaperSize.Width;
+                documentSettingsInfo.DocumentHeight = PrintSettingsInfo.PrintDocument.DefaultPageSettings.PaperSize.Height;
+                documentSettingsInfo.margins = PrintSettingsInfo.PrintDocument.DefaultPageSettings.Margins;
+                documentSettingsInfo.DocumentBounds = PrintSettingsInfo.PrintDocument.DefaultPageSettings.Bounds;
                 SetPreviewExceptPoster();
                 CaculatePrintedPageCount();
                 SetPaperCollection();

+ 2 - 2
PDF Office/ViewModels/Dialog/HomePageToolsDialogs/HomePagePrinter/HomePagePrinterModPosterContentViewModel.cs

@@ -136,11 +136,11 @@ namespace PDF_Office.ViewModels.Dialog.HomePageToolsDialogs.HomePagePrinter
             {
                 if (value > 5.08)
                 {
-                    value = 5.08;
+                    SetProperty(ref _overlapNumber, 5.08);
                 }
                 else if (value < 0)
                 {
-                    value = 0;
+                    SetProperty(ref _overlapNumber, 0);
                 }
                 SetProperty(ref _overlapNumber, value);
             }

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

@@ -87,9 +87,6 @@
                                             <i:KeyTrigger FiredOn="KeyDown" Key="Return">
                                                 <i:InvokeCommandAction Command="{Binding SetCustomPageRangeCommand}" CommandParameter="{Binding ElementName=PageRangeComboBox}"></i:InvokeCommandAction>
                                             </i:KeyTrigger>
-                                            <i:EventTrigger EventName="LostFocus">
-                                                <!--<i:InvokeCommandAction Command="{Binding SetCustomPageRangeCommand}" CommandParameter="{Binding ElementName=PageRangeComboBox}"></i:InvokeCommandAction>-->
-                                            </i:EventTrigger>
                                         </i:Interaction.Triggers>
                                     </cus:WritableComboBox>
                                 </StackPanel>

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

@@ -61,7 +61,7 @@
             <Grid Grid.Row="2"  Margin="8,8,0,0">
                 <StackPanel Orientation="Horizontal" >
                     <TextBlock Text="Overlap:" VerticalAlignment="Center" FontSize="14" Width="80"></TextBlock>
-                    <TextBox Height="32" Width="88" Margin="16,0,16,0" Text="{Binding OverlapNumber,Mode=TwoWay}">
+                    <TextBox Height="32" Width="88" Margin="16,0,16,0" Text="{Binding OverlapNumber,UpdateSourceTrigger=PropertyChanged, Mode=TwoWay}">
                         <TextBox.InputBindings>
                             <KeyBinding Command="{Binding SetOverlapCommand}" Key="Return"></KeyBinding>
                         </TextBox.InputBindings>