In Eyeshot ProgressBar can be used only in asynchronous WorkUnits (the ones ran with design1.StartWork()).
In case you would like to use ProgressBar in a synchronous way, independently from WorkUnits, updating its value when needed and then calling Invalidate(), you can use this trick:
Derive ProgressBar class and expose its Draw method:
public class MyProgressBar : devDept.Eyeshot.Control.ProgressBar
{
public MyProgressBar()
{
Visible = false;
}
public void Draw(DrawSceneParams myParams)
{
base.Draw(myParams);
}
}
Derive Design and draw the custom progress bar in DrawOverlay method:
internal class MyDesign : devDept.Eyeshot.Control.Design
{
public MyProgressBar myProgr = new MyProgressBar();
protected override void DrawOverlay(DrawSceneParams data)
{
base.DrawOverlay(data);
if (myProgr.Visible)
{
data.Viewport = ActiveViewport;
myProgr.Draw(data);
}
}
}
Create design control as an instance of MyDesign class:
this.design1 = new MyDesign();
Somewhere in your code enable/disable the custom ProgressBar and update its value:
var myProgr = ((MyDesign) design1).myProgr;
if (!myProgr.Visible)
{
myProgr.Text = "Processing...";
myProgr.Visible = true;
myProgr.Value = 0;
}
else if (myProgr.Value == 100)
{
myProgr.Value = 0;
myProgr.Visible = false;
}
if (myProgr.Visible)
myProgr.Value += 10;
design1.Invalidate();
Comments
Is there any way to connect it to DoWork rather than StartWork without all this extra code for it to function properly?
Hi Adam,
This is not possible since the DoWork() method will prevent you to graphically upgrade the progress bar.
Please sign in to leave a comment.