예제 #1
0
        public override async void PrintForm()
        {
            if (CanvasContainer is null || DirectPrintContainer is null)
            {
                return;
            }

            _printPanels = PrintPanels;
            if (_printPanels is null || _printPanels.Count == 0)
            {
                return;
            }

            _printHelper = new PrintHelper(CanvasContainer);

            DirectPrintContainer.Children.Remove(_printPanels[0]);

            AddFooter();

            for (int i = 0; i < _printPanels.Count; i++)
            {
                _printHelper.AddFrameworkElementToPrint(_printPanels[i]);
            }

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

            await _printHelper.ShowPrintUIAsync("  ");
        }
        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"));
        }
예제 #3
0
        // Print coloring page.
        public async void Print_Click(object sender, RoutedEventArgs e)
        {
            StorageFolder folder = await ApplicationData.Current.LocalFolder.CreateFolderAsync("PrintImageFolder", CreationCollisionOption.ReplaceExisting);

            StorageFile printFile = await folder.CreateFileAsync("printFile.png", CreationCollisionOption.ReplaceExisting);

            await Save_InkedImagetoFile(printFile);


            var stream = await printFile.OpenReadAsync();

            var bitmapImage = new BitmapImage();

            bitmapImage.SetSource(stream);
            printImage.Source = bitmapImage;

            if (DirectPrintContainer.Children.Contains(PrintableContent))
            {
                DirectPrintContainer.Children.Remove(PrintableContent);
            }
            printHelper = new PrintHelper(Container);
            printHelper.AddFrameworkElementToPrint(PrintableContent);

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


            await printHelper.ShowPrintUIAsync("Coloring book page");

            await folder.DeleteAsync(StorageDeleteOption.PermanentDelete);
        }
예제 #4
0
        private async void PrintButton_Click(object sender, RoutedEventArgs e)
        {
            Shell.Current.DisplayWaitRing = true;

            _printHelper = new PrintHelper(_container);
            _printHelper.AddFrameworkElementToPrint(await PrepareWebViewForPrintingAsync());

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

            await _printHelper.ShowPrintUIAsync("UWP Community Toolkit Sample App");
        }
예제 #5
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 Button_Click(object sender, Windows.UI.Xaml.RoutedEventArgs e)
        {
            Shell.Current.DisplayWaitRing = true;

            RootGrid.Children.Remove(PrintableContent);

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

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

            await _printHelper.ShowPrintUIAsync("UWP Community Toolkit Sample App");
        }
        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());
        }
예제 #9
0
        public void Print()
        {
            _printHelper = new PrintHelper(_printingContainer);

            PrintPage.StartPageNumber = 1;
            foreach (var content in _content)
            {
                var page = new PrintPage(content, _header, _footer, _pageNumbering);
                _printHelper.AddFrameworkElementToPrint(page);
            }

            _printHelper.OnPrintFailed    += printHelper_OnPrintFailed;
            _printHelper.OnPrintSucceeded += printHelper_OnPrintSucceeded;
            _printHelper.OnPrintCanceled  += printHelper_OnPrintCanceled;

            _printHelper.ShowPrintUIAsync("Print Sample");
        }
예제 #10
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());
        }
예제 #12
0
        private async void PrintButton_Click(object sender, RoutedEventArgs e)
        {
            Shell.Current.DisplayWaitRing = true;

            var printblock = new RichTextBlock
            {
                FontFamily = _codeView.FontFamily
            };

            _formatter.FormatRichTextBlock(_displayedText, _language, printblock);

            _printHelper = new PrintHelper(_container);
            _printHelper.AddFrameworkElementToPrint(printblock);

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

            await _printHelper.ShowPrintUIAsync("Windows Community Toolkit Sample App");
        }
예제 #13
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"));
        }
예제 #14
0
        private async void PrintButton_Click(object sender, RoutedEventArgs e)
        {
#if !HAS_UNO
            SampleController.Current.DisplayWaitRing = true;

            var printBlock = new RichTextBlock
            {
                FontFamily     = _codeView.FontFamily,
                RequestedTheme = ElementTheme.Light
            };
            var printFormatter = new RichTextBlockFormatter(ElementTheme.Light);
            printFormatter.FormatRichTextBlock(_displayedText, _language, printBlock);

            _printHelper = new PrintHelper(_container);
            _printHelper.AddFrameworkElementToPrint(printBlock);

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

            await _printHelper.ShowPrintUIAsync("Windows Community Toolkit Sample App");
#endif
        }
        private async void Print_Click(object sender, Windows.UI.Xaml.RoutedEventArgs e)
        {
            SampleController.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 (ShowOrientationSwitch.IsOn)
            {
                printHelperOptions.AddDisplayOption(StandardPrintTaskOptions.Orientation);
            }

            await _printHelper.ShowPrintUIAsync("Windows Community Toolkit Sample App", printHelperOptions);
        }
        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);
        }
예제 #17
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 { }
        }