Beispiel #1
0
        public virtual void FetchSetting()
        {
            ShowPrintOptionCurtain();
            CurrentPrinterName = PrintUtility.GetCurrentPrinterName();
            PaperSizes         = PrintUtility.GetPaperSizes(CurrentPrinterName);
            var userPrintTicket = PrintUtility.GetUserPrintTicket(CurrentPrinter.FullName);

            if (userPrintTicket != null)
            {
                CurrentPrinter.UserPrintTicket = userPrintTicket;
            }
            SetCurrentPaper(CurrentPrinter.UserPrintTicket.PageMediaSize);
            SetPageOrientation(CurrentPrinter.UserPrintTicket.PageOrientation);
            PrintCopyCount = CurrentPrinter.UserPrintTicket.CopyCount != null? CurrentPrinter.UserPrintTicket.CopyCount.Value:PrintCopyCount;
            ExecuteSetPrintingOptions(null);
            HidePrintOptionCurtain();
        }
Beispiel #2
0
 public virtual void InitializeProperties()
 {
     try
     {
         Printers = PrintUtility.GetPrinters();
         SetLocalPrinter();
         var defaultPrintQueue = PrintUtility.GetDefaultPrintQueue(string.Empty);
         IsMarkPageNumbers = true;
         var defaultPrinterFullName = defaultPrintQueue.FullName;
         var defaultExists          = false;
         foreach (var printer in Printers)
         {
             if (printer.Name == defaultPrintQueue.Name)
             {
                 defaultExists = true;
                 break;
             }
         }
         if (!defaultExists)
         {
             Printers.Add(defaultPrintQueue);
             var temp = Printers;
             Printers = null;
             Printers = temp;
         }
         CurrentPrinterName = PrintUtility.GetCurrentPrinterName(defaultPrinterFullName);
         CurrentPrinter     = Printers.First(e => e.FullName == CurrentPrinterName);
         PrintOptionsSetterIsEnable(false);
         SetPrintError(false);
         var userPrintTicket = PrintUtility.GetUserPrintTicket(CurrentPrinter.FullName);
         if (userPrintTicket != null)
         {
             CurrentPrinter.UserPrintTicket = userPrintTicket;
         }
         SetCurrentPaper(CurrentPrinter.UserPrintTicket.PageMediaSize);
         SetPageOrientation(CurrentPrinter.UserPrintTicket.PageOrientation);
         ExecuteSetPrintingOptions(false);
     }
     catch (Exception ex)
     {
         SetPrintError(true);
     }
 }