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.
Post Reply
james.bernard
Posts: 12
Joined: Wed Apr 29, 2020 8:00 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: 14676
Joined: Tue May 22, 2007 9:57 am
Answers: 6
Has voted: 1 time
Been upvoted: 5 times
Contact:

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: 7564
Joined: Tue May 29, 2007 4:43 pm
Answers: 2
Been upvoted: 5 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.

Post Reply