Exemplo n.º 1
0
        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);
        }
Exemplo n.º 2
0
        private void butPrintInfo_Click(object sender, EventArgs e)
        {
            System.Printing.LocalPrintServer theServer;
            theServer = new System.Printing.LocalPrintServer();
            System.Printing.EnumeratedPrintQueueTypes[] myEnum =
            {
                EnumeratedPrintQueueTypes.Connections
                , EnumeratedPrintQueueTypes.Local
            };
            System.Printing.PrintQueueCollection col = theServer.GetPrintQueues(myEnum);

            foreach (System.Printing.PrintQueue qit in col)
            {
                System.Diagnostics.Debug.WriteLine(qit.ClientPrintSchemaVersion);
                System.Diagnostics.Debug.WriteLine(qit.Comment);
                System.Diagnostics.Debug.WriteLine(qit.CurrentJobSettings.Description);
                System.Diagnostics.Debug.WriteLine(qit.Description);
                System.Diagnostics.Debug.WriteLine(qit.FullName);
                System.Printing.PrintCapabilities pc = qit.GetPrintCapabilities();
                System.Diagnostics.Debug.WriteLine(pc.InputBinCapability.ToString());
                System.Diagnostics.Debug.WriteLine(pc.MaxCopyCount);
                System.Diagnostics.Debug.WriteLine(pc.OrientedPageMediaHeight);
                System.Diagnostics.Debug.WriteLine(pc.OrientedPageMediaWidth);
                System.Diagnostics.Debug.WriteLine(pc.PageBorderlessCapability);
                System.Diagnostics.Debug.WriteLine(qit.QueueAttributes.ToString());
                System.Diagnostics.Debug.WriteLine(qit.ShareName);
                System.Diagnostics.Debug.WriteLine(qit.QueueDriver.PropertiesCollection.ToString());
                System.IO.MemoryStream str = qit.GetPrintCapabilitiesAsXml();
                System.IO.StreamReader tr  = new System.IO.StreamReader(str);
                String line;
                while ((line = tr.ReadLine()) != null)
                {
                    System.Diagnostics.Debug.WriteLine(line);
                }
                foreach (DictionaryEntry entry in qit.PropertiesCollection)
                {
                    PrintProperty prop;
                    prop = (PrintProperty)entry.Value;
                    if (prop.Value != null)
                    {
                        System.Diagnostics.Debug.WriteLine("Name " + prop.Name + " value " + prop.Value);
                    }
                }
            }
            //System.Drawing.Printing.PaperKind.A4;
            //System.Printing.PrintDriver;
            //System.Printing.PrintJobSettings;
            //System.Printing.PrintDocumentImageableArea;
            //System.Printing.PrintDriver;
            //System.Printing.PrintJobStatus;
            //System.Printing.PrintQueue;
            //System.Printing.PrintQueueStringProperty;
            //System.Drawing.Printing.PrinterSettings;
            System.Drawing.Printing.PrinterSettings ps;
            ps             = new System.Drawing.Printing.PrinterSettings();
            ps.PrinterName = cmbPrinters.Text;
            System.Drawing.Printing.PrinterSettings.PaperSizeCollection papers;
            papers = ps.PaperSizes;
            foreach (System.Drawing.Printing.PaperSize ps2 in papers)
            {
                System.Diagnostics.Debug.WriteLine(ps2.PaperName + " " + ps2.Kind.ToString() + " " + ps2.Height.ToString() + " " + ps2.Width.ToString());
            }
        }