PrinterModel.cs 4.4 KB

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