HomePageSplitDialogModel.cs 7.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297
  1. using Prism.Mvvm;
  2. using System;
  3. using System.Collections.Generic;
  4. using System.Linq;
  5. using System.Text;
  6. using System.Threading.Tasks;
  7. namespace PDF_Office.Model.HomePageToolsDialogs
  8. {
  9. public class HomePageSplitDialogModel:BindableBase
  10. {
  11. /// <summary>
  12. /// 拆分模式
  13. /// </summary>
  14. public SplitMode Mode = SplitMode.AveragePages;
  15. /// <summary>
  16. /// 页面范围形式
  17. /// </summary>
  18. public PageRangeMode PageMode = PageRangeMode.OddPage;
  19. /// <summary>
  20. /// 拆分模式份数或者页数
  21. /// </summary>
  22. public int GetModeCount = 1;
  23. /// <summary>
  24. /// 页面信息
  25. /// </summary>
  26. public string PageRange = "1,3-4,10";
  27. private int pageSelectedIndex = 1;
  28. public int PageSelectedIndex
  29. {
  30. get { return pageSelectedIndex; }
  31. set
  32. {
  33. SetProperty(ref pageSelectedIndex, value);
  34. switch (value)
  35. {
  36. case 1:
  37. PageMode = PageRangeMode.OddPage;
  38. break;
  39. case 2:
  40. PageMode = PageRangeMode.EvenPage;
  41. break;
  42. case 3:
  43. PageMode = PageRangeMode.CustomPage;
  44. break;
  45. default:
  46. break;
  47. }
  48. }
  49. }
  50. private double pageNum = 1;
  51. /// <summary>
  52. /// 平均页数
  53. /// </summary>
  54. public double PageNum
  55. {
  56. get { return pageNum; }
  57. set
  58. {
  59. SetProperty(ref pageNum, value);
  60. GetModeCount = (int)value;
  61. }
  62. }
  63. private double filesCount = 1;
  64. /// <summary>
  65. /// 平均文件数
  66. /// </summary>
  67. public double FilesCount
  68. {
  69. get { return filesCount; }
  70. set
  71. {
  72. SetProperty(ref filesCount, value);
  73. GetModeCount = (int)value;
  74. }
  75. }
  76. private bool isAveragePages = true;
  77. /// <summary>
  78. /// 平均按页拆分 是否选中
  79. /// </summary>
  80. public bool IsAveragePages
  81. {
  82. get { return isAveragePages; }
  83. set
  84. {
  85. SetProperty(ref isAveragePages, value);
  86. if(value)
  87. {
  88. Mode = SplitMode.AveragePages;
  89. }
  90. }
  91. }
  92. private bool isAveragePDF = false;
  93. /// <summary>
  94. /// 平均按PDF拆分 是否选中
  95. /// </summary>
  96. public bool IsAveragePDF
  97. {
  98. get { return isAveragePDF; }
  99. set
  100. {
  101. SetProperty(ref isAveragePDF, value);
  102. if (value)
  103. {
  104. Mode = SplitMode.AverageFiles;
  105. }
  106. }
  107. }
  108. private bool isCustomRange = false;
  109. /// <summary>
  110. /// 自定义页面范围,是否选中
  111. /// </summary>
  112. public bool IsCustomRange
  113. {
  114. get { return isCustomRange; }
  115. set
  116. {
  117. SetProperty(ref isCustomRange, value);
  118. if (value)
  119. {
  120. Mode = SplitMode.CustomPageRange;
  121. }
  122. }
  123. }
  124. /// <summary>
  125. /// 文件名标签
  126. /// </summary>
  127. private string fileNameLabel = "part";
  128. public string FileNameLabel
  129. {
  130. get { return fileNameLabel; }
  131. set
  132. {
  133. SetProperty(ref fileNameLabel, value);
  134. RefreshFileName();
  135. }
  136. }
  137. private bool hasLabel = true;
  138. /// <summary>
  139. /// 是否含有标签
  140. /// </summary>
  141. public bool HasLabel
  142. {
  143. get { return hasLabel; }
  144. set
  145. {
  146. SetProperty(ref hasLabel, value);
  147. RefreshFileName();
  148. }
  149. }
  150. /// <summary>
  151. /// 文件名与标签分隔符
  152. /// </summary>
  153. private string fileNameDeimiter="-";
  154. public string FileNameDeimiter
  155. {
  156. get { return fileNameDeimiter; }
  157. set
  158. {
  159. SetProperty(ref fileNameDeimiter, value);
  160. RefreshFileName();
  161. }
  162. }
  163. private bool hasDeimiter = true;
  164. /// <summary>
  165. /// 是否含有分隔符
  166. /// </summary>
  167. public bool HasDeimiter
  168. {
  169. get { return hasDeimiter; }
  170. set
  171. {
  172. SetProperty(ref hasDeimiter, value);
  173. RefreshFileName();
  174. }
  175. }
  176. /// <summary>
  177. /// 文件名与标签分隔符
  178. /// </summary>
  179. public bool FrontFileName = true;
  180. /// <summary>
  181. /// 页码 存入页码范围;
  182. /// </summary>
  183. public List<int> PageParm = new List<int> { };
  184. /// <summary>
  185. /// 文件名;
  186. /// </summary>
  187. private string fileName = "";
  188. public string FileName
  189. {
  190. get { return fileName; }
  191. set
  192. {
  193. SetProperty(ref fileName, value);
  194. }
  195. }
  196. private bool isSourceNameFront = true;
  197. /// <summary>
  198. /// 原始文档名前置
  199. /// </summary>
  200. public bool IsSourceNameFront
  201. {
  202. get { return isSourceNameFront; }
  203. set
  204. {
  205. SetProperty(ref isSourceNameFront, value);
  206. RefreshFileName();
  207. }
  208. }
  209. private string sourceName;
  210. /// <summary>
  211. /// 原始文件名
  212. /// </summary>
  213. public string SourceFileName
  214. {
  215. get { return sourceName; }
  216. set
  217. {
  218. SetProperty(ref sourceName, value);
  219. RefreshFileName();
  220. }
  221. }
  222. /// <summary>
  223. /// 刷新文件名
  224. /// </summary>
  225. public void RefreshFileName()
  226. {
  227. string label = HasLabel ? FileNameLabel : "";
  228. string deimiter = hasDeimiter ? FileNameDeimiter : "";
  229. if(isSourceNameFront)
  230. {
  231. FileName = SourceFileName + deimiter + label + ".pdf";
  232. }
  233. else
  234. {
  235. FileName = label + deimiter + SourceFileName + ".pdf";
  236. }
  237. }
  238. public enum SplitMode
  239. {
  240. /// <summary>
  241. /// 按页平均拆分
  242. /// </summary>
  243. AveragePages,
  244. /// <summary>
  245. /// 按文件平均拆分
  246. /// </summary>
  247. AverageFiles,
  248. /// <summary>
  249. /// 自定义页码范围拆分
  250. /// </summary>
  251. CustomPageRange
  252. }
  253. public enum PageRangeMode
  254. {
  255. /// <summary>
  256. /// 奇数页
  257. /// </summary>
  258. OddPage,
  259. /// <summary>
  260. /// 偶数页
  261. /// </summary>
  262. EvenPage,
  263. /// <summary>
  264. /// 自定义页面范围
  265. /// </summary>
  266. CustomPage
  267. }
  268. }
  269. }