GUI Questions

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 3 years and 3 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
james.bernard
Posts: 16
Last visit: Wed Oct 26, 2022 8:29 am

GUI Questions

Post by james.bernard »

Product, version and build: 5.7.174.0
32 or 64 bit version of product: 64
Operating system: Win 10
32 or 64 bit OS: 64

Hey all,
first thanks for the assistance with Job Tracker, I got it working after actually doing what ya'll said :). I have 2 hopefully quick questions.
1) I am trying out the Dark and Light theme for GUI Forms you have setup, I see that you can set certain defined properties for when switching, but can you layout 2 completely different custom themes for switching between Dark and Light? i.e. Make a complete Dark theme with dark icons in the picture boxes, save that, and set that as the dark and then do the same with light? I already have done the predefined properties like borders and whatnot but was curious about having different images as well.
2) With the Job Tracker I have it return if the PC is online or not with a ping before the job runs the scriptblock. It is working but I am not sure if its the best way to go about it, and wanted to know if you guys had a better way of accomplishing it. I will put the code I am using below.
Thanks for all your help!

Code: Select all

#Create a New Job using the Job Tracker
		
		$paramAddJobTracker = @{
			
			Name	  = 'JobName'
			
			JobScript = {
				
				#--------------------------------------------------
			
			Param ($computername)
				
				#Important: Do not access form controls from this script block.
			$PingCheck = Test-Connection $Computername -count 1 -quiet
			if ($PingCheck)
			{
				$RunCDollar = $DrivePath = "\\$ComputerName\C$"
				explorer.exe $DrivePath
				
			}
			else
			{
				$LTJ = "stopped"
			}
			if ($LTJ -ne $null)
			{
				$LTJ
			}
			#--------------------------------------------------
				
			}
			
			ArgumentList = $ComputerName
			
			CompletedScript = {
				
				Param ([System.Management.Automation.Job]$Job)
			$results = Receive-Job -Job $Job
			$outputbox.Clear()
			$LTJ = @($results)[-1]
				if ($LTJ -eq "stopped")
				{
				$outputbox.Clear()
				$outputbox.SelectionColor = 'Red';
				$outputbox.AppendText("PC is Offline")
				}
jvierra
Posts: 15439
Last visit: Tue Nov 21, 2023 6:37 pm
Answers: 30
Has voted: 4 times
Been upvoted: 33 times

Re: GUI Questions

Post by jvierra »

Themes in WinForms are managed by the system. We can only choose what is available. You could detect the current theme then set your icons.

As far as I can tell, full themes are only available in WPF.
User avatar
Alexander Riedel
Posts: 8488
Last visit: Tue Apr 16, 2024 8:42 am
Answers: 20
Been upvoted: 37 times

Re: GUI Questions

Post by Alexander Riedel »

I think he is asking about the dark mode / light mode form template in PowerShell Studio, not the Windows theme.
You can edit the Set-ControlTheme function to include changing the pictures when switching from light or dark
Alexander Riedel
SAPIEN Technologies, Inc.
This topic is 3 years and 3 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