高DPI powershell形式

时间:2016-12-07 17:42:30

标签: .net forms powershell dpi

我有一个表格创建来提供有关您所使用的计算机的信息,当我们将它部署到表面专业4时,我们没有考虑DPI并且它会爆炸测试并且在表单中是不可读的。见下文。

坏形式:

Bad form

这应该是它的样子:

Good-Form

我已经尝试了所有AutoSizeMode并将其放入组和表中,似乎没有任何效果。我把它放在StackOverflow上,看看是否有人有一个很好的解决方案。以下是表格的基础:

#Background Image
$Image = [system.drawing.image]::FromFile("Desktop.jpg")

$Form.BackgroundImage = $Image

$Form.BackgroundImageLayout = "Stretch"


#button
$Button = New-Object System.Windows.Forms.Button 
$Button.TabIndex = 0 
$Button.Name = "Button" 
$System_Drawing_Size = New-Object System.Drawing.Size 
$System_Drawing_Size.Width = 160
$System_Drawing_Size.Height = 30 
$Button.Size = $System_Drawing_Size 
$Button.UseVisualStyleBackColor = $True

$Button.Text = "Button"
$System_Drawing_Point = New-Object System.Drawing.Point 
$System_Drawing_Point.X = 13
$System_Drawing_Point.Y = 230
$Button.Location = $System_Drawing_Point 
$Button.DataBindings.DefaultDataSourceUpdateMode = 0 
$Button.add_Click({Function1})


$Font = New-Object System.Drawing.Font("Calibri",11.5 [System.Drawing.FontStyle]::Regular)
$Form.Font = $Font


#Lables for the computer information and displays them
$Label = New-Object System.Windows.Forms.Label
$Label.Text = "`n Phone: $CallServiceDesk `n E-Mail: `n IP Address: $IPAddress `n Computer Name: $env:computername `n Username: $env:username `n     Domain: $env:userdomain `n HomeServer: $env:HOMESERVER `n AssetTag: $env:TIA `n Service Tag: $env:servicetagsn `n McAfee Proxy: $Proxy"
$Label.BackColor = "Transparent"
$Label.AutoSize = $True

$Form.Controls.Add($Email_Label)
$Form.Controls.Add($Call_Label)
$Form.Controls.Add($Label)
$Form.Controls.Add($Button)
$Form.Controls.Add($Learn_Label)


$Form.ShowDialog() 

if ($Form -eq "Cancel"){exit}

1 个答案:

答案 0 :(得分:0)

我通过在我的字体变量

中添加[System.Drawing.GraphicsUnit]::Pixel来修复此问题
$Font = New-Object System.Drawing.Font("Segoe UI",13,[System.Drawing.FontStyle]::Regular,[System.Drawing.GraphicsUnit]::Pixel)
$Form.Font = $Font
相关问题