См. Аналогичный вопрос, который я задал: Как проверить, работаем ли мы от батареи?
Потому что, если вы работаете от батареи, вы также хотите отключить анимацию.
/// <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;
}
}
А затем, чтобы проверить, работаете ли вы от батареи:
/// <summary>
/// Indicates if we're running on battery power.
/// If we are, then disable CPU wasting things like animations, background operations, network, I/O, etc
/// </summary>
public static Boolean IsRunningOnBattery
{
get
{
PowerLineStatus pls = System.Windows.Forms.SystemInformation.PowerStatus.PowerLineStatus;
if (pls == PowerLineStatus.Offline)
{
//Offline means running on battery
return true;
}
else
{
return false;
}
}
}
Который вы можете просто объединить в один:
public Boolean UseAnimations()
{
return
(!System.Windows.Forms.SystemInformation.TerminalServerSession) &&
(System.Windows.Forms.SystemInformation.PowerStatus.PowerLineStatus != PowerLineStatus.Offline);
}
Примечание: Этот вопрос уже задавался ( Определите, работает ли программа на удаленном рабочем столе )