实现基于 WPF 的 AutoShutdown 主界面,支持关机、重启、睡眠、休眠、唤醒、锁屏和注销等电源任务。 支持指定时间和倒计时计划、执行前提醒、系统关机撤销、Windows 唤醒任务、托盘运行、自定义图标以及 OmniNotify 通知适配。 修复关闭到托盘时的运行提醒,并支持单击托盘图标打开或收起主界面。 补充 README、发布配置和 win-x64 Release 输出要求。 Release: win-x64
40 lines
1.1 KiB
C#
40 lines
1.1 KiB
C#
namespace AutoShutdown.Models;
|
|
|
|
internal enum PowerAction
|
|
{
|
|
Shutdown,
|
|
Restart,
|
|
Sleep,
|
|
Hibernate,
|
|
Wake,
|
|
Lock,
|
|
LogOff
|
|
}
|
|
|
|
internal static class PowerActionText
|
|
{
|
|
public static string Label(this PowerAction action) => action switch
|
|
{
|
|
PowerAction.Shutdown => "关机",
|
|
PowerAction.Restart => "重启",
|
|
PowerAction.Sleep => "睡眠",
|
|
PowerAction.Hibernate => "休眠",
|
|
PowerAction.Wake => "唤醒",
|
|
PowerAction.Lock => "锁屏",
|
|
PowerAction.LogOff => "注销",
|
|
_ => action.ToString()
|
|
};
|
|
|
|
public static string Description(this PowerAction action) => action switch
|
|
{
|
|
PowerAction.Shutdown => "关闭电脑",
|
|
PowerAction.Restart => "重新启动电脑",
|
|
PowerAction.Sleep => "保留会话并进入低功耗状态",
|
|
PowerAction.Hibernate => "保存当前状态后断电待机",
|
|
PowerAction.Wake => "通过任务计划从睡眠或休眠中唤醒",
|
|
PowerAction.Lock => "锁定当前 Windows 会话",
|
|
PowerAction.LogOff => "注销当前用户",
|
|
_ => string.Empty
|
|
};
|
|
}
|