【发布时间】:2016-12-07 17:42:29
【问题描述】:
我创建了一个表单来提供有关您所在计算机的信息,当我们将它部署到 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}
【问题讨论】:
标签: .net forms powershell dpi