PrinterSettings.cs 12 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462
  1. //
  2. // System.Drawing.PrinterSettings.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. //
  12. // Copyright (C) 2004 Novell, Inc (http://www.novell.com)
  13. //
  14. // Permission is hereby granted, free of charge, to any person obtaining
  15. // a copy of this software and associated documentation files (the
  16. // "Software"), to deal in the Software without restriction, including
  17. // without limitation the rights to use, copy, modify, merge, publish,
  18. // distribute, sublicense, and/or sell copies of the Software, and to
  19. // permit persons to whom the Software is furnished to do so, subject to
  20. // the following conditions:
  21. //
  22. // The above copyright notice and this permission notice shall be
  23. // included in all copies or substantial portions of the Software.
  24. //
  25. // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
  26. // EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
  27. // MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
  28. // NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
  29. // LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
  30. // OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
  31. // WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
  32. //
  33. using System;
  34. using System.Runtime.InteropServices;
  35. using System.Collections;
  36. using System.Drawing.Printing;
  37. using System.ComponentModel;
  38. using System.Drawing.Imaging;
  39. namespace System.Drawing.Printing
  40. {
  41. [Serializable]
  42. #if ! NET_2_0
  43. [ComVisible(false)]
  44. #endif
  45. public class PrinterSettings : ICloneable
  46. {
  47. public PrinterSettings()
  48. {
  49. }
  50. // Public subclasses
  51. public class PaperSourceCollection : ICollection, IEnumerable
  52. {
  53. ArrayList _PaperSources = new ArrayList();
  54. public PaperSourceCollection(PaperSource[] array) {
  55. foreach (PaperSource ps in array)
  56. _PaperSources.Add(ps);
  57. }
  58. public int Count { get { return _PaperSources.Count; } }
  59. int ICollection.Count { get { return _PaperSources.Count; } }
  60. bool ICollection.IsSynchronized { get { return false; } }
  61. object ICollection.SyncRoot { get { return this; } }
  62. #if NET_2_0
  63. [EditorBrowsable(EditorBrowsableState.Never)]
  64. public int Add (PaperSource paperSource) {throw new NotImplementedException (); }
  65. public void CopyTo (PaperSource[] paperSources, int index) {throw new NotImplementedException (); }
  66. #endif
  67. public virtual PaperSource this[int index] {
  68. get { return _PaperSources[index] as PaperSource; }
  69. }
  70. IEnumerator IEnumerable.GetEnumerator()
  71. {
  72. return _PaperSources.GetEnumerator();
  73. }
  74. public IEnumerator GetEnumerator()
  75. {
  76. return _PaperSources.GetEnumerator();
  77. }
  78. void ICollection.CopyTo(Array array, int index)
  79. {
  80. _PaperSources.CopyTo(array, index);
  81. }
  82. }
  83. public class PaperSizeCollection : ICollection, IEnumerable
  84. {
  85. ArrayList _PaperSizes = new ArrayList();
  86. public PaperSizeCollection(PaperSize[] array) {
  87. foreach (PaperSize ps in array)
  88. _PaperSizes.Add(ps);
  89. }
  90. public int Count { get { return _PaperSizes.Count; } }
  91. int ICollection.Count { get { return _PaperSizes.Count; } }
  92. bool ICollection.IsSynchronized { get { return false; } }
  93. object ICollection.SyncRoot { get { return this; } }
  94. #if NET_2_0
  95. [EditorBrowsable(EditorBrowsableState.Never)]
  96. public int Add (PaperSize paperSize) {throw new NotImplementedException (); }
  97. public void CopyTo (PaperSize[] paperSizes, int index) {throw new NotImplementedException (); }
  98. #endif
  99. public virtual PaperSize this[int index] {
  100. get { return _PaperSizes[index] as PaperSize; }
  101. }
  102. IEnumerator IEnumerable.GetEnumerator()
  103. {
  104. return _PaperSizes.GetEnumerator();
  105. }
  106. public IEnumerator GetEnumerator()
  107. {
  108. return _PaperSizes.GetEnumerator();
  109. }
  110. void ICollection.CopyTo(Array array, int index)
  111. {
  112. _PaperSizes.CopyTo(array, index);
  113. }
  114. }
  115. public class PrinterResolutionCollection : ICollection, IEnumerable
  116. {
  117. ArrayList _PrinterResolutions = new ArrayList();
  118. public PrinterResolutionCollection(PrinterResolution[] array) {
  119. foreach (PrinterResolution pr in array)
  120. _PrinterResolutions.Add(pr);
  121. }
  122. public int Count { get { return _PrinterResolutions.Count; } }
  123. int ICollection.Count { get { return _PrinterResolutions.Count; } }
  124. bool ICollection.IsSynchronized { get { return false; } }
  125. object ICollection.SyncRoot { get { return this; } }
  126. #if NET_2_0
  127. [EditorBrowsable(EditorBrowsableState.Never)]
  128. public int Add (PrinterResolution printerResolution) {throw new NotImplementedException (); }
  129. public void CopyTo (PrinterResolution[] printerResolutions, int index) {throw new NotImplementedException (); }
  130. #endif
  131. public virtual PrinterResolution this[int index] {
  132. get { return _PrinterResolutions[index] as PrinterResolution; }
  133. }
  134. IEnumerator IEnumerable.GetEnumerator()
  135. {
  136. return _PrinterResolutions.GetEnumerator();
  137. }
  138. public IEnumerator GetEnumerator()
  139. {
  140. return _PrinterResolutions.GetEnumerator();
  141. }
  142. void ICollection.CopyTo(Array array, int index)
  143. {
  144. _PrinterResolutions.CopyTo(array, index);
  145. }
  146. }
  147. public class StringCollection : ICollection, IEnumerable
  148. {
  149. ArrayList _Strings = new ArrayList();
  150. public StringCollection(string[] array) {
  151. foreach (string s in array)
  152. _Strings.Add(s);
  153. }
  154. public int Count { get { return _Strings.Count; } }
  155. int ICollection.Count { get { return _Strings.Count; } }
  156. bool ICollection.IsSynchronized { get { return false; } }
  157. object ICollection.SyncRoot { get { return this; } }
  158. public virtual string this[int index] {
  159. get { return _Strings[index] as string; }
  160. }
  161. #if NET_2_0
  162. [EditorBrowsable(EditorBrowsableState.Never)]
  163. public int Add (string value) {throw new NotImplementedException (); }
  164. public void CopyTo (string[] strings, int index) {throw new NotImplementedException (); }
  165. #endif
  166. IEnumerator IEnumerable.GetEnumerator()
  167. {
  168. return _Strings.GetEnumerator();
  169. }
  170. public IEnumerator GetEnumerator()
  171. {
  172. return _Strings.GetEnumerator();
  173. }
  174. void ICollection.CopyTo(Array array, int index)
  175. {
  176. _Strings.CopyTo(array, index);
  177. }
  178. }
  179. //properties
  180. [MonoTODO("PrinterSettings.CanDuplex")]
  181. public bool CanDuplex
  182. {
  183. get { throw new NotImplementedException(); }
  184. }
  185. [MonoTODO("PrinterSettings.Collate")]
  186. public bool Collate
  187. {
  188. get { throw new NotImplementedException(); }
  189. set { throw new NotImplementedException(); }
  190. }
  191. [MonoTODO("PrinterSettings.Copies")]
  192. public short Copies
  193. {
  194. get { throw new NotImplementedException(); }
  195. set { throw new NotImplementedException(); }
  196. }
  197. [MonoTODO("PrinterSettings.DefaultPageSettings")]
  198. public PageSettings DefaultPageSettings
  199. {
  200. get
  201. {
  202. return new PageSettings(
  203. this,
  204. // TODO: get default color mode for this printer
  205. false,
  206. // TODO: get default orientation for this printer
  207. false,
  208. // TODO: get default paper size for this printer
  209. new PaperSize("A4", 827, 1169),
  210. // TODO: get default paper source for this printer
  211. new PaperSource("default", PaperSourceKind.FormSource),
  212. // TODO: get default resolution for this printer
  213. new PrinterResolution(300, 300, PrinterResolutionKind.Medium)
  214. );
  215. }
  216. }
  217. [MonoTODO("PrinterSettings.Duplex")]
  218. public Duplex Duplex
  219. {
  220. get { throw new NotImplementedException(); }
  221. set { throw new NotImplementedException(); }
  222. }
  223. [MonoTODO("PrinterSettings.FromPage")]
  224. public int FromPage
  225. {
  226. get { throw new NotImplementedException(); }
  227. set { throw new NotImplementedException(); }
  228. }
  229. [MonoTODO("PrinterSettings.InstalledPrinters")]
  230. public static PrinterSettings.StringCollection InstalledPrinters
  231. {
  232. get { throw new NotImplementedException(); }
  233. }
  234. [MonoTODO("PrinterSettings.IsDefaultPrinter")]
  235. public bool IsDefaultPrinter
  236. {
  237. get { throw new NotImplementedException(); }
  238. }
  239. [MonoTODO("PrinterSettings.IsPlotter")]
  240. public bool IsPlotter
  241. {
  242. get { throw new NotImplementedException(); }
  243. }
  244. [MonoTODO("PrinterSettings.IsValid")]
  245. public bool IsValid
  246. {
  247. get { throw new NotImplementedException(); }
  248. }
  249. [MonoTODO("PrinterSettings.LandscapeAngle")]
  250. public int LandscapeAngle
  251. {
  252. get { throw new NotImplementedException(); }
  253. }
  254. [MonoTODO("PrinterSettings.MaximumCopies")]
  255. public int MaximumCopies
  256. {
  257. get { throw new NotImplementedException(); }
  258. }
  259. [MonoTODO("PrinterSettings.MaximumPage")]
  260. public int MaximumPage
  261. {
  262. get { throw new NotImplementedException(); }
  263. set { throw new NotImplementedException(); }
  264. }
  265. [MonoTODO("PrinterSettings.MinimumPage")]
  266. public int MinimumPage
  267. {
  268. get { throw new NotImplementedException(); }
  269. set { throw new NotImplementedException(); }
  270. }
  271. [MonoTODO("PrinterSettings.PaperSizes")]
  272. public PrinterSettings.PaperSizeCollection PaperSizes
  273. {
  274. get { throw new NotImplementedException(); }
  275. }
  276. [MonoTODO("PrinterSettings.PaperSources")]
  277. public PrinterSettings.PaperSourceCollection PaperSources
  278. {
  279. get { throw new NotImplementedException(); }
  280. }
  281. #if NET_2_0
  282. [MonoTODO("PrinterSettings.PrintFileName")]
  283. public string PrintFileName
  284. {
  285. get { throw new NotImplementedException(); }
  286. set { throw new NotImplementedException(); }
  287. }
  288. #endif
  289. [MonoTODO("PrinterSettings.PrinterName")]
  290. public string PrinterName
  291. {
  292. get { throw new NotImplementedException(); }
  293. set { throw new NotImplementedException(); }
  294. }
  295. [MonoTODO("PrinterSettings.PrinterResolutions")]
  296. public PrinterSettings.PrinterResolutionCollection PrinterResolutions
  297. {
  298. get { throw new NotImplementedException(); }
  299. }
  300. [MonoTODO("PrinterSettings.PrintRange")]
  301. public PrintRange PrintRange
  302. {
  303. get { throw new NotImplementedException(); }
  304. set { throw new NotImplementedException(); }
  305. }
  306. [MonoTODO("PrinterSettings.PrintToFile")]
  307. public bool PrintToFile
  308. {
  309. get { throw new NotImplementedException(); }
  310. set { throw new NotImplementedException(); }
  311. }
  312. [MonoTODO("PrinterSettings.SupportsColor")]
  313. public bool SupportsColor
  314. {
  315. get { throw new NotImplementedException(); }
  316. }
  317. [MonoTODO("PrinterSettings.ToPage")]
  318. public int ToPage
  319. {
  320. get { throw new NotImplementedException(); }
  321. set { throw new NotImplementedException(); }
  322. }
  323. //methods
  324. [MonoTODO("PrinterSettings.Clone")]
  325. public virtual object Clone()
  326. {
  327. throw new NotImplementedException();
  328. }
  329. [MonoTODO("PrinterSettings.CreateMeasurementGraphics")]
  330. public Graphics CreateMeasurementGraphics()
  331. {
  332. throw new NotImplementedException();
  333. }
  334. #if NET_2_0
  335. [MonoTODO("PrinterSettings.CreateMeasurementGraphics")]
  336. public Graphics CreateMeasurementGraphics(bool honorOriginAtMargins)
  337. {
  338. throw new NotImplementedException();
  339. }
  340. [MonoTODO("PrinterSettings.CreateMeasurementGraphics")]
  341. public Graphics CreateMeasurementGraphics(PageSettings pageSettings)
  342. {
  343. throw new NotImplementedException();
  344. }
  345. [MonoTODO("PrinterSettings.CreateMeasurementGraphics")]
  346. public Graphics CreateMeasurementGraphics (PageSettings pageSettings, bool honorOriginAtMargins)
  347. {
  348. throw new NotImplementedException();
  349. }
  350. #endif
  351. [MonoTODO("PrinterSettings.GetHdevmode")]
  352. public IntPtr GetHdevmode()
  353. {
  354. throw new NotImplementedException();
  355. }
  356. [MonoTODO("PrinterSettings.GetHdevmode")]
  357. public IntPtr GetHdevmode(PageSettings pageSettings)
  358. {
  359. throw new NotImplementedException();
  360. }
  361. [MonoTODO("PrinterSettings.GetHdevname")]
  362. public IntPtr GetHdevnames()
  363. {
  364. throw new NotImplementedException();
  365. }
  366. #if NET_2_0
  367. [MonoTODO("IsDirectPrintingSupported")]
  368. public bool IsDirectPrintingSupported (Image image)
  369. {
  370. throw new NotImplementedException();
  371. }
  372. [MonoTODO("IsDirectPrintingSupported")]
  373. public bool IsDirectPrintingSupported (ImageFormat imageFormat)
  374. {
  375. throw new NotImplementedException();
  376. }
  377. #endif
  378. [MonoTODO("PrinterSettings.SetHdevmode")]
  379. public void SetHdevmode(IntPtr hdevmode)
  380. {
  381. throw new NotImplementedException();
  382. }
  383. [MonoTODO("PrinterSettings.SetHdevnames")]
  384. public void SetHdevnames(IntPtr hdevnames)
  385. {
  386. throw new NotImplementedException();
  387. }
  388. [MonoTODO("PrinterSettings.ToString")]
  389. public override string ToString()
  390. {
  391. throw new NotImplementedException();
  392. }
  393. }
  394. }