Exemplo n.º 1
0
        protected virtual ICollection <string> FilesToImport(object parameter)
        {
            using (var dialog = _dialogFactory.CreateOpenFileDialog())
            {
                dialog.AddExtension       = true;
                dialog.AutoUpgradeEnabled = true;
                dialog.CheckFileExists    = true;
                dialog.CheckPathExists    = true;
                dialog.Multiselect        = true;
                dialog.ShowHelp           = false;
                dialog.Title  = DialogsTitle;
                dialog.Filter =
                    $"{RubberduckUI.ImportCommand_OpenDialog_Filter_VBFiles} ({FilterExtension})|{FilterExtension}|" +
                    $"{RubberduckUI.ImportCommand_OpenDialog_Filter_AllFiles}, (*.*)|*.*";

                if (dialog.ShowDialog() != DialogResult.OK)
                {
                    return(new List <string>());
                }

                var fileNames      = dialog.FileNames;
                var fileExtensions = fileNames.Select(Path.GetExtension);
                if (fileExtensions.Any(fileExt => !ImportableExtensions.Contains(fileExt)))
                {
                    NotifyUserAboutAbortDueToUnsupportedFileExtensions(fileNames);
                    return(new List <string>());
                }

                return(fileNames);
            }
        }
Exemplo n.º 2
0
        //TODO: Gather all conflicts and report them in one error dialog instead of reporting them one at a time.
        private void NotifyUserAboutAbortDueToUnsupportedFileExtensions(IEnumerable <string> fileNames)
        {
            var firstUnsupportedFile = fileNames.First(filename => !ImportableExtensions.Contains(Path.GetExtension(filename)));
            var unsupportedFileName  = Path.GetFileName(firstUnsupportedFile);
            var message = string.Format(RubberduckUI.ImportCommand_UnsupportedFileExtensions, unsupportedFileName);

            MessageBox.NotifyWarn(message, DialogsTitle);
        }