Force Proxy to any Windows/MacOS/Linux Application TCP and UDP traffic
C ccybersecurityhttp3httpproxylinuxlinux-proxymacosmacos-appmacos-proxyproxifierproxifier-alternativeproxyclienttcpthick-clientudpwindivertwindows
#14 - moved minimize to tray as optional
Sourav Kalal2169555a5bf8
diff --git a/gui/Resources/Resources.Designer.cs b/gui/Resources/Resources.Designer.csindex f3b40c7..d964c9b 100644--- a/gui/Resources/Resources.Designer.cs+++ b/gui/Resources/Resources.Designer.cs@@ -98,6 +98,12 @@ namespace ProxyBridge.GUI.Resources {}}+ internal static string MenuCloseToTray {+ get {+ return ResourceManager.GetString("MenuCloseToTray", resourceCulture);+ }+ }+/// <summary>/// Looks up a localized string similar to Language./// </summary>diff --git a/gui/Resources/Resources.resx b/gui/Resources/Resources.resxindex 9885cdb..658c3f5 100644--- a/gui/Resources/Resources.resx+++ b/gui/Resources/Resources.resx@@ -29,6 +29,9 @@<data name="MenuSettings" xml:space="preserve"><value>Settings</value></data>+ <data name="MenuCloseToTray" xml:space="preserve">+ <value>Close to System Tray</value>+ </data><data name="MenuLanguage" xml:space="preserve"><value>Language</value></data>diff --git a/gui/Resources/Resources.zh.resx b/gui/Resources/Resources.zh.resxindex d6a5851..f3fcabb 100644--- a/gui/Resources/Resources.zh.resx+++ b/gui/Resources/Resources.zh.resx@@ -29,6 +29,9 @@<data name="MenuSettings" xml:space="preserve"><value>设置</value></data>+ <data name="MenuCloseToTray" xml:space="preserve">+ <value>关闭到系统托盘</value>+ </data><data name="MenuLanguage" xml:space="preserve"><value>语言</value></data>diff --git a/gui/Services/ConfigManager.cs b/gui/Services/ConfigManager.csindex d6d67c0..75a8151 100644--- a/gui/Services/ConfigManager.cs+++ b/gui/Services/ConfigManager.cs@@ -16,6 +16,7 @@ public class AppConfigpublic string ProxyPassword { get; set; } = "";public bool DnsViaProxy { get; set; } = true;public string Language { get; set; } = "en";+ public bool CloseToTray { get; set; } = true;public List<ProxyRuleConfig> ProxyRules { get; set; } = new();}diff --git a/gui/Services/Loc.cs b/gui/Services/Loc.csindex 1ea53d1..85cb1d0 100644--- a/gui/Services/Loc.cs+++ b/gui/Services/Loc.cs@@ -42,6 +42,7 @@ public class Loc : INotifyPropertyChangedpublic string MenuProxyRules => Resources.Resources.MenuProxyRules;public string MenuDnsViaProxy => Resources.Resources.MenuDnsViaProxy;public string MenuSettings => Resources.Resources.MenuSettings;+ public string MenuCloseToTray => Resources.Resources.MenuCloseToTray;public string MenuLanguage => Resources.Resources.MenuLanguage;public string MenuAbout => Resources.Resources.MenuAbout;public string MenuAboutProxyBridge => Resources.Resources.MenuAboutProxyBridge;diff --git a/gui/ViewModels/MainWindowViewModel.cs b/gui/ViewModels/MainWindowViewModel.csindex cb2358b..92e6d95 100644--- a/gui/ViewModels/MainWindowViewModel.cs+++ b/gui/ViewModels/MainWindowViewModel.cs@@ -262,6 +262,13 @@ public class MainWindowViewModel : ViewModelBase}}+ private bool _closeToTray = true;+ public bool CloseToTray+ {+ get => _closeToTray;+ set => SetProperty(ref _closeToTray, value);+ }+private readonly Loc _loc = Loc.Instance;public Loc Loc => _loc;@@ -287,6 +294,7 @@ public class MainWindowViewModel : ViewModelBasepublic ICommand ShowAboutCommand { get; }public ICommand CheckForUpdatesCommand { get; }public ICommand ToggleDnsViaProxyCommand { get; }+ public ICommand ToggleCloseToTrayCommand { get; }public ICommand CloseDialogCommand { get; }public ICommand ClearConnectionsLogCommand { get; }public ICommand ClearActivityLogCommand { get; }@@ -424,6 +432,12 @@ public class MainWindowViewModel : ViewModelBaseDnsViaProxy = !DnsViaProxy;});+ ToggleCloseToTrayCommand = new RelayCommand(() =>+ {+ CloseToTray = !CloseToTray;+ SaveConfiguration();+ });+CloseDialogCommand = new RelayCommand(CloseDialogs);ClearConnectionsLogCommand = new RelayCommand(() =>@@ -575,6 +589,8 @@ public class MainWindowViewModel : ViewModelBaseProxyUsername = _currentProxyUsername,ProxyPassword = _currentProxyPassword,DnsViaProxy = _dnsViaProxy,+ Language = _currentLanguage,+ CloseToTray = _closeToTray,ProxyRules = ProxyRules.Select(r => new ProxyRuleConfig{ProcessName = r.ProcessName,@@ -605,6 +621,7 @@ public class MainWindowViewModel : ViewModelBase_currentProxyPassword = config.ProxyPassword;DnsViaProxy = config.DnsViaProxy;+ CloseToTray = config.CloseToTray;_currentLanguage = config.Language;_loc.CurrentCulture = new System.Globalization.CultureInfo(config.Language);@@ -643,6 +660,8 @@ public class MainWindowViewModel : ViewModelBaseProxyUsername = _currentProxyUsername,ProxyPassword = _currentProxyPassword,DnsViaProxy = _dnsViaProxy,+ Language = _currentLanguage,+ CloseToTray = _closeToTray,ProxyRules = ProxyRules.Select(r => new ProxyRuleConfig{ProcessName = r.ProcessName,diff --git a/gui/Views/MainWindow.axaml b/gui/Views/MainWindow.axamlindex bbdc27f..dc9b46b 100644--- a/gui/Views/MainWindow.axaml+++ b/gui/Views/MainWindow.axaml@@ -215,6 +215,15 @@</MenuItem></MenuItem><MenuItem Header="{Binding Loc.MenuSettings}">+ <MenuItem Header="{Binding Loc.MenuCloseToTray}"+ Command="{Binding ToggleCloseToTrayCommand}">+ <MenuItem.Icon>+ <CheckBox IsChecked="{Binding CloseToTray}"+ IsHitTestVisible="False"+ Margin="0"/>+ </MenuItem.Icon>+ </MenuItem>+ <Separator/><MenuItem Header="{Binding Loc.MenuLanguage}"><MenuItem Header="English" Click="OnChangeLanguageEnglish"><MenuItem.Icon>diff --git a/gui/Views/MainWindow.axaml.cs b/gui/Views/MainWindow.axaml.csindex 390278b..ce0ec08 100644--- a/gui/Views/MainWindow.axaml.cs+++ b/gui/Views/MainWindow.axaml.cs@@ -20,13 +20,6 @@ public partial class MainWindow : Windowvm.SetMainWindow(this);}};-- // ,inimize to tray- this.Closing += (s, e) =>- {- e.Cancel = true;- this.Hide();- };}private void OnChangeLanguageEnglish(object? sender, RoutedEventArgs e)@@ -56,7 +49,28 @@ public partial class MainWindow : Windowbase.OnClosing(e);return;}- e.Cancel = true;- this.Hide();++ // verify if user cclose app or minimize to tray+ if (DataContext is MainWindowViewModel viewModel)+ {+ if (viewModel.CloseToTray)+ {+ // minimize to tray+ e.Cancel = true;+ this.Hide();+ }+ else+ {+ // exit the app if not tray+ viewModel.Cleanup();+ base.OnClosing(e);+ }+ }+ else+ {+ // fallback to tray+ e.Cancel = true;+ this.Hide();+ }}}