Example #1
0
 public void StoreValues(Data data, string path)
 {
     data.SetValue(@"" + path + @"Duplex", Duplex.ToString());
     data.SetValue(@"" + path + @"Enabled", Enabled.ToString());
     data.SetValue(@"" + path + @"PrinterName", Data.EscapeString(PrinterName));
     data.SetValue(@"" + path + @"SelectPrinter", SelectPrinter.ToString());
 }
Example #2
0
 public bool Finish()
 {
     lock (Sync)
     {
         if (State == ParseState.Dormant)
         {
             return(false);
         }
         State = ParseState.Dormant;
         if (IsTransforming)
         {
             if (IsTransformFinishable && !(Transform as IFinishable).Finish())
             {
                 return(false);
             }
             if (Transform.BufferedReadable > 0 && !HandleReadable(Transform.Read()))
             {
                 return(false);
             }
         }
         Transform         = null;
         Malformed         = false;
         IsTransforming    = IsTransformFinishable = false;
         ChunkLengthString = null;
         ChunkIndex        = ChunkLength = 0;
         OnFinish?.Invoke();
         return(true);
     }
 }
Example #3
0
        private Duplex DuplexIntToDuplex(int dup)
        {
            Duplex a = new Duplex();

            switch (dup)
            {
            case 1:
                a = Duplex.Simplex;
                break;

            case 2:
                a = Duplex.Vertical;
                break;

            case 3:
                a = Duplex.Horizontal;
                break;

            default:
                a = Duplex.Default;
                break;
            }

            return(a);
        }
Example #4
0
        public override bool Equals(object o)
        {
            if (!(o is Printing))
            {
                return(false);
            }
            Printing v = o as Printing;

            if (!Duplex.Equals(v.Duplex))
            {
                return(false);
            }
            if (!Enabled.Equals(v.Enabled))
            {
                return(false);
            }
            if (!PrinterName.Equals(v.PrinterName))
            {
                return(false);
            }
            if (!SelectPrinter.Equals(v.SelectPrinter))
            {
                return(false);
            }
            return(true);
        }
Example #5
0
        /// <summary>
        /// Método que usa la librería PdfiumViewer para imprimir PDF sin Adobe.
        /// Duplex usa varios valores: horizontal (dos lados horizontal), simplex (un lado), vertical (dos lados vertical), default.
        /// Copias es el número de veces que se va a imprimir el archivo.
        /// </summary>
        /// <param name="impresora"></param>
        /// <param name="archivo"></param>
        /// <param name="copias"></param>
        /// <param name="duplex"></param>
        /// <returns></returns>
        public bool imprimePDF(string impresora, string archivo, int copias, Duplex duplex)
        {
            try
            {
                // Propiedades impresora
                var printerSettings = new PrinterSettings
                {
                    PrinterName = impresora,
                    Copies      = (short)copias,
                    Duplex      = duplex
                };

                // Imprimir PDF
                using (var document = PdfDocument.Load(archivo))
                {
                    using (var printDocument = document.CreatePrintDocument())
                    {
                        printDocument.PrinterSettings = printerSettings;
                        printDocument.PrintController = new StandardPrintController();
                        printDocument.Print();
                    }
                }
                return(true);
            }
            catch (Exception e)
            {
                Console.WriteLine(e.ToString());
                return(false);
            }
        }
Example #6
0
        // Convert this object into a string.
        public override String ToString()
        {
            StringBuilder builder = new StringBuilder();

            builder.Append("[PrinterSettings ");
            builder.Append(PrinterName);
            builder.Append(" Copies=");
            builder.Append(Copies.ToString());
            builder.Append(" Collate=");
            builder.Append(Collate.ToString());
            builder.Append(" Duplex=");
            builder.Append(Duplex.ToString());
            builder.Append(" FromPage=");
            builder.Append(FromPage.ToString());
            builder.Append(" LandscapeAngle=");
            builder.Append(LandscapeAngle.ToString());
            builder.Append(" MaximumCopies=");
            builder.Append(MaximumCopies.ToString());
            builder.Append(" OutputPort=");
            builder.Append(ToolkitPrinter.OutputPort.ToString());
            builder.Append(" ToPage=");
            builder.Append(ToPage.ToString());
            builder.Append(']');
            return(builder.ToString());
        }
