Form opacticy not working

This forum can be browsed by the general public. Posting is limited to current SAPIEN license holders with active maintenance and does not offer a response time guarantee.
Forum rules
DO NOT POST LICENSE NUMBERS, ACTIVATION KEYS OR ANY OTHER LICENSING INFORMATION IN THIS FORUM.
Only the original author and our tech personnel can reply to a topic that is created in this forum. If you find a topic that relates to an issue you are having, please create a new topic and reference the other in your post.

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 1 year and 10 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.
User avatar
B Daring
Posts: 90
Last visit: Mon Feb 05, 2024 3:00 pm
Answers: 2
Has voted: 1 time

Form opacticy not working

Post by B Daring »

I am running the following:

Product: PowerShell Studio 2022 (64 Bit)
Build: v5.8.205
OS: Windows 10 Pro (64 Bit)
Build: v10.0.19044.0

It was also seen on version prior to 205 version 201 (I believe). So what I have is my predecessor had a made a script with a splash screen that does a fade in, basically from here
https://info.sapien.com/index.php/guis/ ... de-in-form

The script works great until I try to run it on a machine that does not have .NET 3.5 installed. What I see when it loads is nothing pops up, but in task manager I see it stuck (trying to load) on the splash screen, which I can only assume it is trying to initialize. Now, I wouldn't think not having .NET 3.5 installed would cause this but it is the only thing that has changed on the machine. I also don't see anything in the event viewer as far as errors or crashes.

Script is below of the splash screen:

Code: Select all

$formSplashForm_Load= {
	#TODO: Initialize Form Controls here
	$timer1.Start()
	$Darker = 1
	$formSplashForm.Opacity = 0
}
$picturebox1_Click={
	#TODO: Place custom script here
	
}#end picturebox1_Click

$timer1_Tick =
{
	#TODO: Place custom script here
	
	If ($Darker -eq 1)
	{
		$formSplashForm.Opacity += 0.05
		if ($formSplashForm.Opacity -ge 1)
			{
				#Stop the timer once we are 100% visible
				$timer1.stop()
				Start-Sleep -s 2
				$Darker = 0
				$timer1.start()
			}
	}
	If ($Darker -eq 0)
	{
		$formSplashForm.Opacity += (-1)
		if ($formSplashForm.Opacity -eq 0)
		{
			$timer1.Stop()
			$formSplashForm.Close()
			#Write-Host "Close Splash"
		}
	}
	
} #end timer1_Tick
User avatar
brittneyr
Site Admin
Posts: 1655
Last visit: Thu Mar 28, 2024 3:14 pm
Answers: 39
Been upvoted: 30 times

Re: Form opacticy not working

Post by brittneyr »

As I tested the example from the article provided, I have found no issues running that form on a machine without .NET 3.5.

Are you packaging this script as an executable?

Does your script run as expected when you run it in a PowerShell console from your machine?

Can you please elaborate on what you mean by "It was also seen on version prior to 205 version 201"?

Can you please export the script or project (Deploy->Export) so I can see the whole script?
Brittney
SAPIEN Technologies, Inc.
User avatar
B Daring
Posts: 90
Last visit: Mon Feb 05, 2024 3:00 pm
Answers: 2
Has voted: 1 time

Re: Form opacticy not working

Post by B Daring »

Thanks Brittneyr,

Yes, packaging it as an executable.

Does your script run as expected when you run it in a PowerShell console from your machine? not currently

"It was also seen on version prior to 205 version 201"? Meaning I experienced the same results prior to updating to 5.8.205

I think I am narrowing it down. In previous versions of Studio we were able to set variables, like I show in the code above, in the timer_tick section. It appears now that it doesn't see those variables? Can we still do that or it is not possible anymore?


$timer1_Tick =
{
#TODO: Place custom script here

If ($Darker -eq 1)
{

The red is no longer working. It sees $Darker as $null, not 0 and not 1 So the timer1 tick runs constantly, never ends. Unless there is a setting I am not aware of.
User avatar
brittneyr
Site Admin
Posts: 1655
Last visit: Thu Mar 28, 2024 3:14 pm
Answers: 39
Been upvoted: 30 times

Re: Form opacticy not working

Post by brittneyr »

From the script you provided above, you never set the variable outside of the scope of a script block. This isn't something we changed, this is how PowerShell scoping rules work.

From the scope of your $timer1_Tick script block, $Darker was never defined.

For more information on PowerShell scope, please refer to the following:
https://www.sapien.com/blog/2015/09/09/ ... l-gui-app/
https://www.sapien.com/blog/2013/04/10/ ... revisited/
Brittney
SAPIEN Technologies, Inc.
User avatar
B Daring
Posts: 90
Last visit: Mon Feb 05, 2024 3:00 pm
Answers: 2
Has voted: 1 time

Re: Form opacticy not working

Post by B Daring »

Thank you very much Brittneyr,

That fixed it. So I must say it did work on an older version of Studio because we have it running currently, but with studio referencing .NET 4.x it stopped. That's what I was tying to do, upgrade all our scripts to stop using .NET 3.5 and this was one that was compiled with 3.5. Hence it broke when I compiled it with 4.x
This topic is 1 year and 10 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.