{"id":6685,"date":"2014-01-07T09:10:00","date_gmt":"2014-01-07T17:10:00","guid":{"rendered":"http:\/\/www.sapien.com\/blog\/?p=6685"},"modified":"2014-01-10T08:58:18","modified_gmt":"2014-01-10T16:58:18","slug":"powershell-studio-fonts-and-other-ambient-properties","status":"publish","type":"post","link":"https:\/\/dev.sapien.com\/blog\/2014\/01\/07\/powershell-studio-fonts-and-other-ambient-properties\/","title":{"rendered":"PowerShell Studio: Ambient properties"},"content":{"rendered":"<p>In the <a href=\"http:\/\/www.sapien.com\/blog\/2013\/02\/12\/powershell-studio-enable-and-disable-groups-of-controls\/\">PowerShell Studio: Enable and Disable Groups of Controls<\/a> article we discussed how you can enable or disable group of controls by setting the parent control\u2019s Enable property. <\/p>\n<p>Now we will look at other properties that have a similar trickle down effect, but work fundamentally in a different fashion. For example, if you change the font of the Form control, you may notice that all the controls within the form change their fonts accordingly. These trickle down properties are known as<em> ambient properties. <\/em>Ambient properties are properties that if not individually set, take their value from the parent control.<\/p>\n<p>There are four common ambient properties:<\/p>\n<p><em><strong>Cursor, Font, BackColor, ForeColor<\/strong><\/em><\/p>\n<p>To illustrate how ambient properties work, consider the following example:<\/p>\n<p>A sample form contains two buttons and various other controls. When button1\u2019s Font property is changed from the default, it uses the new font instead of inheriting the font of the parent form:<\/p>\n<p><img loading=\"lazy\" decoding=\"async\" title=\"image\" style=\"border-left-width: 0px; border-right-width: 0px; border-bottom-width: 0px; display: inline; border-top-width: 0px\" border=\"0\" alt=\"image\" src=\"http:\/\/www.sapien.com\/blog\/wp-content\/uploads\/2013\/12\/image4.png\" width=\"294\" height=\"237\">&nbsp;<br \/><font size=\"2\"><em>(Change the font of the control by using the Properties Pane)<\/em><\/font><\/p>\n<p>On the other hand, button2 is using the default font value and thus inherits the parent form\u2019s font setting:<\/p>\n<p><img loading=\"lazy\" decoding=\"async\" title=\"image\" style=\"border-left-width: 0px; border-right-width: 0px; border-bottom-width: 0px; display: inline; border-top-width: 0px\" border=\"0\" alt=\"image\" src=\"http:\/\/www.sapien.com\/blog\/wp-content\/uploads\/2013\/12\/image5.png\" width=\"337\" height=\"212\">&nbsp;&nbsp; <br \/>&nbsp;<img loading=\"lazy\" decoding=\"async\" title=\"Tip\" style=\"border-left-width: 0px; border-right-width: 0px; border-bottom-width: 0px; margin: 10px 0px 0px; display: inline; border-top-width: 0px\" border=\"0\" alt=\"Tip\" src=\"http:\/\/www.sapien.com\/blog\/wp-content\/uploads\/2013\/12\/Tip.png\" width=\"32\" align=\"left\" height=\"32\"><br \/>&nbsp;<br \/><em>The Properties Panel indicates a property with a non-default value by displaying its value in bold text:<\/em><\/p>\n<p><a href=\"http:\/\/www.sapien.com\/blog\/wp-content\/uploads\/2013\/12\/image7.png\"><img loading=\"lazy\" decoding=\"async\" title=\"image\" style=\"border-left-width: 0px; border-right-width: 0px; border-bottom-width: 0px; display: inline; border-top-width: 0px\" border=\"0\" alt=\"image\" src=\"http:\/\/www.sapien.com\/blog\/wp-content\/uploads\/2013\/12\/image_thumb1.png\" width=\"242\" height=\"81\"><\/a> <a href=\"http:\/\/www.sapien.com\/blog\/wp-content\/uploads\/2013\/12\/image8.png\"><img loading=\"lazy\" decoding=\"async\" title=\"image\" style=\"border-left-width: 0px; border-right-width: 0px; border-bottom-width: 0px; display: inline; border-top-width: 0px\" border=\"0\" alt=\"image\" src=\"http:\/\/www.sapien.com\/blog\/wp-content\/uploads\/2013\/12\/image_thumb2.png\" width=\"242\" height=\"81\"><\/a> <\/p>\n<p>Leaving the default value for the Font property on all the child controls makes it easy to change all the fonts by setting the form\u2019s Font property to the desired font. Since the <em>BackColor and<\/em>&nbsp;<em>ForeColor<\/em> properties are also ambient properties, it makes it easy to theme the controls without having to alter each control\u2019s properties individually. For example, when the form\u2019s ForeColor property is set to Red, all the child controls follow suit (with the exception of the sample label, which has a preset ForeColor):<\/p>\n<p>&nbsp;<img loading=\"lazy\" decoding=\"async\" title=\"image\" style=\"border-left-width: 0px; border-right-width: 0px; border-bottom-width: 0px; display: inline; border-top-width: 0px\" border=\"0\" alt=\"image\" src=\"http:\/\/www.sapien.com\/blog\/wp-content\/uploads\/2013\/12\/image9.png\" width=\"337\" height=\"212\"> <\/p>\n<p><img loading=\"lazy\" decoding=\"async\" title=\"Tip\" style=\"border-left-width: 0px; border-right-width: 0px; border-bottom-width: 0px; margin: 10px 0px 0px; display: inline; border-top-width: 0px\" border=\"0\" alt=\"Tip\" src=\"http:\/\/www.sapien.com\/blog\/wp-content\/uploads\/2013\/12\/Tip.png\" width=\"32\" align=\"left\" height=\"32\"><br \/><em>You can use panel and groupbox controls to set the fonts of specific groups of controls.<\/em><\/p>\n<p>As you can see, ambient properties make it easier to style a large number of controls within the form without having to alter the controls individually; at the same time allowing you to customize the look of individual controls if needed.<\/p>\n<p>You can download the <a href=\"http:\/\/www.sapien.com\/downloads#Sample Scripts\/AmbientProperties.zip\">Ambient Properties Sample<\/a> from our <a href=\"http:\/\/sapien.com\/downloads\">Downloads<\/a> section under Sample Scripts.<\/p>\n","protected":false},"excerpt":{"rendered":"<p>In the PowerShell Studio: Enable and Disable Groups of Controls article we discussed how you can enable or disable group of controls by setting the parent control\u2019s Enable property. Now we will look at other properties that have a similar trickle down effect, but work fundamentally in a different fashion. For example, if you change [&hellip;]<\/p>\n","protected":false},"author":10,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"_monsterinsights_skip_tracking":false,"_monsterinsights_sitenote_active":false,"_monsterinsights_sitenote_note":"","_monsterinsights_sitenote_category":0,"footnotes":""},"categories":[283,705,509],"tags":[641,863,28,1016,314,312],"class_list":["post-6685","post","type-post","status-publish","format-standard","hentry","category-howto","category-powershell-studio-2012","category-primalforms-software-news","tag-controls","tag-fonts","tag-powershell","tag-powershell-studio","tag-primalforms","tag-winforms"],"jetpack_featured_media_url":"","_links":{"self":[{"href":"https:\/\/dev.sapien.com\/blog\/wp-json\/wp\/v2\/posts\/6685","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/dev.sapien.com\/blog\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/dev.sapien.com\/blog\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/dev.sapien.com\/blog\/wp-json\/wp\/v2\/users\/10"}],"replies":[{"embeddable":true,"href":"https:\/\/dev.sapien.com\/blog\/wp-json\/wp\/v2\/comments?post=6685"}],"version-history":[{"count":13,"href":"https:\/\/dev.sapien.com\/blog\/wp-json\/wp\/v2\/posts\/6685\/revisions"}],"predecessor-version":[{"id":6739,"href":"https:\/\/dev.sapien.com\/blog\/wp-json\/wp\/v2\/posts\/6685\/revisions\/6739"}],"wp:attachment":[{"href":"https:\/\/dev.sapien.com\/blog\/wp-json\/wp\/v2\/media?parent=6685"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/dev.sapien.com\/blog\/wp-json\/wp\/v2\/categories?post=6685"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/dev.sapien.com\/blog\/wp-json\/wp\/v2\/tags?post=6685"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}