123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342 |
- using PDF_Office.EventAggregators;
- using PDF_Office.Model.Dialog.HomePageToolsDialogs.HomePagePrinter;
- using Prism.Commands;
- using Prism.Events;
- using Prism.Mvvm;
- using Prism.Regions;
- using System;
- using System.Collections.Generic;
- using System.Linq;
- using System.Windows.Controls;
- namespace PDF_Office.ViewModels.Dialog.HomePageToolsDialogs.HomePagePrinter
- {
- public class HomePagePrinterModMultipleContentViewModel : BindableBase, INavigationAware
- {
- private IEventAggregator eventAggregator;
- private string Unicode = null;
- private int? _verticalPageNumber;
- public int? VerticalPageNumber
- {
- get { return _verticalPageNumber; }
- set { SetProperty(ref _verticalPageNumber, value); }
- }
- private int? _horizontalPageNumber;
- public int? HorizontalPageNumber
- {
- get { return _horizontalPageNumber; }
- set { SetProperty(ref _horizontalPageNumber, value); }
- }
- private bool _isAutoRotate;
- public bool IsAutoRotate
- {
- get { return _isAutoRotate; }
- set { _isAutoRotate = value; }
- }
- private List<string> _pageMatrixList;
- public List<string> PageMatrixList
- {
- get { return _pageMatrixList; }
- set { _pageMatrixList = value; }
- }
- private int _pageMatrixIndex;
- /// <summary>
- /// <para>0: 1x2</para>
- /// <para>1: 2x2</para>
- /// <para>2: 3x2</para>
- /// <para>3: 3x3</para>
- /// <para>4: 4x4</para>
- /// <para>5: 自定义</para>
- /// </summary>
- public int PageMatrixIndex
- {
- get { return _pageMatrixIndex; }
- set
- {
- _pageMatrixIndex = value;
- if (_pageMatrixIndex < 5)
- {
- EnableCustomiseMatrix = false;
- }
- else
- {
- EnableCustomiseMatrix = true;
- }
- SetPageMatrixValue(value);
- }
- }
- private List<string> _pageOrderList;
- public List<string> PageOrderList
- {
- get { return _pageOrderList; }
- set { _pageOrderList = value; }
- }
- private int _pageOrderIndex;
- /// <summary>
- /// <para>0: Horizontal</para>
- /// <para>1: HorizontalReversed</para>
- /// <para>0: Vertical</para>
- /// <para>0: VerticalReversed</para>
- /// </summary>
- public int PageOrderIndex
- {
- get { return _pageOrderIndex; }
- set
- {
- _pageOrderIndex = value;
- SetMultipleInfo();
- SendMultipleInfo();
- }
- }
- private bool _enableCustomiseMatrix;
- public bool EnableCustomiseMatrix
- {
- get { return _enableCustomiseMatrix; }
- set
- {
- SetProperty(ref _enableCustomiseMatrix, value);
- }
- }
- private MultipleInfo _multipleInfo;
- /// <summary>
- /// 多页参数
- /// </summary>
- public MultipleInfo MultipleInfo
- {
- get { return _multipleInfo; }
- set { _multipleInfo = value; }
- }
- private bool _isDuplexModLongEdge = true;
- public bool IsDuplexModLongEdge
- {
- get { return _isDuplexModLongEdge; }
- set { _isDuplexModLongEdge = value; }
- }
- private bool _isDuplexModShortEdge = false;
- public bool IsDuplexModShortEdge
- {
- get { return _isDuplexModShortEdge; }
- set { _isDuplexModShortEdge = value; }
- }
- public DelegateCommand<object> SetPageMatrixCommand { get; set; }
- public DelegateCommand<object> SetCustomMatrixCommand { get; set; }
- public DelegateCommand SetPageOrderCommand { get; set; }
- public DelegateCommand SetAutoRotateCommand { get; set; }
- public DelegateCommand<object> UnlockDuplexCommand { get; set; }
- public DelegateCommand<object> ChangeDuplexModCommand { get; set; }
- public HomePagePrinterModMultipleContentViewModel(IEventAggregator eventAggregator)
- {
- this.eventAggregator = eventAggregator;
- PageMatrixIndex = 0;
- PageOrderIndex = 0;
- PageMatrixList = new List<string>();
- InitPageMatrixList();
- PageOrderList = new List<string>();
- InitPageOrderList();
- SetPageMatrixCommand = new DelegateCommand<object>(SetPageMatrix);
- SetCustomMatrixCommand = new DelegateCommand<object>(SetCustomMatrix);
- SetPageOrderCommand = new DelegateCommand(SetPageOrder);
- SetAutoRotateCommand = new DelegateCommand(SetAutoRotate);
- UnlockDuplexCommand = new DelegateCommand<object>(UnlockDuplex);
- ChangeDuplexModCommand = new DelegateCommand<object>(ChangeDuplexMod);
- MultipleInfo = new MultipleInfo();
- MultipleInfo.EnumPrintMod = EnumPrintMod.StatusMultiple;
- }
- public void SetPageMatrix(object e)
- {
- SetMultipleInfo();
- SendMultipleInfo();
- }
- public void SetCustomMatrix(object e)
- {
- SetMultipleInfo();
- SendMultipleInfo();
- }
- public void SetPageOrder()
- {
- SetMultipleInfo();
- SendMultipleInfo();
- }
- public void SetAutoRotate()
- {
- SetMultipleInfo();
- SendMultipleInfo();
- }
- public void SendMultipleInfo()
- {
- if (MultipleInfo != null)
- {
- this.eventAggregator.GetEvent<SendPrintSettingsModInfoEvent>().Publish(new PrintModInfoWithUnicode { printModInfo = MultipleInfo, Unicode = this.Unicode });
- }
- }
- public void UnlockDuplex(object e)
- {
- var chk = e as CheckBox;
- if (chk != null)
- {
- if (chk.IsChecked == false)
- {
- this.eventAggregator.GetEvent<SendDuplexPrintModEvent>().Publish(new EnumDuplexPrintModWithUnicode { enumDuplexPrintMod = EnumDuplexPrintMod.StatusNone, Unicode = this.Unicode });
- }
- else
- {
- if (IsDuplexModLongEdge)
- {
- this.eventAggregator.GetEvent<SendDuplexPrintModEvent>().Publish(new EnumDuplexPrintModWithUnicode { enumDuplexPrintMod = EnumDuplexPrintMod.StatusFlipLongEdge, Unicode = this.Unicode });
- }
- else
- {
- this.eventAggregator.GetEvent<SendDuplexPrintModEvent>().Publish(new EnumDuplexPrintModWithUnicode { enumDuplexPrintMod = EnumDuplexPrintMod.StatusFlipShortEdge, Unicode = this.Unicode });
- }
- }
- }
- }
- public void ChangeDuplexMod(object e)
- {
- var rdo = e as RadioButton;
- if (rdo != null)
- {
- if (rdo.Name == "DuplexModLongEdgeRdo")
- {
- this.eventAggregator.GetEvent<SendDuplexPrintModEvent>().Publish(new EnumDuplexPrintModWithUnicode { enumDuplexPrintMod = EnumDuplexPrintMod.StatusFlipLongEdge, Unicode = this.Unicode });
- }
- else
- {
- this.eventAggregator.GetEvent<SendDuplexPrintModEvent>().Publish(new EnumDuplexPrintModWithUnicode { enumDuplexPrintMod = EnumDuplexPrintMod.StatusFlipShortEdge, Unicode = this.Unicode });
- }
- }
- }
- private void InitPageMatrixList()
- {
- PageMatrixList.Clear();
- PageMatrixList.Add("2");
- PageMatrixList.Add("4");
- PageMatrixList.Add("6");
- PageMatrixList.Add("9");
- PageMatrixList.Add("16");
- PageMatrixList.Add("自定义");
- }
- private void InitPageOrderList()
- {
- PageOrderList.Clear();
- PageOrderList.Add("横向");
- PageOrderList.Add("横向倒序");
- PageOrderList.Add("纵向");
- PageOrderList.Add("纵向倒序");
- }
- private void SetPageMatrixValue(int pageMatrixIndex)
- {
- switch (pageMatrixIndex)
- {
- case 0:
- HorizontalPageNumber = 1;
- VerticalPageNumber = 2;
- SetMultipleInfo();
- SendMultipleInfo();
- break;
- case 1:
- HorizontalPageNumber = 2;
- VerticalPageNumber = 2;
- SetMultipleInfo();
- SendMultipleInfo();
- break;
- case 2:
- HorizontalPageNumber = 3;
- VerticalPageNumber = 2;
- SetMultipleInfo();
- SendMultipleInfo();
- break;
- case 3:
- HorizontalPageNumber = 3;
- VerticalPageNumber = 3;
- SetMultipleInfo();
- SendMultipleInfo();
- break;
- case 4:
- HorizontalPageNumber = 4;
- VerticalPageNumber = 4;
- SetMultipleInfo();
- SendMultipleInfo();
- break;
- case 5:
- HorizontalPageNumber = null;
- VerticalPageNumber = null;
- break;
- }
- }
- private void SetMultipleInfo()
- {
- if (HorizontalPageNumber == null)
- {
- HorizontalPageNumber = 1;
- }
- if (VerticalPageNumber == null)
- {
- VerticalPageNumber = 1;
- }
- if (MultipleInfo != null)
- {
- MultipleInfo.VerticalPageNumber = (int)VerticalPageNumber;
- MultipleInfo.HorizontalPageNumber = (int)HorizontalPageNumber;
- MultipleInfo.IsAutoRotate = IsAutoRotate;
- MultipleInfo.EnumPageOrder = (EnumPageOrder)PageOrderIndex;
- }
- }
- public bool IsNavigationTarget(NavigationContext navigationContext)
- {
- return true;
- }
- public void OnNavigatedFrom(NavigationContext navigationContext)
- {
- }
- public void OnNavigatedTo(NavigationContext navigationContext)
- {
- SetMultipleInfo();
- SendMultipleInfo();
- navigationContext.Parameters.TryGetValue<string>("Unicode", out Unicode);
- }
- }
- }
|