예제 #1
0
 public override void OnEndPrint(PrintDocument document, PrintEventArgs e)
 {
     this.CheckSecurity(document);
     System.Drawing.IntSecurity.UnmanagedCode.Assert();
     try
     {
         if (this.dc != null)
         {
             try
             {
                 int num = e.Cancel ? SafeNativeMethods.AbortDoc(new HandleRef(this.dc, this.dc.Hdc)) : SafeNativeMethods.EndDoc(new HandleRef(this.dc, this.dc.Hdc));
                 if (num <= 0)
                 {
                     throw new Win32Exception();
                 }
             }
             finally
             {
                 this.dc.Dispose();
                 this.dc = null;
             }
         }
     }
     finally
     {
         CodeAccessPermission.RevertAssert();
     }
     base.OnEndPrint(document, e);
 }
예제 #2
0
        /// <include file='doc\DefaultPrintController.uex' path='docs/doc[@for="StandardPrintController.OnEndPrint"]/*' />
        /// <devdoc>
        ///    <para>
        ///       Implements EndPrint for printing to a physical printer.
        ///    </para>
        /// </devdoc>
        public override void OnEndPrint(PrintDocument document, PrintEventArgs 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(document);

            IntSecurity.UnmanagedCode.Assert();

            if (dc != IntPtr.Zero)
            {
                int result = (e.Cancel) ? SafeNativeMethods.AbortDoc(new HandleRef(this, dc)) : SafeNativeMethods.EndDoc(new HandleRef(this, dc));
                if (result <= 0)
                {
                    throw new Win32Exception();
                }
                bool success = SafeNativeMethods.DeleteDC(new HandleRef(this, dc));
                if (!success)
                {
                    throw new Win32Exception();
                }

                dc = IntPtr.Zero;
            }

            CodeAccessPermission.RevertAssert();

            base.OnEndPrint(document, e);
        }
        public override void OnEndPrint(PrintDocument document, PrintEventArgs 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(document);
            IntSecurity.UnmanagedCode.Assert();

            try
            {
                if (dc != null)
                {
                    try {
                        int result = (e.Cancel) ? SafeNativeMethods.AbortDoc(new HandleRef(dc, dc.Hdc)) : SafeNativeMethods.EndDoc(new HandleRef(dc, dc.Hdc));
                        if (result <= 0)
                        {
                            throw new Win32Exception();
                        }
                    }
                    finally {
                        dc.Dispose();
                        dc = null;
                    }
                }
            }
            finally {
                CodeAccessPermission.RevertAssert();
            }
            base.OnEndPrint(document, e);
        }
예제 #4
0
        /// <summary>
        /// Implements EndPrint for printing to a physical printer.
        /// </summary>
        public override void OnEndPrint(PrintDocument document, PrintEventArgs e)
        {
            Debug.Assert(_dc != null && _graphics == null, "PrintController methods called in the wrong order?");

            if (_dc != null)
            {
                try
                {
                    int result = (e.Cancel) ? SafeNativeMethods.AbortDoc(new HandleRef(_dc, _dc.Hdc)) : SafeNativeMethods.EndDoc(new HandleRef(_dc, _dc.Hdc));
                    if (result <= 0)
                    {
                        throw new Win32Exception();
                    }
                }
                finally
                {
                    _dc.Dispose();
                    _dc = null;
                }
            }

            base.OnEndPrint(document, e);
        }