Added a new reusable FileSelector control allowing tools to get one or many files as input. #308
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Pull request type
Please check the type of change your PR introduces:
What is the current behavior?
More and more tools are getting the ability to accept files as an input, in particular tools in the Graphic category.
Unfortunately, each tools were copying the UI and implementation for letting the user selecting a file, leading to a bunch of duplicated code.
Issue Number: #244, #151
What is the new behavior?
Created a control
FileSelector
which basically unify the UI and implementation for such a need.The control has several parameters:
AllowedFileExtensions
- Defines the exhaustive list of file type that the user can select through the control. Using "*" or a null value corresponds to allowing any kind of file.AllowMultipleFileSelection
- Tells whether the user will be able to select a single or multiple files. Changing this value changes the way the Drag & Drop instructions are displayed. Setting this value totrue
also display aBrowse folders
option, which allows the user to select a folder. The control will then pick up the files in this folder (but not sub-folders) that matchAllowedFileExtensions
.AllowPasteImage
- The "Paste" button allows the user to paste one or several files that he has in the clipboard. Enabling this option will additionally allow the user to paste an image from the clipboard such as a screenshot.FilesSelectedCommand
- A MVVM command that is invoked once the user selected a file, so the tool can reacts to the user interaction.The control filters automatically the selected / dropped / pasted files based on the
AllowedFileExtensions
and shows a message when the files don't respect the filter. However, it doesn't show this message when selecting a folder.Here is how to use the control:
Other information
Quality check
Before creating this PR, have you: