See a similar question i asked: How to check if we’re running on battery?
Because if you're running on battery you also want to disable animations.
/// <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;
}
}
And then to check if you're running on battery:
/// <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;
}
}
}
Which you can just combine into one:
public Boolean UseAnimations()
{
return
(!System.Windows.Forms.SystemInformation.TerminalServerSession) &&
(System.Windows.Forms.SystemInformation.PowerStatus.PowerLineStatus != PowerLineStatus.Offline);
}
Note: This question was already asked (Determine if a program is running on a Remote Desktop)