Class FileDialog
- Namespace
- Myra.Graphics2D.UI.File
- Assembly
- Myra.dll
A dialog for selecting files or folders from the file system.
public class FileDialog : Dialog, IItemWithId, INotifyAttachedPropertyChanged, IContent
- Inheritance
-
FileDialog
- Implements
- Inherited Members
Constructors
FileDialog(FileDialogMode, Stylesheet, string)
Initializes a new instance of the FileDialog class with the specified mode, stylesheet, and style.
public FileDialog(FileDialogMode mode, Stylesheet stylesheet, string styleName = "")
Parameters
modeFileDialogModeThe file dialog mode (open file, save file, or choose folder).
stylesheetStylesheetThe stylesheet to use for applying the style.
styleNamestringThe name of the style to apply. Defaults to the default stylesheet style.
FileDialog(FileDialogMode, string)
Initializes a new instance of the FileDialog class with the specified mode.
public FileDialog(FileDialogMode mode, string styleName = "")
Parameters
modeFileDialogModeThe file dialog mode (open file, save file, or choose folder).
styleNamestringThe name of the style to apply. Defaults to the default stylesheet style.
Properties
AutoAddFilterExtension
Gets or sets a value indicating whether to automatically add the file extension based on the active filter.
public bool AutoAddFilterExtension { get; set; }
Property Value
FilePath
Gets or sets the full path of the selected file or folder.
public string FilePath { get; set; }
Property Value
Filter
Gets or sets the file filter used when enumerating files (e.g., ".txt" or ".*").
public string Filter { get; set; }
Property Value
Folder
Gets or sets the current folder path being browsed.
public string Folder { get; set; }
Property Value
IconDrive
Gets or sets the image displayed for drive items in the file list.
public IImage IconDrive { get; set; }
Property Value
IconFolder
Gets or sets the image displayed for folder items in the file list.
public IImage IconFolder { get; set; }
Property Value
ShowHiddenFiles
Gets or sets a value indicating whether hidden files and folders are shown in the file list.
public bool ShowHiddenFiles { get; set; }
Property Value
Methods
ApplyStyle(WidgetStyle)
Applies the specified widget style to this file dialog.
protected override void ApplyStyle(WidgetStyle style)
Parameters
styleWidgetStyleThe widget style to apply.
CanCloseByOk()
Determines whether the dialog can be closed by clicking OK. For save dialogs, confirms file overwrite if necessary.
protected override bool CanCloseByOk()
Returns
- bool
True if the dialog can be closed; otherwise, false.
CreateListItem(Location)
Creates a display widget for the given file system location (drive or folder).
protected virtual Widget CreateListItem(FileDialog.Location location)
Parameters
locationFileDialog.LocationThe location to create a display widget for.
Returns
- Widget
A widget displaying the location with icon and label.
OnPlacedChanged()
Handles the placement of the dialog window and updates the folder view.
protected override void OnPlacedChanged()
PopulatePlacesListUI(ListView)
Populates the navigation menu with places that can be visited (user directories and drives).
protected virtual void PopulatePlacesListUI(ListView listView)
Parameters
listViewListViewThe list view to populate with place items.
ShowIOError(string, string)
Displays an error message dialog for I/O operations that failed.
protected void ShowIOError(string path, string exceptionMsg)
Parameters
pathstringThe file path where the error occurred.
exceptionMsgstringThe error message describing what went wrong.
TryAccessDirectory(string)
Determines whether a path is a valid accessible directory that can be browsed.
protected bool TryAccessDirectory(string path)
Parameters
pathstringThe directory path to check.
Returns
- bool
True if the path is a valid directory with appropriate access permissions; otherwise, false.