From a97f5812567bac5b6e3a45d8bb6e1febd79a28dc Mon Sep 17 00:00:00 2001 From: Erik Darling <2136037+erikdarlingdata@users.noreply.github.com> Date: Wed, 8 Apr 2026 09:20:05 -0400 Subject: [PATCH] Add server name dropdown for saved connections (issue #183) Replace AutoCompleteBox with TextBox + dropdown button + Popup ListBox so users can see and pick from all previously saved connections. Saved connections are sorted by most recently used. Co-Authored-By: Claude Opus 4.6 (1M context) --- .../Dialogs/ConnectionDialog.axaml | 32 ++++++++++++++++--- .../Dialogs/ConnectionDialog.axaml.cs | 22 ++++++++++--- 2 files changed, 44 insertions(+), 10 deletions(-) diff --git a/src/PlanViewer.App/Dialogs/ConnectionDialog.axaml b/src/PlanViewer.App/Dialogs/ConnectionDialog.axaml index 3b80a42..818c016 100644 --- a/src/PlanViewer.App/Dialogs/ConnectionDialog.axaml +++ b/src/PlanViewer.App/Dialogs/ConnectionDialog.axaml @@ -13,11 +13,33 @@ - + + + + + + + + + s.ServerName).Distinct().ToList(); - ServerNameBox.ItemsSource = serverNames; + var serverNames = _savedConnections + .OrderByDescending(s => s.LastConnected) + .Select(s => s.ServerName) + .Distinct() + .ToList(); + ServerList.ItemsSource = serverNames; // Pre-fill the most recently used connection var mostRecent = _savedConnections @@ -84,12 +88,14 @@ private void ApplySavedConnection(ServerConnection saved) } } - // When the user picks a saved server from the autocomplete dropdown - private void ServerName_SelectionChanged(object? sender, SelectionChangedEventArgs e) + private void ServerList_SelectionChanged(object? sender, SelectionChangedEventArgs e) { - var serverName = ServerNameBox.SelectedItem?.ToString(); + var serverName = ServerList.SelectedItem?.ToString(); if (string.IsNullOrEmpty(serverName)) return; + ServerNameBox.Text = serverName; + ServerDropdown.IsOpen = false; + var saved = _savedConnections.FirstOrDefault(s => s.ServerName.Equals(serverName, StringComparison.OrdinalIgnoreCase)); @@ -190,6 +196,12 @@ private void Connect_Click(object? sender, RoutedEventArgs e) Close(true); } + private void DropdownButton_Click(object? sender, RoutedEventArgs e) + { + ServerDropdown.MinWidth = ServerNameGrid.Bounds.Width; + ServerDropdown.IsOpen = !ServerDropdown.IsOpen; + } + private void Cancel_Click(object? sender, RoutedEventArgs e) { Close(false);