コード例 #1
0
        private async void OnPrint(object sender, RoutedEventArgs e)
        {
            var opt = new PrintHelperOptions
            {
                Orientation = PrintOrientation.Landscape,
                Bordering   = PrintBordering.Borderless,
            };

            _printHelper = new PrintHelper(PrintCanvas, opt);
            _printHelper.OnPrintSucceeded += OnPrintSucceeded;
            _printHelper.OnPrintFailed    += OnPrintFailed;

            foreach (var receptionGroup in ViewModel.ReceptionGroups)
            {
                foreach (var reception in receptionGroup.Receptions)
                {
                    var doc = new ReceptionPrint
                    {
                        ReceptionName = reception.ReceptionName,
                        WeekAsText    = ViewModel.DisplayedWeekAsText,
                        Days          = reception.Days
                    };
                    _printHelper.AddFrameworkElementToPrint(doc);
                }
            }

            await _printHelper.ShowPrintUIAsync(Txt.GetString("Title_PrintReceptions"));
        }
コード例 #2
0
        public async Task Print(Page page, string title)
        {
            _printHelper = new PrintHelper(_panel);
            _printHelper.OnPrintSucceeded += OnPrintSucceeded;
            _printHelper.OnPrintFailed    += OnPrintFailed;

            _printHelper.AddFrameworkElementToPrint(page);
            var opt = new PrintHelperOptions(false)
            {
                Orientation = PrintOrientation.Landscape
            };
            await _printHelper.ShowPrintUIAsync(title, opt);
        }
        private async void btnPrint_Click(object sender, RoutedEventArgs e)
        {
            DocumentExternalVerification form = new DocumentExternalVerification(new PlantDeposit().GetFurtherVerifyDepositReport());

            printHelper = new PrintHelper(this.PrintContainer);
            printHelper.AddFrameworkElementToPrint(form);

            var printHelperOptions = new PrintHelperOptions(false);

            printHelperOptions.Orientation = PrintOrientation.Portrait;

            await printHelper.ShowPrintUIAsync("Herbarium Management IS - List of New Deposits", printHelperOptions);

            //printHelper.PreparePrintContent(new DocumentNewDeposit());
        }
        private async void btnPrintC_Click(object sender, RoutedEventArgs e)
        {
            DocumentDamageReturnsByLoan form = new DocumentDamageReturnsByLoan(
                new HerbariumSheet().GetDamagedSheetReportByLoan(SelectedLoan));

            printHelper = new PrintHelper(this.PrintContainer);
            printHelper.AddFrameworkElementToPrint(form);

            var printHelperOptions = new PrintHelperOptions(false);

            printHelperOptions.Orientation = PrintOrientation.Portrait;

            await printHelper.ShowPrintUIAsync("Herbarium Management IS - List of New Deposits", printHelperOptions);

            //printHelper.PreparePrintContent(new DocumentNewDeposit());
        }
コード例 #5
0
        private async void PrintButton_Click(object sender, RoutedEventArgs e)
        {
            _printHelper = new PrintHelper(Container);
            panelToPrint = RootPanel;
            Container.Children.Remove(panelToPrint);

            _printHelper.AddFrameworkElementToPrint(panelToPrint);

            var printHelperOptions = new PrintHelperOptions(false);

            printHelperOptions.Orientation = Windows.Graphics.Printing.PrintOrientation.Portrait;

            _printHelper.OnPrintCanceled  += PrintHelper_OnPrintCanceled;
            _printHelper.OnPrintFailed    += PrintHelper_OnPrintFailed;
            _printHelper.OnPrintSucceeded += PrintHelper_OnPrintSucceeded;

            await _printHelper.ShowPrintUIAsync("Print order", printHelperOptions);
        }
        private async void btnPrint_Click(object sender, RoutedEventArgs e)
        {
            DocumentVerifiedDeposit form = new DocumentVerifiedDeposit(new HerbariumSheet().GetVerifiedDepositReport(MonthStart.ToString(), MonthEnd.ToString()))
            {
                Year  = MonthStart.Year,
                Month = Months[MonthStart.Month - 1],
            };

            printHelper = new PrintHelper(this.PrintContainer);
            printHelper.AddFrameworkElementToPrint(form);

            var printHelperOptions = new PrintHelperOptions(false);

            printHelperOptions.Orientation = PrintOrientation.Portrait;

            await printHelper.ShowPrintUIAsync("Herbarium Management IS - List of Verified Deposits", printHelperOptions);

            //printHelper.PreparePrintContent(new DocumentNewDeposit());
        }
コード例 #7
0
        private async void DirectPrint_Click(object sender, Windows.UI.Xaml.RoutedEventArgs e)
        {
            SampleController.Current.DisplayWaitRing = true;

            _printHelper = new PrintHelper(DirectPrintContainer);

            _printHelper.OnPrintCanceled  += PrintHelper_OnPrintCanceled;
            _printHelper.OnPrintFailed    += PrintHelper_OnPrintFailed;
            _printHelper.OnPrintSucceeded += PrintHelper_OnPrintSucceeded;

            var printHelperOptions = new PrintHelperOptions(false);

            printHelperOptions.Orientation = (PrintOrientation)DefaultOrientationComboBox.SelectedItem;

            if (ShowOrientationSwitch.IsOn)
            {
                printHelperOptions.AddDisplayOption(StandardPrintTaskOptions.Orientation);
            }

            await _printHelper.ShowPrintUIAsync("Windows Community Toolkit Sample App", printHelperOptions, true);
        }
