-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathOut-Image.ps1
50 lines (33 loc) · 992 Bytes
/
Out-Image.ps1
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
Function Out-Image {
Param(
[Parameter(
Mandatory = $true,
Position = 0,
ValueFromPipeline = $true,
ValueFromPipelineByPropertyName = $true
)]
[ValidateNotNullOrEmpty()]
[System.Drawing.Image]$Image,
[Parameter(
Position = 1
)]
[String]$Title = "Image Viewer"
)
Begin {
}
Process {
[System.Reflection.Assembly]::LoadWithPartialName("System.Windows.Forms") | Out-Null
$Form = [System.Windows.Forms.Form]::new()
$Form.Text = $Title
$Form.Height = $Image.Size.Height
$Form.Width = $Image.Size.Width
$PictureBox = [System.Windows.Forms.PictureBox]::new()
$PictureBox.Height = $Image.Size.Height
$PictureBox.Width = $Image.Size.Width
$PictureBox.SizeMode = [System.Windows.Forms.PictureBoxSizeMode]::CenterImage
$PictureBox.Image = $Image
$Form.Controls.Add($PictureBox)
$Form.Add_Shown( { $Form.Activate() } )
$Form.ShowDialog() | Out-Null
}
}