|
@@ -385,6 +385,7 @@ namespace PDF_Master.ViewModels.Dialog.HomePageToolsDialogs.HomePagePrinter
|
|
|
public DelegateCommand<object> SetReversePageCommand { get; set; }
|
|
|
public DelegateCommand<object> SetPrintBorderCommand { get; set; }
|
|
|
public DelegateCommand<object> SetPrintOritationCommand { get; set; }
|
|
|
+ public DelegateCommand<object> PageTextChangedCommand { get; set; }
|
|
|
#endregion
|
|
|
|
|
|
HomePagePrinterDialogViewModel(IRegionManager regionManager, IDialogService dialogService, IEventAggregator eventAggregator)
|
|
@@ -398,7 +399,7 @@ namespace PDF_Master.ViewModels.Dialog.HomePageToolsDialogs.HomePagePrinter
|
|
|
HomePagePrinterModRegionName = Guid.NewGuid().ToString();
|
|
|
|
|
|
CancelCommand = new DelegateCommand(Cancel);
|
|
|
- ConfirmPrintCommand = new DelegateCommand(ConfirmPrint);
|
|
|
+ ConfirmPrintCommand = new DelegateCommand(ConfirmPrint);
|
|
|
ChangePrintModCommand = new DelegateCommand<object>(ChangePrintMod);
|
|
|
SetPaperCommand = new DelegateCommand(SetPaper);
|
|
|
SelectPrinterCommand = new DelegateCommand<object>(SelectPrinter);
|
|
@@ -406,6 +407,7 @@ namespace PDF_Master.ViewModels.Dialog.HomePageToolsDialogs.HomePagePrinter
|
|
|
SetDuplexCommand = new DelegateCommand<object>(SetDuplex);
|
|
|
SetPageRangeSelectionIndexCommand = new DelegateCommand<object>(SetPageRangeSelectionIndex);
|
|
|
SetCustomPageRangeCommand = new DelegateCommand<object>(SetCustomPageRange);
|
|
|
+ PageTextChangedCommand = new DelegateCommand<object>(PageTextChanged);
|
|
|
SetPrintContentCommand = new DelegateCommand<object>(SetPrintContent);
|
|
|
SetReversePageCommand = new DelegateCommand<object>(SetReversePage);
|
|
|
SetPrintBorderCommand = new DelegateCommand<object>(SetPrintBorder);
|
|
@@ -524,8 +526,10 @@ namespace PDF_Master.ViewModels.Dialog.HomePageToolsDialogs.HomePagePrinter
|
|
|
/// </summary>
|
|
|
public void SetPaper()
|
|
|
{
|
|
|
+ Margins defaultMargin = new Margins();
|
|
|
PrintSettingsInfo.PrintDocument.PrinterSettings.PrinterName = PrinterName;
|
|
|
pageSetupDialog.Document = PrintSettingsInfo.PrintDocument;
|
|
|
+ defaultMargin = PrintSettingsInfo.PrintDocument.DefaultPageSettings.Margins;
|
|
|
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)
|
|
@@ -544,6 +548,10 @@ namespace PDF_Master.ViewModels.Dialog.HomePageToolsDialogs.HomePagePrinter
|
|
|
this.printEvent.GetEvent<SendPrintSettingsInfoEvent>().Publish(new PrintSettingsInfoWithUnicode { printSettingsInfo = this.PrintSettingsInfo, Unicode = this.Unicode });
|
|
|
PrintSettingsInfo.IsPaperSizeChanged = false;
|
|
|
}
|
|
|
+ else
|
|
|
+ {
|
|
|
+ PrintSettingsInfo.PrintDocument.DefaultPageSettings.Margins = defaultMargin;
|
|
|
+ }
|
|
|
}
|
|
|
|
|
|
public void ChangePrintMod(object e)
|
|
@@ -629,7 +637,7 @@ namespace PDF_Master.ViewModels.Dialog.HomePageToolsDialogs.HomePagePrinter
|
|
|
{
|
|
|
var cmb = e as WritableComboBox;
|
|
|
PrintSettingsInfo.PageRangeList.Clear();
|
|
|
- if (int.Parse(cmb.SelectedIndex) < cmb.Items.Count - 1)
|
|
|
+ if ((int.Parse(cmb.SelectedIndex) < cmb.Items.Count - 1))
|
|
|
{
|
|
|
if (!isCurrentPage)
|
|
|
{
|
|
@@ -650,7 +658,6 @@ namespace PDF_Master.ViewModels.Dialog.HomePageToolsDialogs.HomePagePrinter
|
|
|
}
|
|
|
else if (PrintSettingsInfo.EnumPageRange == (int)EnumPageRangeWithoutCurrentPage.StatusEvenRange)
|
|
|
{
|
|
|
- //TODO: 偶数页页数不够异常
|
|
|
if (PDFViewer.Document.PageCount <= 1)
|
|
|
{
|
|
|
for (int temp = 0; temp < PDFViewer.Document.PageCount; temp++)
|
|
@@ -693,7 +700,6 @@ namespace PDF_Master.ViewModels.Dialog.HomePageToolsDialogs.HomePagePrinter
|
|
|
}
|
|
|
else if (PrintSettingsInfo.EnumPageRange == (int)EnumPageRangeWithCurrentPage.StatusEvenRange)
|
|
|
{
|
|
|
- //TODO: 偶数页页数不够异常
|
|
|
if (PDFViewer.Document.PageCount <= 1)
|
|
|
{
|
|
|
for (int temp = 0; temp < PDFViewer.Document.PageCount; temp++)
|
|
@@ -711,11 +717,29 @@ namespace PDF_Master.ViewModels.Dialog.HomePageToolsDialogs.HomePagePrinter
|
|
|
}
|
|
|
}
|
|
|
}
|
|
|
-
|
|
|
+ if (PrintSettingsInfo.needReversePage)
|
|
|
+ {
|
|
|
+ PrintSettingsInfo.PageRangeList.Reverse();
|
|
|
+ }
|
|
|
this.printEvent.GetEvent<SendPrintSettingsInfoEvent>().Publish(new PrintSettingsInfoWithUnicode { printSettingsInfo = this.PrintSettingsInfo, Unicode = this.Unicode });
|
|
|
}
|
|
|
else
|
|
|
{
|
|
|
+ PrintSettingsInfo.EnumPageRange = (int)EnumPageRangeWithCurrentPage.StatusCustomizedRange;
|
|
|
+ if (string.IsNullOrEmpty(PageListString))
|
|
|
+ {
|
|
|
+ for (int temp = 0; temp < PDFViewer.Document.PageCount; temp++)
|
|
|
+ {
|
|
|
+ PrintSettingsInfo.PageRangeList.Add(temp);
|
|
|
+ }
|
|
|
+ if (PrintSettingsInfo.needReversePage)
|
|
|
+ {
|
|
|
+ PrintSettingsInfo.PageRangeList.Reverse();
|
|
|
+ }
|
|
|
+ this.printEvent.GetEvent<SendPrintSettingsInfoEvent>().Publish(new PrintSettingsInfoWithUnicode { printSettingsInfo = this.PrintSettingsInfo, Unicode = this.Unicode });
|
|
|
+ return;
|
|
|
+ }
|
|
|
+
|
|
|
if (!isCurrentPage)
|
|
|
{
|
|
|
for (int temp = 0; temp < PDFViewer.Document.PageCount; temp++)
|
|
@@ -730,12 +754,16 @@ namespace PDF_Master.ViewModels.Dialog.HomePageToolsDialogs.HomePagePrinter
|
|
|
{
|
|
|
PrintSettingsInfo.PageRangeList.Add(temp);
|
|
|
}
|
|
|
- PrintSettingsInfo.EnumPageRange = (int)EnumPageRangeWithCurrentPage.StatusCustomizedRange;
|
|
|
-
|
|
|
+ }
|
|
|
+ if (PrintSettingsInfo.needReversePage)
|
|
|
+ {
|
|
|
+ PrintSettingsInfo.PageRangeList.Reverse();
|
|
|
}
|
|
|
}
|
|
|
}
|
|
|
|
|
|
+
|
|
|
+
|
|
|
public void SetCustomPageRange(object e)
|
|
|
{
|
|
|
if ((PrintSettingsInfo.EnumPageRange == (int)EnumPageRangeWithoutCurrentPage.StatusCustomizedRange && !isCurrentPage) || (PrintSettingsInfo.EnumPageRange == (int)EnumPageRangeWithCurrentPage.StatusCustomizedRange && isCurrentPage))
|
|
@@ -756,6 +784,30 @@ namespace PDF_Master.ViewModels.Dialog.HomePageToolsDialogs.HomePagePrinter
|
|
|
}
|
|
|
}
|
|
|
|
|
|
+ public void PageTextChanged(object e)
|
|
|
+ {
|
|
|
+ if ((PrintSettingsInfo.EnumPageRange == (int)EnumPageRangeWithoutCurrentPage.StatusCustomizedRange && !isCurrentPage) || (PrintSettingsInfo.EnumPageRange == (int)EnumPageRangeWithCurrentPage.StatusCustomizedRange && isCurrentPage))
|
|
|
+ {
|
|
|
+ var cmb = e as WritableComboBox;
|
|
|
+ if (cmb == null)
|
|
|
+ {
|
|
|
+ return;
|
|
|
+ }
|
|
|
+ if (!CommonHelper.GetPagesInRange(ref DocumentTargetPages, cmb.Text, PDFViewer.Document.PageCount, new char[] { ',' }, new char[] { '-' }))
|
|
|
+ { //TODO
|
|
|
+ PrintSettingsInfo.PageRangeList.Clear();
|
|
|
+ for (int temp = 0; temp < PDFViewer.Document.PageCount; temp++)
|
|
|
+ {
|
|
|
+ PrintSettingsInfo.PageRangeList.Add(temp);
|
|
|
+ }
|
|
|
+ this.printEvent.GetEvent<SendPrintSettingsInfoEvent>().Publish(new PrintSettingsInfoWithUnicode { printSettingsInfo = this.PrintSettingsInfo, Unicode = this.Unicode });
|
|
|
+ return;
|
|
|
+ }
|
|
|
+ PrintSettingsInfo.PageRangeList = DocumentTargetPages;
|
|
|
+ this.printEvent.GetEvent<SendPrintSettingsInfoEvent>().Publish(new PrintSettingsInfoWithUnicode { printSettingsInfo = this.PrintSettingsInfo, Unicode = this.Unicode });
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
public void SetPrintOritation(object e)
|
|
|
{
|
|
|
var cmb = e as ComboBox;
|
|
@@ -765,8 +817,7 @@ namespace PDF_Master.ViewModels.Dialog.HomePageToolsDialogs.HomePagePrinter
|
|
|
}
|
|
|
else
|
|
|
{
|
|
|
- PrintSettingsInfo.PrintDocument.DefaultPageSettings.Landscape = true;
|
|
|
- }
|
|
|
+ PrintSettingsInfo.PrintDocument.DefaultPageSettings.Landscape = true; }
|
|
|
|
|
|
PrintSettingsInfo.EnumPrintOrientation = (EnumPrintOrientation)cmb.SelectedIndex;
|
|
|
this.printEvent.GetEvent<SendPrintSettingsInfoEvent>().Publish(new PrintSettingsInfoWithUnicode { printSettingsInfo = this.PrintSettingsInfo, Unicode = this.Unicode });
|
|
@@ -800,6 +851,14 @@ namespace PDF_Master.ViewModels.Dialog.HomePageToolsDialogs.HomePagePrinter
|
|
|
|
|
|
public void SetReversePage(object e)
|
|
|
{
|
|
|
+ var reversePageChk = e as CheckBox;
|
|
|
+ if ((bool)reversePageChk.IsChecked) {
|
|
|
+ PrintSettingsInfo.needReversePage = true;
|
|
|
+ }
|
|
|
+ else
|
|
|
+ {
|
|
|
+ PrintSettingsInfo.needReversePage = false;
|
|
|
+ }
|
|
|
PrintSettingsInfo.PageRangeList.Reverse();
|
|
|
this.printEvent.GetEvent<SendPrintSettingsInfoEvent>().Publish(new PrintSettingsInfoWithUnicode { printSettingsInfo = this.PrintSettingsInfo, Unicode = this.Unicode });
|
|
|
|
|
@@ -925,6 +984,18 @@ namespace PDF_Master.ViewModels.Dialog.HomePageToolsDialogs.HomePagePrinter
|
|
|
/// </summary>
|
|
|
public void ConfirmPrint()
|
|
|
{
|
|
|
+ List<int> PageIndexLists = new List<int>();
|
|
|
+
|
|
|
+ if (PageRangeSelectIndex == 4)
|
|
|
+ {
|
|
|
+ if (!CommonHelper.GetPagesInRange(ref PageIndexLists, CustomRangeString, PDFViewer.Document.PageCount, new char[] { ',' }, new char[] { '-' }))
|
|
|
+ { //TODO
|
|
|
+ AlertsMessage alertsMessage = new AlertsMessage();
|
|
|
+ alertsMessage.ShowDialog("页面范围输入错误", "", "确定");
|
|
|
+ return;
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
printQueue = localDefaultPrintServer.GetPrintQueue(PrinterName);
|
|
|
LoadPrinterSettings();
|
|
|
|
|
@@ -1015,6 +1086,7 @@ namespace PDF_Master.ViewModels.Dialog.HomePageToolsDialogs.HomePagePrinter
|
|
|
|
|
|
public void OnDialogOpened(IDialogParameters parameters)
|
|
|
{
|
|
|
+
|
|
|
parameters.TryGetValue<CPDFViewer>(ParameterNames.PDFViewer, out PDFViewer);
|
|
|
|
|
|
VerifyPasswordResult result = SecurityHelper.VerifyPasswordForSelectedPermissions(PDFViewer.Document, Model.Dialog.ToolsDialogs.SaftyDialogs.EnumPermissionsSet.StatusAllowsPrinting, printDialogs);
|