Pārlūkot izejas kodu

Merge branch 'dev' of http://git.kdan.cc:8865/Windows/PDFOffice_Windows_exe into dev

zhuyi 2 gadi atpakaļ
vecāks
revīzija
b7aeaf5f1c

+ 43 - 19
PDF Office/ViewModels/Dialog/HomePageToolsDialogs/HomePagePrinter/HomePagePrinterDialogViewModel.cs

@@ -198,6 +198,7 @@ namespace PDF_Office.ViewModels.Dialog.HomePageToolsDialogs.HomePagePrinter
 
         public bool FinishedFrontSideFlag = false;
         public int printCurrentPageIndex;
+        public string PageListString = null;
         public bool isCurrentPage;
 
         /// <summary>
@@ -393,25 +394,25 @@ namespace PDF_Office.ViewModels.Dialog.HomePageToolsDialogs.HomePagePrinter
         /// </summary>
         public void SetPaper()
         {
-                PrintSettingsInfo.PrintDocument.PrinterSettings.PrinterName = PrinterName;
-                pageSetupDialog.Document = PrintSettingsInfo.PrintDocument;
-                pageSetupDialog.Document.DefaultPageSettings.Margins = new Margins((int)(PrintSettingsInfo.PrintDocument.DefaultPageSettings.Margins.Left * 2.54), (int)(PrintSettingsInfo.PrintDocument.DefaultPageSettings.Margins.Right * 2.54), (int)(PrintSettingsInfo.PrintDocument.DefaultPageSettings.Margins.Top * 2.54), (int)(PrintSettingsInfo.PrintDocument.DefaultPageSettings.Margins.Bottom * 2.54));
+            PrintSettingsInfo.PrintDocument.PrinterSettings.PrinterName = PrinterName;
+            pageSetupDialog.Document = PrintSettingsInfo.PrintDocument;
+            pageSetupDialog.Document.DefaultPageSettings.Margins = new Margins((int)(PrintSettingsInfo.PrintDocument.DefaultPageSettings.Margins.Left * 2.54), (int)(PrintSettingsInfo.PrintDocument.DefaultPageSettings.Margins.Right * 2.54), (int)(PrintSettingsInfo.PrintDocument.DefaultPageSettings.Margins.Top * 2.54), (int)(PrintSettingsInfo.PrintDocument.DefaultPageSettings.Margins.Bottom * 2.54));
 
-                if (pageSetupDialog.ShowDialog() == System.Windows.Forms.DialogResult.OK)
-                {
-                    PrintSettingsInfo.IsPaperSizeChanged= true;
-                    PrintSettingsInfo.PrintDocument.DefaultPageSettings = pageSetupDialog.PageSettings;
+            if (pageSetupDialog.ShowDialog() == System.Windows.Forms.DialogResult.OK)
+            {
+                PrintSettingsInfo.IsPaperSizeChanged = true;
+                PrintSettingsInfo.PrintDocument.DefaultPageSettings = pageSetupDialog.PageSettings;
 
-                    if (!PrintSettingsInfo.PrintDocument.DefaultPageSettings.Landscape)
-                    {
-                        PrintOrientationIndex = 0;
-                    }
-                    else
-                    {
-                        PrintOrientationIndex = 1;
-                    }
-                    this.printEvent.GetEvent<SendPrintSettingsInfoEvent>().Publish(new PrintSettingsInfoWithUnicode { printSettingsInfo = this.PrintSettingsInfo, Unicode = this.Unicode });
-                    PrintSettingsInfo.IsPaperSizeChanged= false;
+                if (!PrintSettingsInfo.PrintDocument.DefaultPageSettings.Landscape)
+                {
+                    PrintOrientationIndex = 0;
+                }
+                else
+                {
+                    PrintOrientationIndex = 1;
+                }
+                this.printEvent.GetEvent<SendPrintSettingsInfoEvent>().Publish(new PrintSettingsInfoWithUnicode { printSettingsInfo = this.PrintSettingsInfo, Unicode = this.Unicode });
+                PrintSettingsInfo.IsPaperSizeChanged = false;
             }
         }
 
@@ -693,7 +694,7 @@ namespace PDF_Office.ViewModels.Dialog.HomePageToolsDialogs.HomePagePrinter
             if (printModInfoWithUnicode.printModInfo.EnumPrintMod == currentHomePagePrinterMod)
             {
                 PrintSettingsInfo.PrintModInfo = printModInfoWithUnicode.printModInfo;
-               this.printEvent.GetEvent<SendPrintSettingsInfoEvent>().Publish(new PrintSettingsInfoWithUnicode { printSettingsInfo = this.PrintSettingsInfo, Unicode = this.Unicode });
+                this.printEvent.GetEvent<SendPrintSettingsInfoEvent>().Publish(new PrintSettingsInfoWithUnicode { printSettingsInfo = this.PrintSettingsInfo, Unicode = this.Unicode });
             }
         }
 
