예제 #1
0
        public bool DeletePrinter(string printerName, int numPrinters)
        {
            if (numPrinters < 2)
            {
                var message = _translator.GetTranslation("ApplicationSettingsWindow", "DontDeleteLastPrinter",
                                                         "You may not delete the last printer. Uninstall clawPDF if you really want to remove all related printers.");
                const string caption = @"clawPDF";
                MessageWindow.ShowTopMost(message, caption, MessageWindowButtons.OK, MessageWindowIcon.Error);
                return(false);
            }

            var msg = _translator.GetFormattedTranslation("ApplicationSettingsWindow", "AskDeletePrinter",
                                                          "Are you sure that you want to delete the printer '{0}'?", printerName);
            var cpt = _translator.GetTranslation("ApplicationSettingsWindow", "DeletePrinter", "Delete Printer");

            if (MessageWindow.ShowTopMost(msg, cpt, MessageWindowButtons.YesNo, MessageWindowIcon.Question) !=
                MessageWindowResponse.Yes)
            {
                return(false);
            }

            var uac = new UacAssistant();

            return(uac.DeletePrinter(printerName));
        }
예제 #2
0
        public bool AddPrinter(out string newPrinterName)
        {
            newPrinterName = CreateValidPrinterName("clawPDF");
            var 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));
        }