コード例 #8
0
        private async void OnPrint(object sender, Windows.UI.Xaml.RoutedEventArgs e)
        {
            var opt = new PrintHelperOptions
            {
                Orientation = PrintOrientation.Landscape
            };

            _printHelper = new PrintHelper(PrintCanvas, opt);
            _printHelper.OnPrintSucceeded += OnPrintSucceeded;
            _printHelper.OnPrintFailed    += OnPrintFailed;

            var doc = new TeamPrint
            {
                WeekAsText = ViewModel.DisplayedWeekAsText,
                Days       = GroupList.ItemsSource as IEnumerable <DayModel>
            };

            _printHelper.AddFrameworkElementToPrint(doc);

            await _printHelper.ShowPrintUIAsync(Txt.GetString("Title_PrintPickupRounds"));
        }
コード例 #9
0
        private async void Print_Click(object sender, Windows.UI.Xaml.RoutedEventArgs e)
        {
            Shell.Current.DisplayWaitRing = true;

            DirectPrintContainer.Children.Remove(PrintableContent);

            _printHelper = new PrintHelper(Container);
            _printHelper.AddFrameworkElementToPrint(PrintableContent);

            _printHelper.OnPrintCanceled  += PrintHelper_OnPrintCanceled;
            _printHelper.OnPrintFailed    += PrintHelper_OnPrintFailed;
            _printHelper.OnPrintSucceeded += PrintHelper_OnPrintSucceeded;

            var printHelperOptions = new PrintHelperOptions(false);

            printHelperOptions.Orientation = (PrintOrientation)DefaultOrientationComboBox.SelectedItem;

            if (ShowOrientationCheckBox.IsChecked.HasValue && ShowOrientationCheckBox.IsChecked.Value)
            {
                printHelperOptions.AddDisplayOption(StandardPrintTaskOptions.Orientation);
            }

            await _printHelper.ShowPrintUIAsync("UWP Community Toolkit Sample App", printHelperOptions);
        }
コード例 #10
0
        private async void CustomPrint_Click(object sender, Windows.UI.Xaml.RoutedEventArgs e)
        {
            if (customPrintTemplate == null)
            {
                var dialog = new MessageDialog("Could not find the data template resource called 'CustomPrintTemplate' under the listview called 'PrintSampleListView'.", "Incomplete XAML");
                await dialog.ShowAsync();

                return;
            }

            SampleController.Current.DisplayWaitRing = true;

            // Provide an invisible container
            _printHelper = new PrintHelper(CustomPrintContainer);

            var pageNumber = 0;

            foreach (var item in PrintSampleItems)
            {
                var grid = new Grid();
                grid.RowDefinitions.Add(new RowDefinition()
                {
                    Height = GridLength.Auto
                });
                grid.RowDefinitions.Add(new RowDefinition()
                {
                    Height = new GridLength(1, GridUnitType.Star)
                });
                grid.RowDefinitions.Add(new RowDefinition()
                {
                    Height = GridLength.Auto
                });

                // Static header
                var header = new TextBlock {
                    Text = "Windows Community Toolkit Sample App - Print Helper - Custom Print", Margin = new Thickness(0, 0, 0, 20)
                };
                Grid.SetRow(header, 0);
                grid.Children.Add(header);

                // Main content with layout from data template
                var cont = new ContentControl();
                cont.ContentTemplate = customPrintTemplate;
                cont.DataContext     = item;
                Grid.SetRow(cont, 1);
                grid.Children.Add(cont);

                // Footer with page number
                pageNumber++;
                var footer = new TextBlock {
                    Text = string.Format("page {0}", pageNumber), Margin = new Thickness(0, 20, 0, 0)
                };
                Grid.SetRow(footer, 2);
                grid.Children.Add(footer);

                _printHelper.AddFrameworkElementToPrint(grid);
            }

            _printHelper.OnPrintCanceled  += PrintHelper_OnPrintCanceled;
            _printHelper.OnPrintFailed    += PrintHelper_OnPrintFailed;
            _printHelper.OnPrintSucceeded += PrintHelper_OnPrintSucceeded;

            var printHelperOptions = new PrintHelperOptions(false);

            printHelperOptions.Orientation = (PrintOrientation)DefaultOrientationComboBox.SelectedItem;

            if (ShowOrientationSwitch.IsOn)
            {
                printHelperOptions.AddDisplayOption(StandardPrintTaskOptions.Orientation);
            }

            await _printHelper.ShowPrintUIAsync("Windows Community Toolkit Sample App", printHelperOptions);
        }
