HomePagePrinterModMultipleContentViewModel.cs 6.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249
  1. using PDF_Office.Model.Dialog.HomePageToolsDialogs.HomePagePrinter;
  2. using Prism.Commands;
  3. using Prism.Events;
  4. using Prism.Mvvm;
  5. using Prism.Regions;
  6. using System;
  7. using System.Collections.Generic;
  8. using System.Linq;
  9. namespace PDF_Office.ViewModels.Dialog.HomePageToolsDialogs.HomePagePrinter
  10. {
  11. public class HomePagePrinterModMultipleContentViewModel : BindableBase, INavigationAware
  12. {
  13. private IEventAggregator eventAggregator;
  14. private int? _verticalPageNumber;
  15. public int? VerticalPageNumber
  16. {
  17. get { return _verticalPageNumber; }
  18. set { SetProperty(ref _verticalPageNumber, value); }
  19. }
  20. private int? _horizontalPageNumber;
  21. public int? HorizontalPageNumber
  22. {
  23. get { return _horizontalPageNumber; }
  24. set { SetProperty(ref _horizontalPageNumber, value); }
  25. }
  26. private bool _isAutoRotate;
  27. public bool IsAutoRotate
  28. {
  29. get { return _isAutoRotate; }
  30. set { _isAutoRotate = value; }
  31. }
  32. private List<string> _pageMatrixList;
  33. public List<string> PageMatrixList
  34. {
  35. get { return _pageMatrixList; }
  36. set { _pageMatrixList = value; }
  37. }
  38. private int _pageMatrixIndex;
  39. /// <summary>
  40. /// <para>0: 1x2</para>
  41. /// <para>1: 2x2</para>
  42. /// <para>2: 3x2</para>
  43. /// <para>3: 3x3</para>
  44. /// <para>4: 4x4</para>
  45. /// <para>5: 自定义</para>
  46. /// </summary>
  47. public int PageMatrixIndex
  48. {
  49. get { return _pageMatrixIndex; }
  50. set
  51. {
  52. _pageMatrixIndex = value;
  53. if (_pageMatrixIndex < 5)
  54. {
  55. EnableCustomiseMatrix = false;
  56. }
  57. else
  58. {
  59. EnableCustomiseMatrix = true;
  60. }
  61. SetPageMatrixValue(value);
  62. }
  63. }
  64. private List<string> _pageOrderList;
  65. public List<string> PageOrderList
  66. {
  67. get { return _pageOrderList; }
  68. set { _pageOrderList = value; }
  69. }
  70. private int _pageOrderIndex;
  71. /// <summary>
  72. /// <para>0: Horizontal</para>
  73. /// <para>1: HorizontalReversed</para>
  74. /// <para>0: Vertical</para>
  75. /// <para>0: VerticalReversed</para>
  76. /// </summary>
  77. public int PageOrderIndex
  78. {
  79. get { return _pageOrderIndex; }
  80. set
  81. {
  82. _pageOrderIndex = value;
  83. InitMultipleInfo();
  84. SendMultipleInfo();
  85. }
  86. }
  87. private bool _enableCustomiseMatrix;
  88. public bool EnableCustomiseMatrix
  89. {
  90. get { return _enableCustomiseMatrix; }
  91. set
  92. {
  93. SetProperty(ref _enableCustomiseMatrix, value);
  94. }
  95. }
  96. private MultipleInfo _multipleInfo;
  97. /// <summary>
  98. /// 多页参数
  99. /// </summary>
  100. public MultipleInfo MultipleInfo
  101. {
  102. get { return _multipleInfo; }
  103. set { _multipleInfo = value; }
  104. }
  105. public HomePagePrinterModMultipleContentViewModel(IEventAggregator eventAggregator)
  106. {
  107. this.eventAggregator = eventAggregator;
  108. PageMatrixIndex = 0;
  109. PageOrderIndex = 0;
  110. PageMatrixList = new List<string>();
  111. InitPageMatrixList();
  112. PageOrderList = new List<string>();
  113. InitPageOrderList();
  114. MultipleInfo = new MultipleInfo();
  115. }
  116. public void SendMultipleInfo()
  117. {
  118. if (MultipleInfo != null)
  119. {
  120. this.eventAggregator.GetEvent<ModInfoSendEvent>().Publish(MultipleInfo);
  121. }
  122. }
  123. private void InitPageMatrixList()
  124. {
  125. PageMatrixList.Clear();
  126. PageMatrixList.Add("2");
  127. PageMatrixList.Add("4");
  128. PageMatrixList.Add("6");
  129. PageMatrixList.Add("9");
  130. PageMatrixList.Add("16");
  131. PageMatrixList.Add("自定义");
  132. }
  133. private void InitPageOrderList()
  134. {
  135. PageOrderList.Clear();
  136. PageOrderList.Add("横向");
  137. PageOrderList.Add("横向倒序");
  138. PageOrderList.Add("纵向");
  139. PageOrderList.Add("纵向倒序");
  140. }
  141. private void SetPageMatrixValue(int pageMatrixIndex)
  142. {
  143. switch (pageMatrixIndex)
  144. {
  145. case 0:
  146. HorizontalPageNumber = 1;
  147. VerticalPageNumber = 2;
  148. InitMultipleInfo();
  149. SendMultipleInfo();
  150. break;
  151. case 1:
  152. HorizontalPageNumber = 2;
  153. VerticalPageNumber = 2;
  154. InitMultipleInfo();
  155. SendMultipleInfo();
  156. break;
  157. case 2:
  158. HorizontalPageNumber = 3;
  159. VerticalPageNumber = 2;
  160. InitMultipleInfo();
  161. SendMultipleInfo();
  162. break;
  163. case 3:
  164. HorizontalPageNumber = 3;
  165. VerticalPageNumber = 3;
  166. InitMultipleInfo();
  167. SendMultipleInfo();
  168. break;
  169. case 4:
  170. HorizontalPageNumber = 4;
  171. VerticalPageNumber = 4;
  172. InitMultipleInfo();
  173. SendMultipleInfo();
  174. break;
  175. case 5:
  176. HorizontalPageNumber = null;
  177. VerticalPageNumber = null;
  178. break;
  179. }
  180. }
  181. private void InitMultipleInfo()
  182. {
  183. if (HorizontalPageNumber == null)
  184. {
  185. HorizontalPageNumber = 1;
  186. }
  187. if (VerticalPageNumber == null)
  188. {
  189. VerticalPageNumber = 1;
  190. }
  191. if (MultipleInfo != null)
  192. {
  193. MultipleInfo.VerticalPageNumber = (int)VerticalPageNumber;
  194. MultipleInfo.HorizontalPageNumber = (int)HorizontalPageNumber;
  195. MultipleInfo.EnumDisplayPageNumber = EnumDisplayPageNumber.StatusTwo;
  196. MultipleInfo.IsAutoRotate = IsAutoRotate;
  197. MultipleInfo.EnumPageOrder = (EnumPageOrder)PageOrderIndex;
  198. }
  199. }
  200. public bool IsNavigationTarget(NavigationContext navigationContext)
  201. {
  202. return true;
  203. }
  204. public void OnNavigatedFrom(NavigationContext navigationContext)
  205. {
  206. }
  207. public void OnNavigatedTo(NavigationContext navigationContext)
  208. {
  209. InitMultipleInfo();
  210. SendMultipleInfo();
  211. }
  212. }
  213. }