public SettingsDialog()
        {
            System.Printing.LocalPrintServer printServer = new System.Printing.LocalPrintServer();
            this.m_PrintQueueCollection = printServer.GetPrintQueues(new[] { System.Printing.EnumeratedPrintQueueTypes.Local, System.Printing.EnumeratedPrintQueueTypes.Connections });

            InitializeComponent();
            this.DataContext = this;

            if (LocalSettings.AreLocalSettingsConfigured() == true)
            {
                this.m_LocalSettings              = LocalSettings.Instance;
                this.m_FormPropertiesAreEnabled   = true;
                this.PasswordBoxPassword.Password = this.m_LocalSettings.Password;

                if (string.IsNullOrEmpty(this.m_LocalSettings.QRCodeImage) == false)
                {
                    this.LoadQRCodeImage(this.m_LocalSettings.QRCodeImage);
                }
            }
            else
            {
                this.m_FormPropertiesAreEnabled = false;
            }

            this.NotifyPropertyChanged(string.Empty);
        }
        public UserPreferences(YellowstonePathology.Business.User.UserPreference userPreference)
        {
            this.m_UserPreferenceList             = YellowstonePathology.Business.Gateway.AccessionOrderGateway.GetAllUserPreferences();
            this.m_MolecularLabelFormatCollection = YellowstonePathology.Business.Label.Model.LabelFormatCollection.GetMolecularLabelCollection();
            this.m_CassettePrinterCollection      = new Business.Label.Model.CassettePrinterCollection();
            this.m_FacilityCollection             = Business.Facility.Model.FacilityCollection.Instance;

            System.Printing.LocalPrintServer printServer = new System.Printing.LocalPrintServer();
            this.m_PrintQueueCollection = printServer.GetPrintQueues(new[] { System.Printing.EnumeratedPrintQueueTypes.Local, System.Printing.EnumeratedPrintQueueTypes.Connections });

            this.m_ApplicationVersion = YellowstonePathology.Business.Persistence.DocumentGateway.Instance.GetApplicationVersion(this);

            InitializeComponent();

            if (userPreference == null)
            {
                this.m_UserPreference  = new Business.User.UserPreference();
                this.m_HostNameEnabled = true;
            }
            else
            {
                this.m_UserPreference  = YellowstonePathology.Business.Persistence.DocumentGateway.Instance.PullUserPreference(userPreference.HostName, this);
                this.m_HostNameEnabled = false;
            }

            this.m_PageScannerCollection = new Business.Common.PageScannerCollection();
            this.DataContext             = this;
            this.Loaded  += new RoutedEventHandler(UserPreferences_Loaded);
            this.Closing += UserPreferences_Closing;
        }
Example #3
0
        public Task PrintCanvasAsync(Canvas canvas, CancellationToken token = default(CancellationToken))
        {
            System.Windows.Controls.PrintDialog     printDialog      = new System.Windows.Controls.PrintDialog();
            System.Drawing.Printing.PrinterSettings printer          = new System.Drawing.Printing.PrinterSettings();
            System.Printing.LocalPrintServer        localPrintServer = new System.Printing.LocalPrintServer();

            System.Printing.PrintTicket pt = new System.Printing.PrintTicket();
            System.Printing.PrintQueue  pq = new System.Printing.PrintQueue(localPrintServer, printer.PrinterName, System.Printing.PrintSystemDesiredAccess.UsePrinter);

            System.Printing.PageMediaSize PMS      = new System.Printing.PageMediaSize(canvas.ActualWidth + 20, canvas.ActualHeight + 20);
            System.Windows.Size           pageSize = new System.Windows.Size(canvas.ActualWidth + 20, canvas.ActualHeight + 20);
            canvas.Arrange(new Rect(0, 0, pageSize.Width, pageSize.Height));
            canvas.Measure(pageSize);

            pt.PageMediaSize = PMS;
            pt.PageMediaType = System.Printing.PageMediaType.Unknown;

            pq.DefaultPrintTicket.PageMediaSize = PMS;
            pq.DefaultPrintTicket.PageMediaType = System.Printing.PageMediaType.Unknown;

            printDialog.PrintQueue  = pq;
            printDialog.PrintTicket = pt;
            //printDialog.PrintQueue.Commit();

            if (printDialog.ShowDialog() == true)
            {
                printDialog.PrintVisual(canvas, "Состояние холста");
            }
            return(Task.FromResult(0)); //Task.CompletedTask;
        }
 public void Print()
 {
     this.m_PrintDocument = new System.Drawing.Printing.PrintDocument();
     System.Printing.PrintServer printServer = new System.Printing.LocalPrintServer();
     System.Printing.PrintQueue printQueue = printServer.GetPrintQueue(YellowstonePathology.Business.User.UserPreferenceInstance.Instance.UserPreference.HistologySlideLabelPrinter);
     this.m_PrintDocument.PrinterSettings.PrinterName = printQueue.FullName;
     this.m_PrintDocument.PrintPage += new System.Drawing.Printing.PrintPageEventHandler(PrintDocument_PrintPage);
     this.m_PrintDocument.Print();
 }
Example #5
0
 public void Print()
 {
     this.m_PrintDocument = new System.Drawing.Printing.PrintDocument();
     System.Printing.PrintServer printServer = new System.Printing.LocalPrintServer();
     System.Printing.PrintQueue  printQueue  = printServer.GetPrintQueue(YellowstonePathology.Business.User.UserPreferenceInstance.Instance.UserPreference.HistologySlideLabelPrinter);
     this.m_PrintDocument.PrinterSettings.PrinterName = printQueue.FullName;
     this.m_PrintDocument.PrintPage += new System.Drawing.Printing.PrintPageEventHandler(PrintDocument_PrintPage);
     this.m_PrintDocument.Print();
 }
Example #6
0
        private void ButtonPrintTrackingDocument_Click(object sender, RoutedEventArgs e)
        {
            MaterialTrackingBatchSummary materialTrackingBatchSummary = new MaterialTrackingBatchSummary(this.m_MaterialTrackingBatch, this.m_MaterialTrackingLogViewCollection);

            System.Printing.PrintQueue          printQueue  = new System.Printing.LocalPrintServer().DefaultPrintQueue;
            System.Windows.Controls.PrintDialog printDialog = new System.Windows.Controls.PrintDialog();
            printDialog.PrintTicket.PageOrientation = System.Printing.PageOrientation.Portrait;
            printDialog.PrintQueue = printQueue;
            printDialog.PrintDocument(materialTrackingBatchSummary.FixedDocument.DocumentPaginator, "Material Tracking Batch Summary");
        }
Example #7
0
        public void Print()
        {
            System.Printing.PrintQueue printQueue = new System.Printing.LocalPrintServer().DefaultPrintQueue;

            System.Windows.Controls.PrintDialog printDialog = new System.Windows.Controls.PrintDialog();
            printDialog.PrintTicket.PageOrientation = System.Printing.PageOrientation.Portrait;
            printDialog.PrintQueue = printQueue;
            DocumentPaginator documentPaginator = ((IDocumentPaginatorSource)this).DocumentPaginator;
            printDialog.PrintDocument(documentPaginator, "PackingSlip");
        }
Example #8
0
 private void PrintTaskOrder(int copyCount)
 {
     Receiving.TaskOrderDataSheet        taskOrderDataSheet = new Receiving.TaskOrderDataSheet(this.m_TaskOrder, this.m_AccessionOrder);
     System.Printing.PrintQueue          printQueue         = new System.Printing.LocalPrintServer().DefaultPrintQueue;
     System.Windows.Controls.PrintDialog printDialog        = new System.Windows.Controls.PrintDialog();
     printDialog.PrintTicket.PageOrientation = System.Printing.PageOrientation.Portrait;
     printDialog.PrintTicket.CopyCount       = copyCount;
     printDialog.PrintQueue = printQueue;
     printDialog.PrintDocument(taskOrderDataSheet.FixedDocument.DocumentPaginator, "Task Order Data Sheet");
     MessageBox.Show("This task has been submitted to the printer.");
 }