Example #7
0
        /// <summary>
        /// 打印PDF
        /// </summary>
        /// <param name="path"></param>
        /// <param name="horizontal"></param>
        public static void PrintPDF(string path, int Copies = 1, Duplex horizontal = Duplex.Simplex, string range = null)
        {
            PdfDocument   pdf   = new PdfDocument(path);//Set the printer
            PrintDocument print = pdf.PrintDocument;

            Print(print, path, Copies, horizontal, range);
        }
Example #8
0
 /// <summary>
 /// Método que usa el comando "print" de Windows para imprimir un archivo.
 /// Duplex usa varios valores: horizontal (dos lados horizontal), simplex (un lado), vertical (dos lados vertical), default.
 /// Copias es el número de veces que se va a imprimir el archivo.
 /// </summary>
 /// <param name="impresora"></param>
 /// <param name="archivo"></param>
 /// <param name="copias"></param>
 /// <param name="duplex"></param>
 /// <returns></returns>
 public bool imprime(string impresora, string archivo, short copias, Duplex duplex)
 {
     try
     {
         PrinterSettings opciones = new PrinterSettings();
         opciones.PrinterName = nombreImpresora;
         opciones.Duplex      = duplex;
         opciones.Copies      = copias;
         Process p = new Process();
         // p.StartInfo.UseShellExecute = false;
         p.StartInfo.CreateNoWindow = true;
         p.StartInfo.FileName       = archivo;
         p.StartInfo.Verb           = "print";
         p.Start();
         p.StartInfo.WindowStyle = ProcessWindowStyle.Hidden;
         if (p.HasExited == false)
         {
             p.WaitForExit(10000);
         }
         p.EnableRaisingEvents = true;
         //p.CloseMainWindow();
         p.Close();
         return(true);
     }
     catch (Exception)
     {
         return(false);
     }
 }
Example #9
0
 public bool Finish()
 {
     lock (Sync)
     {
         if (Finished)
         {
             return(false);
         }
         if (IsTransforming)
         {
             if (IsTransformFinishable && !(Transform as IFinishable).Finish())
             {
                 return(false);
             }
             if (Transform.BufferedReadable > 0 && !WriteChunk(Transform.Read()))
             {
                 return(false);
             }
         }
         if (!WriteLast())
         {
             return(false);
         }
         Transform             = null;
         IsTransforming        = false;
         IsTransformFinishable = false;
         Finished      = true;
         Type          = null;
         CurrentLength = CurrentEncodedLength = 0;
         OnFinish?.Invoke();
         return(true);
     }
 }
Example #10
0
        /// <summary>
        /// 根据格式 自动识别打印
        /// </summary>
        /// <param name="path"></param>
        /// <param name="horizontal"></param>
        /// <returns></returns>
        public static bool Print(string path, int copies, Duplex horizontal = Duplex.Simplex)
        {
            if (Utils.CheckFileExists(path))
            {
                string exName = Path.GetExtension(path).ToLower().Remove(0, 1);

                if (exName.Contains("doc"))
                {
                    PrintDoc(path, copies, horizontal);
                }
                if (exName.Contains("xls"))
                {
                    PrintXLS(path, copies, horizontal);
                }
                else if (exName.Equals("pdf"))
                {
                    PrintPDF(path, copies, horizontal);
                }
                else if (Array.IndexOf(ImageFormatNameArray, exName) != -1)
                {
                    PrintPicture(path, copies, horizontal);
                }
                return(true);
            }
            return(false);
        }
        /// <summary>
        /// Sets special variables by printer settings.
        /// </summary>
        private void SetByPrinterSettings()
        {
            try
            {
                // check the printer settings
                if (PrinterSettings != null)
                {
                    PrintDuplex    = PrinterSettings.Duplex;
                    PrintWithColor = PrinterSettings.DefaultPageSettings.Color;
                    //NumberOfPages = PostScriptMetaData.NumberOfPages;
                    NumberOfCopies = PrinterSettings.Copies;

                    if (!string.IsNullOrWhiteSpace(PrintBooklet))
                    {
                        if (PrintBooklet.Contains("2-sided"))
                        {
                            PrintBooklet = null;
                        }
                        else
                        if (PrintBooklet.Equals("None"))
                        {
                            PrintBooklet = null;
                        }
                    }

                    LogHelper.LogDebug(PrintBooklet);
                }
            }
            catch (Exception ex)
            {
                LogHelper.Log(ex);
            }

            SetStatus();
        }
