//硬币入 static void CoinAcceptorCoinAccepted(object sender, CoinAcceptorCoinEventArgs e) { var currentMoney = 0; Log.In(string.Format("name->{0} code->{1}", e.CoinName, e.CoinCode)); if (e.CoinCode == 2) { //10元 acceptMoney += 10M; currentMoney = 10; } if (e.CoinCode == 3) { //5元 acceptMoney += 5M; currentMoney = 5; } if (e.CoinCode == 4) { //2元 acceptMoney += 2M; currentMoney = 2; } if (e.CoinCode == 5) { //1元 acceptMoney += 1M; currentMoney = 1; } FireReceiveMoneyEvent(currentMoney); }
void CoinAcceptorCoinAccepted(object sender, CoinAcceptorCoinEventArgs e) { if (Application.Current.Dispatcher.CheckAccess() == false) { Application.Current.Dispatcher.Invoke((EventHandler <CoinAcceptorCoinEventArgs>)CoinAcceptorCoinAccepted, sender, e); return; } _coinCounter += e.CoinValue; //Core.Log.In(string.Format("Coin accepted: {0} ({1:X2}), path {3}. Now accepted: {2:C}", e.CoinName, e.CoinCode, _coinCounter, e.RoutePath)); }
//硬币入 static void CoinAcceptorCoinAccepted(object sender, CoinAcceptorCoinEventArgs e) { Log.In(string.Format("name->{0} code->{1}", e.CoinName, e.CoinCode)); if (e.CoinCode == 2) { //5角 acceptMoney += 0.5M; } if (e.CoinCode == 3) { //1元 acceptMoney += 1M; } FireReceiveMoneyEvent(); }
void _coinAcceptor_CoinAccepted(object sender, CoinAcceptorCoinEventArgs e) { if (InvokeRequired) { Invoke((EventHandler <CoinAcceptorCoinEventArgs>)_coinAcceptor_CoinAccepted, sender, e); return; } _coinValue += e.CoinValue; txtLog.Text += String.Format("Coin accepted: {0} ({1:X2}), path {3}. Now accepted: {2}", e.CoinName, e.CoinCode, _coinValue, e.RoutePath) + Environment.NewLine; labTotalMoneyIn.Text = _coinValue.ToString(); if (CoinAccepted != null) { CoinAccepted(e.CoinValue); } // There is simulator of long-working event handler Thread.Sleep(1000); }
static void CoinAcceptorCoinAccepted(object sender, CoinAcceptorCoinEventArgs e) { //if (Application.Current.Dispatcher.CheckAccess() == false) //{ // Application.Current.Dispatcher.Invoke((EventHandler<CoinAcceptorCoinEventArgs>)CoinAcceptorCoinAccepted, sender, e); // return; //} //_coinCounter += e.CoinValue; //Log.In(String.Format("Coin accepted: {0} ({1:X2}), path {3}. Now accepted: {2:C}", e.CoinName, e.CoinCode, _coinCounter, e.RoutePath)); Log.In(string.Format("name->{0} code->{1}", e.CoinName, e.CoinCode)); if (e.CoinCode == 2) { //5角 acceptMoney += (decimal)0.5; } if (e.CoinCode == 3) { //1元 acceptMoney += (decimal)1; } calc(); }