コード例 #1
0
        /* Do the actual printing on a different thread. This is an STA
         * thread due to the UI like commands that the XPS document
         * processing performs.  */
        private void PrintXPS(String file, bool print_all, int from, int to,
                              bool istempfile)
        {
            Thread PrintThread = new Thread(MainWindow.PrintWork);

            PrintThread.SetApartmentState(ApartmentState.STA);

            var arguments = new List <object>();

            arguments.Add(file);
            arguments.Add(print_all);
            arguments.Add(from);
            arguments.Add(to);
            arguments.Add(m_printcontrol.m_selectedPrinter.FullName);
            arguments.Add(m_printcontrol);
            arguments.Add(istempfile);

            m_xpsprint              = new xpsprint();
            m_xpsprint.PrintUpdate += PrintProgress;
            arguments.Add(m_xpsprint);

            m_printstatus.xaml_PrintProgressText.Text       = "Printing...";
            m_printstatus.xaml_PrintProgressText.FontWeight = FontWeights.Bold;
            m_printstatus.xaml_PrintProgressGrid.Visibility = System.Windows.Visibility.Visible;
            m_printstatus.xaml_PrintProgress.Value          = 0;
            m_viewer_state = ViewerState_t.PRINTING;
            PrintThread.Start(arguments);
        }
コード例 #2
0
        /* The thread that is actually doing the print work */
        public static void PrintWork(object data)
        {
            List <object> genericlist  = data as List <object>;
            String        file         = (String)genericlist[0];
            bool          print_all    = (bool)genericlist[1];
            int           from         = (int)genericlist[2];
            int           to           = (int)genericlist[3];
            String        printer_name = (String)genericlist[4];
            Print         printcontrol = (Print)genericlist[5];
            bool          istempfile   = (bool)genericlist[6];
            xpsprint      xps_print    = (xpsprint)genericlist[7];
            String        filename     = "";

            if (istempfile == true)
            {
                filename = file;
            }

            /* We have to get our own copy of the print queue for the thread */
            LocalPrintServer m_printServer     = new LocalPrintServer();
            PrintQueue       m_selectedPrinter = m_printServer.GetPrintQueue(printer_name);

            XpsDocument xpsDocument = new XpsDocument(file, FileAccess.Read);

            xps_print.Print(m_selectedPrinter, xpsDocument, printcontrol, print_all,
                            from, to, filename, istempfile);

            /* Once we are done, go ahead and delete the file */
            if (istempfile == true)
            {
                xpsDocument.Close();
            }
            xps_print.Done();
        }
コード例 #3
0
ファイル: MainPrint.cs プロジェクト: wangtianyipsy/MiM_Matlab
        /* Do the actual printing on a different thread. This is an STA
         * thread due to the UI like commands that the XPS document
         * processing performs.  */
        private void PrintXPS(String file, bool print_all, int from, int to,
                              bool istempfile)
        {
            Thread PrintThread = new Thread(MainWindow.PrintWork);

            PrintThread.SetApartmentState(ApartmentState.STA);

            var arguments = new List <object>();

            arguments.Add(file);
            arguments.Add(print_all);
            arguments.Add(from);
            arguments.Add(to);
            arguments.Add(m_printcontrol.m_selectedPrinter.FullName);
            arguments.Add(m_printcontrol);
            arguments.Add(istempfile);

            m_xpsprint              = new xpsprint();
            m_xpsprint.PrintUpdate += PrintProgress;
            arguments.Add(m_xpsprint);

            xaml_PrintGrid.Visibility = System.Windows.Visibility.Visible;
            xaml_PrintProgress.Value  = 0;
            PrintThread.Start(arguments);
        }