public PreviewPageInfo[] GetPreviewPageInfo()
        {
            var temp = new PreviewPageInfo[_list.Count];

            _list.CopyTo(temp, 0);
            return(temp);
        }
 public PreviewPageInfo[] GetPreviewPageInfo()
 {
     this.CheckSecurity();
     PreviewPageInfo[] array = new PreviewPageInfo[this.list.Count];
     this.list.CopyTo(array, 0);
     return(array);
 }
        /// <include file='doc\PreviewPrintController.uex' path='docs/doc[@for="PreviewPrintController.OnStartPage"]/*' />
        /// <devdoc>
        ///    <para>
        ///       Implements StartEnd for generating print preview information.
        ///    </para>
        /// </devdoc>
        public override Graphics OnStartPage(PrintDocument document, PrintPageEventArgs e)
        {
            Debug.Assert(dc != IntPtr.Zero && graphics == null, "PrintController methods called in the wrong order?");

            // For security purposes, don't assume our public methods methods are called in any particular order
            CheckSecurity();

            base.OnStartPage(document, e);

            IntSecurity.AllPrintingAndUnmanagedCode.Assert();

            e.PageSettings.CopyToHdevmode(modeHandle);
            Size size = e.PageBounds.Size;

            // Metafile framing rectangles apparently use hundredths of mm as their unit of measurement,
            // instead of the GDI+ standard hundredth of an inch.
            Size     metafileSize = PrinterUnitConvert.Convert(size, PrinterUnit.Display, PrinterUnit.HundredthsOfAMillimeter);
            Metafile metafile     = new Metafile(dc, new Rectangle(0, 0, metafileSize.Width, metafileSize.Height));

            PreviewPageInfo info = new PreviewPageInfo(metafile, size);

            list.Add(info);
            graphics = Graphics.FromImage(metafile);

            if (antiAlias)
            {
                graphics.TextRenderingHint = TextRenderingHint.AntiAlias;
                graphics.SmoothingMode     = SmoothingMode.AntiAlias;
            }

            return(graphics);
        }
 public PreviewPageInfo[] GetPreviewPageInfo()
 {
     this.CheckSecurity();
     PreviewPageInfo[] array = new PreviewPageInfo[this.list.Count];
     this.list.CopyTo(array, 0);
     return array;
 }
Exemplo n.º 5
0
        /// <include file='doc\PreviewPrintController.uex' path='docs/doc[@for="PreviewPrintController.GetPreviewPageInfo"]/*' />
        /// <devdoc>
        ///    <para>
        ///       The "printout".
        ///    </para>
        /// </devdoc>
        public PreviewPageInfo[] GetPreviewPageInfo()
        {
            // For security purposes, don't assume our public methods methods are called in any particular order
            CheckSecurity();

            PreviewPageInfo[] temp = new PreviewPageInfo[list.Count];
            list.CopyTo(temp, 0);
            return(temp);
        }
