Exemplo n.º 1
0
        private void HandleTransitionCompleted(object sender, TransitionCompletedEventArgs e)
        {
            TimerUtil.TraceAndDebugMessage(string.Format("Transition Completed at {0}:\tState ID: {1}\tEvent ID: {2}",
                                                         DateTime.Now,
                                                         ((CurlingTimmerStateMachine.StateID)(e.StateID)).ToString(),
                                                         ((CurlingTimmerStateMachine.EventID)(e.EventID)).ToString()), 1);
            switch ((CurlingTimmerStateMachine.StateID)e.StateID)
            {
            case CurlingTimmerStateMachine.StateID.TimingTeam1:
            case CurlingTimmerStateMachine.StateID.TimingTeam2:
                ProcessTimingTeamsEvents();
                break;

            case CurlingTimmerStateMachine.StateID.WaitingForRockReset:
                ProcessWaitingForRockResetEvents();
                break;

            case CurlingTimmerStateMachine.StateID.TimingBetweenEnds:
                ProcessTimingBetweenEndsEvents();
                break;

            case CurlingTimmerStateMachine.StateID.TimeOutDuringEnd:
                ProcessTimeOutDuringEndEvents();
                break;

            case CurlingTimmerStateMachine.StateID.EndOfGame:
                ProcessEndOfGameEvents();
                break;
            }
        }
Exemplo n.º 2
0
        private void ProcessTimingBetweenEndsEvents()
        {
            SetHammer();
            Opacity = .50;
            Refresh();
            TimeSpan timeout = new TimeSpan(0, 0, 30);

            if ((m_numberOfEndsToPlay == 10 && m_currentEnd == 5) || (m_numberOfEndsToPlay == 8 && m_currentEnd == 4))
            {
                timeout = new TimeSpan(0, 5, 0);
            }
            if (m_numberOfEndsToPlay == 1)
            {
                timeout = new TimeSpan(0, 3, 0);
            }
            ChronometerForm f1 = new ChronometerForm(timeout);

            f1.ShowDialog();
            Opacity = 1.0;
            Refresh();
            buttonTimeIn.Enabled     = true;
            buttonTimeOut.Enabled    = true;
            radioButtonTeam1.Enabled = false;
            radioButtonTeam2.Enabled = false;
            pbTeam1Status.Image      = ResGraphic.YellowDot;
            pbTeam2Status.Image      = ResGraphic.YellowDot;
            TimerUtil.TraceAndDebugMessage(string.Format("Completed End {0}", m_currentEnd), 0);
            m_currentEnd++;
            m_stateMachine.Send((int)CurlingTimmerStateMachine.EventID.StartTiming);
        }
Exemplo n.º 3
0
 private void FixTeamsNewTime(CurlingTimmerStateMachine.StateID stateID)
 {
     if (stateID == CurlingTimmerStateMachine.StateID.TimingTeam1)
     {
         TimeForTeam1 -= (DateTime.Now - SetReferenceTimeIn);
         if (TimeForTeam1.TotalSeconds < 1)
         {
             TimeForTeam1 = new TimeSpan(0, 0, 0);
         }
     }
     else if (stateID == CurlingTimmerStateMachine.StateID.TimingTeam2)
     {
         TimeForTeam2 -= (DateTime.Now - SetReferenceTimeIn);
         if (TimeForTeam2.TotalSeconds < 1)
         {
             TimeForTeam2 = new TimeSpan(0, 0, 0);
         }
     }
     SetReferenceTimeIn = DateTime.Now;
     if ((RockCountTeam1 >= 0) && (RockCountTeam2 >= 0))
     {
         TimerUtil.TraceAndDebugMessage(string.Format("Team 1 - Time Left {0} | Rocks Left {1} || Team2 - Time Left {2} | rocks Left {3}",
                                                      TimerUtil.FormatTime(TimeForTeam1), RockCountTeam1, TimerUtil.FormatTime(TimeForTeam2), RockCountTeam2), 0);
         if (RockCountTeam1 == RockCountTeam2)
         {
             TimerUtil.TraceAndDebugMessage(string.Empty, 0);
         }
     }
 }
