HomePageSplitDialogModel.cs 4.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168
  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 int GetModeCount = 1;
  19. /// <summary>
  20. /// 页面信息
  21. /// </summary>
  22. public string PageRange = "1,3-4,10";
  23. /// <summary>
  24. /// 文件名标签
  25. /// </summary>
  26. private string fileNameLabel = "part";
  27. public string FileNameLabel
  28. {
  29. get { return fileNameLabel; }
  30. set
  31. {
  32. SetProperty(ref fileNameLabel, value);
  33. RefreshFileName();
  34. }
  35. }
  36. private bool hasLabel = true;
  37. /// <summary>
  38. /// 是否含有标签
  39. /// </summary>
  40. public bool HasLabel
  41. {
  42. get { return hasLabel; }
  43. set
  44. {
  45. SetProperty(ref hasLabel, value);
  46. RefreshFileName();
  47. }
  48. }
  49. /// <summary>
  50. /// 文件名与标签分隔符
  51. /// </summary>
  52. private string fileNameDeimiter="-";
  53. public string FileNameDeimiter
  54. {
  55. get { return fileNameDeimiter; }
  56. set
  57. {
  58. SetProperty(ref fileNameDeimiter, value);
  59. RefreshFileName();
  60. }
  61. }
  62. private bool hasDeimiter = true;
  63. /// <summary>
  64. /// 是否含有分隔符
  65. /// </summary>
  66. public bool HasDeimiter
  67. {
  68. get { return hasDeimiter; }
  69. set
  70. {
  71. SetProperty(ref hasDeimiter, value);
  72. RefreshFileName();
  73. }
  74. }
  75. /// <summary>
  76. /// 文件名与标签分隔符
  77. /// </summary>
  78. public bool FrontFileName = true;
  79. /// <summary>
  80. /// 页码 存入页码范围;
  81. /// </summary>
  82. public List<int> PageParm = new List<int> { };
  83. /// <summary>
  84. /// 文件名;
  85. /// </summary>
  86. private string fileName = "";
  87. public string FileName
  88. {
  89. get { return fileName; }
  90. set
  91. {
  92. SetProperty(ref fileName, value);
  93. }
  94. }
  95. private bool isSourceNameFront = true;
  96. /// <summary>
  97. /// 原始文档名前置
  98. /// </summary>
  99. public bool IsSourceNameFront
  100. {
  101. get { return isSourceNameFront; }
  102. set
  103. {
  104. SetProperty(ref isSourceNameFront, value);
  105. RefreshFileName();
  106. }
  107. }
  108. private string sourceName;
  109. /// <summary>
  110. /// 原始文件名
  111. /// </summary>
  112. public string SourceFileName
  113. {
  114. get { return sourceName; }
  115. set
  116. {
  117. SetProperty(ref sourceName, value);
  118. RefreshFileName();
  119. }
  120. }
  121. /// <summary>
  122. /// 刷新文件名
  123. /// </summary>
  124. public void RefreshFileName()
  125. {
  126. string label = HasLabel ? FileNameLabel : "";
  127. string deimiter = hasDeimiter ? FileNameDeimiter : "";
  128. if(isSourceNameFront)
  129. {
  130. FileName = SourceFileName + deimiter + label + ".pdf";
  131. }
  132. else
  133. {
  134. FileName = label + deimiter + SourceFileName + ".pdf";
  135. }
  136. }
  137. public enum SplitMode
  138. {
  139. /// <summary>
  140. /// 按页平均拆分
  141. /// </summary>
  142. AveragePages,
  143. /// <summary>
  144. /// 按文件平均拆分
  145. /// </summary>
  146. AverageFiles,
  147. /// <summary>
  148. /// 自定义页码范围拆分
  149. /// </summary>
  150. CustomPageRange
  151. }
  152. }
  153. }