Exemplo n.º 6
0
        /// <summary>
        /// Implements StartEnd for generating print preview information.
        /// </summary>
        public override Graphics OnStartPage(PrintDocument document, PrintPageEventArgs e)
        {
            base.OnStartPage(document, e);

            if (e.CopySettingsToDevMode)
            {
                e.PageSettings.CopyToHdevmode(_modeHandle);
            }

            Size size = e.PageBounds.Size;

            // Metafile framing rectangles apparently use hundredths of mm as their unit of measurement,
            // instead of the GDI+ standard hundredth of an inch.
            Size metafileSize = PrinterUnitConvert.Convert(size, PrinterUnit.Display, PrinterUnit.HundredthsOfAMillimeter);

            // Create a Metafile which accepts only GDI+ commands since we are the ones creating
            // and using this ...
            // Framework creates a dual-mode EMF for each page in the preview.
            // When these images are displayed in preview,
            // they are added to the dual-mode EMF. However,
            // GDI+ breaks during this process if the image
            // is sufficiently large and has more than 254 colors.
            // This code path can easily be avoided by requesting
            // an EmfPlusOnly EMF..
            Metafile metafile = new Metafile(_dc.Hdc, new Rectangle(0, 0, metafileSize.Width, metafileSize.Height), MetafileFrameUnit.GdiCompatible, EmfType.EmfPlusOnly);

            PreviewPageInfo info = new PreviewPageInfo(metafile, size);

            _list.Add(info);
            PrintPreviewGraphics printGraphics = new PrintPreviewGraphics(document, e);

            _graphics = Graphics.FromImage(metafile);

            if (_graphics != null && document.OriginAtMargins)
            {
                // Adjust the origin of the graphics object to be at the
                // user-specified margin location
                int   dpiX           = UnsafeNativeMethods.GetDeviceCaps(new HandleRef(_dc, _dc.Hdc), SafeNativeMethods.LOGPIXELSX);
                int   dpiY           = UnsafeNativeMethods.GetDeviceCaps(new HandleRef(_dc, _dc.Hdc), SafeNativeMethods.LOGPIXELSY);
                int   hardMarginX_DU = UnsafeNativeMethods.GetDeviceCaps(new HandleRef(_dc, _dc.Hdc), SafeNativeMethods.PHYSICALOFFSETX);
                int   hardMarginY_DU = UnsafeNativeMethods.GetDeviceCaps(new HandleRef(_dc, _dc.Hdc), SafeNativeMethods.PHYSICALOFFSETY);
                float hardMarginX    = hardMarginX_DU * 100 / dpiX;
                float hardMarginY    = hardMarginY_DU * 100 / dpiY;

                _graphics.TranslateTransform(-hardMarginX, -hardMarginY);
                _graphics.TranslateTransform(document.DefaultPageSettings.Margins.Left, document.DefaultPageSettings.Margins.Top);
            }

            _graphics.PrintingHelper = printGraphics;

            if (UseAntiAlias)
            {
                _graphics.TextRenderingHint = TextRenderingHint.AntiAlias;
                _graphics.SmoothingMode     = SmoothingMode.AntiAlias;
            }
            return(_graphics);
        }