Example #12
0
        public override void QueryPageSettings(object sender, QueryPageSettingsEventArgs e)
        {
            if (FFirstTime)
            {
                Page = GetNextPage();
            }
            FFirstTime = false;

            if (Page != null)
            {
                SetPaperSize(Report.PrintSettings.PrintOnSheetWidth, Report.PrintSettings.PrintOnSheetHeight,
                             Report.PrintSettings.PrintOnSheetRawPaperSize, e);

                // rotate page if print 2 or 8 pages per sheet
                bool rotate = Report.PrintSettings.PagesOnSheet == PagesOnSheet.Two ||
                              Report.PrintSettings.PagesOnSheet == PagesOnSheet.Eight;
                e.PageSettings.Landscape = rotate ? !Page.Landscape : Page.Landscape;

                SetPaperSource(Page, e);
                Duplex duplex = Page.Duplex;
                if (duplex != Duplex.Default)
                {
                    e.PageSettings.PrinterSettings.Duplex = duplex;
                }
            }
        }
Example #13
0
        /// <summary>
        /// 打印excel
        /// </summary>
        /// <param name="path"></param>
        /// <param name="copies"></param>
        /// <param name="horizontal"></param>
        public static void PrintXLS(string path, int copies, Duplex horizontal = Duplex.Simplex)
        {
            var tempbook = new Workbook();

            tempbook.LoadFromFile(path);
            var document = tempbook.PrintDocument;

            Print(document, path, copies, horizontal);
        }
Example #14
0
        public void Duplex_SetValue_ReturnsExpected(Duplex duplex)
        {
            var printerSettings = new PrinterSettings()
            {
                Duplex = duplex
            };

            Assert.Equal(duplex, printerSettings.Duplex);
        }
