This commit is contained in:
DHR60 2025-09-06 19:19:34 +08:00
parent f9ea8d83d0
commit 0085e0a507
4 changed files with 34 additions and 1 deletions

View file

@ -27,6 +27,7 @@
<Button
x:Name="btnSave"
Width="100"
Click="BtnSave_Click"
Content="{x:Static resx:ResUI.TbConfirm}" />
<Button
x:Name="btnCancel"
@ -83,6 +84,9 @@
IsReadOnly="True"
ItemsSource="{Binding ProfileItems}"
SelectionMode="Single">
<DataGrid.KeyBindings>
<KeyBinding Command="{Binding SelectFinish}" Gesture="Enter" />
</DataGrid.KeyBindings>
<DataGrid.Columns>
<DataGridTextColumn
Width="80"

View file

@ -18,6 +18,7 @@ public partial class ProfilesSelectWindow : ReactiveWindow<ProfilesSelectViewMod
private static Config _config;
public Task<ProfileItem?> ProfileItem => GetFirstProfileItemAsync();
private bool _allowMultiSelect = false;
public ProfilesSelectWindow()
{
@ -51,6 +52,7 @@ public partial class ProfilesSelectWindow : ReactiveWindow<ProfilesSelectViewMod
public void AllowMultiSelect(bool allow)
{
_allowMultiSelect = allow;
if (allow)
{
lstProfiles.SelectionMode = DataGridSelectionMode.Extended;
@ -112,15 +114,20 @@ public partial class ProfilesSelectWindow : ReactiveWindow<ProfilesSelectViewMod
if (e.KeyModifiers is KeyModifiers.Control or KeyModifiers.Meta)
{
if (e.Key == Key.A)
{
if (_allowMultiSelect)
{
lstProfiles.SelectAll();
}
e.Handled = true;
}
}
else
{
if (e.Key is Key.Enter or Key.Return)
{
ViewModel?.SelectFinish();
e.Handled = true;
}
}
}
@ -157,4 +164,10 @@ public partial class ProfilesSelectWindow : ReactiveWindow<ProfilesSelectViewMod
var item = await ViewModel?.GetProfileItem();
return item;
}
private void BtnSave_Click(object sender, RoutedEventArgs e)
{
// Trigger selection finalize when Confirm is clicked
ViewModel?.SelectFinish();
}
}

View file

@ -35,6 +35,7 @@
Width="100"
Content="{x:Static resx:ResUI.TbConfirm}"
IsDefault="True"
Click="BtnSave_Click"
Style="{StaticResource DefButton}" />
<Button
x:Name="btnCancel"

View file

@ -16,6 +16,7 @@ public partial class ProfilesSelectWindow
private static Config _config;
public Task<ProfileItem?> ProfileItem => GetFirstProfileItemAsync();
private bool _allowMultiSelect = false;
public ProfilesSelectWindow()
{
@ -46,6 +47,7 @@ public partial class ProfilesSelectWindow
public void AllowMultiSelect(bool allow)
{
_allowMultiSelect = allow;
if (allow)
{
lstProfiles.SelectionMode = DataGridSelectionMode.Extended;
@ -108,6 +110,10 @@ public partial class ProfilesSelectWindow
private void menuSelectAll_Click(object sender, RoutedEventArgs e)
{
if (!_allowMultiSelect)
{
return;
}
lstProfiles.SelectAll();
}
@ -119,6 +125,7 @@ public partial class ProfilesSelectWindow
{
case Key.A:
menuSelectAll_Click(null, null);
e.Handled = true;
break;
}
}
@ -127,6 +134,7 @@ public partial class ProfilesSelectWindow
if (e.Key is Key.Enter or Key.Return)
{
ViewModel?.SelectFinish();
e.Handled = true;
}
}
}
@ -156,6 +164,7 @@ public partial class ProfilesSelectWindow
if (e.Key is Key.Enter or Key.Return)
{
ViewModel?.RefreshServers();
e.Handled = true;
}
}
@ -164,5 +173,11 @@ public partial class ProfilesSelectWindow
var item = await ViewModel?.GetProfileItem();
return item;
}
private void BtnSave_Click(object sender, RoutedEventArgs e)
{
// Trigger selection finalize when Confirm is clicked
ViewModel?.SelectFinish();
}
#endregion Event
}