コード例 #1
0
        private void BtnPrint_Click(object sender, RoutedEventArgs e)
        {
            //var filePath = System.IO.Directory.GetCurrentDirectory() + "\\data\\page\\" + pageName + "_学习工作页.pdf";
            //PrintDocument pd = new PrintDocument();
            //Process p = new Process();
            //ProcessStartInfo startInfo = new ProcessStartInfo();
            //startInfo.CreateNoWindow = true;
            //startInfo.WindowStyle = ProcessWindowStyle.Hidden;
            //startInfo.UseShellExecute = true;
            //startInfo.FileName = filePath;
            //startInfo.Verb = "print";
            //startInfo.Arguments = @"/p /h \" + filePath + "\"\"" + pd.PrinterSettings.PrinterName + "\"";
            //p.StartInfo = startInfo;
            //p.Start();
            //p.WaitForExit();

            MessageBox.Show("请先连接打印机。");
            return;

            BtnPrint.IsEnabled = false;
            PrintDialog  pdlg = new PrintDialog();
            FlowDocument doc  = PrintPreviewWindow.LoadDocumentAndRender("PageDocument.xaml", pageModel, new OrderDocumentRenderer());

            Dispatcher.BeginInvoke(new DoPrintMethod(DoPrint), DispatcherPriority.ApplicationIdle, pdlg, ((IDocumentPaginatorSource)doc).DocumentPaginator);
            m_timerToEnableButton = new Timer(TestTimerCallback, null, 3000, Timeout.Infinite);
        }
コード例 #2
0
        private void BtnPrintPreview_Click(object sender, RoutedEventArgs e)
        {
            PrintPreviewWindow previewWnd = new PrintPreviewWindow("PageDocument.xaml", pageModel, new OrderDocumentRenderer());

            previewWnd.Owner         = this;
            previewWnd.ShowInTaskbar = false;
            previewWnd.ShowDialog();
        }