public PrintSlip(string printTemplate)
        {
            printServer                 = new System.Printing.LocalPrintServer();
            printerStatusTimer          = new System.Windows.Forms.Timer();
            printerStatusTimer.Interval = 2000;

            printerStatusTimer.Tick += new EventHandler(printerStatusTimer_Tick);
            this.xmlPrintTemplate    = printTemplate;
        }
        private PrintSlip()
        {
            //PrintTemplate = GetPrintTemplate();
            printServer                 = new System.Printing.LocalPrintServer();
            printerStatusTimer          = new System.Windows.Forms.Timer();
            printerStatusTimer.Interval = 2000;

            printerStatusTimer.Tick += new EventHandler(printerStatusTimer_Tick);
        }
        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);
        }
        private void ButtonUrineLabels_Click(object sender, RoutedEventArgs e)
        {
            System.Printing.PrintServer printServer = new System.Printing.LocalPrintServer();
            System.Printing.PrintQueue printQueue = printServer.GetPrintQueue(YellowstonePathology.Business.User.UserPreferenceInstance.Instance.UserPreference.ContainerLabelPrinter);

            YellowstonePathology.UI.Login.SerumLabel serumLabel = new Login.SerumLabel("Urine", "84166-26");
            System.Windows.Controls.PrintDialog printDialog = new System.Windows.Controls.PrintDialog();

            printDialog.PrintTicket.CopyCount = 50;
            printDialog.PrintTicket.PageMediaSize = new PageMediaSize(384, 96);
            printDialog.PrintQueue = printQueue;
            printDialog.PrintDocument(serumLabel.DocumentPaginator, "Urine Labels");
        }
        private void ButtonBarcodeTesting_Click(object sender, RoutedEventArgs e)
        {
            System.Printing.PrintServer printServer = new System.Printing.LocalPrintServer();
            System.Printing.PrintQueue printQueue = printServer.GetPrintQueue(YellowstonePathology.Business.User.UserPreferenceInstance.Instance.UserPreference.HistologySlideLabelPrinter);

            YellowstonePathology.Business.BarcodeScanning.HistologySlide slide = new YellowstonePathology.Business.BarcodeScanning.HistologySlide("12345678", "S11-17715", "1A4", "Pickles", "Mashed Potatoes", "Billings");
            HistologySlideLabelDocument histologySlideLabelDocument = new HistologySlideLabelDocument(slide, 4);
            histologySlideLabelDocument.Print(printQueue);
        }
        private void PrintRequisition_Click(object sender, RoutedEventArgs e)
        {
            System.Printing.PrintServer printServer = new System.Printing.LocalPrintServer();
            System.Printing.PrintQueue printQueue = printServer.GetPrintQueue(YellowstonePathology.Business.User.UserPreferenceInstance.Instance.UserPreference.RequisitionPrinter);

            Client.StandardRequisition requisitionHeader = new Client.StandardRequisition(983);
            requisitionHeader.Print(2, printQueue);
        }
示例#8
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());
            }
        }