mirror of
https://github.com/goatcorp/Dalamud.git
synced 2026-02-13 19:37:44 +01:00
Merge pull request #2616 from Glorou/FileOnSelect
Add a file selection changed event to FileDialog and it's manager
This commit is contained in:
commit
c4faf84a2d
3 changed files with 13 additions and 0 deletions
|
|
@ -657,6 +657,7 @@ public partial class FileDialog
|
|||
this.fileNameBuffer = $"{this.selectedFileNames.Count} files Selected";
|
||||
}
|
||||
|
||||
this.SelectionChanged(this, this.GetFilePathName());
|
||||
if (setLastSelection)
|
||||
{
|
||||
this.lastSelectedFileName = name;
|
||||
|
|
|
|||
|
|
@ -97,6 +97,8 @@ public partial class FileDialog
|
|||
this.SetupSideBar();
|
||||
}
|
||||
|
||||
public event EventHandler<string>? SelectionChanged;
|
||||
|
||||
/// <summary>
|
||||
/// Shows the dialog.
|
||||
/// </summary>
|
||||
|
|
|
|||
|
|
@ -30,6 +30,12 @@ public class FileDialogManager
|
|||
private Action<bool, List<string>>? multiCallback;
|
||||
private string savedPath = ".";
|
||||
|
||||
/// <summary>
|
||||
/// Event fires when a new file is selected by the user
|
||||
/// </summary>
|
||||
/// <returns>Returns the path of the file as a string</returns>
|
||||
public event EventHandler<string>? SelectionChanged;
|
||||
|
||||
/// <summary>
|
||||
/// Create a dialog which selects an already existing folder.
|
||||
/// </summary>
|
||||
|
|
@ -175,6 +181,8 @@ public class FileDialogManager
|
|||
this.multiCallback = null;
|
||||
}
|
||||
|
||||
private void OnSelectionChange(object sender, string path) => this.SelectionChanged?.Invoke(sender, path);
|
||||
|
||||
private void SetDialog(
|
||||
string id,
|
||||
string title,
|
||||
|
|
@ -200,6 +208,7 @@ public class FileDialogManager
|
|||
if (this.dialog is not null)
|
||||
{
|
||||
this.dialog.SortOrderChanged -= this.OnSortOrderChange;
|
||||
this.dialog.SelectionChanged -= this.OnSelectionChange;
|
||||
}
|
||||
|
||||
this.dialog = new FileDialog(id, title, filters, path, defaultFileName, defaultExtension, selectionCountMax, isModal, flags);
|
||||
|
|
@ -217,6 +226,7 @@ public class FileDialogManager
|
|||
}
|
||||
|
||||
this.dialog.SortOrderChanged += this.OnSortOrderChange;
|
||||
this.dialog.SelectionChanged += this.OnSelectionChange;
|
||||
this.dialog.WindowFlags |= this.AddedWindowFlags;
|
||||
foreach (var (name, location, icon, position) in this.CustomSideBarItems)
|
||||
this.dialog.SetQuickAccess(name, location, icon, position);
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue