From 781fab5aab80d17915126c9ffb3f50866ce89b40 Mon Sep 17 00:00:00 2001 From: 2dust <31833384+2dust@users.noreply.github.com> Date: Tue, 3 Jan 2023 15:43:57 +0800 Subject: [PATCH] bug fix --- v2rayN/v2rayN/Views/RoutingSettingWindow.xaml.cs | 9 +++++++++ v2rayN/v2rayN/Views/SubSettingWindow.xaml.cs | 12 +++++++++++- 2 files changed, 20 insertions(+), 1 deletion(-) diff --git a/v2rayN/v2rayN/Views/RoutingSettingWindow.xaml.cs b/v2rayN/v2rayN/Views/RoutingSettingWindow.xaml.cs index 5fe538c59eb..e676a56f5b3 100644 --- a/v2rayN/v2rayN/Views/RoutingSettingWindow.xaml.cs +++ b/v2rayN/v2rayN/Views/RoutingSettingWindow.xaml.cs @@ -11,6 +11,7 @@ public partial class RoutingSettingWindow public RoutingSettingWindow() { InitializeComponent(); + this.Closing += RoutingSettingWindow_Closing; this.PreviewKeyDown += RoutingSettingWindow_PreviewKeyDown; lstRoutings.SelectionChanged += lstRoutings_SelectionChanged; lstRoutings.MouseDoubleClick += LstRoutings_MouseDoubleClick; @@ -61,6 +62,14 @@ public RoutingSettingWindow() }); } + private void RoutingSettingWindow_Closing(object? sender, System.ComponentModel.CancelEventArgs e) + { + if (ViewModel?.IsModified == true) + { + this.DialogResult = true; + } + } + private void RoutingSettingWindow_PreviewKeyDown(object sender, KeyEventArgs e) { if (Keyboard.IsKeyDown(Key.LeftCtrl) || Keyboard.IsKeyDown(Key.RightCtrl)) diff --git a/v2rayN/v2rayN/Views/SubSettingWindow.xaml.cs b/v2rayN/v2rayN/Views/SubSettingWindow.xaml.cs index 8e01da40e38..34579af3dcb 100644 --- a/v2rayN/v2rayN/Views/SubSettingWindow.xaml.cs +++ b/v2rayN/v2rayN/Views/SubSettingWindow.xaml.cs @@ -1,4 +1,5 @@ using ReactiveUI; +using System.ComponentModel; using System.Reactive.Disposables; using System.Windows.Input; using v2rayN.ViewModels; @@ -12,6 +13,7 @@ public SubSettingWindow() InitializeComponent(); ViewModel = new SubSettingViewModel(this); + this.Closing += SubSettingWindow_Closing; lstSubscription.MouseDoubleClick += LstSubscription_MouseDoubleClick; this.WhenActivated(disposables => @@ -27,10 +29,18 @@ public SubSettingWindow() }); } + private void SubSettingWindow_Closing(object? sender, CancelEventArgs e) + { + if (ViewModel?.IsModified == true) + { + this.DialogResult = true; + } + } + private void LstSubscription_MouseDoubleClick(object sender, MouseButtonEventArgs e) { ViewModel?.EditSub(false); - } + } private void menuClose_Click(object sender, System.Windows.RoutedEventArgs e) {