Optimize server filter

pull/3677/head
2dust 2 years ago
parent 3fa22fdc55
commit b8959c8f12

@ -1411,7 +1411,7 @@ namespace v2rayN.Resx {
} }
/// <summary> /// <summary>
/// 查找类似 Servers Filter 的本地化字符串。 /// 查找类似 Servers Filter, press Enter to execute 的本地化字符串。
/// </summary> /// </summary>
public static string MsgServerTitle { public static string MsgServerTitle {
get { get {

@ -434,7 +434,7 @@
<value>Local</value> <value>Local</value>
</data> </data>
<data name="MsgServerTitle" xml:space="preserve"> <data name="MsgServerTitle" xml:space="preserve">
<value>Servers Filter</value> <value>Servers Filter, press Enter to execute</value>
</data> </data>
<data name="menuCheckUpdate" xml:space="preserve"> <data name="menuCheckUpdate" xml:space="preserve">
<value>Check Update</value> <value>Check Update</value>

@ -434,7 +434,7 @@
<value>本地</value> <value>本地</value>
</data> </data>
<data name="MsgServerTitle" xml:space="preserve"> <data name="MsgServerTitle" xml:space="preserve">
<value>服务器过滤器</value> <value>服务器过滤器,按回车执行</value>
</data> </data>
<data name="menuCheckUpdate" xml:space="preserve"> <data name="menuCheckUpdate" xml:space="preserve">
<value>检查更新</value> <value>检查更新</value>

@ -718,10 +718,13 @@ namespace v2rayN.ViewModels
return; return;
} }
_serverFilter = ServerFilter; _serverFilter = ServerFilter;
if (Utils.IsNullOrEmpty(_serverFilter))
{
RefreshServers(); RefreshServers();
} }
}
private void RefreshServers() public void RefreshServers()
{ {
List<ProfileItemModel> lstModel = LazyConfig.Instance.ProfileItems(_subId, _serverFilter); List<ProfileItemModel> lstModel = LazyConfig.Instance.ProfileItems(_subId, _serverFilter);

@ -499,6 +499,7 @@
GridLinesVisibility="All" GridLinesVisibility="All"
HeadersVisibility="All" HeadersVisibility="All"
IsReadOnly="True" IsReadOnly="True"
RowHeaderWidth="40"
Style="{StaticResource DefDataGrid}"> Style="{StaticResource DefDataGrid}">
<DataGrid.InputBindings> <DataGrid.InputBindings>
<KeyBinding Command="ApplicationCommands.NotACommand" Gesture="Ctrl+C" /> <KeyBinding Command="ApplicationCommands.NotACommand" Gesture="Ctrl+C" />

@ -30,10 +30,10 @@ namespace v2rayN.Views
this.Closing += MainWindow_Closing; this.Closing += MainWindow_Closing;
this.PreviewKeyDown += MainWindow_PreviewKeyDown; this.PreviewKeyDown += MainWindow_PreviewKeyDown;
btnAutofitColumnWidth.Click += BtnAutofitColumnWidth_Click; btnAutofitColumnWidth.Click += BtnAutofitColumnWidth_Click;
txtServerFilter.PreviewKeyDown += TxtServerFilter_PreviewKeyDown;
lstProfiles.PreviewKeyDown += LstProfiles_PreviewKeyDown; lstProfiles.PreviewKeyDown += LstProfiles_PreviewKeyDown;
lstProfiles.SelectionChanged += lstProfiles_SelectionChanged; lstProfiles.SelectionChanged += lstProfiles_SelectionChanged;
lstProfiles.LoadingRow += LstProfiles_LoadingRow; lstProfiles.LoadingRow += LstProfiles_LoadingRow;
lstProfiles.RowHeaderWidth = 30;
if (_config.uiItem.enableDragDropSort) if (_config.uiItem.enableDragDropSort)
{ {
lstProfiles.AllowDrop = true; lstProfiles.AllowDrop = true;
@ -408,6 +408,14 @@ namespace v2rayN.Views
it.Width = new DataGridLength(1, DataGridLengthUnitType.Auto); it.Width = new DataGridLength(1, DataGridLengthUnitType.Auto);
} }
} }
private void TxtServerFilter_PreviewKeyDown(object sender, KeyEventArgs e)
{
if (e.Key is Key.Enter or Key.Return)
{
ViewModel?.RefreshServers();
}
}
#endregion #endregion
#region UI #region UI

Loading…
Cancel
Save