Posts Tagged ‘WinForm’
This month, we are looking at Visual PowerShell 2011 and how to add event handlers to form controls. After evaluating PrimalForms and user feedback, we…   More »
Get-GuiDate: A PowerShell Calendar Tool
Monday, August 24th, 2009 by Alex Angelopoulos
Forms and dialogs can augment PowerShell scripts or even resurface them completely to make them more friendly for people who aren't familiar with the command line. In some cases, a form can even function as a complete script in and of itself. The Get-GuiDate script, developed from a prototype written with PrimalForms, is an example of a script that is completely centered around a control (the Windows.Forms.MonthCalendar control) embedded in a Windows Form.   More »
Updated PowerShell TreeForm
Monday, June 1st, 2009 by Jeffery Hicks
Not too long ago I wrote a blog post about a Windows Form PowerShell script to display a folder tree. I got some feedback about an error when running the script. The problem was that I was casting a variable in one of the functions to a specific type. Normally this is considered a best practice. But in this situation the [System.Windows.Forms.TreeNode] class depends on the parent class being loaded in your PowerShell session. Even though I thought I had tested thoroughly on PowerShell v1 and v2 I must have missed something and the [System.WIndows.Forms] class was getting loaded into my shell prior to running the script, which is why I never saw the error. Anyway, I've since modified the problematic function to remove the type casting.   More »
Cool Config Creation
Tuesday, May 5th, 2009 by Jeffery Hicks
In my recent Special Forces PowerShell class, one of the students brought up a challenge he was facing when we were talking about the -f replacement operator. This is a handy way to build strings.
PS C:\> "Hello, {0}. It is now {1} and you have {2} processes running." -f $env:username,(get-date).ToShortDateString(),
(get-process | measure-object).count
Hello, Jeff. It is now 5/5/2009 and you have 82 processes running.
Paul needed to build configuration files and was looking for an easy way, perhaps using a here string as a template. We tossed around a few ideas. When I got home I decided to see what I could come up with. What I have is a proof of concept really, but it might get you started.   More »
Up another PowerShell Tree
Monday, April 6th, 2009 by Jeffery Hicks
A few weeks ago I posted a PowerShell script that created a directory tree, like the TREE command from the CMD shell. Then while testing something new in PrimalForms, I realized I had a literal form object, a tree view, that I could use. So I put together a short script that creates a graphical tree for a given directory, along with the file counts and sizes from my original scripts. As a bonus, because I now had a graphical interface I could do things such as display empty folders in a different color. The script not only gives you a handy tool but also serves as a demonstration on how to use a TreeView control.   More »
Winforms and Timers
Thursday, December 18th, 2008 by Jeffery Hicks
There's been some discussion lately in the SAPIEN product forums about PrimalForms and timers. As you know, PowerShell v1.0 is essentially single-threaded. This generally means that timers and asynchronous code won't work. But you can use a simple timer in a Windows form. Here's an example of how you might use such a timer.   More »
Getting Started with PrimalForms
Monday, November 3rd, 2008 by Jeffery Hicks
I hope you are as excited about the release of PrimalForms as I am. In the past creating a Windows form in PowerShell was a very tedious task and one I rarely used except for the most simplest of forms. No more. The free PrimalForms tool lets me create a very rich Windows form using a WYSIWYG editor. I can export the form to a file, add my PowerShell code and call it a day.   More »