private void PrintInternal(PrintParameters pp) { _docName = pp._docName; _scaleMode = pp._scaleMode; _margin = pp._margin; _maxPages = pp._maxPages; _pages = null; PrintDialog printDialog = new PrintDialog(); if (printDialog.ShowDialog().Value) { Size printSize = new Size(printDialog.PrintableAreaWidth, printDialog.PrintableAreaHeight); Size pageSize = new Size(printSize.Width - (_margin.Left + _margin.Right), printSize.Height - (_margin.Top + _margin.Bottom)); _pages = GetPageImages(_scaleMode, pageSize, _maxPages); if (_pages != null && _pages.Count > 0) { FlexPaginator flexPaginator = new FlexPaginator(this, printSize, _pages); printDialog.PrintDocument(flexPaginator, pp._docName); } } }
/// <summary> /// Prints the grid using a specified scale mode. /// </summary> /// <param name="docName">Name of the document to print.</param> /// <param name="scaleMode">How to scale the document to fit the pages.</param> /// <param name="margin">Margin around the page in pixels.</param> /// <param name="maxPages">The maximum number of pages to print.</param> public void Print(string docName, ScaleMode scaleMode, Thickness margin, int maxPages) { PrintParameters printParameter = new PrintParameters { _docName = docName, _scaleMode = scaleMode, _margin = margin, _maxPages = maxPages }; PrintInternal(printParameter); }