void CountDown(object o, ElapsedEventArgs a) { CounterItem cItem = counter.CountDown(); if (cItem.Count == 0) { timer.Stop(); if (device == null) { return; } try { pictureBox1.Image = ImageProcessing.Properties.Resources.smile; pictureBox2.Image = null; if (ClosingTimerStarted) { closingTimer.Elapsed -= new ElapsedEventHandler(CloseForm); closingTimer.Stop(); ClosingTimerStarted = false; } closingTimer.Elapsed += new ElapsedEventHandler(CloseForm); closingTimer.Start(); ClosingTimerStarted = true; device.Capture(); } catch (NikonException ex) { if (ex.ErrorCode == eNkMAIDResult.kNkMAIDResult_OutOfFocus) { pictureBox3.Image = null; pictureBox1.Image = ImageProcessing.Properties.Resources.focuserror; pictureBox2.Image = null; } else if (ex.ErrorCode == eNkMAIDResult.kNkMAIDResult_BatteryDontWork) { pictureBox3.Image = null; pictureBox1.Image = ImageProcessing.Properties.Resources.lowbattery; pictureBox2.Image = null; return; } else if (ex.ErrorCode == eNkMAIDResult.kNkMAIDResult_UnexpectedError) { pictureBox3.Image = null; pictureBox1.Image = ImageProcessing.Properties.Resources.unknownerror; pictureBox2.Image = null; return; } closingTimer.Stop(); closingTimer.Enabled = false; ClosingTimerStarted = false; counter = new Counter(); timer.Enabled = true; timer.Start(); } return; } pictureBox1.Image = cItem.Number; pictureBox2.Image = cItem.Smile; }