private void OnPageChanged()
        {
            // Ticket "Demo": Wenn das nicht gemacht wird und beim PrintPreviewWindow sehr schnell die Page-Orientation
            // geändert wird, kommt es im PrimtLayouter.SetMainContent zu einer Exception, da der mainContent
            // noch nicht wieder abgehängt ist.
            if (_xpsDocumentGenerator != null)
                _xpsDocumentGenerator.Dispose();

            int width, height;
            SelectedPaperFormat.PaperFormat.GetWidthAndHeight(
                SelectedPaperOrientation.PaperOrientation, out width, out height);
            _xpsDocumentGenerator = new XpsDocumentGenerator(
                _mainPrintContent,
                _additionalPrintContent,
                _viewDrawingState,
                width,
                height,
                SelectedPageMargin);
            _xpsDocumentGenerator.PrintingFinished += () =>
                {
                    Document = _xpsDocumentGenerator.PrintedDocument;
                };
            Document = TextDocumentGenerator.CreateDocument(width, height, MlResources.DocumentIsBeingGenerated);
            _xpsDocumentGenerator.Print();
        }
Ejemplo n.º 2
0
        public void Print()
        {
            if (_xpsDocumentGenerator != null)
                throw new InvalidOperationException("Cannot print twice!");

            _printDialog = new PrintDialog();
            _printDialog.PrintTicket.PageOrientation = PageOrientation.Landscape;
            if (_printDialog.ShowDialog() != true)
                return;

            var width = (int)_printDialog.PrintableAreaWidth;
            var height = (int)_printDialog.PrintableAreaHeight;
            _xpsDocumentGenerator = new XpsDocumentGenerator(
                _mainPrintContent, _additionalPrintContent, _viewDrawingState, width, height, _pageMargin);
            _xpsDocumentGenerator.StartPrinting += OnStartPrinting;
            _xpsDocumentGenerator.PrintingFinished += OnPrintingFinished;
            _xpsDocumentGenerator.Print();
        }
 public void Dispose()
 {
     if (_xpsDocumentGenerator != null)
         _xpsDocumentGenerator.Dispose();
     _xpsDocumentGenerator = null;
 }