public PhieuNhapHang_PrintPreview_ViewModel(string mapnk, string tennhanvien, string ngaylap, string tenncc, String diachi, string sdt, string fax, string tongtien, ObservableCollection <ListMatHangMua> list)
        {
            MaPhieuNhapKho = mapnk;
            TongTien       = tongtien;
            TenNhanVien    = tennhanvien;
            NgayLap        = ngaylap;
            TenNCC         = tenncc;
            DiaChi         = diachi;
            SDT            = sdt;
            Fax            = fax;
            ListMatHang    = list;
            Load();

            CloseWindowCommand = new RelayCommand <Window>((p) => { return(p == null ? false : true); }, (p) => {
                p.Close();
            });

            Print_Command = new RelayCommand <object>((p) => { return(p == null ? false : true); }, (p) =>
            {
                var ex = p as Window;
                try
                {
                    System.Windows.Controls.PrintDialog printDialog = new System.Windows.Controls.PrintDialog();
                    if (printDialog.ShowDialog() == true)
                    {
                        printDialog.PrintVisual(ex, "Print report");
                    }
                }
                catch (Exception e)
                {
                    System.Windows.MessageBox.Show("Cannot print");
                }
            });
        }
Beispiel #2
0
        private void Print_OnClick(object sender, RoutedEventArgs e)
        {
            var res = pr.ShowDialog();
            var vm  = DataContext as IdViewModel;

            if (vm.SelectedLayout.PrintBackground == false)
            {
                BackgroundImage.Visibility = Visibility.Hidden;
            }

            var ticket = pr.PrintTicket;
            var x      = vm.SelectedLayout.PrintMarginX;
            var y      = vm.SelectedLayout.PrintMarginY;

            if (ticket.PageMediaSize.Width.HasValue && ticket.PageMediaSize.Height.HasValue)
            {
                vm.SelectedLayout.PrintMarginX = x + pr.PrintableAreaWidth - ticket.PageMediaSize.Width.Value;
                vm.SelectedLayout.PrintMarginY = y + pr.PrintableAreaHeight - ticket.PageMediaSize.Height.Value;
            }
            Area.Width  = pr.PrintableAreaWidth;
            Area.Height = pr.PrintableAreaHeight;
            Area.Measure(new Size(Area.Width, Area.Height));
            Area.Arrange(new Rect(0, 0, Area.Width, Area.Height));

            if (res == true)
            {
                pr.PrintVisual(Area, "ID card");
            }

            vm.SelectedLayout.PrintMarginX = x;
            vm.SelectedLayout.PrintMarginY = y;
            BackgroundImage.Visibility     = Visibility.Visible;
        }
        /// <summary>
        /// Prints the screen image.
        /// </summary>
        /// <param name="source">The source.</param>
        /// <param name="scale">The scale.</param>
        /// <param name="rectangle">The rectangle.</param>
        public static void PrintScreenImage(UIElement source, double scale, Rectangle rectangle)
        {
            var dialog = new System.Windows.Controls.PrintDialog();

            var dialogResult = dialog.ShowDialog() ?? false;

            if (!dialogResult)
            {
                return;
            }

            using (var stream = GetScreenImageStream(source, scale, 100, new PngBitmapEncoder()))
            {
                var img = (Bitmap)Image.FromStream(stream);

                if (!rectangle.IsEmpty)
                {
                    img = img.Clone(rectangle.Contract(1), img.PixelFormat);
                }

                var bmpSource = BitmapToBitmapSource(img);

                var visual = new DrawingVisual();
                using (var dc = visual.RenderOpen())
                {
                    dc.DrawImage(bmpSource, new Rect {
                        Width = img.Width, Height = img.Height
                    });
                }

                var filename = $"screenshot_{DateTime.Now.ToString("yyyyMMddHHmm")}";

                dialog.PrintVisual(visual, filename);
            }
        }
 public static void PrintArea(System.Windows.Media.Visual areaToPrint, string titleString)
 {
     System.Windows.Controls.PrintDialog printDlg = new System.Windows.Controls.PrintDialog();
        if (printDlg.ShowDialog() == true)
        {
        printDlg.PrintVisual(areaToPrint, titleString);
        }
 }
Beispiel #5
0
 private void Menu_print_Click(object sender, RoutedEventArgs e)
 {
     System.Windows.Controls.PrintDialog printDialog = new System.Windows.Controls.PrintDialog();
     if (printDialog.ShowDialog() == true)
     {
         printDialog.PrintVisual(image_main, "Page");
     }
 }
