Ejemplo n.º 1
0
        private static void CheckPrinterMappings()
        {
            var printerHelper = new PrinterHelper();
            var printers      = printerHelper.GetPDFCreatorPrinters();

            // 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.GetApplicablePDFCreatorPrinter("PDFCreator", "PDFCreator") ?? "";
            }
        }
Ejemplo n.º 2
0
        public bool IsRepairRequired()
        {
            var printerHelper = new PrinterHelper();

            return(!printerHelper.GetPDFCreatorPrinters().Any());
        }