Hello everyone.
Is there any way to show during form load a splash window?
My From takes 16 seconds to load, due to some modules, and I want to add a Gif inside a PictureBox to be shown during that time? is this possible? I know that Studio has a timer but don't know how to use it, I've seen some examples and try to replicate them using the PictureBox but it did not work.
PictureBox Timer
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.
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.
Re: PictureBox Timer
Just add a timer from the toolbox. You can use the timer default event to do things at each timer tick.
For instructions and example on how to use the Timer control see: https://info.sapien.com/index.php/guis/ ... er-control
For instructions and example on how to use the Timer control see: https://info.sapien.com/index.php/guis/ ... er-control
Re: PictureBox Timer
I've tried to do that but not sure how to get it to work. tried to modify some elements from the example, well thanks for the info, I'll keep practicing
Re: PictureBox Timer
I been meaning to create a function snippet to show a splash screen. Let me see if I can get something in for the next service release of PowerShell Studio.
David
SAPIEN Technologies, Inc.
SAPIEN Technologies, Inc.
Re: PictureBox Timer
David to the rescue. Good idea.
Here is a sample of how to use a timer.
This is from my "snippet" store and I just added the timer to show how it works in a form and how to access and set the event. PowerShell Studio does all of this for you in a few clicks.
Here is a sample of how to use a timer.
Code: Select all
Add-Type -AssemblyName System.Windows.Forms
# control creation
$form = New-Object System.Windows.Forms.Form
$buttonOK = New-Object System.Windows.Forms.Button
$form.Controls.Add($buttonOK)
$timer = New-Object System.Windows.Forms.Timer
# form settings
$form.StartPosition = 'CenterScreen'
$form.Text = 'Basic Form Demo'
$form.add_Load({$timer.Start()})
# buttonOK settings
$buttonOK.Text = 'Ok'
$buttonOK.DialogResult = 'Ok'
#timer settings
$timer.Interval = 1000 # on second
$timer.add_Tick({Write-Host 'Tick!'})
$form.ShowDialog()
Re: PictureBox Timer
Yup that will be a great Idea, per your example, this will only work with text?
$TotalTime = 5 #in seconds
$script:StartTime = (Get-Date).AddSeconds($TotalTime)
$timer1.Start()
$timer1_Tick = {
[TimeSpan]$span = $script:StartTime - (Get-Date)
$picturebox.Visible = $true
$textbox2.Visible = $true # here should show both textbox and pictubox
if ($span.TotalSeconds -le 0)
{
$timerUpdate.Stop()
$picturebox.Visible = $false
$textbox2.Visible = $false
}
}
$TotalTime = 5 #in seconds
$script:StartTime = (Get-Date).AddSeconds($TotalTime)
$timer1.Start()
$timer1_Tick = {
[TimeSpan]$span = $script:StartTime - (Get-Date)
$picturebox.Visible = $true
$textbox2.Visible = $true # here should show both textbox and pictubox
if ($span.TotalSeconds -le 0)
{
$timerUpdate.Stop()
$picturebox.Visible = $false
$textbox2.Visible = $false
}
}
Re: PictureBox Timer
What are you trying to say?
TotalSeconds will never change in your example. Something has to decrement the span.
If you are looking for an elapsed time timer then just set the timer to 16000 and stop it when the event is expired.
TotalSeconds will never change in your example. Something has to decrement the span.
If you are looking for an elapsed time timer then just set the timer to 16000 and stop it when the event is expired.
Re: PictureBox Timer
You can also just add an elapsed time timer at any time in the form. On load or a button click.
Code: Select all
$form1_Load={
$timer = [System.Timers.Timer]::New(16000)
$timer.AutoReset = $false
$timer.SynchronizingObject = $form1
$timer.add_Elapsed({
Write-Host 'Done!'
})
$timer.Start()
}
Re: PictureBox Timer
That just did the trick and so simple, I was writing a lot of thing with no sense, thanks!!!!!!!