Circular Light Indictor Widget

Ask questions about creating Graphical User Interfaces (GUI) in PowerShell and using WinForms controls.
Forum rules
Do not post any licensing information in this forum.

Any code longer than three lines should be added as code using the 'Select Code' dropdown menu or attached as a file.
Locked
sprl111
Posts: 1
Joined: Mon Jun 17, 2019 12:19 pm

Circular Light Indictor Widget

Post by sprl111 »

Hello,

Does PowerShell Studio sport a circular light/LED type On/Off indicator of any type. I'm not finding one in the Toolbox. Maybe there is a way to make a button circular and make that function of a light indicator?

Thanks.

User avatar
davidc
Posts: 5913
Joined: Thu Aug 18, 2011 4:56 am

Re: Circular Light Indictor Widget

Post by davidc »

There is no build in or custom control set for this, but you could create your own.

It is possible to override the CheckBox's Paint event and draw an image, but that is a bit advanced. I recommend searching the web for C# examples.

If you were to use a Button with an image, you would have to track the state outside of the control and toggle the image within your script.
David
SAPIEN Technologies, Inc.

jvierra
Posts: 14453
Joined: Tue May 22, 2007 9:57 am
Contact:

Re: Circular Light Indictor Widget

Post by jvierra »

I would just use an picture control and paint a circular color in the center. Set the paint color to red or green as needed. It shouldn't take more thanabout 5 lines of code.

You could also just add two images (LED) and set the image as needed.

A third possibility is to use the XAML/WPF custom control to host the WPF LED control.

jvierra
Posts: 14453
Joined: Tue May 22, 2007 9:57 am
Contact:

Re: Circular Light Indictor Widget

Post by jvierra »

Here is a quick and dirty example. You can resize the LED without changing the code.

Using images would allow you to use pictures of LEDs or stoplights as an annunciator/indicator.
Attachments
Demo-LED.psf
(33.59 KiB) Downloaded 45 times

jvierra
Posts: 14453
Joined: Tue May 22, 2007 9:57 am
Contact:

Re: Circular Light Indictor Widget

Post by jvierra »

Here is a cute little toggle LED.
Attachments
Demo-LED2.psf
(69.97 KiB) Downloaded 35 times

jvierra
Posts: 14453
Joined: Tue May 22, 2007 9:57 am
Contact:

Re: Circular Light Indictor Widget

Post by jvierra »

Same control and code but altered for new look in the designer.
led3.jpg
led3.jpg (9.65 KiB) Viewed 1130 times
Attachments
Demo-LED3.psf
(35.04 KiB) Downloaded 39 times

User avatar
Lembasts
Posts: 293
Joined: Thu Mar 15, 2012 9:47 am

Re: Circular Light Indictor Widget

Post by Lembasts »

Thanks Mr. V - nice idea.
So to add images we can use open button in PS studio and just add our BMP/JPG.
To add an image programmatically is it:
$checkboxONOFF.image = [System.Drawing.image]::FromFile('c:\redcircle.bmp')?

Locked