Beispiel #1
0
 /// <summary>
 /// Handles the EndPrintImage event of the printDocument control.
 /// </summary>
 private void printDocument_EndPrintImage(object sender, PrintImageEventArgs e)
 {
     if (_disposeCurrentImageAfterUse)
     {
         e.Image.Dispose();
     }
 }
Beispiel #2
0
        /// <summary>
        /// Handles the PrintImage event of the printDocument control.
        /// </summary>
        private void printDocument_PrintImage(object sender, PrintImageEventArgs e)
        {
            // if there are images to print
            if (_imagesToPrint.Length > 0)
            {
                bool hasMoreImages = true;

                // get the printed image
                int imageIndex = _imagesToPrint[_printPageIndex];
                if (imageIndex >= _imageViewer.Images.Count)
                {
                    e.HasMoreImages = false;
                    return;
                }
                try
                {
                    e.Image = GetImage(imageIndex, out _disposeCurrentImageAfterUse);
                }
                catch (DecoderException)
                {
                    hasMoreImages = false;
                }
                // increment the count of printed pages
                _printPageIndex++;

                // check if there is more images to print
                if (hasMoreImages && (_printPageIndex >= _imagesToPrint.Length))
                {
                    hasMoreImages = false;
                }
                e.HasMoreImages = hasMoreImages;
            }
        }