예제 #1
0
파일: Form1.cs 프로젝트: PLS54/CSharpCode
 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);
         }
     }
 }
예제 #2
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();
         }
     }
 }
예제 #3
0
        private void PopulateGrid(Collection <ScoreSheetLine> sca)
        {
            int iEnd = 1;

            dataGridView1.Rows.Clear();
            foreach (ScoreSheetLine sc in sca)
            {
                if (sc != null)
                {
                    dataGridView1.Rows.Add();
                    dataGridView1.Rows[iEnd - 1].Cells[0].Value = iEnd.ToString();
                    dataGridView1.Rows[iEnd - 1].Cells[1].Value = TimerUtil.FormatTime((TimeSpan)sc.TimeUsedTeam1);
                    dataGridView1.Rows[iEnd - 1].Cells[3].Value = TimerUtil.FormatTime((TimeSpan)sc.TimeUsedTeam2);
                    dataGridView1.Rows[iEnd - 1].Cells[2].Value = sc.TimeoutLeftTeam1.ToString();
                    dataGridView1.Rows[iEnd - 1].Cells[4].Value = sc.TimeoutLeftTeam2.ToString();
                    iEnd++;
                }
            }
        }
예제 #4
0
파일: Form1.cs 프로젝트: PLS54/CSharpCode
 void backgroundWorker1_DoWork(object sender, DoWorkEventArgs e)
 {
     for (; ;)
     {
         BackgroundWorker worker = sender as BackgroundWorker;
         if (worker.CancellationPending)
         {
             e.Cancel = true;
         }
         else if (EndOfGame)
         {
             ControlBox = true;
             e.Cancel   = true;
         }
         else if (m_stateMachine != null)
         {
             if (m_stateMachine.CurrentStateID == (int)CurlingTimmerStateMachine.StateID.TimingTeam1)
             {
                 //
                 // It's on a different thread, so use Invoke.
                 //
                 SetTextCallback d     = new SetTextCallback(SetText1);
                 string          text1 = TimerUtil.FormatTime(TimeForTeam1 - (DateTime.Now - SetReferenceTimeIn));
                 try {
                     this.Invoke(d, new object[] { text1 + " (Invoke)" });
                 } catch (ObjectDisposedException) {}
             }
             else if (m_stateMachine.CurrentStateID == (int)CurlingTimmerStateMachine.StateID.TimingTeam2)
             {
                 //
                 // It's on a different thread, so use Invoke.
                 //
                 SetTextCallback d     = new SetTextCallback(SetText2);
                 string          text2 = TimerUtil.FormatTime(TimeForTeam2 - (DateTime.Now - SetReferenceTimeIn));
                 try {
                     this.Invoke(d, new object[] { text2 + " (Invoke)" });
                 } catch (ObjectDisposedException) {}
             }
         }
         System.Threading.Thread.Sleep(TimerUtil.refrehPeriod);
     }
 }
예제 #5
0
파일: Form1.cs 프로젝트: PLS54/CSharpCode
 private void DisplayCurrentTimeInDialog()
 {
     textBoxTeam1.Text = TimerUtil.FormatTime(TimeForTeam1);
     textBoxTeam2.Text = TimerUtil.FormatTime(TimeForTeam2);
 }
예제 #6
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();
 }
예제 #7
0
 public ChronometerForm(TimeSpan ts)
 {
     InitializeComponent();
     m_dt = DateTime.Now + ts;
     TimerUtil.TraceAndDebugMessage(string.Format("Entering Chrono for {0}", TimerUtil.FormatTime(ts)), 0);
 }