Example #9
0
        public void AutoPrint(FlowDocument fd, string title, string caller)
        {
            var         local       = new System.Printing.LocalPrintServer();
            PrintDialog printDialog = new PrintDialog()
            {
                PrintQueue = new System.Printing.PrintQueue(new System.Printing.PrintServer(), "Microsoft Print to PDF")
            };

            printDialog.PrintQueue.AddJob("Report PDF", "Report.pdf", false);
            printDialog.PrintQueue.Commit();
        }
Example #10
0
        public void Print()
        {
            System.Printing.PrintQueue printQueue = new System.Printing.LocalPrintServer().DefaultPrintQueue;

            System.Windows.Controls.PrintDialog printDialog = new System.Windows.Controls.PrintDialog();
            printDialog.PrintTicket.PageOrientation = System.Printing.PageOrientation.Portrait;
            printDialog.PrintQueue = printQueue;
            DocumentPaginator documentPaginator = ((IDocumentPaginatorSource)this).DocumentPaginator;

            printDialog.PrintDocument(documentPaginator, "PackingSlip");
        }
        /// <summary>
        /// Печать.
        /// </summary>
        /// <param name="canvas"></param>
        /// <param name="description"></param>
        public void Print(Canvas canvas, string description)
        {
            if (canvas == null)
            {
                MessageBox.Show("Не заполнена область печати!");
                return;
            }
            if (canvas.Width < 100 || canvas.Height < 100)
            {
                MessageBox.Show("Область печати имеет недопустимый размер!");
                return;
            }

            //var children = canvas.Children.Cast<UIElement>().ToArray();
            var canvasPrint = GetCanvasCopy(canvas);

            // Получить PrintTicket по умолчанию с принтера.
            var localPrintServer = new System.Printing.LocalPrintServer();
            // Получение коллекции локального принтера на компьютере пользователя.
            var localPrinterCollection = localPrintServer.GetPrintQueues();

            System.Collections.IEnumerator localPrinterEnumerator = localPrinterCollection.GetEnumerator();
            if (localPrinterEnumerator.MoveNext())
            {
                // Получить PrintQueue с первого доступного принтера.
                var printQueue = (System.Printing.PrintQueue)localPrinterEnumerator.Current;
                // Получить PrintTicket по умолчанию с принтера.
                if (printQueue != null)
                {
                    var printTicket   = printQueue.DefaultPrintTicket;
                    var pageMediaSize = new System.Printing.PageMediaSize(canvasPrint.Width, canvasPrint.Height);
                    printTicket.PageMediaSize = pageMediaSize;
                    //printTicket.PageMediaType = System.Printing.PageMediaType.Unknown;
                    //var printCapabilites = printQueue.GetPrintCapabilities();
                    // Modify PrintTicket
                    //if (printCapabilites.CollationCapability.Contains(System.Printing.Collation.Collated))
                    //    printTicket.Collation = System.Printing.Collation.Collated;
                    //if (printCapabilites.DuplexingCapability.Contains(System.Printing.Duplexing.TwoSidedLongEdge))
                    //    printTicket.Duplexing = System.Printing.Duplexing.TwoSidedLongEdge;
                    //if (printCapabilites.StaplingCapability.Contains(System.Printing.Stapling.StapleDualLeft))
                    //    printTicket.Stapling = System.Printing.Stapling.StapleDualLeft;
                    var printDialog = new PrintDialog
                    {
                        //PrintQueue = printQueue,
                        PrintTicket = printTicket,
                    };
                    printDialog.PrintQueue.Commit();
                    if (printDialog.ShowDialog() == true)
                    {
                        printDialog.PrintVisual(canvasPrint, description);
                    }
                }
            }
        }
Example #12
0
        public void Print(FlowDocument fd, string title)
        {
            var         local    = new System.Printing.LocalPrintServer();
            PrintDialog printDlg = new PrintDialog()
            {
                PrintQueue = new System.Printing.PrintQueue(new System.Printing.PrintServer(), "Microsoft Print to PDF")
            };

            IDocumentPaginatorSource dps = fd;

            printDlg.PrintDocument(dps.DocumentPaginator, title);
        }
Example #13
0
        private void PrintPaperLabel(YellowstonePathology.Business.Slide.Model.SlideOrder slideOrder)
        {
            System.Windows.Controls.PrintDialog printDialog = new System.Windows.Controls.PrintDialog();
            System.Printing.PrintServer         printServer = new System.Printing.LocalPrintServer();

            System.Printing.PrintQueue printQueue = printServer.GetPrintQueue(YellowstonePathology.Business.User.UserPreferenceInstance.Instance.UserPreference.HistologySlideLabelPrinter);
            printDialog.PrintQueue = printQueue;

            YellowstonePathology.Business.Label.Model.HistologySlidePaperLabel histologySlidePaperLabel = new Business.Label.Model.HistologySlidePaperLabel(slideOrder.SlideOrderId,
                                                                                                                                                            slideOrder.ReportNo, slideOrder.Label, slideOrder.PatientLastName, slideOrder.TestAbbreviation, slideOrder.AccessioningFacility);
            YellowstonePathology.Business.Label.Model.HistologySlidePaperLabelPrinter histologySlidePaperLabelPrinter = new Business.Label.Model.HistologySlidePaperLabelPrinter();
            histologySlidePaperLabelPrinter.Queue.Enqueue(histologySlidePaperLabel);
            histologySlidePaperLabelPrinter.Print();
        }
Example #14
0
        private void ButtonTaskOrderPrint_Click(object sender, RoutedEventArgs e)
        {
            if (this.ListViewTaskOrders.SelectedItem != null)
            {
                YellowstonePathology.Business.Task.Model.TaskOrderView taskOrderView  = (YellowstonePathology.Business.Task.Model.TaskOrderView) this.ListViewTaskOrders.SelectedItem;
                YellowstonePathology.Business.Test.AccessionOrder      accessionOrder = YellowstonePathology.Business.Persistence.DocumentGateway.Instance.PullAccessionOrder(taskOrderView.TaskOrder.MasterAccessionNo, this.m_Writer);
                Login.Receiving.TaskOrderDataSheet taskOrderDataSheet = new Login.Receiving.TaskOrderDataSheet(taskOrderView.TaskOrder, accessionOrder);

                System.Printing.PrintQueue          printQueue  = new System.Printing.LocalPrintServer().DefaultPrintQueue;
                System.Windows.Controls.PrintDialog printDialog = new System.Windows.Controls.PrintDialog();
                printDialog.PrintTicket.PageOrientation = System.Printing.PageOrientation.Portrait;
                printDialog.PrintQueue = printQueue;
                printDialog.PrintDocument(taskOrderDataSheet.FixedDocument.DocumentPaginator, "Task Order Data Sheet");
            }
        }
Example #15
0
        public void Print(System.Windows.Controls.Image image)
        {
            System.Printing.LocalPrintServer localPrintServer = new System.Printing.LocalPrintServer();
            PrintDialog printDialog = new PrintDialog();

            System.Printing.PrintCapabilities capabilities = printDialog.PrintQueue.GetPrintCapabilities(printDialog.PrintTicket);
            double scale = Math.Min(capabilities.PageImageableArea.ExtentWidth / image.ActualWidth, capabilities.PageImageableArea.ExtentHeight / image.ActualHeight);

            image.LayoutTransform = new System.Windows.Media.ScaleTransform(scale, scale);
            System.Windows.Size sz = new System.Windows.Size(capabilities.PageImageableArea.ExtentWidth, capabilities.PageImageableArea.ExtentHeight);
            image.Measure(sz);
            image.Arrange(new System.Windows.Rect(new System.Windows.Point(capabilities.PageImageableArea.OriginWidth, capabilities.PageImageableArea.OriginHeight), sz));

            printDialog.PrintVisual(image, "Print Image");
        }
