private void butOK_Click(object sender, EventArgs e) { PrinterTrayItem tt; tt = new PrinterTrayItem(); tt.TrayName = cmbTray.SelectedItem.ToString(); tt.CurrentPapertypeName = cmbPapertype.SelectedItem.ToString(); this.PrinterTray = tt; DialogResult = DialogResult.OK; Close(); }
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); }
public ACA.LabelX.Toolbox.PrintGroupItem GetLabelPrintGroupByName(string sName) { GlobalDataStore.Logger.Debug("RemClientControlObject.GetLabelPrintGroupByName"); string AppPath = GlobalDataStore.AppPath; string RemotingConfigFilePath = AppPath + @"\ACALabelXClient.config.xml"; FileInfo fi; fi = new FileInfo(RemotingConfigFilePath); if (!fi.Exists) { throw new LabelXRemClientControlOjectException(string.Format("Remoting configuration file doesn't exist: {0}", RemotingConfigFilePath)); } // if (!File.Exists(RemotingConfigFilePath)) // throw new LabelXRemClientControlOjectException(string.Format("Remoting configuration file doesn't exist: {0}", RemotingConfigFilePath)); PrintGroupItem pgItem = null; lock (GlobalDataStore.LockClass) { XPathDocument theDoc; XPathNavigator nav; string sHelp; try { theDoc = new XPathDocument(RemotingConfigFilePath); } catch (System.Xml.XmlException e1) { ApplicationException e2; e2 = new ApplicationException(string.Format("XML syntax error in {0}: {1}", RemotingConfigFilePath, e1.Message), e1); throw e2; } nav = theDoc.CreateNavigator(); XPathNodeIterator nit; nit = nav.Select("/configuration/general-settings/print-groups/print-group[@name='" + sName + "']"); if (nit != null) { nit.MoveNext(); pgItem = new PrintGroupItem(); pgItem.GroupPrinters = new PrinterItems(); pgItem.Name = nit.Current.GetAttribute("name", string.Empty); pgItem.Enabled = nit.Current.GetAttribute("enabled", string.Empty).Equals("true", StringComparison.OrdinalIgnoreCase); nit = nav.Select("/configuration/general-settings/print-groups/print-group[@name='" + sName + "']/printer"); while (nit.MoveNext()) { PrinterItem pit; pit = new PrinterItem(); sHelp = nit.Current.GetAttribute("name", string.Empty); pit.LongName = sHelp; sHelp = nit.Current.GetAttribute("enabled", string.Empty); pit.Enabled = sHelp.Equals("true", StringComparison.OrdinalIgnoreCase); //Retrieve some other data for this printer... System.Printing.LocalPrintServer localServer; localServer = new System.Printing.LocalPrintServer(); System.Printing.PrintQueueCollection col; System.Printing.EnumeratedPrintQueueTypes[] myEnum = { EnumeratedPrintQueueTypes.Connections , EnumeratedPrintQueueTypes.Local }; col = localServer.GetPrintQueues(myEnum); System.Printing.PrintQueue theQueue = null; foreach (System.Printing.PrintQueue q in col) { if (q.FullName.Equals(pit.LongName, StringComparison.OrdinalIgnoreCase)) { theQueue = q; break; } } if (theQueue != null) { pit.QueueLength = theQueue.NumberOfJobs; pit.ShortName = theQueue.Name; pit.Online = !theQueue.IsOffline; pit.NeedsUserIntervention = theQueue.NeedUserIntervention; // //theQueue.NeedUserIntervention; } else { pit.QueueLength = 0; pit.NeedsUserIntervention = false; pit.ShortName = pit.LongName; pit.Online = true; } if (col != null) { col.Dispose(); col = null; } if (theQueue != null) { theQueue.Dispose(); theQueue = null; } if (nit.Current.HasChildren) { //nit.Current.MoveToFirstChild(); nit.Current.MoveToFirstChild(); //MoveToNext("tray", nav.LookupNamespace(nav.Prefix))) do { PrinterTrayItem ptit; ptit = new PrinterTrayItem(); ptit.TrayName = nit.Current.GetAttribute("name", string.Empty); ptit.CurrentPapertypeName = nit.Current.GetAttribute("papertype", string.Empty); pit.Trays.Add(ptit); } while (nit.Current.MoveToNext("tray", nav.LookupNamespace(nav.Prefix))); nit.Current.MoveToParent(); } //pit.CurrentPapertypeName = nit.Current.GetAttribute("papertype",string.Empty); //pit.Tray = nit.Current.GetAttribute("tray", string.Empty); pgItem.GroupPrinters.Add(pit); localServer.Dispose(); } } } return(pgItem); }
public PrinterTrayForm() { InitializeComponent(); pti = null; }