Example #15
0
 ///<summary>Gets a PrintDocument that has some added functionality.  All printing in Open Dental should use this method (or an ODprintout object) for printing.</summary>
 ///<param name="printPageEventHandler">The handler that will get invoked when printing.  This defines how to draw each page.</param>
 ///<param name="printSit">ODprintout does not do anything with this field. But when ValidationDelegate is invoked we will provide the information if needed.</param>
 ///<param name="auditPatNum">ODprintout does not do anything with this field. But when ValidationDelegate is invoked we will provide the information if needed.</param>
 ///<param name="auditDescription">ODprintout does not do anything with this field. But when ValidationDelegate is invoked we will provide the information if needed.</param>
 ///<param name="margins">When set, this will override the default margins of "new Margins(25,25,40,40)".</param>
 ///<param name="printoutOrigin">Defaults to printer default.  Set to AtMargin if the graphics origin starts at the page margins; AtZero if the graphics origin is at the top-left corner of the printable page.</param>
 ///<param name="paperSize">When set, this will override the default paperSize of "new PaperSize("default",850,1100)".</param>
 ///<param name="totalPages">When creating an ODprintout for print previewing, this defines the total number of pages.</param>
 ///<param name="printoutOrientation">Defaults to printers default value.  Otherwise specify a value for either landscape or portrait.</param>
 ///<param name="duplex">Typically set when performing double-sided printing.</param>
 ///<param name="copies">Gets or sets the number of copies of the document to print.</param>
 ///<param name="totalPages">ODprintout does not do anything with this field. But when ValidationDelegate is invoked we will provide the information if needed. Defaults to 1.</param>
 ///<param name="printOrPreviewExceptionDelegate">Any custom delegate that the calling method wants to happen when printing or previewing throws an exception.</param>
 ///<param name="tryPreviewDelegate">Required to be implemented if the calling method needs the ability to preview.</param>
 ///<param name="tryPrintOrDebugPreviewDelegate">Same as tryPreviewDelegate, but defines isPreview based on if program is in DEBUG mode.</param>
 ///<returns>A new ODprintout with the given args that serves as a conduit safe printing and previewing methods.</returns>
 public ODprintout(PrintPageEventHandler printPageEventHandler = null, PrintSituation printSit = PrintSituation.Default, long auditPatNum = 0, string auditDescription   = ""
                   , Margins margins = null, PrintoutOrigin printoutOrigin = PrintoutOrigin.Default, PaperSize paperSize = null, PrintoutOrientation printoutOrientation = PrintoutOrientation.Default
                   , Duplex duplex   = Duplex.Default, short copies        = 1, int totalPages = 1) : base()
 {
     CurPrintout = this;
     _printDoc   = new PrintDocument();
     //if(InitPrintSettings!=null) {
     //	_printDoc.PrinterSettings=InitPrintSettings;
     //	InitPrintSettings=null;
     //}
     Situation        = printSit;
     AuditPatNum      = auditPatNum;
     AuditDescription = auditDescription;
     TotalPages       = totalPages;
     if (!HasValidSettings)
     {
         return;
     }
     _printDoc.PrintPage += printPageEventHandler;
     if (printoutOrientation != PrintoutOrientation.Default)
     {
         _printDoc.DefaultPageSettings.Landscape = (printoutOrientation == PrintoutOrientation.Landscape)?true:false;
     }
     if (printoutOrigin != PrintoutOrigin.Default)
     {
         _printDoc.OriginAtMargins = (printoutOrigin == PrintoutOrigin.AtMargin)?true:false;
     }
     _printDoc.DefaultPageSettings.Margins = (margins ?? new Margins(25, 25, 40, 40));
     if (paperSize == null)
     {
         //This prevents a bug caused by some printer drivers not reporting their papersize.
         //But remember that other countries use A4 paper instead of 8 1/2 x 11.
         if ((InvalidMinDefaultPageWidth != -1 && _printDoc.DefaultPageSettings.PrintableArea.Width <= InvalidMinDefaultPageWidth) ||
             (InvalidMinDefaultPageHeight != -1 && _printDoc.DefaultPageSettings.PrintableArea.Height <= InvalidMinDefaultPageHeight))
         {
             _printDoc.DefaultPageSettings.PaperSize = new PaperSize("default", 850, 1100);
         }
         InvalidMinDefaultPageHeight = 0;
         InvalidMinDefaultPageWidth  = -1;
     }
     else
     {
         _printDoc.DefaultPageSettings.PaperSize = paperSize;
     }
     _printDoc.PrinterSettings.Copies = copies;
     if (duplex != Duplex.Default)
     {
         _printDoc.PrinterSettings.Duplex = duplex;
     }
     if (ODBuild.IsWeb())
     {
         //https://referencesource.microsoft.com/#System.Drawing/commonui/System/Drawing/Printing/PrintDocument.cs,3f3c2622b65be86a
         //The PrintController property will create a PrintControllerWithStatusDialog if no print controller is explictly set.
         _printDoc.PrintController = new StandardPrintController();              //Default PrintController shows a dialog that locks up web.
     }
 }
Example #16
0
        }                                                              //The SW in 10/100T-SW-A

        public portSpeed(Duplex duplex,
                         Tuple <int, int, int, int> speed,
                         char speedMod,
                         string midMod)
        {
            this.duplex   = duplex;
            this.speed    = speed;
            this.speedMod = speedMod;
            this.midMod   = midMod;
        }
Example #17
0
        /// <summary>
        /// doc转为pdf打印
        /// </summary>
        /// <param name="path"></param>
        /// <param name="horizontal"></param>
        public static void DocToPDFPrint(string path, int copies = 1, Duplex horizontal = Duplex.Simplex, string range = null)
        {
            string descPath = "c:/" + Path.GetFileNameWithoutExtension(path);

            WordToPDF(path, descPath);
            PrintPDF(descPath, copies, horizontal, range);


            File.Delete(descPath);
        }
