Page 1 of 1

Circular Light Indictor Widget

Posted: Wed Jun 26, 2019 9:53 am
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.

Re: Circular Light Indictor Widget

Posted: Wed Jun 26, 2019 10:16 am
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.

Re: Circular Light Indictor Widget

Posted: Wed Jun 26, 2019 10:33 am
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.

Re: Circular Light Indictor Widget

Posted: Wed Jun 26, 2019 11:02 am
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.

Re: Circular Light Indictor Widget

Posted: Wed Jun 26, 2019 11:24 am
by jvierra
Here is a cute little toggle LED.

Re: Circular Light Indictor Widget

Posted: Wed Jun 26, 2019 11:28 am
by jvierra
Same control and code but altered for new look in the designer.
led3.jpg
led3.jpg (9.65 KiB) Viewed 2991 times

Re: Circular Light Indictor Widget

Posted: Tue Jul 02, 2019 5:10 pm
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')?