Pārlūkot izejas kodu

2007-02-16 Andreia Gaita <[email protected]>

Redesign how and when cups gets called to minimize
p/invokes, implements caching of printers and printer
settings as per calberto's patch - #79822, plotter detection, 
duplex, fixes for image disposing, code modularization, 
misc. fixes.

svn path=/trunk/mcs/; revision=73048
Andreia Gaita 19 gadi atpakaļ
vecāks
revīzija
7dda136e2b

+ 55 - 0
mcs/class/System.Drawing/System.Drawing.Printing/ChangeLog

@@ -1,3 +1,58 @@
+2007-02-16  Andreia Gaita  <[email protected]>
+
+	Redesign how and when cups gets called to minimize
+	p/invokes, implements caching of printers and printer
+	settings as per calberto's patch - #79822, plotter detection, 
+	duplex, fixes for image disposing, code modularization, 
+	misc. fixes.
+	
+	* PageSettings.cs: Check and ignore null setter values on
+	paper sizes, sources and resolutions.
+	
+	* PaperSize.cs: Add default paper size flag
+	
+	* PaperSource.cs: Add default paper source flag, minor code
+	beautification
+	
+	* PrinterSettings.cs: Add duplex and plotter implementation, 
+	modify calls to PrintingServices to support caching, add
+	a printer capabilities list to store specific printer options - 
+	only loaded with cups, for now. Move the internal list classes
+	to the end of the code so as not to clutter.
+	
+	* PrintingServices.cs: Separate the PrintingServices class in 2 - 
+	PrintingServices and GlobalPrintingServices (see calberto's patch
+	in #79822). The PrintingServices class is where all the methods
+	caching information reside, the GlobalPrintingServices methods do 
+	no caching.
+	The cached information resides on the Printer class, added to the 
+	SysPrn class.
+	
+	* PrintingServicesUnix.cs: Big rewrite. 
+	- Essentially, redesigned and modularized the code to minimize cups 
+	calls. Then, applied the caching so all the cups calls are reduced 
+	to a minimum, by loading a list of printers onto a hashtable, then 
+	loading the settings of the chosen printer and saving that in the 
+	hashtable all in one go.
+	- Also, fixes for loading	the proper default values of the printer, 
+	which are stored in it's global options;
+	- Modularization of cups/ppd loading methods (LoadPrinterOptions, 
+	LoadOptionList, OpenPrinter, ClosePrinter) so we don't repeat 
+	cups/ppd loading loops everywhere. 
+	- Proper disposing of pointers and structures, calling the proper
+	cups free calls.
+	- Add duplex support
+	
+	* PrintingServicesWin32.cs: IsPrinterValid is no longer caching the value,
+	since it should be supporting global caching as well, though that is not
+	yet complete on win32. Implements plotter detection support, and changes for
+	the new PrinterSettings/GlobalPrinterSettings structure. Some minor changes
+	the code to minimize p/invoke calls (load the printer sources and sizes 
+	before accessing the collections)
+	
+	* StandardPrintController.cs: PrinterSettings/GlobalPrinterSettings structure
+	changes
+
 2007-02-09  Sebastien Pouliot  <[email protected]>
 
 	* PrintingServicesUnix.cs: Ensure we free the original pointer in

+ 6 - 4
mcs/class/System.Drawing/System.Drawing.Printing/PageSettings.cs

@@ -77,7 +77,6 @@ namespace System.Drawing.Printing
 		internal PageSettings(PrinterSettings printerSettings, bool color, bool landscape, PaperSize paperSize, PaperSource paperSource, PrinterResolution printerResolution)
 		{
 			PrinterSettings = printerSettings;
-			
 			this.color = color;
 			this.landscape = landscape;
 			this.paperSize = paperSize;
@@ -144,7 +143,8 @@ namespace System.Drawing.Printing
 				return paperSize;
 			}
 			set{
-				paperSize = value;
+				if (value != null)
+					paperSize = value;
 			}
 		}
 		
@@ -155,7 +155,8 @@ namespace System.Drawing.Printing
 				return paperSource;
 			}
 			set{
-				paperSource = value;
+				if (value != null)
+					paperSource = value;
 			}
 		}
 		
@@ -166,7 +167,8 @@ namespace System.Drawing.Printing
 				return printerResolution;
 			}
 			set{
-				printerResolution = value;
+				if (value != null)
+					printerResolution = value;
 			}
 		}
 		

+ 20 - 2
mcs/class/System.Drawing/System.Drawing.Printing/PaperSize.cs

@@ -46,6 +46,8 @@ namespace System.Drawing.Printing
 		int width;
 		int height;
 		PaperKind kind;
+		internal bool is_default;
+		
 #if NET_2_0
 		public PaperSize ()
 		{
@@ -58,7 +60,16 @@ namespace System.Drawing.Printing
 			this.height = height;
 			this.name = name;
 			this.kind = PaperKind.Custom;
-		}		
+		}
+
+		internal PaperSize(string name, int width, int height, PaperKind kind, bool isDefault)
+		{
+			this.width = width;
+			this.height = height;
+			this.name = name;
+			this.kind = PaperKind.Custom;
+			this.is_default = isDefault;
+		}
 
 		public int Width{
 			get{
@@ -97,7 +108,6 @@ namespace System.Drawing.Printing
 				return kind;
 			}
 		}
-		internal void SetKind (PaperKind k) {kind = k;}
 #if NET_2_0
 		[MonoTODO]
 		public int RawKind {
@@ -106,6 +116,14 @@ namespace System.Drawing.Printing
 		}
 
 #endif
+	
+		internal bool IsDefault {
+			get { return this.is_default; }
+			set { this.is_default = value; }
+		}
+
+
+		internal void SetKind (PaperKind k) {kind = k;}
 
 		public override string ToString(){
 			string ret = "[PaperSize {0} Kind={1} Height={2} Width={3}]";

+ 23 - 10
mcs/class/System.Drawing/System.Drawing.Printing/PaperSource.cs

@@ -42,8 +42,9 @@ namespace System.Drawing.Printing
 #endif	
 	public class PaperSource
 	{
-		PaperSourceKind _Kind;
-		string _SourceName;
+		private PaperSourceKind kind;
+		private string source_name;
+		internal bool is_default;
 		
 #if NET_2_0
 		public PaperSource ()
@@ -51,30 +52,36 @@ namespace System.Drawing.Printing
 			
 		}
 #endif
-		// NOTE:how to construct this class?
-		// I have added a constructor, but I am not sure of me...
+
 		internal PaperSource(string sourceName, PaperSourceKind kind)
 		{
-			_SourceName = sourceName;
-			_Kind = kind;
+			this.source_name = sourceName;
+			this.kind = kind;
+		}
+
+		internal PaperSource(string sourceName, PaperSourceKind kind, bool isDefault)
+		{
+			this.source_name = sourceName;
+			this.kind = kind;
+			this.is_default = IsDefault;
 		}
 
 		public PaperSourceKind Kind{
 			get {
-				return _Kind; 
+				return this.kind; 
 			}
 		}
 		public string SourceName{
 			get {
-				return _SourceName;
+				return this.source_name;
 			}
 #if NET_2_0
 		set {
-				_SourceName = value;
+				this.source_name = value;
 			}
 #endif
 		}
-
+		
 #if NET_2_0
 		[MonoTODO]
 		public int RawKind {
@@ -87,9 +94,15 @@ namespace System.Drawing.Printing
 		}		  
 #endif
 
+		internal bool IsDefault {
+			get { return is_default;}
+			set { is_default = value;}
+		}
+
 		public override string ToString(){
 			string ret = "[PaperSource {0} Kind={1}]";
 			return String.Format(ret, this.SourceName, this.Kind);
 		}
+		
 	}
 }

