Пример #1
0
        void vm_PreviewNotice(object sender, SimpleMvvmToolkit.NotificationEventArgs <Core.Model.Order> e)
        {
            try
            {
                var flowDocument = PrintHelper.GetPrintDocument(e.Message, e.Data);
                var xps          = PrintHelper.GetXpsDocument(flowDocument);
                var document     = xps.GetFixedDocumentSequence();

                var previewWindow = new PreviewTicket();
                previewWindow.Owner = Application.Current.MainWindow;
                previewWindow.docViewer.Document = document;
                previewWindow.ShowDialog();
            }
            catch (Exception ex)
            {
                LogService.Error("Error while preview ticket", ex);
                MessageBox.Show(ex.Message);
            }
        }
Пример #2
0
        private void PreviewTemplate()
        {
            if (string.IsNullOrEmpty(SelectedTemplate.Value))
            {
                return;
            }

            try
            {
                var xml = this.SelectedTemplate.Value;

                if (this.Order != null)
                {
                    this.PreviewTemplateContent = PrintHelper.GetPrintDocument(xml, this.Order);
                }
            }
            catch (Exception ex)
            {
                NotifyError("Error while preview", ex);
            }
        }
Пример #3
0
        private void PrintOrderToPrinter(Order order)
        {
            if (this.SelectedTemplate == null)
            {
                NotifyError("Print template is not selected!", null);
            }

            if (string.IsNullOrEmpty(this.SelectedTemplate.Value))
            {
                NotifyError("Print template does not have valid text!", null);
            }

            try
            {
                var flowDocument = PrintHelper.GetPrintDocument(this.SelectedTemplate.Value, this.SelectedOrder);
                var xps          = PrintHelper.GetXpsDocument(flowDocument);
                PrintHelper.PrintXpsToPrinter(xps, Properties.Settings.Default.TicketPrinter);
            }
            catch (Exception ex)
            {
                NotifyError("Error printing order", ex);
            }
        }