PaperSize.cs 3.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133
  1. //
  2. // System.Drawing.PaperSize.cs
  3. //
  4. // Author:
  5. // Dennis Hayes ([email protected])
  6. // Herve Poussineau ([email protected])
  7. //
  8. // (C) 2002 Ximian, Inc
  9. //
  10. //
  11. // Copyright (C) 2004 Novell, Inc (http://www.novell.com)
  12. //
  13. // Permission is hereby granted, free of charge, to any person obtaining
  14. // a copy of this software and associated documentation files (the
  15. // "Software"), to deal in the Software without restriction, including
  16. // without limitation the rights to use, copy, modify, merge, publish,
  17. // distribute, sublicense, and/or sell copies of the Software, and to
  18. // permit persons to whom the Software is furnished to do so, subject to
  19. // the following conditions:
  20. //
  21. // The above copyright notice and this permission notice shall be
  22. // included in all copies or substantial portions of the Software.
  23. //
  24. // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
  25. // EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
  26. // MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
  27. // NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
  28. // LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
  29. // OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
  30. // WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
  31. //
  32. using System;
  33. namespace System.Drawing.Printing
  34. {
  35. /// <summary>
  36. /// Summary description for PaperSize.
  37. /// </summary>
  38. #if NET_2_0
  39. [Serializable]
  40. #endif
  41. public class PaperSize
  42. {
  43. string name;
  44. int width;
  45. int height;
  46. PaperKind kind;
  47. internal bool is_default;
  48. #if NET_2_0
  49. public PaperSize ()
  50. {
  51. }
  52. #endif
  53. public PaperSize(string name, int width, int height)
  54. {
  55. this.width = width;
  56. this.height = height;
  57. this.name = name;
  58. this.kind = PaperKind.Custom;
  59. }
  60. internal PaperSize(string name, int width, int height, PaperKind kind, bool isDefault)
  61. {
  62. this.width = width;
  63. this.height = height;
  64. this.name = name;
  65. this.kind = PaperKind.Custom;
  66. this.is_default = isDefault;
  67. }
  68. public int Width{
  69. get{
  70. return width;
  71. }set
  72. {
  73. if (Kind != PaperKind.Custom)
  74. throw new ArgumentException();
  75. width = value;
  76. }
  77. }
  78. public int Height{
  79. get{
  80. return height;
  81. }set
  82. {
  83. if (Kind != PaperKind.Custom)
  84. throw new ArgumentException();
  85. height = value;
  86. }
  87. }
  88. public string PaperName{
  89. get{
  90. return name;
  91. }
  92. set{
  93. if (Kind != PaperKind.Custom)
  94. throw new ArgumentException();
  95. name = value;
  96. }
  97. }
  98. public PaperKind Kind{
  99. get{
  100. return kind;
  101. }
  102. }
  103. #if NET_2_0
  104. [MonoTODO]
  105. public int RawKind {
  106. get { throw new NotImplementedException(); }
  107. set { throw new NotImplementedException(); }
  108. }
  109. #endif
  110. internal bool IsDefault {
  111. get { return this.is_default; }
  112. set { this.is_default = value; }
  113. }
  114. internal void SetKind (PaperKind k) {kind = k;}
  115. public override string ToString(){
  116. string ret = "[PaperSize {0} Kind={1} Height={2} Width={3}]";
  117. return String.Format(ret, this.PaperName, this.Kind, this.Height, this.Width);
  118. }
  119. }
  120. }