{"id":270,"date":"2011-11-12T18:42:55","date_gmt":"2011-11-12T07:42:55","guid":{"rendered":"http:\/\/blog.quppa.net\/2011\/11\/12\/when-should-a-programs-ui-animations-be-disabled\/"},"modified":"2011-11-12T18:42:55","modified_gmt":"2011-11-12T07:42:55","slug":"when-should-a-programs-ui-animations-be-disabled","status":"publish","type":"post","link":"https:\/\/www.quppa.net\/blog\/2011\/11\/12\/when-should-a-programs-ui-animations-be-disabled\/","title":{"rendered":"When should a program\u2019s UI animations be disabled?"},"content":{"rendered":"<p>Modern frameworks like the <a title=\"MSDN: Windows Presentation Foundation\" href=\"http:\/\/msdn.microsoft.com\/en-us\/library\/ms754130.aspx\">Windows Presentation Foundation<\/a>, its relative <a title=\"Silverlight\" href=\"http:\/\/www.silverlight.net\/\">Silverlight<\/a> and the upcoming <a title=\"MSDN: The Windows Runtime\" href=\"http:\/\/msdn.microsoft.com\/en-us\/library\/windows\/apps\/hh464942.aspx\">Windows Runtime<\/a> make it easy to add animations to a program\u2019s graphical user interface. When implemented well, animations subtly improve the user experience and can demonstrate a high level of polish in your application. The <a title=\"Zune\" href=\"http:\/\/www.zune.net\/en-us\/products\/software\/download\/default.htm\">Zune client software<\/a> and <a title=\"Windows Live Essentials 2011\" href=\"http:\/\/explore.live.com\/windows-live-essentials\">Windows Live Messenger<\/a> both feature beautiful animations \u2013 coincidentally, both were written with internal Microsoft frameworks (<a title=\"istartedsomething: Mysterious Microsoft Iris UI Framework \u201cUIX\u201d behind the new Zune software eye-candy\" href=\"http:\/\/www.istartedsomething.com\/20071116\/microsoft-iris-uix-framework-zune\/\">Iris<\/a> and \u2018DirectUI\u2019, respectively; the second is apparently unrelated to anything in WinRT). The Twitter client <a title=\"MetroTwit\" href=\"http:\/\/www.metrotwit.com\/\">MetroTwit<\/a> shows what can be done in WPF (its interface was inspired by the Zune software and the <a title=\"Wikipedia: Metro (Design Language)\" href=\"http:\/\/en.wikipedia.org\/wiki\/Metro_(design_language)\">Metro design language<\/a>).<\/p>\n<p>There are times, however, when animations may become detrimental to the user experience. Animations may appear choppy on lower-end or older systems (especially with heavy frameworks like WPF), and in general they should be disabled entirely for Remote Desktop Connection sessions (only very fast networks with low latency may be able to handle them). Jossef Goldberg from the Visual Studio team <a title=\"WPF Performance and .NET Framework Client Profile: Optimizing Visual Studio 2010 and WPF applications for Remote Desktop\" href=\"http:\/\/blogs.msdn.com\/b\/jgoldb\/archive\/2010\/02\/27\/optimizing-visual-studio-2010-and-wpf-applications-for-remote-desktop.aspx\">has written about the efforts made to bring the performance of Visual Studio 2010 over remote connections up to par<\/a>, and while his advice is mainly about WPF, the same principles apply to other frameworks, also.<\/p>\n<p>So, how can we decide whether animations should be disabled or not? The answer will likely vary from project to project, but there are a few things that we can do:<\/p>\n<h1>1. Check if the program is running in a remote session<\/h1>\n<p>In Win32, use the <a title=\"MSDN: GetSystemMetrics function\" href=\"http:\/\/msdn.microsoft.com\/en-us\/library\/windows\/desktop\/ms724385.aspx\">GetSystemMetrics function<\/a> to get the SM_REMOTESESSION metric (a non-zero result means it is a remote session). In WPF, use the <a title=\"MSDN: System.Windows.SystemParameters.IsRemoteSession\" href=\"http:\/\/msdn.microsoft.com\/en-us\/library\/system.windows.systemparameters.isremotesession.aspx\">SystemParameters.IsRemoteSession property<\/a> in the System.Windows namespace. In Windows Forms, use the <a title=\"MSDN: Systems.Windows.Forms.SystemInformation.TerminalServerSession Property\" href=\"http:\/\/msdn.microsoft.com\/en-us\/library\/system.windows.forms.systeminformation.terminalserversession.aspx\">SystemInformation.TerminalServerSession property<\/a> in the System.Windows.Forms namespace.<\/p>\n<h1>2. Check if animations are enabled in Windows<\/h1>\n<p>Windows Vista introduced many new animations to common controls like buttons (notice the smooth glow effect and compare it to the binary states found in Windows XP). Regrettably this change made most owner-drawn implementations look shoddy since they mostly lack animation (e.g. buttons in Firefox), but that\u2019s a topic for another post.<\/p>\n<p>Anyway, these animations can be switched off in the following dialog (aside: the list box was mercifully <a title=\"Performance options dialog has available space for list, doesn&#39;t use it, isn&#39;t resizable\" href=\"http:\/\/www.aerotaskforce.com\/view\/74\">increased in size in Windows 7<\/a>, though the window still isn\u2019t resizable):<img loading=\"lazy\" decoding=\"async\" style=\"margin: 5px auto; border: 0px currentcolor; float: none; display: block; background-image: none;\" title=\"Performance Options\" border=\"0\" alt=\"Performance Options Screenshot\" src=\"https:\/\/www.quppa.net\/blog\/wp-content\/uploads\/PerfOptions2.png\" width=\"407\" height=\"330\" \/><\/p>\n<p>If the user has disabled animations here, it\u2019s probably a good idea to respect that choice in any program you write. We can use the <a title=\"MSDN: SystemParametersInfo function\" href=\"http:\/\/msdn.microsoft.com\/en-us\/library\/windows\/desktop\/ms724947.aspx\">SystemParametersInfo function<\/a> with the SPI_GETCLIENTAREAANIMATION parameter to check the system setting (or use the <a title=\"MSDN: System.Windows.SystemParameters.ClientAreaAnimation\" href=\"http:\/\/msdn.microsoft.com\/en-us\/library\/system.windows.systemparameters.clientareaanimation.aspx\">SystemParameters.ClientAreaAnimation property<\/a> in the System.Windows namespace, but note that this always returns true in Windows XP). <strong>This only applies to Windows Vista and later.<\/strong><\/p>\n<h1>3. WPF-only: Check the graphics rendering tier<\/h1>\n<p>The <a title=\"MSDN: System.Windows.Media.RenderCapability.Tier Property\" href=\"http:\/\/msdn.microsoft.com\/en-us\/library\/system.windows.media.rendercapability.tier.aspx\">RenderCapability.Tier property<\/a> in the System.Windows.Media namespace gives an indication of the graphical capabilities of the system. There are currently 3 tiers, and while the exact meaning may change between .NET releases (as it did in .NET 4.0), this property can be used to help determine what animations, if any, should be enabled.<\/p>\n<h1>4. Ask the user!<\/h1>\n<p>It can\u2019t hurt to give the user a choice about animations. The remote session checks described above will work for RDP, but there are <a title=\"Wikipedia: Virtual Network Computing\" href=\"http:\/\/en.wikipedia.org\/wiki\/Virtual_Network_Computing\">other technologies available<\/a>, and we don\u2019t want to punish VNC users by invalidating the entire window 60 times per second for some fancy animation, even if we can\u2019t tell that they\u2019re connecting remotely. If exposing such an option in the UI doesn\u2019t make sense, at least offer it as a command line switch.<\/p>\n<h1>Addendum (2011-11-20)<\/h1>\n<p>Snooping around PresentationFramework.Aero.dll in .NET Reflector, I happened to come across the \u2018Animates\u2019 property in the ButtonChrome class (Microsoft.Windows.Themes namespace):<\/p>\n<pre class=\"lang:c# decode:true \">private bool Animates {\n  get {\n    return ((((SystemParameters.PowerLineStatus == PowerLineStatus.Online) &amp;&amp; SystemParameters.ClientAreaAnimation) &amp;&amp; (RenderCapability.Tier &gt; 0)) &amp;&amp; base.IsEnabled);\n  }\n}<\/pre>\n<p>Similar properties can be found in the other *Chrome classes. Checking the computer\u2019s power status isn\u2019t something covered in this article, but it\u2019s certainly a good idea. <\/p>\n","protected":false},"excerpt":{"rendered":"<p>Modern frameworks like the Windows Presentation Foundation, its relative Silverlight and the upcoming Windows Runtime make it easy to add animations to a program\u2019s graphical user interface. When implemented well, animations subtly improve the user experience and can demonstrate a high level of polish in your application. The Zune client software and Windows Live Messenger &hellip; <a href=\"https:\/\/www.quppa.net\/blog\/2011\/11\/12\/when-should-a-programs-ui-animations-be-disabled\/\" class=\"more-link\">Continue reading<span class=\"screen-reader-text\"> &#8220;When should a program\u2019s UI animations be disabled?&#8221;<\/span><\/a><\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[6,9],"tags":[11,14,107,112,170,179,185],"class_list":["post-270","post","type-post","status-publish","format-standard","hentry","category-programming","category-windows","tag-aero","tag-animations","tag-rdp","tag-remote","tag-win32","tag-winforms","tag-wpf"],"_links":{"self":[{"href":"https:\/\/www.quppa.net\/blog\/wp-json\/wp\/v2\/posts\/270","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/www.quppa.net\/blog\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/www.quppa.net\/blog\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/www.quppa.net\/blog\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/www.quppa.net\/blog\/wp-json\/wp\/v2\/comments?post=270"}],"version-history":[{"count":0,"href":"https:\/\/www.quppa.net\/blog\/wp-json\/wp\/v2\/posts\/270\/revisions"}],"wp:attachment":[{"href":"https:\/\/www.quppa.net\/blog\/wp-json\/wp\/v2\/media?parent=270"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.quppa.net\/blog\/wp-json\/wp\/v2\/categories?post=270"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.quppa.net\/blog\/wp-json\/wp\/v2\/tags?post=270"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}