Beispiel #6
0
 public void Print()
 {
     System.Windows.Controls.PrintDialog dialog = new System.Windows.Controls.PrintDialog();
     if (dialog.ShowDialog() != true)
     {
         return;
     }
     dialog.PrintVisual(this, string.Empty);
 }
 protected void PrintCommandExecute()
 {
     System.Windows.Controls.PrintDialog dialog = new System.Windows.Controls.PrintDialog();
     if (dialog.ShowDialog() != true)
     {
         return;
     }
     dialog.PrintVisual(this, string.Empty);
 }
Beispiel #8
0
        private static void DoPrint(FrameworkElement grid)
        {
            var pd = new System.Windows.Controls.PrintDialog();

            if (pd.ShowDialog() == true)
            {
                pd.PrintVisual(grid, "appointments to print");
            }
        }
Beispiel #9
0
        private void PrintOnClick(object sender, RoutedEventArgs e)
        {
            var printDialog = new System.Windows.Controls.PrintDialog();

            if (printDialog.ShowDialog() == true)
            {
                printDialog.PrintVisual(GraphLayout, "Graph");
            }
        }
        private void BtnPrint_OnClick(object sender, RoutedEventArgs e)
        {
            PrintBtn.Visibility = Visibility.Hidden;

            PrintDialog print = new PrintDialog();

            print.PrintVisual(Grid, "Biografbilletter");

            PrintBtn.Visibility = Visibility.Visible;
        }
Beispiel #11
0
        public void PrintSalesReport(string receiptText)
        {
            try
            {
                var dlg = new PrintDialog();
                dlg.PrintTicket.CopyCount = 1;
                if (dlg.ShowDialog().GetValueOrDefault())
                {
                    // Create DrawingVisual and open DrawingContext.
                    DrawingVisual  vis = new DrawingVisual();
                    DrawingContext dc  = vis.RenderOpen();

                    FormattedText formtxt = new FormattedText(
                        receiptText,
                        CultureInfo.CurrentCulture,
                        FlowDirection.LeftToRight,
                        new Typeface(new FontFamily("GenericMonospace"),
                                     FontStyles.Normal, FontWeights.Bold,
                                     FontStretches.Normal),
                        12, Brushes.Black);

                    Size sizeText = new Size(formtxt.Width, formtxt.Height);

                    dc.DrawText(formtxt, new Point(_leftMargin, 25));
                    dc.Close();

                    switch (dlg.PrintTicket.PageOrientation)
                    {
                    case PageOrientation.Landscape:
                        vis.Transform =
                            new RotateTransform(-90, dlg.PrintableAreaWidth / 2,
                                                dlg.PrintableAreaWidth / 2);
                        break;

                    case PageOrientation.ReversePortrait:
                        vis.Transform =
                            new RotateTransform(180, dlg.PrintableAreaWidth / 2,
                                                dlg.PrintableAreaHeight / 2);
                        break;

                    case PageOrientation.ReverseLandscape:
                        vis.Transform =
                            new RotateTransform(90, dlg.PrintableAreaHeight / 2,
                                                dlg.PrintableAreaHeight / 2);
                        break;
                    }

                    // Finally, print the page.
                    dlg.PrintVisual(vis, "BB Copy");
                }
            }
            catch (Exception ex)
            {
            }
        }
 private void btnPrint_Click(object sender, RoutedEventArgs e)
 {
     System.Windows.Controls.PrintDialog Printdlg = new System.Windows.Controls.PrintDialog();
     if ((bool)Printdlg.ShowDialog().GetValueOrDefault())
     {
         Size pageSize = new Size(Printdlg.PrintableAreaWidth, Printdlg.PrintableAreaHeight);
         // sizing of the element.
         stackPanelPrintArea.Measure(pageSize);
         stackPanelPrintArea.Arrange(new Rect(5, 5, pageSize.Width, pageSize.Height));
         Printdlg.PrintVisual(stackPanelPrintArea, Title);
     }
 }
        private void printButton_Click(object sender, RoutedEventArgs e)
        {
            System.Windows.Controls.PrintDialog prnt = new System.Windows.Controls.PrintDialog();

            if (prnt.ShowDialog() == true)
            {
                prnt.PrintVisual(EventInvoiceGrid, "Printing Grid");
            }
            EventsList    EL      = new EventsList(eventIdTextBlock.Text, EventCalculation.eventDate, EventCalculation.eventStartTime, EventCalculation.photographyCost, EventCalculation.decorationCost, EventCalculation.totalcenterCost, EventCalculation.vat, EventCalculation.discount, EventCalculation.totalCostWithVat, EventCalculation.advancePay, EventCalculation.remainingPay, EventCalculation.customerName, EventCalculation.customerContactNumber, EventCalculation.customerEmail, EventCalculation.customerAddress, "Pending");
            EventService  service = new EventService();
            int           x       = service.AddEvent(EL);
            CenterService cs      = new CenterService();

            cs.BookCenter(eventIdTextBlock.Text, EventCalculation.centerId);
            EventCalculation.eventDate            = "";
            EventCalculation.eventStartTime       = "";
            EventCalculation.eventEndTime         = "";
            EventCalculation.printedPhotos        = "";
            EventCalculation.eachPhotoCost        = "";
            EventCalculation.photographyCost      = 0;
            EventCalculation.decorationCost       = 0;
            EventCalculation.stage                = "";
            EventCalculation.homelight            = "";
            EventCalculation.homelightDuration    = "";
            EventCalculation.streetlight          = "";
            EventCalculation.streetlightDeuration = "";
            EventCalculation.gate                = "";
            EventCalculation.planaquin           = "";
            EventCalculation.centerName          = "";
            EventCalculation.centerLoaction      = "";
            EventCalculation.totalCostWithoutVat = 0;
            EventCalculation.totalcenterCost     = 0;
            EventCalculation.eventDuration       = "";
            EventCalculation.CostStage           = 0;
            EventCalculation.CostHomeLight       = 0;
            EventCalculation.CostStreetLight     = 0;
            EventCalculation.CostGate            = 0;
            EventCalculation.CostPlanaquin       = 0;
            EventCalculation.vat                   = 0;
            EventCalculation.discount              = 0;
            EventCalculation.totalCostWithVat      = 0;
            EventCalculation.customerName          = "";
            EventCalculation.customerContactNumber = "";
            EventCalculation.customerEmail         = "";
            EventCalculation.customerAddress       = "";
            EventCalculation.eventId               = "";
            EventCalculation.advancePay            = "";
            EventCalculation.remainingPay          = "";
            this.Close();
        }
 private void BImprimir_Click(object sender, RoutedEventArgs e)
 {
     try
     {
         this.IsEnabled = false;
         System.Windows.Controls.PrintDialog printDialog = new System.Windows.Controls.PrintDialog();
         if (printDialog.ShowDialog() == true)
         {
             printDialog.PrintVisual(print, "informe");
         }
     }
     finally
     {
         this.IsEnabled = true;
     }
 }