Exemplo n.º 7
0
		public override Graphics OnStartPage(PrintDocument document, PrintPageEventArgs e)
		{
			Image image = new Bitmap (e.PageSettings.PaperSize.Width, e.PageSettings.PaperSize.Height);

			PreviewPageInfo info = new PreviewPageInfo (image, new Size (e.PageSettings.PaperSize.Width,
										     e.PageSettings.PaperSize.Height));
			
			pageInfoList.Add (info);

			Graphics g = Graphics.FromImage (info.Image);
			g.FillRectangle (new SolidBrush (Color.White), new Rectangle (new Point (0,0), new Size (image.Width, image.Height)));

			return g;
		}
        public override Graphics OnStartPage(PrintDocument document, PrintPageEventArgs e)
        {
            Image image = new Bitmap(e.PageSettings.PaperSize.Width, e.PageSettings.PaperSize.Height);

            PreviewPageInfo info = new PreviewPageInfo(image, new Size(e.PageSettings.PaperSize.Width,
                                             e.PageSettings.PaperSize.Height));

            pageInfoList.Add(info);

            Graphics g = Graphics.FromImage(info.Image);
            g.FillRectangle(new SolidBrush(Color.White), new Rectangle(new Point(0, 0), new Size(image.Width, image.Height)));

            return g;
        }
 public override Graphics OnStartPage(PrintDocument document, PrintPageEventArgs e)
 {
     this.CheckSecurity();
     base.OnStartPage(document, e);
     try
     {
         IntSecurity.AllPrintingAndUnmanagedCode.Assert();
         e.PageSettings.CopyToHdevmode((IntPtr)base.modeHandle);
         Size            size  = e.PageBounds.Size;
         Size            size2 = PrinterUnitConvert.Convert(size, PrinterUnit.Display, PrinterUnit.HundredthsOfAMillimeter);
         Metafile        image = new Metafile(this.dc.Hdc, new Rectangle(0, 0, size2.Width, size2.Height), MetafileFrameUnit.GdiCompatible, EmfType.EmfPlusOnly);
         PreviewPageInfo info  = new PreviewPageInfo(image, size);
         this.list.Add(info);
         PrintPreviewGraphics graphics = new PrintPreviewGraphics(document, e);
         this.graphics = Graphics.FromImage(image);
         if ((this.graphics != null) && document.OriginAtMargins)
         {
             int   deviceCaps = UnsafeNativeMethods.GetDeviceCaps(new HandleRef(this.dc, this.dc.Hdc), 0x58);
             int   num2       = UnsafeNativeMethods.GetDeviceCaps(new HandleRef(this.dc, this.dc.Hdc), 90);
             int   num3       = UnsafeNativeMethods.GetDeviceCaps(new HandleRef(this.dc, this.dc.Hdc), 0x70);
             int   num4       = UnsafeNativeMethods.GetDeviceCaps(new HandleRef(this.dc, this.dc.Hdc), 0x71);
             float num5       = (num3 * 100) / deviceCaps;
             float num6       = (num4 * 100) / num2;
             this.graphics.TranslateTransform(-num5, -num6);
             this.graphics.TranslateTransform((float)document.DefaultPageSettings.Margins.Left, (float)document.DefaultPageSettings.Margins.Top);
         }
         this.graphics.PrintingHelper = graphics;
         if (this.antiAlias)
         {
             this.graphics.TextRenderingHint = TextRenderingHint.AntiAlias;
             this.graphics.SmoothingMode     = SmoothingMode.AntiAlias;
         }
     }
     finally
     {
         CodeAccessPermission.RevertAssert();
     }
     return(this.graphics);
 }
 public override Graphics OnStartPage(PrintDocument document, PrintPageEventArgs e)
 {
     this.CheckSecurity();
     base.OnStartPage(document, e);
     try
     {
         IntSecurity.AllPrintingAndUnmanagedCode.Assert();
         e.PageSettings.CopyToHdevmode((IntPtr) base.modeHandle);
         Size size = e.PageBounds.Size;
         Size size2 = PrinterUnitConvert.Convert(size, PrinterUnit.Display, PrinterUnit.HundredthsOfAMillimeter);
         Metafile image = new Metafile(this.dc.Hdc, new Rectangle(0, 0, size2.Width, size2.Height), MetafileFrameUnit.GdiCompatible, EmfType.EmfPlusOnly);
         PreviewPageInfo info = new PreviewPageInfo(image, size);
         this.list.Add(info);
         PrintPreviewGraphics graphics = new PrintPreviewGraphics(document, e);
         this.graphics = Graphics.FromImage(image);
         if ((this.graphics != null) && document.OriginAtMargins)
         {
             int deviceCaps = UnsafeNativeMethods.GetDeviceCaps(new HandleRef(this.dc, this.dc.Hdc), 0x58);
             int num2 = UnsafeNativeMethods.GetDeviceCaps(new HandleRef(this.dc, this.dc.Hdc), 90);
             int num3 = UnsafeNativeMethods.GetDeviceCaps(new HandleRef(this.dc, this.dc.Hdc), 0x70);
             int num4 = UnsafeNativeMethods.GetDeviceCaps(new HandleRef(this.dc, this.dc.Hdc), 0x71);
             float num5 = (num3 * 100) / deviceCaps;
             float num6 = (num4 * 100) / num2;
             this.graphics.TranslateTransform(-num5, -num6);
             this.graphics.TranslateTransform((float) document.DefaultPageSettings.Margins.Left, (float) document.DefaultPageSettings.Margins.Top);
         }
         this.graphics.PrintingHelper = graphics;
         if (this.antiAlias)
         {
             this.graphics.TextRenderingHint = TextRenderingHint.AntiAlias;
             this.graphics.SmoothingMode = SmoothingMode.AntiAlias;
         }
     }
     finally
     {
         CodeAccessPermission.RevertAssert();
     }
     return this.graphics;
 }
