public PrinterItems GetLocalPrintersEx() { PrinterItems retItems = new PrinterItems(); try { retItems = RemoteObject.GetLocalPrintersEx(); } catch (Exception ex) { throw new RemClientControlObjectProxyException("Call to printer service failed.", ex); } return(retItems); }
public PrinterItems GetLocalPrintersEx() { GlobalDataStore.Logger.Debug("RemClientControlObject.GetLocalPrintersEx"); PrinterItems retItems = new PrinterItems(); System.Printing.LocalPrintServer localServer; localServer = new System.Printing.LocalPrintServer(); System.Printing.EnumeratedPrintQueueTypes[] myEnum = { EnumeratedPrintQueueTypes.Connections , EnumeratedPrintQueueTypes.Local }; System.Printing.PrintQueueCollection col = localServer.GetPrintQueues(myEnum); foreach (System.Printing.PrintQueue qit in col) { PrinterItem it; it = new PrinterItem(); it.QueueLength = qit.NumberOfJobs; it.LongName = qit.FullName; it.ShortName = qit.Name; it.Enabled = true; it.Online = !qit.IsOffline; it.NeedsUserIntervention = qit.NeedUserIntervention; System.Drawing.Printing.PrinterSettings ps; ps = new System.Drawing.Printing.PrinterSettings(); ps.PrinterName = qit.FullName; foreach (System.Drawing.Printing.PaperSource src in ps.PaperSources) { PrinterTrayItem theTray; theTray = new PrinterTrayItem(); theTray.TrayName = src.SourceName; it.Trays.Add(theTray); } retItems.Add(it); } col.Dispose(); return(retItems); }