In Eyeshot ProgressBar can be used only in asynchronous WorkUnits (the ones ran with model.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.ProgressBar
{
public MyProgressBar()
{
Visible = false;
}
public void Draw(ViewportLayout.DrawSceneParams myParams)
{
base.Draw(myParams);
}
}
Derive Model and draw the custom progress bar in DrawOverlay method:
internal class MyModel : devDept.Eyeshot.Model
{
public MyProgressBar myProgr = new MyProgressBar();
protected override void DrawOverlay(DrawSceneParams data)
{
base.DrawOverlay(data);
if (myProgr.Visible)
{
data.Viewport = Viewports[ActiveViewport];
myProgr.Draw(data);
}
}
}
Create model1 control as an instance of MyModel class:
this.model1 = new MyModel();
Somewhere in your code enable/disable the custom ProgressBar and update its value:
var myProgr = ((MyModel) model1).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;
model1.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.