示例#1
0
        public ScreenVignette()
        {
            InitializeWidget();



            showGUI              = new TapGestureDetector();
            showGUI.TapDetected += ShowGUIEvent;
            ShowGUI.AddGestureDetector(showGUI);

            StartingTownTGD              = new TapGestureDetector();
            StartingTownTGD.TapDetected += HandleTapDetected;
            StartingTownButton.AddGestureDetector(StartingTownTGD);

            Town2TGD              = new TapGestureDetector();
            Town2TGD.TapDetected += HandleTapDetected;
            StrongHold2Button.AddGestureDetector(Town2TGD);

            Town3TGD              = new TapGestureDetector();
            Town3TGD.TapDetected += HandleTapDetected;
            Town3Button.AddGestureDetector(Town3TGD);

            BossTownTGD              = new TapGestureDetector();
            BossTownTGD.TapDetected += HandleTapDetected;
            BossTownButton.AddGestureDetector(BossTownTGD);

            LumberMill1TGD              = new TapGestureDetector();
            LumberMill1TGD.TapDetected += HandleTapDetected;
            LumberMill1Button.AddGestureDetector(LumberMill1TGD);

            LumberMill2TGD              = new TapGestureDetector();
            LumberMill2TGD.TapDetected += HandleTapDetected;
            LumberMill2Button.AddGestureDetector(LumberMill2TGD);

            IronMineTGD              = new TapGestureDetector();
            IronMineTGD.TapDetected += HandleTapDetected;
            IronMineButton.AddGestureDetector(IronMineTGD);

            ContinueTGD              = new TapGestureDetector();
            ContinueTGD.TapDetected += HandleTapDetected;
            Continue.AddGestureDetector(ContinueTGD);

            GotoButton.ButtonAction += HandleGotoButtonButtonAction;
            Visit.ButtonAction      += HandleVisitButtonAction;
            Close.ButtonAction      += HandleCloseButtonAction;

            UpdateIAmHere();
        }
示例#2
0
        /*
         *  HandlePosEvent is called from _ui_Notify event listener (above).
         *
         *  Most messages are simply turned into .NET events.  A few do more,
         *  especially:
         *      ADD_TO_BASKET : Updates our own Basket object with new items
         *      REMOVE_FROM_BASKET : Removes item from our own Basket
         *      BASKET_COMMITTED : Updates the Basket state; and fetches all the vouchers
         */
        private void HandlePosEvent(PosEvent posEvent)
        {
            if (posEvent == null)
            {
                // Debug.Assert(false);
                return;
            }
            if (_timeoutTimer != null)
            {
                _timeoutTimer.Enabled = false;
                _timeoutTimer         = null;
            }
            switch (posEvent.EventName)
            {
            case PosEventType.READY:
                Ready?.Invoke(this, null);
                _rollbackHandler.ProcessPendingRollbacks(_config.Url);
                break;

            case PosEventType.SHOW_GUI:
                _ui.Show();
                ShowGUI?.Invoke(this, null);
                break;

            case PosEventType.HIDE_GUI:
                _ui.Hide();
                HideGUI?.Invoke(this, null);
                break;

            case PosEventType.ADD_TO_BASKET:
                var addedItem = (AddToBasketEvent)posEvent;
                _basket.Id = addedItem.BasketId;
                _basket.Items.Add(addedItem.BasketItem);
                ItemAdded?.Invoke(this, addedItem.BasketItem);
                break;

            case PosEventType.BASKET_COMMITTED:
                var basketCommittedEvent = (BasketCommittedEvent)posEvent;
                // Check:
                //  (1) Incoming .BasketId is what we expect.  This is just a sanity check, and should never fail.
                //  (2) basketCommittedEvent.Basket.Committed = TRUE
                //  (3) this.FailOnCommit = FALSE.  This may be set to TRUE to test correct processing of a Commit failure.
                if (_basket.Id == basketCommittedEvent.BasketId && basketCommittedEvent.Basket.Committed && !FailOnCommit)
                {
                    _basket.Clear();
                    _basket.Id = basketCommittedEvent.BasketId;
                    foreach (var basketItem in basketCommittedEvent.Basket.basketItems)
                    {
                        _basket.Items.Add(basketItem);     // Now with Touch ID, and Vouchers (we trust!)
                        if (basketItem is PurchaseBasketItem)
                        {
                            var purchase = (PurchaseBasketItem)basketItem;
                            if (purchase.Vouchers?.Count > 0)
                            {
                                GetVoucher(purchase.Vouchers[0].Link);
                            }
                        }
                        else if (basketItem is RefundBasketItem)
                        {
                            var refund = (RefundBasketItem)basketItem;
                            if (refund.RefundVoucher != null)
                            {
                                GetVoucher(refund.RefundVoucher.Link);
                            }
                        }
                    }
                    _basket.Committed = true;
                    BasketCommitted?.Invoke(this, _basket);
                }
                else
                {
                    ProcessFailedCommit();
                }
                // _basket.Clear();
                break;

            case PosEventType.REMOVE_FROM_BASKET:
                var removeFromBasketEvent = (RemoveFromBasketEvent)posEvent;
                foreach (var basketItem in _basket.Items)
                {
                    if (basketItem.Id == removeFromBasketEvent.BasketItemId)
                    {
                        _basket.Items.Remove(basketItem);
                        ItemRemoved?.Invoke(this, basketItem);
                        break;
                    }
                }
                break;

            case PosEventType.PRINT_VOUCHER:     // This is an "unexpected" ad hoc voucher...
                var PrintVoucherEvent = (PrintVoucherEvent)posEvent;
                VoucherAvailable?.Invoke(this, PrintVoucherEvent.Data);
                break;

            case PosEventType.VOUCHER_HTML:     //...whereas this is the response to the BasketGetVoucherEvent message
                var voucherHtmlEvent = (VoucherHtmlEvent)posEvent;
                if (!string.IsNullOrEmpty(voucherHtmlEvent.VoucherHtml))
                {
                    VoucherAvailable?.Invoke(this, voucherHtmlEvent.VoucherHtml);
                }
                break;

            case PosEventType.START_DEVICE:
                var startDeviceEvent = (StartDeviceEvent)posEvent;
                StartDevice?.Invoke(this, startDeviceEvent.Device);
                break;

            case PosEventType.STOP_DEVICE:
                var stopDeviceEvent = (StopDeviceEvent)posEvent;
                StopDevice?.Invoke(this, stopDeviceEvent.Device);
                break;

            case PosEventType.DISPLAY_MESSAGE:
                var displayMessageEvent = (DisplayMessageEvent)posEvent;
                DisplayMessage?.Invoke(this, displayMessageEvent.Message);
                break;

            case PosEventType.SIMPLE_PRODUCT:
                var simpleProductEvent = (SimpleProductEvent)posEvent;
                SimpleProduct?.Invoke(this, new SimpleProductInfo(simpleProductEvent));
                break;

            case PosEventType.SYNC_BASKET:
                var synBasketEvent = (SyncBasketEvent)posEvent;
                SyncBasket?.Invoke(this, null);
                break;

            case PosEventType.ERROR:
                var errorEvent = (ErrorEvent)posEvent;
                if (errorEvent.Method == "BasketCommitBasket")
                {
                    ProcessFailedCommit();
                }
                Error?.Invoke(this, errorEvent.Reason);
                break;

            default:
                Debug.Assert(false);     // Unknown PosEventType
                break;
            }
        }