コード例 #11
0
ファイル: MainPage.xaml.cs プロジェクト: ypsilondev/SyncBoard
        // Print PDF
        private async void Printer_Click(object sender, RoutedEventArgs e)
        {
            // Calculate amount of required pages
            int pageCount = (int)inkCanvas.ActualHeight / PAGE_HEIGHT + 1;

            // Clear the print-canvas
            PrintCanvas.Children.Clear();

            // Setup the required pages
            List <Panel> pagePanels = new List <Panel>();

            for (int i = 0; i < pageCount; i++)
            {
                pagePanels.Add(new ItemsStackPanel());
            }

            // Paint background PFDs
            foreach (Viewbox pdfSite in imports.Children)
            {
                int page       = (int)(pdfSite.Translation.Y / PAGE_HEIGHT);
                int pageOffset = 0;

                while (pdfSite.Translation.Y + PAGE_HEIGHT > PAGE_HEIGHT * (page + pageOffset))
                {
                    Image img = (Image)pdfSite.Child;

                    Viewbox v = new Viewbox()
                    {
                        Child = new Image()
                        {
                            Source    = img.Source,
                            Margin    = new Thickness(0, 0, 0, 0),
                            MaxWidth  = PRINT_RECTANGLE_WIDTH,
                            MaxHeight = PRINT_RECTANGLE_HEIGHT
                        }
                    };

                    pagePanels[page + pageOffset].Children.Add(v);
                    pageOffset++;
                }
            }

            // Paint the strokes to the pages
            foreach (var stroke in inkCanvas.InkPresenter.StrokeContainer.GetStrokes())
            {
                int page       = (int)(stroke.BoundingRect.Top / PAGE_HEIGHT);
                int pageOffset = 0;

                while (stroke.BoundingRect.Bottom > PAGE_HEIGHT * (page + pageOffset))
                {
                    var polyLine = this.CreatePolyLineFromStroke(stroke);
                    //polyLine2.Translation = new Vector3(0, -PAGE_HEIGHT * (page + 1), 0);
                    this.TranslatePolyLineToPage(polyLine, page + pageOffset);
                    pagePanels[page + pageOffset].Children.Add(polyLine);
                    pageOffset++;
                }
            }

            // Add all pages to the output (except blanks)
            for (int i = 0; i < pageCount; i++)
            {
                if (pagePanels[i].Children.Count > 0)
                {
                    PrintCanvas.Children.Add(pagePanels[i]);
                }
            }

            // Open print-GUI
            try
            {
                var _printHelper       = new PrintHelper(PrintCanvas);
                var printHelperOptions = new PrintHelperOptions();
                printHelperOptions.AddDisplayOption(StandardPrintTaskOptions.Orientation);
                printHelperOptions.Orientation = PrintOrientation.Portrait;

                await _printHelper.ShowPrintUIAsync("SyncBoard Print", printHelperOptions, true);
            }
            catch (Exception ignored)
            {
            }
        }
コード例 #12
0
        private async void AppBarButton_Print_Click(object sender, RoutedEventArgs e)
        {
            try
            {
                var defaultPrintHelperOptions = new PrintHelperOptions()
                {
                    Orientation = PrintOrientation.Portrait
                };
                defaultPrintHelperOptions.AddDisplayOption(StandardPrintTaskOptions.Orientation);

                printHelper = new PrintHelper(Container, defaultPrintHelperOptions);

                var grid = new Grid()
                {
                    Height              = Grid_InkCanvas.Height,
                    Width               = Grid_InkCanvas.Width,
                    Margin              = Grid_InkCanvas.Margin,
                    BorderThickness     = Grid_InkCanvas.BorderThickness,
                    HorizontalAlignment = HorizontalAlignment.Stretch,
                    VerticalAlignment   = VerticalAlignment.Stretch
                };

                var rtb = new RenderTargetBitmap();
                await rtb.RenderAsync(Grid_InkCanvas);

                IBuffer pixelBuffer = await rtb.GetPixelsAsync();

                byte[] pixels = pixelBuffer.ToArray();

                DisplayInformation displayInformation = DisplayInformation.GetForCurrentView();

                var           stream  = new InMemoryRandomAccessStream();
                BitmapEncoder encoder = await BitmapEncoder.CreateAsync(BitmapEncoder.PngEncoderId, stream);

                encoder.SetPixelData(BitmapPixelFormat.Bgra8, BitmapAlphaMode.Premultiplied, (uint)rtb.PixelWidth, (uint)rtb.PixelHeight, displayInformation.RawDpiX, displayInformation.RawDpiY, pixels);

                await encoder.FlushAsync(); stream.Seek(0);

                BitmapImage bimg = new BitmapImage();
                await bimg.SetSourceAsync(stream);

                Image img = new Image()
                {
                    Width  = Grid_InkCanvas.Width,
                    Height = Grid_InkCanvas.Height,
                    Source = bimg
                };

                Viewbox vb = new Viewbox()
                {
                    Child = grid
                };

                grid.Children.Add(img);

                printHelper.AddFrameworkElementToPrint(vb);

                printHelper.OnPrintFailed    += PrintHelper_OnPrintFailed;
                printHelper.OnPrintSucceeded += PrintHelper_OnPrintSucceeded;

                await printHelper.ShowPrintUIAsync("GeometrySketch");
            }
            catch { }
        }