Example #16
0
        private void HyperLinkPrintLabel_Click(object sender, RoutedEventArgs e)
        {
            YellowstonePathology.Business.Test.PanelSetOrder panelSetOrder = this.m_AccessionOrder.PanelSetOrderCollection.GetPAP();
            YellowstonePathology.Business.OrderIdParser      orderIdParser = new Business.OrderIdParser(panelSetOrder.ReportNo);
            string dummyReportNo = (orderIdParser.ReportNoYear + 50).ToString() + "-" + orderIdParser.MasterAccessionNoNumber + "." + orderIdParser.ReportNoLetter;

            YellowstonePathology.UI.Login.CytologySlideLabelDocument cytologySlideLabelDocument = new Login.CytologySlideLabelDocument(dummyReportNo, this.m_AccessionOrder.PLastName, false);
            System.Windows.Controls.PrintDialog printDialog = new System.Windows.Controls.PrintDialog();

            System.Printing.PrintServer printServer = new System.Printing.LocalPrintServer();
            System.Printing.PrintQueue  printQueue  = printServer.GetPrintQueue(YellowstonePathology.Business.User.UserPreferenceInstance.Instance.UserPreference.CytologySlideLabelPrinter);

            printDialog.PrintQueue = printQueue;
            printDialog.PrintDocument(cytologySlideLabelDocument.DocumentPaginator, "Slide Labels");
        }
        private void ButtonPrint_Click(object sender, RoutedEventArgs e)
        {
            if (this.m_Copies > 0)
            {
                if (this.ComboBoxForm.SelectedItem != null)
                {
                    if (this.ComboBoxPrinter.SelectedItem != null)
                    {
                        System.Printing.PrintServer printServer = new System.Printing.LocalPrintServer();
                        System.Printing.PrintQueue  printQueue  = printServer.GetPrintQueue(YellowstonePathology.Business.User.UserPreferenceInstance.Instance.UserPreference.RequisitionPrinter);

                        ComboBoxItem comboBoxItem = (ComboBoxItem)this.ComboBoxForm.SelectedItem;
                        switch (comboBoxItem.Content.ToString())
                        {
                        case "Standard":
                            StandardRequisition standardRequisition = new StandardRequisition(this.m_ClientId);
                            standardRequisition.Print(this.m_Copies, printQueue);
                            break;

                        case "Cytology":
                            CytologyRequisition cytologyRequisition = new CytologyRequisition(this.m_ClientId);
                            cytologyRequisition.Print(this.m_Copies, printQueue);
                            break;

                        case "Oncology":
                            OncologyRequisition oncologyRequisition = new OncologyRequisition(this.m_ClientId);
                            oncologyRequisition.Print(this.m_Copies, printQueue);
                            break;

                        case "IHC/Molecular":
                            IHCMolecularRequisition ihcMolecularRequisition = new IHCMolecularRequisition(this.m_ClientId);
                            ihcMolecularRequisition.Print(this.m_Copies, printQueue);
                            break;
                        }
                        Close();
                    }
                    else
                    {
                        MessageBox.Show("You must select a printer.");
                    }
                }
                else
                {
                    MessageBox.Show("You must select a form type.");
                }
            }
        }
Example #18
0
        private void Button_Click(object sender, RoutedEventArgs e)
        {
            //9、点击出菜,打印机打印一条小票,显示桌号、备注信息、名称、份数、开台服务员名字。
            if (GridMenuComplete.SelectedItem != null)
            {
                MenuInfo mi = GridMenuComplete.SelectedItem as MenuInfo;
                if (mi.SelectedDesk != null)
                {
                    DXInfo.Restaurant.DeskManageFacade dmf = new DXInfo.Restaurant.DeskManageFacade();
                    dmf.CancelOutMenu(uow, mi.OrderMenuId, App.MyIdentity.oper.UserId, mi.SelectedDesk.DeskId);

                    List <SelInv> confirmmenu = new List <SelInv>();
                    SelInv        si          = new SelInv();
                    var           inv         = (from d in uow.Inventory.GetAll() where d.Id == mi.InventoryId select d).FirstOrDefault();
                    si.Category = inv.Category;
                    si.Amount   = mi.Price;
                    si.Quantity = 1;
                    si.Name     = mi.InvName;
                    si.Comment  = mi.Comment;
                    confirmmenu.Add(si);

                    var ctx = new
                    {
                        DeskNo     = mi.SelectedDesk.DeskCode + "(取消出菜)",
                        Sum        = mi.Price,
                        Count      = 1,
                        lSelInv    = confirmmenu,
                        CreateDate = DateTime.Now,
                        DeptName   = App.MyIdentity.dept.DeptName,
                    };
                    System.Printing.LocalPrintServer lp = new System.Printing.LocalPrintServer();
                    System.Printing.PrintQueue       pq = new System.Printing.PrintQueue(lp, inv.Printer);
                    DeskConfirmWindow dcw = new DeskConfirmWindow(ctx, pq);
                    if (dcw.ShowDialog().GetValueOrDefault())
                    {
                    }

                    MessageBox.Show(mi.SelectedDesk.DeskCode + "(" + mi.InvName + ")" + "取消出菜成功");
                    UpdateOrderMenuData();
                }
                else
                {
                    MessageBox.Show("请选中桌台号");
                }
            }
        }
Example #19
0
        public ReportPreview(System.Windows.Window wnd = null)
        {
            InitializeComponent();

            this.CRVIEWER.ShowCopyButton            = false;
            this.CRVIEWER.ShowExportButton          = false;
            this.CRVIEWER.ShowLogo                  = false;
            this.CRVIEWER.ShowOpenFileButton        = false;
            this.CRVIEWER.ShowPrintButton           = false;
            this.CRVIEWER.ShowRefreshButton         = false;
            this.CRVIEWER.ShowToggleSidePanelButton = false;
            this.CRVIEWER.ViewerCore.Zoom(75);
            this.CRVIEWER.ToggleSidePanel = SAPBusinessObjects.WPF.Viewer.Constants.SidePanelKind.None;

            if (wnd != null)
            {
                this.Top    = (int)wnd.Top;
                this.Left   = (int)wnd.Left;
                this.Height = (int)wnd.Height;
                this.Width  = (int)wnd.Width;
            }

            var plist = (NameValueCollection)ConfigurationManager.GetSection("previewSettings");

            if (plist != null)
            {
                if (plist["customize"] == "available")
                {
                    IsCustomizeAvailable = true;
                }
                LoadToolItemProperty(plist["customButton"], marginCustomButton, ref posCutomButton);
                LoadToolItemProperty(plist["closeButton"], marginCloseButton, ref posCloseButton);
            }
            SetupPrintButton(this.CRVIEWER);

            System.Printing.PrintQueue defaultPrinter = new System.Printing.LocalPrintServer().DefaultPrintQueue;
            this.defaultPrinterName = defaultPrinter.FullName;

            this.PrinterList = new List <string>();
            foreach (string pnm in System.Drawing.Printing.PrinterSettings.InstalledPrinters)
            {
                this.PrinterList.Add(pnm);
            }
        }
