public TakePhoto(ImageCollection image, NikonDevice device) { InitializeComponent(); Cursor.Hide(); this.DoubleBuffered = true; CenterComponents(); // Hook up device capture events this.device = device; device.ImageReady += new ImageReadyDelegate(device_ImageReady); device.CaptureComplete += new CaptureCompleteDelegate(device_CaptureComplete); counter = new Counter(); Image = image; this.BackgroundImage = new Bitmap(Image.BackgroundImage); printImage = new Bitmap(Image.BackgroundImage); timer = new System.Timers.Timer(1000); timer.Elapsed += new ElapsedEventHandler(CountDown); closingTimer = new System.Timers.Timer(6000); CounterItem cItem = counter.CountDown(); pictureBox1.Image = cItem.Number; pictureBox2.Image = cItem.Smile; timer.Start(); }
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; } else if (ex.ErrorCode == eNkMAIDResult.kNkMAIDResult_UnexpectedError) { pictureBox3.Image = null; pictureBox1.Image = ImageProcessing.Properties.Resources.unknownerror; pictureBox2.Image = null; } counter = new Counter(); timer.Enabled = true; timer.Start(); } return; } pictureBox1.Image = cItem.Number; pictureBox2.Image = cItem.Smile; }
public TakePhoto(ImageCollection image, NikonDevice device, CoinSelector selector) { InitializeComponent(); this.DoubleBuffered = true; this.Cursor = new Cursor(GetType(), "hand128.cur"); Cursor.Hide(); CenterComponents(); coinSelector = selector; coinSelector.OnCoinDetected += coinSelector_OnCoinDetected; coinSelector.PollingEnabled = false; CoinData coinData = LogManager.GetLastCoinData(); coinSelector.TotalCoin = coinData.TotalValue; coinSelector.UsedCoin = coinData.UsedValue; // Hook up device capture events this.device = device; device.ImageReady += new ImageReadyDelegate(device_ImageReady); device.CaptureComplete += new CaptureCompleteDelegate(device_CaptureComplete); counter = new Counter(); Image = image; this.BackgroundImage = new Bitmap(Image.BackgroundImage); printImage = new Bitmap(Image.BackgroundImage); timer = new System.Timers.Timer(1000); timer.Elapsed += new ElapsedEventHandler(CountDown); timer.Enabled = false; copyCount = new CopyCount(Settings.Instance.CopyCount); coinWaitTimer = new System.Timers.Timer(); coinWaitTimer.Interval = 60000; coinWaitTimer.Enabled = false; coinWaitTimer.AutoReset = false; coinWaitTimer.Elapsed += coinWaitTimer_Elapsed; closingTimer = new System.Timers.Timer(6000); CounterItem cItem = counter.CountDown(); pictureBox1.Image = cItem.Number; pictureBox2.Image = cItem.Smile; timer.Start(); pictureBox5.Image = generateADImage(copyCount.Count); pictureBox8.Image = generateTotalCoinImage(copyCount.Count * Settings.Instance.COST); pictureBox9.Image = generateCoinImage(coinSelector.RemainedCoin); }