Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
32 changes: 27 additions & 5 deletions src/PlanViewer.App/Dialogs/ConnectionDialog.axaml
Original file line number Diff line number Diff line change
Expand Up @@ -13,11 +13,33 @@
<!-- Server Name -->
<TextBlock Grid.Row="0" Text="Server name" Foreground="{DynamicResource ForegroundBrush}"
FontSize="12" Margin="0,0,0,4"/>
<AutoCompleteBox Grid.Row="1" x:Name="ServerNameBox"
Watermark="e.g. sql2022 or server.database.windows.net"
FontSize="13" Height="32" Margin="0,0,0,12"
FilterMode="ContainsOrdinal"
SelectionChanged="ServerName_SelectionChanged"/>
<Grid Grid.Row="1" x:Name="ServerNameGrid" ColumnDefinitions="*,Auto" Margin="0,0,0,12" ColumnSpacing="0">
<TextBox x:Name="ServerNameBox"
Watermark="e.g. sql2022 or server.database.windows.net"
FontSize="13" Height="32"/>
<Button Grid.Column="1" Click="DropdownButton_Click"
Height="32" Width="32" Padding="0"
Background="Black" CornerRadius="0,4,4,0"
BorderBrush="White" BorderThickness="1">
<Path Data="M 0,0 L 4,4 L 8,0"
Stroke="{DynamicResource ForegroundBrush}"
StrokeThickness="1.5"
VerticalAlignment="Center"
HorizontalAlignment="Center"/>
</Button>
<Popup x:Name="ServerDropdown"
PlacementTarget="{Binding #ServerNameGrid}"
Placement="BottomEdgeAlignedLeft"
IsLightDismissEnabled="True"
MaxHeight="200">
<Border Background="{DynamicResource BackgroundBrush}"
BorderBrush="#555" BorderThickness="1" CornerRadius="4">
<ListBox x:Name="ServerList"
SelectionChanged="ServerList_SelectionChanged"
FontSize="13"/>
</Border>
</Popup>
</Grid>

<!-- Authentication -->
<TextBlock Grid.Row="2" Text="Authentication" Foreground="{DynamicResource ForegroundBrush}"
Expand Down
22 changes: 17 additions & 5 deletions src/PlanViewer.App/Dialogs/ConnectionDialog.axaml.cs
Original file line number Diff line number Diff line change
Expand Up @@ -34,8 +34,12 @@ public ConnectionDialog(ICredentialService credentialService, ConnectionStore co
private void PopulateSavedServers()
{
_savedConnections = _connectionStore.Load();
var serverNames = _savedConnections.Select(s => 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
Expand Down Expand Up @@ -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));

Expand Down Expand Up @@ -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);
Expand Down
2 changes: 1 addition & 1 deletion src/PlanViewer.App/PlanViewer.App.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
<ApplicationManifest>app.manifest</ApplicationManifest>
<ApplicationIcon>EDD.ico</ApplicationIcon>
<AvaloniaUseCompiledBindingsByDefault>true</AvaloniaUseCompiledBindingsByDefault>
<Version>1.4.2</Version>
<Version>1.4.3</Version>
<Authors>Erik Darling</Authors>
<Company>Darling Data LLC</Company>
<Product>Performance Studio</Product>
Expand Down
Loading