Exemplo n.º 1
0
        private void AddFiles()
        {
            OpenFileDialogOptions options = new OpenFileDialogOptions();

            options.CheckFileExists = true;
            options.Filter          = "Film files|*.avi;*.srt;*.mkv;*.mp4;*.flv|Recent files|RecentFiles.*.xml|All files|*.*";
            options.InitialFolder   = LastFolder;
            options.Title           = "Select File(s) to Copy";

            String[] fileNames;
            if (UIServices.ShowOpenFileDialog(options, out fileNames))
            {
                LastFolder = IOServices.GetFileInfo(fileNames[0]).FolderName;

                foreach (String file in fileNames)
                {
                    if ((file.Contains("RecentFiles")) && (file.EndsWith(".xml")))
                    {
                        Model.ReadXml(file);

                        TryAutoApplyFilter();
                    }
                    else
                    {
                        Model.AddEntry(file);
                    }
                }

                RaiseFileEntriesChanged();
            }
        }
        public async Task <OpenFileDialogResult> ShowDialogAsync(OpenFileDialogOptions options)
        {
            Microsoft.Win32.OpenFileDialog openFileDialog = new()
            {
                Filter = await ConvertFileFiltersToFileFilterFormat(options.FileFilters)
            };

            return(openFileDialog.ShowDialog() switch
            {
                true => OnTrueResult(openFileDialog),
                false => OnFalseResult(),
                _ => throw new OpenFileDialogUnknownResultTypeException("An unknown error occurred while reading the result of the dialog box!")
            });
        }