Marquee - progress bar how to use it?

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 5 years and 3 days 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
User avatar
lontru
Posts: 103
Last visit: Thu Mar 07, 2024 2:00 pm

Marquee - progress bar how to use it?

Post by lontru »

https://info.sapien.com/index.php/guis/ ... ar-control
I have a loop that run when i press a button until a condition is meet.
so i want to use the Marquee animation but i cant figure out how to use it?

Marquee
Indicates progress by continuously scrolling a block across a ProgressBar in a marquee fashion. Use Marquee when you can’t specify a quantity of progress, but still need to indicate that progress is being made. Use the MarqueeAnimationSpeed property to control the speed of the ProgressBar.
Image

here the button code:

Code: Select all

$buttonRemove_Click = {
	if ([System.Windows.Forms.MessageBox]::Show("Continue removing: $cmdevice from $global:TargetCollection", "Warning", [System.Windows.Forms.MessageBoxButtons]::OKCancel) -eq "OK")
	{
		$statusbar1.Text = "Removing Device: $cmdevice from collection: $global:TargetCollection"
		Remove-CMDeviceCollectionDirectMembershipRule -CollectionId "$($(Get-CMCollection -Name "$global:TargetCollection").CollectionID)" -ResourceId $SelectedCM
		$progressbar1.Style = 'Marquee'
		$progressbar1.Step = 1
		$progressbar1.Value = 0
		$progressbar1.Maximum = 100
		DO
		{
			$a
			$a++
			Start-Sleep -Seconds 1
			Write-Host "$a"
			$statusbar1.Text = "Removing Device Pending: $cmdevice - $a"
			$progressbar1.Style = 'Marquee'
			$progressbar1.Visible = $true
			$progressbar1.Refresh
			$progressbar1.Value += 1
			
			$Check = Get-CMCollectionMember -CollectionName "$global:TargetCollection" -Name "$cmdevice"
		}
		Until (!$Check)
		$progressbar1.Visible = $false
		Refreshdatagridview
		$statusbar1.Text = "Removing Device: $cmdevice - DONE"
		$date = Get-Date
		$message = ("Device: $cmdevice was removed from collection: $global:TargetCollection by $Name - $($env:UserName) - $date")
		Write-Host "$message"
		Write-log -message ("$message") -component "$($env:UserName)" -Severity 1 -Function "$($MyInvocation.MyCommand)"
	}
	else
	{
		$statusbar1.Text = "User cancelled device $cmdevice removal from: $global:TargetCollection"
	}
	
}
jvierra
Posts: 15439
Last visit: Tue Nov 21, 2023 6:37 pm
Answers: 30
Has voted: 4 times
Been upvoted: 33 times

Re: Marquee - progress bar how to use it?

Post by jvierra »

See this blog: https://www.sapien.com/blog/2019/03/12/ ... lications/

It is new and does a good job of explaining how to use a progress bar.
User avatar
lontru
Posts: 103
Last visit: Thu Mar 07, 2024 2:00 pm

Re: Marquee - progress bar how to use it?

Post by lontru »

is there a download link for the sample showed in the blog?

The code behind this form?
Image
jvierra
Posts: 15439
Last visit: Tue Nov 21, 2023 6:37 pm
Answers: 30
Has voted: 4 times
Been upvoted: 33 times

Re: Marquee - progress bar how to use it?

Post by jvierra »

The example is part of PowerShell Studio. It is on the toolbox panel on the tab for custom control sets.
User avatar
lontru
Posts: 103
Last visit: Thu Mar 07, 2024 2:00 pm

Re: Marquee - progress bar how to use it?

Post by lontru »

Is this where you are refering to? i only have these?
Image
jvierra
Posts: 15439
Last visit: Tue Nov 21, 2023 6:37 pm
Answers: 30
Has voted: 4 times
Been upvoted: 33 times

Re: Marquee - progress bar how to use it?

Post by jvierra »

As per the articles - "Button - Start-Job" and "Form - Job Tracker".

These are the demos and can easily be edited to customize the results.
User avatar
lontru
Posts: 103
Last visit: Thu Mar 07, 2024 2:00 pm

Re: Marquee - progress bar how to use it?

Post by lontru »

i see i will look into those sample code
This topic is 5 years and 3 days 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