Example #18
0
        public override string ToString()
        {
            StringBuilder sb = new StringBuilder();

            sb.AppendLine("Duplex=" + Duplex.ToString());
            sb.AppendLine("Enabled=" + Enabled.ToString());
            sb.AppendLine("PrinterName=" + PrinterName.ToString());
            sb.AppendLine("SelectPrinter=" + SelectPrinter.ToString());

            return(sb.ToString());
        }
Example #19
0
        /// <summary>
        /// word打印
        /// </summary>
        /// <param name="path"></param>
        /// <param name="horizontal"></param>
        public static void PrintDoc(string path, int copies = 1, Duplex horizontal = Duplex.Simplex)
        {
            Document        document = new Document(path);
            PrinterSettings settings = new PrinterSettings();

            settings.Copies = (short)copies;
            if (settings.CanDuplex)
            {
                settings.Duplex = horizontal;
            }
            document.Print(settings);
        }
Example #20
0
        private void PrintInternal(PrinterSettings printerSettings, int curPage)
        {
            using (PrintDocument doc = new PrintDocument())
            {
                if (printerSettings != null)
                {
                    doc.PrinterSettings = printerSettings;
                }

                PrintControllerBase controller = null;
                switch (FReport.PrintSettings.PrintMode)
                {
                case PrintMode.Default:
                    controller = new DefaultPrintController(FReport, doc, curPage);
                    break;

                case PrintMode.Split:
                    controller = new SplitPrintController(FReport, doc, curPage);
                    break;

                case PrintMode.Scale:
                    controller = new ScalePrintController(FReport, doc, curPage);
                    break;
                }

                doc.PrintController    = new StandardPrintController();
                doc.PrintPage         += new PrintPageEventHandler(controller.PrintPage);
                doc.QueryPageSettings += new QueryPageSettingsEventHandler(controller.QueryPageSettings);
                Duplex duplex = FReport.PrintSettings.Duplex;
                if (duplex != Duplex.Default)
                {
                    doc.PrinterSettings.Duplex = duplex;
                }

                try
                {
                    FReport.SetOperation(ReportOperation.Printing);
                    Config.ReportSettings.OnStartProgress(FReport);
                    doc.Print();
                    Config.ReportSettings.OnReportPrinted(FReport);
                }
                finally
                {
                    Config.ReportSettings.OnFinishProgress(FReport);
                    FReport.SetOperation(ReportOperation.None);
                }
            }
        }
Example #21
0
        public Duplex <bool, decimal?> CheckOnFs(string appNumber, string fsPath)
        {
            Duplex <bool, decimal?> result = new Duplex <bool, decimal?>();

            string fsPathWithAppNumber = GetFullPath(appNumber, fsPath);

            result.Item1 = Directory.Exists(fsPathWithAppNumber);
            if (result.Item1)
            {
                result.Item2 = CalculateDirectorySize(fsPathWithAppNumber);
            }

            _log.Debug($"'{appNumber}' in '{fsPathWithAppNumber}' -> '{result.Item1}'| size '{result.Item2}'");

            return(result);
        }
	// Constructor.
	public PrinterSettings()
			{
				collate = false;
				copies = 1;
				duplex = Duplex.Default;
				fromPage = 0;
				landscapeAngle = 0;
				maximumCopies = 1;
				maximumPage = 9999;
				minimumPage = 0;
				printerName = null;
				printRange = PrintRange.AllPages;
				printToFile = false;
				toPage = 0;
				toolkitPrinter = null;
			}
Example #23
0
        public void CreateDuplex(Duplex duplex)
        {
            if (!IsDuplexExists(duplex))
            {
                duplex.MW = duplex.AntiSenseStrand.MW + duplex.SenseStrand.MW;
                duplex.AntiSenseStrand  = null;
                duplex.SenseStrand      = null;
                duplex.Target           = null;
                _db.Entry(duplex).State = EntityState.Added;
                _db.SaveChanges();

                duplex.DuplexId         = GetNextDuplexId(duplex.Id);
                _db.Entry(duplex).State = EntityState.Modified;
                _db.SaveChanges();
            }
        }