Example #20
0
        public UserPreferences()
        {
            this.m_MolecularLabelFormatCollection = YellowstonePathology.Business.Label.Model.LabelFormatCollection.GetMolecularLabelCollection();
            this.m_UserPreference = YellowstonePathology.Business.User.UserPreferenceInstance.Instance.UserPreference;

            this.m_FacilityCollection = Business.Facility.Model.FacilityCollection.GetAllFacilities();
            this.m_LocationCollection = new Business.Facility.Model.LocationCollection();

            System.Printing.LocalPrintServer printServer = new System.Printing.LocalPrintServer();
            this.m_PrintQueueCollection = printServer.GetPrintQueues(new[] { System.Printing.EnumeratedPrintQueueTypes.Local, System.Printing.EnumeratedPrintQueueTypes.Connections });

            this.m_ApplicationVersion = YellowstonePathology.Business.Persistence.DocumentGateway.Instance.GetApplicationVersion(this);

            InitializeComponent();

            this.DataContext = this;
            this.Loaded += new RoutedEventHandler(UserPreferences_Loaded);
            this.Closing += UserPreferences_Closing;
        }
        public static System.Printing.PrintQueue GetSlideLabelPrintQueue(string slideLabelPrinter)
        {
            System.Printing.PrintQueue printQueue = null;
            System.Printing.PrintServer printServer = null;

            switch (slideLabelPrinter)
            {
                case "Histology Slide Label Printer":
                    printServer = new System.Printing.LocalPrintServer();
                    printQueue = printServer.GetPrintQueue("Histology Slide Label Printer");
                    break;
                case "Cytology Slide Label Printer":
                    printServer = new System.Printing.PrintServer(@"\\YPIIHISTO03");
                    printQueue = printServer.GetPrintQueue("CytologySlideLabelPrinter");
                    break;
            }

            return printQueue;
        }
        private void ButtonPrintDataSheet_Click(object sender, RoutedEventArgs e)
        {
            if (this.m_AccessionOrder.PanelSetOrderCollection.Count > 0)
            {
                Business.Persistence.DocumentGateway.Instance.Save();
                YellowstonePathology.Document.Result.Data.AccessionOrderDataSheetData accessionOrderDataSheetData = YellowstonePathology.Business.Gateway.XmlGateway.GetAccessionOrderDataSheetData(this.m_AccessionOrder.MasterAccessionNo);
                YellowstonePathology.Document.Result.Xps.AccessionOrderDataSheet      accessionOrderDataSheet     = new Document.Result.Xps.AccessionOrderDataSheet(accessionOrderDataSheetData);
                System.Printing.PrintQueue printQueue = new System.Printing.LocalPrintServer().DefaultPrintQueue;

                System.Windows.Controls.PrintDialog printDialog = new System.Windows.Controls.PrintDialog();
                printDialog.PrintTicket.PageOrientation = System.Printing.PageOrientation.Portrait;
                printDialog.PrintQueue = printQueue;
                printDialog.PrintDocument(accessionOrderDataSheet.FixedDocument.DocumentPaginator, "AccessionDataSheet");
            }
            else
            {
                MessageBox.Show("You must order something before the data sheet can be printed out.");
            }
        }
Example #23
0
        static void PdfPrintingTest()
        {
            PdfSharp.Pdf.PdfDocument pdfDocument = PdfSharp.Pdf.IO.PdfReader.Open(@"C:\MERCURY\BHPP_Flyer_5_10.pdf", PdfSharp.Pdf.IO.PdfDocumentOpenMode.ReadOnly);



            System.Printing.LocalPrintServer printServer = new System.Printing.LocalPrintServer();

            // System.Printing.PrintServer printServer = new System.Printing.PrintServer (@"\\qsdc001");

            System.Printing.PrintQueueCollection printQueues = printServer.GetPrintQueues();

            foreach (System.Printing.PrintQueue currentPrintQueue in printQueues)
            {
                System.Diagnostics.Debug.WriteLine(currentPrintQueue.Name);
            }



            System.Diagnostics.Process acrobatProcess = new System.Diagnostics.Process();

            acrobatProcess.StartInfo.FileName = @"C:\Program Files (x86)\Adobe\Reader 9.0\Reader\AcroRd32.exe";

            acrobatProcess.Start();

            // System.Threading.Thread.Sleep (5000);


            PdfSharp.Pdf.Printing.PdfFilePrinter.AdobeReaderPath = @"C:\Program Files (x86)\Adobe\Reader 9.0\Reader\AcroRd32.exe";

            PdfSharp.Pdf.Printing.PdfFilePrinter pdfPrinter = new PdfSharp.Pdf.Printing.PdfFilePrinter();

            pdfPrinter.PrinterName = @"Microsoft XPS Document Writer";

            pdfPrinter.PdfFileName = @"C:\MERCURY\BHPP_Flyer_5_10.pdf";

            pdfPrinter.WorkingDirectory = @"C:\MERCURY\";

            pdfPrinter.Print();

            // acrobatProcess.CloseMainWindow ();
        }
        public UserPreferences()
        {
            this.m_MolecularLabelFormatCollection = YellowstonePathology.Business.Label.Model.LabelFormatCollection.GetMolecularLabelCollection();
            this.m_UserPreference = YellowstonePathology.Business.User.UserPreferenceInstance.Instance.UserPreference;

            this.m_FacilityCollection = Business.Facility.Model.FacilityCollection.GetAllFacilities();
            this.m_LocationCollection = new Business.Facility.Model.LocationCollection();

            System.Printing.LocalPrintServer printServer = new System.Printing.LocalPrintServer();
            this.m_PrintQueueCollection = printServer.GetPrintQueues(new[] { System.Printing.EnumeratedPrintQueueTypes.Local, System.Printing.EnumeratedPrintQueueTypes.Connections });

            this.m_ApplicationVersion     = YellowstonePathology.Business.Persistence.DocumentGateway.Instance.GetApplicationVersion(this);
            this.m_ProcessorRunCollection = Business.Surgical.ProcessorRunCollection.GetAll(true);

            InitializeComponent();

            this.DataContext = this;
            this.Loaded     += new RoutedEventHandler(UserPreferences_Loaded);
            this.Closing    += UserPreferences_Closing;
        }
Example #25
0
        public static System.Printing.PrintQueue GetSlideLabelPrintQueue(string slideLabelPrinter)
        {
            System.Printing.PrintQueue  printQueue  = null;
            System.Printing.PrintServer printServer = null;

            switch (slideLabelPrinter)
            {
            case "Histology Slide Label Printer":
                printServer = new System.Printing.LocalPrintServer();
                printQueue  = printServer.GetPrintQueue("Histology Slide Label Printer");
                break;

            case "Cytology Slide Label Printer":
                printServer = new System.Printing.PrintServer(@"\\YPIIHISTO03");
                printQueue  = printServer.GetPrintQueue("CytologySlideLabelPrinter");
                break;
            }

            return(printQueue);
        }
        private void HyperLinkPrintAllPaperSlides_Click(object sender, RoutedEventArgs e)
        {
            foreach (Business.Specimen.Model.SpecimenOrder specimenOrder in this.m_AccessionOrder.SpecimenOrderCollection)
            {
                foreach (Business.Test.AliquotOrder aliquotOrder in specimenOrder.AliquotOrderCollection)
                {
                    foreach (Business.Slide.Model.SlideOrder slideOrder in aliquotOrder.SlideOrderCollection)
                    {
                        System.Windows.Controls.PrintDialog printDialog = new System.Windows.Controls.PrintDialog();
                        System.Printing.PrintServer         printServer = new System.Printing.LocalPrintServer();

                        System.Printing.PrintQueue printQueue = printServer.GetPrintQueue(YellowstonePathology.Business.User.UserPreferenceInstance.Instance.UserPreference.HistologySlideLabelPrinter);
                        printDialog.PrintQueue = printQueue;

                        YellowstonePathology.Business.Label.Model.HistologySlidePaperLabel histologySlidePaperLabel = new Business.Label.Model.HistologySlidePaperLabel(slideOrder.SlideOrderId,
                                                                                                                                                                        slideOrder.ReportNo, slideOrder.Label, slideOrder.PatientLastName, slideOrder.TestAbbreviation, slideOrder.AccessioningFacility);
                        YellowstonePathology.Business.Label.Model.HistologySlidePaperLabelPrinter histologySlidePaperLabelPrinter = new Business.Label.Model.HistologySlidePaperLabelPrinter();
                        histologySlidePaperLabelPrinter.Queue.Enqueue(histologySlidePaperLabel);
                        histologySlidePaperLabelPrinter.Print();
                    }
                }
            }
        }