+ 231 - 213
mcs/class/System.Drawing/System.Drawing.Printing/PrinterSettings.cs

@@ -31,6 +31,7 @@
 
 using System.Runtime.InteropServices;
 using System.Collections;
+using System.Collections.Specialized;
 using System.ComponentModel;
 using System.Drawing.Imaging;
 
@@ -60,17 +61,22 @@ namespace System.Drawing.Printing
 		internal PrinterSettings.PaperSizeCollection paper_sizes;
 		internal PrinterSettings.PaperSourceCollection paper_sources;
 		private PageSettings default_pagesettings;
+		private Duplex duplex;
+		internal bool is_plotter;
+		private PrintingServices printing_services;
 		
-		public PrinterSettings() : this (SysPrn.Service.DefaultPrinter)
+		internal NameValueCollection printer_capabilities; // this stores a list of all the printer options. Used only in cups, but might come in handy on win too.
+		public PrinterSettings() : this (SysPrn.CreatePrintingService ())
 		{			
 			print_tofile = false;
 		}
 		
-		internal PrinterSettings (string printer)
-		{						
-			printer_name = printer;			
+		internal PrinterSettings (PrintingServices printing_services)
+		{
+			this.printing_services = printing_services;
+			printer_name = printing_services.DefaultPrinter;
 			ResetToDefaults ();
-			SysPrn.Service.LoadPrinterSettings (printer_name, this);			
+			printing_services.LoadPrinterSettings (printer_name, this);
 		}
 		
 		private void ResetToDefaults ()
@@ -81,190 +87,9 @@ namespace System.Drawing.Printing
 			default_pagesettings = null;
 			maximum_page = 9999; 	
 			copies = 1;
+			collate = true;
 		}
-
-		// Public subclasses
-
-		public class PaperSourceCollection : ICollection, IEnumerable
-		{
-			ArrayList _PaperSources = new ArrayList();
-			
-			public PaperSourceCollection(PaperSource[] array) {
-				foreach (PaperSource ps in array)
-					_PaperSources.Add(ps);
-			}
-			
-			public int Count { get { return _PaperSources.Count; } }
-			int ICollection.Count { get { return _PaperSources.Count; } }
-			bool ICollection.IsSynchronized { get { return false; } }
-			object ICollection.SyncRoot { get { return this; } }			
-#if NET_2_0
-			[EditorBrowsable(EditorBrowsableState.Never)]
-      			public int Add (PaperSource paperSource) {return _PaperSources.Add (paperSource); }
-			public void CopyTo (PaperSource[] paperSources, int index)  {throw new NotImplementedException (); }
-#else
-			internal int Add (PaperSource paperSource) {return _PaperSources.Add (paperSource); }
-#endif
-			
-			public virtual PaperSource this[int index] {
-				get { return _PaperSources[index] as PaperSource; }
-			}
-			
-			IEnumerator IEnumerable.GetEnumerator()
-			{
-				return _PaperSources.GetEnumerator();
-			}
-			
-			public IEnumerator GetEnumerator()
-			{
-				return _PaperSources.GetEnumerator();
-			}
-			
-			void ICollection.CopyTo(Array array, int index)
-			{
-				_PaperSources.CopyTo(array, index);
-			}
-			
-			internal void Clear ()
-			{ 
-				_PaperSources.Clear (); 
-			}
-			
-		}
-
-		public class PaperSizeCollection : ICollection, IEnumerable
-		{
-			ArrayList _PaperSizes = new ArrayList();
-			
-			public PaperSizeCollection(PaperSize[] array) {
-				foreach (PaperSize ps in array)
-					_PaperSizes.Add(ps);
-			}
-			
-			public int Count { get { return _PaperSizes.Count; } }
-			int ICollection.Count { get { return _PaperSizes.Count; } }
-			bool ICollection.IsSynchronized { get { return false; } }
-			object ICollection.SyncRoot { get { return this; } }			
-#if NET_2_0		
-			[EditorBrowsable(EditorBrowsableState.Never)]
-			public int Add (PaperSize paperSize) {return _PaperSizes.Add (paperSize); }	
-			public void CopyTo (PaperSize[] paperSizes, int index) {throw new NotImplementedException (); }			
-#else
-			internal int Add (PaperSize paperSize) {return _PaperSizes.Add (paperSize); }	
-#endif
-			
-			public virtual PaperSize this[int index] {
-				get { return _PaperSizes[index] as PaperSize; }
-			}
-			
-			IEnumerator IEnumerable.GetEnumerator()
-			{
-				return _PaperSizes.GetEnumerator();
-			}
-			
-			public IEnumerator GetEnumerator()
-			{
-				return _PaperSizes.GetEnumerator();
-			}
-			
-			void ICollection.CopyTo(Array array, int index)
-			{
-				_PaperSizes.CopyTo(array, index);
-			}
-			
-			internal void Clear ()
-			{ 
-				_PaperSizes.Clear (); 
-			}
-		}
-
-		public class PrinterResolutionCollection : ICollection, IEnumerable
-		{
-			ArrayList _PrinterResolutions = new ArrayList();
-			
-			public PrinterResolutionCollection(PrinterResolution[] array) {
-				foreach (PrinterResolution pr in array)
-					_PrinterResolutions.Add(pr);
-			}
-			
-			public int Count { get { return _PrinterResolutions.Count; } }
-			int ICollection.Count { get { return _PrinterResolutions.Count; } }
-			bool ICollection.IsSynchronized { get { return false; } }
-			object ICollection.SyncRoot { get { return this; } }			
-#if NET_2_0
-			[EditorBrowsable(EditorBrowsableState.Never)]
-			public int Add (PrinterResolution printerResolution) { return _PrinterResolutions.Add (printerResolution); }
-			public void CopyTo (PrinterResolution[] printerResolutions, int index) {throw new NotImplementedException (); }
-#else
-			internal int Add (PrinterResolution printerResolution) { return _PrinterResolutions.Add (printerResolution); }
-#endif
-						
-			public virtual PrinterResolution this[int index] {
-				get { return _PrinterResolutions[index] as PrinterResolution; }
-			}
-			
-			IEnumerator IEnumerable.GetEnumerator()
-			{
-				return _PrinterResolutions.GetEnumerator();
-			}
-			
-			public IEnumerator GetEnumerator()
-			{
-				return _PrinterResolutions.GetEnumerator();
-			}
-			
-			void ICollection.CopyTo(Array array, int index)
-			{
-				_PrinterResolutions.CopyTo(array, index);
-			}
-			
-			internal void Clear ()
-			{ 
-				_PrinterResolutions.Clear (); 
-			}
-		}
-
-		public class StringCollection : ICollection, IEnumerable
-		{
-			ArrayList _Strings = new ArrayList();
-			
-			public StringCollection(string[] array) {
-				foreach (string s in array)
-					_Strings.Add(s);
-			}
-			
-			public int Count { get { return _Strings.Count; } }
-			int ICollection.Count { get { return _Strings.Count; } }
-			bool ICollection.IsSynchronized { get { return false; } }
-			object ICollection.SyncRoot { get { return this; } }
-						
-			public virtual string this[int index] {
-				get { return _Strings[index] as string; }
-			}
-#if NET_2_0
-			[EditorBrowsable(EditorBrowsableState.Never)]
-      			public int Add (string value) { return _Strings.Add (value); }
-      			public void CopyTo (string[] strings, int index) {throw new NotImplementedException (); }      			
-#else
-			internal int Add (string value) { return _Strings.Add (value); }
-#endif
-
-			IEnumerator IEnumerable.GetEnumerator()
-			{
-				return _Strings.GetEnumerator();
-			}
-			
-			public IEnumerator GetEnumerator()
-			{
-				return _Strings.GetEnumerator();
-			}
-			
-			void ICollection.CopyTo(Array array, int index)
-			{
-				_Strings.CopyTo(array, index);
-			}			
-		}
-		
+	
 		//properties
 		
 		public bool CanDuplex
