При запуске кода ниже содержание намного шире, чем ширина разрешения.Таким образом, вы должны прокрутить вправо.Как я могу это исправить, чтобы он обернулся в текущем разрешении ширины?
example.ps1:
<#
Example
#>
[void] [System.Reflection.Assembly]::LoadWithPartialName("System.Drawing")
[void] [System.Reflection.Assembly]::LoadWithPartialName("System.Windows.Forms")
[void] [System.Windows.Forms.Application]::EnableVisualStyles()
#
function NewButton {
Param ([string] $text,[System.EventHandler] $execute, [System.Windows.Forms.FlowLayoutPanel]$panel)
$button = New-Object System.Windows.Forms.Button
$button.Size = New-Object System.Drawing.Size(200,200)
$button.Text = $text
$button.Add_Click($execute)
$panel.Controls.Add($button)
}
function NewForm {
` $Form = New-Object system.Windows.Forms.Form
$Form.AutoScroll = $True
$form.AutoSize = $true;
$form.AutoSizeMode = [System.Windows.Forms.AutoSizeMode]::GrowAndShrink
$Form.Text = "WinMenu"
$Form.Opacity = 0.9
$Form.StartPosition = "CenterScreen"
$Form.WindowState = [System.Windows.Forms.FormWindowState]::Normal
$Icon = [system.drawing.icon]::ExtractAssociatedIcon($PSHOME + "\powershell.exe")
$Form.Icon = $Icon
return $Form
}
function newFlowPanel {
Param([system.windows.forms.form]$form)
$flowPanel = New-object System.Windows.Forms.FlowLayoutPanel
$flowPanel.AutoSize = $true
$flowPanel.AutoScroll = $true
$flowPanel.WrapContents = $true
$flowPanel.FlowDirection = [System.Windows.Forms.FlowDirection]::LeftToRight
$flowpanel.AutoSizeMode = [System.Windows.Forms.AutoSizeMode]::GrowAndShrink
$form.Controls.Add($flowpanel)
return $flowpanel
}
$form = NewForm
$flowpanel = newFlowPanel -form $form
function Tskschd { Start-Process -FilePath "$($env:windir)\system32\taskschd.msc"}
function Regedit { Start-Process -FilePath "$($env:windir)\system32\regedt32.exe"}
function SoundVolume { Start-Process -FilePath "$($env:windir)\system32\sndvol.exe"}
function Programs { Start-Process -FilePath "$($env:windir)\system32\appwiz.cpl"}
function Azman { Start-Process -FilePath "$($env:windir)\system32\azman.msc"}
function Cert { Start-Process -FilePath "$($env:windir)\system32\certlm.msc"}
function Services { Start-Process -FilePath "$($env:windir)\system32\services.msc"}
function Firewall { Start-Process -FilePath "$($env:windir)\system32\wf.msc"}
function Tpm { Start-Process -FilePath "$($env:windir)\system32\tpm.msc"}
function Compmgmt { Start-Process -FilePath "$($env:windir)\system32\compmgmt.msc"}
function Comexp { Start-Process -FilePath "$($env:windir)\system32\comexp.msc"}
function Ssms {Start-Process -FilePath "C:\Program Files (x86)\Microsoft SQL Server Management Studio 18\Common7\IDE\Ssms.exe"}
function HackerNews {Start-Process -FilePath "https://news.ycombinator.com/"}
NewButton -text "TaskScheduler" -execute ${function:Tskschd} -panel $flowpanel
NewButton -text "Regedit" -execute ${function:Regedit} -panel $flowpanel
NewButton -text "SoundVolumne" -execute ${function:SoundVolume} -panel $flowpanel
NewButton -text "Programs" -execute ${function:Programs} -panel $flowpanel
NewButton -text "Azman" -execute ${function:Azman} -panel $flowpanel
NewButton -text "Cert" -execute ${function:Cert} -panel $flowpanel
NewButton -text "Services" -execute ${function:Services} -panel $flowpanel
NewButton -text "Firewall" -execute ${function:Firewall} -panel $flowpanel
NewButton -text "Tpm" -execute ${function:Tpm} -panel $flowpanel
NewButton -text "Compmgmt" -execute ${function:Compmgmt} -panel $flowpanel
NewButton -text "Comexp" -execute ${function:Comexp} -panel $flowpanel
NewButton -text "Ssms" -execute ${function:Ssms} -panel $flowpanel
NewButton -text "HackerNews" -execute ${function:HackerNews} -panel $flowpanel
# repeast
NewButton -text "TaskScheduler" -execute ${function:Tskschd} -panel $flowpanel
NewButton -text "Regedit" -execute ${function:Regedit} -panel $flowpanel
NewButton -text "SoundVolumne" -execute ${function:SoundVolume} -panel $flowpanel
NewButton -text "Programs" -execute ${function:Programs} -panel $flowpanel
NewButton -text "Azman" -execute ${function:Azman} -panel $flowpanel
NewButton -text "Cert" -execute ${function:Cert} -panel $flowpanel
NewButton -text "Services" -execute ${function:Services} -panel $flowpanel
NewButton -text "Firewall" -execute ${function:Firewall} -panel $flowpanel
NewButton -text "Tpm" -execute ${function:Tpm} -panel $flowpanel
NewButton -text "Compmgmt" -execute ${function:Compmgmt} -panel $flowpanel
NewButton -text "Comexp" -execute ${function:Comexp} -panel $flowpanel
NewButton -text "Ssms" -execute ${function:Ssms} -panel $flowpanel
NewButton -text "HackerNews" -execute ${function:HackerNews} -panel $flowpanel
# repeat
NewButton -text "TaskScheduler" -execute ${function:Tskschd} -panel $flowpanel
NewButton -text "Regedit" -execute ${function:Regedit} -panel $flowpanel
NewButton -text "SoundVolumne" -execute ${function:SoundVolume} -panel $flowpanel
NewButton -text "Programs" -execute ${function:Programs} -panel $flowpanel
NewButton -text "Azman" -execute ${function:Azman} -panel $flowpanel
NewButton -text "Cert" -execute ${function:Cert} -panel $flowpanel
NewButton -text "Services" -execute ${function:Services} -panel $flowpanel
NewButton -text "Firewall" -execute ${function:Firewall} -panel $flowpanel
NewButton -text "Tpm" -execute ${function:Tpm} -panel $flowpanel
NewButton -text "Compmgmt" -execute ${function:Compmgmt} -panel $flowpanel
NewButton -text "Comexp" -execute ${function:Comexp} -panel $flowpanel
NewButton -text "Ssms" -execute ${function:Ssms} -panel $flowpanel
NewButton -text "HackerNews" -execute ${function:HackerNews} -panel $flowpanel
$form.ShowDialog()