Example #27
0
        private void btnConfirm_Click(object sender, RoutedEventArgs e)
        {
            #region 菜品入库
            Hashtable htAdd = new Hashtable();
            Hashtable htSub = new Hashtable();
            if (GridSelected.ItemsSource == null)
            {
                ocSelDesks = new ObservableCollection <DXInfo.Models.OrderMenuEx>();
            }
            else
            {
                ocSelDesks = GridSelected.ItemsSource as ObservableCollection <DXInfo.Models.OrderMenuEx>;
            }
            if (desk != null && order != null && ocSelDesks.Count > 0)
            {
                using (TransactionScope transaction = new TransactionScope())
                {
                    int addmenu = 0;
                    foreach (DXInfo.Models.OrderMenuEx selDesk in ocSelDesks)
                    {
                        if (selDesk.Id != Guid.Empty)
                        {
                            DXInfo.Models.OrderMenus orderMenu = uow.OrderMenus.GetById(selDesk.Id);//.Where(w => w.Id == selDesk.Id).FirstOrDefault();
                            if (orderMenu != null)
                            {
                                if (orderMenu.Status == 2 && orderMenu.Quantity != selDesk.Quantity)
                                {
                                    DXInfo.Models.Inventory inv = uow.Inventory.GetById(orderMenu.InventoryId);//.Where(w => w.Id == orderMenu.InventoryId).FirstOrDefault();
                                    if (!string.IsNullOrEmpty(inv.Printer))
                                    {
                                        if (orderMenu.Quantity > selDesk.Quantity)
                                        {
                                            if (htSub.Contains(inv.Printer))
                                            {
                                                List <InventoryEx> confirmmenu = htSub[inv.Printer] as List <InventoryEx>;
                                                InventoryEx        si          = new InventoryEx();
                                                si.Category = inv.Category;
                                                //si.Quantity = orderMenu.Quantity - selDesk.Quantity;
                                                si.SalePrice = inv.SalePrice;
                                                //si.Amount = inv.SalePrice * (orderMenu.Quantity - selDesk.Quantity);
                                                si.Quantity = orderMenu.Quantity - selDesk.Quantity;
                                                si.Name     = inv.Name;
                                                si.Comment  = orderMenu.Comment;
                                                confirmmenu.Add(si);
                                                htSub[inv.Printer] = confirmmenu;
                                            }
                                            else
                                            {
                                                List <InventoryEx> confirmmenu = new List <InventoryEx>();
                                                InventoryEx        si          = new InventoryEx();
                                                si.Category = inv.Category;
                                                //si.Amount = inv.SalePrice * (orderMenu.Quantity - selDesk.Quantity);
                                                //si.Quantity = orderMenu.Quantity - selDesk.Quantity;
                                                si.SalePrice = inv.SalePrice;
                                                si.Quantity  = orderMenu.Quantity - selDesk.Quantity;
                                                si.Name      = inv.Name;
                                                si.Comment   = orderMenu.Comment;
                                                confirmmenu.Add(si);
                                                htSub.Add(inv.Printer, confirmmenu);
                                            }
                                        }
                                        else
                                        {
                                            if (htAdd.Contains(inv.Printer))
                                            {
                                                List <InventoryEx> confirmmenu = htAdd[inv.Printer] as List <InventoryEx>;
                                                InventoryEx        si          = new InventoryEx();
                                                si.Category = inv.Category;
                                                //si.Amount = inv.SalePrice*(selDesk.Quantity-orderMenu.Quantity);
                                                //si.Quantity = orderMenu.Quantity - selDesk.Quantity;
                                                si.SalePrice = inv.SalePrice;
                                                si.Quantity  = selDesk.Quantity - orderMenu.Quantity;
                                                si.Name      = inv.Name;
                                                si.Comment   = orderMenu.Comment;
                                                confirmmenu.Add(si);
                                                htAdd[inv.Printer] = confirmmenu;
                                            }
                                            else
                                            {
                                                List <InventoryEx> confirmmenu = new List <InventoryEx>();
                                                InventoryEx        si          = new InventoryEx();
                                                si.Category = inv.Category;
                                                //si.Amount = inv.SalePrice * (selDesk.Quantity - orderMenu.Quantity);
                                                si.SalePrice = inv.SalePrice;
                                                si.Quantity  = selDesk.Quantity - orderMenu.Quantity;
                                                si.Name      = inv.Name;
                                                si.Comment   = orderMenu.Comment;
                                                confirmmenu.Add(si);
                                                htAdd.Add(inv.Printer, confirmmenu);
                                            }
                                        }
                                    }
                                }
                                orderMenu.Quantity = selDesk.Quantity;
                                orderMenu.Amount   = selDesk.Quantity * orderMenu.Price;
                                orderMenu.Comment  = selDesk.Comment;

                                DXInfo.Models.OrderMenusHis menuHis = new DXInfo.Models.OrderMenusHis();
                                menuHis.LinkId      = orderMenu.Id;
                                menuHis.OrderId     = orderMenu.OrderId;
                                menuHis.InventoryId = orderMenu.InventoryId;
                                menuHis.Price       = orderMenu.Price;
                                menuHis.Quantity    = orderMenu.Quantity;
                                menuHis.Amount      = orderMenu.Amount;
                                menuHis.UserId      = App.MyIdentity.oper.UserId;
                                menuHis.CreateDate  = DateTime.Now;
                                menuHis.Status      = orderMenu.Status;
                                menuHis.Comment     = orderMenu.Comment;
                                uow.OrderMenusHis.Add(menuHis);
                            }
                        }
                        else
                        {
                            DXInfo.Models.OrderMenus orderMenu = new DXInfo.Models.OrderMenus();
                            orderMenu.OrderId     = order.Id;
                            orderMenu.InventoryId = selDesk.InventoryId;
                            orderMenu.Price       = selDesk.Price;
                            orderMenu.Quantity    = selDesk.Quantity;
                            orderMenu.Amount      = selDesk.Amount;
                            orderMenu.Comment     = selDesk.Comment;
                            orderMenu.CreateDate  = DateTime.Now;
                            orderMenu.UserId      = App.MyIdentity.user.UserId;
                            uow.OrderMenus.Add(orderMenu);

                            uow.Commit();

                            DXInfo.Models.OrderMenusHis menuHis = new DXInfo.Models.OrderMenusHis();
                            menuHis.LinkId      = orderMenu.Id;
                            menuHis.OrderId     = orderMenu.OrderId;
                            menuHis.InventoryId = orderMenu.InventoryId;
                            menuHis.Price       = orderMenu.Price;
                            menuHis.Quantity    = orderMenu.Quantity;
                            menuHis.Amount      = orderMenu.Amount;
                            menuHis.UserId      = App.MyIdentity.oper.UserId;
                            menuHis.CreateDate  = DateTime.Now;
                            menuHis.Status      = orderMenu.Status;
                            menuHis.Comment     = orderMenu.Comment;
                            uow.OrderMenusHis.Add(menuHis);
                            addmenu++;
                        }
                    }
                    if (addmenu > 0)
                    {
                        DXInfo.Models.OrderDishes odish = uow.OrderDishes.GetById(order.Id);//.Where(w => w.Id == order.Id).FirstOrDefault();
                        odish.Status = 0;
                    }
                    uow.Commit();
                    transaction.Complete();
                }
            }
            #endregion
            string deskCodes = "";
            DXInfo.Restaurant.DeskManageFacade dmf = new DXInfo.Restaurant.DeskManageFacade(uow, Guid.Empty, Guid.Empty);
            deskCodes = dmf.GetOrderDeskCodes(uow, order.Id);

            if (htAdd.Count > 0)
            {
                foreach (DictionaryEntry de in htAdd)
                {
                    List <InventoryEx> confirmmenu = de.Value as List <InventoryEx>;
                    decimal            dsum        = confirmmenu.Sum(s => s.Amount);
                    decimal            dcount      = confirmmenu.Sum(s => s.Quantity);
                    if (confirmmenu.Count > 0)
                    {
                        var ctx = new
                        {
                            DeskNo     = deskCodes + "(加单)",
                            Sum        = dsum,
                            Count      = dcount,
                            lSelInv    = confirmmenu,
                            CreateDate = DateTime.Now,
                            DeptName   = App.MyIdentity.dept.DeptName,
                        };
                        System.Printing.LocalPrintServer lp = new System.Printing.LocalPrintServer();
                        System.Printing.PrintQueue       pq = new System.Printing.PrintQueue(lp, de.Key.ToString());
                        DeskConfirmWindow dcw = new DeskConfirmWindow(ctx, pq);
                        if (dcw.ShowDialog().GetValueOrDefault())
                        {
                        }
                    }
                }
            }
            if (htSub.Count > 0)
            {
                foreach (DictionaryEntry de in htSub)
                {
                    List <InventoryEx> confirmmenu = de.Value as List <InventoryEx>;
                    decimal            dsum        = confirmmenu.Sum(s => s.Amount);
                    decimal            dcount      = confirmmenu.Sum(s => s.Quantity);
                    if (confirmmenu.Count > 0)
                    {
                        var ctx = new
                        {
                            DeskNo     = deskCodes + "(减单)",
                            Sum        = dsum,
                            Count      = dcount,
                            lSelInv    = confirmmenu,
                            CreateDate = DateTime.Now,
                            DeptName   = App.MyIdentity.dept.DeptName,
                        };
                        System.Printing.LocalPrintServer lp = new System.Printing.LocalPrintServer();
                        System.Printing.PrintQueue       pq = new System.Printing.PrintQueue(lp, de.Key.ToString());
                        DeskConfirmWindow dcw = new DeskConfirmWindow(ctx, pq);
                        if (dcw.ShowDialog().GetValueOrDefault())
                        {
                        }
                    }
                }
            }
            this.DialogResult = true;
        }
