diff --git a/Consts/MainConst.cs b/Consts/MainConst.cs index dff3caa..e65dfe8 100644 --- a/Consts/MainConst.cs +++ b/Consts/MainConst.cs @@ -40,6 +40,8 @@ internal abstract partial class MainConst : MainMultilangConst internal static string MihomoConfPath => Path.Combine(AppDomain.CurrentDomain.SetupInformation.ApplicationBase!, "config.yaml"); internal static string[] MihomoNameServers => ["https://doh.apad.pro/dns-query", "https://ns.net.kg/dns-query"]; + internal static string NotifyIconText => "Sheas Cealer"; + [GeneratedRegex(@"^(https?:\/\/)?[a-zA-Z0-9](-*[a-zA-Z0-9])*(\.[a-zA-Z0-9](-*[a-zA-Z0-9])*)*(:\d{1,5})?(\/[a-zA-Z0-9.\-_\~\!\$\&\'\(\)\*\+\,\;\=\:\@\%]*)*$")] internal static partial Regex UpstreamUrlRegex(); diff --git a/Wins/MainWin.xaml.cs b/Wins/MainWin.xaml.cs index e0c111d..3a48911 100644 --- a/Wins/MainWin.xaml.cs +++ b/Wins/MainWin.xaml.cs @@ -15,6 +15,7 @@ using System.Net; using System.Net.Http; using System.Net.NetworkInformation; using System.Net.Sockets; +using System.Reflection; using System.Security.Cryptography; using System.Security.Cryptography.X509Certificates; using System.Text; @@ -760,7 +761,23 @@ public partial class MainWin : Window } private void MainWin_KeyDown(object sender, KeyEventArgs e) { - if (e.KeyboardDevice.Modifiers == ModifierKeys.Control && e.Key == Key.W) + if (e.KeyboardDevice.Modifiers != ModifierKeys.Control) + return; + + if (e.Key == Key.W) Application.Current.Shutdown(); + else if (e.Key == Key.H) + { + System.Windows.Forms.NotifyIcon notifyIcon = new() { Icon = System.Drawing.Icon.ExtractAssociatedIcon(Assembly.GetExecutingAssembly().Location), Text = MainConst.NotifyIconText, Visible = true }; + + notifyIcon.Click += (_, _) => + { + Show(); + + notifyIcon.Dispose(); + }; + + Hide(); + } } } \ No newline at end of file