mirror of
https://github.com/MaaAssistantArknights/MaaAssistantArknights.git
synced 2026-07-19 10:32:19 +08:00
feat: 保存除关机和休眠外的其他完成后选项
https://github.com/MaaAssistantArknights/MaaAssistantArknights/issues/1001 https://github.com/MaaAssistantArknights/MaaAssistantArknights/issues/989
This commit is contained in:
@@ -33,15 +33,28 @@ namespace MeoAsstGui
|
||||
public ObservableCollection<DragItemViewModel> TaskItemViewModels { get; set; }
|
||||
public ObservableCollection<LogItemViewModel> LogItemViewModels { get; set; }
|
||||
|
||||
private ActionType _actionAfterComplated = ActionType.DoNothing;
|
||||
private string _actionAfterComplated = ViewStatusStorage.Get("MainFunction.ActionAfterComplated", ActionType.DoNothing.ToString());
|
||||
public List<GenericCombData<ActionType>> ActionAfterCompletedList { get; set; }
|
||||
|
||||
public ActionType ActionAfterCompleted
|
||||
{
|
||||
get { return _actionAfterComplated; }
|
||||
get
|
||||
{
|
||||
if (ActionType.TryParse(_actionAfterComplated, out ActionType action))
|
||||
{
|
||||
return action;
|
||||
}
|
||||
return ActionType.DoNothing;
|
||||
}
|
||||
set
|
||||
{
|
||||
SetAndNotify(ref _actionAfterComplated, value);
|
||||
SetAndNotify(ref _actionAfterComplated, value.ToString());
|
||||
string storeValue = ActionType.DoNothing.ToString();
|
||||
if (value != ActionType.Shutdown && value != ActionType.Hibernate)
|
||||
{
|
||||
storeValue = value.ToString();
|
||||
}
|
||||
ViewStatusStorage.Set("MainFunction.ActionAfterComplated", storeValue);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -633,63 +646,41 @@ namespace MeoAsstGui
|
||||
var asstProxy = _container.Get<AsstProxy>();
|
||||
if (!asstProxy.AsstStartCloseDown())
|
||||
{
|
||||
Execute.OnUIThread(() =>
|
||||
{
|
||||
using (var toast = new ToastNotification("游戏关闭失败"))
|
||||
{
|
||||
toast.AppendContentText("请手动关闭游戏")
|
||||
.Show(lifeTime: 5, row: 2);
|
||||
}
|
||||
});
|
||||
AddLog("关闭游戏失败", "DarkRed");
|
||||
}
|
||||
break;
|
||||
|
||||
case ActionType.ExitSelf:
|
||||
if (!new ToastNotification().CheckToastSystem())
|
||||
if (new ToastNotification().CheckToastSystem())
|
||||
{
|
||||
Environment.Exit(0); //不使用系统通知的情况下exit会关闭通知窗口
|
||||
ToastNotificationManagerCompat.History.Clear(); //exit似乎不会走bootstapper,单独清一下通知
|
||||
}
|
||||
else ToastNotificationManagerCompat.History.Clear(); //exit似乎不会走bootstapper,单独清一下通知
|
||||
Environment.Exit(0);
|
||||
break;
|
||||
|
||||
case ActionType.ExitEmulator:
|
||||
if (!killemulator())
|
||||
Execute.OnUIThread(() =>
|
||||
{
|
||||
using (var toast = new ToastNotification("模拟器关闭失败"))
|
||||
{
|
||||
toast.AppendContentText("请手动关闭模拟器")
|
||||
.Show(lifeTime: 5, row: 2);
|
||||
}
|
||||
});
|
||||
{
|
||||
AddLog("模拟器关闭失败", "DarkRed");
|
||||
}
|
||||
break;
|
||||
|
||||
case ActionType.ExitEmulatorAndSelf:
|
||||
if (!killemulator())
|
||||
{
|
||||
Execute.OnUIThread(() =>
|
||||
{
|
||||
using (var toast = new ToastNotification("模拟器关闭失败"))
|
||||
{
|
||||
toast.AppendContentText("请手动关闭模拟器及关闭助手")
|
||||
.Show(lifeTime: 5, row: 2);
|
||||
}
|
||||
});
|
||||
break;
|
||||
AddLog("模拟器关闭失败", "DarkRed");
|
||||
}
|
||||
if (!new ToastNotification().CheckToastSystem())
|
||||
if (new ToastNotification().CheckToastSystem())
|
||||
{
|
||||
Environment.Exit(0); //不使用系统通知的情况下exit会关闭通知窗口
|
||||
ToastNotificationManagerCompat.History.Clear(); //exit似乎不会走bootstapper,单独清一下通知
|
||||
}
|
||||
else ToastNotificationManagerCompat.History.Clear(); //exit似乎不会走bootstapper,单独清一下通知
|
||||
Environment.Exit(0);
|
||||
break;
|
||||
|
||||
case ActionType.Shutdown:
|
||||
System.Diagnostics.Process.Start("shutdown.exe", "-s -t 60");
|
||||
var result = _windowManager.ShowMessageBox("已刷完,即将关机,是否取消?", "提示", MessageBoxButton.OK, MessageBoxImage.Question);
|
||||
if (result == MessageBoxResult.OK)
|
||||
var shutdownResult = _windowManager.ShowMessageBox("已刷完,即将关机,是否取消?", "提示", MessageBoxButton.OK, MessageBoxImage.Question);
|
||||
if (shutdownResult == MessageBoxResult.OK)
|
||||
{
|
||||
System.Diagnostics.Process.Start("shutdown.exe", "-a");
|
||||
}
|
||||
@@ -702,7 +693,12 @@ namespace MeoAsstGui
|
||||
break;
|
||||
|
||||
case ActionType.Hibernate:
|
||||
System.Diagnostics.Process.Start("shutdown.exe", "-h");
|
||||
System.Diagnostics.Process.Start("shutdown.exe", "-h -t 60");
|
||||
var hibernateResult = _windowManager.ShowMessageBox("已刷完,即将休眠,是否取消?", "提示", MessageBoxButton.OK, MessageBoxImage.Question);
|
||||
if (hibernateResult == MessageBoxResult.OK)
|
||||
{
|
||||
System.Diagnostics.Process.Start("shutdown.exe", "-a");
|
||||
}
|
||||
break;
|
||||
|
||||
default:
|
||||
|
||||
Reference in New Issue
Block a user