From 24be7b2180695153c82bd2cc6d563af8f1f43a39 Mon Sep 17 00:00:00 2001 From: 2dust <31833384+2dust@users.noreply.github.com> Date: Fri, 10 Feb 2023 16:01:47 +0800 Subject: [PATCH] store msg filter --- v2rayN/v2rayN/Global.cs | 2 +- v2rayN/v2rayN/Mode/ConfigItems.cs | 1 + v2rayN/v2rayN/Views/MsgView.xaml | 3 ++- v2rayN/v2rayN/Views/MsgView.xaml.cs | 12 ++++++++++++ 4 files changed, 16 insertions(+), 2 deletions(-) diff --git a/v2rayN/v2rayN/Global.cs b/v2rayN/v2rayN/Global.cs index 83aaeed1..12b478e0 100644 --- a/v2rayN/v2rayN/Global.cs +++ b/v2rayN/v2rayN/Global.cs @@ -114,7 +114,7 @@ public static readonly List Protocols = new List { "http", "tls", "bittorrent" }; public static readonly List TunMtus = new List { "9000", "1500" }; public static readonly List TunStacks = new List { "gvisor", "system" }; - public static readonly List PresetMsgFilters = new List { "^(?!.*proxy).*$", "^(?!.*direct).*$", "" }; + public static readonly List PresetMsgFilters = new List { "proxy", "direct", "block", "" }; public static readonly List SpeedTestUrls = new List { @"http://cachefly.cachefly.net/100mb.test", @"http://cachefly.cachefly.net/10mb.test" }; #endregion diff --git a/v2rayN/v2rayN/Mode/ConfigItems.cs b/v2rayN/v2rayN/Mode/ConfigItems.cs index 5f89e201..e2620071 100644 --- a/v2rayN/v2rayN/Mode/ConfigItems.cs +++ b/v2rayN/v2rayN/Mode/ConfigItems.cs @@ -122,6 +122,7 @@ namespace v2rayN.Mode public bool enableDragDropSort { get; set; } public bool doubleClick2Activate { get; set; } public bool autoHideStartup { get; set; } = true; + public string mainMsgFilter { get; set; } public Dictionary mainLvColWidth { get; set; } } diff --git a/v2rayN/v2rayN/Views/MsgView.xaml b/v2rayN/v2rayN/Views/MsgView.xaml index f2f75e8d..af464d31 100644 --- a/v2rayN/v2rayN/Views/MsgView.xaml +++ b/v2rayN/v2rayN/Views/MsgView.xaml @@ -29,7 +29,8 @@ materialDesign:HintAssist.Hint="{x:Static resx:ResUI.MsgFilterTitle}" materialDesign:TextFieldAssist.HasClearButton="True" IsEditable="True" - Style="{StaticResource DefComboBox}" /> + Style="{StaticResource DefComboBox}" + TextBoxBase.TextChanged="cmbMsgFilter_TextChanged" /> ("MsgView").Subscribe(x => DelegateAppendText(x)); Global.PresetMsgFilters.ForEach(it => { cmbMsgFilter.Items.Add(it); }); + if (!_config.uiItem.mainMsgFilter.IsNullOrEmpty()) + { + cmbMsgFilter.Text = _config.uiItem.mainMsgFilter; + } } void DelegateAppendText(string msg) @@ -86,6 +94,10 @@ namespace v2rayN.Views private void menuMsgViewClear_Click(object sender, System.Windows.RoutedEventArgs e) { ClearMsg(); + } + private void cmbMsgFilter_TextChanged(object sender, System.Windows.Controls.TextChangedEventArgs e) + { + _config.uiItem.mainMsgFilter = cmbMsgFilter.Text.TrimEx(); } }