From 4bcd23389d889d4bb9cc2b1d7ccf27dea5f0b0aa Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E7=AD=B1=E5=82=91?= Date: Sun, 8 Oct 2023 00:09:25 +0800 Subject: [PATCH] Move stop proxy code --- Source/GrasscutterTools/Pages/PageOpenCommand.cs | 13 ------------- Source/GrasscutterTools/Pages/PageProxy.cs | 16 ++++++++++++++++ 2 files changed, 16 insertions(+), 13 deletions(-) diff --git a/Source/GrasscutterTools/Pages/PageOpenCommand.cs b/Source/GrasscutterTools/Pages/PageOpenCommand.cs index 8ecc1c8..94ac272 100644 --- a/Source/GrasscutterTools/Pages/PageOpenCommand.cs +++ b/Source/GrasscutterTools/Pages/PageOpenCommand.cs @@ -168,19 +168,6 @@ namespace GrasscutterTools.Pages Settings.Default.RemoteUid = NUDRemotePlayerId.Value; Settings.Default.Host = TxtHost.Text; Settings.Default.TokenCache = Common.OC?.Token; - - try - { - Logger.I(TAG, "Stop Proxy"); - ProxyHelper.StopProxy(); - } - catch (Exception ex) - { -#if DEBUG - MessageBox.Show(ex.ToString(), Resources.Error, MessageBoxButtons.OK, MessageBoxIcon.Error); -#endif - Logger.E(TAG, "Stop Proxy Failed.", ex); - } } /// diff --git a/Source/GrasscutterTools/Pages/PageProxy.cs b/Source/GrasscutterTools/Pages/PageProxy.cs index 6c35f44..37258c0 100644 --- a/Source/GrasscutterTools/Pages/PageProxy.cs +++ b/Source/GrasscutterTools/Pages/PageProxy.cs @@ -46,6 +46,22 @@ namespace GrasscutterTools.Pages } } + public override void OnClosed() + { + try + { + Logger.I(TAG, "Stop Proxy"); + ProxyHelper.StopProxy(); + } + catch (Exception ex) + { +#if DEBUG + MessageBox.Show(ex.ToString(), Resources.Error, MessageBoxButtons.OK, MessageBoxIcon.Error); +#endif + Logger.E(TAG, "Stop Proxy Failed.", ex); + } + } + /// /// 点击启动GC服务器时触发 ///