PageEditItem.cs 4.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192
  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
  47. {
  48. size = value;
  49. //if(Size.Width>0&&Size.Height>0)
  50. //{
  51. // var heigit = size.Height * 208 / size.Width;
  52. // ItemSize = new Size(208,heigit);
  53. //}
  54. //再设置Size时 同步更新文件尺寸大小,以及设置页面方向
  55. double width = CommonHelper.GetUnitsFromPageSize(value.Width);
  56. double height = CommonHelper.GetUnitsFromPageSize(value.Height);
  57. this.PageSize = $"{width.ToString("F0")}x{height.ToString("F0")}mm";
  58. if (value.Width < value.Height)
  59. {
  60. this.isVertical = true;
  61. }
  62. else
  63. {
  64. this.isVertical = false;
  65. }
  66. }
  67. }
  68. private BitmapSource image;
  69. /// <summary>
  70. /// 页面缩略图
  71. /// </summary>
  72. public BitmapSource Image
  73. {
  74. get { return image; }
  75. set
  76. {
  77. SetProperty(ref image, value);
  78. }
  79. }
  80. private bool showPageSize = false;
  81. /// <summary>
  82. /// 是否显示页码尺寸
  83. /// </summary>
  84. public bool ShowPageSize
  85. {
  86. get { return showPageSize; }
  87. set
  88. {
  89. SetProperty(ref showPageSize, value);
  90. }
  91. }
  92. private int fontSize = 14;
  93. public int FontSize
  94. {
  95. get { return fontSize; }
  96. set
  97. {
  98. SetProperty(ref fontSize, value);
  99. }
  100. }
  101. private bool haveBookMark = false;
  102. /// <summary>
  103. /// 该页是否有书签标记
  104. /// </summary>
  105. public bool HaveBookMark
  106. {
  107. get { return haveBookMark; }
  108. set
  109. {
  110. SetProperty(ref haveBookMark, value);
  111. }
  112. }
  113. private Visibility visible = Visibility.Visible;
  114. /// <summary>
  115. /// 是否显示
  116. /// </summary>
  117. public Visibility Visible
  118. {
  119. get { return visible; }
  120. set
  121. {
  122. SetProperty(ref visible, value);
  123. }
  124. }
  125. private bool selected = false;
  126. /// <summary>
  127. /// 是否选中
  128. /// 用于获取项的选中状态
  129. /// </summary>
  130. public bool Selected
  131. {
  132. get { return selected; }
  133. set
  134. {
  135. SetProperty(ref selected, value);
  136. }
  137. }
  138. private Size itemSize = new Size(208, 294);
  139. /// <summary>
  140. /// 控件大小
  141. /// 直接修改Listbox 容器的项大小,会导致间距有问题,所有采用动态绑定大小的方式来实现Item大小更新
  142. /// </summary>
  143. public Size ItemSize
  144. {
  145. get { return itemSize; }
  146. set
  147. {
  148. SetProperty(ref itemSize, value);
  149. }
  150. }
  151. /// <summary>
  152. /// 此次打开中是否已经获取图片,避免重复拿图
  153. /// </summary>
  154. public bool IsGetImage = false;
  155. private bool isvertical = true;
  156. /// <summary>
  157. /// 是否是竖直的图
  158. /// </summary>
  159. public bool isVertical
  160. {
  161. get { return isvertical; }
  162. set
  163. {
  164. isvertical = value;
  165. }
  166. }
  167. }
  168. }