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.
This topic is 4 years and 8 months old and has exceeded the time allowed for comments. Please begin a new topic or use the search feature to find a similar but newer topic.
Locked
sprl111
Posts: 1
Last visit: Wed Jun 26, 2019 12:11 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
Last visit: Mon Jul 08, 2019 8:55 am
Been upvoted: 2 times

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: 15439
Last visit: Tue Nov 21, 2023 6:37 pm
Answers: 30
Has voted: 4 times
Been upvoted: 33 times

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: 15439
Last visit: Tue Nov 21, 2023 6:37 pm
Answers: 30
Has voted: 4 times
Been upvoted: 33 times

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 201 times
jvierra
Posts: 15439
Last visit: Tue Nov 21, 2023 6:37 pm
Answers: 30
Has voted: 4 times
Been upvoted: 33 times

Re: Circular Light Indictor Widget

Post by jvierra »

Here is a cute little toggle LED.
Attachments
Demo-LED2.psf
(69.97 KiB) Downloaded 162 times
jvierra
Posts: 15439
Last visit: Tue Nov 21, 2023 6:37 pm
Answers: 30
Has voted: 4 times
Been upvoted: 33 times

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 2995 times
Attachments
Demo-LED3.psf
(35.04 KiB) Downloaded 176 times
User avatar
Lembasts
Posts: 405
Last visit: Wed Mar 20, 2024 1:40 pm
Has voted: 1 time
Been upvoted: 1 time

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')?
This topic is 4 years and 8 months old and has exceeded the time allowed for comments. Please begin a new topic or use the search feature to find a similar but newer topic.
Locked