Created
April 26, 2017 21:08
-
-
Save Chirishman/aaeb02d7d4fadfae343b0fc809013330 to your computer and use it in GitHub Desktop.
Arbitrary input as a text window
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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