Exemplo n.º 4
0
 private void buttonTimeOut_Click(object sender, EventArgs e)
 {
     TimerUtil.TraceAndDebugMessage("Button timeout pressed", 1);
     if ((CurlingTimmerStateMachine.StateID)m_stateMachine.CurrentStateID == (CurlingTimmerStateMachine.StateID.TimingTeam1))
     {
         if (m_timeOutLeftTeam1 != 0)
         {
             m_timeOutLeftTeam1--;
             m_timeOutUsedThisEndTeam1++;
         }
         else
         {
             return;
         }
     }
     else if ((CurlingTimmerStateMachine.StateID)m_stateMachine.CurrentStateID == (CurlingTimmerStateMachine.StateID.TimingTeam2))
     {
         if (m_timeOutLeftTeam2 != 0)
         {
             m_timeOutLeftTeam2--;
             m_timeOutUsedThisEndTeam2++;
         }
         else
         {
             return;
         }
     }
     else
     {
         return;
     }
     m_stateMachine.Send((int)CurlingTimmerStateMachine.EventID.TimeOut);
     buttonDummy.Select();
     buttonTimeOut.Enabled = false;
 }
Exemplo n.º 5
0
 private void ProcessWaitingForRockResetEvents()
 {
     stopTimingToolStripMenuItem.Enabled = false;
     m_scoreSheet.Add(new ScoreSheetLine(TimeAllowedForGame - TimeForTeam1, TimeAllowedForGame - TimeForTeam2, m_timeOutUsedThisEndTeam1, m_timeOutUsedThisEndTeam2));
     m_timeOutUsedThisEndTeam1 = 0;
     m_timeOutUsedThisEndTeam2 = 0;
     m_rockCount = 0;
     SetRockCount();
     if (EndOfRegularPlay())
     {
         HandleExtraEnds();
     }
     TimerUtil.TraceAndDebugMessage("Cancelling", 1);
     backgroundWorker2.CancelAsync();
     buttonTimeIn.Enabled     = true;
     buttonTimeOut.Enabled    = false;
     radioButtonTeam1.Visible = true;
     radioButtonTeam2.Visible = true;
     radioButtonTeam1.Enabled = true;
     radioButtonTeam2.Enabled = true;
     radioButtonTeam1.Checked = false;
     radioButtonTeam2.Checked = false;
     pbTeam1Status.Image      = ResGraphic.YellowDot;
     pbTeam2Status.Image      = ResGraphic.YellowDot;
 }
Exemplo n.º 6
0
 private void stopTimingToolStripMenuItem_Click(object sender, EventArgs e)
 {
     if (m_stateMachine == null)
     {
         return;
     }
     TimerUtil.TraceAndDebugMessage("Button Stop time pressed", 1);
     m_stateMachine.Send((int)CurlingTimmerStateMachine.EventID.TimeOut);
     buttonDummy.Select();
     buttonTimeOut.Enabled = false;
 }
Exemplo n.º 7
0
 private void HandleExitingState(object sender, StateEventArgs e)
 {
     TimerUtil.TraceAndDebugMessage(string.Format("Transition Exiting:\tState ID: {0}", ((CurlingTimmerStateMachine.StateID)(e.StateID)).ToString()), 1);
     switch ((CurlingTimmerStateMachine.StateID)e.StateID)
     {
     case CurlingTimmerStateMachine.StateID.TimingTeam1:
     case CurlingTimmerStateMachine.StateID.TimingTeam2:
         FixTeamsNewTime((CurlingTimmerStateMachine.StateID)e.StateID);
         break;
     }
 }
Exemplo n.º 8
0
 private void Form1_KeyPress(object sender, KeyPressEventArgs e)
 {
     TimerUtil.TraceAndDebugMessage(string.Format("Key pressed {0}", e.KeyChar), 1);
     if (e.KeyChar == ' ')
     {
         Debug.WriteLine("Processing space");
         if (buttonTimeIn.Enabled)
         {
             OperatorStartsChangeTiming();
         }
     }
 }
