コード例 #1
0
ファイル: PrintManager.cs プロジェクト: Askarov5/ZContact
        //Print DataGrid
        public void Print_DataGrid(DataGrid dataGrid, string title)
        {
            PrintDialog Printdlg = new PrintDialog();

            if ((bool)Printdlg.ShowDialog().GetValueOrDefault())
            {
                Size pageSize = new Size(Printdlg.PrintableAreaWidth, Printdlg.PrintableAreaHeight);
                // sizing of the element.
                dataGrid.Measure(pageSize);
                dataGrid.Arrange(new Rect(5, 5, pageSize.Width, pageSize.Height));
                Printdlg.PrintVisual(dataGrid, title);
            }
        }
コード例 #2
0
ファイル: PrintUtils.cs プロジェクト: AsmisAlan/INTI
        public static void PrintDataGrid(DataGrid dataGrid, string title)
        {
            var printDialog = new PrintDialog();

            if (printDialog.ShowDialog().Value)
            {
                var pagesize = new Size(printDialog.PrintableAreaWidth, printDialog.PrintableAreaHeight);

                dataGrid.Measure(pagesize);

                dataGrid.Arrange(new Rect(5, 5, pagesize.Width, pagesize.Height));

                printDialog.PrintVisual(dataGrid, title);
            }
        }
コード例 #3
0
        public void PrintCardsDirectly(object cards)
        {
            // Create a PrintDialog
            PrintDialog printDlg = new PrintDialog();
            //casts the object cards to DataGrid
            DataGrid dg = cards as DataGrid;

            // sets Font Size
            dg.FontSize = fontSize;

            //prepares a formatted page
            FormatPrintDialoge(printDlg);

            //centering the DataGrid to the page
            Size pageSize = new Size(printDlg.PrintableAreaWidth, printDlg.PrintableAreaHeight + 300);

            dg.Arrange(new Rect(15, 15, pageSize.Height, pageSize.Width));

            // Call PrintDocument method to send document to printer
            printDlg.PrintVisual(dg, "GridPrinting");
        }