Open File Dialog
KAMISHIBAI supports the following three types of dialogs
- single file selection dialog
- multiple file selection dialog
- folder selection dialog
Single File Selection Dialog
Pass OpenFileDialogContext to the OpenFile method of IPresentationService.
var context = new OpenFileDialogContext
{
Title = "Please select an image"
};
context.Filters.Add(new FileDialogFilter("Image", "png", "jpg"));
context.Filters.Add(new FileDialogFilter("All files", "*"));
if (_presentationService.OpenFile(context) == DialogResult.Ok)
{
var file = context.FileName;
...
}
The path to the selected file is obtained from the context’s FileName property.
See the API document below for details.
Multiple File Selection Dialog
Set Multiselect to true in OpenFileDialogContext.
var context = new OpenFileDialogContext
{
Title = "Please select an image",
Multiselect = true
};
context.Filters.Add(new FileDialogFilter("Image", "png", "jpg"));
context.Filters.Add(new FileDialogFilter("All files", "*"));
if (_presentationService.OpenFile(context) == DialogResult.Ok)
{
var files = context.FileNames;
...
}
The path of the selected files is obtained from the context’s FileNames property.
Folder Selection Dialog
Set true to IsFolderPicker in OpenFileDialogContext.
var context = new OpenFileDialogContext
{
IsFolderPicker = true
};
if (_presentationService.OpenFile(context) == DialogResult.Ok)
{
var file = context.FileName;
...
}
The path to the selected folder is obtained from the context’s FileName property.
« Message Dialog | Menu | Save File Dialog » |