red light green light in a form powershell
<p>trying to use powershell to display a form with a button
the button will perform a test. this is work.
if the test fails the a circle next to the button will be red
vs green. Can this been done ? if so is FillEllipse the right way ?
Do I need to create a new form ?</p>

<pre><code>#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()
</code></pre>