Example #28
0
        public void MakePdf(PdfMakingSpecs specs, Control owner, BackgroundWorker worker,
                            DoWorkEventArgs doWorkEventArgs)
        {
            _worker = worker;
#if !__MonoCS__
            // Mono doesn't current provide System.Printing.  Leave the 'if' here to emphasize the
            // system specific nature of the following check.
            if (Platform.IsWindows)
            {
                // Check whether we have a default printer set (or for that matter, any printers).
                // Gecko on Windows requires a default printer for any print operation, even one
                // to a file.  See https://jira.sil.org/browse/BL-1237.
                string errorMessage = null;
                System.Printing.LocalPrintServer printServer = null;
                try
                {
                    printServer = new System.Printing.LocalPrintServer();
                }
                catch (Exception)                 // System.Printing.PrintQueueException isn't in our System.Printing assembly, so... using Exception
                {
                    // http://issues.bloomlibrary.org/youtrack/issue/BL-4060
                    Logger.WriteEvent("reproduced BL-4060 when trying to create LocalPrinterServer");
                }
                if (printServer == null || !printServer.GetPrintQueues().Any())
                {
                    errorMessage = GetNoDefaultPrinterErrorMessage();
                }
                else
                {
                    System.Printing.PrintQueue defaultPrinter;
                    // BL-2535 it's possible get past the above printQueues.Any() but then get
                    // a System.Printing.PrintQueueException exception with "Access Denied" error here, if
                    // the default printer for some reason is no longer "allowed".
                    try
                    {
                        defaultPrinter = System.Printing.LocalPrintServer.GetDefaultPrintQueue();

                        if (defaultPrinter == null || String.IsNullOrEmpty(defaultPrinter.FullName))
                        {
                            errorMessage = GetNoDefaultPrinterErrorMessage();
                        }
                    }
                    catch (Exception error)                    // System.Printing.PrintQueueException isn't in our System.Printing assembly, so... using Exception
                    {
                        defaultPrinter = null;
                        errorMessage   = L10NSharp.LocalizationManager.GetString(@"PublishTab.PDF.Error.PrinterError",
                                                                                 "Bloom requires access to a printer in order to make a PDF, even though you are not printing.  Windows gave this error when Bloom tried to access the default printer: {0}",
                                                                                 @"Error message displayed in a message dialog box");
                        errorMessage = string.Format(errorMessage, error.Message);
                    }
                }

                if (errorMessage != null)
                {
                    var exception = new ApplicationException(errorMessage);
                    // Note that if we're being run by a BackgroundWorker, it will catch the exception.
                    // If not, but the caller provides a DoWorkEventArgs, pass the exception through
                    // that object rather than throwing it.
                    if (worker != null || doWorkEventArgs == null)
                    {
                        throw exception;
                    }
                    doWorkEventArgs.Result = exception;
                    return;
                }
            }
#endif
            if (_worker != null)
            {
                _worker.ReportProgress(0, L10NSharp.LocalizationManager.GetString(@"PublishTab.PdfMaker.MakingFromHtml",
                                                                                  "Making PDF from HTML",
                                                                                  @"Message displayed in a progress report dialog box"));
            }

            var    runner = new CommandLineRunner();
            string exePath;
            var    bldr = new StringBuilder();
            // Codebase is reliable even when Resharper copies the EXE somewhere else for testing.
            var execDir       = BloomFileLocator.GetCodeBaseFolder();
            var fromDirectory = String.Empty;
            var filePath      = Path.Combine(execDir, "BloomPdfMaker.exe");
            if (!RobustFile.Exists(filePath))
            {
                var msg = LocalizationManager.GetString("InstallProblem.BloomPdfMaker",
                                                        "A component of Bloom, BloomPdfMaker.exe, seems to be missing. This prevents previews and printing. Antivirus software sometimes does this. You may need technical help to repair the Bloom installation and protect this file from being deleted again.");
                throw new FileNotFoundException(msg, "BloomPdfMaker.exe");                 // must be this class to trigger the right reporting mechanism.
            }
            if (Platform.IsMono)
            {
                exePath = Path.ChangeExtension(filePath, "sh");
            }
            else
            {
                exePath = filePath;
            }

            SetArguments(bldr, specs);
            var arguments = bldr.ToString();
            var progress  = new NullProgress();
            var res       = runner.Start(exePath, arguments, Encoding.UTF8, fromDirectory, 3600, progress,
                                         ProcessGeckofxReporting);
            if (res.DidTimeOut || !RobustFile.Exists(specs.OutputPdfPath))
            {
                Logger.WriteEvent(@"***ERROR PDF generation failed: res.StandardOutput = " + res.StandardOutput);

                var msg = L10NSharp.LocalizationManager.GetString(@"PublishTab.PDF.Error.Failed",
                                                                  "Bloom was not able to create the PDF file ({0}).{1}{1}Details: BloomPdfMaker (command line) did not produce the expected document.",
                                                                  @"Error message displayed in a message dialog box. {0} is the filename, {1} is a newline character.");

                // This message string is intentionally separate because it was added after the previous string had already been localized in most languages.
                // It's not useful to add if we're already in save memory mode.
                var msg2 = specs.SaveMemoryMode ? "" : L10NSharp.LocalizationManager.GetString(@"PublishTab.PDF.Error.TrySinglePage",
                                                                                               "The book's images might have exceeded the amount of RAM memory available. Please turn on the \"Use Less Memory\" option which is slower but uses less memory.",
                                                                                               @"Error message displayed in a message dialog box") + Environment.NewLine;

                var fullMsg = String.Format(msg, specs.OutputPdfPath, Environment.NewLine) + Environment.NewLine +
                              msg2 + res.StandardOutput;

                var except = new ApplicationException(fullMsg);
                // Note that if we're being run by a BackgroundWorker, it will catch the exception.
                // If not, but the caller provides a DoWorkEventArgs, pass the exception through
                // that object rather than throwing it.
                if (worker != null || doWorkEventArgs == null)
                {
                    throw except;
                }
                else
                {
                    doWorkEventArgs.Result = except;
                }
            }
        }
