posted on Monday, November 26, 2007 10:07 AM |

For the bartender system, now that the timing is offloaded to the relay boards, I've run into a problem.  I have a progress bar but no real way to have it update.

In doing so, I created crappy time based progress bar.  I used a timer and inherited off the pre-existing progress bar.  This was done with Visual Studio 2008 also.  VS 2005 users will have to just drop the get/set or add in a private variable.  94ms is a rough estimation, at 1 minute, it is a secondish too long, at 93ms, it is a secondish too short.  Since this is all for visual pop, I don't think it really matters.

Why is there a public new void PerformStep()?  I had to override the base class's function and that is what I had to do.  The funny thing is I still call the base.PerformStep() in the timer_Tick function.

public class ProgressBarTimed : ProgressBar
{
private Timer timer = new Timer();
//DateTime start;

public int Milliseconds{ get; set; }

public new void PerformStep()
{
    Step = 100;
    timer.Interval = 94; // extra cycles for timer event and progress bar event
    Maximum = Milliseconds;
    timer.Tick += timer_Tick;
    timer.Start();
    //start = DateTime.Now;
}

private void timer_Tick(object sender, EventArgs e)
{
    base.PerformStep();
    if (Value == Maximum)
    {
        timer.Stop();

        //MessageBox.Show(start + "\n" + DateTime.Now + "\n" + (DateTime.Now - start).Milliseconds.ToString());
    }
}
}
Tags [ Building Drunktender pictures ]

Your Comments.

  • # re: Automated bartender progress

    I am impressed with your progress and quality of work.

    Left by Bob Rutkas at 11/10/2007 7:29 AM
Post Comment
Title *
Name *
Email
Url
Comment *  
Please add 6 and 7 and type the answer here: