PrinterModel.cs 4.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171
  1. using System;
  2. using System.Collections.Generic;
  3. using System.Linq;
  4. using System.Text;
  5. using System.Threading.Tasks;
  6. using System.Printing;
  7. using System.Drawing.Printing;
  8. using System.Windows;
  9. using ComPDFKit.PDFDocument;
  10. namespace ComPDFKit.Controls
  11. {
  12. public enum DuplexStage
  13. {
  14. None,
  15. FrontSide,
  16. BackSide
  17. }
  18. public enum DuplexPrintMod
  19. {
  20. None,
  21. FlipLongEdge,
  22. FlipShortEdge
  23. }
  24. public enum PrintMod
  25. {
  26. Size,
  27. Poster,
  28. Multiple,
  29. Booklet
  30. }
  31. public enum DisplayPageNumber
  32. {
  33. Two,
  34. Four,
  35. Six,
  36. Nine,
  37. Sixteen,
  38. Customized
  39. }
  40. public enum PageOrder
  41. {
  42. Horizontal,
  43. HorizontalReverse,
  44. Vertical,
  45. VerticalReverse,
  46. }
  47. public enum SizeType
  48. {
  49. Adaptive,
  50. Actural,
  51. Customized
  52. }
  53. public enum BookletBinding
  54. {
  55. Left,
  56. Right,
  57. LeftTall,
  58. RightTall
  59. }
  60. public enum BookletSubset
  61. {
  62. BothSides,
  63. FrontSideOnly,
  64. BackSideOnly
  65. }
  66. public class PrinterModel
  67. {
  68. }
  69. public class PrintSettingsInfo
  70. {
  71. public CPDFDocument Document;
  72. public bool IsGrayscale { get; set; } = false;
  73. public bool IsReverseOrder { get; set; } = false;
  74. public bool NeedRerendering { get; set; } = true;
  75. public bool IsPaperSizeChanged { get; set; } = false;
  76. public bool NeedReversePage { get; set; } = false;
  77. public bool IsPrintAnnot { get; set; } = true;
  78. public bool IsPrintForm { get; set; } = true;
  79. public bool IsBorderless { get; set; } = false;
  80. public List<int> TargetPaperList = new List<int>();
  81. public PageMargins PageMargins { get; set; } = new PageMargins() { Top = 0, Bottom = 0, Left = 0, Right = 0 };
  82. public int Copies { get; set; } = 1;
  83. public string PrinterName { get; set; } = string.Empty;
  84. public DuplexPrintMod DuplexPrintMod { get; set; } = DuplexPrintMod.None;
  85. public PageOrientation PrintOrientation { get; set; } = PageOrientation.Portrait;
  86. public Rect PageBound { get; set; } = new Rect();
  87. public List<int> PageRangeList = new List<int>();
  88. public PrintDocument PrintDocument { get; set; } = new PrintDocument();
  89. public Thickness Margins { get; set; } = new Thickness() { Bottom = 0, Left = 0, Right = 0, Top = 0 };
  90. public PaperSize PaperSize { get; set; } = null;
  91. public double ActualHeight { get => PaperSize.Height - Margins.Bottom - Margins.Top; }
  92. public double ActualWidth { get => PaperSize.Width - Margins.Left - Margins.Right; }
  93. public PrintMode PrintMode { get; set; } = null;
  94. }
  95. public abstract class PrintMode { }
  96. public class SizeModeInfo : PrintMode
  97. {
  98. public SizeType SizeType { get; set; } = SizeType.Adaptive;
  99. public int Scale { get; set; } = 100;
  100. }
  101. public class PosterModeInfo : PrintMode
  102. {
  103. public bool HasCutmarks { get; set; } = false;
  104. public bool HasLabel { get; set; } = false;
  105. public double OverLap { get; set; } = 0;
  106. public int TileRatio { get; set; } = 100;
  107. public string Label { get; set; } = string.Empty;
  108. }
  109. public class MultipleModeInfo : PrintMode
  110. {
  111. public PageOrder PageOrder { get; set; } = PageOrder.Horizontal;
  112. public SheetPair Sheet { get; set; } = new SheetPair(2, 1);
  113. public bool IsAutoRotate { get; set; } = false;
  114. public bool IsPrintBorder { get; set; } = false;
  115. public class SheetPair : IEquatable<SheetPair>
  116. {
  117. public int HorizontalPageNumber { get; set; }
  118. public int VerticalPageNumber { get; set; }
  119. public int TotalPageNumber
  120. {
  121. get => HorizontalPageNumber * VerticalPageNumber;
  122. }
  123. public SheetPair(int horizontalPageNumber, int verticalPageNumber)
  124. {
  125. HorizontalPageNumber = horizontalPageNumber;
  126. VerticalPageNumber = verticalPageNumber;
  127. }
  128. public bool Equals(SheetPair other)
  129. {
  130. return HorizontalPageNumber == other.HorizontalPageNumber && VerticalPageNumber == other.VerticalPageNumber;
  131. }
  132. }
  133. }
  134. public class BookletModeInfo : PrintMode
  135. {
  136. public BookletBinding BookletBinding { get; set; } = BookletBinding.Left;
  137. public BookletSubset Subset { get; set; } = BookletSubset.BothSides;
  138. public int BeginPageIndex { get; set; }
  139. public int EndPageIndex { get; set; }
  140. public bool IsAutoRotate { get; set; } = false;
  141. }
  142. public struct PageMargins
  143. {
  144. public double Top { get; set; }
  145. public double Bottom { get; set; }
  146. public double Left { get; set; }
  147. public double Right { get; set; }
  148. }
  149. }