{"id":4738,"date":"2012-08-27T10:06:00","date_gmt":"2012-08-27T18:06:00","guid":{"rendered":"http:\/\/www.sapien.com\/blog\/?p=4738"},"modified":"2012-08-27T10:06:59","modified_gmt":"2012-08-27T18:06:59","slug":"powershell-studio-new-progressbar-control","status":"publish","type":"post","link":"https:\/\/dev.sapien.com\/blog\/2012\/08\/27\/powershell-studio-new-progressbar-control\/","title":{"rendered":"PowerShell Studio: New ProgressBar Control"},"content":{"rendered":"<p>In the last service release of PowerShell Studio 2012 (v3.0.8) a new custom control called ProgressBarOverlay was introduced. This new progress control functions exactly like the typical progress bar, with the added ability of displaying a text percentage over the progress bar. <\/p>\n<p><strong>Adding a ProgressBarOverlay Control:<\/strong><\/p>\n<p>Like the typical progress bar, you can add the new progress bar control using the ToolBox Pane:<\/p>\n<p><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\" border=\"0\" alt=\"ToolBox\" src=\"http:\/\/www.sapien.com\/blog\/wp-content\/uploads\/2012\/08\/ToolBox.png\" width=\"208\" height=\"174\"><\/p>\n<p>&nbsp;<\/p>\n<p>The new control offers full designer support as you would expect from a normal progress bar:<\/p>\n<p><a href=\"http:\/\/www.sapien.com\/blog\/wp-content\/uploads\/2012\/08\/ProgressBarOverlay-in-Designer1.png\" target=\"_blank\"><img loading=\"lazy\" decoding=\"async\" style=\"background-image: none; border-bottom: 0px; border-left: 0px; padding-left: 0px; padding-right: 0px; display: inline; border-top: 0px; border-right: 0px; padding-top: 0px\" title=\"ProgressBarOverlay in Designer\" border=\"0\" alt=\"ProgressBarOverlay in Designer\" src=\"http:\/\/www.sapien.com\/blog\/wp-content\/uploads\/2012\/08\/ProgressBarOverlay-in-Designer_thumb1.png\" width=\"244\" height=\"162\"><\/a><\/p>\n<p>&nbsp;<\/p>\n<p><strong>Displaying Percentage:<\/strong><\/p>\n<p><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=\"Displaying Percentage\" border=\"0\" alt=\"Displaying Percentage\" src=\"http:\/\/www.sapien.com\/blog\/wp-content\/uploads\/2012\/08\/Displaying-Percentage.png\" width=\"272\" height=\"37\"><\/p>\n<p>By default, the ProgressBarOverlay control displays the current percentage. This value is calculated using the progress bar\u2019s Value and Maximum properties. As you step or directly modify the progress bar\u2019s Value, the control will automatically update to reflect the current percentage.<\/p>\n<p>Note: The percentage will not be displayed if the ProgressBar\u2019s Style property is set to <em>Marquee<\/em>.<\/p>\n<p>&nbsp;<\/p>\n<p><strong>Displaying Alternate Text:<\/strong><\/p>\n<p><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=\"TextOverlay on ProgressBar\" border=\"0\" alt=\"TextOverlay on ProgressBar\" src=\"http:\/\/www.sapien.com\/blog\/wp-content\/uploads\/2012\/08\/TextOverlay-on-ProgressBar.png\" width=\"275\" height=\"35\"><\/p>\n<p>In certain cases you may want to display text instead of a percentage; particularly when using the <em>Marquee<\/em> style in instances where the progress is unknown. In order to display custom text, the ProgressBarOverlay control has a property called:<\/p>\n<p><strong>TextOverlay<\/strong>&nbsp;&nbsp; <\/p>\n<p>Set this property in order to display custom text over on the progress bar.<\/p>\n<p><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=\"TextOverlay in Property Pane\" border=\"0\" alt=\"TextOverlay in Property Pane\" src=\"http:\/\/www.sapien.com\/blog\/wp-content\/uploads\/2012\/08\/TextOverlay-in-Property-Pane.png\" width=\"263\" height=\"180\"><\/p>\n<p>&nbsp;<\/p>\n<p><strong>The Custom Control in Exported Script:<\/strong><\/p>\n<p>PowerShell has the ability to compile C# code on demand by use the Add-Type cmdlet. This powerful feature allows us to create and utilize customs control directly in the exported script. <\/p>\n<p><a href=\"http:\/\/www.sapien.com\/blog\/wp-content\/uploads\/2012\/08\/Defining-the-Custom-Control-with-Add-Type1.png\" target=\"_blank\"><img loading=\"lazy\" decoding=\"async\" style=\"background-image: none; border-bottom: 0px; border-left: 0px; padding-left: 0px; padding-right: 0px; display: inline; border-top: 0px; border-right: 0px; padding-top: 0px\" title=\"Defining the Custom Control with Add-Type\" border=\"0\" alt=\"Defining the Custom Control with Add-Type\" src=\"http:\/\/www.sapien.com\/blog\/wp-content\/uploads\/2012\/08\/Defining-the-Custom-Control-with-Add-Type_thumb1.png\" width=\"244\" height=\"100\"><\/a><\/p>\n<p>When the script is executed, it checks if the custom type is already defined. If the custom type is not defined, the script will call the Add-Type cmdlet to compile the code on demand. Once the type is defined, the script can instantiate and use the custom control:<\/p>\n<p><img loading=\"lazy\" decoding=\"async\" style=\"background-image: none; border-bottom: 0px; border-left: 0px; padding-left: 0px; padding-right: 0px; display: inline; border-top: 0px; border-right: 0px; padding-top: 0px\" title=\"Instantiating the Custom Control\" border=\"0\" alt=\"Instantiating the Custom Control\" src=\"http:\/\/www.sapien.com\/blog\/wp-content\/uploads\/2012\/08\/Instantiating-the-Custom-Control1.png\" width=\"613\" height=\"138\"><\/p>\n<p>&nbsp;<\/p>\n<p>For further help on using the progress bar, please refer to the <a href=\"http:\/\/www.sapien.com\/blog\/2011\/07\/14\/primalforms-2011-spotlight-on-the-progressbar-control\/\">Spotlight on the ProgressBar Control<\/a> blog.<\/p>\n","protected":false},"excerpt":{"rendered":"<p>In the last service release of PowerShell Studio 2012 (v3.0.8) a new custom control called ProgressBarOverlay was introduced. This new progress control functions exactly like the typical progress bar, with the added ability of displaying a text percentage over the progress bar. Adding a ProgressBarOverlay Control: Like the typical progress bar, you can add the [&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,21,644,25],"tags":[694,724,28,1016,663],"class_list":["post-4738","post","type-post","status-publish","format-standard","hentry","category-powershell-studio-2012","category-software-news","category-spotlight-on-controls","category-windows-powershell","tag-694","tag-control","tag-powershell","tag-powershell-studio","tag-progressbar"],"jetpack_featured_media_url":"","_links":{"self":[{"href":"https:\/\/dev.sapien.com\/blog\/wp-json\/wp\/v2\/posts\/4738","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=4738"}],"version-history":[{"count":6,"href":"https:\/\/dev.sapien.com\/blog\/wp-json\/wp\/v2\/posts\/4738\/revisions"}],"predecessor-version":[{"id":4755,"href":"https:\/\/dev.sapien.com\/blog\/wp-json\/wp\/v2\/posts\/4738\/revisions\/4755"}],"wp:attachment":[{"href":"https:\/\/dev.sapien.com\/blog\/wp-json\/wp\/v2\/media?parent=4738"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/dev.sapien.com\/blog\/wp-json\/wp\/v2\/categories?post=4738"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/dev.sapien.com\/blog\/wp-json\/wp\/v2\/tags?post=4738"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}