PageSettings.cs 3.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166
  1. //
  2. // System.Drawing.PageSettings.cs
  3. //
  4. // Authors:
  5. // Dennis Hayes ([email protected])
  6. // Herve Poussineau ([email protected])
  7. // Andreas Nahr ([email protected])
  8. //
  9. // (C) 2002 Ximian, Inc
  10. //
  11. using System;
  12. using System.Runtime.InteropServices;
  13. namespace System.Drawing.Printing
  14. {
  15. [ComVisible (false)]
  16. public class PageSettings : ICloneable
  17. {
  18. bool _Color;
  19. bool _Landscape;
  20. // create a new default Margins object (is 1 inch for all margins)
  21. Margins _Margins = new Margins();
  22. PaperSize _PaperSize;
  23. PaperSource _PaperSource;
  24. PrinterResolution _PrinterResolution;
  25. PrinterSettings _PrinterSettings;
  26. public PageSettings() : this(new PrinterSettings())
  27. {
  28. }
  29. public PageSettings(PrinterSettings printerSettings)
  30. {
  31. PrinterSettings = printerSettings;
  32. Color = printerSettings.DefaultPageSettings.Color;
  33. Landscape = printerSettings.DefaultPageSettings.Landscape;
  34. PaperSize = printerSettings.DefaultPageSettings.PaperSize;
  35. PaperSource = printerSettings.DefaultPageSettings.PaperSource;
  36. PrinterResolution = printerSettings.DefaultPageSettings.PrinterResolution;
  37. }
  38. // used by PrinterSettings.DefaultPageSettings
  39. internal PageSettings(PrinterSettings printerSettings, bool color, bool landscape, PaperSize paperSize, PaperSource paperSource, PrinterResolution printerResolution)
  40. {
  41. PrinterSettings = printerSettings;
  42. Color = color;
  43. Landscape = landscape;
  44. PaperSize = paperSize;
  45. PaperSource = paperSource;
  46. PrinterResolution = printerResolution;
  47. }
  48. //props
  49. public Rectangle Bounds{
  50. get{
  51. int width = this.PaperSize.Width;
  52. int height = this.PaperSize.Height;
  53. width -= this.Margins.Left + this.Margins.Right;
  54. height -= this.Margins.Top + this.Margins.Bottom;
  55. if (this.Landscape) {
  56. // swap width and height
  57. int tmp = width;
  58. width = height;
  59. height = tmp;
  60. }
  61. return new Rectangle(0, 0, width, height);
  62. }
  63. }
  64. public bool Color{
  65. get{
  66. return _Color;
  67. }
  68. set{
  69. _Color = value;
  70. }
  71. }
  72. public bool Landscape {
  73. get{
  74. return _Landscape;
  75. }
  76. set{
  77. _Landscape = value;
  78. }
  79. }
  80. public Margins Margins{
  81. get{
  82. return _Margins;
  83. }
  84. set{
  85. _Margins = value;
  86. }
  87. }
  88. public PaperSize PaperSize{
  89. get{
  90. return _PaperSize;
  91. }
  92. set{
  93. _PaperSize = value;
  94. }
  95. }
  96. public PaperSource PaperSource{
  97. get{
  98. return _PaperSource;
  99. }
  100. set{
  101. _PaperSource = value;
  102. }
  103. }
  104. public PrinterResolution PrinterResolution{
  105. get{
  106. return _PrinterResolution;
  107. }
  108. set{
  109. _PrinterResolution = value;
  110. }
  111. }
  112. public PrinterSettings PrinterSettings{
  113. get{
  114. return _PrinterSettings;
  115. }
  116. set{
  117. _PrinterSettings = value;
  118. }
  119. }
  120. public object Clone(){
  121. return new PageSettings(this.PrinterSettings);
  122. }
  123. [MonoTODO("PageSettings.CopyToHdevmode")]
  124. public void CopyToHdevmode (IntPtr hdevmode){
  125. throw new NotImplementedException ();
  126. }
  127. [MonoTODO("PageSettings.SetHdevmode")]
  128. public void SetHdevmode (IntPtr hdevmode){
  129. throw new NotImplementedException ();
  130. }
  131. public override string ToString(){
  132. string ret = "[PageSettings: Color={0}";
  133. ret += ", Landscape={1}";
  134. ret += ", Margins={2}";
  135. ret += ", PaperSize={3}";
  136. ret += ", PaperSource={4}";
  137. ret += ", PrinterResolution={5}";
  138. ret += "]";
  139. return String.Format(ret, this.Color, this.Landscape, this.Margins, this.PaperSize, this.PaperSource, this.PrinterResolution);
  140. }
  141. }
  142. }