@@ -298,7 +123,7 @@ namespace System.Drawing.Printing
 						false,	
 						// Real defaults are set by LoadPrinterSettings				
 						new PaperSize("A4", 827, 1169),						
-						new PaperSource("default", PaperSourceKind.FormSource),						
+						new PaperSource("Tray", PaperSourceKind.FormSource),						
 						new PrinterResolution(200, 200, PrinterResolutionKind.Medium));
 				}
 				
@@ -306,11 +131,10 @@ namespace System.Drawing.Printing
 			}
 		}
 
-		[MonoTODO("PrinterSettings.Duplex")]
 		public Duplex Duplex
 		{
-			get { throw new NotImplementedException(); }
-			set { throw new NotImplementedException(); }
+			get { return this.duplex; }
+			set { this.duplex = value; }
 		}
 		
 		public int FromPage
@@ -326,23 +150,22 @@ namespace System.Drawing.Printing
 		
 		public static PrinterSettings.StringCollection InstalledPrinters
 		{
-			get { return SysPrn.Service.InstalledPrinters; }
+			get { return SysPrn.GlobalService.InstalledPrinters; }
 		}
 	
 		public bool IsDefaultPrinter
 		{
-			get { return (printer_name == SysPrn.Service.DefaultPrinter); }
+			get { return (printer_name == printing_services.DefaultPrinter); }
 		}
 
-		[MonoTODO("PrinterSettings.IsPlotter")]
 		public bool IsPlotter
 		{
-			get { return false; }
+			get { return is_plotter; }
 		}
 
 		public bool IsValid
 		{
-			get { return SysPrn.Service.IsPrinterValid(this.printer_name, false); }
+			get { return printing_services.IsPrinterValid (this.printer_name); }
 		}
 		
 		public int LandscapeAngle
@@ -383,10 +206,7 @@ namespace System.Drawing.Printing
 			get {
 				if (!this.IsValid)
 					throw new InvalidPrinterException(this);
-				if (paper_sizes == null) {
-					paper_sizes = new PrinterSettings.PaperSizeCollection (new PaperSize [] {});
-					SysPrn.Service.LoadPrinterPaperSizes (printer_name, this);
-				}				
+
 				return paper_sizes;				
 			}
 		}
@@ -396,10 +216,7 @@ namespace System.Drawing.Printing
 			get {
 				if (!this.IsValid)
 					throw new InvalidPrinterException(this);
-				if (paper_sources == null) {
-					paper_sources = new PrinterSettings.PaperSourceCollection (new PaperSource [] {});
-					SysPrn.Service.LoadPrinterPaperSources (printer_name, this);
-				}
+
 				return paper_sources;
 			}
 		}
@@ -421,7 +238,7 @@ namespace System.Drawing.Printing
 					return;
 					
 				printer_name = value;
-				SysPrn.Service.LoadPrinterSettings (printer_name, this);
+				printing_services.LoadPrinterSettings (printer_name, this);
 			}
 		}
 		
@@ -430,10 +247,12 @@ namespace System.Drawing.Printing
 			get {
 				if (!this.IsValid)
 					throw new InvalidPrinterException(this);
+					
 				if (printer_resolutions == null) {
 					printer_resolutions = new PrinterSettings.PrinterResolutionCollection (new PrinterResolution[] {});
-					SysPrn.Service.LoadPrinterResolutions (printer_name, this);
+					printing_services.LoadPrinterResolutions (printer_name, this);
 				}
+				
 				return printer_resolutions;
 			}
 		}
@@ -471,11 +290,19 @@ namespace System.Drawing.Printing
 				to_page = value;
 			}		
 		}
+		
+		internal NameValueCollection PrinterCapabilities {
+			get { 
+				if (this.printer_capabilities == null)
+					this.printer_capabilities = new NameValueCollection();
+				return this.printer_capabilities;
+			}
+		}
 
 		//methods		
 		public object Clone ()
 		{
-			PrinterSettings ps = new PrinterSettings (printer_name);
+			PrinterSettings ps = new PrinterSettings (printing_services);
 			return ps;
 		}
 
@@ -497,7 +324,7 @@ namespace System.Drawing.Printing
 			throw new NotImplementedException();
 		}
 		
-		[MonoTODO("PrinterSettings.CreateMeasurementGraphics")]
+		[MonoTODO("PrinterSettings.CreateMeasurementGraphics")]
 		public Graphics CreateMeasurementGraphics (PageSettings pageSettings, bool honorOriginAtMargins)		
 		{
 			throw new NotImplementedException();
@@ -530,11 +357,11 @@ namespace System.Drawing.Printing
 			throw new NotImplementedException();
 		}
 		
