0
ボタンを使ってフォームを表示するためにpowershellを使用しようとすると、ボタンがテストを実行します。 これは仕事です。 テストに失敗した場合は、ボタンの隣にある円が赤色になります。 と緑色です。これはできましたか?もしそうなら、FillEllipseは正しい方法ですか? 新しいフォームを作成する必要はありますか?powershellの形の赤い薄緑色の光
#Load the GDI+ and WinForms Assemblies
`enter code here`[void] [System.Reflection.Assembly]::LoadWithPartialName("System.Drawing")
[void] [System.Reflection.Assembly]::LoadWithPartialName("System.Windows.Forms")
# Create pen and brush objects
$myBrush = new-object Drawing.SolidBrush green
$mypen = new-object Drawing.Pen black
# Create a Rectangle object for use when drawing rectangle
#$rect = new-object Drawing.Rectangle 10, 10, 180, 180
# Create a Form
$form = New-Object System.Windows.Forms.Form
$form.Size = New-Object System.Drawing.Size(600,600)
$form.text = "Network Connectivity Test"
#$form = New-Object Windows.Forms.Form
# Get the form's graphics object
$formGraphics = $form.createGraphics()
function do-interface {
#
}
#$Label = New-Object System.Windows.Forms.Label
$Label.Text = "Ethernet 1"
#$Label.AutoSize = $true
$Label.Location = New-Object System.Drawing.Size(75,50)
$Font = New-Object System.Drawing.Font("Arial",15,[System.Drawing.FontStyle]::Bold)
$form.Font = $Font
$Form.Controls.Add($Label)
# Define the paint handler
$form.add_paint(
{
$formGraphics.FillEllipse($myBrush, 350, 80, 15, 15) # draw an ellipse using rectangle object
#$formGraphics.FillEllipse($myBrush, $rect) # draw an ellipse using rectangle object
}
)
$Button = New-Object System.Windows.Forms.Button
$Button.Location = New-Object System.Drawing.Size(30,30)
$Button.Size = New-Object System.Drawing.Size(90,40)
$Button.Text = "Interfaces"
$Button.Add_Click({do-interface})
$form.Controls.Add($Button)
$form.Add_Shown({$form.Activate()})
[void] $form.ShowDialog()