private void PrintVisualClick(object sender, RoutedEventArgs e)
        {
            var visualSize   = new Size(visual.ActualWidth, visual.ActualHeight);
            var printControl = PrintControlFactory.Create(visualSize, visual);

            printControl.ShowPrintPreview();
        }
示例#2
0
        private void Button_Click(object sender, RoutedEventArgs e)
        {
            var visualSize   = new Size(Plot.ActualWidth, Plot.ActualHeight);
            var printControl = PrintControlFactory.Create(visualSize, Plot);

            printControl.ShowPrintPreview();

            e.Handled = true;
        }
示例#3
0
        private void btnPrint_Click(object sender, RoutedEventArgs e)
        {
            var dataTable      = GenerateUtil.GenerateDataTable1 <QueryRightRowViewModel>(headers, viewModel.RecordCollection);
            var columnWidths   = headers.Select(x => x.Item3 * 0.51).ToList();
            var ht             = new HeaderTemplate();
            var headerTemplate = XamlWriter.Save(ht);
            var printControl   = PrintControlFactory.Create(dataTable, columnWidths, headerTemplate);

            printControl.ShowPrintPreview();
        }
 private void PrintData_Click(object sender, RoutedEventArgs e)
 {
     try
     {
         var visualSize   = new Size(dataGrid.ActualWidth, dataGrid.ActualHeight);
         var printControl = PrintControlFactory.Create(visualSize, dataGrid);
         printControl.ShowPrintPreview();
     }
     catch (Exception ex)
     {
         MessageBox.Show(string.Format("Wystąpił błąd podczas próby drukowania!\n {0}", ex.Message), "Błąd", MessageBoxButton.OK, MessageBoxImage.Error);
     }
 }
        private void PrintDataTableClick(object sender, RoutedEventArgs e)
        {
            var dataTable    = CreateSampleDataTable();
            var columnWidths = new List <double>()
            {
                30, 40, 300, 300, 150
            };
            var ht             = new HeaderTemplate();
            var headerTemplate = XamlWriter.Save(ht);
            var printControl   = PrintControlFactory.Create(dataTable, columnWidths, headerTemplate);

            printControl.ShowPrintPreview();
        }
示例#6
0
        private void printBarcode(BitmapImage bitmap, string description)
        {
            PrintDialog       pDiag     = new PrintDialog();
            PrintCapabilities printCaps = pDiag.PrintQueue.GetPrintCapabilities(pDiag.PrintTicket);

            renderBarcode("Taylor, Hunter", printCaps);
            DrawingVisual visual = getDrawingVisual(bitmap);

            //bitmap = addBitmapPadding(bitmap);
            //double scale = Math.Min(printCaps.PageImageableArea.ExtentWidth / visual.ContentBounds.Width, printCaps.PageImageableArea.ExtentHeight / visual.ContentBounds.Height);

            //Transform the Visual to scale
            visual.Transform = new ScaleTransform(0.95, 0.95);

            var visualSize   = new Size(visual.ContentBounds.Width, visual.ContentBounds.Height);
            var printControl = PrintControlFactory.Create(visualSize, visual);

            //var printControl = PrintControlFactory.Create(imgBarcode);
            printControl.ShowPrintPreview();

            //if (pDiag.ShowDialog() == true)
            //{
            //    //get selected printer capabilities
            //    PrintCapabilities printCaps = pDiag.PrintQueue.GetPrintCapabilities(pDiag.PrintTicket);
            //    renderBarcode("Tonitta Sauls", printCaps);

            //    DrawingVisual visual = getDrawingVisual(bitmap);
            //    //bitmap = addBitmapPadding(bitmap);

            //    //get scale of the print wrt to screen of WPF visual
            //    double scale = Math.Min(printCaps.PageImageableArea.ExtentWidth / visual.ContentBounds.Width, printCaps.PageImageableArea.ExtentHeight / visual.ContentBounds.Height);

            //    //Transform the Visual to scale
            //    visual.Transform = new ScaleTransform(scale, scale);

            //    //get the size of the printer page
            //    //Size sz = new Size(printCaps.PageImageableArea.ExtentWidth, printCaps.PageImageableArea.ExtentHeight);

            //    //update the layout of the visual to the printer page size.
            //    //visual.Measure(sz);
            //    //visual.Arrange(new Rect(new Point(printCaps.PageImageableArea.OriginWidth, printCaps.PageImageableArea.OriginHeight), sz));

            //    //pDiag.PrintVisual(visual, description);
            //    var visualSize = new Size(visual.ContentBounds.Width, visual.ContentBounds.Height);
            //    var printControl = PrintControlFactory.Create(visualSize, visual);
            //    printControl.ShowPrintPreview();
            //}
        }
		private void printBarcode()
		{
			if (getPatientInfo() == null)
			{
				MessageBox.Show("Invalid input entered.\nPlease correct errors marked by red fields.",
								"Input Error", MessageBoxButton.OK, MessageBoxImage.Error);
				return;
			}

			DrawingVisual visual = Util.renderPatientBarcode(getPatientInfo());

			var visualSize = new Size(visual.ContentBounds.Width, visual.ContentBounds.Height);
			var printControl = PrintControlFactory.Create(visualSize, visual);
	
			printControl.ShowPrintPreview();
		}
		private void printBarcode()
		{
			//if (getPatientInfo() == null)
			//{
			//    MessageBox.Show("Invalid input entered.\nPlease correct errors marked by red fields.",
			//                    "Input Error", MessageBoxButton.OK, MessageBoxImage.Error);
			//    return;
			//}

			DrawingVisual visual = Util.renderMedicationBarcode(MedicationPoolWindow.SelectedMedication);

			var visualSize = new Size(visual.ContentBounds.Width, visual.ContentBounds.Height);
			var printControl = PrintControlFactory.Create(visualSize, visual);

			printControl.ShowPrintPreview();
		}
