public async Task<string> AddPrinter()
        {
            var newPrinterName = CreateValidPrinterName("PDFCreator");
            var questionText = Translation.EnterPrintername;
            newPrinterName = await RequestPrinternameFromUser(questionText, newPrinterName);
            if (newPrinterName == null)
                return null;

            while (!_printerHelper.IsValidPrinterName(newPrinterName))
            {
                questionText = Translation.GetPrinterAlreadyInstalledMessage(newPrinterName);
                newPrinterName = CreateValidPrinterName(newPrinterName);
                newPrinterName = await RequestPrinternameFromUser(questionText, newPrinterName);
                if (newPrinterName == null)
                    return null;
            }

            if (_uacAssistant.AddPrinter(newPrinterName))
                if (CheckInstalledPrinter(newPrinterName))
                    return newPrinterName;

            const string caption = "PDFCreator";
            var message = Translation.GetCouldNotInstallPrinterMessage(newPrinterName);
            await ShowMessage(message, caption, MessageOptions.OK, MessageIcon.Error);

            return null;
        }
Exemplo n.º 2
0
        public bool AddPrinter(out string newPrinterName)
        {
            newPrinterName = CreateValidPrinterName("PDFCreator");
            var questionText = _translator.GetTranslation("InputBoxWindow", "EnterPrintername");

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

            while (!_printerHelper.IsValidPrinterName(newPrinterName))
            {
                questionText = _translator.GetFormattedTranslation("ApplicationSettingsWindow", "PrinterAlreadyInstalled",
                                                                   newPrinterName);
                newPrinterName = CreateValidPrinterName(newPrinterName);
                newPrinterName = RequestPrinternameFromUser(questionText, newPrinterName);
                if (newPrinterName == null)
                {
                    return(false);
                }
            }

            if (_uacAssistant.AddPrinter(newPrinterName))
            {
                if (CheckInstalledPrinter(newPrinterName))
                {
                    return(true);
                }
            }

            const string caption = "PDFCreator";
            var          message = _translator.GetFormattedTranslation("ApplicationSettingsWindow", "CouldNotInstallPrinter",
                                                                       newPrinterName);

            ShowMessage(message, caption, MessageOptions.OK, MessageIcon.Error);

            return(false);
        }
Exemplo n.º 3
0
        public bool AddPrinter(out string newPrinterName)
        {
            newPrinterName = CreateValidPrinterName("PDFCreator");
            var questionText = _translation.EnterPrintername;

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

            while (!_printerHelper.IsValidPrinterName(newPrinterName))
            {
                questionText   = _translation.GetPrinterAlreadyInstalledMessage(newPrinterName);
                newPrinterName = CreateValidPrinterName(newPrinterName);
                newPrinterName = RequestPrinternameFromUser(questionText, newPrinterName);
                if (newPrinterName == null)
                {
                    return(false);
                }
            }

            if (_uacAssistant.AddPrinter(newPrinterName))
            {
                if (CheckInstalledPrinter(newPrinterName))
                {
                    return(true);
                }
            }

            const string caption = "PDFCreator";
            var          message = _translation.GetCouldNotInstallPrinterMessage(newPrinterName);

            ShowMessage(message, caption, MessageOptions.OK, MessageIcon.Error);

            return(false);
        }