Last time we looked at PowerShell Studio’s new UI features such as the updated Ribbon and custom layouts. Now we will take a look at the new Forms Designer features.
Styles
Have you ever got tired of applying the same properties over and over to controls such as anchoring? Well this is where Styles come into play, one of the new additions to PowerShell Studio’s Designer.
So what is a Style?
Styles are a set of predefined properties that you can quickly assign to one or more controls within the designer.
Applying Styles:
Let’s look at some sample Styles and how you apply them. You start by opening the designer and selecting the control(s) you wish to apply a Style to.
Next you can access the Style List by using:
The Designer Context Menu:
Or the Ribbon:
The quickest method is to use the keyboard shortcut: Ctrl + L
Next you will be presented with a list of Styles you can apply to the selected control(s).
Some Styles only apply to a specific control type. You can check the “Show styles for same type only” checkbox to only display control specific styles.
(If a Style only applies to a specific type, the type will be displayed in blue.)
The following are example uses for styles:
The Console Font Style changes the control’s font to a fixed sized font. This style is useful for displaying PowerShell output in a TextBox.
Before applying Style:
After applying Style:
Use the OK Button Style to convert any button into a OK button.
Before applying Style:
After applying Style:
The Button’s text is changed to “OK” and the DialogResult property is also changed to ‘OK’ , which triggers the form to close when the button is pressed (See: Spotlight on the Button Control blog article).
Creating New Styles:
Now, not only can you use preexisting Styles but you can also create your own custom Styles.
To create a new Style you must first select the control you wish to use as a template.
In this case, I want to create a Style that applies a blue color to text.
In this example, we will use the button control as a base.
Next select the Create Style option (Ctrl + Shift + L):
You will be presented with the “Create Style Template” dialog:
The dialog displays the selected source control (only one source control per style).
Next you can choose to limit the Style to a ‘Matching Type’ or to apply it to ‘Any Type’.
In this case, we want to apply this style to ‘Any Type’. If you chose the ‘Matching Type’ options, the style could only have been applied to Buttons.
Next enter creator information and the mandatory description of the Style:
After entering the description, you must check all the properties of the template control you would like the Style to incorporate.
In this case, we only want the ForeColor, which is set to blue beforehand on the button.
Next press the ‘Create’ button and save the new Style:
Now apply the new Style to other controls:
What’s cool is that you can apply multiple styles to multiple controls at once.
The controls after applying multiple Styles:
Next: Part 3 – Control Sets
1 comment on “PowerShell Studio 2012: What’s New? (Part 2)”
Comments are closed.