diff --git a/v2rayN/ServiceLib/Base/MyReactiveObject.cs b/v2rayN/ServiceLib/Base/MyReactiveObject.cs index 7a0a304f..0049429d 100644 --- a/v2rayN/ServiceLib/Base/MyReactiveObject.cs +++ b/v2rayN/ServiceLib/Base/MyReactiveObject.cs @@ -6,6 +6,5 @@ namespace ServiceLib.Base { protected static Config? _config; protected Func>? _updateView; - protected NoticeHandler? _noticeHandler; } } \ No newline at end of file diff --git a/v2rayN/ServiceLib/Enums/ECoreType.cs b/v2rayN/ServiceLib/Enums/ECoreType.cs index 35693b02..c8a08c91 100644 --- a/v2rayN/ServiceLib/Enums/ECoreType.cs +++ b/v2rayN/ServiceLib/Enums/ECoreType.cs @@ -4,11 +4,14 @@ { v2fly = 1, Xray = 2, + //SagerNet = 3, v2fly_v5 = 4, + //clash = 11, //clash_meta = 12, mihomo = 13, + hysteria = 21, naiveproxy = 22, tuic = 23, diff --git a/v2rayN/ServiceLib/Handler/AppHandler.cs b/v2rayN/ServiceLib/Handler/AppHandler.cs index 9fa7c59b..bf3cb420 100644 --- a/v2rayN/ServiceLib/Handler/AppHandler.cs +++ b/v2rayN/ServiceLib/Handler/AppHandler.cs @@ -1,6 +1,4 @@ -using Splat; - -namespace ServiceLib.Handler +namespace ServiceLib.Handler { public sealed class AppHandler { @@ -33,7 +31,7 @@ namespace ServiceLib.Handler #region Init public AppHandler() - { + { } public bool InitApp() @@ -42,7 +40,6 @@ namespace ServiceLib.Handler { return false; } - Locator.CurrentMutable.RegisterLazySingleton(() => new NoticeHandler(), typeof(NoticeHandler)); Thread.CurrentThread.CurrentUICulture = new(_config.uiItem.currentLanguage); //Under Win10 diff --git a/v2rayN/ServiceLib/Handler/CoreConfigHandler.cs b/v2rayN/ServiceLib/Handler/CoreConfigHandler.cs index c560a0c8..43fdc6c2 100644 --- a/v2rayN/ServiceLib/Handler/CoreConfigHandler.cs +++ b/v2rayN/ServiceLib/Handler/CoreConfigHandler.cs @@ -1,6 +1,4 @@ -using ServiceLib.Services.CoreConfig; - -namespace ServiceLib.Handler +namespace ServiceLib.Handler { /// /// Core configuration file processing class diff --git a/v2rayN/ServiceLib/Handler/NoticeHandler.cs b/v2rayN/ServiceLib/Handler/NoticeHandler.cs index 8efb12d7..2a8aff68 100644 --- a/v2rayN/ServiceLib/Handler/NoticeHandler.cs +++ b/v2rayN/ServiceLib/Handler/NoticeHandler.cs @@ -4,6 +4,9 @@ namespace ServiceLib.Handler { public class NoticeHandler { + private static readonly Lazy _instance = new(() => new()); + public static NoticeHandler Instance => _instance.Value; + public void Enqueue(string? content) { if (content.IsNullOrEmpty()) diff --git a/v2rayN/ServiceLib/Handler/StatisticsHandler.cs b/v2rayN/ServiceLib/Handler/StatisticsHandler.cs index 475e5b3d..29f2ae70 100644 --- a/v2rayN/ServiceLib/Handler/StatisticsHandler.cs +++ b/v2rayN/ServiceLib/Handler/StatisticsHandler.cs @@ -1,6 +1,4 @@ -using ServiceLib.Services.Statistics; - -namespace ServiceLib.Handler +namespace ServiceLib.Handler { public class StatisticsHandler { diff --git a/v2rayN/ServiceLib/Handler/TaskHandler.cs b/v2rayN/ServiceLib/Handler/TaskHandler.cs index abcf2cac..7ab58092 100644 --- a/v2rayN/ServiceLib/Handler/TaskHandler.cs +++ b/v2rayN/ServiceLib/Handler/TaskHandler.cs @@ -1,6 +1,4 @@ -using ServiceLib.Services; - -namespace ServiceLib.Handler +namespace ServiceLib.Handler { public class TaskHandler { diff --git a/v2rayN/ServiceLib/Handler/WebDavHandler.cs b/v2rayN/ServiceLib/Handler/WebDavHandler.cs index ea9b714a..81386cc2 100644 --- a/v2rayN/ServiceLib/Handler/WebDavHandler.cs +++ b/v2rayN/ServiceLib/Handler/WebDavHandler.cs @@ -110,7 +110,7 @@ namespace ServiceLib.Handler } else { - SaveLog(result.Description); + SaveLog(result.Description); } } catch (Exception ex) diff --git a/v2rayN/ServiceLib/ViewModels/AddServer2ViewModel.cs b/v2rayN/ServiceLib/ViewModels/AddServer2ViewModel.cs index 8c1545b8..8124f268 100644 --- a/v2rayN/ServiceLib/ViewModels/AddServer2ViewModel.cs +++ b/v2rayN/ServiceLib/ViewModels/AddServer2ViewModel.cs @@ -1,6 +1,5 @@ using ReactiveUI; using ReactiveUI.Fody.Helpers; -using Splat; using System.Reactive; namespace ServiceLib.ViewModels @@ -20,7 +19,6 @@ namespace ServiceLib.ViewModels public AddServer2ViewModel(ProfileItem profileItem, Func>? updateView) { - _noticeHandler = Locator.Current.GetService(); _config = AppHandler.Instance.Config; _updateView = updateView; @@ -55,25 +53,25 @@ namespace ServiceLib.ViewModels string remarks = SelectedSource.remarks; if (Utils.IsNullOrEmpty(remarks)) { - _noticeHandler?.Enqueue(ResUI.PleaseFillRemarks); + NoticeHandler.Instance.Enqueue(ResUI.PleaseFillRemarks); return; } if (Utils.IsNullOrEmpty(SelectedSource.address)) { - _noticeHandler?.Enqueue(ResUI.FillServerAddressCustom); + NoticeHandler.Instance.Enqueue(ResUI.FillServerAddressCustom); return; } SelectedSource.coreType = CoreType.IsNullOrEmpty() ? null : (ECoreType)Enum.Parse(typeof(ECoreType), CoreType); if (ConfigHandler.EditCustomServer(_config, SelectedSource) == 0) { - _noticeHandler?.Enqueue(ResUI.OperationSuccess); + NoticeHandler.Instance.Enqueue(ResUI.OperationSuccess); await _updateView?.Invoke(EViewAction.CloseWindow, null); } else { - _noticeHandler?.Enqueue(ResUI.OperationFailed); + NoticeHandler.Instance.Enqueue(ResUI.OperationFailed); } } @@ -89,7 +87,7 @@ namespace ServiceLib.ViewModels item.address = fileName; if (ConfigHandler.AddCustomServer(_config, item, false) == 0) { - _noticeHandler?.Enqueue(ResUI.SuccessfullyImportedCustomServer); + NoticeHandler.Instance.Enqueue(ResUI.SuccessfullyImportedCustomServer); if (Utils.IsNotEmpty(item.indexId)) { SelectedSource = JsonUtils.DeepCopy(item); @@ -98,7 +96,7 @@ namespace ServiceLib.ViewModels } else { - _noticeHandler?.Enqueue(ResUI.FailedImportedCustomServer); + NoticeHandler.Instance.Enqueue(ResUI.FailedImportedCustomServer); } } @@ -107,7 +105,7 @@ namespace ServiceLib.ViewModels var address = SelectedSource.address; if (Utils.IsNullOrEmpty(address)) { - _noticeHandler?.Enqueue(ResUI.FillServerAddressCustom); + NoticeHandler.Instance.Enqueue(ResUI.FillServerAddressCustom); return; } @@ -118,7 +116,7 @@ namespace ServiceLib.ViewModels } else { - _noticeHandler?.Enqueue(ResUI.FailedReadConfiguration); + NoticeHandler.Instance.Enqueue(ResUI.FailedReadConfiguration); } } } diff --git a/v2rayN/ServiceLib/ViewModels/AddServerViewModel.cs b/v2rayN/ServiceLib/ViewModels/AddServerViewModel.cs index 574eed8c..af26da9f 100644 --- a/v2rayN/ServiceLib/ViewModels/AddServerViewModel.cs +++ b/v2rayN/ServiceLib/ViewModels/AddServerViewModel.cs @@ -1,6 +1,5 @@ using ReactiveUI; using ReactiveUI.Fody.Helpers; -using Splat; using System.Reactive; namespace ServiceLib.ViewModels @@ -18,7 +17,7 @@ namespace ServiceLib.ViewModels public AddServerViewModel(ProfileItem profileItem, Func>? updateView) { _config = AppHandler.Instance.Config; - _noticeHandler = Locator.Current.GetService(); + _updateView = updateView; if (profileItem.indexId.IsNullOrEmpty()) @@ -45,32 +44,32 @@ namespace ServiceLib.ViewModels { if (Utils.IsNullOrEmpty(SelectedSource.remarks)) { - _noticeHandler?.Enqueue(ResUI.PleaseFillRemarks); + NoticeHandler.Instance.Enqueue(ResUI.PleaseFillRemarks); return; } if (Utils.IsNullOrEmpty(SelectedSource.address)) { - _noticeHandler?.Enqueue(ResUI.FillServerAddress); + NoticeHandler.Instance.Enqueue(ResUI.FillServerAddress); return; } var port = SelectedSource.port.ToString(); if (Utils.IsNullOrEmpty(port) || !Utils.IsNumeric(port) || SelectedSource.port <= 0 || SelectedSource.port >= Global.MaxPort) { - _noticeHandler?.Enqueue(ResUI.FillCorrectServerPort); + NoticeHandler.Instance.Enqueue(ResUI.FillCorrectServerPort); return; } if (SelectedSource.configType == EConfigType.Shadowsocks) { if (Utils.IsNullOrEmpty(SelectedSource.id)) { - _noticeHandler?.Enqueue(ResUI.FillPassword); + NoticeHandler.Instance.Enqueue(ResUI.FillPassword); return; } if (Utils.IsNullOrEmpty(SelectedSource.security)) { - _noticeHandler?.Enqueue(ResUI.PleaseSelectEncryption); + NoticeHandler.Instance.Enqueue(ResUI.PleaseSelectEncryption); return; } } @@ -79,7 +78,7 @@ namespace ServiceLib.ViewModels { if (Utils.IsNullOrEmpty(SelectedSource.id)) { - _noticeHandler?.Enqueue(ResUI.FillUUID); + NoticeHandler.Instance.Enqueue(ResUI.FillUUID); return; } } @@ -87,12 +86,12 @@ namespace ServiceLib.ViewModels if (ConfigHandler.AddServer(_config, SelectedSource) == 0) { - _noticeHandler?.Enqueue(ResUI.OperationSuccess); + NoticeHandler.Instance.Enqueue(ResUI.OperationSuccess); await _updateView?.Invoke(EViewAction.CloseWindow, null); } else { - _noticeHandler?.Enqueue(ResUI.OperationFailed); + NoticeHandler.Instance.Enqueue(ResUI.OperationFailed); } } } diff --git a/v2rayN/ServiceLib/ViewModels/BackupAndRestoreViewModel.cs b/v2rayN/ServiceLib/ViewModels/BackupAndRestoreViewModel.cs index 0ddceeb4..defeb603 100644 --- a/v2rayN/ServiceLib/ViewModels/BackupAndRestoreViewModel.cs +++ b/v2rayN/ServiceLib/ViewModels/BackupAndRestoreViewModel.cs @@ -24,7 +24,6 @@ namespace ServiceLib.ViewModels { _config = AppHandler.Instance.Config; _updateView = updateView; - _noticeHandler = Locator.Current.GetService(); WebDavCheckCmd = ReactiveCommand.CreateFromTask(async () => { diff --git a/v2rayN/ServiceLib/ViewModels/CheckUpdateViewModel.cs b/v2rayN/ServiceLib/ViewModels/CheckUpdateViewModel.cs index 7ed31f49..fdac0852 100644 --- a/v2rayN/ServiceLib/ViewModels/CheckUpdateViewModel.cs +++ b/v2rayN/ServiceLib/ViewModels/CheckUpdateViewModel.cs @@ -24,7 +24,6 @@ namespace ServiceLib.ViewModels { _config = AppHandler.Instance.Config; _updateView = updateView; - _noticeHandler = Locator.Current.GetService(); RefreshSubItems(); diff --git a/v2rayN/ServiceLib/ViewModels/ClashProxiesViewModel.cs b/v2rayN/ServiceLib/ViewModels/ClashProxiesViewModel.cs index 822ec95e..1f2f931a 100644 --- a/v2rayN/ServiceLib/ViewModels/ClashProxiesViewModel.cs +++ b/v2rayN/ServiceLib/ViewModels/ClashProxiesViewModel.cs @@ -2,7 +2,6 @@ using DynamicData; using DynamicData.Binding; using ReactiveUI; using ReactiveUI.Fody.Helpers; -using Splat; using System.Reactive; using System.Reactive.Linq; using static ServiceLib.Models.ClashProviders; @@ -44,7 +43,6 @@ namespace ServiceLib.ViewModels public ClashProxiesViewModel(Func>? updateView) { - _noticeHandler = Locator.Current.GetService(); _config = AppHandler.Instance.Config; _updateView = updateView; @@ -135,7 +133,7 @@ namespace ServiceLib.ViewModels private void UpdateHandler(bool notify, string msg) { - _noticeHandler?.SendMessageEx(msg); + NoticeHandler.Instance.SendMessageEx(msg); } public void ProxiesReload() @@ -363,7 +361,7 @@ namespace ServiceLib.ViewModels var selectedProxy = TryGetProxy(name); if (selectedProxy == null || selectedProxy.type != "Selector") { - _noticeHandler?.Enqueue(ResUI.OperationFailed); + NoticeHandler.Instance.Enqueue(ResUI.OperationFailed); return; } @@ -379,7 +377,7 @@ namespace ServiceLib.ViewModels SelectedGroup = group2; } - _noticeHandler?.Enqueue(ResUI.OperationSuccess); + NoticeHandler.Instance.Enqueue(ResUI.OperationSuccess); } private void ProxiesDelayTest(bool blAll) diff --git a/v2rayN/ServiceLib/ViewModels/DNSSettingViewModel.cs b/v2rayN/ServiceLib/ViewModels/DNSSettingViewModel.cs index e283a915..cccbc00d 100644 --- a/v2rayN/ServiceLib/ViewModels/DNSSettingViewModel.cs +++ b/v2rayN/ServiceLib/ViewModels/DNSSettingViewModel.cs @@ -1,6 +1,5 @@ using ReactiveUI; using ReactiveUI.Fody.Helpers; -using Splat; using System.Reactive; namespace ServiceLib.ViewModels @@ -24,7 +23,7 @@ namespace ServiceLib.ViewModels public DNSSettingViewModel(Func>? updateView) { _config = AppHandler.Instance.Config; - _noticeHandler = Locator.Current.GetService(); + _updateView = updateView; var item = AppHandler.Instance.GetDNSItem(ECoreType.Xray); @@ -68,7 +67,7 @@ namespace ServiceLib.ViewModels { if (normalDNS.Contains("{") || normalDNS.Contains("}")) { - _noticeHandler?.Enqueue(ResUI.FillCorrectDNSText); + NoticeHandler.Instance.Enqueue(ResUI.FillCorrectDNSText); return; } } @@ -78,7 +77,7 @@ namespace ServiceLib.ViewModels var obj2 = JsonUtils.Deserialize(normalDNS2); if (obj2 == null) { - _noticeHandler?.Enqueue(ResUI.FillCorrectDNSText); + NoticeHandler.Instance.Enqueue(ResUI.FillCorrectDNSText); return; } } @@ -87,7 +86,7 @@ namespace ServiceLib.ViewModels var obj2 = JsonUtils.Deserialize(tunDNS2); if (obj2 == null) { - _noticeHandler?.Enqueue(ResUI.FillCorrectDNSText); + NoticeHandler.Instance.Enqueue(ResUI.FillCorrectDNSText); return; } } @@ -106,7 +105,7 @@ namespace ServiceLib.ViewModels item2.tunDNS = JsonUtils.Serialize(JsonUtils.ParseJson(tunDNS2)); ; ConfigHandler.SaveDNSItems(_config, item2); - _noticeHandler?.Enqueue(ResUI.OperationSuccess); + NoticeHandler.Instance.Enqueue(ResUI.OperationSuccess); await _updateView?.Invoke(EViewAction.CloseWindow, null); } } diff --git a/v2rayN/ServiceLib/ViewModels/MainWindowViewModel.cs b/v2rayN/ServiceLib/ViewModels/MainWindowViewModel.cs index 9c4cbd0c..9df6744a 100644 --- a/v2rayN/ServiceLib/ViewModels/MainWindowViewModel.cs +++ b/v2rayN/ServiceLib/ViewModels/MainWindowViewModel.cs @@ -147,7 +147,7 @@ namespace ServiceLib.ViewModels public MainWindowViewModel(bool isAdministrator, Func>? updateView) { _config = AppHandler.Instance.Config; - _noticeHandler = Locator.Current.GetService(); + _updateView = updateView; _isAdministrator = isAdministrator; @@ -281,7 +281,7 @@ namespace ServiceLib.ViewModels { if (await _updateView?.Invoke(EViewAction.GlobalHotkeySettingWindow, null) == true) { - _noticeHandler?.Enqueue(ResUI.OperationSuccess); + NoticeHandler.Instance.Enqueue(ResUI.OperationSuccess); } }); RebootAsAdminCmd = ReactiveCommand.Create(() => @@ -364,16 +364,16 @@ namespace ServiceLib.ViewModels private void UpdateHandler(bool notify, string msg) { - _noticeHandler?.SendMessage(msg); + NoticeHandler.Instance.SendMessage(msg); if (notify) { - _noticeHandler?.Enqueue(msg); + NoticeHandler.Instance.Enqueue(msg); } } private void UpdateTaskHandler(bool success, string msg) { - _noticeHandler?.SendMessageEx(msg); + NoticeHandler.Instance.SendMessageEx(msg); if (success) { var indexIdOld = _config.indexId; @@ -559,7 +559,7 @@ namespace ServiceLib.ViewModels { RefreshSubscriptions(); RefreshServers(); - _noticeHandler?.Enqueue(string.Format(ResUI.SuccessfullyImportedServerViaClipboard, ret)); + NoticeHandler.Instance.Enqueue(string.Format(ResUI.SuccessfullyImportedServerViaClipboard, ret)); } } @@ -567,7 +567,7 @@ namespace ServiceLib.ViewModels { if (Utils.IsNullOrEmpty(result)) { - _noticeHandler?.Enqueue(ResUI.NoValidQRcodeFound); + NoticeHandler.Instance.Enqueue(ResUI.NoValidQRcodeFound); } else { @@ -576,7 +576,7 @@ namespace ServiceLib.ViewModels { RefreshSubscriptions(); RefreshServers(); - _noticeHandler?.Enqueue(ResUI.SuccessfullyImportedServerViaScan); + NoticeHandler.Instance.Enqueue(ResUI.SuccessfullyImportedServerViaScan); } } } @@ -594,7 +594,7 @@ namespace ServiceLib.ViewModels var item = AppHandler.Instance.GetProfileItem(indexId); if (item is null) { - _noticeHandler?.Enqueue(ResUI.PleaseSelectServer); + NoticeHandler.Instance.Enqueue(ResUI.PleaseSelectServer); return; } @@ -631,7 +631,7 @@ namespace ServiceLib.ViewModels } await (new UpdateService()).RunAvailabilityCheck(async (bool success, string msg) => { - _noticeHandler?.SendMessageEx(msg); + NoticeHandler.Instance.SendMessageEx(msg); await _updateView?.Invoke(EViewAction.DispatcherServerAvailability, msg); }); } @@ -784,7 +784,7 @@ namespace ServiceLib.ViewModels { //await _updateView?.Invoke(EViewAction.UpdateSysProxy, _config.tunModeItem.enableTun ? true : false); await _updateView?.Invoke(EViewAction.UpdateSysProxy, false); - _noticeHandler?.SendMessageEx($"{ResUI.TipChangeSystemProxy} - {_config.systemProxyItem.sysProxyType.ToString()}"); + NoticeHandler.Instance.SendMessageEx($"{ResUI.TipChangeSystemProxy} - {_config.systemProxyItem.sysProxyType.ToString()}"); BlSystemProxyClear = (type == ESysProxyType.ForcedClear); BlSystemProxySet = (type == ESysProxyType.ForcedChange); @@ -844,7 +844,7 @@ namespace ServiceLib.ViewModels if (ConfigHandler.SetDefaultRouting(_config, item) == 0) { - _noticeHandler?.SendMessageEx(ResUI.TipChangeRouting); + NoticeHandler.Instance.SendMessageEx(ResUI.TipChangeRouting); Reload(); await _updateView?.Invoke(EViewAction.DispatcherRefreshIcon, null); } diff --git a/v2rayN/ServiceLib/ViewModels/MsgViewModel.cs b/v2rayN/ServiceLib/ViewModels/MsgViewModel.cs index bbf72308..8a329939 100644 --- a/v2rayN/ServiceLib/ViewModels/MsgViewModel.cs +++ b/v2rayN/ServiceLib/ViewModels/MsgViewModel.cs @@ -1,6 +1,5 @@ using ReactiveUI; using ReactiveUI.Fody.Helpers; -using Splat; using System.Collections.Concurrent; using System.Text.RegularExpressions; @@ -24,7 +23,6 @@ namespace ServiceLib.ViewModels { _config = AppHandler.Instance.Config; _updateView = updateView; - _noticeHandler = Locator.Current.GetService(); MessageBus.Current.Listen(Global.CommandSendMsgView).Subscribe(async x => await AppendQueueMsg(x)); diff --git a/v2rayN/ServiceLib/ViewModels/OptionSettingViewModel.cs b/v2rayN/ServiceLib/ViewModels/OptionSettingViewModel.cs index fde0ff90..b7dd6a6d 100644 --- a/v2rayN/ServiceLib/ViewModels/OptionSettingViewModel.cs +++ b/v2rayN/ServiceLib/ViewModels/OptionSettingViewModel.cs @@ -1,6 +1,5 @@ using ReactiveUI; using ReactiveUI.Fody.Helpers; -using Splat; using System.Reactive; namespace ServiceLib.ViewModels @@ -103,7 +102,7 @@ namespace ServiceLib.ViewModels public OptionSettingViewModel(Func>? updateView) { _config = AppHandler.Instance.Config; - _noticeHandler = Locator.Current.GetService(); + _updateView = updateView; #region Core @@ -251,7 +250,7 @@ namespace ServiceLib.ViewModels if (Utils.IsNullOrEmpty(localPort.ToString()) || !Utils.IsNumeric(localPort.ToString()) || localPort <= 0 || localPort >= Global.MaxPort) { - _noticeHandler?.Enqueue(ResUI.FillLocalListeningPort); + NoticeHandler.Instance.Enqueue(ResUI.FillLocalListeningPort); return; } var needReboot = (EnableStatistics != _config.guiItem.enableStatistics @@ -267,7 +266,7 @@ namespace ServiceLib.ViewModels // || Utile.IsNullOrEmpty(KcpreadBufferSize.ToString()) || !Utile.IsNumeric(KcpreadBufferSize.ToString()) // || Utile.IsNullOrEmpty(KcpwriteBufferSize.ToString()) || !Utile.IsNumeric(KcpwriteBufferSize.ToString())) //{ - // _noticeHandler?.Enqueue(ResUI.FillKcpParameters); + // NoticeHandler.Instance.Enqueue(ResUI.FillKcpParameters); // return; //} @@ -337,17 +336,17 @@ namespace ServiceLib.ViewModels { if (needReboot) { - _noticeHandler?.Enqueue(ResUI.NeedRebootTips); + NoticeHandler.Instance.Enqueue(ResUI.NeedRebootTips); } else { - _noticeHandler?.Enqueue(ResUI.OperationSuccess); + NoticeHandler.Instance.Enqueue(ResUI.OperationSuccess); } await _updateView?.Invoke(EViewAction.CloseWindow, null); } else { - _noticeHandler?.Enqueue(ResUI.OperationFailed); + NoticeHandler.Instance.Enqueue(ResUI.OperationFailed); } } diff --git a/v2rayN/ServiceLib/ViewModels/ProfilesViewModel.cs b/v2rayN/ServiceLib/ViewModels/ProfilesViewModel.cs index 722897d7..173d77d4 100644 --- a/v2rayN/ServiceLib/ViewModels/ProfilesViewModel.cs +++ b/v2rayN/ServiceLib/ViewModels/ProfilesViewModel.cs @@ -2,7 +2,6 @@ using DynamicData; using DynamicData.Binding; using ReactiveUI; using ReactiveUI.Fody.Helpers; -using ServiceLib.Services; using Splat; using System.Reactive; using System.Reactive.Linq; @@ -99,7 +98,7 @@ namespace ServiceLib.ViewModels public ProfilesViewModel(Func>? updateView) { _config = AppHandler.Instance.Config; - _noticeHandler = Locator.Current.GetService(); + _updateView = updateView; MessageBus.Current.Listen(Global.CommandRefreshProfiles).Subscribe(async x => await _updateView?.Invoke(EViewAction.DispatcherRefreshServersBiz, null)); @@ -259,8 +258,8 @@ namespace ServiceLib.ViewModels { if (Utils.IsNullOrEmpty(result.IndexId)) { - _noticeHandler?.SendMessageEx(result.Delay); - _noticeHandler?.Enqueue(result.Delay); + NoticeHandler.Instance.SendMessageEx(result.Delay); + NoticeHandler.Instance.Enqueue(result.Delay); return; } var item = _profileItems.Where(it => it.indexId == result.IndexId).FirstOrDefault(); @@ -430,7 +429,7 @@ namespace ServiceLib.ViewModels var item = AppHandler.Instance.GetProfileItem(SelectedProfile.indexId); if (item is null) { - _noticeHandler?.Enqueue(ResUI.PleaseSelectServer); + NoticeHandler.Instance.Enqueue(ResUI.PleaseSelectServer); return; } eConfigType = item.configType; @@ -467,7 +466,7 @@ namespace ServiceLib.ViewModels var exists = lstSelecteds.Exists(t => t.indexId == _config.indexId); ConfigHandler.RemoveServer(_config, lstSelecteds); - _noticeHandler?.Enqueue(ResUI.OperationSuccess); + NoticeHandler.Instance.Enqueue(ResUI.OperationSuccess); RefreshServers(); if (exists) @@ -481,7 +480,7 @@ namespace ServiceLib.ViewModels var tuple = ConfigHandler.DedupServerList(_config, _config.subIndexId); RefreshServers(); Reload(); - _noticeHandler?.Enqueue(string.Format(ResUI.RemoveDuplicateServerResult, tuple.Item1, tuple.Item2)); + NoticeHandler.Instance.Enqueue(string.Format(ResUI.RemoveDuplicateServerResult, tuple.Item1, tuple.Item2)); } private void CopyServer() @@ -493,7 +492,7 @@ namespace ServiceLib.ViewModels if (ConfigHandler.CopyServer(_config, lstSelecteds) == 0) { RefreshServers(); - _noticeHandler?.Enqueue(ResUI.OperationSuccess); + NoticeHandler.Instance.Enqueue(ResUI.OperationSuccess); } } @@ -519,7 +518,7 @@ namespace ServiceLib.ViewModels var item = AppHandler.Instance.GetProfileItem(indexId); if (item is null) { - _noticeHandler?.Enqueue(ResUI.PleaseSelectServer); + NoticeHandler.Instance.Enqueue(ResUI.PleaseSelectServer); return; } @@ -552,7 +551,7 @@ namespace ServiceLib.ViewModels var item = AppHandler.Instance.GetProfileItem(SelectedProfile.indexId); if (item is null) { - _noticeHandler?.Enqueue(ResUI.PleaseSelectServer); + NoticeHandler.Instance.Enqueue(ResUI.PleaseSelectServer); return; } var url = FmtHandler.GetShareUri(item); @@ -573,7 +572,7 @@ namespace ServiceLib.ViewModels if (ConfigHandler.AddCustomServer4Multiple(_config, lstSelecteds, coreType, out string indexId) != 0) { - _noticeHandler?.Enqueue(ResUI.OperationFailed); + NoticeHandler.Instance.Enqueue(ResUI.OperationFailed); return; } if (indexId == _config.indexId) @@ -618,7 +617,7 @@ namespace ServiceLib.ViewModels } ConfigHandler.MoveToGroup(_config, lstSelecteds, SelectedMoveToGroup.id); - _noticeHandler?.Enqueue(ResUI.OperationSuccess); + NoticeHandler.Instance.Enqueue(ResUI.OperationSuccess); RefreshServers(); SelectedMoveToGroup = new(); @@ -630,7 +629,7 @@ namespace ServiceLib.ViewModels var item = _lstProfile.FirstOrDefault(t => t.indexId == SelectedProfile.indexId); if (item is null) { - _noticeHandler?.Enqueue(ResUI.PleaseSelectServer); + NoticeHandler.Instance.Enqueue(ResUI.PleaseSelectServer); return; } @@ -685,19 +684,19 @@ namespace ServiceLib.ViewModels var item = AppHandler.Instance.GetProfileItem(SelectedProfile.indexId); if (item is null) { - _noticeHandler?.Enqueue(ResUI.PleaseSelectServer); + NoticeHandler.Instance.Enqueue(ResUI.PleaseSelectServer); return; } if (blClipboard) { if (CoreConfigHandler.GenerateClientConfig(item, null, out string msg, out string content) != 0) { - Locator.Current.GetService()?.Enqueue(msg); + NoticeHandler.Instance.Enqueue(msg); } else { await _updateView?.Invoke(EViewAction.SetClipboardData, content); - _noticeHandler?.SendMessage(ResUI.OperationSuccess); + NoticeHandler.Instance.SendMessage(ResUI.OperationSuccess); } } else @@ -714,12 +713,12 @@ namespace ServiceLib.ViewModels } if (CoreConfigHandler.GenerateClientConfig(item, fileName, out string msg, out string content) != 0) { - Locator.Current.GetService()?.Enqueue(msg); + NoticeHandler.Instance.Enqueue(msg); } else { msg = string.Format(ResUI.SaveClientConfigurationIn, fileName); - Locator.Current.GetService()?.SendMessageAndEnqueue(msg); + NoticeHandler.Instance.SendMessageAndEnqueue(msg); } } @@ -751,7 +750,7 @@ namespace ServiceLib.ViewModels { await _updateView?.Invoke(EViewAction.SetClipboardData, sb.ToString()); } - _noticeHandler?.SendMessage(ResUI.BatchExportURLSuccessfully); + NoticeHandler.Instance.SendMessage(ResUI.BatchExportURLSuccessfully); } } diff --git a/v2rayN/ServiceLib/ViewModels/RoutingRuleDetailsViewModel.cs b/v2rayN/ServiceLib/ViewModels/RoutingRuleDetailsViewModel.cs index c6b7e0b6..5dc2971e 100644 --- a/v2rayN/ServiceLib/ViewModels/RoutingRuleDetailsViewModel.cs +++ b/v2rayN/ServiceLib/ViewModels/RoutingRuleDetailsViewModel.cs @@ -1,6 +1,5 @@ using ReactiveUI; using ReactiveUI.Fody.Helpers; -using Splat; using System.Reactive; namespace ServiceLib.ViewModels @@ -30,7 +29,7 @@ namespace ServiceLib.ViewModels public RoutingRuleDetailsViewModel(RulesItem rulesItem, Func>? updateView) { _config = AppHandler.Instance.Config; - _noticeHandler = Locator.Current.GetService(); + _updateView = updateView; if (rulesItem.id.IsNullOrEmpty()) @@ -84,10 +83,10 @@ namespace ServiceLib.ViewModels if (!hasRule) { - _noticeHandler?.Enqueue(string.Format(ResUI.RoutingRuleDetailRequiredTips, "Port/Protocol/Domain/IP/Process")); + NoticeHandler.Instance.Enqueue(string.Format(ResUI.RoutingRuleDetailRequiredTips, "Port/Protocol/Domain/IP/Process")); return; } - //_noticeHandler?.Enqueue(ResUI.OperationSuccess); + //NoticeHandler.Instance.Enqueue(ResUI.OperationSuccess); await _updateView?.Invoke(EViewAction.CloseWindow, null); } } diff --git a/v2rayN/ServiceLib/ViewModels/RoutingRuleSettingViewModel.cs b/v2rayN/ServiceLib/ViewModels/RoutingRuleSettingViewModel.cs index bb5c8752..5fa24745 100644 --- a/v2rayN/ServiceLib/ViewModels/RoutingRuleSettingViewModel.cs +++ b/v2rayN/ServiceLib/ViewModels/RoutingRuleSettingViewModel.cs @@ -1,8 +1,6 @@ using DynamicData.Binding; using ReactiveUI; using ReactiveUI.Fody.Helpers; -using ServiceLib.Services; -using Splat; using System.Reactive; namespace ServiceLib.ViewModels @@ -38,7 +36,7 @@ namespace ServiceLib.ViewModels public RoutingRuleSettingViewModel(RoutingItem routingItem, Func>? updateView) { _config = AppHandler.Instance.Config; - _noticeHandler = Locator.Current.GetService(); + _updateView = updateView; SelectedSource = new(); @@ -160,7 +158,7 @@ namespace ServiceLib.ViewModels { if (SelectedSource is null || SelectedSource.outboundTag.IsNullOrEmpty()) { - _noticeHandler?.Enqueue(ResUI.PleaseSelectRules); + NoticeHandler.Instance.Enqueue(ResUI.PleaseSelectRules); return; } if (await _updateView?.Invoke(EViewAction.ShowYesNo, null) == false) @@ -183,7 +181,7 @@ namespace ServiceLib.ViewModels { if (SelectedSource is null || SelectedSource.outboundTag.IsNullOrEmpty()) { - _noticeHandler?.Enqueue(ResUI.PleaseSelectRules); + NoticeHandler.Instance.Enqueue(ResUI.PleaseSelectRules); return; } @@ -207,7 +205,7 @@ namespace ServiceLib.ViewModels { if (SelectedSource is null || SelectedSource.outboundTag.IsNullOrEmpty()) { - _noticeHandler?.Enqueue(ResUI.PleaseSelectRules); + NoticeHandler.Instance.Enqueue(ResUI.PleaseSelectRules); return; } @@ -228,7 +226,7 @@ namespace ServiceLib.ViewModels string remarks = SelectedRouting.remarks; if (Utils.IsNullOrEmpty(remarks)) { - _noticeHandler?.Enqueue(ResUI.PleaseFillRemarks); + NoticeHandler.Instance.Enqueue(ResUI.PleaseFillRemarks); return; } var item = SelectedRouting; @@ -241,12 +239,12 @@ namespace ServiceLib.ViewModels if (ConfigHandler.SaveRoutingItem(_config, item) == 0) { - _noticeHandler?.Enqueue(ResUI.OperationSuccess); + NoticeHandler.Instance.Enqueue(ResUI.OperationSuccess); await _updateView?.Invoke(EViewAction.CloseWindow, null); } else { - _noticeHandler?.Enqueue(ResUI.OperationFailed); + NoticeHandler.Instance.Enqueue(ResUI.OperationFailed); } } @@ -268,7 +266,7 @@ namespace ServiceLib.ViewModels if (ret == 0) { RefreshRulesItems(); - _noticeHandler?.Enqueue(ResUI.OperationSuccess); + NoticeHandler.Instance.Enqueue(ResUI.OperationSuccess); } } @@ -283,7 +281,7 @@ namespace ServiceLib.ViewModels if (ret == 0) { RefreshRulesItems(); - _noticeHandler?.Enqueue(ResUI.OperationSuccess); + NoticeHandler.Instance.Enqueue(ResUI.OperationSuccess); } } @@ -292,7 +290,7 @@ namespace ServiceLib.ViewModels var url = SelectedRouting.url; if (Utils.IsNullOrEmpty(url)) { - _noticeHandler?.Enqueue(ResUI.MsgNeedUrl); + NoticeHandler.Instance.Enqueue(ResUI.MsgNeedUrl); return; } @@ -302,7 +300,7 @@ namespace ServiceLib.ViewModels if (ret == 0) { RefreshRulesItems(); - _noticeHandler?.Enqueue(ResUI.OperationSuccess); + NoticeHandler.Instance.Enqueue(ResUI.OperationSuccess); } } diff --git a/v2rayN/ServiceLib/ViewModels/RoutingSettingViewModel.cs b/v2rayN/ServiceLib/ViewModels/RoutingSettingViewModel.cs index 0e7eb84a..fa1195df 100644 --- a/v2rayN/ServiceLib/ViewModels/RoutingSettingViewModel.cs +++ b/v2rayN/ServiceLib/ViewModels/RoutingSettingViewModel.cs @@ -1,7 +1,6 @@ using DynamicData.Binding; using ReactiveUI; using ReactiveUI.Fody.Helpers; -using Splat; using System.Reactive; namespace ServiceLib.ViewModels @@ -68,7 +67,7 @@ namespace ServiceLib.ViewModels public RoutingSettingViewModel(Func>? updateView) { _config = AppHandler.Instance.Config; - _noticeHandler = Locator.Current.GetService(); + _updateView = updateView; SelectedSource = new(); @@ -200,12 +199,12 @@ namespace ServiceLib.ViewModels if (ConfigHandler.SaveConfig(_config) == 0) { - _noticeHandler?.Enqueue(ResUI.OperationSuccess); + NoticeHandler.Instance.Enqueue(ResUI.OperationSuccess); await _updateView?.Invoke(EViewAction.CloseWindow, null); } else { - _noticeHandler?.Enqueue(ResUI.OperationFailed); + NoticeHandler.Instance.Enqueue(ResUI.OperationFailed); } } @@ -219,8 +218,8 @@ namespace ServiceLib.ViewModels DirectIP = "geoip:private,geoip:cn"; BlockDomain = "geosite:category-ads-all"; - //_noticeHandler?.Enqueue(ResUI.OperationSuccess); - _noticeHandler?.Enqueue(ResUI.OperationSuccess); + //NoticeHandler.Instance.Enqueue(ResUI.OperationSuccess); + NoticeHandler.Instance.Enqueue(ResUI.OperationSuccess); } public async Task RoutingAdvancedEditAsync(bool blNew) @@ -249,7 +248,7 @@ namespace ServiceLib.ViewModels { if (SelectedSource is null || SelectedSource.remarks.IsNullOrEmpty()) { - _noticeHandler?.Enqueue(ResUI.PleaseSelectRules); + NoticeHandler.Instance.Enqueue(ResUI.PleaseSelectRules); return; } if (await _updateView?.Invoke(EViewAction.ShowYesNo, null) == false) @@ -274,7 +273,7 @@ namespace ServiceLib.ViewModels var item = AppHandler.Instance.GetRoutingItem(SelectedSource?.id); if (item is null) { - _noticeHandler?.Enqueue(ResUI.PleaseSelectRules); + NoticeHandler.Instance.Enqueue(ResUI.PleaseSelectRules); return; } diff --git a/v2rayN/ServiceLib/ViewModels/SubEditViewModel.cs b/v2rayN/ServiceLib/ViewModels/SubEditViewModel.cs index a8dfa013..31d3a171 100644 --- a/v2rayN/ServiceLib/ViewModels/SubEditViewModel.cs +++ b/v2rayN/ServiceLib/ViewModels/SubEditViewModel.cs @@ -1,6 +1,5 @@ using ReactiveUI; using ReactiveUI.Fody.Helpers; -using Splat; using System.Reactive; namespace ServiceLib.ViewModels @@ -15,7 +14,7 @@ namespace ServiceLib.ViewModels public SubEditViewModel(SubItem subItem, Func>? updateView) { _config = AppHandler.Instance.Config; - _noticeHandler = Locator.Current.GetService(); + _updateView = updateView; if (subItem.id.IsNullOrEmpty()) @@ -38,18 +37,18 @@ namespace ServiceLib.ViewModels string remarks = SelectedSource.remarks; if (Utils.IsNullOrEmpty(remarks)) { - _noticeHandler?.Enqueue(ResUI.PleaseFillRemarks); + NoticeHandler.Instance.Enqueue(ResUI.PleaseFillRemarks); return; } if (ConfigHandler.AddSubItem(_config, SelectedSource) == 0) { - _noticeHandler?.Enqueue(ResUI.OperationSuccess); + NoticeHandler.Instance.Enqueue(ResUI.OperationSuccess); await _updateView?.Invoke(EViewAction.CloseWindow, null); } else { - _noticeHandler?.Enqueue(ResUI.OperationFailed); + NoticeHandler.Instance.Enqueue(ResUI.OperationFailed); } } } diff --git a/v2rayN/ServiceLib/ViewModels/SubSettingViewModel.cs b/v2rayN/ServiceLib/ViewModels/SubSettingViewModel.cs index d9822942..5fb624ee 100644 --- a/v2rayN/ServiceLib/ViewModels/SubSettingViewModel.cs +++ b/v2rayN/ServiceLib/ViewModels/SubSettingViewModel.cs @@ -2,7 +2,6 @@ using DynamicData.Binding; using ReactiveUI; using ReactiveUI.Fody.Helpers; -using Splat; using System.Reactive; namespace ServiceLib.ViewModels @@ -26,7 +25,7 @@ namespace ServiceLib.ViewModels public SubSettingViewModel(Func>? updateView) { _config = AppHandler.Instance.Config; - _noticeHandler = Locator.Current.GetService(); + _updateView = updateView; SelectedSource = new(); @@ -95,7 +94,7 @@ namespace ServiceLib.ViewModels ConfigHandler.DeleteSubItem(_config, it.id); } RefreshSubItems(); - _noticeHandler?.Enqueue(ResUI.OperationSuccess); + NoticeHandler.Instance.Enqueue(ResUI.OperationSuccess); IsModified = true; } } diff --git a/v2rayN/v2rayN.Desktop/ViewModels/AppViewModel.cs b/v2rayN/v2rayN.Desktop/ViewModels/AppViewModel.cs index 9842e066..c7726c25 100644 --- a/v2rayN/v2rayN.Desktop/ViewModels/AppViewModel.cs +++ b/v2rayN/v2rayN.Desktop/ViewModels/AppViewModel.cs @@ -17,7 +17,6 @@ namespace v2rayN.Desktop.ViewModels public AppViewModel() { _config = AppHandler.Instance.Config; - _noticeHandler = Locator.Current.GetService(); AddServerViaClipboardCmd = ReactiveCommand.Create(() => { diff --git a/v2rayN/v2rayN.Desktop/ViewModels/ThemeSettingViewModel.cs b/v2rayN/v2rayN.Desktop/ViewModels/ThemeSettingViewModel.cs index 2638f556..f29725df 100644 --- a/v2rayN/v2rayN.Desktop/ViewModels/ThemeSettingViewModel.cs +++ b/v2rayN/v2rayN.Desktop/ViewModels/ThemeSettingViewModel.cs @@ -3,7 +3,6 @@ using Avalonia.Controls; using Avalonia.Styling; using ReactiveUI; using ReactiveUI.Fody.Helpers; -using Splat; using System.Reactive.Linq; namespace v2rayN.Desktop.ViewModels @@ -22,7 +21,6 @@ namespace v2rayN.Desktop.ViewModels public ThemeSettingViewModel() { _config = AppHandler.Instance.Config; - _noticeHandler = Locator.Current.GetService(); BindingUI(); RestoreUI(); @@ -75,7 +73,7 @@ namespace v2rayN.Desktop.ViewModels _config.uiItem.currentLanguage = CurrentLanguage; Thread.CurrentThread.CurrentUICulture = new(CurrentLanguage); ConfigHandler.SaveConfig(_config); - _noticeHandler?.Enqueue(ResUI.NeedRebootTips); + NoticeHandler.Instance.Enqueue(ResUI.NeedRebootTips); } }); } diff --git a/v2rayN/v2rayN.Desktop/Views/BackupAndRestoreView.axaml.cs b/v2rayN/v2rayN.Desktop/Views/BackupAndRestoreView.axaml.cs index 47df76bb..4ed7c27e 100644 --- a/v2rayN/v2rayN.Desktop/Views/BackupAndRestoreView.axaml.cs +++ b/v2rayN/v2rayN.Desktop/Views/BackupAndRestoreView.axaml.cs @@ -2,7 +2,6 @@ using Avalonia.Interactivity; using Avalonia.ReactiveUI; using ReactiveUI; -using Splat; using System.Reactive.Disposables; using v2rayN.Desktop.Common; @@ -10,7 +9,6 @@ namespace v2rayN.Desktop.Views { public partial class BackupAndRestoreView : ReactiveUserControl { - private NoticeHandler? _noticeHandler; private Window _window; public BackupAndRestoreView(Window window) @@ -23,7 +21,6 @@ namespace v2rayN.Desktop.Views ViewModel = new BackupAndRestoreViewModel(UpdateViewHandler); - _noticeHandler = Locator.Current.GetService(); this.WhenActivated(disposables => { this.Bind(ViewModel, vm => vm.OperationMsg, v => v.txtMsg.Text).DisposeWith(disposables); diff --git a/v2rayN/v2rayN.Desktop/Views/DNSSettingWindow.axaml.cs b/v2rayN/v2rayN.Desktop/Views/DNSSettingWindow.axaml.cs index 5e05b10d..56fed37d 100644 --- a/v2rayN/v2rayN.Desktop/Views/DNSSettingWindow.axaml.cs +++ b/v2rayN/v2rayN.Desktop/Views/DNSSettingWindow.axaml.cs @@ -49,7 +49,7 @@ namespace v2rayN.Desktop.Views this.BindCommand(ViewModel, vm => vm.SaveCmd, v => v.btnSave).DisposeWith(disposables); this.BindCommand(ViewModel, vm => vm.ImportDefConfig4V2rayCmd, v => v.btnImportDefConfig4V2ray).DisposeWith(disposables); this.BindCommand(ViewModel, vm => vm.ImportDefConfig4SingboxCmd, v => v.btnImportDefConfig4Singbox).DisposeWith(disposables); - }); + }); } private async Task UpdateViewHandler(EViewAction action, object? obj) diff --git a/v2rayN/v2rayN.Desktop/Views/MainWindow.axaml.cs b/v2rayN/v2rayN.Desktop/Views/MainWindow.axaml.cs index f5406798..5afc6985 100644 --- a/v2rayN/v2rayN.Desktop/Views/MainWindow.axaml.cs +++ b/v2rayN/v2rayN.Desktop/Views/MainWindow.axaml.cs @@ -79,7 +79,6 @@ namespace v2rayN.Desktop.Views this.BindCommand(ViewModel, vm => vm.ClearServerStatisticsCmd, v => v.menuClearServerStatistics).DisposeWith(disposables); this.BindCommand(ViewModel, vm => vm.OpenTheFileLocationCmd, v => v.menuOpenTheFileLocation).DisposeWith(disposables); - this.BindCommand(ViewModel, vm => vm.ReloadCmd, v => v.menuReload).DisposeWith(disposables); this.OneWayBind(ViewModel, vm => vm.BlReloadEnabled, v => v.menuReload.IsEnabled).DisposeWith(disposables); diff --git a/v2rayN/v2rayN.Desktop/Views/ProfilesView.axaml.cs b/v2rayN/v2rayN.Desktop/Views/ProfilesView.axaml.cs index 018482e8..305b1f42 100644 --- a/v2rayN/v2rayN.Desktop/Views/ProfilesView.axaml.cs +++ b/v2rayN/v2rayN.Desktop/Views/ProfilesView.axaml.cs @@ -196,7 +196,7 @@ namespace v2rayN.Desktop.Views else { ViewModel?.EditServerAsync(EConfigType.Custom); - } + } } private void LstProfiles_LoadingRow(object? sender, DataGridRowEventArgs e) @@ -313,6 +313,7 @@ namespace v2rayN.Desktop.Views ViewModel?.RefreshServers(); } } + private void MenuStorageUI_Click(object? sender, RoutedEventArgs e) { StorageUI(); diff --git a/v2rayN/v2rayN.Desktop/Views/QrcodeView.axaml.cs b/v2rayN/v2rayN.Desktop/Views/QrcodeView.axaml.cs index 15ba0357..2f8bab2a 100644 --- a/v2rayN/v2rayN.Desktop/Views/QrcodeView.axaml.cs +++ b/v2rayN/v2rayN.Desktop/Views/QrcodeView.axaml.cs @@ -12,7 +12,7 @@ namespace v2rayN.Desktop.Views txtContent.Text = url; imgQrcode.Source = GetQRCode(url); - // btnCancel.Click += (s, e) => this.Close(); + // btnCancel.Click += (s, e) => this.Close(); } private Bitmap? GetQRCode(string? url) diff --git a/v2rayN/v2rayN/Common/WindowsUtils.cs b/v2rayN/v2rayN/Common/WindowsUtils.cs index 27a66f63..b9ca2323 100644 --- a/v2rayN/v2rayN/Common/WindowsUtils.cs +++ b/v2rayN/v2rayN/Common/WindowsUtils.cs @@ -207,7 +207,7 @@ namespace v2rayN uint attributeSize = (uint)Marshal.SizeOf(attribute); DwmSetWindowAttribute(hWnd, DWMWINDOWATTRIBUTE.DWMWA_USE_IMMERSIVE_DARK_MODE_BEFORE_20H1, ref attribute, attributeSize); DwmSetWindowAttribute(hWnd, DWMWINDOWATTRIBUTE.DWMWA_USE_IMMERSIVE_DARK_MODE, ref attribute, attributeSize); - } + } /// /// 开机自动启动 diff --git a/v2rayN/v2rayN/ViewModels/ThemeSettingViewModel.cs b/v2rayN/v2rayN/ViewModels/ThemeSettingViewModel.cs index bce52e8c..aa20ee0e 100644 --- a/v2rayN/v2rayN/ViewModels/ThemeSettingViewModel.cs +++ b/v2rayN/v2rayN/ViewModels/ThemeSettingViewModel.cs @@ -5,7 +5,6 @@ using MaterialDesignColors.ColorManipulation; using MaterialDesignThemes.Wpf; using ReactiveUI; using ReactiveUI.Fody.Helpers; -using Splat; using System.Reactive.Linq; using System.Runtime.InteropServices; using System.Windows; @@ -38,7 +37,7 @@ namespace v2rayN.ViewModels public ThemeSettingViewModel() { _config = AppHandler.Instance.Config; - _noticeHandler = Locator.Current.GetService(); + RegisterSystemColorSet(_config, Application.Current.MainWindow, (bool bl) => { ModifyTheme(bl); }); BindingUI(); @@ -161,7 +160,7 @@ namespace v2rayN.ViewModels _config.uiItem.currentLanguage = CurrentLanguage; Thread.CurrentThread.CurrentUICulture = new(CurrentLanguage); ConfigHandler.SaveConfig(_config); - _noticeHandler?.Enqueue(ResUI.NeedRebootTips); + NoticeHandler.Instance.Enqueue(ResUI.NeedRebootTips); } }); } diff --git a/v2rayN/v2rayN/Views/AddServer2Window.xaml.cs b/v2rayN/v2rayN/Views/AddServer2Window.xaml.cs index aac02464..44b0136c 100644 --- a/v2rayN/v2rayN/Views/AddServer2Window.xaml.cs +++ b/v2rayN/v2rayN/Views/AddServer2Window.xaml.cs @@ -17,7 +17,7 @@ namespace v2rayN.Views foreach (ECoreType it in Enum.GetValues(typeof(ECoreType))) { if (it == ECoreType.v2rayN) - continue; + continue; cmbCoreType.Items.Add(it.ToString()); } cmbCoreType.Items.Add(string.Empty); diff --git a/v2rayN/v2rayN/Views/BackupAndRestoreView.xaml.cs b/v2rayN/v2rayN/Views/BackupAndRestoreView.xaml.cs index 33052044..b6787971 100644 --- a/v2rayN/v2rayN/Views/BackupAndRestoreView.xaml.cs +++ b/v2rayN/v2rayN/Views/BackupAndRestoreView.xaml.cs @@ -1,5 +1,4 @@ using ReactiveUI; -using Splat; using System.Reactive.Disposables; using System.Windows; @@ -7,8 +6,6 @@ namespace v2rayN.Views { public partial class BackupAndRestoreView { - private NoticeHandler? _noticeHandler; - public BackupAndRestoreView() { InitializeComponent(); @@ -17,7 +14,6 @@ namespace v2rayN.Views ViewModel = new BackupAndRestoreViewModel(UpdateViewHandler); - _noticeHandler = Locator.Current.GetService(); this.WhenActivated(disposables => { this.Bind(ViewModel, vm => vm.OperationMsg, v => v.txtMsg.Text).DisposeWith(disposables); @@ -32,7 +28,7 @@ namespace v2rayN.Views this.BindCommand(ViewModel, vm => vm.RemoteBackupCmd, v => v.menuRemoteBackup).DisposeWith(disposables); this.BindCommand(ViewModel, vm => vm.RemoteRestoreCmd, v => v.menuRemoteRestore).DisposeWith(disposables); }); - } + } private void MenuLocalBackup_Click(object sender, RoutedEventArgs e) { diff --git a/v2rayN/v2rayN/Views/ClashConnectionsView.xaml b/v2rayN/v2rayN/Views/ClashConnectionsView.xaml index 90ff3142..b9e3ef5e 100644 --- a/v2rayN/v2rayN/Views/ClashConnectionsView.xaml +++ b/v2rayN/v2rayN/Views/ClashConnectionsView.xaml @@ -1,11 +1,11 @@ t.coreType != ECoreType.v2fly + .Where(t => t.coreType != ECoreType.v2fly && t.coreType != ECoreType.hysteria)) { var item = new MenuItem() diff --git a/v2rayN/v2rayN/Views/RoutingRuleDetailsWindow.xaml b/v2rayN/v2rayN/Views/RoutingRuleDetailsWindow.xaml index 86740dcd..75b764ec 100644 --- a/v2rayN/v2rayN/Views/RoutingRuleDetailsWindow.xaml +++ b/v2rayN/v2rayN/Views/RoutingRuleDetailsWindow.xaml @@ -164,8 +164,6 @@ HorizontalAlignment="Left" Style="{StaticResource ToolbarTextBlock}" Text="{x:Static resx:ResUI.TbRoutingTips}" /> - -