Example #29
0
        public void Print(System.Windows.Controls.Image image)
        {
            System.Printing.LocalPrintServer localPrintServer = new System.Printing.LocalPrintServer();
            PrintDialog printDialog = new PrintDialog();

            System.Printing.PrintCapabilities capabilities = printDialog.PrintQueue.GetPrintCapabilities(printDialog.PrintTicket);
            double scale = Math.Min(capabilities.PageImageableArea.ExtentWidth / image.ActualWidth, capabilities.PageImageableArea.ExtentHeight/image.ActualHeight);
            image.LayoutTransform = new System.Windows.Media.ScaleTransform(scale, scale);
            System.Windows.Size sz = new System.Windows.Size(capabilities.PageImageableArea.ExtentWidth, capabilities.PageImageableArea.ExtentHeight);
            image.Measure(sz);
            image.Arrange(new System.Windows.Rect(new System.Windows.Point(capabilities.PageImageableArea.OriginWidth, capabilities.PageImageableArea.OriginHeight), sz));

            printDialog.PrintVisual(image, "Print Image");
        }
        private void ButtonPrintDataSheet_Click(object sender, RoutedEventArgs e)
        {
            if (this.m_AccessionOrder.PanelSetOrderCollection.Count > 0)
            {
                Business.Persistence.DocumentGateway.Instance.Save();
                //YellowstonePathology.Document.Result.Data.AccessionOrderDataSheetData accessionOrderDataSheetData = YellowstonePathology.Business.Gateway.XmlGateway.GetAccessionOrderDataSheetData(this.m_AccessionOrder.MasterAccessionNo);
                //YellowstonePathology.Document.Result.Xps.AccessionOrderDataSheet accessionOrderDataSheet = new Document.Result.Xps.AccessionOrderDataSheet(accessionOrderDataSheetData);
                YellowstonePathology.Business.XPSDocument.Result.Data.AccessionOrderDataSheetDataV2 accessionOrderDataSheetData = YellowstonePathology.Business.Gateway.XmlGateway.GetAccessionOrderDataSheetData(this.m_AccessionOrder.MasterAccessionNo);
                YellowstonePathology.Document.Result.Xps.AccessionOrderDataSheetV2 accessionOrderDataSheet = new Document.Result.Xps.AccessionOrderDataSheetV2(accessionOrderDataSheetData);
                System.Printing.PrintQueue printQueue = new System.Printing.LocalPrintServer().DefaultPrintQueue;

                System.Windows.Controls.PrintDialog printDialog = new System.Windows.Controls.PrintDialog();
                printDialog.PrintTicket.PageOrientation = System.Printing.PageOrientation.Portrait;
                printDialog.PrintQueue = printQueue;
                printDialog.PrintDocument(accessionOrderDataSheet.FixedDocument.DocumentPaginator, "AccessionDataSheet");
            }
            else
            {
                MessageBox.Show("You must order something before the data sheet can be printed out.");
            }
        }
        public void MakePdf(string inputHtmlPath, string outputPdfPath, string paperSizeName,
			bool landscape, bool saveMemoryMode, Control owner, BackgroundWorker worker, DoWorkEventArgs doWorkEventArgs)
        {
            #if !__MonoCS__
            // Mono doesn't current provide System.Printing.  Leave the 'if' here to emphasize the
            // system specific nature of the following check.
            if (Platform.IsWindows)
            {
                // Check whether we have a default printer set (or for that matter, any printers).
                // Gecko on Windows requires a default printer for any print operation, even one
                // to a file.  See https://jira.sil.org/browse/BL-1237.
                string errorMessage = null;
                System.Printing.LocalPrintServer printServer = null;
                try
                {
                    printServer = new System.Printing.LocalPrintServer();
                }
                catch (Exception) // System.Printing.PrintQueueException isn't in our System.Printing assembly, so... using Exception
                {
                    // http://issues.bloomlibrary.org/youtrack/issue/BL-4060
                    Logger.WriteEvent("reproduced BL-4060 when trying to create LocalPrinterServer");
                }
                if (printServer == null || !printServer.GetPrintQueues().Any())
                {
                    errorMessage = GetNoDefaultPrinterErrorMessage();
                }
                else
                {
                    System.Printing.PrintQueue defaultPrinter;
                    // BL-2535 it's possible get past the above printQueues.Any() but then get
                    // a System.Printing.PrintQueueException exception with "Access Denied" error here, if
                    // the default printer for some reason is no longer "allowed".
                    try
                    {
                        defaultPrinter = System.Printing.LocalPrintServer.GetDefaultPrintQueue();

                        if(defaultPrinter == null || String.IsNullOrEmpty(defaultPrinter.FullName))
                        {
                            errorMessage = GetNoDefaultPrinterErrorMessage();
                        }
                    }
                    catch(Exception error) // System.Printing.PrintQueueException isn't in our System.Printing assembly, so... using Exception
                    {
                        defaultPrinter = null;
                        errorMessage = L10NSharp.LocalizationManager.GetDynamicString(@"Bloom", @"MakePDF.PrinterError",
                            "Bloom requires access to a printer in order to make a PDF, even though you are not printing.  Windows gave this error when Bloom tried to access the default printer: {0}",
                            @"Error message displayed in a message dialog box");
                        errorMessage = string.Format(errorMessage, error.Message);
                    }
                }
                if (errorMessage !=null)
                {
                    var exception = new ApplicationException(errorMessage);
                    // Note that if we're being run by a BackgroundWorker, it will catch the exception.
                    // If not, but the caller provides a DoWorkEventArgs, pass the exception through
                    // that object rather than throwing it.
                    if (worker != null || doWorkEventArgs == null)
                        throw exception;
                    doWorkEventArgs.Result = exception;
                    return;
                }
            }
            #endif
            var runner = new CommandLineRunner();
            string exePath;
            var bldr = new StringBuilder();
            // Codebase is reliable even when Resharper copies the EXE somewhere else for testing.
            var loc = Assembly.GetExecutingAssembly().CodeBase.Substring((Platform.IsUnix ? "file://" : "file:///").Length);
            var execDir = Path.GetDirectoryName(loc);
            var fromDirectory = String.Empty;
            var filePath = Path.Combine(execDir, "BloomPdfMaker.exe");
            if (!RobustFile.Exists(filePath))
            {
                var msg = LocalizationManager.GetString("InstallProblem.BloomPdfMaker",
                    "A component of Bloom, BloomPdfMaker.exe, seems to be missing. This prevents previews and printing. Antivirus software sometimes does this. You may need technical help to repair the Bloom installation and protect this file from being deleted again.");
                throw new FileNotFoundException(msg, "BloomPdfMaker.exe"); // must be this class to trigger the right reporting mechanism.
            }
            if (Platform.IsMono)
            {
                exePath = "mono";
                bldr.AppendFormat("--debug \"{0}\" ", filePath);
            }
            else
            {
                exePath = filePath;
            }
            SetArguments(bldr, inputHtmlPath, outputPdfPath, paperSizeName, landscape, saveMemoryMode);
            var arguments = bldr.ToString();
            var progress = new NullProgress();
            var res = runner.Start(exePath, arguments, Encoding.UTF8, fromDirectory, 3600, progress, null);
            if (res.DidTimeOut || !RobustFile.Exists (outputPdfPath))
            {
                Logger.WriteEvent(@"***ERROR PDF generation failed: res.StandardOutput = "+res.StandardOutput);

                var msg = L10NSharp.LocalizationManager.GetDynamicString(@"Bloom", @"MakePDF.Failed",
                    "Bloom was not able to create the PDF file ({0}).{1}{1}Details: BloomPdfMaker (command line) did not produce the expected document.",
                    @"Error message displayed in a message dialog box. {0} is the filename, {1} is a newline character.");

                // This message string is intentionally separate because it was added after the previous string had already been localized in most languages.
                var msg2 = L10NSharp.LocalizationManager.GetDynamicString(@"Bloom", @"MakePDF.TrySinglePage",
                    "The book's images might have exceeded the amount of RAM memory available. Please turn on the \"Use Less Memory\" option which is slower but uses less memory.",
                    @"Error message displayed in a message dialog box");

                var fullMsg = String.Format(msg, outputPdfPath, Environment.NewLine) + Environment.NewLine + msg2 + Environment.NewLine + res.StandardOutput;

                var except = new ApplicationException(fullMsg);
                // Note that if we're being run by a BackgroundWorker, it will catch the exception.
                // If not, but the caller provides a DoWorkEventArgs, pass the exception through
                // that object rather than throwing it.
                if (worker != null || doWorkEventArgs == null)
                    throw except;
                else
                    doWorkEventArgs.Result = except;
            }
        }
