private string GetPrinterName()
        {
            if (string.IsNullOrWhiteSpace(PdfCreatorPrinter))
            {
                PdfCreatorPrinter = _settingsProvider.Settings.CreatorAppSettings.PrimaryPrinter;
            }

            return(_printerHelper.GetApplicablePDFCreatorPrinter(PdfCreatorPrinter));
        }
示例#2
0
        private async void DeletePrinterCommandExecute(object obj)
        {
            var currentMapping = _printerMappingView.CurrentItem as PrinterMappingWrapper;

            if (currentMapping == null)
            {
                return;
            }

            var success = await _printerActionsAssistant.DeletePrinter(currentMapping.PrinterName, PdfCreatorPrinters.Count);

            if (success)
            {
                PrinterMappings.Remove(currentMapping);
                PdfCreatorPrinters = _printerProvider.GetPDFCreatorPrinters();

                RaisePropertyChanged(nameof(PrimaryPrinter));
                RaisePropertyChanged(nameof(PrinterMappings));
                RaisePropertyChanged(nameof(PdfCreatorPrinters));

                PrimaryPrinter = _printerHelper.GetApplicablePDFCreatorPrinter("");
            }
        }
示例#3
0
        private void CheckPrinterMappings(PdfCreatorSettings settings)
        {
            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") ?? "";
            }
        }