Skip to content

Instantly share code, notes, and snippets.

@Chirishman
Created April 26, 2017 21:08
Show Gist options
  • Save Chirishman/aaeb02d7d4fadfae343b0fc809013330 to your computer and use it in GitHub Desktop.
Save Chirishman/aaeb02d7d4fadfae343b0fc809013330 to your computer and use it in GitHub Desktop.
Arbitrary input as a text window
Function Out-Window {
Param(
[Parameter(Mandatory=$true,ValueFromPipeline=$true)]
$InputObject
)
$OutputSettings = @{
Multiline = $true
WordWrap = $false
ScrollBars = "Both"
Dock = "Fill"
ReadOnly = $true
Text = $InputObject | Out-String
Font = [System.Drawing.Font]::new(([System.Drawing.FontFamily]::new('Lucida Console')),9)
}
Add-Type -Assembly System.Windows.Forms
$outputPane = New-Object Windows.Forms.TextBox
$OutputSettings.GetEnumerator() | %{
$outputPane.($_.Key) = $_.Value
}
$FormSettings = @{
Text = "Browsing " + $root.Text
Width = 1000
Height = 800
}
$form = New-Object Windows.Forms.Form
$FormSettings.GetEnumerator() | %{
$form.($_.Key) = $_.Value
}
$form.Controls.Add($outputPane)
$form.ShowDialog() | Out-Null
$form.Dispose()
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment