Table of Contents

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

mode FileDialogMode

The file dialog mode (open file, save file, or choose folder).

stylesheet Stylesheet

The stylesheet to use for applying the style.

styleName string

The 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

mode FileDialogMode

The file dialog mode (open file, save file, or choose folder).

styleName string

The 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

bool

FilePath

Gets or sets the full path of the selected file or folder.

public string FilePath { get; set; }

Property Value

string

Filter

Gets or sets the file filter used when enumerating files (e.g., ".txt" or ".*").

public string Filter { get; set; }

Property Value

string

Folder

Gets or sets the current folder path being browsed.

public string Folder { get; set; }

Property Value

string

IconDrive

Gets or sets the image displayed for drive items in the file list.

public IImage IconDrive { get; set; }

Property Value

IImage

IconFolder

Gets or sets the image displayed for folder items in the file list.

public IImage IconFolder { get; set; }

Property Value

IImage

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

bool

Methods

ApplyStyle(WidgetStyle)

Applies the specified widget style to this file dialog.

protected override void ApplyStyle(WidgetStyle style)

Parameters

style WidgetStyle

The 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

location FileDialog.Location

The 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

listView ListView

The 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

path string

The file path where the error occurred.

exceptionMsg string

The 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

path string

The directory path to check.

Returns

bool

True if the path is a valid directory with appropriate access permissions; otherwise, false.