Example #32
0
        private void PrintPaperLabel(YellowstonePathology.Business.Slide.Model.SlideOrder slideOrder)
        {
            System.Windows.Controls.PrintDialog printDialog = new System.Windows.Controls.PrintDialog();
            System.Printing.PrintServer printServer = new System.Printing.LocalPrintServer();

            System.Printing.PrintQueue printQueue = printServer.GetPrintQueue(YellowstonePathology.Business.User.UserPreferenceInstance.Instance.UserPreference.HistologySlideLabelPrinter);
            printDialog.PrintQueue = printQueue;

            YellowstonePathology.Business.Label.Model.HistologySlidePaperLabel histologySlidePaperLabel = new Business.Label.Model.HistologySlidePaperLabel(slideOrder.SlideOrderId,
                slideOrder.ReportNo, slideOrder.Label, slideOrder.PatientLastName, slideOrder.TestAbbreviation, slideOrder.Location);
            YellowstonePathology.Business.Label.Model.HistologySlidePaperLabelPrinter histologySlidePaperLabelPrinter = new Business.Label.Model.HistologySlidePaperLabelPrinter();
            histologySlidePaperLabelPrinter.Queue.Enqueue(histologySlidePaperLabel);
            histologySlidePaperLabelPrinter.Print();
        }
Example #33
0
 private void PrintTaskOrder(int copyCount)
 {
     Receiving.TaskOrderDataSheet taskOrderDataSheet = new Receiving.TaskOrderDataSheet(this.m_TaskOrder, this.m_AccessionOrder);
     System.Printing.PrintQueue printQueue = new System.Printing.LocalPrintServer().DefaultPrintQueue;
     System.Windows.Controls.PrintDialog printDialog = new System.Windows.Controls.PrintDialog();
     printDialog.PrintTicket.PageOrientation = System.Printing.PageOrientation.Portrait;
     printDialog.PrintTicket.CopyCount = copyCount;
     printDialog.PrintQueue = printQueue;
     printDialog.PrintDocument(taskOrderDataSheet.FixedDocument.DocumentPaginator, "Task Order Data Sheet");
     MessageBox.Show("This task has been submitted to the printer.");
 }
        private void HyperLinkPrintLabel_Click(object sender, RoutedEventArgs e)
        {
            YellowstonePathology.Business.Test.PanelSetOrder panelSetOrder = this.m_AccessionOrder.PanelSetOrderCollection.GetPAP();
            YellowstonePathology.Business.OrderIdParser orderIdParser = new Business.OrderIdParser(panelSetOrder.ReportNo);
            string dummyReportNo = (orderIdParser.ReportNoYear + 50).ToString() + "-" + orderIdParser.MasterAccessionNoNumber + "." + orderIdParser.ReportNoLetter;

            YellowstonePathology.UI.Login.CytologySlideLabelDocument cytologySlideLabelDocument = new Login.CytologySlideLabelDocument(dummyReportNo, this.m_AccessionOrder.PLastName, false);
            System.Windows.Controls.PrintDialog printDialog = new System.Windows.Controls.PrintDialog();

            System.Printing.PrintServer printServer = new System.Printing.LocalPrintServer();
            System.Printing.PrintQueue printQueue = printServer.GetPrintQueue(YellowstonePathology.Business.User.UserPreferenceInstance.Instance.UserPreference.CytologySlideLabelPrinter);

            printDialog.PrintQueue = printQueue;
            printDialog.PrintDocument(cytologySlideLabelDocument.DocumentPaginator, "Slide Labels");
        }
        private void ButtonTaskOrderPrint_Click(object sender, RoutedEventArgs e)
        {
            if (this.ListViewTaskOrders.SelectedItem != null)
            {
                YellowstonePathology.Business.Task.Model.TaskOrder taskOrder = (YellowstonePathology.Business.Task.Model.TaskOrder)this.ListViewTaskOrders.SelectedItem;
                YellowstonePathology.Business.Test.AccessionOrder accessionOrder = YellowstonePathology.Business.Persistence.DocumentGateway.Instance.PullAccessionOrder(taskOrder.MasterAccessionNo, this.m_Writer);
                Login.Receiving.TaskOrderDataSheet taskOrderDataSheet = new Login.Receiving.TaskOrderDataSheet(taskOrder, accessionOrder);

                System.Printing.PrintQueue printQueue = new System.Printing.LocalPrintServer().DefaultPrintQueue;
                System.Windows.Controls.PrintDialog printDialog = new System.Windows.Controls.PrintDialog();
                printDialog.PrintTicket.PageOrientation = System.Printing.PageOrientation.Portrait;
                printDialog.PrintQueue = printQueue;
                printDialog.PrintDocument(taskOrderDataSheet.FixedDocument.DocumentPaginator, "Task Order Data Sheet");
            }
        }
        private void ButtonPrint_Click(object sender, RoutedEventArgs e)
        {
            if (this.m_Copies > 0)
            {
                if (this.ComboBoxForm.SelectedItem != null)
                {
                    if (this.ComboBoxPrinter.SelectedItem != null)
                    {
                        System.Printing.PrintServer printServer = new System.Printing.LocalPrintServer();
                        System.Printing.PrintQueue printQueue = printServer.GetPrintQueue(YellowstonePathology.Business.User.UserPreferenceInstance.Instance.UserPreference.RequisitionPrinter);

                        ComboBoxItem comboBoxItem = (ComboBoxItem)this.ComboBoxForm.SelectedItem;
                        switch (comboBoxItem.Content.ToString())
                        {
                            case "Standard":
                                StandardRequisition standardRequisition = new StandardRequisition(this.m_ClientId);
                                standardRequisition.Print(this.m_Copies, printQueue);
                                break;
                            case "Oncology":
                                OncologyRequisition oncologyRequisition = new OncologyRequisition(this.m_ClientId);
                                oncologyRequisition.Print(this.m_Copies, printQueue);
                                break;
                            case "IHC/Molecular":
                                IHCMolecularRequisition ihcMolecularRequisition = new IHCMolecularRequisition(this.m_ClientId);
                                ihcMolecularRequisition.Print(this.m_Copies, printQueue);
                                break;
                        }
                        Close();
                    }
                    else
                    {
                        MessageBox.Show("You must select a printer.");
                    }
                }
                else
                {
                    MessageBox.Show("You must select a form type.");
                }
            }
        }
 private void ButtonPrintTrackingDocument_Click(object sender, RoutedEventArgs e)
 {
     MaterialTrackingBatchSummary materialTrackingBatchSummary = new MaterialTrackingBatchSummary(this.m_MaterialTrackingBatch, this.m_MaterialTrackingLogViewCollection);
     System.Printing.PrintQueue printQueue = new System.Printing.LocalPrintServer().DefaultPrintQueue;
     System.Windows.Controls.PrintDialog printDialog = new System.Windows.Controls.PrintDialog();
     printDialog.PrintTicket.PageOrientation = System.Printing.PageOrientation.Portrait;
     printDialog.PrintQueue = printQueue;
     printDialog.PrintDocument(materialTrackingBatchSummary.FixedDocument.DocumentPaginator, "Material Tracking Batch Summary");
 }