Synchronous ProgressBar

In Eyeshot 9 the ProgressBar can be used only in asynchronous WorkUnits (the ones ran with viewportLayout.StartWork()).

In case you want to use the ProgressBar in a synchronous way, independently from the WorkUnits, updating its value when needed and then calling Invalidate(), you can use this trick:

Derive the ProgressBar class and expose its Draw method:

       public class MyProgressBar : devDept.Eyeshot.ProgressBar
            public MyProgressBar()
                Visible = false;

            public void Draw(ViewportLayout.DrawSceneParams myParams)


Derive the ViewportLayout and draw the custom progress bar in the DrawOverlay method:

 internal class MyViewportLayout : devDept.Eyeshot.ViewportLayout
        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 the viewportLayout1 control as an instance of the MyViewportLayout class:


this.viewportLayout1 = new MyViewportLayout();


Somewhere in your code enable/disable the custom ProgressBar and update its value:

            var myProgr = ((MyViewportLayout) viewportLayout1).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;

Was this article helpful?
4 out of 4 found this helpful
Have more questions? Submit a request


  • How do you set the max value of the progress bar calculate the increment value?

  • Realised that you can calculate the value as a percentage.

    private int Progress(int count, int value, int total)
        return (int)((double)count / total * 100);

  • Is there some way to display multiple progress bars for display progress of simulations calculations in different threads and/or different WorkUnits?

    Thanks, Jas

Please sign in to leave a comment.