示例#1
0
        //TODO: Change the time calculation to be more accurate
        private void OnTimeEvent(object sender, ElapsedEventArgs e)
        {
            Invoke(new Action(() =>
            {
                s += 1;
                if (s == 60)
                {
                    s  = 0;
                    m += 1;
                }
                if (m == 60)
                {
                    m  = 0;
                    h += 1;
                }

                if (s % 30 == 0)
                {
                    if (forceIndex >= forceLabels.Length)
                    {
                        for (int i = 0; i < forceLabels.Length; i++)
                        {
                            forceLabels[i].Text = forceArray[forceIndex - (forceLabels.Length - i) + 1].ToString();
                        }
                        for (int i = 0; i < timeLabels.Length; i++)
                        {
                            timeLabels[i].Text = timeArray[forceIndex - (timeLabels.Length - i)].ToString();
                        }
                    }
                    else if (forceIndex > 0)
                    {
                        feedbackControl.PushPunch(forceArray[forceIndex]);
                        cumulativeTime += timeArray[forceIndex - 1];
                        timeLabels[forceIndex - 1].Text = timeArray[forceIndex - 1].ToString();
                        session.insertHit(forceArray[forceIndex], cumulativeTime);
                        forceLabels[forceIndex].Text      = forceArray[forceIndex].ToString();
                        forceLabels[forceIndex].ForeColor = System.Drawing.Color.CadetBlue;
                    }
                    else
                    {
                        forceLabels[forceIndex].Text      = forceArray[forceIndex].ToString();
                        forceLabels[forceIndex].ForeColor = System.Drawing.Color.CadetBlue;
                    }
                    forceIndex++;


                    totalTime.Text = string.Format("{0:00}:{1:00}:{2:00}", h, m, s);
                    if (forceIndex >= forceArray.Length)
                    {
                        SoundPlayer bellRing   = new SoundPlayer(@"soundEffect\old-fashioned-bell.wav");
                        scoreInfoLabel.Text    = string.Format("{0:n0} N", session.TotalForce);
                        totalTimeLabelnfo.Text = string.Format("{0:0.00} s", cumulativeTime);
                        bellRing.Play();
                        t.Stop();

                        History.InsertSession(session);
                    }
                }
            }));
        }
示例#2
0
        // Called on every tick of the timer to simulate punches to the punching bag
        private void propagate()
        {
            lastHit.Text = arrayTest[i].ToString();

            if (useFeedback)
            {
                feedbackControl.PushPunch(arrayTest[i]);
            }

            session.insertHit(arrayTest[i], timeIntervalSec - (quickTotal / 1000.0));

            i = (i + 1) % arrayTest.Length;
        }