From 9a55dac778ab71abd5aff78cf7c8f7306a7669e9 Mon Sep 17 00:00:00 2001 From: Pat Hartl Date: Mon, 11 Sep 2023 20:21:40 -0500 Subject: [PATCH] Auto populate server working directory based on executable path --- LANCommander/Components/FilePicker.razor | 4 ++++ LANCommander/Pages/Servers/Edit.razor | 7 ++++++- 2 files changed, 10 insertions(+), 1 deletion(-) diff --git a/LANCommander/Components/FilePicker.razor b/LANCommander/Components/FilePicker.razor index 0c8822a..dd101aa 100644 --- a/LANCommander/Components/FilePicker.razor +++ b/LANCommander/Components/FilePicker.razor @@ -24,6 +24,7 @@ @code { [Parameter] public string Value { get; set; } [Parameter] public EventCallback ValueChanged { get; set; } + [Parameter] public EventCallback OnSelected { get; set; } [Parameter] public Guid ArchiveId { get; set; } [Parameter] public string Title { get; set; } = "Choose File"; [Parameter] public string OkText { get; set; } = "Select File"; @@ -75,6 +76,9 @@ if (ValueChanged.HasDelegate) await ValueChanged.InvokeAsync(Value); + if (OnSelected.HasDelegate) + await OnSelected.InvokeAsync(Value); + StateHasChanged(); }; } diff --git a/LANCommander/Pages/Servers/Edit.razor b/LANCommander/Pages/Servers/Edit.razor index 3689e24..c6972f6 100644 --- a/LANCommander/Pages/Servers/Edit.razor +++ b/LANCommander/Pages/Servers/Edit.razor @@ -73,7 +73,7 @@ - + @@ -193,6 +193,11 @@ } } + private void OnPathSelected(string path) + { + Server.WorkingDirectory = Path.GetDirectoryName(path); + } + private void NotifyServerAdded(object? sender, LocationChangedEventArgs e) { NavigationManager.LocationChanged -= NotifyServerAdded;