chore: format & nullable

[skip changelog]
This commit is contained in:
status102
2024-11-22 21:44:20 +08:00
parent 89fe3ddcc2
commit 47d8b0f604
10 changed files with 42 additions and 22 deletions

View File

@@ -1,5 +1,4 @@
// <copyright file="GUI.cs" company="MaaAssistantArknights">
// <copyright file="GUI.cs" company="MaaAssistantArknights">
// MaaWpfGui - A part of the MaaCoreArknights project
// Copyright (C) 2021 MistEO and Contributors
//

View File

@@ -48,5 +48,4 @@ public class NotificationHint
public static NotificationHint RowCount(int rowCount) => new NotificationHintRowCount(rowCount);
public static NotificationHint ExpirationTime(TimeSpan value) => new NotificationHintExpirationTime(value);
}

View File

@@ -30,7 +30,8 @@ internal class NotificationImplWinRT : INotificationPoster, IDisposable
public void Dispose()
{
ToastNotificationManagerCompat.OnActivated -= OnWinRTActivated;
//ToastNotificationManagerCompat.History.Clear();
// ToastNotificationManagerCompat.History.Clear();
}
private void OnWinRTActivated(ToastNotificationActivatedEventArgsCompat args)

View File

@@ -389,7 +389,7 @@ namespace MaaWpfGui.Main
var jsonStr = PtrToStringCustom(jsonBuffer, Encoding.UTF8);
// Console.WriteLine(json_str);
var json = (JObject?)JsonConvert.DeserializeObject(jsonStr);
var json = (JObject?)JsonConvert.DeserializeObject(jsonStr ?? string.Empty);
MaaService.ProcCallbackMsg dlg = ProcMsg;
Execute.OnUIThread(
() =>
@@ -458,8 +458,8 @@ namespace MaaWpfGui.Main
{
case "Connected":
Connected = true;
_connectedAdb = details["details"]?["adb"]?.ToString();
_connectedAddress = details["details"]?["address"]?.ToString();
_connectedAdb = details["details"]!["adb"]!.ToString();
_connectedAddress = details["details"]!["address"]!.ToString();
SettingsViewModel.ConnectSettings.ConnectAddress = _connectedAddress;
break;
@@ -1030,7 +1030,7 @@ namespace MaaWpfGui.Main
case "ReportToPenguinStats":
{
var why = details!["why"].ToString();
var why = details!["why"]!.ToString();
Instances.TaskQueueViewModel.AddLog(why + "" + LocalizationHelper.GetString("GiveUpUploadingPenguins"), UiLogColor.Error);
break;
}
@@ -1069,8 +1069,8 @@ namespace MaaWpfGui.Main
{
case "ProcessTask":
{
string taskName = details!["details"]?["task"]?.ToString();
int execTimes = (int)details["details"]["exec_times"];
string taskName = details!["details"]!["task"]!.ToString();
int execTimes = (int)details!["details"]!["exec_times"]!;
switch (taskName)
{
@@ -1318,7 +1318,7 @@ namespace MaaWpfGui.Main
case "RecruitSpecialTag":
{
string special = subTaskDetails!["tag"]?.ToString();
string special = subTaskDetails!["tag"]!.ToString();
if (special == "支援机械" && Instances.SettingsViewModel.NotChooseLevel1 == false)
{
break;
@@ -1332,7 +1332,7 @@ namespace MaaWpfGui.Main
case "RecruitRobotTag":
{
string special = subTaskDetails!["tag"]?.ToString();
string special = subTaskDetails!["tag"]!.ToString();
using var toast = new ToastNotification(LocalizationHelper.GetString("RecruitingTips"));
toast.AppendContentText(special).ShowRecruitRobot();
@@ -1381,7 +1381,7 @@ namespace MaaWpfGui.Main
case "RecruitTagsSelected":
{
var selected = subTaskDetails["tags"] ?? new JArray();
var selected = subTaskDetails!["tags"] ?? new JArray();
string selectedLog = selected.Aggregate(string.Empty, (current, tag) => current + (tag + "\n"));
selectedLog = selectedLog.EndsWith('\n') ? selectedLog.TrimEnd('\n') : LocalizationHelper.GetString("NoDrop");
@@ -1674,7 +1674,7 @@ namespace MaaWpfGui.Main
break;
case "AccountSwitch":
Instances.TaskQueueViewModel.AddLog(LocalizationHelper.GetString("AccountSwitch") + $" -->> {subTaskDetails["account_name"]}", UiLogColor.Info); // subTaskDetails!["current_account"]
Instances.TaskQueueViewModel.AddLog(LocalizationHelper.GetString("AccountSwitch") + $" -->> {subTaskDetails!["account_name"]}", UiLogColor.Info); // subTaskDetails!["current_account"]
break;
case "RoguelikeCollapsalParadigms":
string deepen_or_weaken_str = subTaskDetails!["deepen_or_weaken"]?.ToString() ?? "Unknown";
@@ -1933,7 +1933,7 @@ namespace MaaWpfGui.Main
private AsstTaskId AsstAppendTaskWithEncoding(string type, JObject? taskParams = null)
{
taskParams ??= new();
taskParams ??= [];
return AsstAppendTask(_handle, type, JsonConvert.SerializeObject(taskParams));
}
@@ -1944,7 +1944,7 @@ namespace MaaWpfGui.Main
return false;
}
taskParams ??= new();
taskParams ??= [];
return AsstSetTaskParams(_handle, id, JsonConvert.SerializeObject(taskParams));
}

View File

@@ -25,10 +25,10 @@ namespace MaaWpfGui.Utilities
private static extern bool ExitWindowsEx(uint uFlags, uint dwReason);
[DllImport("advapi32.dll", SetLastError = true)]
private static extern bool AdjustTokenPrivileges(IntPtr TokenHandle, bool DisableAllPrivileges, ref TOKEN_PRIVILEGES NewState, uint BufferLengthInBytes, IntPtr PreviousState, IntPtr ReturnLengthInBytes);
private static extern bool AdjustTokenPrivileges(IntPtr tokenHandle, bool disableAllPrivileges, ref TOKEN_PRIVILEGES newState, uint bufferLengthInBytes, IntPtr PreviousState, IntPtr ReturnLengthInBytes);
[DllImport("advapi32.dll", SetLastError = true)]
private static extern bool OpenProcessToken(IntPtr ProcessHandle, uint DesiredAccess, out IntPtr TokenHandle);
private static extern bool OpenProcessToken(IntPtr processHandle, uint desiredAccess, out IntPtr tokenHandle);
[DllImport("kernel32.dll", SetLastError = true)]
private static extern IntPtr GetCurrentProcess();

View File

@@ -795,7 +795,7 @@ namespace MaaWpfGui.ViewModels.UI
/// <summary>
/// Gets or sets the list of divider vertical offset.
/// </summary>
public List<double> DividerVerticalOffsetList { get; set; } = new();
public List<double> DividerVerticalOffsetList { get; set; } = [];
private int _selectedIndex;

View File

@@ -1631,7 +1631,7 @@ namespace MaaWpfGui.ViewModels.UI
{
var order = Instances.SettingsViewModel.GetInfrastOrderList();
Instances.AsstProxy.AsstSetInfrastTaskParams(
order.ToArray(),
order,
Instances.SettingsViewModel.UsesOfDrones,
Instances.SettingsViewModel.ContinueTraining,
Instances.SettingsViewModel.DormThreshold / 100.0,
@@ -1653,7 +1653,7 @@ namespace MaaWpfGui.ViewModels.UI
var order = Instances.SettingsViewModel.GetInfrastOrderList();
return Instances.AsstProxy.AsstAppendInfrast(
order.ToArray(),
order,
Instances.SettingsViewModel.UsesOfDrones,
Instances.SettingsViewModel.ContinueTraining,
Instances.SettingsViewModel.DormThreshold / 100.0,

View File

@@ -1,3 +1,16 @@
// <copyright file="GameSettingsUserControlModel.cs" company="MaaAssistantArknights">
// MaaWpfGui - A part of the MaaCoreArknights project
// Copyright (C) 2021 MistEO and Contributors
//
// This program is free software: you can redistribute it and/or modify
// it under the terms of the GNU Affero General Public License v3.0 only as published by
// the Free Software Foundation, either version 3 of the License, or
// any later version.
//
// This program is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY
// </copyright>
#nullable enable
using System.Collections.Generic;
using MaaWpfGui.Constants;

View File

@@ -1,4 +1,4 @@
// <copyright file="MaaWineBridge.cs" company="MaaAssistantArknights">
// <copyright file="MaaDesktopIntegration.cs" company="MaaAssistantArknights">
// MaaWpfGui - A part of the MaaCoreArknights project
// Copyright (C) 2021 MistEO and Contributors
//

View File

@@ -1,6 +1,14 @@
// <copyright file="WineBridgeAvailability.cs" company="MaaAssistantArknights">
// MaaWpfGui - A part of the MAA project
// MaaWpfGui - A part of the MaaCoreArknights project
// Copyright (C) 2021 MistEO and Contributors
//
// This program is free software: you can redistribute it and/or modify
// it under the terms of the GNU Affero General Public License v3.0 only as published by
// the Free Software Foundation, either version 3 of the License, or
// any later version.
//
// This program is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY
// </copyright>
public enum WineBridgeAvailability