示例#1
0
        private static void CheckPrinterMappings()
        {
            var printerHelper = new PrinterHelper();
            var printers      = printerHelper.GetclawPDFPrinters();

            // if there are no printers, something is broken and we need to fix that first
            //如果没有打印机,就会出现故障,我们需要先修复
            if (!printers.Any())
            {
                return;
            }

            //Assign DefaultProfile for all installed printers without mapped profile.
            //为没有映射配置文件的所有已安装打印机分配默认配置文件。
            foreach (var printer in printers)
            {
                if (Settings.ApplicationSettings.PrinterMappings.All(o => o.PrinterName != printer))
                {
                    Settings.ApplicationSettings.PrinterMappings.Add(new PrinterMapping(printer,
                                                                                        ProfileGuids.DEFAULT_PROFILE_GUID));
                }
            }
            //Remove uninstalled printers from mapping
            //从映射中删除已卸载的打印机
            foreach (var mapping in Settings.ApplicationSettings.PrinterMappings.ToArray())
            {
                if (printers.All(o => o != mapping.PrinterName))
                {
                    Settings.ApplicationSettings.PrinterMappings.Remove(mapping);
                }
            }
            //Check primary printer
            //检查主打印机
            if (Settings.ApplicationSettings.PrinterMappings.All(o =>
                                                                 o.PrinterName != Settings.ApplicationSettings.PrimaryPrinter))
            {
                Settings.ApplicationSettings.PrimaryPrinter =
                    printerHelper.GetApplicableclawPDFPrinter("clawPDF", "clawPDF") ?? "";
            }
        }
示例#2
0
 protected PrintFileHelperBase()
 {
     _clawPdfPrinter =
         _printerHelper.GetApplicableclawPDFPrinter(
             SettingsHelper.Settings.ApplicationSettings.PrimaryPrinter);
 }