@@ -718,7 +719,7 @@ namespace PDF_Office.ViewModels.Dialog.HomePageToolsDialogs.HomePagePrinter
             param.Add(ParameterNames.PDFViewer, PDFViewer);
             param.Add(ParameterNames.PrintSettingsInfo, PrintSettingsInfo);
             param.Add("Unicode", Unicode);
-           printRegion.RequestNavigate(HomePagePrinterDocumentRegionName, HomePagePrinterDocumentName, param);
+            printRegion.RequestNavigate(HomePagePrinterDocumentRegionName, HomePagePrinterDocumentName, param);
             PageSetupDialog pageSetupDialog = new PageSetupDialog();
             PrintSettingsInfo.PrintDocument.PrinterSettings.PrinterName = PrinterName;
             pageSetupDialog.Document = PrintSettingsInfo.PrintDocument;
@@ -884,6 +885,7 @@ 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)
             {
@@ -899,7 +901,29 @@ namespace PDF_Office.ViewModels.Dialog.HomePageToolsDialogs.HomePagePrinter
                 {
                     isCurrentPage = false;
                 }
+
+                //if (parameters.TryGetValue<List<int>>(ParameterNames.PageList, out PageList))
+                //{
+                //    PageListString = CommonHelper.GetPageParmFromList(PageList);
+                //    if (!string.IsNullOrEmpty(PageListString))
+                //    {
+                //        PrintSettingsInfo.PageRangeList = PageList;
+                //    }
+                //}
+                List<int> PageList = new List<int>();
+
+                PageRangeSelectIndex = 4;
+                PageList.Clear();
+                PageList.Add(1);
+                PageList.Add(2);
+                PageListString = CommonHelper.GetPageParmFromList(PageList);
+                if (!string.IsNullOrEmpty(PageListString))
+                {
+                    PrintSettingsInfo.PageRangeList = PageList;
+                }
+
                 System.Windows.Size pageSize = PDFViewer.Document.GetPageSize(0);
+
                 if ((pageSize.Height / pageSize.Width > 1.0 && (double)PrintSettingsInfo.PrintDocument.DefaultPageSettings.PaperSize.Height / PrintSettingsInfo.PrintDocument.DefaultPageSettings.PaperSize.Width < 1.0)
                     || (pageSize.Height / pageSize.Width < 1.0 && (double)PrintSettingsInfo.PrintDocument.DefaultPageSettings.PaperSize.Height / PrintSettingsInfo.PrintDocument.DefaultPageSettings.PaperSize.Width > 1.0))
                 {

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

@@ -109,7 +109,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" Loaded="PageRangeComboBox_Loaded" Width="132" Height="32" Margin="16,0,0,0" MaxPageRange="{Binding MaxPageRange, Mode=TwoWay}"  SelectedIndex="{Binding PageRangeSelectIndex,Mode=TwoWay}" >
+                                        <cus:WritableComboBox  x:Name="PageRangeComboBox" Loaded="PageRangeComboBox_Loaded" Width="132" Height="32" Margin="16,0,0,0" MaxPageRange="{Binding MaxPageRange, Mode=TwoWay}"  SelectedIndex="{Binding PageRangeSelectIndex,Mode=TwoWay}">
                                             <i:Interaction.Triggers>
                                                 <i:EventTrigger EventName="SelectionChanged">
                                                     <i:InvokeCommandAction Command="{Binding SetPageRangeSelectionIndexCommand}" CommandParameter="{Binding ElementName=PageRangeComboBox}"></i:InvokeCommandAction>

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

@@ -32,8 +32,9 @@ namespace PDF_Office.Views.Dialog.HomePageToolsDialogs.HomePagePrinter
                     ComboBoxItem comboBoxItem = new ComboBoxItem();
                     comboBoxItem.Content = "当前页面";
                     PageRangeComboBox.writableComboBox.Items.Insert(1, comboBoxItem);
-
                 }
+                if (!string.IsNullOrEmpty( ((HomePagePrinterDialogViewModel)this.DataContext).PageListString))
+                    PageRangeComboBox.writableTextBox.Text = ((HomePagePrinterDialogViewModel)this.DataContext).PageListString;
             }
         }