-		[MonoTODO("IsDirectPrintingSupported")]
+		[MonoTODO("IsDirectPrintingSupported")]
 		public bool IsDirectPrintingSupported (ImageFormat imageFormat)
 		{
 			throw new NotImplementedException();
-		}
+		}
 #endif
 
 		[MonoTODO("PrinterSettings.SetHdevmode")]
@@ -553,8 +380,199 @@ namespace System.Drawing.Printing
 		{
 			return "Printer [PrinterSettings " + printer_name + " Copies=" + copies +  " Collate=" + collate 
 			+ " Duplex=" + can_duplex + " FromPage=" + from_page + " LandscapeAngle=" + landscape_angle 
-			+ " MaximumCopies=" + maximum_copies + " OutputPort=" + " ToPage=" + to_page + "]";
+			+ " MaximumCopies=" + maximum_copies + " OutputPort=" + " ToPage=" + to_page + "]";
+
+		}
+		
+		// Public subclasses
+		#region Public Subclasses
+		
+
+		public class PaperSourceCollection : ICollection, IEnumerable
+		{
+			ArrayList _PaperSources = new ArrayList();
+			
+			public PaperSourceCollection(PaperSource[] array) {
+				foreach (PaperSource ps in array)
+					_PaperSources.Add(ps);
+			}
+			
+			public int Count { get { return _PaperSources.Count; } }
+			int ICollection.Count { get { return _PaperSources.Count; } }
+			bool ICollection.IsSynchronized { get { return false; } }
+			object ICollection.SyncRoot { get { return this; } }			
+#if NET_2_0
+			[EditorBrowsable(EditorBrowsableState.Never)]
+      			public int Add (PaperSource paperSource) {return _PaperSources.Add (paperSource); }
+			public void CopyTo (PaperSource[] paperSources, int index)  {throw new NotImplementedException (); }
+#else
+			internal int Add (PaperSource paperSource) {return _PaperSources.Add (paperSource); }
+#endif
+			
+			public virtual PaperSource this[int index] {
+				get { return _PaperSources[index] as PaperSource; }
+			}
+			
+			IEnumerator IEnumerable.GetEnumerator()
+			{
+				return _PaperSources.GetEnumerator();
+			}
+			
+			public IEnumerator GetEnumerator()
+			{
+				return _PaperSources.GetEnumerator();
+			}
+			
+			void ICollection.CopyTo(Array array, int index)
+			{
+				_PaperSources.CopyTo(array, index);
+			}
+			
+			internal void Clear ()
+			{ 
+				_PaperSources.Clear (); 
+			}
+			
+		}
 
-		}		
+		public class PaperSizeCollection : ICollection, IEnumerable
+		{
+			ArrayList _PaperSizes = new ArrayList();
+			
+			public PaperSizeCollection(PaperSize[] array) {
+				foreach (PaperSize ps in array)
+					_PaperSizes.Add(ps);
+			}
+			
+			public int Count { get { return _PaperSizes.Count; } }
+			int ICollection.Count { get { return _PaperSizes.Count; } }
+			bool ICollection.IsSynchronized { get { return false; } }
+			object ICollection.SyncRoot { get { return this; } }			
+#if NET_2_0		
+			[EditorBrowsable(EditorBrowsableState.Never)]
+			public int Add (PaperSize paperSize) {return _PaperSizes.Add (paperSize); }	
+			public void CopyTo (PaperSize[] paperSizes, int index) {throw new NotImplementedException (); }			
+#else
+			internal int Add (PaperSize paperSize) {return _PaperSizes.Add (paperSize); }	
+#endif
+			
+			public virtual PaperSize this[int index] {
+				get { return _PaperSizes[index] as PaperSize; }
+			}
+			
+			IEnumerator IEnumerable.GetEnumerator()
+			{
+				return _PaperSizes.GetEnumerator();
+			}
+			
+			public IEnumerator GetEnumerator()
+			{
+				return _PaperSizes.GetEnumerator();
+			}
+			
+			void ICollection.CopyTo(Array array, int index)
+			{
+				_PaperSizes.CopyTo(array, index);
+			}
+			
+			internal void Clear ()
+			{ 
+				_PaperSizes.Clear (); 
+			}
+		}
+
+		public class PrinterResolutionCollection : ICollection, IEnumerable
+		{
+			ArrayList _PrinterResolutions = new ArrayList();
+			
+			public PrinterResolutionCollection(PrinterResolution[] array) {
+				foreach (PrinterResolution pr in array)
+					_PrinterResolutions.Add(pr);
+			}
+			
+			public int Count { get { return _PrinterResolutions.Count; } }
+			int ICollection.Count { get { return _PrinterResolutions.Count; } }
+			bool ICollection.IsSynchronized { get { return false; } }
+			object ICollection.SyncRoot { get { return this; } }			
+#if NET_2_0
+			[EditorBrowsable(EditorBrowsableState.Never)]
+			public int Add (PrinterResolution printerResolution) { return _PrinterResolutions.Add (printerResolution); }
+			public void CopyTo (PrinterResolution[] printerResolutions, int index) {throw new NotImplementedException (); }
+#else
+			internal int Add (PrinterResolution printerResolution) { return _PrinterResolutions.Add (printerResolution); }
+#endif
+						
+			public virtual PrinterResolution this[int index] {
+				get { return _PrinterResolutions[index] as PrinterResolution; }
+			}
+			
+			IEnumerator IEnumerable.GetEnumerator()
+			{
+				return _PrinterResolutions.GetEnumerator();
+			}
+			
+			public IEnumerator GetEnumerator()
+			{
+				return _PrinterResolutions.GetEnumerator();
+			}
+			
+			void ICollection.CopyTo(Array array, int index)
+			{
+				_PrinterResolutions.CopyTo(array, index);
+			}
+			
+			internal void Clear ()
+			{ 
+				_PrinterResolutions.Clear (); 
+			}
+		}
+
+		public class StringCollection : ICollection, IEnumerable
+		{
+			ArrayList _Strings = new ArrayList();
+			
+			public StringCollection(string[] array) {
+				foreach (string s in array)
+					_Strings.Add(s);
+			}
+			
+			public int Count { get { return _Strings.Count; } }
+			int ICollection.Count { get { return _Strings.Count; } }
+			bool ICollection.IsSynchronized { get { return false; } }
+			object ICollection.SyncRoot { get { return this; } }
+						
+			public virtual string this[int index] {
+				get { return _Strings[index] as string; }
+			}
+#if NET_2_0
+			[EditorBrowsable(EditorBrowsableState.Never)]
+      			public int Add (string value) { return _Strings.Add (value); }
+      			public void CopyTo (string[] strings, int index) {throw new NotImplementedException (); }      			
+#else
+			internal int Add (string value) { return _Strings.Add (value); }
+#endif
+
+			IEnumerator IEnumerable.GetEnumerator()
+			{
+				return _Strings.GetEnumerator();
+			}
+			
+			public IEnumerator GetEnumerator()
+			{
+				return _Strings.GetEnumerator();
+			}
+			
+			void ICollection.CopyTo(Array array, int index)
+			{
+				_Strings.CopyTo(array, index);
+			}			
+		}
+		
+		#endregion
+
+		void GetPrintDialogInfo (string printer_name, ref string port, ref string type, ref string status, ref string comment)
+		{
+			printing_services.GetPrintDialogInfo (printer_name, ref port, ref type, ref status, ref comment);
+		}
 	}
 }

