2 // System.Drawing.PageSettings.cs
5 // Dennis Hayes (dennish@Raytek.com)
6 // Herve Poussineau (hpoussineau@fr.st)
7 // Andreas Nahr (ClassDevelopment@A-SoftTech.com)
9 // (C) 2002 Ximian, Inc
13 // Copyright (C) 2004 Novell, Inc (http://www.novell.com)
15 // Permission is hereby granted, free of charge, to any person obtaining
16 // a copy of this software and associated documentation files (the
17 // "Software"), to deal in the Software without restriction, including
18 // without limitation the rights to use, copy, modify, merge, publish,
19 // distribute, sublicense, and/or sell copies of the Software, and to
20 // permit persons to whom the Software is furnished to do so, subject to
21 // the following conditions:
23 // The above copyright notice and this permission notice shall be
24 // included in all copies or substantial portions of the Software.
26 // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
27 // EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
28 // MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
29 // NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
30 // LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
31 // OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
32 // WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
36 using System.Runtime.InteropServices;
38 namespace System.Drawing.Printing
45 public class PageSettings : ICloneable
51 RectangleF _PrintableArea;
52 // create a new default Margins object (is 1 inch for all margins)
53 Margins _Margins = new Margins();
55 PaperSource _PaperSource;
56 PrinterResolution _PrinterResolution;
57 PrinterSettings _PrinterSettings;
59 public PageSettings() : this(new PrinterSettings())
63 public PageSettings(PrinterSettings printerSettings)
65 PrinterSettings = printerSettings;
67 Color = printerSettings.DefaultPageSettings.Color;
68 Landscape = printerSettings.DefaultPageSettings.Landscape;
69 PaperSize = printerSettings.DefaultPageSettings.PaperSize;
70 PaperSource = printerSettings.DefaultPageSettings.PaperSource;
71 PrinterResolution = printerSettings.DefaultPageSettings.PrinterResolution;
74 // used by PrinterSettings.DefaultPageSettings
75 internal PageSettings(PrinterSettings printerSettings, bool color, bool landscape, PaperSize paperSize, PaperSource paperSource, PrinterResolution printerResolution)
77 PrinterSettings = printerSettings;
80 Landscape = landscape;
81 PaperSize = paperSize;
82 PaperSource = paperSource;
83 PrinterResolution = printerResolution;
87 public Rectangle Bounds{
89 int width = this.PaperSize.Width;
90 int height = this.PaperSize.Height;
92 width -= this.Margins.Left + this.Margins.Right;
93 height -= this.Margins.Top + this.Margins.Bottom;
96 // swap width and height
101 return new Rectangle (Margins.Left, Margins.Top, width, height);
114 public bool Landscape {
123 public Margins Margins{
132 public PaperSize PaperSize{
141 public PaperSource PaperSource{
146 _PaperSource = value;
150 public PrinterResolution PrinterResolution{
152 return _PrinterResolution;
155 _PrinterResolution = value;
159 public PrinterSettings PrinterSettings{
161 return _PrinterSettings;
164 _PrinterSettings = value;
168 public float HardMarginX {
174 public float HardMarginY {
180 public RectangleF PrintableArea {
182 return _PrintableArea;
188 public object Clone(){
189 return new PageSettings(this.PrinterSettings);
193 [MonoTODO("PageSettings.CopyToHdevmode")]
194 public void CopyToHdevmode (IntPtr hdevmode){
195 throw new NotImplementedException ();
199 [MonoTODO("PageSettings.SetHdevmode")]
200 public void SetHdevmode (IntPtr hdevmode){
201 throw new NotImplementedException ();
204 public override string ToString(){
205 string ret = "[PageSettings: Color={0}";
206 ret += ", Landscape={1}";
207 ret += ", Margins={2}";
208 ret += ", PaperSize={3}";
209 ret += ", PaperSource={4}";
210 ret += ", PrinterResolution={5}";
213 return String.Format(ret, this.Color, this.Landscape, this.Margins, this.PaperSize, this.PaperSource, this.PrinterResolution);