问题描述
我想成为一个优秀的开发人员的公民,,如果我们正在运行通过远程桌面,或电池运行禁用的事情。
i want to be a good developer citizen, pay my taxes, and disable things if we're running over Remote Desktop, or running on battery.
如果我们通过远程桌面在运行中(或等价终端服务器会话),我们必须禁用动画和双缓冲。你可以检查此:
If we're running over remote desktop (or equivalently in a Terminal server session), we must disable animations and double-buffering. You can check this with:
/// <summary>
/// Indicates if we're running in a remote desktop session.
/// If we are, then you MUST disable animations and double buffering i.e. Pay your taxes!
///
/// </summary>
/// <returns></returns>
public static Boolean IsRemoteSession
{
//This is just a friendly wrapper around the built-in way
get
{
return System.Windows.Forms.SystemInformation.TerminalServerSession;
}
}
现在我需要找出如果用户正在运行电池供电。如果是这样,我不希望通过他们的电池吹。我想要做的事情,如
Now i need to find out if the user is running on battery power. If they are, i don't want to blow through their battery. i want to do things such as
- 禁用动画
- 禁用背景拼写检查
- 关闭后台打印
- 关闭梯度
- 使用
graphics.SmoothingMode = SmoothingMode.HighSpeed ;
- 使用
graphics.InterpolationMode = InterpolationMode.Low;
- 使用
graphics.CompositingQuality = CompositingQuality.HighSpeed;
- 最大限度地减少硬盘的使用 - 避免旋转加速
- 最小化网络接入 - 节省的WiFi功率
- disable animations
- disable background spell-checking
- disable background printing
- turn off gradients
- use
graphics.SmoothingMode = SmoothingMode.HighSpeed;
- use
graphics.InterpolationMode = InterpolationMode.Low;
- use
graphics.CompositingQuality = CompositingQuality.HighSpeed;
- minimize hard drive access - to avoid spin up
- minimize network access - to save WiFi power
有没有一种管理方法,如果机器的目前电池运行?
Is there a managed way to see if the machine is currently running on battery?
参考
的
的
推荐答案
我相信你可以检查 SystemInformation.PowerStatus 来看看它在电池或没有。
I believe you can check SystemInformation.PowerStatus to see if it's on battery or not.
Boolean isRunningOnBattery =
(System.Windows.Forms.SystemInformation.PowerStatus.PowerLineStatus ==
PowerLineStatus.Offline);
编辑:除上述外,还有一个System.Windows.Forms的类。它的一个方法是 ,这将等于PowerLineStatus.Online如果它使用交流电源。
In addition to the above, there's also a System.Windows.Forms.PowerStatus class. One of its methods is PowerLineStatus, which will equal PowerLineStatus.Online if it's on AC Power.
这篇关于C#.NET:如何检查,如果我们使用电池运行?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!