Skip to content

Force Proxy to any Windows/MacOS/Linux Application TCP and UDP traffic

#60 added delete selection proxy rule

Sourav Kalal3ad55abcf944
diff --git a/Windows/gui/ViewModels/ProxyRulesViewModel.cs b/Windows/gui/ViewModels/ProxyRulesViewModel.cs
index 811b10e..6f8f6bd 100644
--- a/Windows/gui/ViewModels/ProxyRulesViewModel.cs
+++ b/Windows/gui/ViewModels/ProxyRulesViewModel.cs
@@ -87,6 +87,7 @@ public class ProxyRulesViewModel : ViewModelBase
public ICommand ToggleSelectAllCommand { get; }
public ICommand ExportRulesCommand { get; }
public ICommand ImportRulesCommand { get; }
+ public ICommand DeleteSelectedRulesCommand { get; }
public bool HasSelectedRules => ProxyRules.Any(r => r.IsSelected);
public bool AllRulesSelected => ProxyRules.Any() && ProxyRules.All(r => r.IsSelected);
@@ -314,6 +315,33 @@ public class ProxyRulesViewModel : ViewModelBase
await ShowMessageAsync("Import Failed", $"Failed to import rules: {ex.Message}");
}
});
+
+ DeleteSelectedRulesCommand = new RelayCommand(async () =>
+ {
+ var selectedRules = ProxyRules.Where(r => r.IsSelected).ToList();
+ if (selectedRules.Count == 0)
+ return;
+
+ var confirmMsg = selectedRules.Count == 1
+ ? $"Delete 1 selected rule?"
+ : $"Delete {selectedRules.Count} selected rules?";
+
+ var confirmed = await ShowConfirmDialogAsync("Delete Selected Rules", confirmMsg);
+ if (!confirmed)
+ return;
+
+ foreach (var rule in selectedRules)
+ {
+ if (_proxyService != null && _proxyService.DeleteRule(rule.RuleId))
+ {
+ ProxyRules.Remove(rule);
+ }
+ }
+
+ _onConfigChanged?.Invoke();
+ OnPropertyChanged(nameof(HasSelectedRules));
+ OnPropertyChanged(nameof(AllRulesSelected));
+ });
}
private async System.Threading.Tasks.Task<bool> ShowConfirmDialogAsync(string title, string message)
diff --git a/Windows/gui/Views/ProxyRulesWindow.axaml b/Windows/gui/Views/ProxyRulesWindow.axaml
index 7da1fc1..b54d75c 100644
--- a/Windows/gui/Views/ProxyRulesWindow.axaml
+++ b/Windows/gui/Views/ProxyRulesWindow.axaml
@@ -48,6 +48,15 @@
</StackPanel>
</Button.Content>
</Button>
+ <Button Command="{Binding DeleteSelectedRulesCommand}"
+ Classes="secondary"
+ Padding="12,8"
+ IsEnabled="{Binding HasSelectedRules}">
+ <StackPanel Orientation="Horizontal" Spacing="6">
+ <TextBlock Text="🗑" FontSize="14"/>
+ <TextBlock Text="Delete Selected"/>
+ </StackPanel>
+ </Button>
<Button Command="{Binding ExportRulesCommand}"
Classes="secondary"
Padding="12,8"