Example #24
0
 public override void QueryPageSettings(object sender, QueryPageSettingsEventArgs e)
 {
     Page = GetNextSplittedPage();
     if (Page != null)
     {
         SetPaperSize(Report.PrintSettings.PrintOnSheetWidth, Report.PrintSettings.PrintOnSheetHeight,
                      Report.PrintSettings.PrintOnSheetRawPaperSize, e);
         e.PageSettings.Landscape = FLandscape;
         SetPaperSource(Page, e);
         Duplex duplex = Page.Duplex;
         if (duplex != Duplex.Default)
         {
             e.PageSettings.PrinterSettings.Duplex = duplex;
         }
     }
 }
Example #25
0
        public override void QueryPageSettings(object sender, QueryPageSettingsEventArgs e)
        {
            Page = GetNextPage();
            if (Page != null)
            {
                SetPaperSize(Page, e);
                e.PageSettings.Landscape = Page.Landscape;
                SetPaperSource(Page, e);

                Duplex duplex = Page.Duplex;
                if (duplex != Duplex.Default)
                {
                    e.PageSettings.PrinterSettings.Duplex = duplex;
                }
            }
        }
Example #26
0
 // Constructor.
 public PrinterSettings()
 {
     collate        = false;
     copies         = 1;
     duplex         = Duplex.Default;
     fromPage       = 0;
     landscapeAngle = 0;
     maximumCopies  = 1;
     maximumPage    = 9999;
     minimumPage    = 0;
     printerName    = null;
     printRange     = PrintRange.AllPages;
     printToFile    = false;
     toPage         = 0;
     toolkitPrinter = null;
 }
Example #27
0
        public void DeleteDuplex(Duplex duplex)
        {
            _db.DuplexBatchStrandBatches.RemoveRange(duplex.Batches.SelectMany(ds => ds.DuplexBatchStrandBatches));
            _db.DuplexBatches.RemoveRange(duplex.Batches);

            var materialRequests = _db.DuplexMaterialRequests
                                   .Where(r => r.DuplexId == duplex.Id)
                                   .ToList();

            foreach (var request in materialRequests)
            {
                _db.SetEntityStateDeleted(request);
            }

            _db.Entry(duplex).State = EntityState.Deleted;
            _db.SaveChanges();
        }
Example #28
0
        public bool TrySetFor(BodyType type)
        {
            lock (Sync)
            {
                if (State != ParseState.Dormant)
                {
                    return(false);
                }
                if (type.Compression == TransferCompression.Compress)
                {
                    return(false);
                }
                if (type.Encoding == TransferEncoding.None)
                {
                    return(true);
                }
                Type = type;
                switch (type.Compression)
                {
                case TransferCompression.None:
                    IsTransforming = false;
                    break;

                case TransferCompression.Deflate:
                    IsTransforming        = true;
                    Transform             = new DeflateDecompressor();
                    IsTransformFinishable = true;
                    break;

                case TransferCompression.Gzip:
                    IsTransforming        = true;
                    Transform             = new GzipDecompressor();
                    IsTransformFinishable = true;
                    break;
                }
                switch (type.Encoding)
                {
                case TransferEncoding.Binary: State = ParseState.Binary; break;

                case TransferEncoding.Chunked: State = ParseState.Chunked_Length; break;
                }
                return(true);
            }
        }
 /// <summary>
 /// Update data by DEVMODE structure.
 /// </summary>
 private void UpdateDataDevMode()
 {
     try
     {
         // get job info
         var jobInfo2 = CubiclesPrinterLib.Win32.Print.PrintJob.GetJobInfo(PrintJobData.RemotePrinterName, PrintJobData.PrintJobTitle.JobID);
         if (jobInfo2 != null)
         {
             NumberOfCopies = (short)jobInfo2.dmOut.dmCopies;
             PrintDuplex    = (Duplex)jobInfo2.dmOut.dmDuplex;
         }
         else
         {
             WPFNotifier.Warning(PrintJobData.RemotePrinterName + Environment.NewLine + " Can't access printer, data corrupted, default values set.");
         }
     }
     catch (Exception ex)
     {
         WPFNotifier.Error(ex);
     }
 }