Exemplo n.º 11
0
        public override Graphics OnStartPage(PrintDocument document, PrintPageEventArgs e) {
            Debug.Assert(dc != null && graphics == null, "PrintController methods called in the wrong order?");

            // For security purposes, don't assume our public methods methods are called in any particular order
            CheckSecurity();

            base.OnStartPage(document, e);

            
            try {
                IntSecurity.AllPrintingAndUnmanagedCode.Assert();
                e.PageSettings.CopyToHdevmode(modeHandle);
                Size size = e.PageBounds.Size;

                // Metafile framing rectangles apparently use hundredths of mm as their unit of measurement,
                // instead of the GDI+ standard hundredth of an inch.
                Size metafileSize = PrinterUnitConvert.Convert(size, PrinterUnit.Display, PrinterUnit.HundredthsOfAMillimeter);

                // Create a Metafile which accepts only GDI+ commands since we are the ones creating
                // and using this ...
                // Framework creates a dual-mode EMF for each page in the preview. 
                // When these images are displayed in preview, 
                // they are added to the dual-mode EMF. However, 
                // GDI+ breaks during this process if the image 
                // is sufficiently large and has more than 254 colors. 
                // This code path can easily be avoided by requesting
                // an EmfPlusOnly EMF..
                Metafile metafile = new Metafile(dc.Hdc, new Rectangle(0,0, metafileSize.Width, metafileSize.Height), MetafileFrameUnit.GdiCompatible, EmfType.EmfPlusOnly);
    
                PreviewPageInfo info = new PreviewPageInfo(metafile, size);
                list.Add(info);
                PrintPreviewGraphics printGraphics = new PrintPreviewGraphics(document, e);
                graphics = Graphics.FromImage(metafile);

                if (graphics != null && document.OriginAtMargins) {
                    
                    // Adjust the origin of the graphics object to be at the
                    // user-specified margin location
                    //
                    int dpiX = UnsafeNativeMethods.GetDeviceCaps(new HandleRef(dc, dc.Hdc), SafeNativeMethods.LOGPIXELSX);
                    int dpiY = UnsafeNativeMethods.GetDeviceCaps(new HandleRef(dc, dc.Hdc), SafeNativeMethods.LOGPIXELSY);
                    int hardMarginX_DU = UnsafeNativeMethods.GetDeviceCaps(new HandleRef(dc, dc.Hdc), SafeNativeMethods.PHYSICALOFFSETX);
                    int hardMarginY_DU = UnsafeNativeMethods.GetDeviceCaps(new HandleRef(dc, dc.Hdc), SafeNativeMethods.PHYSICALOFFSETY);                
                    float hardMarginX = hardMarginX_DU * 100 / dpiX;
                    float hardMarginY = hardMarginY_DU * 100 / dpiY;
                    
                    graphics.TranslateTransform(-hardMarginX, -hardMarginY);
                    graphics.TranslateTransform(document.DefaultPageSettings.Margins.Left, document.DefaultPageSettings.Margins.Top);
                }


                graphics.PrintingHelper = printGraphics;
                
    
                if (antiAlias) {
                    graphics.TextRenderingHint = TextRenderingHint.AntiAlias;
                    graphics.SmoothingMode = SmoothingMode.AntiAlias;
                }
            }
            finally {
                CodeAccessPermission.RevertAssert();
            }
            return graphics;
        }
Exemplo n.º 12
0
        /// <include file='doc\PreviewPrintController.uex' path='docs/doc[@for="PreviewPrintController.GetPreviewPageInfo"]/*' />
        /// <devdoc>
        ///    <para>
        ///       The "printout".
        ///    </para>
        /// </devdoc>
        public PreviewPageInfo[] GetPreviewPageInfo() {
            // For security purposes, don't assume our public methods methods are called in any particular order
            CheckSecurity();

            PreviewPageInfo[] temp = new PreviewPageInfo[list.Count];
            list.CopyTo(temp, 0);
            return temp;
        }
 private void InvalidatePreview()
 {
     m_currentPreviewPage = null;
       this.InvalidateLayout();
 }
        private void GeneratePreview()
        {
            m_currentPreviewPage = null;

              PrintDocument document = this.PrintDocument;

              if( document == null )
            return;

              PrintController oldController = document.PrintController;

              try
              {
            Cursor.Current = Cursors.WaitCursor;

            PreviewPrintController controller = new PreviewPrintController();

            document.PrintController = controller;
            document.PrintPage += new PrintPageEventHandler( document_PrintPage );
            document.Print();
            document.PrintPage -= new PrintPageEventHandler( document_PrintPage );

            PreviewPageInfo[] pages = controller.GetPreviewPageInfo();

            m_currentPreviewPage = pages[ 0 ];
              }
              finally
              {
            document.PrintController = oldController;
            Cursor.Current = Cursors.Default;
              }
        }
Exemplo n.º 15
0
		public PreviewPageInfo [] GetPreviewPageInfo()
		{
			PreviewPageInfo [] pi = new PreviewPageInfo[pageInfoList.Count];
			pageInfoList.CopyTo (pi);
			return pi;
		}
 public PreviewPageInfo[] GetPreviewPageInfo()
 {
     PreviewPageInfo[] pi = new PreviewPageInfo[pageInfoList.Count];
     pageInfoList.CopyTo(pi);
     return(pi);
 }