|
@@ -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();
|
|
|
}
|
|
|
}
|
|
|
}
|