.net 高DPI powershell形式

.net 高DPI powershell形式,.net,forms,powershell,dpi,.net,Forms,Powershell,Dpi,我创建了一个表单来提供有关您所使用的计算机的信息,当我们将其部署到surface pro 4时,我们没有考虑DPI,它破坏了测试,表单中无法读取。见下文 不良形式: 它应该是这样的: 我尝试了所有的AutoSizeMode,并将其放入组和表中,但似乎没有任何效果。我把它放在StackOverflow上,看看是否有人有好的解决方案。以下是我的表单基础: #Background Image $Image = [system.drawing.image]::FromFile("Desktop.jp

我创建了一个表单来提供有关您所使用的计算机的信息,当我们将其部署到surface pro 4时,我们没有考虑DPI,它破坏了测试,表单中无法读取。见下文

不良形式:

它应该是这样的:

我尝试了所有的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}

我通过在我的字体变量中添加
[System.Drawing.GraphicsUnit]::Pixel
解决了这个问题

$Font = New-Object System.Drawing.Font("Segoe UI",13,[System.Drawing.FontStyle]::Regular,[System.Drawing.GraphicsUnit]::Pixel)
$Form.Font = $Font

我通过在我的字体变量中添加
[System.Drawing.GraphicsUnit]::Pixel
解决了这个问题

$Font = New-Object System.Drawing.Font("Segoe UI",13,[System.Drawing.FontStyle]::Regular,[System.Drawing.GraphicsUnit]::Pixel)
$Form.Font = $Font