Beispiel #15
0
        private void printimage(System.Windows.Media.ImageSource bi)
        {
            var vis = new System.Windows.Media.DrawingVisual();

            System.Windows.Media.DrawingContext dc = vis.RenderOpen();
            dc.DrawImage(bi, new System.Windows.Rect {
                Width = bi.Width, Height = bi.Height
            });
            dc.Close();

            var pdialog = new System.Windows.Controls.PrintDialog();
            //  if (pdialog.ShowDialog() == true)
            {
                pdialog.PrintVisual(vis, "My Image");
            }
        }
Beispiel #16
0
        public void print_flowDocument()
        {
            // Create a PrintDialog
            var printDlg = new System.Windows.Controls.PrintDialog();

            // Create a FlowDocument dynamically.
            FlowDocument doc = CreateFlowDocument();

            doc.Name = "FlowDoc";

            // Create IDocumentPaginatorSource from FlowDocument
            IDocumentPaginatorSource idpSource = doc;

            // Call PrintDocument method to send document to printer
            //printDlg.PrintDocument(idpSource.DocumentPaginator, "Hello WPF Printing.");
            printDlg.PrintVisual(this, "Hello WPF Printing.");
        }
Beispiel #17
0
        private void Button_Click(object sender, RoutedEventArgs e)
        {
            var a = true;

            if (a)
            {
                return;
            }

            System.Windows.Controls.PrintDialog Printdlg = new System.Windows.Controls.PrintDialog();
            if ((bool)Printdlg.ShowDialog().GetValueOrDefault())
            {
                Size pageSize = new Size(Printdlg.PrintableAreaWidth, Printdlg.PrintableAreaHeight);
                // sizing of the element.
                dataGrid1.Measure(pageSize);
                dataGrid1.Arrange(new Rect(5, 5, pageSize.Width, pageSize.Height));
                Printdlg.PrintVisual(dataGrid1, Title);
            }
        }
