diff --git a/v2rayN/ServiceLib/Common/JsonUtils.cs b/v2rayN/ServiceLib/Common/JsonUtils.cs index 40d0cdfc..4d0f8e71 100644 --- a/v2rayN/ServiceLib/Common/JsonUtils.cs +++ b/v2rayN/ServiceLib/Common/JsonUtils.cs @@ -31,7 +31,11 @@ namespace ServiceLib.Common { return default; } - return JsonSerializer.Deserialize(strJson); + var options = new JsonSerializerOptions + { + PropertyNameCaseInsensitive = true + }; + return JsonSerializer.Deserialize(strJson, options); } catch { diff --git a/v2rayN/ServiceLib/Handler/AppHandler.cs b/v2rayN/ServiceLib/Handler/AppHandler.cs index 3f585339..167fe4eb 100644 --- a/v2rayN/ServiceLib/Handler/AppHandler.cs +++ b/v2rayN/ServiceLib/Handler/AppHandler.cs @@ -51,7 +51,7 @@ { return false; } - Thread.CurrentThread.CurrentUICulture = new(_config.uiItem.currentLanguage); + Thread.CurrentThread.CurrentUICulture = new(_config.UiItem.CurrentLanguage); //Under Win10 if (Utils.IsWindows() && Environment.OSVersion.Version.Major < 10) @@ -85,7 +85,7 @@ public int GetLocalPort(EInboundProtocol protocol) { - var localPort = _config.inbound.FirstOrDefault(t => t.protocol == nameof(EInboundProtocol.socks))?.localPort ?? 10808; + var localPort = _config.Inbound.FirstOrDefault(t => t.Protocol == nameof(EInboundProtocol.socks))?.LocalPort ?? 10808; return localPort + (int)protocol; } @@ -165,11 +165,11 @@ public async Task> ProfileItemsEx(string subid, string filter) { - var lstModel = await ProfileItems(_config.subIndexId, filter); + var lstModel = await ProfileItems(_config.SubIndexId, filter); await ConfigHandler.SetDefaultServer(_config, lstModel); - var lstServerStat = (_config.guiItem.enableStatistics ? StatisticsHandler.Instance.ServerStat : null) ?? []; + var lstServerStat = (_config.GuiItem.EnableStatistics ? StatisticsHandler.Instance.ServerStat : null) ?? []; var lstProfileExs = ProfileExHandler.Instance.ProfileExs; lstModel = (from t in lstModel join t2 in lstServerStat on t.indexId equals t2.indexId into t2b @@ -188,7 +188,7 @@ streamSecurity = t.streamSecurity, subid = t.subid, subRemarks = t.subRemarks, - isActive = t.indexId == _config.indexId, + isActive = t.indexId == _config.IndexId, sort = t33 == null ? 0 : t33.sort, delay = t33 == null ? 0 : t33.delay, delayVal = t33?.delay != 0 ? $"{t33?.delay} {Global.DelayUnit}" : string.Empty, @@ -268,16 +268,16 @@ return (ECoreType)profileItem.coreType; } - if (_config.coreTypeItem == null) + if (_config.CoreTypeItem == null) { return ECoreType.Xray; } - var item = _config.coreTypeItem.FirstOrDefault(it => it.configType == eConfigType); + var item = _config.CoreTypeItem.FirstOrDefault(it => it.ConfigType == eConfigType); if (item == null) { return ECoreType.Xray; } - return item.coreType; + return item.CoreType; } #endregion Core Type diff --git a/v2rayN/ServiceLib/Handler/ClashApiHandler.cs b/v2rayN/ServiceLib/Handler/ClashApiHandler.cs index 90897503..832f6549 100644 --- a/v2rayN/ServiceLib/Handler/ClashApiHandler.cs +++ b/v2rayN/ServiceLib/Handler/ClashApiHandler.cs @@ -72,7 +72,7 @@ namespace ServiceLib.Handler return; } var urlBase = $"{GetApiUrl()}/proxies"; - urlBase += @"/{0}/delay?timeout=10000&url=" + AppHandler.Instance.Config.speedTestItem.speedPingTestUrl; + urlBase += @"/{0}/delay?timeout=10000&url=" + AppHandler.Instance.Config.SpeedTestItem.SpeedPingTestUrl; List tasks = new List(); foreach (var it in lstProxy) diff --git a/v2rayN/ServiceLib/Handler/ConfigHandler.cs b/v2rayN/ServiceLib/Handler/ConfigHandler.cs index 24d06e4d..ab58463c 100644 --- a/v2rayN/ServiceLib/Handler/ConfigHandler.cs +++ b/v2rayN/ServiceLib/Handler/ConfigHandler.cs @@ -37,133 +37,133 @@ namespace ServiceLib.Handler config ??= new Config(); - config.coreBasicItem ??= new() + config.CoreBasicItem ??= new() { - logEnabled = false, - loglevel = "warning", - muxEnabled = false, + LogEnabled = false, + Loglevel = "warning", + MuxEnabled = false, }; - if (config.inbound == null) + if (config.Inbound == null) { - config.inbound = new List(); + config.Inbound = new List(); InItem inItem = new() { - protocol = EInboundProtocol.socks.ToString(), - localPort = 10808, - udpEnabled = true, - sniffingEnabled = true, - routeOnly = false, + Protocol = EInboundProtocol.socks.ToString(), + LocalPort = 10808, + UdpEnabled = true, + SniffingEnabled = true, + RouteOnly = false, }; - config.inbound.Add(inItem); + config.Inbound.Add(inItem); } else { - if (config.inbound.Count > 0) + if (config.Inbound.Count > 0) { - config.inbound[0].protocol = EInboundProtocol.socks.ToString(); + config.Inbound[0].Protocol = EInboundProtocol.socks.ToString(); } } - config.routingBasicItem ??= new() + config.RoutingBasicItem ??= new() { - enableRoutingAdvanced = true + EnableRoutingAdvanced = true }; - if (Utils.IsNullOrEmpty(config.routingBasicItem.domainStrategy)) + if (Utils.IsNullOrEmpty(config.RoutingBasicItem.DomainStrategy)) { - config.routingBasicItem.domainStrategy = Global.DomainStrategies[0];//"IPIfNonMatch"; + config.RoutingBasicItem.DomainStrategy = Global.DomainStrategies[0];//"IPIfNonMatch"; } - config.kcpItem ??= new KcpItem + config.KcpItem ??= new KcpItem { - mtu = 1350, - tti = 50, - uplinkCapacity = 12, - downlinkCapacity = 100, - readBufferSize = 2, - writeBufferSize = 2, - congestion = false + Mtu = 1350, + Tti = 50, + UplinkCapacity = 12, + DownlinkCapacity = 100, + ReadBufferSize = 2, + WriteBufferSize = 2, + Congestion = false }; - config.grpcItem ??= new GrpcItem + config.GrpcItem ??= new GrpcItem { - idle_timeout = 60, - health_check_timeout = 20, - permit_without_stream = false, - initial_windows_size = 0, + IdleTimeout = 60, + HealthCheckTimeout = 20, + PermitWithoutStream = false, + InitialWindowsSize = 0, }; - config.tunModeItem ??= new TunModeItem + config.TunModeItem ??= new TunModeItem { - enableTun = false, - mtu = 9000, + EnableTun = false, + Mtu = 9000, }; - config.guiItem ??= new() + config.GuiItem ??= new() { - enableStatistics = false, + EnableStatistics = false, }; - config.msgUIItem ??= new(); + config.MsgUIItem ??= new(); - config.uiItem ??= new UIItem() + config.UiItem ??= new UIItem() { - enableAutoAdjustMainLvColWidth = true + EnableAutoAdjustMainLvColWidth = true }; - if (config.uiItem.mainColumnItem == null) + if (config.UiItem.MainColumnItem == null) { - config.uiItem.mainColumnItem = new(); + config.UiItem.MainColumnItem = new(); } - if (Utils.IsNullOrEmpty(config.uiItem.currentLanguage)) + if (Utils.IsNullOrEmpty(config.UiItem.CurrentLanguage)) { if (Thread.CurrentThread.CurrentCulture.Name.Equals("zh-cn", StringComparison.CurrentCultureIgnoreCase)) { - config.uiItem.currentLanguage = Global.Languages[0]; + config.UiItem.CurrentLanguage = Global.Languages[0]; } else { - config.uiItem.currentLanguage = Global.Languages[2]; + config.UiItem.CurrentLanguage = Global.Languages[2]; } } - config.constItem ??= new ConstItem(); - if (Utils.IsNullOrEmpty(config.constItem.defIEProxyExceptions)) + config.ConstItem ??= new ConstItem(); + if (Utils.IsNullOrEmpty(config.ConstItem.DefIEProxyExceptions)) { - config.constItem.defIEProxyExceptions = Global.IEProxyExceptions; + config.ConstItem.DefIEProxyExceptions = Global.IEProxyExceptions; } - config.speedTestItem ??= new(); - if (config.speedTestItem.speedTestTimeout < 10) + config.SpeedTestItem ??= new(); + if (config.SpeedTestItem.SpeedTestTimeout < 10) { - config.speedTestItem.speedTestTimeout = 10; + config.SpeedTestItem.SpeedTestTimeout = 10; } - if (Utils.IsNullOrEmpty(config.speedTestItem.speedTestUrl)) + if (Utils.IsNullOrEmpty(config.SpeedTestItem.SpeedTestUrl)) { - config.speedTestItem.speedTestUrl = Global.SpeedTestUrls[0]; + config.SpeedTestItem.SpeedTestUrl = Global.SpeedTestUrls[0]; } - if (Utils.IsNullOrEmpty(config.speedTestItem.speedPingTestUrl)) + if (Utils.IsNullOrEmpty(config.SpeedTestItem.SpeedPingTestUrl)) { - config.speedTestItem.speedPingTestUrl = Global.SpeedPingTestUrl; + config.SpeedTestItem.SpeedPingTestUrl = Global.SpeedPingTestUrl; } - config.mux4RayItem ??= new() + config.Mux4RayItem ??= new() { - concurrency = 8, - xudpConcurrency = 16, - xudpProxyUDP443 = "reject" + Concurrency = 8, + XudpConcurrency = 16, + XudpProxyUDP443 = "reject" }; - config.mux4SboxItem ??= new() + config.Mux4SboxItem ??= new() { - protocol = Global.SingboxMuxs[0], - max_connections = 8 + Protocol = Global.SingboxMuxs[0], + MaxConnections = 8 }; - config.hysteriaItem ??= new() + config.HysteriaItem ??= new() { - up_mbps = 100, - down_mbps = 100 + UpMbps = 100, + DownMbps = 100 }; - config.clashUIItem ??= new(); - config.systemProxyItem ??= new(); - config.webDavItem ??= new(); + config.ClashUIItem ??= new(); + config.SystemProxyItem ??= new(); + config.WebDavItem ??= new(); return config; } @@ -369,7 +369,7 @@ namespace ServiceLib.Handler return -1; } - config.indexId = indexId; + config.IndexId = indexId; await ToJsonFile(config); @@ -378,11 +378,11 @@ namespace ServiceLib.Handler public static async Task SetDefaultServer(Config config, List lstProfile) { - if (lstProfile.Exists(t => t.indexId == config.indexId)) + if (lstProfile.Exists(t => t.indexId == config.IndexId)) { return 0; } - var count = await SQLiteHelper.Instance.TableAsync().CountAsync(t => t.indexId == config.indexId); + var count = await SQLiteHelper.Instance.TableAsync().CountAsync(t => t.indexId == config.IndexId); if (count > 0) { return 0; @@ -398,7 +398,7 @@ namespace ServiceLib.Handler public static async Task GetDefaultServer(Config config) { - var item = await AppHandler.Instance.GetProfileItem(config.indexId); + var item = await AppHandler.Instance.GetProfileItem(config.IndexId); if (item is null) { var item2 = await SQLiteHelper.Instance.TableAsync().FirstOrDefaultAsync(); @@ -887,7 +887,7 @@ namespace ServiceLib.Handler List lstKeep = new(); List lstRemove = new(); - if (!config.guiItem.keepOlderDedupl) lstProfile.Reverse(); + if (!config.GuiItem.KeepOlderDedupl) lstProfile.Reverse(); foreach (ProfileItem item in lstProfile) { @@ -920,11 +920,11 @@ namespace ServiceLib.Handler { if (Utils.IsNullOrEmpty(profileItem.allowInsecure)) { - profileItem.allowInsecure = config.coreBasicItem.defAllowInsecure.ToString().ToLower(); + profileItem.allowInsecure = config.CoreBasicItem.DefAllowInsecure.ToString().ToLower(); } if (Utils.IsNullOrEmpty(profileItem.fingerprint) && profileItem.streamSecurity == Global.StreamSecurityReality) { - profileItem.fingerprint = config.coreBasicItem.defFingerprint; + profileItem.fingerprint = config.CoreBasicItem.DefFingerprint; } } } @@ -1089,7 +1089,7 @@ namespace ServiceLib.Handler if (isSub && Utils.IsNotEmpty(subid)) { var existItem = lstOriSub?.FirstOrDefault(t => t.isSub == isSub - && config.uiItem.enableUpdateSubOnlyRemarksExist ? t.remarks == profileItem.remarks : CompareProfileItem(t, profileItem, true)); + && config.UiItem.EnableUpdateSubOnlyRemarksExist ? t.remarks == profileItem.remarks : CompareProfileItem(t, profileItem, true)); if (existItem != null) { //Check for duplicate indexId @@ -1604,7 +1604,7 @@ namespace ServiceLib.Handler { if (await SQLiteHelper.Instance.TableAsync().Where(t => t.id == routingItem.id).CountAsync() > 0) { - config.routingBasicItem.routingIndexId = routingItem.id; + config.RoutingBasicItem.RoutingIndexId = routingItem.id; } await ToJsonFile(config); @@ -1614,7 +1614,7 @@ namespace ServiceLib.Handler public static async Task GetDefaultRouting(Config config) { - var item = await AppHandler.Instance.GetRoutingItem(config.routingBasicItem.routingIndexId); + var item = await AppHandler.Instance.GetRoutingItem(config.RoutingBasicItem.RoutingIndexId); if (item is null) { var item2 = await SQLiteHelper.Instance.TableAsync().FirstOrDefaultAsync(t => t.locked == false); @@ -1627,7 +1627,7 @@ namespace ServiceLib.Handler public static async Task InitRouting(Config config, bool blImportAdvancedRules = false) { - if (string.IsNullOrEmpty(config.constItem.routeRulesTemplateSourceUrl)) + if (string.IsNullOrEmpty(config.ConstItem.RouteRulesTemplateSourceUrl)) { await InitBuiltinRouting(config, blImportAdvancedRules); } @@ -1642,7 +1642,7 @@ namespace ServiceLib.Handler public static async Task InitExternalRouting(Config config, bool blImportAdvancedRules = false) { var downloadHandle = new DownloadService(); - var templateContent = await downloadHandle.TryDownloadString(config.constItem.routeRulesTemplateSourceUrl, true, ""); + var templateContent = await downloadHandle.TryDownloadString(config.ConstItem.RouteRulesTemplateSourceUrl, true, ""); if (string.IsNullOrEmpty(templateContent)) return await InitBuiltinRouting(config, blImportAdvancedRules); // fallback @@ -1826,9 +1826,9 @@ namespace ServiceLib.Handler switch (type) { case EPresetType.Default: - config.constItem.geoSourceUrl = ""; - config.constItem.srsSourceUrl = ""; - config.constItem.routeRulesTemplateSourceUrl = ""; + config.ConstItem.GeoSourceUrl = ""; + config.ConstItem.SrsSourceUrl = ""; + config.ConstItem.RouteRulesTemplateSourceUrl = ""; await SQLiteHelper.Instance.DeleteAllAsync(); await InitBuiltinDNS(config); @@ -1836,9 +1836,9 @@ namespace ServiceLib.Handler return true; case EPresetType.Russia: - config.constItem.geoSourceUrl = Global.GeoFilesSources[1]; - config.constItem.srsSourceUrl = Global.SingboxRulesetSources[1]; - config.constItem.routeRulesTemplateSourceUrl = Global.RoutingRulesSources[1]; + config.ConstItem.GeoSourceUrl = Global.GeoFilesSources[1]; + config.ConstItem.SrsSourceUrl = Global.SingboxRulesetSources[1]; + config.ConstItem.RouteRulesTemplateSourceUrl = Global.RoutingRulesSources[1]; await SaveDNSItems(config, await GetExternalDNSItem(ECoreType.Xray, Global.DNSTemplateSources[1] + "v2ray.json")); await SaveDNSItems(config, await GetExternalDNSItem(ECoreType.sing_box, Global.DNSTemplateSources[1] + "sing_box.json")); diff --git a/v2rayN/ServiceLib/Handler/CoreHandler.cs b/v2rayN/ServiceLib/Handler/CoreHandler.cs index f843aaf7..a2f85d02 100644 --- a/v2rayN/ServiceLib/Handler/CoreHandler.cs +++ b/v2rayN/ServiceLib/Handler/CoreHandler.cs @@ -182,7 +182,7 @@ namespace ServiceLib.Handler // coreType = LazyConfig.Instance.GetCoreType(node, node.configType); //} var coreType = AppHandler.Instance.GetCoreType(node, node.configType); - _config.runningCoreType = coreType; + _config.RunningCoreType = coreType; var coreInfo = CoreInfoHandler.Instance.GetCoreInfo(coreType); var displayLog = node.configType != EConfigType.Custom || node.displayLog; @@ -198,7 +198,7 @@ namespace ServiceLib.Handler { ProfileItem? itemSocks = null; var preCoreType = ECoreType.sing_box; - if (node.configType != EConfigType.Custom && coreType != ECoreType.sing_box && _config.tunModeItem.enableTun) + if (node.configType != EConfigType.Custom && coreType != ECoreType.sing_box && _config.TunModeItem.EnableTun) { itemSocks = new ProfileItem() { @@ -211,7 +211,7 @@ namespace ServiceLib.Handler } else if ((node.configType == EConfigType.Custom && node.preSocksPort > 0)) { - preCoreType = _config.tunModeItem.enableTun ? ECoreType.sing_box : ECoreType.Xray; + preCoreType = _config.TunModeItem.EnableTun ? ECoreType.sing_box : ECoreType.Xray; itemSocks = new ProfileItem() { coreType = preCoreType, @@ -219,7 +219,7 @@ namespace ServiceLib.Handler address = Global.Loopback, port = node.preSocksPort.Value, }; - _config.runningCoreType = preCoreType; + _config.RunningCoreType = preCoreType; } if (itemSocks != null) { diff --git a/v2rayN/ServiceLib/Handler/ProfileExHandler.cs b/v2rayN/ServiceLib/Handler/ProfileExHandler.cs index 0636d0b1..6503cc7c 100644 --- a/v2rayN/ServiceLib/Handler/ProfileExHandler.cs +++ b/v2rayN/ServiceLib/Handler/ProfileExHandler.cs @@ -20,7 +20,7 @@ namespace ServiceLib.Handler private async Task Init() { await InitData(); - Task.Run(async () => + await Task.Run(async () => { while (true) { diff --git a/v2rayN/ServiceLib/Handler/StatisticsHandler.cs b/v2rayN/ServiceLib/Handler/StatisticsHandler.cs index 249f5e69..3cb55f47 100644 --- a/v2rayN/ServiceLib/Handler/StatisticsHandler.cs +++ b/v2rayN/ServiceLib/Handler/StatisticsHandler.cs @@ -18,7 +18,7 @@ { _config = config; _updateFunc = updateFunc; - if (!config.guiItem.enableStatistics) + if (!config.GuiItem.EnableStatistics) { return; } @@ -81,7 +81,7 @@ private async Task UpdateServerStat(ServerSpeedItem server) { - await GetServerStatItem(_config.indexId); + await GetServerStatItem(_config.IndexId); if (_serverStatItem is null) { @@ -95,7 +95,7 @@ _serverStatItem.totalDown += server.proxyDown; } - server.indexId = _config.indexId; + server.indexId = _config.IndexId; server.todayUp = _serverStatItem.todayUp; server.todayDown = _serverStatItem.todayDown; server.totalUp = _serverStatItem.totalUp; diff --git a/v2rayN/ServiceLib/Handler/SysProxy/SysProxyHandler.cs b/v2rayN/ServiceLib/Handler/SysProxy/SysProxyHandler.cs index 54bfec06..d6735e4b 100644 --- a/v2rayN/ServiceLib/Handler/SysProxy/SysProxyHandler.cs +++ b/v2rayN/ServiceLib/Handler/SysProxy/SysProxyHandler.cs @@ -6,7 +6,7 @@ namespace ServiceLib.Handler.SysProxy { public static async Task UpdateSysProxy(Config config, bool forceDisable) { - var type = config.systemProxyItem.sysProxyType; + var type = config.SystemProxyItem.SysProxyType; if (forceDisable && type != ESysProxyType.Unchanged) { @@ -84,19 +84,19 @@ namespace ServiceLib.Handler.SysProxy private static void GetWindowsProxyString(Config config, int port, int portSocks, out string strProxy, out string strExceptions) { strExceptions = ""; - if (config.systemProxyItem.notProxyLocalAddress) + if (config.SystemProxyItem.NotProxyLocalAddress) { - strExceptions = $";{config.constItem.defIEProxyExceptions};{config.systemProxyItem.systemProxyExceptions}"; + strExceptions = $";{config.ConstItem.DefIEProxyExceptions};{config.SystemProxyItem.SystemProxyExceptions}"; } strProxy = string.Empty; - if (Utils.IsNullOrEmpty(config.systemProxyItem.systemProxyAdvancedProtocol)) + if (Utils.IsNullOrEmpty(config.SystemProxyItem.SystemProxyAdvancedProtocol)) { strProxy = $"{Global.Loopback}:{port}"; } else { - strProxy = config.systemProxyItem.systemProxyAdvancedProtocol + strProxy = config.SystemProxyItem.SystemProxyAdvancedProtocol .Replace("{ip}", Global.Loopback) .Replace("{http_port}", port.ToString()) .Replace("{socks_port}", portSocks.ToString()); diff --git a/v2rayN/ServiceLib/Handler/TaskHandler.cs b/v2rayN/ServiceLib/Handler/TaskHandler.cs index edff7e5e..2fef0c50 100644 --- a/v2rayN/ServiceLib/Handler/TaskHandler.cs +++ b/v2rayN/ServiceLib/Handler/TaskHandler.cs @@ -55,9 +55,9 @@ await Task.Delay(1000 * 3600); var dtNow = DateTime.Now; - if (config.guiItem.autoUpdateInterval > 0) + if (config.GuiItem.AutoUpdateInterval > 0) { - if ((dtNow - autoUpdateGeoTime).Hours % config.guiItem.autoUpdateInterval == 0) + if ((dtNow - autoUpdateGeoTime).Hours % config.GuiItem.AutoUpdateInterval == 0) { await updateHandle.UpdateGeoFileAll(config, (bool success, string msg) => { diff --git a/v2rayN/ServiceLib/Handler/WebDavHandler.cs b/v2rayN/ServiceLib/Handler/WebDavHandler.cs index 3eda381c..c034d06f 100644 --- a/v2rayN/ServiceLib/Handler/WebDavHandler.cs +++ b/v2rayN/ServiceLib/Handler/WebDavHandler.cs @@ -24,9 +24,9 @@ namespace ServiceLib.Handler { try { - if (_config.webDavItem.url.IsNullOrEmpty() - || _config.webDavItem.userName.IsNullOrEmpty() - || _config.webDavItem.password.IsNullOrEmpty()) + if (_config.WebDavItem.Url.IsNullOrEmpty() + || _config.WebDavItem.UserName.IsNullOrEmpty() + || _config.WebDavItem.Password.IsNullOrEmpty()) { throw new ArgumentException("webdav parameter error or null"); } @@ -35,19 +35,19 @@ namespace ServiceLib.Handler _client?.Dispose(); _client = null; } - if (_config.webDavItem.dirName.IsNullOrEmpty()) + if (_config.WebDavItem.DirName.IsNullOrEmpty()) { _webDir = Global.AppName + "_backup"; } else { - _webDir = _config.webDavItem.dirName.TrimEx(); + _webDir = _config.WebDavItem.DirName.TrimEx(); } var clientParams = new WebDavClientParams { - BaseAddress = new Uri(_config.webDavItem.url), - Credentials = new NetworkCredential(_config.webDavItem.userName, _config.webDavItem.password) + BaseAddress = new Uri(_config.WebDavItem.Url), + Credentials = new NetworkCredential(_config.WebDavItem.UserName, _config.WebDavItem.Password) }; _client = new WebDavClient(clientParams); } diff --git a/v2rayN/ServiceLib/Models/Config.cs b/v2rayN/ServiceLib/Models/Config.cs index 6bc73d3a..fce57300 100644 --- a/v2rayN/ServiceLib/Models/Config.cs +++ b/v2rayN/ServiceLib/Models/Config.cs @@ -8,18 +8,18 @@ { #region property - public string indexId { get; set; } - public string subIndexId { get; set; } + public string IndexId { get; set; } + public string SubIndexId { get; set; } - public ECoreType runningCoreType { get; set; } + public ECoreType RunningCoreType { get; set; } public bool IsRunningCore(ECoreType type) { - if (type == ECoreType.Xray && runningCoreType is ECoreType.Xray or ECoreType.v2fly or ECoreType.v2fly_v5) + if (type == ECoreType.Xray && RunningCoreType is ECoreType.Xray or ECoreType.v2fly or ECoreType.v2fly_v5) { return true; } - if (type == ECoreType.sing_box && runningCoreType is ECoreType.sing_box or ECoreType.mihomo) + if (type == ECoreType.sing_box && RunningCoreType is ECoreType.sing_box or ECoreType.mihomo) { return true; } @@ -30,25 +30,25 @@ #region other entities - public CoreBasicItem coreBasicItem { get; set; } - public TunModeItem tunModeItem { get; set; } - public KcpItem kcpItem { get; set; } - public GrpcItem grpcItem { get; set; } - public RoutingBasicItem routingBasicItem { get; set; } - public GUIItem guiItem { get; set; } - public MsgUIItem msgUIItem { get; set; } - public UIItem uiItem { get; set; } - public ConstItem constItem { get; set; } - public SpeedTestItem speedTestItem { get; set; } - public Mux4RayItem mux4RayItem { get; set; } - public Mux4SboxItem mux4SboxItem { get; set; } - public HysteriaItem hysteriaItem { get; set; } - public ClashUIItem clashUIItem { get; set; } - public SystemProxyItem systemProxyItem { get; set; } - public WebDavItem webDavItem { get; set; } - public List inbound { get; set; } - public List globalHotkeys { get; set; } - public List coreTypeItem { get; set; } + public CoreBasicItem CoreBasicItem { get; set; } + public TunModeItem TunModeItem { get; set; } + public KcpItem KcpItem { get; set; } + public GrpcItem GrpcItem { get; set; } + public RoutingBasicItem RoutingBasicItem { get; set; } + public GUIItem GuiItem { get; set; } + public MsgUIItem MsgUIItem { get; set; } + public UIItem UiItem { get; set; } + public ConstItem ConstItem { get; set; } + public SpeedTestItem SpeedTestItem { get; set; } + public Mux4RayItem Mux4RayItem { get; set; } + public Mux4SboxItem Mux4SboxItem { get; set; } + public HysteriaItem HysteriaItem { get; set; } + public ClashUIItem ClashUIItem { get; set; } + public SystemProxyItem SystemProxyItem { get; set; } + public WebDavItem WebDavItem { get; set; } + public List Inbound { get; set; } + public List GlobalHotkeys { get; set; } + public List CoreTypeItem { get; set; } #endregion other entities } diff --git a/v2rayN/ServiceLib/Models/ConfigItems.cs b/v2rayN/ServiceLib/Models/ConfigItems.cs index f42aee96..aea3eab9 100644 --- a/v2rayN/ServiceLib/Models/ConfigItems.cs +++ b/v2rayN/ServiceLib/Models/ConfigItems.cs @@ -3,152 +3,137 @@ [Serializable] public class CoreBasicItem { - /// - /// 允许日志 - /// - public bool logEnabled { get; set; } + public bool LogEnabled { get; set; } - /// - /// 日志等级 - /// - public string loglevel { get; set; } + public string Loglevel { get; set; } - /// - /// 允许Mux多路复用 - /// - public bool muxEnabled { get; set; } + public bool MuxEnabled { get; set; } - /// - /// 是否允许不安全连接 - /// - public bool defAllowInsecure { get; set; } + public bool DefAllowInsecure { get; set; } - public string defFingerprint { get; set; } + public string DefFingerprint { get; set; } - /// - /// 默认用户代理 - /// - public string defUserAgent { get; set; } + public string DefUserAgent { get; set; } - public bool enableFragment { get; set; } + public bool EnableFragment { get; set; } - public bool enableCacheFile4Sbox { get; set; } = true; + public bool EnableCacheFile4Sbox { get; set; } = true; } [Serializable] public class InItem { - public int localPort { get; set; } + public int LocalPort { get; set; } - public string protocol { get; set; } + public string Protocol { get; set; } - public bool udpEnabled { get; set; } + public bool UdpEnabled { get; set; } - public bool sniffingEnabled { get; set; } = true; - public List? destOverride { get; set; } = ["http", "tls"]; - public bool routeOnly { get; set; } - public bool allowLANConn { get; set; } + public bool SniffingEnabled { get; set; } = true; + public List? DestOverride { get; set; } = ["http", "tls"]; + public bool RouteOnly { get; set; } + public bool AllowLANConn { get; set; } - public bool newPort4LAN { get; set; } + public bool NewPort4LAN { get; set; } - public string user { get; set; } + public string User { get; set; } - public string pass { get; set; } + public string Pass { get; set; } } [Serializable] public class KcpItem { - public int mtu { get; set; } + public int Mtu { get; set; } - public int tti { get; set; } + public int Tti { get; set; } - public int uplinkCapacity { get; set; } + public int UplinkCapacity { get; set; } - public int downlinkCapacity { get; set; } + public int DownlinkCapacity { get; set; } - public bool congestion { get; set; } + public bool Congestion { get; set; } - public int readBufferSize { get; set; } + public int ReadBufferSize { get; set; } - public int writeBufferSize { get; set; } + public int WriteBufferSize { get; set; } } [Serializable] public class GrpcItem { - public int idle_timeout { get; set; } - public int health_check_timeout { get; set; } - public bool permit_without_stream { get; set; } - public int initial_windows_size { get; set; } + public int IdleTimeout { get; set; } + public int HealthCheckTimeout { get; set; } + public bool PermitWithoutStream { get; set; } + public int InitialWindowsSize { get; set; } } [Serializable] public class GUIItem { - public bool autoRun { get; set; } + public bool AutoRun { get; set; } - public bool enableStatistics { get; set; } + public bool EnableStatistics { get; set; } - public bool keepOlderDedupl { get; set; } + public bool KeepOlderDedupl { get; set; } - public bool ignoreGeoUpdateCore { get; set; } = true; + public bool IgnoreGeoUpdateCore { get; set; } = true; - public int autoUpdateInterval { get; set; } + public int AutoUpdateInterval { get; set; } - public bool checkPreReleaseUpdate { get; set; } = false; + public bool CheckPreReleaseUpdate { get; set; } = false; - public bool enableSecurityProtocolTls13 { get; set; } + public bool EnableSecurityProtocolTls13 { get; set; } - public int trayMenuServersLimit { get; set; } = 20; + public int TrayMenuServersLimit { get; set; } = 20; - public bool enableHWA { get; set; } = false; + public bool EnableHWA { get; set; } = false; } [Serializable] public class MsgUIItem { - public string? mainMsgFilter { get; set; } - public bool? autoRefresh { get; set; } + public string? MainMsgFilter { get; set; } + public bool? AutoRefresh { get; set; } } [Serializable] public class UIItem { - public bool enableAutoAdjustMainLvColWidth { get; set; } - public bool enableUpdateSubOnlyRemarksExist { get; set; } - public double mainWidth { get; set; } - public double mainHeight { get; set; } - public double mainGirdHeight1 { get; set; } - public double mainGirdHeight2 { get; set; } - public EGirdOrientation mainGirdOrientation { get; set; } = EGirdOrientation.Vertical; - public bool colorModeDark { get; set; } - public bool followSystemTheme { get; set; } - public string? colorPrimaryName { get; set; } - public string currentLanguage { get; set; } - public string currentFontFamily { get; set; } - public int currentFontSize { get; set; } - public bool enableDragDropSort { get; set; } - public bool doubleClick2Activate { get; set; } - public bool autoHideStartup { get; set; } - public List mainColumnItem { get; set; } - public bool showInTaskbar { get; set; } + public bool EnableAutoAdjustMainLvColWidth { get; set; } + public bool EnableUpdateSubOnlyRemarksExist { get; set; } + public double MainWidth { get; set; } + public double MainHeight { get; set; } + public double MainGirdHeight1 { get; set; } + public double MainGirdHeight2 { get; set; } + public EGirdOrientation MainGirdOrientation { get; set; } = EGirdOrientation.Vertical; + public bool ColorModeDark { get; set; } + public bool FollowSystemTheme { get; set; } + public string? ColorPrimaryName { get; set; } + public string CurrentLanguage { get; set; } + public string CurrentFontFamily { get; set; } + public int CurrentFontSize { get; set; } + public bool EnableDragDropSort { get; set; } + public bool DoubleClick2Activate { get; set; } + public bool AutoHideStartup { get; set; } + public List MainColumnItem { get; set; } + public bool ShowInTaskbar { get; set; } } [Serializable] public class ConstItem { - public string defIEProxyExceptions { get; set; } - public string subConvertUrl { get; set; } = string.Empty; - public string? geoSourceUrl { get; set; } - public string? srsSourceUrl { get; set; } - public string? routeRulesTemplateSourceUrl { get; set; } + public string DefIEProxyExceptions { get; set; } + public string SubConvertUrl { get; set; } = string.Empty; + public string? GeoSourceUrl { get; set; } + public string? SrsSourceUrl { get; set; } + public string? RouteRulesTemplateSourceUrl { get; set; } } [Serializable] public class KeyEventItem { - public EGlobalHotkey eGlobalHotkey { get; set; } + public EGlobalHotkey EGlobalHotkey { get; set; } public bool Alt { get; set; } @@ -162,38 +147,38 @@ [Serializable] public class CoreTypeItem { - public EConfigType configType { get; set; } + public EConfigType ConfigType { get; set; } - public ECoreType coreType { get; set; } + public ECoreType CoreType { get; set; } } [Serializable] public class TunModeItem { - public bool enableTun { get; set; } - public bool strictRoute { get; set; } = true; - public string stack { get; set; } - public int mtu { get; set; } - public bool enableExInbound { get; set; } - public bool enableIPv6Address { get; set; } + public bool EnableTun { get; set; } + public bool StrictRoute { get; set; } = true; + public string Stack { get; set; } + public int Mtu { get; set; } + public bool EnableExInbound { get; set; } + public bool EnableIPv6Address { get; set; } } [Serializable] public class SpeedTestItem { - public int speedTestTimeout { get; set; } - public string speedTestUrl { get; set; } - public string speedPingTestUrl { get; set; } + public int SpeedTestTimeout { get; set; } + public string SpeedTestUrl { get; set; } + public string SpeedPingTestUrl { get; set; } } [Serializable] public class RoutingBasicItem { - public string domainStrategy { get; set; } - public string domainStrategy4Singbox { get; set; } - public string domainMatcher { get; set; } - public string routingIndexId { get; set; } - public bool enableRoutingAdvanced { get; set; } + public string DomainStrategy { get; set; } + public string DomainStrategy4Singbox { get; set; } + public string DomainMatcher { get; set; } + public string RoutingIndexId { get; set; } + public bool EnableRoutingAdvanced { get; set; } } [Serializable] @@ -207,55 +192,55 @@ [Serializable] public class Mux4RayItem { - public int? concurrency { get; set; } - public int? xudpConcurrency { get; set; } - public string? xudpProxyUDP443 { get; set; } + public int? Concurrency { get; set; } + public int? XudpConcurrency { get; set; } + public string? XudpProxyUDP443 { get; set; } } [Serializable] public class Mux4SboxItem { - public string protocol { get; set; } - public int max_connections { get; set; } - public bool? padding { get; set; } + public string Protocol { get; set; } + public int MaxConnections { get; set; } + public bool? Padding { get; set; } } [Serializable] public class HysteriaItem { - public int up_mbps { get; set; } - public int down_mbps { get; set; } + public int UpMbps { get; set; } + public int DownMbps { get; set; } } [Serializable] public class ClashUIItem { - public ERuleMode ruleMode { get; set; } - public bool enableIPv6 { get; set; } - public bool enableMixinContent { get; set; } - public int proxiesSorting { get; set; } - public bool proxiesAutoRefresh { get; set; } - public int proxiesAutoDelayTestInterval { get; set; } = 10; - public int connectionsSorting { get; set; } - public bool connectionsAutoRefresh { get; set; } - public int connectionsRefreshInterval { get; set; } = 2; + public ERuleMode RuleMode { get; set; } + public bool EnableIPv6 { get; set; } + public bool EnableMixinContent { get; set; } + public int ProxiesSorting { get; set; } + public bool ProxiesAutoRefresh { get; set; } + public int ProxiesAutoDelayTestInterval { get; set; } = 10; + public int ConnectionsSorting { get; set; } + public bool ConnectionsAutoRefresh { get; set; } + public int ConnectionsRefreshInterval { get; set; } = 2; } [Serializable] public class SystemProxyItem { - public ESysProxyType sysProxyType { get; set; } - public string systemProxyExceptions { get; set; } - public bool notProxyLocalAddress { get; set; } = true; - public string systemProxyAdvancedProtocol { get; set; } + public ESysProxyType SysProxyType { get; set; } + public string SystemProxyExceptions { get; set; } + public bool NotProxyLocalAddress { get; set; } = true; + public string SystemProxyAdvancedProtocol { get; set; } } [Serializable] public class WebDavItem { - public string? url { get; set; } - public string? userName { get; set; } - public string? password { get; set; } - public string? dirName { get; set; } + public string? Url { get; set; } + public string? UserName { get; set; } + public string? Password { get; set; } + public string? DirName { get; set; } } } \ No newline at end of file diff --git a/v2rayN/ServiceLib/Services/CoreConfig/CoreConfigClashService.cs b/v2rayN/ServiceLib/Services/CoreConfig/CoreConfigClashService.cs index 58e03603..05c42643 100644 --- a/v2rayN/ServiceLib/Services/CoreConfig/CoreConfigClashService.cs +++ b/v2rayN/ServiceLib/Services/CoreConfig/CoreConfigClashService.cs @@ -83,12 +83,12 @@ //socks-port fileContent["socks-port"] = AppHandler.Instance.GetLocalPort(EInboundProtocol.socks); //log-level - fileContent["log-level"] = GetLogLevel(_config.coreBasicItem.loglevel); + fileContent["log-level"] = GetLogLevel(_config.CoreBasicItem.Loglevel); //external-controller fileContent["external-controller"] = $"{Global.Loopback}:{AppHandler.Instance.StatePort2}"; //allow-lan - if (_config.inbound[0].allowLANConn) + if (_config.Inbound[0].AllowLANConn) { fileContent["allow-lan"] = "true"; fileContent["bind-address"] = "*"; @@ -99,7 +99,7 @@ } //ipv6 - fileContent["ipv6"] = _config.clashUIItem.enableIPv6; + fileContent["ipv6"] = _config.ClashUIItem.EnableIPv6; //mode if (!fileContent.ContainsKey("mode")) @@ -108,14 +108,14 @@ } else { - if (_config.clashUIItem.ruleMode != ERuleMode.Unchanged) + if (_config.ClashUIItem.RuleMode != ERuleMode.Unchanged) { - fileContent["mode"] = _config.clashUIItem.ruleMode.ToString().ToLower(); + fileContent["mode"] = _config.ClashUIItem.RuleMode.ToString().ToLower(); } } //enable tun mode - if (_config.tunModeItem.enableTun) + if (_config.TunModeItem.EnableTun) { string tun = Utils.GetEmbedText(Global.ClashTunYaml); if (Utils.IsNotEmpty(tun)) @@ -181,7 +181,7 @@ } foreach (var item in mixinContent) { - if (!_config.tunModeItem.enableTun && item.Key == "tun") + if (!_config.TunModeItem.EnableTun && item.Key == "tun") { continue; } diff --git a/v2rayN/ServiceLib/Services/CoreConfig/CoreConfigSingboxService.cs b/v2rayN/ServiceLib/Services/CoreConfig/CoreConfigSingboxService.cs index 93575e33..8d6d84ea 100644 --- a/v2rayN/ServiceLib/Services/CoreConfig/CoreConfigSingboxService.cs +++ b/v2rayN/ServiceLib/Services/CoreConfig/CoreConfigSingboxService.cs @@ -444,12 +444,12 @@ namespace ServiceLib.Services.CoreConfig { try { - switch (_config.coreBasicItem.loglevel) + switch (_config.CoreBasicItem.Loglevel) { case "debug": case "info": case "error": - singboxConfig.log.level = _config.coreBasicItem.loglevel; + singboxConfig.log.level = _config.CoreBasicItem.Loglevel; break; case "warning": @@ -459,11 +459,11 @@ namespace ServiceLib.Services.CoreConfig default: break; } - if (_config.coreBasicItem.loglevel == Global.None) + if (_config.CoreBasicItem.Loglevel == Global.None) { singboxConfig.log.disabled = true; } - if (_config.coreBasicItem.logEnabled) + if (_config.CoreBasicItem.LogEnabled) { var dtNow = DateTime.Now; singboxConfig.log.output = Utils.GetLogPath($"sbox_{dtNow:yyyy-MM-dd}.txt"); @@ -483,8 +483,8 @@ namespace ServiceLib.Services.CoreConfig var listen = "::"; singboxConfig.inbounds = []; - if (!_config.tunModeItem.enableTun - || _config.tunModeItem.enableTun && _config.tunModeItem.enableExInbound && _config.runningCoreType == ECoreType.sing_box) + if (!_config.TunModeItem.EnableTun + || _config.TunModeItem.EnableTun && _config.TunModeItem.EnableExInbound && _config.RunningCoreType == ECoreType.sing_box) { var inbound = new Inbound4Sbox() { @@ -495,11 +495,11 @@ namespace ServiceLib.Services.CoreConfig singboxConfig.inbounds.Add(inbound); inbound.listen_port = AppHandler.Instance.GetLocalPort(EInboundProtocol.socks); - inbound.sniff = _config.inbound[0].sniffingEnabled; - inbound.sniff_override_destination = _config.inbound[0].routeOnly ? false : _config.inbound[0].sniffingEnabled; - inbound.domain_strategy = Utils.IsNullOrEmpty(_config.routingBasicItem.domainStrategy4Singbox) ? null : _config.routingBasicItem.domainStrategy4Singbox; + inbound.sniff = _config.Inbound[0].SniffingEnabled; + inbound.sniff_override_destination = _config.Inbound[0].RouteOnly ? false : _config.Inbound[0].SniffingEnabled; + inbound.domain_strategy = Utils.IsNullOrEmpty(_config.RoutingBasicItem.DomainStrategy4Singbox) ? null : _config.RoutingBasicItem.DomainStrategy4Singbox; - if (_config.routingBasicItem.enableRoutingAdvanced) + if (_config.RoutingBasicItem.EnableRoutingAdvanced) { var routing = await ConfigHandler.GetDefaultRouting(_config); if (Utils.IsNotEmpty(routing.domainStrategy4Singbox)) @@ -512,9 +512,9 @@ namespace ServiceLib.Services.CoreConfig var inbound2 = GetInbound(inbound, EInboundProtocol.http, false); singboxConfig.inbounds.Add(inbound2); - if (_config.inbound[0].allowLANConn) + if (_config.Inbound[0].AllowLANConn) { - if (_config.inbound[0].newPort4LAN) + if (_config.Inbound[0].NewPort4LAN) { var inbound3 = GetInbound(inbound, EInboundProtocol.socks2, true); inbound3.listen = listen; @@ -525,10 +525,10 @@ namespace ServiceLib.Services.CoreConfig singboxConfig.inbounds.Add(inbound4); //auth - if (Utils.IsNotEmpty(_config.inbound[0].user) && Utils.IsNotEmpty(_config.inbound[0].pass)) + if (Utils.IsNotEmpty(_config.Inbound[0].User) && Utils.IsNotEmpty(_config.Inbound[0].Pass)) { - inbound3.users = new() { new() { username = _config.inbound[0].user, password = _config.inbound[0].pass } }; - inbound4.users = new() { new() { username = _config.inbound[0].user, password = _config.inbound[0].pass } }; + inbound3.users = new() { new() { username = _config.Inbound[0].User, password = _config.Inbound[0].Pass } }; + inbound4.users = new() { new() { username = _config.Inbound[0].User, password = _config.Inbound[0].Pass } }; } } else @@ -539,24 +539,24 @@ namespace ServiceLib.Services.CoreConfig } } - if (_config.tunModeItem.enableTun) + if (_config.TunModeItem.EnableTun) { - if (_config.tunModeItem.mtu <= 0) + if (_config.TunModeItem.Mtu <= 0) { - _config.tunModeItem.mtu = Utils.ToInt(Global.TunMtus[0]); + _config.TunModeItem.Mtu = Utils.ToInt(Global.TunMtus[0]); } - if (Utils.IsNullOrEmpty(_config.tunModeItem.stack)) + if (Utils.IsNullOrEmpty(_config.TunModeItem.Stack)) { - _config.tunModeItem.stack = Global.TunStacks[0]; + _config.TunModeItem.Stack = Global.TunStacks[0]; } var tunInbound = JsonUtils.Deserialize(Utils.GetEmbedText(Global.TunSingboxInboundFileName)) ?? new Inbound4Sbox { }; - tunInbound.mtu = _config.tunModeItem.mtu; - tunInbound.strict_route = _config.tunModeItem.strictRoute; - tunInbound.stack = _config.tunModeItem.stack; - tunInbound.sniff = _config.inbound[0].sniffingEnabled; + tunInbound.mtu = _config.TunModeItem.Mtu; + tunInbound.strict_route = _config.TunModeItem.StrictRoute; + tunInbound.stack = _config.TunModeItem.Stack; + tunInbound.sniff = _config.Inbound[0].SniffingEnabled; //tunInbound.sniff_override_destination = _config.inbound[0].routeOnly ? false : _config.inbound[0].sniffingEnabled; - if (_config.tunModeItem.enableIPv6Address == false) + if (_config.TunModeItem.EnableIPv6Address == false) { tunInbound.inet6_address = null; } @@ -671,8 +671,8 @@ namespace ServiceLib.Services.CoreConfig }; } - outbound.up_mbps = _config.hysteriaItem.up_mbps > 0 ? _config.hysteriaItem.up_mbps : null; - outbound.down_mbps = _config.hysteriaItem.down_mbps > 0 ? _config.hysteriaItem.down_mbps : null; + outbound.up_mbps = _config.HysteriaItem.UpMbps > 0 ? _config.HysteriaItem.UpMbps : null; + outbound.down_mbps = _config.HysteriaItem.DownMbps > 0 ? _config.HysteriaItem.DownMbps : null; break; } case EConfigType.TUIC: @@ -708,14 +708,14 @@ namespace ServiceLib.Services.CoreConfig { try { - if (_config.coreBasicItem.muxEnabled && Utils.IsNotEmpty(_config.mux4SboxItem.protocol)) + if (_config.CoreBasicItem.MuxEnabled && Utils.IsNotEmpty(_config.Mux4SboxItem.Protocol)) { var mux = new Multiplex4Sbox() { enabled = true, - protocol = _config.mux4SboxItem.protocol, - max_connections = _config.mux4SboxItem.max_connections, - padding = _config.mux4SboxItem.padding, + protocol = _config.Mux4SboxItem.Protocol, + max_connections = _config.Mux4SboxItem.MaxConnections, + padding = _config.Mux4SboxItem.Padding, }; outbound.multiplex = mux; } @@ -746,7 +746,7 @@ namespace ServiceLib.Services.CoreConfig { enabled = true, server_name = server_name, - insecure = Utils.ToBool(node.allowInsecure.IsNullOrEmpty() ? _config.coreBasicItem.defAllowInsecure.ToString().ToLower() : node.allowInsecure), + insecure = Utils.ToBool(node.allowInsecure.IsNullOrEmpty() ? _config.CoreBasicItem.DefAllowInsecure.ToString().ToLower() : node.allowInsecure), alpn = node.GetAlpn(), }; if (Utils.IsNotEmpty(node.fingerprint)) @@ -754,7 +754,7 @@ namespace ServiceLib.Services.CoreConfig tls.utls = new Utls4Sbox() { enabled = true, - fingerprint = node.fingerprint.IsNullOrEmpty() ? _config.coreBasicItem.defFingerprint : node.fingerprint + fingerprint = node.fingerprint.IsNullOrEmpty() ? _config.CoreBasicItem.DefFingerprint : node.fingerprint }; } if (node.streamSecurity == Global.StreamSecurityReality) @@ -834,9 +834,9 @@ namespace ServiceLib.Services.CoreConfig case nameof(ETransport.grpc): transport.type = nameof(ETransport.grpc); transport.service_name = node.path; - transport.idle_timeout = _config.grpcItem.idle_timeout.ToString("##s"); - transport.ping_timeout = _config.grpcItem.health_check_timeout.ToString("##s"); - transport.permit_without_stream = _config.grpcItem.permit_without_stream; + transport.idle_timeout = _config.GrpcItem.IdleTimeout.ToString("##s"); + transport.ping_timeout = _config.GrpcItem.HealthCheckTimeout.ToString("##s"); + transport.permit_without_stream = _config.GrpcItem.PermitWithoutStream; break; default: @@ -912,7 +912,7 @@ namespace ServiceLib.Services.CoreConfig try { var dnsOutbound = "dns_out"; - if (!_config.inbound[0].sniffingEnabled) + if (!_config.Inbound[0].SniffingEnabled) { singboxConfig.route.rules.Add(new() { @@ -933,7 +933,7 @@ namespace ServiceLib.Services.CoreConfig clash_mode = ERuleMode.Global.ToString() }); - if (_config.tunModeItem.enableTun) + if (_config.TunModeItem.EnableTun) { singboxConfig.route.auto_detect_interface = true; @@ -958,7 +958,7 @@ namespace ServiceLib.Services.CoreConfig }); } - if (_config.routingBasicItem.enableRoutingAdvanced) + if (_config.RoutingBasicItem.EnableRoutingAdvanced) { var routing = await ConfigHandler.GetDefaultRouting(_config); if (routing != null) @@ -1089,7 +1089,7 @@ namespace ServiceLib.Services.CoreConfig } } - if (_config.tunModeItem.enableTun && item.process?.Count > 0) + if (_config.TunModeItem.EnableTun && item.process?.Count > 0) { rule3.process_name = item.process; rules.Add(rule3); @@ -1183,7 +1183,7 @@ namespace ServiceLib.Services.CoreConfig { var item = await AppHandler.Instance.GetDNSItem(ECoreType.sing_box); var strDNS = string.Empty; - if (_config.tunModeItem.enableTun) + if (_config.TunModeItem.EnableTun) { strDNS = Utils.IsNullOrEmpty(item?.tunDNS) ? Utils.GetEmbedText(Global.TunSingboxDNSFileName) : item?.tunDNS; } @@ -1248,7 +1248,7 @@ namespace ServiceLib.Services.CoreConfig } //Tun2SocksAddress - if (_config.tunModeItem.enableTun && node?.configType == EConfigType.SOCKS && Utils.IsDomain(node?.sni)) + if (_config.TunModeItem.EnableTun && node?.configType == EConfigType.SOCKS && Utils.IsDomain(node?.sni)) { dns4Sbox.rules.Insert(0, new() { @@ -1272,7 +1272,7 @@ namespace ServiceLib.Services.CoreConfig }; } - if (_config.coreBasicItem.enableCacheFile4Sbox) + if (_config.CoreBasicItem.EnableCacheFile4Sbox) { singboxConfig.experimental ??= new Experimental4Sbox(); singboxConfig.experimental.cache_file = new CacheFile4Sbox() @@ -1334,7 +1334,7 @@ namespace ServiceLib.Services.CoreConfig //load custom ruleset file List customRulesets = []; - if (_config.routingBasicItem.enableRoutingAdvanced) + if (_config.RoutingBasicItem.EnableRoutingAdvanced) { var routing = await ConfigHandler.GetDefaultRouting(_config); if (Utils.IsNotEmpty(routing.customRulesetPath4Singbox)) @@ -1375,9 +1375,9 @@ namespace ServiceLib.Services.CoreConfig } else { - var srsUrl = string.IsNullOrEmpty(_config.constItem.srsSourceUrl) + var srsUrl = string.IsNullOrEmpty(_config.ConstItem.SrsSourceUrl) ? Global.SingboxRulesetUrl - : _config.constItem.srsSourceUrl; + : _config.ConstItem.SrsSourceUrl; customRuleset = new() { diff --git a/v2rayN/ServiceLib/Services/CoreConfig/CoreConfigV2rayService.cs b/v2rayN/ServiceLib/Services/CoreConfig/CoreConfigV2rayService.cs index 9b7cf9c7..97919ba3 100644 --- a/v2rayN/ServiceLib/Services/CoreConfig/CoreConfigV2rayService.cs +++ b/v2rayN/ServiceLib/Services/CoreConfig/CoreConfigV2rayService.cs @@ -356,16 +356,16 @@ namespace ServiceLib.Services.CoreConfig { try { - if (_config.coreBasicItem.logEnabled) + if (_config.CoreBasicItem.LogEnabled) { var dtNow = DateTime.Now; - v2rayConfig.log.loglevel = _config.coreBasicItem.loglevel; + v2rayConfig.log.loglevel = _config.CoreBasicItem.Loglevel; v2rayConfig.log.access = Utils.GetLogPath($"Vaccess_{dtNow:yyyy-MM-dd}.txt"); v2rayConfig.log.error = Utils.GetLogPath($"Verror_{dtNow:yyyy-MM-dd}.txt"); } else { - v2rayConfig.log.loglevel = _config.coreBasicItem.loglevel; + v2rayConfig.log.loglevel = _config.CoreBasicItem.Loglevel; v2rayConfig.log.access = ""; v2rayConfig.log.error = ""; } @@ -384,33 +384,33 @@ namespace ServiceLib.Services.CoreConfig var listen = "0.0.0.0"; v2rayConfig.inbounds = []; - Inbounds4Ray? inbound = GetInbound(_config.inbound[0], EInboundProtocol.socks, true); + Inbounds4Ray? inbound = GetInbound(_config.Inbound[0], EInboundProtocol.socks, true); v2rayConfig.inbounds.Add(inbound); //http - Inbounds4Ray? inbound2 = GetInbound(_config.inbound[0], EInboundProtocol.http, false); + Inbounds4Ray? inbound2 = GetInbound(_config.Inbound[0], EInboundProtocol.http, false); v2rayConfig.inbounds.Add(inbound2); - if (_config.inbound[0].allowLANConn) + if (_config.Inbound[0].AllowLANConn) { - if (_config.inbound[0].newPort4LAN) + if (_config.Inbound[0].NewPort4LAN) { - var inbound3 = GetInbound(_config.inbound[0], EInboundProtocol.socks2, true); + var inbound3 = GetInbound(_config.Inbound[0], EInboundProtocol.socks2, true); inbound3.listen = listen; v2rayConfig.inbounds.Add(inbound3); - var inbound4 = GetInbound(_config.inbound[0], EInboundProtocol.http2, false); + var inbound4 = GetInbound(_config.Inbound[0], EInboundProtocol.http2, false); inbound4.listen = listen; v2rayConfig.inbounds.Add(inbound4); //auth - if (Utils.IsNotEmpty(_config.inbound[0].user) && Utils.IsNotEmpty(_config.inbound[0].pass)) + if (Utils.IsNotEmpty(_config.Inbound[0].User) && Utils.IsNotEmpty(_config.Inbound[0].Pass)) { inbound3.settings.auth = "password"; - inbound3.settings.accounts = new List { new AccountsItem4Ray() { user = _config.inbound[0].user, pass = _config.inbound[0].pass } }; + inbound3.settings.accounts = new List { new AccountsItem4Ray() { user = _config.Inbound[0].User, pass = _config.Inbound[0].Pass } }; inbound4.settings.auth = "password"; - inbound4.settings.accounts = new List { new AccountsItem4Ray() { user = _config.inbound[0].user, pass = _config.inbound[0].pass } }; + inbound4.settings.accounts = new List { new AccountsItem4Ray() { user = _config.Inbound[0].User, pass = _config.Inbound[0].Pass } }; } } else @@ -441,12 +441,12 @@ namespace ServiceLib.Services.CoreConfig return new(); } inbound.tag = protocol.ToString(); - inbound.port = inItem.localPort + (int)protocol; + inbound.port = inItem.LocalPort + (int)protocol; inbound.protocol = bSocks ? EInboundProtocol.socks.ToString() : EInboundProtocol.http.ToString(); - inbound.settings.udp = inItem.udpEnabled; - inbound.sniffing.enabled = inItem.sniffingEnabled; - inbound.sniffing.destOverride = inItem.destOverride; - inbound.sniffing.routeOnly = inItem.routeOnly; + inbound.settings.udp = inItem.UdpEnabled; + inbound.sniffing.enabled = inItem.SniffingEnabled; + inbound.sniffing.destOverride = inItem.DestOverride; + inbound.sniffing.routeOnly = inItem.RouteOnly; return inbound; } @@ -457,10 +457,10 @@ namespace ServiceLib.Services.CoreConfig { if (v2rayConfig.routing?.rules != null) { - v2rayConfig.routing.domainStrategy = _config.routingBasicItem.domainStrategy; - v2rayConfig.routing.domainMatcher = Utils.IsNullOrEmpty(_config.routingBasicItem.domainMatcher) ? null : _config.routingBasicItem.domainMatcher; + v2rayConfig.routing.domainStrategy = _config.RoutingBasicItem.DomainStrategy; + v2rayConfig.routing.domainMatcher = Utils.IsNullOrEmpty(_config.RoutingBasicItem.DomainMatcher) ? null : _config.RoutingBasicItem.DomainMatcher; - if (_config.routingBasicItem.enableRoutingAdvanced) + if (_config.RoutingBasicItem.EnableRoutingAdvanced) { var routing = await ConfigHandler.GetDefaultRouting(_config); if (routing != null) @@ -624,7 +624,7 @@ namespace ServiceLib.Services.CoreConfig usersItem.security = Global.DefaultSecurity; } - await GenOutboundMux(node, outbound, _config.coreBasicItem.muxEnabled); + await GenOutboundMux(node, outbound, _config.CoreBasicItem.MuxEnabled); outbound.settings.servers = null; break; @@ -719,7 +719,7 @@ namespace ServiceLib.Services.CoreConfig usersItem.email = Global.UserEMail; usersItem.encryption = node.security; - await GenOutboundMux(node, outbound, _config.coreBasicItem.muxEnabled); + await GenOutboundMux(node, outbound, _config.CoreBasicItem.MuxEnabled); if (node.streamSecurity == Global.StreamSecurityReality || node.streamSecurity == Global.StreamSecurity) @@ -733,7 +733,7 @@ namespace ServiceLib.Services.CoreConfig } if (node.streamSecurity == Global.StreamSecurityReality && Utils.IsNullOrEmpty(node.flow)) { - await GenOutboundMux(node, outbound, _config.coreBasicItem.muxEnabled); + await GenOutboundMux(node, outbound, _config.CoreBasicItem.MuxEnabled); } outbound.settings.servers = null; @@ -782,9 +782,9 @@ namespace ServiceLib.Services.CoreConfig if (enabled) { outbound.mux.enabled = true; - outbound.mux.concurrency = _config.mux4RayItem.concurrency; - outbound.mux.xudpConcurrency = _config.mux4RayItem.xudpConcurrency; - outbound.mux.xudpProxyUDP443 = _config.mux4RayItem.xudpProxyUDP443; + outbound.mux.concurrency = _config.Mux4RayItem.Concurrency; + outbound.mux.xudpConcurrency = _config.Mux4RayItem.XudpConcurrency; + outbound.mux.xudpProxyUDP443 = _config.Mux4RayItem.XudpProxyUDP443; } else { @@ -807,15 +807,15 @@ namespace ServiceLib.Services.CoreConfig string host = node.requestHost.TrimEx(); string sni = node.sni; string useragent = ""; - if (!_config.coreBasicItem.defUserAgent.IsNullOrEmpty()) + if (!_config.CoreBasicItem.DefUserAgent.IsNullOrEmpty()) { try { - useragent = Global.UserAgentTexts[_config.coreBasicItem.defUserAgent]; + useragent = Global.UserAgentTexts[_config.CoreBasicItem.DefUserAgent]; } catch (KeyNotFoundException) { - useragent = _config.coreBasicItem.defUserAgent; + useragent = _config.CoreBasicItem.DefUserAgent; } } @@ -826,9 +826,9 @@ namespace ServiceLib.Services.CoreConfig TlsSettings4Ray tlsSettings = new() { - allowInsecure = Utils.ToBool(node.allowInsecure.IsNullOrEmpty() ? _config.coreBasicItem.defAllowInsecure.ToString().ToLower() : node.allowInsecure), + allowInsecure = Utils.ToBool(node.allowInsecure.IsNullOrEmpty() ? _config.CoreBasicItem.DefAllowInsecure.ToString().ToLower() : node.allowInsecure), alpn = node.GetAlpn(), - fingerprint = node.fingerprint.IsNullOrEmpty() ? _config.coreBasicItem.defFingerprint : node.fingerprint + fingerprint = node.fingerprint.IsNullOrEmpty() ? _config.CoreBasicItem.DefFingerprint : node.fingerprint }; if (Utils.IsNotEmpty(sni)) { @@ -848,7 +848,7 @@ namespace ServiceLib.Services.CoreConfig TlsSettings4Ray realitySettings = new() { - fingerprint = node.fingerprint.IsNullOrEmpty() ? _config.coreBasicItem.defFingerprint : node.fingerprint, + fingerprint = node.fingerprint.IsNullOrEmpty() ? _config.CoreBasicItem.DefFingerprint : node.fingerprint, serverName = sni, publicKey = node.publicKey, shortId = node.shortId, @@ -865,16 +865,16 @@ namespace ServiceLib.Services.CoreConfig case nameof(ETransport.kcp): KcpSettings4Ray kcpSettings = new() { - mtu = _config.kcpItem.mtu, - tti = _config.kcpItem.tti + mtu = _config.KcpItem.Mtu, + tti = _config.KcpItem.Tti }; - kcpSettings.uplinkCapacity = _config.kcpItem.uplinkCapacity; - kcpSettings.downlinkCapacity = _config.kcpItem.downlinkCapacity; + kcpSettings.uplinkCapacity = _config.KcpItem.UplinkCapacity; + kcpSettings.downlinkCapacity = _config.KcpItem.DownlinkCapacity; - kcpSettings.congestion = _config.kcpItem.congestion; - kcpSettings.readBufferSize = _config.kcpItem.readBufferSize; - kcpSettings.writeBufferSize = _config.kcpItem.writeBufferSize; + kcpSettings.congestion = _config.KcpItem.Congestion; + kcpSettings.readBufferSize = _config.KcpItem.ReadBufferSize; + kcpSettings.writeBufferSize = _config.KcpItem.WriteBufferSize; kcpSettings.header = new Header4Ray { type = node.headerType @@ -983,10 +983,10 @@ namespace ServiceLib.Services.CoreConfig authority = Utils.IsNullOrEmpty(host) ? null : host, serviceName = node.path, multiMode = node.headerType == Global.GrpcMultiMode, - idle_timeout = _config.grpcItem.idle_timeout, - health_check_timeout = _config.grpcItem.health_check_timeout, - permit_without_stream = _config.grpcItem.permit_without_stream, - initial_windows_size = _config.grpcItem.initial_windows_size, + idle_timeout = _config.GrpcItem.IdleTimeout, + health_check_timeout = _config.GrpcItem.HealthCheckTimeout, + permit_without_stream = _config.GrpcItem.PermitWithoutStream, + initial_windows_size = _config.GrpcItem.InitialWindowsSize, }; streamSettings.grpcSettings = grpcSettings; break; @@ -1117,7 +1117,7 @@ namespace ServiceLib.Services.CoreConfig public async Task GenStatistic(V2rayConfig v2rayConfig) { - if (_config.guiItem.enableStatistics) + if (_config.GuiItem.EnableStatistics) { string tag = EInboundProtocol.api.ToString(); API4Ray apiObj = new(); @@ -1168,7 +1168,7 @@ namespace ServiceLib.Services.CoreConfig private async Task GenMoreOutbounds(ProfileItem node, V2rayConfig v2rayConfig) { //fragment proxy - if (_config.coreBasicItem.enableFragment + if (_config.CoreBasicItem.EnableFragment && Utils.IsNotEmpty(v2rayConfig.outbounds[0].streamSettings?.security)) { var fragmentOutbound = new Outbounds4Ray diff --git a/v2rayN/ServiceLib/Services/DownloadService.cs b/v2rayN/ServiceLib/Services/DownloadService.cs index 88b01772..d27732b5 100644 --- a/v2rayN/ServiceLib/Services/DownloadService.cs +++ b/v2rayN/ServiceLib/Services/DownloadService.cs @@ -18,7 +18,7 @@ namespace ServiceLib.Services { try { - SetSecurityProtocol(AppHandler.Instance.Config.guiItem.enableSecurityProtocolTls13); + SetSecurityProtocol(AppHandler.Instance.Config.GuiItem.EnableSecurityProtocolTls13); var progress = new Progress(); progress.ProgressChanged += (sender, value) => @@ -50,7 +50,7 @@ namespace ServiceLib.Services { try { - SetSecurityProtocol(AppHandler.Instance.Config.guiItem.enableSecurityProtocolTls13); + SetSecurityProtocol(AppHandler.Instance.Config.GuiItem.EnableSecurityProtocolTls13); UpdateCompleted?.Invoke(this, new RetResult(false, $"{ResUI.Downloading} {url}")); var progress = new Progress(); @@ -80,7 +80,7 @@ namespace ServiceLib.Services public async Task UrlRedirectAsync(string url, bool blProxy) { - SetSecurityProtocol(AppHandler.Instance.Config.guiItem.enableSecurityProtocolTls13); + SetSecurityProtocol(AppHandler.Instance.Config.GuiItem.EnableSecurityProtocolTls13); var webRequestHandler = new SocketsHttpHandler { AllowAutoRedirect = false, @@ -150,7 +150,7 @@ namespace ServiceLib.Services { try { - SetSecurityProtocol(AppHandler.Instance.Config.guiItem.enableSecurityProtocolTls13); + SetSecurityProtocol(AppHandler.Instance.Config.GuiItem.EnableSecurityProtocolTls13); var webProxy = await GetWebProxy(blProxy); var client = new HttpClient(new SocketsHttpHandler() { @@ -195,7 +195,7 @@ namespace ServiceLib.Services { try { - SetSecurityProtocol(AppHandler.Instance.Config.guiItem.enableSecurityProtocolTls13); + SetSecurityProtocol(AppHandler.Instance.Config.GuiItem.EnableSecurityProtocolTls13); var webProxy = await GetWebProxy(blProxy); @@ -227,7 +227,7 @@ namespace ServiceLib.Services try { var config = AppHandler.Instance.Config; - var responseTime = await GetRealPingTime(config.speedTestItem.speedPingTestUrl, webProxy, 10); + var responseTime = await GetRealPingTime(config.SpeedTestItem.SpeedPingTestUrl, webProxy, 10); return responseTime; } catch (Exception ex) diff --git a/v2rayN/ServiceLib/Services/SpeedtestService.cs b/v2rayN/ServiceLib/Services/SpeedtestService.cs index 7132a600..a821e86d 100644 --- a/v2rayN/ServiceLib/Services/SpeedtestService.cs +++ b/v2rayN/ServiceLib/Services/SpeedtestService.cs @@ -203,8 +203,8 @@ namespace ServiceLib.Services return; } - string url = _config.speedTestItem.speedTestUrl; - var timeout = _config.speedTestItem.speedTestTimeout; + string url = _config.SpeedTestItem.SpeedTestUrl; + var timeout = _config.SpeedTestItem.SpeedTestTimeout; DownloadService downloadHandle = new(); @@ -265,8 +265,8 @@ namespace ServiceLib.Services return; } - string url = _config.speedTestItem.speedTestUrl; - var timeout = _config.speedTestItem.speedTestTimeout; + string url = _config.SpeedTestItem.SpeedTestUrl; + var timeout = _config.SpeedTestItem.SpeedTestTimeout; DownloadService downloadHandle = new(); @@ -331,7 +331,7 @@ namespace ServiceLib.Services private async Task GetRealPingTime(DownloadService downloadHandle, IWebProxy webProxy) { - int responseTime = await downloadHandle.GetRealPingTime(_config.speedTestItem.speedPingTestUrl, webProxy, 10); + int responseTime = await downloadHandle.GetRealPingTime(_config.SpeedTestItem.SpeedPingTestUrl, webProxy, 10); //string output = Utile.IsNullOrEmpty(status) ? FormatOut(responseTime, "ms") : status; return FormatOut(responseTime, Global.DelayUnit); } diff --git a/v2rayN/ServiceLib/Services/UpdateService.cs b/v2rayN/ServiceLib/Services/UpdateService.cs index d93407a2..c939ecd2 100644 --- a/v2rayN/ServiceLib/Services/UpdateService.cs +++ b/v2rayN/ServiceLib/Services/UpdateService.cs @@ -154,7 +154,7 @@ namespace ServiceLib.Services //convert if (Utils.IsNotEmpty(item.convertTarget)) { - var subConvertUrl = Utils.IsNullOrEmpty(config.constItem.subConvertUrl) ? Global.SubConvertUrls.FirstOrDefault() : config.constItem.subConvertUrl; + var subConvertUrl = Utils.IsNullOrEmpty(config.ConstItem.SubConvertUrl) ? Global.SubConvertUrls.FirstOrDefault() : config.ConstItem.SubConvertUrl; url = string.Format(subConvertUrl!, Utils.UrlEncode(url)); if (!url.Contains("target=")) { @@ -457,9 +457,9 @@ namespace ServiceLib.Services _config = config; _updateFunc = updateFunc; - var geoUrl = string.IsNullOrEmpty(config?.constItem.geoSourceUrl) + var geoUrl = string.IsNullOrEmpty(config?.ConstItem.GeoSourceUrl) ? Global.GeoUrl - : config.constItem.geoSourceUrl; + : config.ConstItem.GeoSourceUrl; var fileName = $"{geoName}.dat"; var targetPath = Utils.GetBinPath($"{fileName}"); @@ -521,9 +521,9 @@ namespace ServiceLib.Services private async Task UpdateSrsFile(string type, string srsName, Config config, Action updateFunc) { - var srsUrl = string.IsNullOrEmpty(_config.constItem.srsSourceUrl) + var srsUrl = string.IsNullOrEmpty(_config.ConstItem.SrsSourceUrl) ? Global.SingboxRulesetUrl - : _config.constItem.srsSourceUrl; + : _config.ConstItem.SrsSourceUrl; var fileName = $"{type}-{srsName}.srs"; var targetPath = Path.Combine(Utils.GetBinPath("srss"), fileName); diff --git a/v2rayN/ServiceLib/ViewModels/BackupAndRestoreViewModel.cs b/v2rayN/ServiceLib/ViewModels/BackupAndRestoreViewModel.cs index ddb808c6..35c3d60d 100644 --- a/v2rayN/ServiceLib/ViewModels/BackupAndRestoreViewModel.cs +++ b/v2rayN/ServiceLib/ViewModels/BackupAndRestoreViewModel.cs @@ -38,7 +38,7 @@ namespace ServiceLib.ViewModels await RemoteRestore(); }); - SelectedSource = JsonUtils.DeepCopy(_config.webDavItem); + SelectedSource = JsonUtils.DeepCopy(_config.WebDavItem); } private void DisplayOperationMsg(string msg = "") @@ -49,7 +49,7 @@ namespace ServiceLib.ViewModels private async Task WebDavCheck() { DisplayOperationMsg(); - _config.webDavItem = SelectedSource; + _config.WebDavItem = SelectedSource; await ConfigHandler.SaveConfig(_config); var result = await WebDavHandler.Instance.CheckConnection(); diff --git a/v2rayN/ServiceLib/ViewModels/CheckUpdateViewModel.cs b/v2rayN/ServiceLib/ViewModels/CheckUpdateViewModel.cs index e7fe3195..5ca1d2ff 100644 --- a/v2rayN/ServiceLib/ViewModels/CheckUpdateViewModel.cs +++ b/v2rayN/ServiceLib/ViewModels/CheckUpdateViewModel.cs @@ -28,12 +28,12 @@ namespace ServiceLib.ViewModels await CheckUpdate(); }); - EnableCheckPreReleaseUpdate = _config.guiItem.checkPreReleaseUpdate; + EnableCheckPreReleaseUpdate = _config.GuiItem.CheckPreReleaseUpdate; this.WhenAnyValue( x => x.EnableCheckPreReleaseUpdate, y => y == true) - .Subscribe(c => { _config.guiItem.checkPreReleaseUpdate = EnableCheckPreReleaseUpdate; }); + .Subscribe(c => { _config.GuiItem.CheckPreReleaseUpdate = EnableCheckPreReleaseUpdate; }); RefreshSubItems(); } @@ -263,7 +263,7 @@ namespace ServiceLib.ViewModels } else { - FileManager.ZipExtractToFile(fileName, toPath, _config.guiItem.ignoreGeoUpdateCore ? "geo" : ""); + FileManager.ZipExtractToFile(fileName, toPath, _config.GuiItem.IgnoreGeoUpdateCore ? "geo" : ""); } if (Utils.IsLinux()) diff --git a/v2rayN/ServiceLib/ViewModels/ClashConnectionsViewModel.cs b/v2rayN/ServiceLib/ViewModels/ClashConnectionsViewModel.cs index 14f91385..14025b43 100644 --- a/v2rayN/ServiceLib/ViewModels/ClashConnectionsViewModel.cs +++ b/v2rayN/ServiceLib/ViewModels/ClashConnectionsViewModel.cs @@ -31,8 +31,8 @@ namespace ServiceLib.ViewModels { _config = AppHandler.Instance.Config; _updateView = updateView; - SortingSelected = _config.clashUIItem.connectionsSorting; - AutoRefresh = _config.clashUIItem.connectionsAutoRefresh; + SortingSelected = _config.ClashUIItem.ConnectionsSorting; + AutoRefresh = _config.ClashUIItem.ConnectionsAutoRefresh; var canEditRemove = this.WhenAnyValue( x => x.SelectedSource, @@ -46,7 +46,7 @@ namespace ServiceLib.ViewModels this.WhenAnyValue( x => x.AutoRefresh, y => y == true) - .Subscribe(c => { _config.clashUIItem.connectionsAutoRefresh = AutoRefresh; }); + .Subscribe(c => { _config.ClashUIItem.ConnectionsAutoRefresh = AutoRefresh; }); ConnectionCloseCmd = ReactiveCommand.CreateFromTask(async () => { await ClashConnectionClose(false); @@ -67,14 +67,14 @@ namespace ServiceLib.ViewModels Observable.Interval(TimeSpan.FromSeconds(5)) .Subscribe(async x => { - if (!(AutoRefresh && _config.uiItem.showInTaskbar && _config.IsRunningCore(ECoreType.sing_box))) + if (!(AutoRefresh && _config.UiItem.ShowInTaskbar && _config.IsRunningCore(ECoreType.sing_box))) { return; } var dtNow = DateTime.Now; - if (_config.clashUIItem.connectionsRefreshInterval > 0) + if (_config.ClashUIItem.ConnectionsRefreshInterval > 0) { - if ((dtNow - lastTime).Minutes % _config.clashUIItem.connectionsRefreshInterval == 0) + if ((dtNow - lastTime).Minutes % _config.ClashUIItem.ConnectionsRefreshInterval == 0) { await GetClashConnections(); lastTime = dtNow; @@ -90,9 +90,9 @@ namespace ServiceLib.ViewModels { return; } - if (SortingSelected != _config.clashUIItem.connectionsSorting) + if (SortingSelected != _config.ClashUIItem.ConnectionsSorting) { - _config.clashUIItem.connectionsSorting = SortingSelected; + _config.ClashUIItem.ConnectionsSorting = SortingSelected; } await GetClashConnections(); diff --git a/v2rayN/ServiceLib/ViewModels/ClashProxiesViewModel.cs b/v2rayN/ServiceLib/ViewModels/ClashProxiesViewModel.cs index 5fea4792..c6a35138 100644 --- a/v2rayN/ServiceLib/ViewModels/ClashProxiesViewModel.cs +++ b/v2rayN/ServiceLib/ViewModels/ClashProxiesViewModel.cs @@ -66,9 +66,9 @@ namespace ServiceLib.ViewModels SelectedGroup = new(); SelectedDetail = new(); - AutoRefresh = _config.clashUIItem.proxiesAutoRefresh; - SortingSelected = _config.clashUIItem.proxiesSorting; - RuleModeSelected = (int)_config.clashUIItem.ruleMode; + AutoRefresh = _config.ClashUIItem.ProxiesAutoRefresh; + SortingSelected = _config.ClashUIItem.ProxiesSorting; + RuleModeSelected = (int)_config.ClashUIItem.RuleMode; this.WhenAnyValue( x => x.SelectedGroup, @@ -88,7 +88,7 @@ namespace ServiceLib.ViewModels this.WhenAnyValue( x => x.AutoRefresh, y => y == true) - .Subscribe(c => { _config.clashUIItem.proxiesAutoRefresh = AutoRefresh; }); + .Subscribe(c => { _config.ClashUIItem.ProxiesAutoRefresh = AutoRefresh; }); Init(); } @@ -105,7 +105,7 @@ namespace ServiceLib.ViewModels { return; } - if (_config.clashUIItem.ruleMode == (ERuleMode)RuleModeSelected) + if (_config.ClashUIItem.RuleMode == (ERuleMode)RuleModeSelected) { return; } @@ -114,7 +114,7 @@ namespace ServiceLib.ViewModels public async Task SetRuleModeCheck(ERuleMode mode) { - if (_config.clashUIItem.ruleMode == mode) + if (_config.ClashUIItem.RuleMode == mode) { return; } @@ -127,9 +127,9 @@ namespace ServiceLib.ViewModels { return; } - if (SortingSelected != _config.clashUIItem.proxiesSorting) + if (SortingSelected != _config.ClashUIItem.ProxiesSorting) { - _config.clashUIItem.proxiesSorting = SortingSelected; + _config.ClashUIItem.ProxiesSorting = SortingSelected; } RefreshProxyDetails(c); @@ -155,7 +155,7 @@ namespace ServiceLib.ViewModels private async Task SetRuleMode(ERuleMode mode) { - _config.clashUIItem.ruleMode = mode; + _config.ClashUIItem.RuleMode = mode; if (mode != ERuleMode.Unchanged) { @@ -438,14 +438,14 @@ namespace ServiceLib.ViewModels Observable.Interval(TimeSpan.FromSeconds(60)) .Subscribe(async x => { - if (!(AutoRefresh && _config.uiItem.showInTaskbar && _config.IsRunningCore(ECoreType.sing_box))) + if (!(AutoRefresh && _config.UiItem.ShowInTaskbar && _config.IsRunningCore(ECoreType.sing_box))) { return; } var dtNow = DateTime.Now; - if (_config.clashUIItem.proxiesAutoDelayTestInterval > 0) + if (_config.ClashUIItem.ProxiesAutoDelayTestInterval > 0) { - if ((dtNow - lastTime).Minutes % _config.clashUIItem.proxiesAutoDelayTestInterval == 0) + if ((dtNow - lastTime).Minutes % _config.ClashUIItem.ProxiesAutoDelayTestInterval == 0) { await ProxiesDelayTest(); lastTime = dtNow; diff --git a/v2rayN/ServiceLib/ViewModels/MainWindowViewModel.cs b/v2rayN/ServiceLib/ViewModels/MainWindowViewModel.cs index 1844516e..a343b44d 100644 --- a/v2rayN/ServiceLib/ViewModels/MainWindowViewModel.cs +++ b/v2rayN/ServiceLib/ViewModels/MainWindowViewModel.cs @@ -142,11 +142,11 @@ namespace ServiceLib.ViewModels }); SubGroupUpdateCmd = ReactiveCommand.CreateFromTask(async () => { - await UpdateSubscriptionProcess(_config.subIndexId, false); + await UpdateSubscriptionProcess(_config.SubIndexId, false); }); SubGroupUpdateViaProxyCmd = ReactiveCommand.CreateFromTask(async () => { - await UpdateSubscriptionProcess(_config.subIndexId, true); + await UpdateSubscriptionProcess(_config.SubIndexId, true); }); //Setting @@ -204,14 +204,14 @@ namespace ServiceLib.ViewModels private async Task Init() { - _config.uiItem.showInTaskbar = true; + _config.UiItem.ShowInTaskbar = true; await ConfigHandler.InitBuiltinRouting(_config); await ConfigHandler.InitBuiltinDNS(_config); CoreHandler.Instance.Init(_config, UpdateHandler); TaskHandler.Instance.RegUpdateTask(_config, UpdateTaskHandler); - if (_config.guiItem.enableStatistics) + if (_config.GuiItem.EnableStatistics) { await StatisticsHandler.Instance.Init(_config, UpdateStatisticsHandler); } @@ -238,13 +238,13 @@ namespace ServiceLib.ViewModels NoticeHandler.Instance.SendMessageEx(msg); if (success) { - var indexIdOld = _config.indexId; + var indexIdOld = _config.IndexId; RefreshServers(); - if (indexIdOld != _config.indexId) + if (indexIdOld != _config.IndexId) { Reload(); } - if (_config.uiItem.enableAutoAdjustMainLvColWidth) + if (_config.UiItem.EnableAutoAdjustMainLvColWidth) { _updateView?.Invoke(EViewAction.AdjustMainLvColWidth, null); } @@ -253,7 +253,7 @@ namespace ServiceLib.ViewModels private void UpdateStatisticsHandler(ServerSpeedItem update) { - if (!_config.uiItem.showInTaskbar) + if (!_config.UiItem.ShowInTaskbar) { return; } @@ -351,7 +351,7 @@ namespace ServiceLib.ViewModels { ProfileItem item = new() { - subid = _config.subIndexId, + subid = _config.SubIndexId, configType = eConfigType, isSub = false, }; @@ -368,7 +368,7 @@ namespace ServiceLib.ViewModels if (ret == true) { RefreshServers(); - if (item.indexId == _config.indexId) + if (item.indexId == _config.IndexId) { await Reload(); } @@ -382,7 +382,7 @@ namespace ServiceLib.ViewModels await _updateView?.Invoke(EViewAction.AddServerViaClipboard, null); return; } - int ret = await ConfigHandler.AddBatchServers(_config, clipboardData, _config.subIndexId, false); + int ret = await ConfigHandler.AddBatchServers(_config, clipboardData, _config.SubIndexId, false); if (ret > 0) { RefreshSubscriptions(); @@ -426,7 +426,7 @@ namespace ServiceLib.ViewModels } else { - int ret = await ConfigHandler.AddBatchServers(_config, result, _config.subIndexId, false); + int ret = await ConfigHandler.AddBatchServers(_config, result, _config.SubIndexId, false); if (ret > 0) { RefreshSubscriptions(); @@ -572,7 +572,7 @@ namespace ServiceLib.ViewModels private async Task AutoHideStartup() { - if (_config.uiItem.autoHideStartup) + if (_config.UiItem.AutoHideStartup) { ShowHideWindow(false); } diff --git a/v2rayN/ServiceLib/ViewModels/MsgViewModel.cs b/v2rayN/ServiceLib/ViewModels/MsgViewModel.cs index 5ddec596..1a679383 100644 --- a/v2rayN/ServiceLib/ViewModels/MsgViewModel.cs +++ b/v2rayN/ServiceLib/ViewModels/MsgViewModel.cs @@ -23,17 +23,17 @@ namespace ServiceLib.ViewModels { _config = AppHandler.Instance.Config; _updateView = updateView; - MsgFilter = _config.msgUIItem.mainMsgFilter ?? string.Empty; - AutoRefresh = _config.msgUIItem.autoRefresh ?? true; + MsgFilter = _config.MsgUIItem.MainMsgFilter ?? string.Empty; + AutoRefresh = _config.MsgUIItem.AutoRefresh ?? true; this.WhenAnyValue( x => x.MsgFilter) - .Subscribe(c => _config.msgUIItem.mainMsgFilter = MsgFilter); + .Subscribe(c => _config.MsgUIItem.MainMsgFilter = MsgFilter); this.WhenAnyValue( x => x.AutoRefresh, y => y == true) - .Subscribe(c => { _config.msgUIItem.autoRefresh = AutoRefresh; }); + .Subscribe(c => { _config.MsgUIItem.AutoRefresh = AutoRefresh; }); MessageBus.Current.Listen(EMsgCommand.SendMsgView.ToString()).Subscribe(OnNext); } @@ -62,7 +62,7 @@ namespace ServiceLib.ViewModels } _blLockShow = true; - if (!_config.uiItem.showInTaskbar) + if (!_config.UiItem.ShowInTaskbar) { await Task.Delay(1000); } diff --git a/v2rayN/ServiceLib/ViewModels/OptionSettingViewModel.cs b/v2rayN/ServiceLib/ViewModels/OptionSettingViewModel.cs index 012caa06..a10f301e 100644 --- a/v2rayN/ServiceLib/ViewModels/OptionSettingViewModel.cs +++ b/v2rayN/ServiceLib/ViewModels/OptionSettingViewModel.cs @@ -119,26 +119,26 @@ namespace ServiceLib.ViewModels { #region Core - var inbound = _config.inbound[0]; - localPort = inbound.localPort; - udpEnabled = inbound.udpEnabled; - sniffingEnabled = inbound.sniffingEnabled; - routeOnly = inbound.routeOnly; - allowLANConn = inbound.allowLANConn; - newPort4LAN = inbound.newPort4LAN; - user = inbound.user; - pass = inbound.pass; - muxEnabled = _config.coreBasicItem.muxEnabled; - logEnabled = _config.coreBasicItem.logEnabled; - loglevel = _config.coreBasicItem.loglevel; - defAllowInsecure = _config.coreBasicItem.defAllowInsecure; - defFingerprint = _config.coreBasicItem.defFingerprint; - defUserAgent = _config.coreBasicItem.defUserAgent; - mux4SboxProtocol = _config.mux4SboxItem.protocol; - enableCacheFile4Sbox = _config.coreBasicItem.enableCacheFile4Sbox; - hyUpMbps = _config.hysteriaItem.up_mbps; - hyDownMbps = _config.hysteriaItem.down_mbps; - enableFragment = _config.coreBasicItem.enableFragment; + var inbound = _config.Inbound[0]; + localPort = inbound.LocalPort; + udpEnabled = inbound.UdpEnabled; + sniffingEnabled = inbound.SniffingEnabled; + routeOnly = inbound.RouteOnly; + allowLANConn = inbound.AllowLANConn; + newPort4LAN = inbound.NewPort4LAN; + user = inbound.User; + pass = inbound.Pass; + muxEnabled = _config.CoreBasicItem.MuxEnabled; + logEnabled = _config.CoreBasicItem.LogEnabled; + loglevel = _config.CoreBasicItem.Loglevel; + defAllowInsecure = _config.CoreBasicItem.DefAllowInsecure; + defFingerprint = _config.CoreBasicItem.DefFingerprint; + defUserAgent = _config.CoreBasicItem.DefUserAgent; + mux4SboxProtocol = _config.Mux4SboxItem.Protocol; + enableCacheFile4Sbox = _config.CoreBasicItem.EnableCacheFile4Sbox; + hyUpMbps = _config.HysteriaItem.UpMbps; + hyDownMbps = _config.HysteriaItem.DownMbps; + enableFragment = _config.CoreBasicItem.EnableFragment; #endregion Core @@ -156,47 +156,47 @@ namespace ServiceLib.ViewModels #region UI - AutoRun = _config.guiItem.autoRun; - EnableStatistics = _config.guiItem.enableStatistics; - KeepOlderDedupl = _config.guiItem.keepOlderDedupl; - IgnoreGeoUpdateCore = _config.guiItem.ignoreGeoUpdateCore; - EnableAutoAdjustMainLvColWidth = _config.uiItem.enableAutoAdjustMainLvColWidth; - EnableUpdateSubOnlyRemarksExist = _config.uiItem.enableUpdateSubOnlyRemarksExist; - EnableSecurityProtocolTls13 = _config.guiItem.enableSecurityProtocolTls13; - AutoHideStartup = _config.uiItem.autoHideStartup; - EnableCheckPreReleaseUpdate = _config.guiItem.checkPreReleaseUpdate; - EnableDragDropSort = _config.uiItem.enableDragDropSort; - DoubleClick2Activate = _config.uiItem.doubleClick2Activate; - AutoUpdateInterval = _config.guiItem.autoUpdateInterval; - TrayMenuServersLimit = _config.guiItem.trayMenuServersLimit; - CurrentFontFamily = _config.uiItem.currentFontFamily; - SpeedTestTimeout = _config.speedTestItem.speedTestTimeout; - SpeedTestUrl = _config.speedTestItem.speedTestUrl; - SpeedPingTestUrl = _config.speedTestItem.speedPingTestUrl; - EnableHWA = _config.guiItem.enableHWA; - SubConvertUrl = _config.constItem.subConvertUrl; - MainGirdOrientation = (int)_config.uiItem.mainGirdOrientation; - GeoFileSourceUrl = _config.constItem.geoSourceUrl; - SrsFileSourceUrl = _config.constItem.srsSourceUrl; - RoutingRulesSourceUrl = _config.constItem.routeRulesTemplateSourceUrl; + AutoRun = _config.GuiItem.AutoRun; + EnableStatistics = _config.GuiItem.EnableStatistics; + KeepOlderDedupl = _config.GuiItem.KeepOlderDedupl; + IgnoreGeoUpdateCore = _config.GuiItem.IgnoreGeoUpdateCore; + EnableAutoAdjustMainLvColWidth = _config.UiItem.EnableAutoAdjustMainLvColWidth; + EnableUpdateSubOnlyRemarksExist = _config.UiItem.EnableUpdateSubOnlyRemarksExist; + EnableSecurityProtocolTls13 = _config.GuiItem.EnableSecurityProtocolTls13; + AutoHideStartup = _config.UiItem.AutoHideStartup; + EnableCheckPreReleaseUpdate = _config.GuiItem.CheckPreReleaseUpdate; + EnableDragDropSort = _config.UiItem.EnableDragDropSort; + DoubleClick2Activate = _config.UiItem.DoubleClick2Activate; + AutoUpdateInterval = _config.GuiItem.AutoUpdateInterval; + TrayMenuServersLimit = _config.GuiItem.TrayMenuServersLimit; + CurrentFontFamily = _config.UiItem.CurrentFontFamily; + SpeedTestTimeout = _config.SpeedTestItem.SpeedTestTimeout; + SpeedTestUrl = _config.SpeedTestItem.SpeedTestUrl; + SpeedPingTestUrl = _config.SpeedTestItem.SpeedPingTestUrl; + EnableHWA = _config.GuiItem.EnableHWA; + SubConvertUrl = _config.ConstItem.SubConvertUrl; + MainGirdOrientation = (int)_config.UiItem.MainGirdOrientation; + GeoFileSourceUrl = _config.ConstItem.GeoSourceUrl; + SrsFileSourceUrl = _config.ConstItem.SrsSourceUrl; + RoutingRulesSourceUrl = _config.ConstItem.RouteRulesTemplateSourceUrl; #endregion UI #region System proxy - notProxyLocalAddress = _config.systemProxyItem.notProxyLocalAddress; - systemProxyAdvancedProtocol = _config.systemProxyItem.systemProxyAdvancedProtocol; - systemProxyExceptions = _config.systemProxyItem.systemProxyExceptions; + notProxyLocalAddress = _config.SystemProxyItem.NotProxyLocalAddress; + systemProxyAdvancedProtocol = _config.SystemProxyItem.SystemProxyAdvancedProtocol; + systemProxyExceptions = _config.SystemProxyItem.SystemProxyExceptions; #endregion System proxy #region Tun mode - TunStrictRoute = _config.tunModeItem.strictRoute; - TunStack = _config.tunModeItem.stack; - TunMtu = _config.tunModeItem.mtu; - TunEnableExInbound = _config.tunModeItem.enableExInbound; - TunEnableIPv6Address = _config.tunModeItem.enableIPv6Address; + TunStrictRoute = _config.TunModeItem.StrictRoute; + TunStack = _config.TunModeItem.Stack; + TunMtu = _config.TunModeItem.Mtu; + TunEnableExInbound = _config.TunModeItem.EnableExInbound; + TunEnableIPv6Address = _config.TunModeItem.EnableIPv6Address; #endregion Tun mode @@ -205,28 +205,28 @@ namespace ServiceLib.ViewModels private async Task InitCoreType() { - if (_config.coreTypeItem == null) + if (_config.CoreTypeItem == null) { - _config.coreTypeItem = new List(); + _config.CoreTypeItem = new List(); } foreach (EConfigType it in Enum.GetValues(typeof(EConfigType))) { - if (_config.coreTypeItem.FindIndex(t => t.configType == it) >= 0) + if (_config.CoreTypeItem.FindIndex(t => t.ConfigType == it) >= 0) { continue; } - _config.coreTypeItem.Add(new CoreTypeItem() + _config.CoreTypeItem.Add(new CoreTypeItem() { - configType = it, - coreType = ECoreType.Xray + ConfigType = it, + CoreType = ECoreType.Xray }); } - _config.coreTypeItem.ForEach(it => + _config.CoreTypeItem.ForEach(it => { - var type = it.coreType.ToString(); - switch ((int)it.configType) + var type = it.CoreType.ToString(); + switch ((int)it.ConfigType) { case 1: CoreType1 = type; @@ -263,11 +263,11 @@ namespace ServiceLib.ViewModels NoticeHandler.Instance.Enqueue(ResUI.FillLocalListeningPort); return; } - var needReboot = (EnableStatistics != _config.guiItem.enableStatistics - || EnableDragDropSort != _config.uiItem.enableDragDropSort - || EnableHWA != _config.guiItem.enableHWA - || CurrentFontFamily != _config.uiItem.currentFontFamily - || MainGirdOrientation != (int)_config.uiItem.mainGirdOrientation); + var needReboot = (EnableStatistics != _config.GuiItem.EnableStatistics + || EnableDragDropSort != _config.UiItem.EnableDragDropSort + || EnableHWA != _config.GuiItem.EnableHWA + || CurrentFontFamily != _config.UiItem.CurrentFontFamily + || MainGirdOrientation != (int)_config.UiItem.MainGirdOrientation); //if (Utile.IsNullOrEmpty(Kcpmtu.ToString()) || !Utile.IsNumeric(Kcpmtu.ToString()) // || Utile.IsNullOrEmpty(Kcptti.ToString()) || !Utile.IsNumeric(Kcptti.ToString()) @@ -281,66 +281,66 @@ namespace ServiceLib.ViewModels //} //Core - _config.inbound[0].localPort = localPort; - _config.inbound[0].udpEnabled = udpEnabled; - _config.inbound[0].sniffingEnabled = sniffingEnabled; - _config.inbound[0].destOverride = destOverride?.ToList(); - _config.inbound[0].routeOnly = routeOnly; - _config.inbound[0].allowLANConn = allowLANConn; - _config.inbound[0].newPort4LAN = newPort4LAN; - _config.inbound[0].user = user; - _config.inbound[0].pass = pass; - if (_config.inbound.Count > 1) + _config.Inbound[0].LocalPort = localPort; + _config.Inbound[0].UdpEnabled = udpEnabled; + _config.Inbound[0].SniffingEnabled = sniffingEnabled; + _config.Inbound[0].DestOverride = destOverride?.ToList(); + _config.Inbound[0].RouteOnly = routeOnly; + _config.Inbound[0].AllowLANConn = allowLANConn; + _config.Inbound[0].NewPort4LAN = newPort4LAN; + _config.Inbound[0].User = user; + _config.Inbound[0].Pass = pass; + if (_config.Inbound.Count > 1) { - _config.inbound.RemoveAt(1); + _config.Inbound.RemoveAt(1); } - _config.coreBasicItem.logEnabled = logEnabled; - _config.coreBasicItem.loglevel = loglevel; - _config.coreBasicItem.muxEnabled = muxEnabled; - _config.coreBasicItem.defAllowInsecure = defAllowInsecure; - _config.coreBasicItem.defFingerprint = defFingerprint; - _config.coreBasicItem.defUserAgent = defUserAgent; - _config.mux4SboxItem.protocol = mux4SboxProtocol; - _config.coreBasicItem.enableCacheFile4Sbox = enableCacheFile4Sbox; - _config.hysteriaItem.up_mbps = hyUpMbps; - _config.hysteriaItem.down_mbps = hyDownMbps; - _config.coreBasicItem.enableFragment = enableFragment; + _config.CoreBasicItem.LogEnabled = logEnabled; + _config.CoreBasicItem.Loglevel = loglevel; + _config.CoreBasicItem.MuxEnabled = muxEnabled; + _config.CoreBasicItem.DefAllowInsecure = defAllowInsecure; + _config.CoreBasicItem.DefFingerprint = defFingerprint; + _config.CoreBasicItem.DefUserAgent = defUserAgent; + _config.Mux4SboxItem.Protocol = mux4SboxProtocol; + _config.CoreBasicItem.EnableCacheFile4Sbox = enableCacheFile4Sbox; + _config.HysteriaItem.UpMbps = hyUpMbps; + _config.HysteriaItem.DownMbps = hyDownMbps; + _config.CoreBasicItem.EnableFragment = enableFragment; - _config.guiItem.autoRun = AutoRun; - _config.guiItem.enableStatistics = EnableStatistics; - _config.guiItem.keepOlderDedupl = KeepOlderDedupl; - _config.guiItem.ignoreGeoUpdateCore = IgnoreGeoUpdateCore; - _config.uiItem.enableAutoAdjustMainLvColWidth = EnableAutoAdjustMainLvColWidth; - _config.uiItem.enableUpdateSubOnlyRemarksExist = EnableUpdateSubOnlyRemarksExist; - _config.guiItem.enableSecurityProtocolTls13 = EnableSecurityProtocolTls13; - _config.uiItem.autoHideStartup = AutoHideStartup; - _config.guiItem.autoUpdateInterval = AutoUpdateInterval; - _config.guiItem.checkPreReleaseUpdate = EnableCheckPreReleaseUpdate; - _config.uiItem.enableDragDropSort = EnableDragDropSort; - _config.uiItem.doubleClick2Activate = DoubleClick2Activate; - _config.guiItem.trayMenuServersLimit = TrayMenuServersLimit; - _config.uiItem.currentFontFamily = CurrentFontFamily; - _config.speedTestItem.speedTestTimeout = SpeedTestTimeout; - _config.speedTestItem.speedTestUrl = SpeedTestUrl; - _config.speedTestItem.speedPingTestUrl = SpeedPingTestUrl; - _config.guiItem.enableHWA = EnableHWA; - _config.constItem.subConvertUrl = SubConvertUrl; - _config.uiItem.mainGirdOrientation = (EGirdOrientation)MainGirdOrientation; - _config.constItem.geoSourceUrl = GeoFileSourceUrl; - _config.constItem.srsSourceUrl = SrsFileSourceUrl; - _config.constItem.routeRulesTemplateSourceUrl = RoutingRulesSourceUrl; + _config.GuiItem.AutoRun = AutoRun; + _config.GuiItem.EnableStatistics = EnableStatistics; + _config.GuiItem.KeepOlderDedupl = KeepOlderDedupl; + _config.GuiItem.IgnoreGeoUpdateCore = IgnoreGeoUpdateCore; + _config.UiItem.EnableAutoAdjustMainLvColWidth = EnableAutoAdjustMainLvColWidth; + _config.UiItem.EnableUpdateSubOnlyRemarksExist = EnableUpdateSubOnlyRemarksExist; + _config.GuiItem.EnableSecurityProtocolTls13 = EnableSecurityProtocolTls13; + _config.UiItem.AutoHideStartup = AutoHideStartup; + _config.GuiItem.AutoUpdateInterval = AutoUpdateInterval; + _config.GuiItem.CheckPreReleaseUpdate = EnableCheckPreReleaseUpdate; + _config.UiItem.EnableDragDropSort = EnableDragDropSort; + _config.UiItem.DoubleClick2Activate = DoubleClick2Activate; + _config.GuiItem.TrayMenuServersLimit = TrayMenuServersLimit; + _config.UiItem.CurrentFontFamily = CurrentFontFamily; + _config.SpeedTestItem.SpeedTestTimeout = SpeedTestTimeout; + _config.SpeedTestItem.SpeedTestUrl = SpeedTestUrl; + _config.SpeedTestItem.SpeedPingTestUrl = SpeedPingTestUrl; + _config.GuiItem.EnableHWA = EnableHWA; + _config.ConstItem.SubConvertUrl = SubConvertUrl; + _config.UiItem.MainGirdOrientation = (EGirdOrientation)MainGirdOrientation; + _config.ConstItem.GeoSourceUrl = GeoFileSourceUrl; + _config.ConstItem.SrsSourceUrl = SrsFileSourceUrl; + _config.ConstItem.RouteRulesTemplateSourceUrl = RoutingRulesSourceUrl; //systemProxy - _config.systemProxyItem.systemProxyExceptions = systemProxyExceptions; - _config.systemProxyItem.notProxyLocalAddress = notProxyLocalAddress; - _config.systemProxyItem.systemProxyAdvancedProtocol = systemProxyAdvancedProtocol; + _config.SystemProxyItem.SystemProxyExceptions = systemProxyExceptions; + _config.SystemProxyItem.NotProxyLocalAddress = notProxyLocalAddress; + _config.SystemProxyItem.SystemProxyAdvancedProtocol = systemProxyAdvancedProtocol; //tun mode - _config.tunModeItem.strictRoute = TunStrictRoute; - _config.tunModeItem.stack = TunStack; - _config.tunModeItem.mtu = TunMtu; - _config.tunModeItem.enableExInbound = TunEnableExInbound; - _config.tunModeItem.enableIPv6Address = TunEnableIPv6Address; + _config.TunModeItem.StrictRoute = TunStrictRoute; + _config.TunModeItem.Stack = TunStack; + _config.TunModeItem.Mtu = TunMtu; + _config.TunModeItem.EnableExInbound = TunEnableExInbound; + _config.TunModeItem.EnableIPv6Address = TunEnableIPv6Address; //coreType await SaveCoreType(); @@ -365,11 +365,11 @@ namespace ServiceLib.ViewModels private async Task SaveCoreType() { - for (int k = 1; k <= _config.coreTypeItem.Count; k++) + for (int k = 1; k <= _config.CoreTypeItem.Count; k++) { - var item = _config.coreTypeItem[k - 1]; + var item = _config.CoreTypeItem[k - 1]; var type = string.Empty; - switch ((int)item.configType) + switch ((int)item.ConfigType) { case 1: type = CoreType1; @@ -398,7 +398,7 @@ namespace ServiceLib.ViewModels default: continue; } - item.coreType = (ECoreType)Enum.Parse(typeof(ECoreType), type); + item.CoreType = (ECoreType)Enum.Parse(typeof(ECoreType), type); } } } diff --git a/v2rayN/ServiceLib/ViewModels/ProfilesViewModel.cs b/v2rayN/ServiceLib/ViewModels/ProfilesViewModel.cs index 39ed44e7..bc6249fe 100644 --- a/v2rayN/ServiceLib/ViewModels/ProfilesViewModel.cs +++ b/v2rayN/ServiceLib/ViewModels/ProfilesViewModel.cs @@ -107,7 +107,7 @@ namespace ServiceLib.ViewModels this.WhenAnyValue( x => x.SelectedSub, - y => y != null && !y.remarks.IsNullOrEmpty() && _config.subIndexId != y.id) + y => y != null && !y.remarks.IsNullOrEmpty() && _config.SubIndexId != y.id) .Subscribe(async c => await SubSelectedChangedAsync(c)); this.WhenAnyValue( x => x.SelectedMoveToGroup, @@ -334,7 +334,7 @@ namespace ServiceLib.ViewModels { return; } - _config.subIndexId = SelectedSub?.id; + _config.SubIndexId = SelectedSub?.id; RefreshServers(); @@ -361,14 +361,14 @@ namespace ServiceLib.ViewModels public async Task RefreshServersBiz() { - var lstModel = await AppHandler.Instance.ProfileItemsEx(_config.subIndexId, _serverFilter); + var lstModel = await AppHandler.Instance.ProfileItemsEx(_config.SubIndexId, _serverFilter); _lstProfile = JsonUtils.Deserialize>(JsonUtils.Serialize(lstModel)) ?? []; _profileItems.Clear(); _profileItems.AddRange(lstModel); if (lstModel.Count > 0) { - var selected = lstModel.FirstOrDefault(t => t.indexId == _config.indexId); + var selected = lstModel.FirstOrDefault(t => t.indexId == _config.IndexId); if (selected != null) { SelectedProfile = selected; @@ -390,9 +390,9 @@ namespace ServiceLib.ViewModels { _subItems.Add(item); } - if (_config.subIndexId != null && _subItems.FirstOrDefault(t => t.id == _config.subIndexId) != null) + if (_config.SubIndexId != null && _subItems.FirstOrDefault(t => t.id == _config.SubIndexId) != null) { - SelectedSub = _subItems.FirstOrDefault(t => t.id == _config.subIndexId); + SelectedSub = _subItems.FirstOrDefault(t => t.id == _config.SubIndexId); } else { @@ -458,7 +458,7 @@ namespace ServiceLib.ViewModels if (ret == true) { RefreshServers(); - if (item.indexId == _config.indexId) + if (item.indexId == _config.IndexId) { Reload(); } @@ -476,7 +476,7 @@ namespace ServiceLib.ViewModels { return; } - var exists = lstSelecteds.Exists(t => t.indexId == _config.indexId); + var exists = lstSelecteds.Exists(t => t.indexId == _config.IndexId); await ConfigHandler.RemoveServer(_config, lstSelecteds); NoticeHandler.Instance.Enqueue(ResUI.OperationSuccess); @@ -490,7 +490,7 @@ namespace ServiceLib.ViewModels private async Task RemoveDuplicateServer() { - var tuple = await ConfigHandler.DedupServerList(_config, _config.subIndexId); + var tuple = await ConfigHandler.DedupServerList(_config, _config.SubIndexId); RefreshServers(); Reload(); NoticeHandler.Instance.Enqueue(string.Format(ResUI.RemoveDuplicateServerResult, tuple.Item1, tuple.Item2)); @@ -525,7 +525,7 @@ namespace ServiceLib.ViewModels { return; } - if (indexId == _config.indexId) + if (indexId == _config.IndexId) { return; } @@ -591,7 +591,7 @@ namespace ServiceLib.ViewModels NoticeHandler.Instance.Enqueue(ResUI.OperationFailed); return; } - if (ret?.Data?.ToString() == _config.indexId) + if (ret?.Data?.ToString() == _config.IndexId) { RefreshServers(); Reload(); @@ -611,7 +611,7 @@ namespace ServiceLib.ViewModels _dicHeaderSort.TryAdd(colName, true); _dicHeaderSort.TryGetValue(colName, out bool asc); - if (await ConfigHandler.SortServers(_config, _config.subIndexId, colName, asc) != 0) + if (await ConfigHandler.SortServers(_config, _config.SubIndexId, colName, asc) != 0) { return; } @@ -784,7 +784,7 @@ namespace ServiceLib.ViewModels } else { - item = await AppHandler.Instance.GetSubItem(_config.subIndexId); + item = await AppHandler.Instance.GetSubItem(_config.SubIndexId); if (item is null) { return; diff --git a/v2rayN/ServiceLib/ViewModels/RoutingSettingViewModel.cs b/v2rayN/ServiceLib/ViewModels/RoutingSettingViewModel.cs index 89e22396..d529f85b 100644 --- a/v2rayN/ServiceLib/ViewModels/RoutingSettingViewModel.cs +++ b/v2rayN/ServiceLib/ViewModels/RoutingSettingViewModel.cs @@ -111,10 +111,10 @@ namespace ServiceLib.ViewModels { SelectedSource = new(); - enableRoutingAdvanced = _config.routingBasicItem.enableRoutingAdvanced; - domainStrategy = _config.routingBasicItem.domainStrategy; - domainMatcher = _config.routingBasicItem.domainMatcher; - domainStrategy4Singbox = _config.routingBasicItem.domainStrategy4Singbox; + enableRoutingAdvanced = _config.RoutingBasicItem.EnableRoutingAdvanced; + domainStrategy = _config.RoutingBasicItem.DomainStrategy; + domainMatcher = _config.RoutingBasicItem.DomainMatcher; + domainStrategy4Singbox = _config.RoutingBasicItem.DomainStrategy4Singbox; await ConfigHandler.InitBuiltinRouting(_config); await RefreshRoutingItems(); @@ -182,7 +182,7 @@ namespace ServiceLib.ViewModels foreach (var item in routings) { bool def = false; - if (item.id == _config.routingBasicItem.routingIndexId) + if (item.id == _config.RoutingBasicItem.RoutingIndexId) { def = true; } @@ -204,10 +204,10 @@ namespace ServiceLib.ViewModels private async Task SaveRoutingAsync() { - _config.routingBasicItem.domainStrategy = domainStrategy; - _config.routingBasicItem.enableRoutingAdvanced = enableRoutingAdvanced; - _config.routingBasicItem.domainMatcher = domainMatcher; - _config.routingBasicItem.domainStrategy4Singbox = domainStrategy4Singbox; + _config.RoutingBasicItem.DomainStrategy = domainStrategy; + _config.RoutingBasicItem.EnableRoutingAdvanced = enableRoutingAdvanced; + _config.RoutingBasicItem.DomainMatcher = domainMatcher; + _config.RoutingBasicItem.DomainStrategy4Singbox = domainStrategy4Singbox; await EndBindingLockedData(); diff --git a/v2rayN/ServiceLib/ViewModels/StatusBarViewModel.cs b/v2rayN/ServiceLib/ViewModels/StatusBarViewModel.cs index 80c5366e..c5c0ed81 100644 --- a/v2rayN/ServiceLib/ViewModels/StatusBarViewModel.cs +++ b/v2rayN/ServiceLib/ViewModels/StatusBarViewModel.cs @@ -117,7 +117,7 @@ namespace ServiceLib.ViewModels y => y != null && !y.Text.IsNullOrEmpty()) .Subscribe(c => ServerSelectedChanged(c)); - SystemProxySelected = (int)_config.systemProxyItem.sysProxyType; + SystemProxySelected = (int)_config.SystemProxyItem.SysProxyType; this.WhenAnyValue( x => x.SystemProxySelected, y => y >= 0) @@ -182,18 +182,18 @@ namespace ServiceLib.ViewModels SelectedRouting = new(); SelectedServer = new(); - if (_config.tunModeItem.enableTun && AppHandler.Instance.IsAdministrator) + if (_config.TunModeItem.EnableTun && AppHandler.Instance.IsAdministrator) { EnableTun = true; } else { - _config.tunModeItem.enableTun = EnableTun = false; + _config.TunModeItem.EnableTun = EnableTun = false; } await RefreshRoutingsMenu(); await InboundDisplayStatus(); - await ChangeSystemProxyAsync(_config.systemProxyItem.sysProxyType, true); + await ChangeSystemProxyAsync(_config.SystemProxyItem.SysProxyType, true); } public void InitUpdateView(Func>? updateView) @@ -248,10 +248,10 @@ namespace ServiceLib.ViewModels private async Task RefreshServersMenu() { - var lstModel = await AppHandler.Instance.ProfileItems(_config.subIndexId, ""); + var lstModel = await AppHandler.Instance.ProfileItems(_config.SubIndexId, ""); _servers.Clear(); - if (lstModel.Count > _config.guiItem.trayMenuServersLimit) + if (lstModel.Count > _config.GuiItem.TrayMenuServersLimit) { BlServers = false; return; @@ -265,7 +265,7 @@ namespace ServiceLib.ViewModels var item = new ComboItem() { ID = it.indexId, Text = name }; _servers.Add(item); - if (_config.indexId == it.indexId) + if (_config.IndexId == it.indexId) { SelectedServer = item; } @@ -312,15 +312,15 @@ namespace ServiceLib.ViewModels public async Task SetListenerType(ESysProxyType type) { - if (_config.systemProxyItem.sysProxyType == type) + if (_config.SystemProxyItem.SysProxyType == type) { return; } - _config.systemProxyItem.sysProxyType = type; + _config.SystemProxyItem.SysProxyType = type; await ChangeSystemProxyAsync(type, true); - NoticeHandler.Instance.SendMessageEx($"{ResUI.TipChangeSystemProxy} - {_config.systemProxyItem.sysProxyType.ToString()}"); + NoticeHandler.Instance.SendMessageEx($"{ResUI.TipChangeSystemProxy} - {_config.SystemProxyItem.SysProxyType.ToString()}"); - SystemProxySelected = (int)_config.systemProxyItem.sysProxyType; + SystemProxySelected = (int)_config.SystemProxyItem.SysProxyType; await ConfigHandler.SaveConfig(_config, false); } @@ -347,7 +347,7 @@ namespace ServiceLib.ViewModels public async Task RefreshRoutingsMenu() { _routingItems.Clear(); - if (!_config.routingBasicItem.enableRoutingAdvanced) + if (!_config.RoutingBasicItem.EnableRoutingAdvanced) { BlRouting = false; return; @@ -358,7 +358,7 @@ namespace ServiceLib.ViewModels foreach (var item in routings) { _routingItems.Add(item); - if (item.id == _config.routingBasicItem.routingIndexId) + if (item.id == _config.RoutingBasicItem.RoutingIndexId) { SelectedRouting = item; } @@ -382,7 +382,7 @@ namespace ServiceLib.ViewModels { return; } - if (_config.routingBasicItem.routingIndexId == item.id) + if (_config.RoutingBasicItem.RoutingIndexId == item.id) { return; } @@ -401,7 +401,7 @@ namespace ServiceLib.ViewModels { return; } - if (_config.systemProxyItem.sysProxyType == (ESysProxyType)SystemProxySelected) + if (_config.SystemProxyItem.SysProxyType == (ESysProxyType)SystemProxySelected) { return; } @@ -410,13 +410,13 @@ namespace ServiceLib.ViewModels private async Task DoEnableTun(bool c) { - if (_config.tunModeItem.enableTun != EnableTun) + if (_config.TunModeItem.EnableTun != EnableTun) { - _config.tunModeItem.enableTun = EnableTun; + _config.TunModeItem.EnableTun = EnableTun; // When running as a non-administrator, reboot to administrator mode if (EnableTun && !AppHandler.Instance.IsAdministrator) { - _config.tunModeItem.enableTun = false; + _config.TunModeItem.EnableTun = false; Locator.Current.GetService()?.RebootAsAdmin(); return; } @@ -437,9 +437,9 @@ namespace ServiceLib.ViewModels sb.Append($"[{EInboundProtocol.http}:{AppHandler.Instance.GetLocalPort(EInboundProtocol.http)}]"); InboundDisplay = $"{ResUI.LabLocal}:{sb}"; - if (_config.inbound[0].allowLANConn) + if (_config.Inbound[0].AllowLANConn) { - if (_config.inbound[0].newPort4LAN) + if (_config.Inbound[0].NewPort4LAN) { StringBuilder sb2 = new(); sb2.Append($"[{EInboundProtocol.socks}:{AppHandler.Instance.GetLocalPort(EInboundProtocol.socks2)}]"); diff --git a/v2rayN/v2rayN.Desktop/ViewModels/ThemeSettingViewModel.cs b/v2rayN/v2rayN.Desktop/ViewModels/ThemeSettingViewModel.cs index f29725df..d960cee0 100644 --- a/v2rayN/v2rayN.Desktop/ViewModels/ThemeSettingViewModel.cs +++ b/v2rayN/v2rayN.Desktop/ViewModels/ThemeSettingViewModel.cs @@ -28,21 +28,21 @@ namespace v2rayN.Desktop.ViewModels private void RestoreUI() { - ModifyTheme(_config.uiItem.colorModeDark); + ModifyTheme(_config.UiItem.ColorModeDark); } private void BindingUI() { - ColorModeDark = _config.uiItem.colorModeDark; - CurrentFontSize = _config.uiItem.currentFontSize; - CurrentLanguage = _config.uiItem.currentLanguage; + ColorModeDark = _config.UiItem.ColorModeDark; + CurrentFontSize = _config.UiItem.CurrentFontSize; + CurrentLanguage = _config.UiItem.CurrentLanguage; this.WhenAnyValue(x => x.ColorModeDark) .Subscribe(c => { - if (_config.uiItem.colorModeDark != ColorModeDark) + if (_config.UiItem.ColorModeDark != ColorModeDark) { - _config.uiItem.colorModeDark = ColorModeDark; + _config.UiItem.ColorModeDark = ColorModeDark; ModifyTheme(ColorModeDark); ConfigHandler.SaveConfig(_config); } @@ -55,7 +55,7 @@ namespace v2rayN.Desktop.ViewModels { if (CurrentFontSize >= Global.MinFontSize) { - _config.uiItem.currentFontSize = CurrentFontSize; + _config.UiItem.CurrentFontSize = CurrentFontSize; double size = CurrentFontSize; ModifyFontSize(size); @@ -68,9 +68,9 @@ namespace v2rayN.Desktop.ViewModels y => y != null && !y.IsNullOrEmpty()) .Subscribe(c => { - if (Utils.IsNotEmpty(CurrentLanguage) && _config.uiItem.currentLanguage != CurrentLanguage) + if (Utils.IsNotEmpty(CurrentLanguage) && _config.UiItem.CurrentLanguage != CurrentLanguage) { - _config.uiItem.currentLanguage = CurrentLanguage; + _config.UiItem.CurrentLanguage = CurrentLanguage; Thread.CurrentThread.CurrentUICulture = new(CurrentLanguage); ConfigHandler.SaveConfig(_config); NoticeHandler.Instance.Enqueue(ResUI.NeedRebootTips); diff --git a/v2rayN/v2rayN.Desktop/Views/BackupAndRestoreView.axaml.cs b/v2rayN/v2rayN.Desktop/Views/BackupAndRestoreView.axaml.cs index 4ed7c27e..9098c09f 100644 --- a/v2rayN/v2rayN.Desktop/Views/BackupAndRestoreView.axaml.cs +++ b/v2rayN/v2rayN.Desktop/Views/BackupAndRestoreView.axaml.cs @@ -25,10 +25,10 @@ namespace v2rayN.Desktop.Views { this.Bind(ViewModel, vm => vm.OperationMsg, v => v.txtMsg.Text).DisposeWith(disposables); - this.Bind(ViewModel, vm => vm.SelectedSource.url, v => v.txtWebDavUrl.Text).DisposeWith(disposables); - this.Bind(ViewModel, vm => vm.SelectedSource.userName, v => v.txtWebDavUserName.Text).DisposeWith(disposables); - this.Bind(ViewModel, vm => vm.SelectedSource.password, v => v.txtWebDavPassword.Text).DisposeWith(disposables); - this.Bind(ViewModel, vm => vm.SelectedSource.dirName, v => v.txtWebDavDirName.Text).DisposeWith(disposables); + this.Bind(ViewModel, vm => vm.SelectedSource.Url, v => v.txtWebDavUrl.Text).DisposeWith(disposables); + this.Bind(ViewModel, vm => vm.SelectedSource.UserName, v => v.txtWebDavUserName.Text).DisposeWith(disposables); + this.Bind(ViewModel, vm => vm.SelectedSource.Password, v => v.txtWebDavPassword.Text).DisposeWith(disposables); + this.Bind(ViewModel, vm => vm.SelectedSource.DirName, v => v.txtWebDavDirName.Text).DisposeWith(disposables); this.BindCommand(ViewModel, vm => vm.WebDavCheckCmd, v => v.menuWebDavCheck).DisposeWith(disposables); diff --git a/v2rayN/v2rayN.Desktop/Views/MainWindow.axaml.cs b/v2rayN/v2rayN.Desktop/Views/MainWindow.axaml.cs index 2c07ac3c..c4ce8123 100644 --- a/v2rayN/v2rayN.Desktop/Views/MainWindow.axaml.cs +++ b/v2rayN/v2rayN.Desktop/Views/MainWindow.axaml.cs @@ -83,7 +83,7 @@ namespace v2rayN.Desktop.Views this.BindCommand(ViewModel, vm => vm.ReloadCmd, v => v.menuReload).DisposeWith(disposables); this.OneWayBind(ViewModel, vm => vm.BlReloadEnabled, v => v.menuReload.IsEnabled).DisposeWith(disposables); - switch (_config.uiItem.mainGirdOrientation) + switch (_config.UiItem.MainGirdOrientation) { case EGirdOrientation.Horizontal: gridMain.IsVisible = true; @@ -124,7 +124,7 @@ namespace v2rayN.Desktop.Views } menuAddServerViaScan.IsVisible = false; - switch (_config.uiItem.mainGirdOrientation) + switch (_config.UiItem.MainGirdOrientation) { case EGirdOrientation.Horizontal: tabProfiles.Content ??= new ProfilesView(this); @@ -360,7 +360,7 @@ namespace v2rayN.Desktop.Views public void ShowHideWindow(bool? blShow) { - var bl = blShow ?? !_config.uiItem.showInTaskbar; + var bl = blShow ?? !_config.UiItem.ShowInTaskbar; if (bl) { this.Show(); @@ -375,46 +375,46 @@ namespace v2rayN.Desktop.Views { this.Hide(); } - _config.uiItem.showInTaskbar = bl; + _config.UiItem.ShowInTaskbar = bl; } private void RestoreUI() { - if (_config.uiItem.mainWidth > 0 && _config.uiItem.mainHeight > 0) + if (_config.UiItem.MainWidth > 0 && _config.UiItem.MainHeight > 0) { - Width = _config.uiItem.mainWidth; - Height = _config.uiItem.mainHeight; + Width = _config.UiItem.MainWidth; + Height = _config.UiItem.MainHeight; } - if (_config.uiItem.mainGirdHeight1 > 0 && _config.uiItem.mainGirdHeight2 > 0) + if (_config.UiItem.MainGirdHeight1 > 0 && _config.UiItem.MainGirdHeight2 > 0) { - if (_config.uiItem.mainGirdOrientation == EGirdOrientation.Horizontal) + if (_config.UiItem.MainGirdOrientation == EGirdOrientation.Horizontal) { - gridMain.ColumnDefinitions[0].Width = new GridLength(_config.uiItem.mainGirdHeight1, GridUnitType.Star); - gridMain.ColumnDefinitions[2].Width = new GridLength(_config.uiItem.mainGirdHeight2, GridUnitType.Star); + gridMain.ColumnDefinitions[0].Width = new GridLength(_config.UiItem.MainGirdHeight1, GridUnitType.Star); + gridMain.ColumnDefinitions[2].Width = new GridLength(_config.UiItem.MainGirdHeight2, GridUnitType.Star); } - else if (_config.uiItem.mainGirdOrientation == EGirdOrientation.Vertical) + else if (_config.UiItem.MainGirdOrientation == EGirdOrientation.Vertical) { - gridMain1.RowDefinitions[0].Height = new GridLength(_config.uiItem.mainGirdHeight1, GridUnitType.Star); - gridMain1.RowDefinitions[2].Height = new GridLength(_config.uiItem.mainGirdHeight2, GridUnitType.Star); + gridMain1.RowDefinitions[0].Height = new GridLength(_config.UiItem.MainGirdHeight1, GridUnitType.Star); + gridMain1.RowDefinitions[2].Height = new GridLength(_config.UiItem.MainGirdHeight2, GridUnitType.Star); } } } private void StorageUI() { - _config.uiItem.mainWidth = Utils.ToInt(this.Width); - _config.uiItem.mainHeight = Utils.ToInt(this.Height); + _config.UiItem.MainWidth = Utils.ToInt(this.Width); + _config.UiItem.MainHeight = Utils.ToInt(this.Height); - if (_config.uiItem.mainGirdOrientation == EGirdOrientation.Horizontal) + if (_config.UiItem.MainGirdOrientation == EGirdOrientation.Horizontal) { - _config.uiItem.mainGirdHeight1 = Math.Ceiling(gridMain.ColumnDefinitions[0].ActualWidth + 0.1); - _config.uiItem.mainGirdHeight2 = Math.Ceiling(gridMain.ColumnDefinitions[2].ActualWidth + 0.1); + _config.UiItem.MainGirdHeight1 = Math.Ceiling(gridMain.ColumnDefinitions[0].ActualWidth + 0.1); + _config.UiItem.MainGirdHeight2 = Math.Ceiling(gridMain.ColumnDefinitions[2].ActualWidth + 0.1); } - else if (_config.uiItem.mainGirdOrientation == EGirdOrientation.Vertical) + else if (_config.UiItem.MainGirdOrientation == EGirdOrientation.Vertical) { - _config.uiItem.mainGirdHeight1 = Math.Ceiling(gridMain1.RowDefinitions[0].ActualHeight + 0.1); - _config.uiItem.mainGirdHeight2 = Math.Ceiling(gridMain1.RowDefinitions[2].ActualHeight + 0.1); + _config.UiItem.MainGirdHeight1 = Math.Ceiling(gridMain1.RowDefinitions[0].ActualHeight + 0.1); + _config.UiItem.MainGirdHeight2 = Math.Ceiling(gridMain1.RowDefinitions[2].ActualHeight + 0.1); } ConfigHandler.SaveConfig(_config); } diff --git a/v2rayN/v2rayN.Desktop/Views/OptionSettingWindow.axaml.cs b/v2rayN/v2rayN.Desktop/Views/OptionSettingWindow.axaml.cs index 33d6f630..d0408789 100644 --- a/v2rayN/v2rayN.Desktop/Views/OptionSettingWindow.axaml.cs +++ b/v2rayN/v2rayN.Desktop/Views/OptionSettingWindow.axaml.cs @@ -24,7 +24,7 @@ namespace v2rayN.Desktop.Views { clbdestOverride.Items.Add(it); }); - _config.inbound[0].destOverride?.ForEach(it => + _config.Inbound[0].DestOverride?.ForEach(it => { clbdestOverride.SelectedItems.Add(it); }); diff --git a/v2rayN/v2rayN.Desktop/Views/ProfilesView.axaml.cs b/v2rayN/v2rayN.Desktop/Views/ProfilesView.axaml.cs index 305b1f42..e03edc46 100644 --- a/v2rayN/v2rayN.Desktop/Views/ProfilesView.axaml.cs +++ b/v2rayN/v2rayN.Desktop/Views/ProfilesView.axaml.cs @@ -189,7 +189,7 @@ namespace v2rayN.Desktop.Views private void LstProfiles_DoubleTapped(object? sender, Avalonia.Input.TappedEventArgs e) { - if (_config.uiItem.doubleClick2Activate) + if (_config.UiItem.DoubleClick2Activate) { ViewModel?.SetDefaultServer(); } @@ -325,7 +325,7 @@ namespace v2rayN.Desktop.Views private void RestoreUI() { - var lvColumnItem = _config.uiItem.mainColumnItem.OrderBy(t => t.Index).ToList(); + var lvColumnItem = _config.UiItem.MainColumnItem.OrderBy(t => t.Index).ToList(); var displayIndex = 0; foreach (var item in lvColumnItem) { @@ -348,7 +348,7 @@ namespace v2rayN.Desktop.Views } if (item.Name.StartsWith("to")) { - if (!_config.guiItem.enableStatistics) + if (!_config.GuiItem.EnableStatistics) { item2.IsVisible = false; } @@ -375,7 +375,7 @@ namespace v2rayN.Desktop.Views Index = item2.DisplayIndex }); } - _config.uiItem.mainColumnItem = lvColumnItem; + _config.UiItem.MainColumnItem = lvColumnItem; ConfigHandler.SaveConfig(_config); } diff --git a/v2rayN/v2rayN.Desktop/Views/StatusBarView.axaml.cs b/v2rayN/v2rayN.Desktop/Views/StatusBarView.axaml.cs index 89563971..db574dc3 100644 --- a/v2rayN/v2rayN.Desktop/Views/StatusBarView.axaml.cs +++ b/v2rayN/v2rayN.Desktop/Views/StatusBarView.axaml.cs @@ -76,7 +76,7 @@ namespace v2rayN.Desktop.Views { if (Application.Current?.ApplicationLifetime is IClassicDesktopStyleApplicationLifetime desktop) { - desktop.MainWindow.Icon = AvaUtils.GetAppIcon(_config.systemProxyItem.sysProxyType); + desktop.MainWindow.Icon = AvaUtils.GetAppIcon(_config.SystemProxyItem.SysProxyType); } } diff --git a/v2rayN/v2rayN/Converters/MaterialDesignFonts.cs b/v2rayN/v2rayN/Converters/MaterialDesignFonts.cs index 84e61823..20d9d5b5 100644 --- a/v2rayN/v2rayN/Converters/MaterialDesignFonts.cs +++ b/v2rayN/v2rayN/Converters/MaterialDesignFonts.cs @@ -10,7 +10,7 @@ namespace v2rayN.Converters { try { - var fontFamily = AppHandler.Instance.Config.uiItem.currentFontFamily; + var fontFamily = AppHandler.Instance.Config.UiItem.CurrentFontFamily; if (Utils.IsNotEmpty(fontFamily)) { var fontPath = Utils.GetFontsPath(); diff --git a/v2rayN/v2rayN/Handler/HotkeyHandler.cs b/v2rayN/v2rayN/Handler/HotkeyHandler.cs index 42c4092f..3ae7ddf5 100644 --- a/v2rayN/v2rayN/Handler/HotkeyHandler.cs +++ b/v2rayN/v2rayN/Handler/HotkeyHandler.cs @@ -37,8 +37,8 @@ namespace v2rayN.Handler private void Init() { _hotkeyTriggerDic.Clear(); - if (_config.globalHotkeys == null) return; - foreach (var item in _config.globalHotkeys) + if (_config.GlobalHotkeys == null) return; + foreach (var item in _config.GlobalHotkeys) { if (item.KeyCode != null && (Key)item.KeyCode != Key.None) { @@ -50,12 +50,12 @@ namespace v2rayN.Handler key = (key << 16) | (int)modifiers; if (!_hotkeyTriggerDic.ContainsKey(key)) { - _hotkeyTriggerDic.Add(key, new() { item.eGlobalHotkey }); + _hotkeyTriggerDic.Add(key, new() { item.EGlobalHotkey }); } else { - if (!_hotkeyTriggerDic[key].Contains(item.eGlobalHotkey)) - _hotkeyTriggerDic[key].Add(item.eGlobalHotkey); + if (!_hotkeyTriggerDic[key].Contains(item.EGlobalHotkey)) + _hotkeyTriggerDic[key].Add(item.EGlobalHotkey); } } } diff --git a/v2rayN/v2rayN/Handler/WindowsHandler.cs b/v2rayN/v2rayN/Handler/WindowsHandler.cs index 3c887d3c..4a5ef4c0 100644 --- a/v2rayN/v2rayN/Handler/WindowsHandler.cs +++ b/v2rayN/v2rayN/Handler/WindowsHandler.cs @@ -13,7 +13,7 @@ namespace v2rayN.Handler { try { - var index = (int)config.systemProxyItem.sysProxyType; + var index = (int)config.SystemProxyItem.SysProxyType; //Load from routing setting var createdIcon = await GetNotifyIcon4Routing(config); @@ -46,7 +46,7 @@ namespace v2rayN.Handler public System.Windows.Media.ImageSource GetAppIcon(Config config) { - var index = (int)config.systemProxyItem.sysProxyType + 1; + var index = (int)config.SystemProxyItem.SysProxyType + 1; return BitmapFrame.Create(new Uri($"pack://application:,,,/Resources/NotifyIcon{index}.ico", UriKind.RelativeOrAbsolute)); } @@ -54,7 +54,7 @@ namespace v2rayN.Handler { try { - if (!config.routingBasicItem.enableRoutingAdvanced) + if (!config.RoutingBasicItem.EnableRoutingAdvanced) { return null; } @@ -66,7 +66,7 @@ namespace v2rayN.Handler } Color color = ColorTranslator.FromHtml("#3399CC"); - int index = (int)config.systemProxyItem.sysProxyType; + int index = (int)config.SystemProxyItem.SysProxyType; if (index > 0) { color = (new[] { Color.Red, Color.Purple, Color.DarkGreen, Color.Orange, Color.DarkSlateBlue, Color.RoyalBlue })[index - 1]; diff --git a/v2rayN/v2rayN/ViewModels/ThemeSettingViewModel.cs b/v2rayN/v2rayN/ViewModels/ThemeSettingViewModel.cs index 2eeb4024..f16596c2 100644 --- a/v2rayN/v2rayN/ViewModels/ThemeSettingViewModel.cs +++ b/v2rayN/v2rayN/ViewModels/ThemeSettingViewModel.cs @@ -52,12 +52,12 @@ namespace v2rayN.ViewModels } else { - ModifyTheme(_config.uiItem.colorModeDark); + ModifyTheme(_config.UiItem.ColorModeDark); } - if (!_config.uiItem.colorPrimaryName.IsNullOrEmpty()) + if (!_config.UiItem.ColorPrimaryName.IsNullOrEmpty()) { - var swatch = new SwatchesProvider().Swatches.FirstOrDefault(t => t.Name == _config.uiItem.colorPrimaryName); + var swatch = new SwatchesProvider().Swatches.FirstOrDefault(t => t.Name == _config.UiItem.ColorPrimaryName); if (swatch != null && swatch.ExemplarHue != null && swatch.ExemplarHue?.Color != null) @@ -69,24 +69,24 @@ namespace v2rayN.ViewModels private void BindingUI() { - ColorModeDark = _config.uiItem.colorModeDark; - FollowSystemTheme = _config.uiItem.followSystemTheme; + ColorModeDark = _config.UiItem.ColorModeDark; + FollowSystemTheme = _config.UiItem.FollowSystemTheme; _swatches.AddRange(new SwatchesProvider().Swatches); - if (!_config.uiItem.colorPrimaryName.IsNullOrEmpty()) + if (!_config.UiItem.ColorPrimaryName.IsNullOrEmpty()) { - SelectedSwatch = _swatches.FirstOrDefault(t => t.Name == _config.uiItem.colorPrimaryName); + SelectedSwatch = _swatches.FirstOrDefault(t => t.Name == _config.UiItem.ColorPrimaryName); } - CurrentFontSize = _config.uiItem.currentFontSize; - CurrentLanguage = _config.uiItem.currentLanguage; + CurrentFontSize = _config.UiItem.CurrentFontSize; + CurrentLanguage = _config.UiItem.CurrentLanguage; this.WhenAnyValue( x => x.ColorModeDark, y => y == true) .Subscribe(c => { - if (_config.uiItem.colorModeDark != ColorModeDark) + if (_config.UiItem.ColorModeDark != ColorModeDark) { - _config.uiItem.colorModeDark = ColorModeDark; + _config.UiItem.ColorModeDark = ColorModeDark; ModifyTheme(ColorModeDark); ConfigHandler.SaveConfig(_config); } @@ -96,9 +96,9 @@ namespace v2rayN.ViewModels y => y == true) .Subscribe(c => { - if (_config.uiItem.followSystemTheme != FollowSystemTheme) + if (_config.UiItem.FollowSystemTheme != FollowSystemTheme) { - _config.uiItem.followSystemTheme = FollowSystemTheme; + _config.UiItem.FollowSystemTheme = FollowSystemTheme; ConfigHandler.SaveConfig(_config); if (FollowSystemTheme) { @@ -123,9 +123,9 @@ namespace v2rayN.ViewModels { return; } - if (_config.uiItem.colorPrimaryName != SelectedSwatch?.Name) + if (_config.UiItem.ColorPrimaryName != SelectedSwatch?.Name) { - _config.uiItem.colorPrimaryName = SelectedSwatch?.Name; + _config.UiItem.ColorPrimaryName = SelectedSwatch?.Name; ChangePrimaryColor(SelectedSwatch.ExemplarHue.Color); ConfigHandler.SaveConfig(_config); } @@ -138,7 +138,7 @@ namespace v2rayN.ViewModels { if (CurrentFontSize >= Global.MinFontSize) { - _config.uiItem.currentFontSize = CurrentFontSize; + _config.UiItem.CurrentFontSize = CurrentFontSize; double size = (long)CurrentFontSize; Application.Current.Resources["StdFontSize"] = size; Application.Current.Resources["StdFontSize1"] = size + 1; @@ -153,9 +153,9 @@ namespace v2rayN.ViewModels y => y != null && !y.IsNullOrEmpty()) .Subscribe(c => { - if (Utils.IsNotEmpty(CurrentLanguage) && _config.uiItem.currentLanguage != CurrentLanguage) + if (Utils.IsNotEmpty(CurrentLanguage) && _config.UiItem.CurrentLanguage != CurrentLanguage) { - _config.uiItem.currentLanguage = CurrentLanguage; + _config.UiItem.CurrentLanguage = CurrentLanguage; Thread.CurrentThread.CurrentUICulture = new(CurrentLanguage); ConfigHandler.SaveConfig(_config); NoticeHandler.Instance.Enqueue(ResUI.NeedRebootTips); @@ -189,7 +189,7 @@ namespace v2rayN.ViewModels var hwndSource = HwndSource.FromHwnd(helper.EnsureHandle()); hwndSource.AddHook((IntPtr hwnd, int msg, IntPtr wParam, IntPtr lParam, ref bool handled) => { - if (config.uiItem.followSystemTheme) + if (config.UiItem.FollowSystemTheme) { const int WM_SETTINGCHANGE = 0x001A; if (msg == WM_SETTINGCHANGE) diff --git a/v2rayN/v2rayN/Views/AddServer2Window.xaml.cs b/v2rayN/v2rayN/Views/AddServer2Window.xaml.cs index 44b0136c..19904340 100644 --- a/v2rayN/v2rayN/Views/AddServer2Window.xaml.cs +++ b/v2rayN/v2rayN/Views/AddServer2Window.xaml.cs @@ -34,7 +34,7 @@ namespace v2rayN.Views this.BindCommand(ViewModel, vm => vm.EditServerCmd, v => v.btnEdit).DisposeWith(disposables); this.BindCommand(ViewModel, vm => vm.SaveServerCmd, v => v.btnSave).DisposeWith(disposables); }); - WindowsUtils.SetDarkBorder(this, AppHandler.Instance.Config.uiItem.followSystemTheme ? !WindowsUtils.IsLightTheme() : AppHandler.Instance.Config.uiItem.colorModeDark); + WindowsUtils.SetDarkBorder(this, AppHandler.Instance.Config.UiItem.FollowSystemTheme ? !WindowsUtils.IsLightTheme() : AppHandler.Instance.Config.UiItem.ColorModeDark); } private async Task UpdateViewHandler(EViewAction action, object? obj) diff --git a/v2rayN/v2rayN/Views/AddServerWindow.xaml.cs b/v2rayN/v2rayN/Views/AddServerWindow.xaml.cs index 1593e9bb..6d95e23d 100644 --- a/v2rayN/v2rayN/Views/AddServerWindow.xaml.cs +++ b/v2rayN/v2rayN/Views/AddServerWindow.xaml.cs @@ -219,7 +219,7 @@ namespace v2rayN.Views }); this.Title = $"{profileItem.configType}"; - WindowsUtils.SetDarkBorder(this, AppHandler.Instance.Config.uiItem.followSystemTheme ? !WindowsUtils.IsLightTheme() : AppHandler.Instance.Config.uiItem.colorModeDark); + WindowsUtils.SetDarkBorder(this, AppHandler.Instance.Config.UiItem.FollowSystemTheme ? !WindowsUtils.IsLightTheme() : AppHandler.Instance.Config.UiItem.ColorModeDark); } private async Task UpdateViewHandler(EViewAction action, object? obj) diff --git a/v2rayN/v2rayN/Views/BackupAndRestoreView.xaml.cs b/v2rayN/v2rayN/Views/BackupAndRestoreView.xaml.cs index b6787971..848a5acd 100644 --- a/v2rayN/v2rayN/Views/BackupAndRestoreView.xaml.cs +++ b/v2rayN/v2rayN/Views/BackupAndRestoreView.xaml.cs @@ -18,10 +18,10 @@ namespace v2rayN.Views { this.Bind(ViewModel, vm => vm.OperationMsg, v => v.txtMsg.Text).DisposeWith(disposables); - this.Bind(ViewModel, vm => vm.SelectedSource.url, v => v.txtWebDavUrl.Text).DisposeWith(disposables); - this.Bind(ViewModel, vm => vm.SelectedSource.userName, v => v.txtWebDavUserName.Text).DisposeWith(disposables); - this.Bind(ViewModel, vm => vm.SelectedSource.password, v => v.txtWebDavPassword.Text).DisposeWith(disposables); - this.Bind(ViewModel, vm => vm.SelectedSource.dirName, v => v.txtWebDavDirName.Text).DisposeWith(disposables); + this.Bind(ViewModel, vm => vm.SelectedSource.Url, v => v.txtWebDavUrl.Text).DisposeWith(disposables); + this.Bind(ViewModel, vm => vm.SelectedSource.UserName, v => v.txtWebDavUserName.Text).DisposeWith(disposables); + this.Bind(ViewModel, vm => vm.SelectedSource.Password, v => v.txtWebDavPassword.Text).DisposeWith(disposables); + this.Bind(ViewModel, vm => vm.SelectedSource.DirName, v => v.txtWebDavDirName.Text).DisposeWith(disposables); this.BindCommand(ViewModel, vm => vm.WebDavCheckCmd, v => v.menuWebDavCheck).DisposeWith(disposables); diff --git a/v2rayN/v2rayN/Views/DNSSettingWindow.xaml.cs b/v2rayN/v2rayN/Views/DNSSettingWindow.xaml.cs index 1868fc2e..8a8407ae 100644 --- a/v2rayN/v2rayN/Views/DNSSettingWindow.xaml.cs +++ b/v2rayN/v2rayN/Views/DNSSettingWindow.xaml.cs @@ -50,7 +50,7 @@ namespace v2rayN.Views this.BindCommand(ViewModel, vm => vm.ImportDefConfig4V2rayCmd, v => v.btnImportDefConfig4V2ray).DisposeWith(disposables); this.BindCommand(ViewModel, vm => vm.ImportDefConfig4SingboxCmd, v => v.btnImportDefConfig4Singbox).DisposeWith(disposables); }); - WindowsUtils.SetDarkBorder(this, AppHandler.Instance.Config.uiItem.followSystemTheme ? !WindowsUtils.IsLightTheme() : AppHandler.Instance.Config.uiItem.colorModeDark); + WindowsUtils.SetDarkBorder(this, AppHandler.Instance.Config.UiItem.FollowSystemTheme ? !WindowsUtils.IsLightTheme() : AppHandler.Instance.Config.UiItem.ColorModeDark); } private async Task UpdateViewHandler(EViewAction action, object? obj) diff --git a/v2rayN/v2rayN/Views/GlobalHotkeySettingWindow.xaml.cs b/v2rayN/v2rayN/Views/GlobalHotkeySettingWindow.xaml.cs index 487edd0b..6dc6ee6b 100644 --- a/v2rayN/v2rayN/Views/GlobalHotkeySettingWindow.xaml.cs +++ b/v2rayN/v2rayN/Views/GlobalHotkeySettingWindow.xaml.cs @@ -17,7 +17,7 @@ namespace v2rayN.Views this.Owner = Application.Current.MainWindow; _config = AppHandler.Instance.Config; - _config.globalHotkeys ??= new List(); + _config.GlobalHotkeys ??= new List(); btnReset.Click += btnReset_Click; btnSave.Click += btnSave_Click; @@ -30,7 +30,7 @@ namespace v2rayN.Views HotkeyHandler.Instance.IsPause = true; this.Closing += (s, e) => HotkeyHandler.Instance.IsPause = false; - WindowsUtils.SetDarkBorder(this, _config.uiItem.followSystemTheme ? !WindowsUtils.IsLightTheme() : _config.uiItem.colorModeDark); + WindowsUtils.SetDarkBorder(this, _config.UiItem.FollowSystemTheme ? !WindowsUtils.IsLightTheme() : _config.UiItem.ColorModeDark); InitData(); } @@ -38,11 +38,11 @@ namespace v2rayN.Views { _TextBoxKeyEventItem = new() { - { txtGlobalHotkey0,GetKeyEventItemByEGlobalHotkey(_config.globalHotkeys,EGlobalHotkey.ShowForm) }, - { txtGlobalHotkey1,GetKeyEventItemByEGlobalHotkey(_config.globalHotkeys,EGlobalHotkey.SystemProxyClear) }, - { txtGlobalHotkey2,GetKeyEventItemByEGlobalHotkey(_config.globalHotkeys,EGlobalHotkey.SystemProxySet) }, - { txtGlobalHotkey3,GetKeyEventItemByEGlobalHotkey(_config.globalHotkeys,EGlobalHotkey.SystemProxyUnchanged)}, - { txtGlobalHotkey4,GetKeyEventItemByEGlobalHotkey(_config.globalHotkeys,EGlobalHotkey.SystemProxyPac)} + { txtGlobalHotkey0,GetKeyEventItemByEGlobalHotkey(_config.GlobalHotkeys,EGlobalHotkey.ShowForm) }, + { txtGlobalHotkey1,GetKeyEventItemByEGlobalHotkey(_config.GlobalHotkeys,EGlobalHotkey.SystemProxyClear) }, + { txtGlobalHotkey2,GetKeyEventItemByEGlobalHotkey(_config.GlobalHotkeys,EGlobalHotkey.SystemProxySet) }, + { txtGlobalHotkey3,GetKeyEventItemByEGlobalHotkey(_config.GlobalHotkeys,EGlobalHotkey.SystemProxyUnchanged)}, + { txtGlobalHotkey4,GetKeyEventItemByEGlobalHotkey(_config.GlobalHotkeys,EGlobalHotkey.SystemProxyPac)} }; BindingData(); } @@ -61,9 +61,9 @@ namespace v2rayN.Views private KeyEventItem GetKeyEventItemByEGlobalHotkey(List KEList, EGlobalHotkey eg) { - return JsonUtils.DeepCopy(KEList.Find((it) => it.eGlobalHotkey == eg) ?? new() + return JsonUtils.DeepCopy(KEList.Find((it) => it.EGlobalHotkey == eg) ?? new() { - eGlobalHotkey = eg, + EGlobalHotkey = eg, Control = false, Alt = false, Shift = false, @@ -101,7 +101,7 @@ namespace v2rayN.Views private void btnSave_Click(object sender, RoutedEventArgs e) { - _config.globalHotkeys = _TextBoxKeyEventItem.Values.ToList(); + _config.GlobalHotkeys = _TextBoxKeyEventItem.Values.ToList(); if ( ConfigHandler.SaveConfig(_config, false).Result == 0) { diff --git a/v2rayN/v2rayN/Views/MainWindow.xaml.cs b/v2rayN/v2rayN/Views/MainWindow.xaml.cs index d5b61a5c..aab6877d 100644 --- a/v2rayN/v2rayN/Views/MainWindow.xaml.cs +++ b/v2rayN/v2rayN/Views/MainWindow.xaml.cs @@ -41,7 +41,7 @@ namespace v2rayN.Views Locator.CurrentMutable.RegisterLazySingleton(() => ViewModel, typeof(MainWindowViewModel)); WindowsHandler.Instance.RegisterGlobalHotkey(_config, OnHotkeyHandler, null); - switch (_config.uiItem.mainGirdOrientation) + switch (_config.UiItem.MainGirdOrientation) { case EGirdOrientation.Horizontal: tabProfiles.Content ??= new ProfilesView(); @@ -105,7 +105,7 @@ namespace v2rayN.Views this.BindCommand(ViewModel, vm => vm.ReloadCmd, v => v.menuReload).DisposeWith(disposables); this.OneWayBind(ViewModel, vm => vm.BlReloadEnabled, v => v.menuReload.IsEnabled).DisposeWith(disposables); - switch (_config.uiItem.mainGirdOrientation) + switch (_config.UiItem.MainGirdOrientation) { case EGirdOrientation.Horizontal: gridMain.Visibility = Visibility.Visible; @@ -135,7 +135,7 @@ namespace v2rayN.Views this.Title = $"{Utils.GetVersion()} - {(AppHandler.Instance.IsAdministrator ? ResUI.RunAsAdmin : ResUI.NotRunAsAdmin)}"; - if (!_config.guiItem.enableHWA) + if (!_config.GuiItem.EnableHWA) { RenderOptions.ProcessRenderMode = RenderMode.SoftwareOnly; } @@ -362,7 +362,7 @@ namespace v2rayN.Views public void ShowHideWindow(bool? blShow) { - var bl = blShow ?? !_config.uiItem.showInTaskbar; + var bl = blShow ?? !_config.UiItem.ShowInTaskbar; if (bl) { Application.Current.MainWindow.Show(); @@ -377,50 +377,50 @@ namespace v2rayN.Views { Application.Current.MainWindow.Hide(); } - _config.uiItem.showInTaskbar = bl; + _config.UiItem.ShowInTaskbar = bl; } private void RestoreUI() { - if (_config.uiItem.mainWidth > 0 && _config.uiItem.mainHeight > 0) + if (_config.UiItem.MainWidth > 0 && _config.UiItem.MainHeight > 0) { - Width = _config.uiItem.mainWidth; - Height = _config.uiItem.mainHeight; + Width = _config.UiItem.MainWidth; + Height = _config.UiItem.MainHeight; } var maxWidth = SystemParameters.WorkArea.Width; var maxHeight = SystemParameters.WorkArea.Height; if (Width > maxWidth) Width = maxWidth; if (Height > maxHeight) Height = maxHeight; - if (_config.uiItem.mainGirdHeight1 > 0 && _config.uiItem.mainGirdHeight2 > 0) + if (_config.UiItem.MainGirdHeight1 > 0 && _config.UiItem.MainGirdHeight2 > 0) { - if (_config.uiItem.mainGirdOrientation == EGirdOrientation.Horizontal) + if (_config.UiItem.MainGirdOrientation == EGirdOrientation.Horizontal) { - gridMain.ColumnDefinitions[0].Width = new GridLength(_config.uiItem.mainGirdHeight1, GridUnitType.Star); - gridMain.ColumnDefinitions[2].Width = new GridLength(_config.uiItem.mainGirdHeight2, GridUnitType.Star); + gridMain.ColumnDefinitions[0].Width = new GridLength(_config.UiItem.MainGirdHeight1, GridUnitType.Star); + gridMain.ColumnDefinitions[2].Width = new GridLength(_config.UiItem.MainGirdHeight2, GridUnitType.Star); } - else if (_config.uiItem.mainGirdOrientation == EGirdOrientation.Vertical) + else if (_config.UiItem.MainGirdOrientation == EGirdOrientation.Vertical) { - gridMain1.RowDefinitions[0].Height = new GridLength(_config.uiItem.mainGirdHeight1, GridUnitType.Star); - gridMain1.RowDefinitions[2].Height = new GridLength(_config.uiItem.mainGirdHeight2, GridUnitType.Star); + gridMain1.RowDefinitions[0].Height = new GridLength(_config.UiItem.MainGirdHeight1, GridUnitType.Star); + gridMain1.RowDefinitions[2].Height = new GridLength(_config.UiItem.MainGirdHeight2, GridUnitType.Star); } } } private void StorageUI() { - _config.uiItem.mainWidth = Utils.ToInt(this.Width); - _config.uiItem.mainHeight = Utils.ToInt(this.Height); + _config.UiItem.MainWidth = Utils.ToInt(this.Width); + _config.UiItem.MainHeight = Utils.ToInt(this.Height); - if (_config.uiItem.mainGirdOrientation == EGirdOrientation.Horizontal) + if (_config.UiItem.MainGirdOrientation == EGirdOrientation.Horizontal) { - _config.uiItem.mainGirdHeight1 = Math.Ceiling(gridMain.ColumnDefinitions[0].ActualWidth + 0.1); - _config.uiItem.mainGirdHeight2 = Math.Ceiling(gridMain.ColumnDefinitions[2].ActualWidth + 0.1); + _config.UiItem.MainGirdHeight1 = Math.Ceiling(gridMain.ColumnDefinitions[0].ActualWidth + 0.1); + _config.UiItem.MainGirdHeight2 = Math.Ceiling(gridMain.ColumnDefinitions[2].ActualWidth + 0.1); } - else if (_config.uiItem.mainGirdOrientation == EGirdOrientation.Vertical) + else if (_config.UiItem.MainGirdOrientation == EGirdOrientation.Vertical) { - _config.uiItem.mainGirdHeight1 = Math.Ceiling(gridMain1.RowDefinitions[0].ActualHeight + 0.1); - _config.uiItem.mainGirdHeight2 = Math.Ceiling(gridMain1.RowDefinitions[2].ActualHeight + 0.1); + _config.UiItem.MainGirdHeight1 = Math.Ceiling(gridMain1.RowDefinitions[0].ActualHeight + 0.1); + _config.UiItem.MainGirdHeight2 = Math.Ceiling(gridMain1.RowDefinitions[2].ActualHeight + 0.1); } } diff --git a/v2rayN/v2rayN/Views/OptionSettingWindow.xaml.cs b/v2rayN/v2rayN/Views/OptionSettingWindow.xaml.cs index ba62351c..5a1e1b3f 100644 --- a/v2rayN/v2rayN/Views/OptionSettingWindow.xaml.cs +++ b/v2rayN/v2rayN/Views/OptionSettingWindow.xaml.cs @@ -26,7 +26,7 @@ namespace v2rayN.Views { clbdestOverride.Items.Add(it); }); - _config.inbound[0].destOverride?.ForEach(it => + _config.Inbound[0].DestOverride?.ForEach(it => { clbdestOverride.SelectedItems.Add(it); }); @@ -180,7 +180,7 @@ namespace v2rayN.Views this.BindCommand(ViewModel, vm => vm.SaveCmd, v => v.btnSave).DisposeWith(disposables); }); - WindowsUtils.SetDarkBorder(this, AppHandler.Instance.Config.uiItem.followSystemTheme ? !WindowsUtils.IsLightTheme() : AppHandler.Instance.Config.uiItem.colorModeDark); + WindowsUtils.SetDarkBorder(this, AppHandler.Instance.Config.UiItem.FollowSystemTheme ? !WindowsUtils.IsLightTheme() : AppHandler.Instance.Config.UiItem.ColorModeDark); } private async Task UpdateViewHandler(EViewAction action, object? obj) @@ -206,7 +206,7 @@ namespace v2rayN.Views { files.AddRange(Directory.GetFiles(path, pattern)); } - var culture = _config.uiItem.currentLanguage == Global.Languages[0] ? "zh-cn" : "en-us"; + var culture = _config.UiItem.CurrentLanguage == Global.Languages[0] ? "zh-cn" : "en-us"; var culture2 = "en-us"; foreach (var ttf in files) { diff --git a/v2rayN/v2rayN/Views/ProfilesView.xaml.cs b/v2rayN/v2rayN/Views/ProfilesView.xaml.cs index de1dc7e4..23459fc1 100644 --- a/v2rayN/v2rayN/Views/ProfilesView.xaml.cs +++ b/v2rayN/v2rayN/Views/ProfilesView.xaml.cs @@ -32,7 +32,7 @@ namespace v2rayN.Views lstProfiles.LoadingRow += LstProfiles_LoadingRow; menuSelectAll.Click += menuSelectAll_Click; - if (_config.uiItem.enableDragDropSort) + if (_config.UiItem.EnableDragDropSort) { lstProfiles.AllowDrop = true; lstProfiles.PreviewMouseLeftButtonDown += LstProfiles_PreviewMouseLeftButtonDown; @@ -195,7 +195,7 @@ namespace v2rayN.Views private void LstProfiles_MouseDoubleClick(object sender, MouseButtonEventArgs e) { - if (_config.uiItem.doubleClick2Activate) + if (_config.UiItem.DoubleClick2Activate) { ViewModel?.SetDefaultServer(); } @@ -321,7 +321,7 @@ namespace v2rayN.Views private void RestoreUI() { - var lvColumnItem = _config.uiItem.mainColumnItem.OrderBy(t => t.Index).ToList(); + var lvColumnItem = _config.UiItem.MainColumnItem.OrderBy(t => t.Index).ToList(); var displayIndex = 0; foreach (var item in lvColumnItem) { @@ -340,7 +340,7 @@ namespace v2rayN.Views } if (item.Name.StartsWith("to")) { - if (!_config.guiItem.enableStatistics) + if (!_config.GuiItem.EnableStatistics) { item2.Visibility = Visibility.Hidden; } @@ -363,7 +363,7 @@ namespace v2rayN.Views Index = item2.DisplayIndex }); } - _config.uiItem.mainColumnItem = lvColumnItem; + _config.UiItem.MainColumnItem = lvColumnItem; ConfigHandler.SaveConfig(_config); } diff --git a/v2rayN/v2rayN/Views/RoutingRuleDetailsWindow.xaml.cs b/v2rayN/v2rayN/Views/RoutingRuleDetailsWindow.xaml.cs index c5069638..48cc8121 100644 --- a/v2rayN/v2rayN/Views/RoutingRuleDetailsWindow.xaml.cs +++ b/v2rayN/v2rayN/Views/RoutingRuleDetailsWindow.xaml.cs @@ -58,7 +58,7 @@ namespace v2rayN.Views this.BindCommand(ViewModel, vm => vm.SaveCmd, v => v.btnSave).DisposeWith(disposables); }); - WindowsUtils.SetDarkBorder(this, AppHandler.Instance.Config.uiItem.followSystemTheme ? !WindowsUtils.IsLightTheme() : AppHandler.Instance.Config.uiItem.colorModeDark); + WindowsUtils.SetDarkBorder(this, AppHandler.Instance.Config.UiItem.FollowSystemTheme ? !WindowsUtils.IsLightTheme() : AppHandler.Instance.Config.UiItem.ColorModeDark); } private async Task UpdateViewHandler(EViewAction action, object? obj) diff --git a/v2rayN/v2rayN/Views/RoutingRuleSettingWindow.xaml.cs b/v2rayN/v2rayN/Views/RoutingRuleSettingWindow.xaml.cs index 0423341e..5c1dcbff 100644 --- a/v2rayN/v2rayN/Views/RoutingRuleSettingWindow.xaml.cs +++ b/v2rayN/v2rayN/Views/RoutingRuleSettingWindow.xaml.cs @@ -60,7 +60,7 @@ namespace v2rayN.Views this.BindCommand(ViewModel, vm => vm.SaveCmd, v => v.btnSave).DisposeWith(disposables); }); - WindowsUtils.SetDarkBorder(this, AppHandler.Instance.Config.uiItem.followSystemTheme ? !WindowsUtils.IsLightTheme() : AppHandler.Instance.Config.uiItem.colorModeDark); + WindowsUtils.SetDarkBorder(this, AppHandler.Instance.Config.UiItem.FollowSystemTheme ? !WindowsUtils.IsLightTheme() : AppHandler.Instance.Config.UiItem.ColorModeDark); } private async Task UpdateViewHandler(EViewAction action, object? obj) diff --git a/v2rayN/v2rayN/Views/RoutingSettingWindow.xaml.cs b/v2rayN/v2rayN/Views/RoutingSettingWindow.xaml.cs index ee8adcd0..22532d24 100644 --- a/v2rayN/v2rayN/Views/RoutingSettingWindow.xaml.cs +++ b/v2rayN/v2rayN/Views/RoutingSettingWindow.xaml.cs @@ -66,7 +66,7 @@ namespace v2rayN.Views this.BindCommand(ViewModel, vm => vm.SaveCmd, v => v.btnSave).DisposeWith(disposables); }); - WindowsUtils.SetDarkBorder(this, AppHandler.Instance.Config.uiItem.followSystemTheme ? !WindowsUtils.IsLightTheme() : AppHandler.Instance.Config.uiItem.colorModeDark); + WindowsUtils.SetDarkBorder(this, AppHandler.Instance.Config.UiItem.FollowSystemTheme ? !WindowsUtils.IsLightTheme() : AppHandler.Instance.Config.UiItem.ColorModeDark); } private async Task UpdateViewHandler(EViewAction action, object? obj) diff --git a/v2rayN/v2rayN/Views/SubEditWindow.xaml.cs b/v2rayN/v2rayN/Views/SubEditWindow.xaml.cs index f23081e6..17c01549 100644 --- a/v2rayN/v2rayN/Views/SubEditWindow.xaml.cs +++ b/v2rayN/v2rayN/Views/SubEditWindow.xaml.cs @@ -37,7 +37,7 @@ namespace v2rayN.Views this.BindCommand(ViewModel, vm => vm.SaveCmd, v => v.btnSave).DisposeWith(disposables); }); - WindowsUtils.SetDarkBorder(this, AppHandler.Instance.Config.uiItem.followSystemTheme ? !WindowsUtils.IsLightTheme() : AppHandler.Instance.Config.uiItem.colorModeDark); + WindowsUtils.SetDarkBorder(this, AppHandler.Instance.Config.UiItem.FollowSystemTheme ? !WindowsUtils.IsLightTheme() : AppHandler.Instance.Config.UiItem.ColorModeDark); } private async Task UpdateViewHandler(EViewAction action, object? obj) diff --git a/v2rayN/v2rayN/Views/SubSettingWindow.xaml.cs b/v2rayN/v2rayN/Views/SubSettingWindow.xaml.cs index 472c8b60..e099cc6a 100644 --- a/v2rayN/v2rayN/Views/SubSettingWindow.xaml.cs +++ b/v2rayN/v2rayN/Views/SubSettingWindow.xaml.cs @@ -31,7 +31,7 @@ namespace v2rayN.Views this.BindCommand(ViewModel, vm => vm.SubEditCmd, v => v.menuSubEdit).DisposeWith(disposables); this.BindCommand(ViewModel, vm => vm.SubShareCmd, v => v.menuSubShare).DisposeWith(disposables); }); - WindowsUtils.SetDarkBorder(this, AppHandler.Instance.Config.uiItem.followSystemTheme ? !WindowsUtils.IsLightTheme() : AppHandler.Instance.Config.uiItem.colorModeDark); + WindowsUtils.SetDarkBorder(this, AppHandler.Instance.Config.UiItem.FollowSystemTheme ? !WindowsUtils.IsLightTheme() : AppHandler.Instance.Config.UiItem.ColorModeDark); } private async Task UpdateViewHandler(EViewAction action, object? obj)