diff --git a/src/MaaWpfGui/Main/AsstProxy.cs b/src/MaaWpfGui/Main/AsstProxy.cs index e715be335c..4eced374dd 100644 --- a/src/MaaWpfGui/Main/AsstProxy.cs +++ b/src/MaaWpfGui/Main/AsstProxy.cs @@ -1057,7 +1057,7 @@ namespace MaaWpfGui.Main allDrops += "\n"; } - allDrops = allDrops.EndsWith("\n") ? allDrops.TrimEnd('\n') : LocalizationHelper.GetString("NoDrop"); + allDrops = allDrops.EndsWith('\n') ? allDrops.TrimEnd('\n') : LocalizationHelper.GetString("NoDrop"); Instances.TaskQueueViewModel.AddLog(LocalizationHelper.GetString("TotalDrop") + "\n" + allDrops + (curTimes >= 0 ? $"\n{LocalizationHelper.GetString("CurTimes")} : {curTimes}" : string.Empty)); break; @@ -1085,7 +1085,7 @@ namespace MaaWpfGui.Main string logContent = tags.Select(tagName => tagName.ToString()) .Aggregate(string.Empty, (current, tagStr) => current + (tagStr + "\n")); - logContent = logContent.EndsWith("\n") ? logContent.TrimEnd('\n') : LocalizationHelper.GetString("Error"); + logContent = logContent.EndsWith('\n') ? logContent.TrimEnd('\n') : LocalizationHelper.GetString("Error"); Instances.TaskQueueViewModel.AddLog(LocalizationHelper.GetString("RecruitingResults") + "\n" + logContent); break; @@ -1152,7 +1152,7 @@ namespace MaaWpfGui.Main var selected = (JArray)subTaskDetails["tags"] ?? new(); string selectedLog = selected.Aggregate(string.Empty, (current, tag) => current + (tag + "\n")); - selectedLog = selectedLog.EndsWith("\n") ? selectedLog.TrimEnd('\n') : LocalizationHelper.GetString("NoDrop"); + selectedLog = selectedLog.EndsWith('\n') ? selectedLog.TrimEnd('\n') : LocalizationHelper.GetString("NoDrop"); Instances.TaskQueueViewModel.AddLog(LocalizationHelper.GetString("Choose") + " Tags:\n" + selectedLog); @@ -1187,7 +1187,6 @@ namespace MaaWpfGui.Main Instances.TaskQueueViewModel.AddLog(string.Format(LocalizationHelper.GetString("RoguelikeInvestment"), subTaskDetails["count"], subTaskDetails["total"], subTaskDetails["deposit"]), UiLogColor.Info); break; - case "RoguelikeSettlement": // 肉鸽结算 bool roguelikeGamePass = (bool)subTaskDetails["game_pass"]; @@ -1456,7 +1455,7 @@ namespace MaaWpfGui.Main /// 是否有效。 private static bool IfPortEstablished(string address) { - if (string.IsNullOrEmpty(address) || !address.Contains(":")) + if (string.IsNullOrEmpty(address) || !address.Contains(':')) { return false; } @@ -1515,7 +1514,7 @@ namespace MaaWpfGui.Main // tcp连接测试端口是否有效,超时时间500ms // 如果是本地设备,没有冒号 bool adbResult = - (!Instances.SettingsViewModel.ConnectAddress.Contains(":") && + (!Instances.SettingsViewModel.ConnectAddress.Contains(':') && !string.IsNullOrEmpty(Instances.SettingsViewModel.ConnectAddress)) || IfPortEstablished(Instances.SettingsViewModel.ConnectAddress); bool bsResult = IfPortEstablished(bsHvAddress); diff --git a/src/MaaWpfGui/ViewModels/UI/CopilotViewModel.cs b/src/MaaWpfGui/ViewModels/UI/CopilotViewModel.cs index bc18934a1e..37a178f557 100644 --- a/src/MaaWpfGui/ViewModels/UI/CopilotViewModel.cs +++ b/src/MaaWpfGui/ViewModels/UI/CopilotViewModel.cs @@ -43,7 +43,7 @@ namespace MaaWpfGui.ViewModels.UI { private readonly RunningState _runningState; private static readonly ILogger _logger = Log.ForContext(); - private List _copilotIdList = new List(); // 用于保存作业列表中的作业的Id,对于同一个作业,只有都执行成功才点赞 + private List _copilotIdList = new(); // 用于保存作业列表中的作业的Id,对于同一个作业,只有都执行成功才点赞 /// /// Gets the view models of log items. @@ -500,7 +500,7 @@ namespace MaaWpfGui.ViewModels.UI return; } - var fileName = fileInfo.Name.Substring(0, fileInfo.Name.Length - fileInfo.Extension.Length); + var fileName = fileInfo.Name[..^fileInfo.Extension.Length]; var stageName = FindStageName(fileName); if (string.IsNullOrEmpty(stageName)) @@ -601,7 +601,7 @@ namespace MaaWpfGui.ViewModels.UI // ReSharper disable once UnusedParameter.Global public void OnDropDownOpened(object sender, EventArgs e) { - if (!(sender is ComboBox comboBox)) + if (sender is not ComboBox comboBox) { return; } @@ -1005,7 +1005,7 @@ namespace MaaWpfGui.ViewModels.UI private bool _isVideoTask; - private readonly List _recentlyRatedCopilotId = new List(); // TODO: 可能考虑加个持久化 + private readonly List _recentlyRatedCopilotId = new(); // TODO: 可能考虑加个持久化 private bool _couldLikeWebJson; @@ -1133,7 +1133,7 @@ namespace MaaWpfGui.ViewModels.UI // ReSharper disable once UnusedParameter.Global public void MouseDown(object sender, MouseButtonEventArgs e) { - if (!(sender is UIElement element)) + if (sender is not UIElement element) { return; } @@ -1156,7 +1156,7 @@ namespace MaaWpfGui.ViewModels.UI return; } - if (!(sender is UIElement element)) + if (sender is not UIElement element) { return; }