PageSettings.cs 3.5 KB

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