+ 63 - 25
mcs/class/System.Drawing/System.Drawing.Printing/PrintingServices.cs

@@ -33,27 +33,23 @@ using System.Drawing.Imaging;
 
 namespace System.Drawing.Printing
 {
+	/// <summary>
+	/// This class is designed to cache the values retrieved by the 
+	/// native printing services, as opposed to GlobalPrintingServices, which
+	/// doesn't cache any values.
+	/// </summary>
 	internal abstract class PrintingServices
 	{
-		// Properties
-		internal abstract PrinterSettings.StringCollection InstalledPrinters { get; }
+		#region Properties
 		internal abstract string DefaultPrinter { get; }
-				
+		#endregion
 
-		// Methods
-		internal abstract bool StartDoc (GraphicsPrinter gr, string doc_name, string output_file);
-		internal abstract IntPtr CreateGraphicsContext (PrinterSettings settings, PageSettings page_settings);
-		internal abstract bool StartPage (GraphicsPrinter gr);
-		internal abstract bool EndPage (GraphicsPrinter gr);
-		internal abstract bool EndDoc (GraphicsPrinter gr);
-		
+		#region Methods
+		internal abstract bool IsPrinterValid(string printer);
 		internal abstract void LoadPrinterSettings (string printer, PrinterSettings settings);
 		internal abstract void LoadPrinterResolutions (string printer, PrinterSettings settings);
-		internal abstract void LoadPrinterPaperSizes (string printer, PrinterSettings settings);
-		internal abstract void LoadPrinterPaperSources (string printer, PrinterSettings settings);
-		internal abstract bool IsPrinterValid(string printer, bool force);
 
-		//Used from SWF
+		// Used from SWF
 		internal abstract void GetPrintDialogInfo (string printer, ref string port, ref string type, ref string status, ref string comment);
 		
 		internal void LoadDefaultResolutions (PrinterSettings.PrinterResolutionCollection col)
@@ -63,28 +59,70 @@ namespace System.Drawing.Printing
 			col.Add (new PrinterResolution ((int) PrinterResolutionKind.Low, -1, PrinterResolutionKind.Low));
 			col.Add (new PrinterResolution ((int) PrinterResolutionKind.Draft, -1, PrinterResolutionKind.Draft));
 		}
+		#endregion
+	}
+	
+	internal abstract class GlobalPrintingServices
+	{
+		#region Properties
+		internal abstract PrinterSettings.StringCollection InstalledPrinters { get; }
+		#endregion
+
+		#region Methods
+		internal abstract IntPtr CreateGraphicsContext (PrinterSettings settings, PageSettings page_settings);
+
+		internal abstract bool StartDoc (GraphicsPrinter gr, string doc_name, string output_file);
+		internal abstract bool StartPage (GraphicsPrinter gr);
+		internal abstract bool EndPage (GraphicsPrinter gr);
+		internal abstract bool EndDoc (GraphicsPrinter gr);
+		#endregion
+	
 	}
 
 	internal class SysPrn
 	{
-		static PrintingServices service;
+		static GlobalPrintingServices global_printing_services;
+		static bool is_unix;
 
 		static SysPrn ()
 		{
-			if (GDIPlus.RunningOnUnix ()) {
-				service = new  PrintingServicesUnix ();
-			} else {
-				service = new PrintingServicesWin32 ();
-			}
+			is_unix = GDIPlus.RunningOnUnix ();
 		}
+		
+		internal static PrintingServices CreatePrintingService () {
+			if (is_unix)
+				return new PrintingServicesUnix ();
+			return new PrintingServicesWin32 ();				
+		}			
 
-		static internal PrintingServices Service {
-			get { return service; }
+		internal static GlobalPrintingServices GlobalService {
+			get {
+				if (global_printing_services == null) {
+					if (is_unix)
+						global_printing_services = new GlobalPrintingServicesUnix ();
+					else
+						global_printing_services = new GlobalPrintingServicesWin32 ();
+				}
+
+				return global_printing_services;
+			}
 		}
 
-		internal static void GetPrintDialogInfo (string printer, ref string port, ref string type, ref string status, ref string comment)
-		{
-			service.GetPrintDialogInfo (printer, ref port, ref type, ref status, ref comment);
+		internal class Printer {
+			public readonly string Name;
+			public readonly string Comment;
+			public readonly string Port;
+			public readonly string Type;
+			public readonly string Status;
+			public PrinterSettings Settings;
+			public bool IsDefault;
+			
+			public Printer (string port, string type, string status, string comment) {
+				Port = port;
+				Type = type;
+				Status = status;
+				Comment = comment;
+			}
 		}
 	}
 	

Failā izmaiņas netiks attēlotas, jo tās ir par lielu
+ 551 - 339
mcs/class/System.Drawing/System.Drawing.Printing/PrintingServicesUnix.cs


+ 166 - 93
mcs/class/System.Drawing/System.Drawing.Printing/PrintingServicesWin32.cs

@@ -43,14 +43,11 @@ namespace System.Drawing.Printing
 
 		}
 
-		internal override bool IsPrinterValid(string printer, bool force)
+		internal override bool IsPrinterValid(string printer)
 		{
 			if (printer == null | printer == String.Empty)
 				return false;
 
-			if (!force && this.printer_name != null && String.Intern(this.printer_name).Equals(printer))
-				return is_printer_valid;
-
 			int ret = Win32DocumentProperties (IntPtr.Zero, IntPtr.Zero, printer, IntPtr.Zero, IntPtr.Zero, 0);
 			is_printer_valid = (ret > 0);
 			this.printer_name = printer; 
@@ -75,6 +72,12 @@ namespace System.Drawing.Printing
 			ret = Win32DeviceCapabilities (printer, null, DCCapabilities.DC_ORIENTATION, IntPtr.Zero, IntPtr.Zero);
 			if (ret != -1)
 				settings.landscape_angle = ret;
+			
+			IntPtr dc = IntPtr.Zero;
+			dc = Win32CreateIC (null, printer, null, IntPtr.Zero /* DEVMODE */);
+			ret = Win32GetDeviceCaps (dc, (int)DevCapabilities.TECHNOLOGY);
+			settings.is_plotter = ret == (int)PrinterType.DT_PLOTTER;
+			Win32DeleteDC (dc);
 
 			try {
 				Win32OpenPrinter (printer, out hPrn, IntPtr.Zero);
@@ -88,13 +91,15 @@ namespace System.Drawing.Printing
 
 				devmode = (DEVMODE) Marshal.PtrToStructure (ptr_dev, typeof(DEVMODE));
 
-	        		foreach (PaperSize paper_size in settings.PaperSizes) {
+				LoadPrinterPaperSizes (printer, settings);
+	        	foreach (PaperSize paper_size in settings.PaperSizes) {
 					if ((int) paper_size.Kind ==  devmode.dmPaperSize) {
 						settings.DefaultPageSettings.PaperSize = paper_size;
 						break;
 					}
 				}
 
+				LoadPrinterPaperSources (printer, settings);
 				foreach (PaperSource paper_source in settings.PaperSources) {
 					if ((int) paper_source.Kind ==  devmode.dmDefaultSource) {
 						settings.DefaultPageSettings.PaperSource = paper_source;
@@ -106,7 +111,7 @@ namespace System.Drawing.Printing
 	        		Win32ClosePrinter (hPrn);
 
 	        		if (ptr_dev != IntPtr.Zero)
-					Marshal.FreeHGlobal (ptr_dev);
+						Marshal.FreeHGlobal (ptr_dev);
 	        	}
 
 
@@ -140,7 +145,7 @@ namespace System.Drawing.Printing
 			Marshal.FreeHGlobal (buff);
 		}
 
-		internal override void LoadPrinterPaperSizes (string printer, PrinterSettings settings)
+		void LoadPrinterPaperSizes (string printer, PrinterSettings settings)
 		{
 			int items, ret;
 			IntPtr ptr_names, buff_names = IntPtr.Zero;
@@ -148,7 +153,11 @@ namespace System.Drawing.Printing
 			IntPtr ptr_sizes_enum, buff_sizes_enum = IntPtr.Zero;
 			string name;
 
-			settings.PaperSizes.Clear ();
+			if (settings.PaperSizes == null)
+				settings.paper_sizes = new PrinterSettings.PaperSizeCollection (new PaperSize [0]);
+			else
+				settings.PaperSizes.Clear ();
+
 			items = Win32DeviceCapabilities (printer, null, DCCapabilities.DC_PAPERSIZE, IntPtr.Zero, IntPtr.Zero);
 
 			if (items == -1)
@@ -202,7 +211,7 @@ namespace System.Drawing.Printing
 			}
 		}
 
-		internal override bool StartDoc (GraphicsPrinter gr, string doc_name, string output_file)
+		internal static bool StartDoc (GraphicsPrinter gr, string doc_name, string output_file)
 		{
 			DOCINFO di = new DOCINFO ();
 			int ret;
@@ -218,7 +227,7 @@ namespace System.Drawing.Printing
 			return (ret > 0) ? true : false;
 		}
 
-		internal override void LoadPrinterPaperSources (string printer, PrinterSettings settings)
+		void LoadPrinterPaperSources (string printer, PrinterSettings settings)
 		{
 			int items, ret;
 			IntPtr ptr_names, buff_names = IntPtr.Zero;
@@ -226,7 +235,11 @@ namespace System.Drawing.Printing
 			PaperSourceKind kind;
 			string name;
 
-			settings.PaperSources.Clear ();
+			if (settings.PaperSources == null)
+				settings.paper_sources = new PrinterSettings.PaperSourceCollection (new PaperSource [0]);
+			else
+				settings.PaperSources.Clear ();
+
 			items = Win32DeviceCapabilities (printer, null, DCCapabilities.DC_BINNAMES, IntPtr.Zero, IntPtr.Zero);
 
 			if (items == -1)
@@ -266,19 +279,19 @@ namespace System.Drawing.Printing
 
 		}
 
-		internal override bool StartPage (GraphicsPrinter gr)
+		internal static bool StartPage (GraphicsPrinter gr)
 		{
 			int ret = Win32StartPage (gr.Hdc);
 			return (ret > 0) ? true : false;
 		}
 
-		internal override bool EndPage (GraphicsPrinter gr)
+		internal static bool EndPage (GraphicsPrinter gr)
 		{
 			int ret = Win32EndPage (gr.Hdc);
 			return (ret > 0) ? true : false;
 		}
 
-		internal override bool EndDoc (GraphicsPrinter gr)
+		internal static bool EndDoc (GraphicsPrinter gr)
 		{
 			int ret = Win32EndDoc (gr.Hdc);
 			Win32DeleteDC (gr.Hdc);
@@ -286,7 +299,7 @@ namespace System.Drawing.Printing
 			return (ret > 0) ? true : false;
 		}
 
-		internal override IntPtr CreateGraphicsContext (PrinterSettings settings, PageSettings default_page_settings)
+		internal static IntPtr CreateGraphicsContext (PrinterSettings settings, PageSettings default_page_settings)
 		{
 			IntPtr dc = IntPtr.Zero;
 			dc = Win32CreateDC (null, settings.PrinterName, null, IntPtr.Zero /* DEVMODE */);
@@ -300,13 +313,13 @@ namespace System.Drawing.Printing
 				int length = name.Capacity;
 
 				if (Win32GetDefaultPrinter (name, ref length) > 0)
-					if (this.IsPrinterValid(name.ToString(), false))
+					if (IsPrinterValid(name.ToString()))
 						return name.ToString ();
 				return String.Empty;
 			}
 		}
 
-		internal override PrinterSettings.StringCollection InstalledPrinters {
+		internal static PrinterSettings.StringCollection InstalledPrinters {
 			get {
 				PrinterSettings.StringCollection col = new PrinterSettings.StringCollection (new string[] {});
 				PRINTER_INFO printer_info;
@@ -409,14 +422,14 @@ namespace System.Drawing.Printing
 		// DllImports
 		//
 
-		[DllImport("winspool.drv", CharSet=CharSet.Unicode, EntryPoint="OpenPrinter", SetLastError=true)]
+		[DllImport("winspool.drv", CharSet=CharSet.Unicode, EntryPoint="OpenPrinter", SetLastError=true)]
 		static extern int Win32OpenPrinter (string pPrinterName, out IntPtr phPrinter, IntPtr pDefault);
 
 		[DllImport("winspool.drv", CharSet=CharSet.Unicode, EntryPoint="GetPrinter", SetLastError=true)]
 		static extern int Win32GetPrinter (IntPtr hPrinter, int level, IntPtr dwBuf, int size, ref int dwNeeded);
 
 		[DllImport("winspool.drv", CharSet=CharSet.Unicode, EntryPoint="ClosePrinter", SetLastError=true)]
-		static extern int Win32ClosePrinter (IntPtr hPrinter);
+		static extern int Win32ClosePrinter (IntPtr hPrinter);
 
 		[DllImport("winspool.drv", CharSet=CharSet.Unicode, EntryPoint="DeviceCapabilities", SetLastError=true)]
 		static extern int Win32DeviceCapabilities (string device, string port, DCCapabilities cap, IntPtr outputBuffer, IntPtr deviceMode);
@@ -425,17 +438,21 @@ namespace System.Drawing.Printing
 		static extern int Win32EnumPrinters (int Flags, string Name, uint Level, IntPtr pPrinterEnum, uint cbBuf,
     			ref uint pcbNeeded, ref uint pcReturned);
 
-      		[DllImport("winspool.drv", EntryPoint="GetDefaultPrinter", CharSet=CharSet.Unicode, SetLastError=true)]
-      		private static extern int Win32GetDefaultPrinter (StringBuilder buffer, ref int bufferSize);
+      	[DllImport("winspool.drv", EntryPoint="GetDefaultPrinter", CharSet=CharSet.Unicode, SetLastError=true)]
+      	private static extern int Win32GetDefaultPrinter (StringBuilder buffer, ref int bufferSize);
 
-		[DllImport("winspool.drv", EntryPoint="DocumentProperties", CharSet=CharSet.Unicode, SetLastError=true)]
+		[DllImport("winspool.drv", EntryPoint="DocumentProperties", CharSet=CharSet.Unicode, SetLastError=true)]
 		private static extern int Win32DocumentProperties (IntPtr hwnd, IntPtr hPrinter, string pDeviceName,
 			IntPtr pDevModeOutput, IntPtr pDevModeInput, int fMode);
 
-    		[DllImport("gdi32.dll", EntryPoint="CreateDC")]
+    	[DllImport("gdi32.dll", EntryPoint="CreateDC")]
 		static extern IntPtr Win32CreateDC (string lpszDriver, string lpszDevice,
    			string lpszOutput, IntPtr lpInitData);
 
+    	[DllImport("gdi32.dll", EntryPoint="CreateIC")]
+		static extern IntPtr Win32CreateIC (string lpszDriver, string lpszDevice,
+   			string lpszOutput, IntPtr lpInitData);
+
    		[DllImport("gdi32.dll", CharSet=CharSet.Unicode, EntryPoint="StartDoc")]
 		static extern int Win32StartDoc (IntPtr hdc, [In] ref DOCINFO lpdi);
 
@@ -451,9 +468,12 @@ namespace System.Drawing.Printing
 		[DllImport("gdi32.dll", EntryPoint="DeleteDC")]
   		public static extern IntPtr Win32DeleteDC (IntPtr hDc);
 
-    		//
-    		// Structs
-    		//
+		[DllImport("gdi32.dll", EntryPoint="GetDeviceCaps")]
+  		public static extern int Win32GetDeviceCaps (IntPtr hDc, int index);
+
+		//
+		// Structs
+		//
 		[StructLayout (LayoutKind.Sequential)]
 		internal struct PRINTER_INFO
 		{
@@ -478,9 +498,9 @@ namespace System.Drawing.Printing
 			public uint	Status;
 			public uint	cJobs;
 			public uint	AveragePPM;
-    		}
+    	}
 
-    		[StructLayout (LayoutKind.Sequential)]
+    	[StructLayout (LayoutKind.Sequential)]
 		internal struct DOCINFO
 		{
   			public int     	cbSize;
@@ -490,47 +510,47 @@ namespace System.Drawing.Printing
   			public int	fwType;
   		}
 
-		[StructLayout(LayoutKind.Sequential, CharSet=CharSet.Unicode)]
-		internal struct DEVMODE
-		{
-			[MarshalAs(UnmanagedType.ByValTStr,SizeConst=32)]
-			public string	dmDeviceName;
-			public short	dmSpecVersion;
-			public short	dmDriverVersion;
-			public short	dmSize;
-			public short	dmDriverExtra;
-			public int	dmFields;
-
-			public short	dmOrientation;
-			public short	dmPaperSize;
-			public short	dmPaperLength;
-			public short	dmPaperWidth;
-
-			public short	dmScale;
-			public short	dmCopies;
-			public short	dmDefaultSource;
-			public short	dmPrintQuality;
-			public short	dmColor;
-			public short	dmDuplex;
-			public short	dmYResolution;
-			public short	dmTTOption;
-			public short	dmCollate;
-			[MarshalAs(UnmanagedType.ByValTStr, SizeConst = 32)]
-			public string	dmFormName;
-			public short	dmLogPixels;
-			public short	dmBitsPerPel;
-			public int	dmPelsWidth;
-			public int	dmPelsHeight;
-			public int	dmDisplayFlags;
-			public int	dmDisplayFrequency;
-			public int	dmICMMethod;
-			public int	dmICMIntent;
-			public int	dmMediaType;
-			public int	dmDitherType;
-			public int	dmReserved1;
-			public int	dmReserved2;
-			public int	dmPanningWidth;
-			public int	dmPanningHeight;
+		[StructLayout(LayoutKind.Sequential, CharSet=CharSet.Unicode)]
+		internal struct DEVMODE
+		{
+			[MarshalAs(UnmanagedType.ByValTStr,SizeConst=32)]
+			public string	dmDeviceName;
+			public short	dmSpecVersion;
+			public short	dmDriverVersion;
+			public short	dmSize;
+			public short	dmDriverExtra;
+			public int	dmFields;
+
+			public short	dmOrientation;
+			public short	dmPaperSize;
+			public short	dmPaperLength;
+			public short	dmPaperWidth;
+
+			public short	dmScale;
+			public short	dmCopies;
+			public short	dmDefaultSource;
+			public short	dmPrintQuality;
+			public short	dmColor;
+			public short	dmDuplex;
+			public short	dmYResolution;
+			public short	dmTTOption;
+			public short	dmCollate;
+			[MarshalAs(UnmanagedType.ByValTStr, SizeConst = 32)]
+			public string	dmFormName;
+			public short	dmLogPixels;
+			public short	dmBitsPerPel;
+			public int	dmPelsWidth;
+			public int	dmPelsHeight;
+			public int	dmDisplayFlags;
+			public int	dmDisplayFrequency;
+			public int	dmICMMethod;
+			public int	dmICMIntent;
+			public int	dmMediaType;
+			public int	dmDitherType;
+			public int	dmReserved1;
+			public int	dmReserved2;
+			public int	dmPanningWidth;
+			public int	dmPanningHeight;
 		}
 
   		// Enums
@@ -574,33 +594,86 @@ namespace System.Drawing.Printing
 		[Flags]
 		internal enum PrinterStatus : uint
 		{
-			PS_PAUSED =		0x00000001,
-			PS_ERROR = 		0x00000002,
-			PS_PENDING_DELETION =	0x00000004,
-			PS_PAPER_JAM = 		0x00000008,
-			PS_PAPER_OUT = 		0x00000010,
-			PS_MANUAL_FEED = 	0x00000020,
-			PS_PAPER_PROBLEM = 	0x00000040,
-			PS_OFFLINE = 		0x00000080,
-			PS_IO_ACTIVE = 		0x00000100,
-			PS_BUSY = 		0x00000200,
-			PS_PRINTING	= 	0x00000400,
-			PS_OUTPUT_BIN_FULL = 	0x00000800,
-			PS_NOT_AVAILABLE = 	0x00001000,
-			PS_WAITING = 		0x00002000,
-			PS_PROCESSING = 	0x00004000,
-			PS_INITIALIZING = 	0x00008000,
-			PS_WARMING_UP = 	0x00010000,
-			PS_TONER_LOW =		0x00020000,
-			PS_NO_TONER =		0x00040000,
-			PS_PAGE_PUNT = 		0x00080000,
-			PS_USER_INTERVENTION =	0x00100000,
-			PS_OUT_OF_MEMORY = 	0x00200000,
-			PS_DOOR_OPEN = 		0x00400000,
-			PS_SERVER_UNKNOWN = 	0x00800000,
+			PS_PAUSED =		0x00000001,
+			PS_ERROR = 		0x00000002,
+			PS_PENDING_DELETION =	0x00000004,
+			PS_PAPER_JAM = 		0x00000008,
+			PS_PAPER_OUT = 		0x00000010,
+			PS_MANUAL_FEED = 	0x00000020,
+			PS_PAPER_PROBLEM = 	0x00000040,
+			PS_OFFLINE = 		0x00000080,
+			PS_IO_ACTIVE = 		0x00000100,
+			PS_BUSY = 		0x00000200,
+			PS_PRINTING	= 	0x00000400,
+			PS_OUTPUT_BIN_FULL = 	0x00000800,
+			PS_NOT_AVAILABLE = 	0x00001000,
+			PS_WAITING = 		0x00002000,
+			PS_PROCESSING = 	0x00004000,
+			PS_INITIALIZING = 	0x00008000,
+			PS_WARMING_UP = 	0x00010000,
+			PS_TONER_LOW =		0x00020000,
+			PS_NO_TONER =		0x00040000,
+			PS_PAGE_PUNT = 		0x00080000,
+			PS_USER_INTERVENTION =	0x00100000,
+			PS_OUT_OF_MEMORY = 	0x00200000,
+			PS_DOOR_OPEN = 		0x00400000,
+			PS_SERVER_UNKNOWN = 	0x00800000,
 			PS_POWER_SAVE = 	0x01000000
  		}
+ 		
+ 		// for use in GetDeviceCaps
+		internal enum DevCapabilities
+		{
+			TECHNOLOGY	= 2,
+		}
+		
+		internal enum PrinterType
+		{
+			DT_PLOTTER		= 0, // Vector Plotter
+			DT_RASDIPLAY	= 1, // Raster Display
+			DT_RASPRINTER	= 2, // Raster printer
+			DT_RASCAMERA	= 3, // Raster camera
+			DT_CHARSTREAM	= 4, // Character-stream, PLP
+			DT_METAFILE		= 5, // Metafile, VDM
+			DT_DISPFILE		= 6, // Display-file
+		}
+
  	}
+
+	class GlobalPrintingServicesWin32 : GlobalPrintingServices
+	{
+		internal override PrinterSettings.StringCollection InstalledPrinters {
+			get {
+				return PrintingServicesWin32.InstalledPrinters;
+			}
+		}
+
+		internal override IntPtr CreateGraphicsContext (PrinterSettings settings, PageSettings default_page_settings)
+		{
+			return PrintingServicesWin32.CreateGraphicsContext (settings, default_page_settings);
+		}
+
+		internal override bool StartDoc (GraphicsPrinter gr, string doc_name, string output_file)
+		{
+			return PrintingServicesWin32.StartDoc (gr, doc_name, output_file);
+		}
+
+		internal override bool EndDoc (GraphicsPrinter gr)
+		{
+			return PrintingServicesWin32.EndDoc (gr);
+		}
+
+		internal override bool StartPage (GraphicsPrinter gr)
+		{
+			return PrintingServicesWin32.StartPage (gr);
+		}
+
+		internal override bool EndPage (GraphicsPrinter gr)
+		{
+			return PrintingServicesWin32.EndPage (gr);
+		}
+	}
 }
 
 
+

+ 5 - 5
mcs/class/System.Drawing/System.Drawing.Printing/StandardPrintController.cs

@@ -44,24 +44,24 @@ namespace System.Drawing.Printing
 		
 		public override void OnEndPage (PrintDocument document, PrintPageEventArgs e)
 		{
-			SysPrn.Service.EndPage (e.GraphicsContext);
+			SysPrn.GlobalService.EndPage (e.GraphicsContext);
 		}
 		
 		public override void OnStartPrint (PrintDocument document, PrintEventArgs e)
 		{			
-			IntPtr dc = SysPrn.Service.CreateGraphicsContext (document.PrinterSettings, document.DefaultPageSettings);
+			IntPtr dc = SysPrn.GlobalService.CreateGraphicsContext (document.PrinterSettings, document.DefaultPageSettings);
 			e.GraphicsContext = new GraphicsPrinter (null, dc);
-			SysPrn.Service.StartDoc (e.GraphicsContext, document.DocumentName, string.Empty);			
+			SysPrn.GlobalService.StartDoc (e.GraphicsContext, document.DocumentName, string.Empty);			
 		}
 		
 		public override void OnEndPrint (PrintDocument document, PrintEventArgs e)
 		{			
-			SysPrn.Service.EndDoc (e.GraphicsContext);
+			SysPrn.GlobalService.EndDoc (e.GraphicsContext);
 		}
 		
 		public override Graphics OnStartPage (PrintDocument document, PrintPageEventArgs e)
 		{				
-			SysPrn.Service.StartPage (e.GraphicsContext);
+			SysPrn.GlobalService.StartPage (e.GraphicsContext);
 			return e.Graphics;
 		}
 	}

Daži faili netika attēloti, jo izmaiņu fails ir pārāk liels