Beispiel #18
0
        private void PrintDayOfTicket(List <SaleItem> items, string name, DateTime date, string orderNumber,
                                      string tableNumber, bool isToGo, bool isWalkUp, string printerName, bool isPrintQrCode, string notes, string footer)
        {
            try
            {
                var dlg = new PrintDialog();
                if (!string.IsNullOrEmpty(printerName))
                {
                    try
                    {
                        dlg.PrintQueue = new PrintQueue(new PrintServer(), printerName);
                    }
                    catch
                    {
                    }
                }
                dlg.PrintTicket.CopyCount = 1;

                if (dlg.ShowDialog().GetValueOrDefault())
                {
                    // Create DrawingVisual and open DrawingContext.
                    DrawingVisual  vis = new DrawingVisual();
                    DrawingContext dc  = vis.RenderOpen();

                    var receiptText = "Most Precious Blood" + Environment.NewLine + "Catholic Church" + Environment.NewLine + Environment.NewLine;
                    receiptText += "Lenten Fish Fry" + Environment.NewLine + Environment.NewLine;
                    receiptText += "Presented by the" + Environment.NewLine + "Men's Fellowship" + Environment.NewLine;
                    receiptText += Environment.NewLine;
                    receiptText += "Order Number: " + Environment.NewLine + orderNumber + Environment.NewLine + Environment.NewLine;
                    receiptText += "Transaction Date: " + Environment.NewLine;
                    receiptText += DateTime.Now.ToString("MM/dd/yy HH:mm:ss") + Environment.NewLine + Environment.NewLine;
                    receiptText += "Name: " + Environment.NewLine + name.ToUpper() + Environment.NewLine + Environment.NewLine;
                    receiptText += "Seating Time: " + Environment.NewLine + date.ToString("MM/dd/yy HH:mm") + Environment.NewLine + Environment.NewLine;

                    var    itemList     = items.OrderByDescending(x => x.Price).ThenBy(x => x.Name).Select(x => x.Name).Distinct();
                    double runningTotal = 0;
                    foreach (var item in itemList)
                    {
                        var count = items.Count(x => x.Name == item);
                        var price = items.First(x => x.Name == item).Price;
                        var total = count * price;
                        runningTotal += total;
                        //Full Fried (5 x $5).......... $25
                        receiptText += string.Format("{0} ({1} x ${2})....... ${3}{4}", item, count, price, total, Environment.NewLine);
                    }
                    receiptText += Environment.NewLine + Environment.NewLine + "Total Sale: $" + runningTotal;

                    if (!string.IsNullOrEmpty(notes))
                    {
                        receiptText += Environment.NewLine + Environment.NewLine + "Notes:" + Environment.NewLine;
                        if (!ShouldBreakUpNotes(notes))
                        {
                            receiptText += notes + Environment.NewLine;
                        }
                        else
                        {
                            //while (notes.Length >= _notesCharacters)
                            //{
                            //var line = "";
                            //while (line.Length < _notesCharacters && (notes.Contains(" ") || notes.Contains(Environment.NewLine)))
                            //{
                            //    var index = 0;
                            //    var delimeter = " ";
                            //    if (notes.IndexOf(" ") > 0)
                            //    {
                            //        index = notes.IndexOf(" ");
                            //    }
                            //    if (notes.IndexOf(Environment.NewLine) > 0 &&
                            //        notes.IndexOf(Environment.NewLine) < index)
                            //    {
                            //        index = notes.IndexOf(Environment.NewLine);
                            //        delimeter = Environment.NewLine;
                            //    }
                            //    if (line.Length > 0)
                            //    {
                            //        line += delimeter;
                            //    }
                            //    if (index == 0)
                            //    {
                            //        index = _notesCharacters;
                            //    }

                            //    line += notes.Substring(0, index).Trim();
                            //    notes = notes.Substring(index).Trim();
                            //    if (delimeter == Environment.NewLine)
                            //    {
                            //        break;
                            //    }
                            //}
                            receiptText += notes.Replace(" ", Environment.NewLine) + Environment.NewLine;
                            //}
                        }
                        receiptText += Environment.NewLine;
                        receiptText += Environment.NewLine;
                        receiptText += "." + Environment.NewLine;
                        receiptText += Environment.NewLine;
                    }

                    double top = 25;

                    if (!string.IsNullOrEmpty(tableNumber))
                    {
                        FormattedText formattedTextTableNumber = new FormattedText(
                            tableNumber + Environment.NewLine,
                            CultureInfo.CurrentCulture,
                            FlowDirection.LeftToRight,
                            new Typeface(new FontFamily("GenericMonospace"),
                                         FontStyles.Normal, FontWeights.Bold,
                                         FontStretches.Normal),
                            36, Brushes.Black);
                        Size sizeTableNumberText = new Size(formattedTextTableNumber.Width,
                                                            formattedTextTableNumber.Height);
                        dc.DrawText(formattedTextTableNumber, new Point(_leftMargin, top));
                        top += sizeTableNumberText.Height;
                    }

                    FormattedText formtxt = new FormattedText(
                        receiptText,
                        CultureInfo.CurrentCulture,
                        FlowDirection.LeftToRight,
                        new Typeface(new FontFamily("GenericMonospace"),
                                     FontStyles.Normal, FontWeights.Bold,
                                     FontStretches.Normal),
                        12, Brushes.Black);

                    Size sizeText = new Size(formtxt.Width, formtxt.Height);
                    dc.DrawText(formtxt, new Point(_leftMargin, top));
                    top += sizeText.Height;

                    if (isPrintQrCode)
                    {
                        var image = GetCode(orderNumber);

                        BitmapImage imgSrc = new BitmapImage();
                        imgSrc.BeginInit();
                        imgSrc.StreamSource = new MemoryStream(ImageToByte(image));
                        imgSrc.EndInit();

                        dc.DrawImage(imgSrc, new Rect(new Point(_leftMargin, top), new Point(_leftMargin + 200, 225 + top)));
                        top += 225;
                    }

                    if (isToGo)
                    {
                        FormattedText formattedTextToGo = new FormattedText(
                            Environment.NewLine + "TAKE OUT" + Environment.NewLine,
                            CultureInfo.CurrentCulture,
                            FlowDirection.LeftToRight,
                            new Typeface(new FontFamily("GenericMonospace"),
                                         FontStyles.Normal, FontWeights.Bold,
                                         FontStretches.Normal),
                            36, Brushes.Black);
                        dc.DrawText(formattedTextToGo, new Point(_leftMargin, top));
                        Size sizeTextToGo = new Size(formattedTextToGo.Width, formattedTextToGo.Height);
                        top += sizeTextToGo.Height;
                    }

                    if (isWalkUp)
                    {
                        FormattedText formattedTextWalkUp = new FormattedText(
                            Environment.NewLine + "WALK UP" + Environment.NewLine + Environment.NewLine,
                            CultureInfo.CurrentCulture,
                            FlowDirection.LeftToRight,
                            new Typeface(new FontFamily("GenericMonospace"),
                                         FontStyles.Normal, FontWeights.Bold,
                                         FontStretches.Normal),
                            36, Brushes.Black);
                        dc.DrawText(formattedTextWalkUp, new Point(_leftMargin, top));
                    }
                    if (!string.IsNullOrEmpty(footer))
                    {
                        FormattedText footerText = new FormattedText(
                            footer,
                            CultureInfo.CurrentCulture,
                            FlowDirection.LeftToRight,
                            new Typeface(new FontFamily("GenericMonospace"),
                                         FontStyles.Normal, FontWeights.Bold,
                                         FontStretches.Normal),
                            12, Brushes.Black);

                        dc.DrawText(footerText, new Point(_leftMargin, top));
                    }
                    dc.Close();

                    switch (dlg.PrintTicket.PageOrientation)
                    {
                    case PageOrientation.Landscape:
                        vis.Transform =
                            new RotateTransform(-90, dlg.PrintableAreaWidth / 2,
                                                dlg.PrintableAreaWidth / 2);
                        break;

                    case PageOrientation.ReversePortrait:
                        vis.Transform =
                            new RotateTransform(180, dlg.PrintableAreaWidth / 2,
                                                dlg.PrintableAreaHeight / 2);
                        break;

                    case PageOrientation.ReverseLandscape:
                        vis.Transform =
                            new RotateTransform(90, dlg.PrintableAreaHeight / 2,
                                                dlg.PrintableAreaHeight / 2);
                        break;
                    }

                    // Finally, print the page.
                    dlg.PrintVisual(vis, "BB Copy");
                }
            }
            catch (Exception ex)
            {
                MessageBox.Show(ex.Message);
            }
        }
Beispiel #19
0
 private void PrintOnClick(object sender, RoutedEventArgs e)
 {
     var printDialog = new System.Windows.Controls.PrintDialog();
     if (printDialog.ShowDialog() == true)
     {
         printDialog.PrintVisual(GraphLayout, "Graph");
     }
 }