mirror of
https://github.com/MaaAssistantArknights/MaaAssistantArknights.git
synced 2026-07-18 18:20:39 +08:00
@@ -138,6 +138,7 @@
|
||||
<Compile Include="UserControl\VersionUpdateSettingsUserControl.xaml.cs">
|
||||
<DependentUpon>VersionUpdateSettingsUserControl.xaml</DependentUpon>
|
||||
</Compile>
|
||||
<Compile Include="ViewModels\StartAppModel.cs" />
|
||||
<Compile Include="ViewModels\RecruitViewModel.cs" />
|
||||
<Compile Include="ViewModels\RootViewModel.cs" />
|
||||
<Compile Include="ViewModels\CopilotViewModel.cs" />
|
||||
|
||||
@@ -14,8 +14,11 @@
|
||||
<RowDefinition />
|
||||
<RowDefinition />
|
||||
</Grid.RowDefinitions>
|
||||
<CheckBox Grid.Row="0" IsChecked="{Binding StartGameEnable}" Block.TextAlignment="Center" Margin="10"
|
||||
HorizontalAlignment="Center" VerticalAlignment="Center"
|
||||
<CheckBox Grid.Row="0" IsChecked="{Binding StartAppEnable}" Block.TextAlignment="Center" Margin="0,10,0,0"
|
||||
HorizontalAlignment="Center" VerticalAlignment="Top"
|
||||
Content="开机时自动启动助手" />
|
||||
<CheckBox Grid.Row="0" IsChecked="{Binding StartGameEnable}" Block.TextAlignment="Center" Margin="0,30,0,0"
|
||||
HorizontalAlignment="Center" VerticalAlignment="Top"
|
||||
Content="开始唤醒时自动启动游戏客户端" />
|
||||
<StackPanel Grid.Row="1" IsEnabled="{Binding StartGameEnable}" Orientation="Horizontal" HorizontalAlignment="Center" VerticalAlignment="Center">
|
||||
<TextBlock Style="{StaticResource TextBlockDefault}" Block.TextAlignment="Center"
|
||||
|
||||
@@ -48,7 +48,7 @@ namespace MeoAsstGui
|
||||
_listTitle.Add("自动公招");
|
||||
_listTitle.Add("信用商店");
|
||||
_listTitle.Add("定时执行");
|
||||
_listTitle.Add("唤醒设置");
|
||||
_listTitle.Add("启动设置");
|
||||
_listTitle.Add("企鹅数据");
|
||||
_listTitle.Add("连接设置");
|
||||
_listTitle.Add("通知显示");
|
||||
@@ -153,6 +153,23 @@ namespace MeoAsstGui
|
||||
}
|
||||
|
||||
/* 唤醒设置 */
|
||||
private bool _startAppEnable = StartAppModel.CheckStart();
|
||||
public bool StartAppEnable
|
||||
{
|
||||
get { return _startAppEnable; }
|
||||
set
|
||||
{
|
||||
SetAndNotify(ref _startAppEnable, value);
|
||||
StartAppModel.SetStart(value);
|
||||
var toast = new ToastNotification("更改已保存");
|
||||
if (value)
|
||||
{
|
||||
toast.AppendContentText("下次开机助手将自动启动!").ShowMore();
|
||||
}
|
||||
else toast.AppendContentText("下次开机助手将不再自动启动!").ShowMore();
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
private bool _startGameEnable = Convert.ToBoolean(ViewStatusStorage.Get("Start.StartGameEnable", bool.FalseString));
|
||||
|
||||
|
||||
48
src/MeoAsstGui/ViewModels/StartAppModel.cs
Normal file
48
src/MeoAsstGui/ViewModels/StartAppModel.cs
Normal file
@@ -0,0 +1,48 @@
|
||||
// MeoAsstGui - A part of the MeoAssistantArknights 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 General Public License 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
|
||||
|
||||
using System;
|
||||
using System.IO;
|
||||
using System.Diagnostics;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
using Microsoft.Win32;
|
||||
|
||||
namespace MeoAsstGui
|
||||
{
|
||||
public class StartAppModel
|
||||
{
|
||||
private static RegistryKey _key = Registry.CurrentUser.OpenSubKey("Software\\Microsoft\\Windows\\CurrentVersion\\Run", true);
|
||||
private static string fileValue = Process.GetCurrentProcess().MainModule.FileName;
|
||||
public static bool CheckStart()
|
||||
{
|
||||
if (_key.GetValue("MeoAsst") == null)
|
||||
return false;
|
||||
else return true;
|
||||
}
|
||||
public static bool SetStart(bool set)
|
||||
{
|
||||
if (set)
|
||||
{
|
||||
_key.SetValue("MeoAsst", fileValue);
|
||||
return CheckStart();
|
||||
}
|
||||
else
|
||||
{
|
||||
_key.DeleteValue("MeoAsst");
|
||||
return !CheckStart();
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user