简体   繁体   English

如何使用Powershell Studio 2012在进度条中制作品牌?

[英]How can I make a marque in the progress bar using Powershell Studio 2012?

Is anyone familiar with how to make the progress bar show a "moving" effect in a marque-style while performing a script task in Powershell Studio 2012? 在Powershell Studio 2012中执行脚本任务时,是否有人熟悉如何使进度条在品牌风格中显示“移动”效果?

I do not want it to display a percentage or something. 我不希望它显示百分比或其他东西。 When I hit a button it will start to load.... and when finished it will stop. 当我按下一个按钮时它将开始加载....一旦完成它将停止。 The most convenient method would be to have two functions, "Load" and "Done". 最方便的方法是有两个功能,“加载”和“完成”。

Is this possible? 这可能吗?

You could use Write-Progress -Activity "Doing stuff" -Status "Working" -PercentComplete $X , then vary X from 25-99 so the progress bar does that funky fill/reset thing. 你可以使用Write-Progress -Activity "Doing stuff" -Status "Working" -PercentComplete $X ,然后从Write-Progress -Activity "Doing stuff" -Status "Working" -PercentComplete $X改变X,这样进度条可以做那个时髦的填充/重置事情。

The default Write-Progress cmdlet doesn't have a marquee style though. 但是,默认的Write-Progress cmdlet没有选框样式。

lets say you got a button that runs a code and perform some kind of task.... 假设你有一个运行代码并执行某种任务的按钮....
Example: 例:

$buttonStart_Click={
    $progressbar1.MarqueeAnimationSpeed = 5 #this set the speed of the animation to 5
    #your code here...
    $progressbar1.MarqueeAnimationSpeed = 0 #this will stop the animation
}

One crucial thing though, if your code will do some "heavy" tasks, most likely the form and the progressbar with it will freeze until it finishes the task. 但有一件重要的事情,如果你的代码会执行一些“繁重的”任务,那么表单和带有它的进度条很可能会冻结,直到它完成任务。 so no point of having a bar is it. 所以没有任何一个酒吧的意义。
simple and lazy solution will be this line: 简单和懒惰的解决方案将是这一行:

[System.Windows.Forms.Application]::DoEvents()

this will unfreeze the form while the code runs the task. 这将在代码运行任务时解冻窗体。 check the Sapien's spotlight of the bar. 检查Sapien酒吧的聚光灯。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM