Пример #1
0
 public OpenFileDialogResult ShowOpenFileDialog(OpenFileDialogParameters openFileDialogParameters)
 {
     if (openFileDialogParameters == null)
         throw new ArgumentNullException("openFileDialogParameters");
     OpenFileDialog openFileDialog = new OpenFileDialog();
     if (!String.IsNullOrEmpty(openFileDialogParameters.Filter))
         openFileDialog.Filter = openFileDialogParameters.Filter;
     openFileDialog.Multiselect = openFileDialogParameters.Multiselect;
     if (!String.IsNullOrEmpty(openFileDialogParameters.InitialDirectory))
         openFileDialog.InitialDirectory = openFileDialogParameters.InitialDirectory;
     OpenFileDialogResult result = new OpenFileDialogResult();
     result.DialogResult = openFileDialog.ShowDialog() == true;
     result.SelectedFilePaths = result.DialogResult ? openFileDialog.FileNames.ToList() : new List<string>();
     return result;
 }
Пример #2
0
        public OpenFileDialogResult ShowOpenFileDialog(OpenFileDialogParameters openFileDialogParameters)
        {
            if (openFileDialogParameters == null)
            {
                throw new ArgumentNullException("openFileDialogParameters");
            }
            OpenFileDialog openFileDialog = new OpenFileDialog();

            if (!String.IsNullOrEmpty(openFileDialogParameters.Filter))
            {
                openFileDialog.Filter = openFileDialogParameters.Filter;
            }
            openFileDialog.Multiselect = openFileDialogParameters.Multiselect;
            if (!String.IsNullOrEmpty(openFileDialogParameters.InitialDirectory))
            {
                openFileDialog.InitialDirectory = openFileDialogParameters.InitialDirectory;
            }
            OpenFileDialogResult result = new OpenFileDialogResult();

            result.DialogResult      = openFileDialog.ShowDialog() == true;
            result.SelectedFilePaths = result.DialogResult ? openFileDialog.FileNames.ToList() : new List <string>();
            return(result);
        }