Creating a Drawing Panel

by Apr 23, 2013

In PowerShell 3.0, WPF is a great (and easy) way of creating GUIs. If you have a touch-enabled machine, check out how easily you can open a drawing window from PowerShell:

Add-Type -AssemblyName PresentationFramework
Add-Type -AssemblyName PresentationCore
Add-Type -AssemblyName WindowsBase

$window = New-Object Windows.Window
$inkCanvas = New-Object Windows.Controls.InkCanvas

$window.Title = 'Scribble Pad'
$window.Content = $inkCanvas
$window.Width = 800
$window.Height = 600
$window.WindowStartupLocation = 'CenterScreen'

$inkCanvas.MinWidth = $inkCanvas.MinHeight = 100

$null = $window.ShowDialog()

If you do not have a touch screen, use the mouse to draw on the canvas.

Twitter This Tip! ReTweet this Tip!