示例#9
0
 /// <summary>
 /// Prints the file
 /// </summary>
 /// <returns>Exception if the printing failed, otherwise null</returns>
 public Exception Print(FrameworkElement graphLayout)
 {
     try
     {
         //This is using the Awesome code from : http://www.codeproject.com/KB/printing/wpfprintengine.aspx
         //By Saraf Talukder
         var visualSize   = new Size(graphLayout.ActualWidth, graphLayout.ActualHeight);
         var printControl = PrintControlFactory.Create(visualSize, graphLayout);
         printControl.ShowPrintPreview();
         return(null);
     }
     catch (Exception ex)
     {
         return(ex);
     }
 }
        public static void PrintGrid(ref DataGrid fwe, string header)
        {
            var columnWidths = GetColumnWidths(fwe);

            var ht             = new HeaderTemplate();
            var headerTemplate = XamlWriter.Save(ht);

            headerTemplate = headerTemplate.Replace("TitleHeader", header);
            var dt = Grid2Dt(fwe);


            var printControl = PrintControlFactory.Create(dt, columnWidths, headerTemplate);

            printControl.ShowPrintPreview();
            // var visual = printControl.DrawingVisual;

            // SetUpPrint(fwe,visual);
        }
        private void Button_Click(object sender, RoutedEventArgs e)
        {
            var columnWidths = new List <double>();

            foreach (DataGridColumn column in DGTable.Columns)
            {
                columnWidths.Add((column.Width).DesiredValue);
            }

            var ht = new HeaderTemplate();

            var headerTemplate = XamlWriter.Save(ht);
            var printControl   = PrintControlFactory.Create(DataTable, columnWidths, headerTemplate);

            printControl.ShowPrintPreview();

            e.Handled = true;
        }
示例#12
0
        void FillTable(List <MissingItems> items)
        {
            items = items.OrderBy(i => i.store).ToList();
            if (items.Count == 0)
            {
                MessageBox.Show("no items to report");
                return;
            }
            timer1.Start();
            var dataTable = new DataTable();

            AddColumn(dataTable, "store", typeof(string));
            AddColumn(dataTable, "type", typeof(string));
            AddColumn(dataTable, "P", typeof(string));
            AddColumn(dataTable, "description", typeof(string));
            AddColumn(dataTable, "CustomerName", typeof(string));
            AddColumn(dataTable, "PressStartTime", typeof(string));
            int     row     = 0;
            string  store1  = items[0].store;
            DataRow dataRow = null;

            foreach (MissingItems item in items)
            {
                dataRow = dataTable.NewRow();
                //if change in store than add a line of blanks for seperation
                if (store1 != item.store)
                {
                    dataRow[0] = row.ToString();
                    dataRow[1] = "  ";
                    dataRow[2] = "  ";
                    dataRow[3] = "  ";
                    dataRow[4] = "  ";
                    dataRow[5] = "  ";
                    row        = 0;
                    dataTable.Rows.Add(dataRow);
                    dataRow = dataTable.NewRow();
                }
                row++;
                dataRow[0] = item.store;
                dataRow[1] = item.qcsType;
                if (item.TimeStampIn != null)
                {
                    dataRow[2] = "P";
                    dataRow[5] = item.TimeStampIn.Value.ToString("ddd") + " " + item.TimeStampIn.Value.ToShortTimeString();
                }

                dataRow[3] = item.description;
                dataRow[4] = item.CustomerName;

                dataTable.Rows.Add(dataRow);
                store1 = item.store;
            }
            dataRow    = dataTable.NewRow();
            dataRow[0] = row.ToString();
            dataRow[1] = "  ";
            dataRow[2] = "  ";
            dataRow[3] = "  ";

            dataTable.Rows.Add(dataRow);

            var columnWidths = new List <double>()
            {
                35, 80, 20, 300, 150, 100
            };
            var ht             = new HeaderTemplate();
            var headerTemplate = XamlWriter.Save(ht);
            var printControl   = PrintControlFactory.Create(dataTable, columnWidths, headerTemplate);

            printControl.ShowPrintPreview();
        }