private void WindowsTestPageButton_OnClick(object sender, RoutedEventArgs e) { if (!QuerySaveModifiedSettings()) { return; } var printerHelper = new Shared.Helper.PrinterHelper(); printerHelper.PrintWindowsTestPage(ViewModel.ApplicationSettings.PrimaryPrinter); }
/// <summary> /// Prints the file. /// </summary> /// <param name="processTimeout">The timespan to wait for the process to finish</param> /// <returns>true, if printing was successful</returns> public bool Print(TimeSpan processTimeout) { if (CommandType == PrintType.Unprintable) { throw new InvalidOperationException("File is not printable"); } var printerHelper = new Shared.Helper.PrinterHelper(); if (CommandType == PrintType.Print && Printer != printerHelper.GetDefaultPrinter()) { throw new InvalidOperationException("The default printer needs to be set in order to print this file"); } var p = ProcessWrapperFactory.BuildProcessWrapper(new ProcessStartInfo(Filename)); if (SupportsPrintTo()) { p.StartInfo.Verb = "Printto"; p.StartInfo.Arguments = "\"" + Printer + "\""; } else { p.StartInfo.Verb = "Print"; } try { p.Start(); p.WaitForExit(processTimeout); if (!p.HasExited) { Logger.Warn("Process was not finishing after {0} seconds, killing it now...", processTimeout.TotalSeconds); p.Kill(); } else { Successful = true; } } catch (Exception ex) { Logger.Error("Exception during print process" + "\r\nType: " + ex.GetType() + "\r\nMessage: " + ex.Message ); return(false); } return(Successful); }
public PrinterTabViewModel(ApplicationSettings applicationSettings, IEnumerable <ConversionProfile> profiles, Func <ICollection <string> > fetchPrintersFunc, TranslationHelper translationHelper, Edition edition) : base(edition) { SettingsChanged += OnSettingsChanged; _translationHelper = translationHelper; var helper = new Shared.Helper.PrinterHelper(); GetPrinterListAction = fetchPrintersFunc ?? helper.GetPDFCreatorPrinters; ConversionProfiles = profiles; ApplicationSettings = applicationSettings; AddPrinterCommand = new DelegateCommand(AddPrintercommandExecute); RenamePrinterCommand = new DelegateCommand(RenamePrinterCommandExecute, ModifyPrinterCommandCanExecute); DeletePrinterCommand = new DelegateCommand(DeletePrinterCommandExecute, ModifyPrinterCommandCanExecute); }
public Printers() { _printerHelper = new Shared.Helper.PrinterHelper(); }