{"id":4025,"date":"2012-04-26T08:16:00","date_gmt":"2012-04-26T16:16:00","guid":{"rendered":"http:\/\/www.sapien.com\/blog\/?p=4025"},"modified":"2012-05-01T08:56:26","modified_gmt":"2012-05-01T16:56:26","slug":"powershell-studio-2012-whats-new-part-3","status":"publish","type":"post","link":"https:\/\/dev.sapien.com\/blog\/2012\/04\/26\/powershell-studio-2012-whats-new-part-3\/","title":{"rendered":"PowerShell Studio 2012: What&rsquo;s New? (Part 3)"},"content":{"rendered":"<p>Last time we looked at the new Styles. Now we will take a look at the next major designer feature:<\/p>\n<p><strong><span style=\"font-size: small\"><span style=\"font-size: medium\">Control Sets<\/span><\/span><\/strong><\/p>\n<p>Control Sets are essentially custom controls that you can drag and drop from the Toolbox Panel into the designer like any other ordinary form control. They are made up of either single or multiple controls with predefined properties, events and functions.<\/p>\n<p>You can access the control sets in the Toolbox Panel under the \u201cControl Sets\u201d tab:<\/p>\n<p><a href=\"http:\/\/www.sapien.com\/blog\/wp-content\/uploads\/2012\/04\/Toolbox-Control-Sets.png\"><img loading=\"lazy\" decoding=\"async\" style=\"background-image: none; border-right-width: 0px; padding-left: 0px; padding-right: 0px; display: inline; border-top-width: 0px; border-bottom-width: 0px; border-left-width: 0px; padding-top: 0px\" title=\"Toolbox - Control Sets\" border=\"0\" alt=\"Toolbox - Control Sets\" src=\"http:\/\/www.sapien.com\/blog\/wp-content\/uploads\/2012\/04\/Toolbox-Control-Sets_thumb.png\" width=\"141\" height=\"244\"><\/a><\/p>\n<p>PowerShell Studio 2012 comes with a number of predefined Control Sets that you can immediately use in your forms.<\/p>\n<p><strong><em><\/em><\/strong><\/p>\n<p><strong><span style=\"font-size: small\">Sample Control Sets:<\/span><\/strong><\/p>\n<p>Here are some of the sample Control Sets you may find useful.<\/p>\n<p>&nbsp;<\/p>\n<p><strong>Button \u2013 Run Process<\/strong><\/p>\n<p>This button starts a process when pressed and displays a busy animation as long as the initiated process continues runs.<\/p>\n<p>&nbsp;<\/p>\n<p><strong>Chart \u2013 Disk Space<\/strong><\/p>\n<p>Insert this chart and it will automatically display the disk space usage for each physical hard drive.<\/p>\n<p><a href=\"http:\/\/www.sapien.com\/blog\/wp-content\/uploads\/2012\/04\/Disk-Space.png\"><img loading=\"lazy\" decoding=\"async\" style=\"background-image: none; border-right-width: 0px; padding-left: 0px; padding-right: 0px; display: inline; border-top-width: 0px; border-bottom-width: 0px; border-left-width: 0px; padding-top: 0px\" title=\"Disk Space\" border=\"0\" alt=\"Disk Space\" src=\"http:\/\/www.sapien.com\/blog\/wp-content\/uploads\/2012\/04\/Disk-Space_thumb.png\" width=\"244\" height=\"244\"><\/a><\/p>\n<p>&nbsp;<\/p>\n<p><strong>ListView \u2013 ApplicationList<\/strong><\/p>\n<p>This Control Set inserts a List View that is used to determine if a specified application or file is installed. If the application is found, it will also extract the icon and display it in the ListView.<\/p>\n<p><a href=\"http:\/\/www.sapien.com\/blog\/wp-content\/uploads\/2012\/04\/Application-List.png\"><img loading=\"lazy\" decoding=\"async\" style=\"background-image: none; border-right-width: 0px; padding-left: 0px; padding-right: 0px; display: inline; border-top-width: 0px; border-bottom-width: 0px; border-left-width: 0px; padding-top: 0px\" title=\"Application List\" border=\"0\" alt=\"Application List\" src=\"http:\/\/www.sapien.com\/blog\/wp-content\/uploads\/2012\/04\/Application-List_thumb.png\" width=\"244\" height=\"244\"><\/a><\/p>\n<p>&nbsp;<\/p>\n<p><strong>TextBox \u2013 Browse for File<\/strong><\/p>\n<p>This Control Set inserts a Textbox and an accompanying browse button. There is a high probability that you will need a Browse for Files at one point. This control set will handle all the backend wiring and all you will need to do is set the filter for the OpenFileDialog.<\/p>\n<p><a href=\"http:\/\/www.sapien.com\/blog\/wp-content\/uploads\/2012\/04\/TextBox-Browse-for-File.png\"><img loading=\"lazy\" decoding=\"async\" style=\"background-image: none; border-right-width: 0px; padding-left: 0px; padding-right: 0px; display: inline; border-top-width: 0px; border-bottom-width: 0px; border-left-width: 0px; padding-top: 0px\" title=\"TextBox - Browse for File\" border=\"0\" alt=\"TextBox - Browse for File\" src=\"http:\/\/www.sapien.com\/blog\/wp-content\/uploads\/2012\/04\/TextBox-Browse-for-File_thumb.png\" width=\"244\" height=\"117\"><\/a><\/p>\n<p>&nbsp;<\/p>\n<p><strong><span style=\"font-size: small\"><font size=\"3\">Creating Custom Control Sets<\/font><\/span><\/strong><\/p>\n<p>The best part of Control Sets is that you can create your own. The first step of creating a Control Set is to select the controls you wish to include.<\/p>\n<p>In this example, we select a Textbox and a Button that is used to display all the processes when a button is pressed.<\/p>\n<p><a href=\"http:\/\/www.sapien.com\/blog\/wp-content\/uploads\/2012\/04\/Textbox-and-Button.png\"><img loading=\"lazy\" decoding=\"async\" style=\"background-image: none; border-right-width: 0px; padding-left: 0px; padding-right: 0px; display: inline; border-top-width: 0px; border-bottom-width: 0px; border-left-width: 0px; padding-top: 0px\" title=\"Textbox and Button\" border=\"0\" alt=\"Textbox and Button\" src=\"http:\/\/www.sapien.com\/blog\/wp-content\/uploads\/2012\/04\/Textbox-and-Button_thumb.png\" width=\"244\" height=\"244\"><\/a><\/p>\n<p>Next select the \u201cCreate Control Set\u201d option from either:<\/p>\n<p>ContextMenu:<\/p>\n<p><a href=\"http:\/\/www.sapien.com\/blog\/wp-content\/uploads\/2012\/04\/Create-Control-Set-ContextMenu.png\"><img loading=\"lazy\" decoding=\"async\" style=\"background-image: none; border-right-width: 0px; padding-left: 0px; padding-right: 0px; display: inline; border-top-width: 0px; border-bottom-width: 0px; border-left-width: 0px; padding-top: 0px\" title=\"Create Control Set ContextMenu\" border=\"0\" alt=\"Create Control Set ContextMenu\" src=\"http:\/\/www.sapien.com\/blog\/wp-content\/uploads\/2012\/04\/Create-Control-Set-ContextMenu_thumb.png\" width=\"244\" height=\"222\"><\/a><\/p>\n<p>Or the Ribbon:<\/p>\n<p><a href=\"http:\/\/www.sapien.com\/blog\/wp-content\/uploads\/2012\/04\/Create-Control-Set-Ribbon.png\"><img loading=\"lazy\" decoding=\"async\" style=\"background-image: none; border-right-width: 0px; padding-left: 0px; padding-right: 0px; display: inline; border-top-width: 0px; border-bottom-width: 0px; border-left-width: 0px; padding-top: 0px\" title=\"Create Control Set Ribbon\" border=\"0\" alt=\"Create Control Set Ribbon\" src=\"http:\/\/www.sapien.com\/blog\/wp-content\/uploads\/2012\/04\/Create-Control-Set-Ribbon_thumb.png\" width=\"244\" height=\"139\"><\/a><\/p>\n<p>Or use the Keyboard Short (Ctrl + T).<\/p>\n<p>Next you are presented with the Create Control Set Dialog:<\/p>\n<p><a href=\"http:\/\/www.sapien.com\/blog\/wp-content\/uploads\/2012\/04\/Create-Control-Set-Dialog.png\"><img loading=\"lazy\" decoding=\"async\" style=\"background-image: none; border-right-width: 0px; padding-left: 0px; padding-right: 0px; display: inline; border-top-width: 0px; border-bottom-width: 0px; border-left-width: 0px; padding-top: 0px\" title=\"Create Control Set Dialog\" border=\"0\" alt=\"Create Control Set Dialog\" src=\"http:\/\/www.sapien.com\/blog\/wp-content\/uploads\/2012\/04\/Create-Control-Set-Dialog_thumb.png\" width=\"244\" height=\"172\"><\/a><\/p>\n<p>The first tab is the \u201cGeneral\u201d tab where you enter information about the control set and the icon that will be displayed in the toolbox.<\/p>\n<p>The \u201cControl Insertion\u201d section allows you to handle the non-visual controls by either choosing to \u201cAlways Insert\u201dthe control or \u201cUse Existing Type\u201d action.<\/p>\n<blockquote>\n<p><em>Use Existing Type<\/em>\u2013 checks if a control of the same type exists. If the control exists in the Form, it will reference the existing control instead of inserting the new control. If the type doesn\u2019t exist, it will insert the control. Use this action if you are using controls such as the ErrorProvider and the ToolTip controls, which don\u2019t require multiple instances.<\/p>\n<\/blockquote>\n<blockquote>\n<p><em>Always Insert<\/em>\u2013 It will always insert the control regardless of whether a control of the same type already exists.<\/p>\n<\/blockquote>\n<p>The next is the Function Tab, which allows you to check any functions you wish to include with the control set.<\/p>\n<p><a href=\"http:\/\/www.sapien.com\/blog\/wp-content\/uploads\/2012\/04\/Functions-Tab.png\"><img loading=\"lazy\" decoding=\"async\" style=\"background-image: none; border-right-width: 0px; padding-left: 0px; padding-right: 0px; display: inline; border-top-width: 0px; border-bottom-width: 0px; border-left-width: 0px; padding-top: 0px\" title=\"Functions Tab\" border=\"0\" alt=\"Functions Tab\" src=\"http:\/\/www.sapien.com\/blog\/wp-content\/uploads\/2012\/04\/Functions-Tab_thumb.png\" width=\"244\" height=\"172\"><\/a><\/p>\n<p>Note: PowerShell Studio will automatically add any functions that are called from the control events.<\/p>\n<p>If you select the Form as part of a control set, it will display another tab called \u2018Container Tab\u2019. In this tab you are presented with lists containing used events and properties of the form. If you check any of the events or properties, they will be applied (similar to Styles) to any form that inserts the Control Set.<\/p>\n<p><a href=\"http:\/\/www.sapien.com\/blog\/wp-content\/uploads\/2012\/04\/Container-Tab.png\"><img loading=\"lazy\" decoding=\"async\" style=\"background-image: none; border-right-width: 0px; padding-left: 0px; padding-right: 0px; display: inline; border-top-width: 0px; border-bottom-width: 0px; border-left-width: 0px; padding-top: 0px\" title=\"Container Tab\" border=\"0\" alt=\"Container Tab\" src=\"http:\/\/www.sapien.com\/blog\/wp-content\/uploads\/2012\/04\/Container-Tab_thumb.png\" width=\"244\" height=\"172\"><\/a><\/p>\n<p>The Fade In Form Control Set is a good example of this. It uses the Form\u2019s Load event to trigger the timer control.<\/p>\n<p>Next you press the \u2018Finish\u2019 button and Save the new Control Set:<\/p>\n<p><a href=\"http:\/\/www.sapien.com\/blog\/wp-content\/uploads\/2012\/04\/Save-the-ControlSet.png\"><img loading=\"lazy\" decoding=\"async\" style=\"background-image: none; border-right-width: 0px; padding-left: 0px; padding-right: 0px; display: inline; border-top-width: 0px; border-bottom-width: 0px; border-left-width: 0px; padding-top: 0px\" title=\"Save the ControlSet\" border=\"0\" alt=\"Save the ControlSet\" src=\"http:\/\/www.sapien.com\/blog\/wp-content\/uploads\/2012\/04\/Save-the-ControlSet_thumb.png\" width=\"244\" height=\"182\"><\/a><\/p>\n<p>And now the new Control Set appears in the Toolbox pane:<\/p>\n<p><a href=\"http:\/\/www.sapien.com\/blog\/wp-content\/uploads\/2012\/04\/Control-Set-in-the-ToolBox.png\"><img loading=\"lazy\" decoding=\"async\" style=\"background-image: none; border-right-width: 0px; padding-left: 0px; padding-right: 0px; display: inline; border-top-width: 0px; border-bottom-width: 0px; border-left-width: 0px; padding-top: 0px\" title=\"Control Set in the ToolBox\" border=\"0\" alt=\"Control Set in the ToolBox\" src=\"http:\/\/www.sapien.com\/blog\/wp-content\/uploads\/2012\/04\/Control-Set-in-the-ToolBox_thumb.png\" width=\"244\" height=\"161\"><\/a><\/p>\n<p><strong><\/strong><\/p>\n<p><strong>Control Set Best Practices:<\/strong><\/p>\n<p>Here are some recommended practices when creating Control Sets:<\/p>\n<blockquote>\n<p>1. Try to keep the Control Set\u2019s size small enough so it fits in the initial form size. This may not always be the case but it helps prevents the controls from inserting outside of the form.<\/p>\n<p>2. Try to keep the Anchoring of the controls to the default Top Left.<\/p>\n<p>3. If you are using functions to modify form controls, then it is highly recommend to pass the form control as a parameter into the function. Functions are only inserted if they do not already exist, therefore, you have to make sure your functions can be shared over multiple instances of the Control Set. Events on the other hand are always inserted and are automatically renamed to ensure there are no conflicts.<\/p>\n<\/blockquote>\n<p>&nbsp;<\/p>\n<p>Next: <a href=\"http:\/\/www.sapien.com\/blog\/2012\/05\/01\/powershell-studio-2012-whats-new-part-4\/\">Part 4<\/a> &#8211; New Script Editor Features<\/p>\n","protected":false},"excerpt":{"rendered":"<p>Last time we looked at the new Styles. Now we will take a look at the next major designer feature: Control Sets Control Sets are essentially custom controls that you can drag and drop from the Toolbox Panel into the designer like any other ordinary form control. They are made up of either single or [&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":[705,509,21,25],"tags":[694,28,1016,314,128],"class_list":["post-4025","post","type-post","status-publish","format-standard","hentry","category-powershell-studio-2012","category-primalforms-software-news","category-software-news","category-windows-powershell","tag-694","tag-powershell","tag-powershell-studio","tag-primalforms","tag-whats-new-whats-changed"],"jetpack_featured_media_url":"","_links":{"self":[{"href":"https:\/\/dev.sapien.com\/blog\/wp-json\/wp\/v2\/posts\/4025","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=4025"}],"version-history":[{"count":13,"href":"https:\/\/dev.sapien.com\/blog\/wp-json\/wp\/v2\/posts\/4025\/revisions"}],"predecessor-version":[{"id":4262,"href":"https:\/\/dev.sapien.com\/blog\/wp-json\/wp\/v2\/posts\/4025\/revisions\/4262"}],"wp:attachment":[{"href":"https:\/\/dev.sapien.com\/blog\/wp-json\/wp\/v2\/media?parent=4025"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/dev.sapien.com\/blog\/wp-json\/wp\/v2\/categories?post=4025"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/dev.sapien.com\/blog\/wp-json\/wp\/v2\/tags?post=4025"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}