Exemplo n.º 9
0
        private void backgroundWorker2_DoWork(object sender, DoWorkEventArgs e)
        {
            BackgroundWorker worker = sender as BackgroundWorker;
            TimeSpan         startTimingDelaySpan = new TimeSpan(0, 0, 0, 0, StartTimingDelay);

            do
            {
                Thread.Sleep(TimerUtil.refrehPeriod);
                startTimingDelaySpan -= new TimeSpan(0, 0, 0, 0, TimerUtil.refrehPeriod);
                TimerUtil.TraceAndDebugMessage(string.Format("TimeSpan left {0}", startTimingDelaySpan), 1);
            } while (!worker.CancellationPending && (startTimingDelaySpan.CompareTo(new TimeSpan(0)) >= 0));
            if (worker.CancellationPending)
            {
                e.Cancel = true;
            }
        }
Exemplo n.º 10
0
 private void backgroundWorker2_RunWorkerCompleted(object sender, RunWorkerCompletedEventArgs e)
 {
     if (!m_fDone)
     {
         TimeSpan ts = m_dt - DateTime.Now;
         textBoxTimeLeft.Text = TimerUtil.FormatTime(ts);
         if (ts.CompareTo(new TimeSpan(0, 0, 0)) != 1)
         {
             TimerUtil.TraceAndDebugMessage("Chrono to 00:00", 0);
             Close();
         }
         else
         {
             backgroundWorker2.RunWorkerAsync();
         }
     }
 }
Exemplo n.º 11
0
 private void SendStartTiming()
 {
     KeyPress           -= new System.Windows.Forms.KeyPressEventHandler(this.Form1_KeyPress);
     buttonTimeIn.Click -= new System.EventHandler(this.buttonTimeIn_Click);
     backgroundWorker2.RunWorkerAsync();
     if (radioButtonTeam1.Checked || radioButtonTeam2.Checked)
     {
         optionsToolStripMenuItem.Enabled    = false;
         stopTimingToolStripMenuItem.Enabled = true;
         if (m_stateMachine == null)
         {
             SetHammer();
         }
         SetCursorPos(0, 0);
         TimerUtil.TraceAndDebugMessage("Sending StartTiming Event to state machine", 1);
         m_stateMachine.Send((int)CurlingTimmerStateMachine.EventID.StartTiming, null);
     }
     else
     {
         CurlingMessageBox.Show("Please select the team throwing the last rock", "Operator error", Properties.Resources.SelectLastRock);
     }
 }
Exemplo n.º 12
0
 private void buttonStartTimeInBetweenEnds_Click(object sender, EventArgs e)
 {
     TimerUtil.TraceAndDebugMessage("Button time-in between ends pressed", 1);
     buttonDummy.Select();
     SendStartTiming();
 }
Exemplo n.º 13
0
 private void buttonTimeIn_Click(object sender, EventArgs e)
 {
     TimerUtil.TraceAndDebugMessage("Button time-in pressed", 1);
     OperatorStartsChangeTiming();
 }
Exemplo n.º 14
0
 private void backgroundWorker2_RunWorkerCompleted(object sender, RunWorkerCompletedEventArgs e)
 {
     TimerUtil.TraceAndDebugMessage("Completed", 1);
     buttonTimeIn.Click += new System.EventHandler(this.buttonTimeIn_Click);
     KeyPress           += new System.Windows.Forms.KeyPressEventHandler(this.Form1_KeyPress);
 }
Exemplo n.º 15
0
 private void button1_Click(object sender, EventArgs e)
 {
     TimerUtil.TraceAndDebugMessage(string.Format("Exiting Chrono with {0} left", TimerUtil.FormatTime(m_dt - DateTime.Now)), 0);
     m_fDone = true;
     Close();
 }
Exemplo n.º 16
0
 public ChronometerForm(TimeSpan ts)
 {
     InitializeComponent();
     m_dt = DateTime.Now + ts;
     TimerUtil.TraceAndDebugMessage(string.Format("Entering Chrono for {0}", TimerUtil.FormatTime(ts)), 0);
 }