Exemplo n.º 1
0
        public PrintStatus_t StartPrint(PrintParams_t pparams)
        {
            try
            {
                if (m_worker != null && m_worker.IsBusy)
                {
                    m_worker.CancelAsync();
                    return(PrintStatus_t.PRINT_BUSY);
                }

                if (m_worker == null)
                {
                    Thread asyncThread = new Thread(PrintWorkThread);
                    asyncThread.SetApartmentState(ApartmentState.STA);
                    asyncThread.Start(pparams);

                    /*	m_worker = new BackgroundWorker();
                     *      m_worker.WorkerReportsProgress = true;
                     *      m_worker.WorkerSupportsCancellation = true;
                     *      m_worker.RunWorkerCompleted += new RunWorkerCompletedEventHandler(PrintCompleted);
                     *      m_worker.ProgressChanged += new ProgressChangedEventHandler(PrintProgressChanged);
                     *      m_worker.DoWork += new DoWorkEventHandler(PrintWork);*/
                }

                ////m_pparams = pparams;
                //m_worker.RunWorkerAsync(pparams);
                pparams.status = PrintStatus_t.PRINT_BUSY;
                return(PrintStatus_t.PRINT_READY);
            }
            catch (OutOfMemoryException e)
            {
                Console.WriteLine("Memory allocation failed during printing\n");
                return(PrintStatus_t.PRINT_ERROR);
            }
        }
Exemplo n.º 2
0
        private void PrintWork(object sender, DoWorkEventArgs e)
        {
            PrintParams_t    PParams = (PrintParams_t)e.Argument;
            BackgroundWorker worker  = sender as BackgroundWorker;

            Print(PParams);
        }
Exemplo n.º 3
0
        /* Main print entry point */
        private void Print(PrintParams_t pparams)
        {
            XpsDocumentWriter docwrite = GetDocWriter(pparams.queu);

            docwrite.WritingPrintTicketRequired +=
                new WritingPrintTicketRequiredEventHandler(PrintTicket);
            PrintPages(docwrite, pparams.fixdoc);
        }
Exemplo n.º 4
0
        /* Callback */
        private void PrintCompleted(object sender, RunWorkerCompletedEventArgs e)
        {
            PrintParams_t  Value;
            PrintEventArgs info;
            PrintParams_t  Params = (PrintParams_t)e.Result;

            if (e.Cancelled)
            {
                info = new PrintEventArgs(PrintStatus_t.PRINT_READY, PrintResult_t.PrintCANCELLED, 100);
            }
            else
            {
                Value = (PrintParams_t)e.Result;
                info  = new PrintEventArgs(PrintStatus_t.PRINT_READY, PrintResult_t.PrintCOMPLETED, 100);
            }
            PrintUpdateMain(this, info);
        }
Exemplo n.º 5
0
 /* Main print entry point */
 private void Print(PrintParams_t pparams)
 {
     XpsDocumentWriter docwrite = GetDocWriter(pparams.queu);
     docwrite.WritingPrintTicketRequired +=
         new WritingPrintTicketRequiredEventHandler(PrintTicket);
     PrintPages(docwrite, pparams.fixdoc);
 }
Exemplo n.º 6
0
        public PrintStatus_t StartPrint(PrintParams_t pparams)
        {
            try
            {
                if (m_worker != null && m_worker.IsBusy)
                {
                    m_worker.CancelAsync();
                    return PrintStatus_t.PRINT_BUSY;
                }

                if (m_worker == null)
                {

                    Thread asyncThread = new Thread(PrintWorkThread);
                    asyncThread.SetApartmentState(ApartmentState.STA);
                    asyncThread.Start(pparams);

                /*	m_worker = new BackgroundWorker();
                    m_worker.WorkerReportsProgress = true;
                    m_worker.WorkerSupportsCancellation = true;
                    m_worker.RunWorkerCompleted += new RunWorkerCompletedEventHandler(PrintCompleted);
                    m_worker.ProgressChanged += new ProgressChangedEventHandler(PrintProgressChanged);
                    m_worker.DoWork += new DoWorkEventHandler(PrintWork);*/
                }

                ////m_pparams = pparams;
                //m_worker.RunWorkerAsync(pparams);
                pparams.status = PrintStatus_t.PRINT_BUSY;
                return PrintStatus_t.PRINT_READY;
            }
            catch (OutOfMemoryException e)
            {
                Console.WriteLine("Memory allocation failed during printing\n");
                return PrintStatus_t.PRINT_ERROR;
            }
        }
Exemplo n.º 7
0
        public void PrintWorkThread(object data)
        {
            PrintParams_t PParams = (PrintParams_t)data;

            Print(PParams);
        }