/// <summary>
        ///     Add multiple files. The files are checked - if there are problems, abstract functions (that might present dialogs
        ///     to the user) get called.
        /// </summary>
        /// <param name="files">
        ///     A list of files. If this contains a directory or files are not printable, an error message will be
        ///     shown.
        /// </param>
        /// <returns>true, if all files are printable</returns>
        public bool AddFiles(IEnumerable <string> files)
        {
            var printerName = GetPrinterName();

            foreach (var f in files)
            {
                _printCommands.Add(new PrintCommand(f, printerName, _fileAssoc, _printerHelper, _file, _settingsProvider.Settings.ApplicationSettings.ConversionTimeout));
            }

            var directories = _printCommands.FindAll(p => _directory.Exists(p.Filename));

            if (directories.Count > 0)
            {
                DirectoriesNotSupportedHint();
                return(false);
            }

            if (!_printCommands.IsPrintable)
            {
                var sb          = new StringBuilder("The following file(s) could not be converted:");
                var unprintable = _printCommands.UnprintableCommands;

                foreach (var file in unprintable)
                {
                    sb.AppendLine(file.Filename);
                }
                _logger.Error(sb.ToString);

                var canProceed = unprintable.Count < files.Count();

                if (!canProceed)
                {
                    UnprintableFilesHint(unprintable);
                    _printCommands.RemoveUnprintableCommands();
                    return(false);
                }

                var proceed = UnprintableFilesProceedQuery(unprintable);

                if (proceed)
                {
                    _printCommands.RemoveUnprintableCommands();
                }
                else
                {
                    _printCommands.RemoveAllCommands();
                }

                return(proceed);
            }

            return(true);
        }
Beispiel #2
0
        /// <summary>
        ///     Add multiple files. The files are checked - if there are problems, abstract functions (that might present dialogs
        ///     to the user) get called.
        /// </summary>
        /// <param name="files">
        ///     A list of files. If this contains a directory or files are not printable, an error message will be
        ///     shown.
        /// </param>
        /// <returns>true, if all files are printable</returns>
        public bool AddFiles(IEnumerable <string> files)
        {
            var printerName = GetPrinterName();

            foreach (var f in files)
            {
                _printCommands.Add(new PrintCommand(f, printerName, _fileAssoc));
            }

            var directories = _printCommands.FindAll(p => Directory.Exists(p.Filename));

            if (directories.Count > 0)
            {
                DirectoriesNotSupportedHint();
                return(false);
            }

            if (!_printCommands.IsPrintable)
            {
                var sb          = new StringBuilder("The following file(s) could not be converted:");
                var unprintable = _printCommands.UnprintableCommands;
                foreach (var file in unprintable)
                {
                    sb.AppendLine(file.Filename);
                }
                _logger.Error(sb.ToString);
                if (!UnprintableFilesQuery(unprintable))
                {
                    return(false);
                }

                _printCommands.RemoveUnprintableCommands();
            }

            return(true);
        }