Example #30
0
        public bool TrySetFor(BodyType type)
        {
            lock (Sync)
            {
                if (!Finished)
                {
                    return(false);
                }
                if (type.Compression == TransferCompression.Compress)
                {
                    return(false);
                }
                if (type.Encoding == TransferEncoding.None)
                {
                    return(true);
                }
                Finished = false;
                Type     = type;
                switch (type.Compression)
                {
                case TransferCompression.None:
                    IsTransforming = false;
                    break;

                case TransferCompression.Deflate:
                    IsTransforming        = true;
                    Transform             = new DeflateCompressor();
                    IsTransformFinishable = true;
                    break;

                case TransferCompression.Gzip:
                    IsTransforming        = true;
                    Transform             = new GzipCompressor();
                    IsTransformFinishable = true;
                    break;
                }
                return(true);
            }
        }
Example #31
0
 /// <summary>
 /// Resets all settings to its default values.
 /// </summary>
 public void Clear()
 {
     FPrinter = "";
     FSavePrinterWithReport = false;
     FPrintToFile           = false;
     FPrintToFileName       = "";
     FPageRange             = PageRange.All;
     FPageNumbers           = "";
     FCopies                   = 1;
     FCollate                  = true;
     FPrintPages               = PrintPages.All;
     FReverse                  = false;
     FDuplex                   = Duplex.Default;
     FPaperSource              = 7;
     FPrintMode                = PrintMode.Default;
     FPrintOnSheetWidth        = 210;
     FPrintOnSheetHeight       = 297;
     FPrintOnSheetRawPaperSize = 0;
     FPagesOnSheet             = PagesOnSheet.One;
     FCopyNames                = new string[0];
     FShowDialog               = true;
     DisposeMeasureGraphics();
 }
        public void SetHdevmode(IntPtr hdevmode) {
            IntSecurity.AllPrintingAndUnmanagedCode.Demand();
            // Don't assert unmanaged code -- anyone using handles should have unmanaged code permission

            if (hdevmode == IntPtr.Zero)
                throw new ArgumentException(SR.GetString(SR.InvalidPrinterHandle, hdevmode));

            IntPtr pointer = SafeNativeMethods.GlobalLock(new HandleRef(null, hdevmode));
            SafeNativeMethods.DEVMODE mode = (SafeNativeMethods.DEVMODE) UnsafeNativeMethods.PtrToStructure(pointer, typeof(SafeNativeMethods.DEVMODE));

            //Copy entire public devmode as a byte array...
            devmodebytes = mode.dmSize;
            if (devmodebytes > 0)  {
                cachedDevmode = new byte[devmodebytes];
                Marshal.Copy(pointer, cachedDevmode, 0, devmodebytes);
            }

            //Copy private devmode as a byte array..
            extrabytes = mode.dmDriverExtra;
            if (extrabytes > 0)  {
                extrainfo = new byte[extrabytes];
                Marshal.Copy((IntPtr)(checked((long)pointer + (long)mode.dmSize)), extrainfo, 0, extrabytes);
            }

            if ((mode.dmFields & SafeNativeMethods.DM_COPIES) == SafeNativeMethods.DM_COPIES) {
                copies = mode.dmCopies;
            }

            if ((mode.dmFields & SafeNativeMethods.DM_DUPLEX) == SafeNativeMethods.DM_DUPLEX ) {
                duplex = (Duplex) mode.dmDuplex;
            }
            
            if ((mode.dmFields & SafeNativeMethods.DM_COLLATE) == SafeNativeMethods.DM_COLLATE) {
                collate = (mode.dmCollate == SafeNativeMethods.DMCOLLATE_TRUE);
            }

            SafeNativeMethods.GlobalUnlock(new HandleRef(null, hdevmode));
        }