PageEditItem.cs 4.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176
  1. using PDF_Master.Helper;
  2. using Prism.Commands;
  3. using Prism.Mvvm;
  4. using System;
  5. using System.Collections.Generic;
  6. using System.Linq;
  7. using System.Text;
  8. using System.Threading.Tasks;
  9. using System.Windows;
  10. using System.Windows.Media.Imaging;
  11. namespace PDF_Master.Model.PageEdit
  12. {
  13. public class PageEditItem:BindableBase
  14. {
  15. private int pageNumber;
  16. /// <summary>
  17. /// 页码
  18. /// </summary>
  19. public int PageNumber
  20. {
  21. get { return pageNumber; }
  22. set
  23. {
  24. SetProperty(ref pageNumber, value);
  25. }
  26. }
  27. private string pageSize = "";
  28. /// <summary>
  29. /// 用于显示的页面尺寸
  30. /// </summary>
  31. public string PageSize
  32. {
  33. get { return pageSize; }
  34. set
  35. {
  36. SetProperty(ref pageSize, value);
  37. }
  38. }
  39. /// <summary>
  40. /// Size类型的页面尺寸 用于插入功能
  41. /// </summary>
  42. private Size size;
  43. public Size Size
  44. {
  45. get { return size; }
  46. set { size = value;
  47. //if(Size.Width>0&&Size.Height>0)
  48. //{
  49. // var heigit = size.Height * 208 / size.Width;
  50. // ItemSize = new Size(208,heigit);
  51. //}
  52. //再设置Size时 同步更新文件尺寸大小,以及设置页面方向
  53. double width = CommonHelper.GetUnitsFromPageSize(value.Width);
  54. double height = CommonHelper.GetUnitsFromPageSize(value.Height);
  55. this.PageSize = $"{width.ToString("F0")}mm*{height.ToString("F0")} mm";
  56. if(value.Width<value.Height)
  57. {
  58. this.isVertical = true;
  59. }
  60. else
  61. {
  62. this.isVertical = false;
  63. }
  64. }
  65. }
  66. private BitmapSource image;
  67. /// <summary>
  68. /// 页面缩略图
  69. /// </summary>
  70. public BitmapSource Image
  71. {
  72. get { return image; }
  73. set
  74. {
  75. SetProperty(ref image, value);
  76. }
  77. }
  78. private bool showPageSize = false;
  79. /// <summary>
  80. /// 是否显示页码尺寸
  81. /// </summary>
  82. public bool ShowPageSize
  83. {
  84. get { return showPageSize; }
  85. set
  86. {
  87. SetProperty(ref showPageSize, value);
  88. }
  89. }
  90. private bool haveBookMark = false;
  91. /// <summary>
  92. /// 该页是否有书签标记
  93. /// </summary>
  94. public bool HaveBookMark
  95. {
  96. get { return haveBookMark; }
  97. set
  98. {
  99. SetProperty(ref haveBookMark, value);
  100. }
  101. }
  102. private Visibility visible = Visibility.Visible;
  103. /// <summary>
  104. /// 是否显示
  105. /// </summary>
  106. public Visibility Visible
  107. {
  108. get { return visible; }
  109. set
  110. {
  111. SetProperty(ref visible, value);
  112. }
  113. }
  114. private bool selected = false;
  115. /// <summary>
  116. /// 是否选中
  117. /// 用于获取项的选中状态
  118. /// </summary>
  119. public bool Selected
  120. {
  121. get { return selected; }
  122. set
  123. {
  124. SetProperty(ref selected, value);
  125. }
  126. }
  127. private Size itemSize = new Size(208, 294);
  128. /// <summary>
  129. /// 控件大小
  130. /// 直接修改Listbox 容器的项大小,会导致间距有问题,所有采用动态绑定大小的方式来实现Item大小更新
  131. /// </summary>
  132. public Size ItemSize
  133. {
  134. get { return itemSize; }
  135. set
  136. {
  137. SetProperty(ref itemSize, value);
  138. }
  139. }
  140. /// <summary>
  141. /// 此次打开中是否已经获取图片,避免重复拿图
  142. /// </summary>
  143. public bool IsGetImage = false;
  144. private bool isvertical = true;
  145. /// <summary>
  146. /// 是否是竖直的图
  147. /// </summary>
  148. public bool isVertical
  149. {
  150. get { return isvertical; }
  151. set {
  152. isvertical = value;
  153. }
  154. }
  155. }
  156. }