public bool AddPrinter(out string newPrinterName)
        {
            newPrinterName = CreateValidPrinterName("PDFCreator");
            string questionText = _translator.GetTranslation("InputBoxWindow", "EnterPrintername",
                                                             "Please enter printer name:");

            newPrinterName = RequestPrinternameFromUser(questionText, newPrinterName);
            if (newPrinterName == null)
            {
                return(false);
            }

            var printerHelper = new PrinterHelper();

            while (!printerHelper.IsValidPrinterName(newPrinterName))
            {
                questionText = _translator.GetFormattedTranslation("ApplicationSettingsWindow", "PrinterAlreadyInstalled",
                                                                   "A printer with the name '{0}' is already installed on your system. Please enter a new printer name:",
                                                                   newPrinterName);
                newPrinterName = CreateValidPrinterName(newPrinterName);
                newPrinterName = RequestPrinternameFromUser(questionText, newPrinterName);
                if (newPrinterName == null)
                {
                    return(false);
                }
            }

            var uac = new UacAssistant();

            return(uac.AddPrinter(newPrinterName));
        }
        private InputBoxValidation ValidatePrinterName(string arg)
        {
            var printerHelper = new PrinterHelper();

            if (printerHelper.IsValidPrinterName(arg))
            {
                return(new InputBoxValidation(true, ""));
            }

            return(new InputBoxValidation(false, _translator.GetTranslation("ApplicationSettingsWindow", "InvalidPrinterName",
                                                                            "The name is invalid or a printer with this name already exists")));
        }
        private string CreateValidPrinterName(string baseName)
        {
            int    i           = 2;
            string printerName = baseName;

            var printerHelper = new PrinterHelper();

            while (!printerHelper.IsValidPrinterName(printerName))
            {
                printerName = baseName + i++;
            }

            return(printerName);
        }