void coinSelector_OnCoinDetected(object eventObject, CoinDetectedEventArgs args) { coinWaitTimer.Enabled = false; LogManager.LogCoinData(new CoinLogData(new CoinData(args.Value, args.UsedCoinValue, args.RemainedCoinValue, args.TotalCoinValue))); pictureBox9.Invoke((MethodInvoker) delegate { pictureBox9.Image = generateCoinImage(args.RemainedCoinValue); }); double remainingValue = Settings.Instance.COST * copyCount.Count - args.RemainedCoinValue; if (args.RemainedCoinValue >= Settings.Instance.COST * copyCount.Count) { if (coinSelector.PollingEnabled) { coinSelector.PollingEnabled = false; } coinWaitTimer.Enabled = false; setPictureCountSelectVisible(false); pictureBox10_Click(null, null); pictureBox10.Invoke((MethodInvoker) delegate { pictureBox10.Visible = false; }); } else { coinWaitTimer.Enabled = true; pictureBox10.Invoke((MethodInvoker) delegate { pictureBox10.Visible = false; }); } double[] enabledValues = new double[3]; if (remainingValue >= CoinValues.TRY025) { enabledValues[0] = CoinValues.TRY025; } if (remainingValue >= CoinValues.TRY050) { enabledValues[1] = CoinValues.TRY050; } if (remainingValue >= CoinValues.TRY100) { enabledValues[2] = CoinValues.TRY100; } coinSelector.SetEnabledCoins(enabledValues); }
private void _tmrPoll_Elapsed(object sender, ElapsedEventArgs e) { int i, j, cidx, EvtCnt; whSelPollResponse[] PollResps = new whSelPollResponse[whSelectorComm.MaxPollEvents]; this._tmrPoll.Enabled = false; this._currentDevice.PollSelector(ref PollResps, out EvtCnt); // Process poll response(s) if (EvtCnt > 0) { for (i = 0; i < EvtCnt; i++) { // Show last poll if (PollResps[i].Status == whSelPollEvent.Coin) { cidx = PollResps[i].CoinIndex; // Show counts this._totalCoinCount[cidx]++; this._totalCoin = 0; for (j = 0; j < this._totalCoinCount.Length; j++) { this._totalCoin += this._coinValues[j].Value * this._totalCoinCount[j]; } this._remainedCoin = this._totalCoin - this._usedCoin; CoinDetectedEventArgs args = new CoinDetectedEventArgs(this._coinValues[cidx].Value, this._totalCoin, this._remainedCoin, this._usedCoin); OnCoinDetected(this, args); } } } if (this._tmrPoolEnabled) { this._tmrPoll.Enabled = true; } }