///<summary>
        /// Modify the behavior of the list to linear.
        ///</summary>
        /// <param name="label">Text to display on the first line of pinpad display.</param>
        /// <param name="minimunLimit">Minimum numeric value for pick. Limit: -32.768.</param>
        /// <param name="maximumLimit">Maximum numeric value for pick. Limit: 32.767.</param>
        private Nullable <short> AddLinearBehaviorNumericValue(string label, short minimunLimit, short maximumLimit)
        {
            PinpadKeyCode code  = PinpadKeyCode.Undefined;
            short         index = minimunLimit;

            do
            {
                this._display.ShowMessage(label + ":", index.ToString(), DisplayPaddingType.Left);
                code = this._keyboard.GetKey();

                if (code == PinpadKeyCode.Backspace)
                {
                    // Restart counter
                    index = minimunLimit;
                }
                else if (code == this.DataPickerKeys.DownKey && index < maximumLimit)
                {
                    // Down key
                    index++;
                }
                else if (code == this.DataPickerKeys.UpKey && index > minimunLimit)
                {
                    // Up key
                    index--;
                }
            } while (code != PinpadKeyCode.Return && code != PinpadKeyCode.Cancel && code != PinpadKeyCode.Undefined);

            if (code == PinpadKeyCode.Cancel)
            {
                return(null);
            }
            return(index);
        }
        /// <summary>
        /// Modify the behavior of the list to linear.
        /// </summary>
        /// <typeparam name="V"></typeparam>
        /// <param name="label">Text to display on the first line of pinpad display.</param>
        /// <param name="index">Index of the option selected.</param>
        /// <param name="options">Array with options.</param>
        private PinpadKeyCode AddLinearBehavior <V>(string label, out int index, params V[] options)
        {
            PinpadKeyCode code = PinpadKeyCode.Undefined;

            index = 0;

            do
            {
                this._display.ShowMessage(label + ":", options[index].ToString(), DisplayPaddingType.Left);
                code = this._keyboard.GetKey();

                if (code == PinpadKeyCode.Backspace)
                {
                    // Restart counter
                    index = 0;
                }
                else if (code == this.DataPickerKeys.DownKey && index < options.Length - 1)
                {
                    // Down key
                    index++;
                }
                else if (code == this.DataPickerKeys.UpKey && index > 0)
                {
                    // Up key
                    index--;
                }
            }while (code != PinpadKeyCode.Return && code != PinpadKeyCode.Cancel && code != PinpadKeyCode.Undefined);

            return(code);
        }
        /// <summary>
        /// Updates pinpad screen with input labels.
        /// </summary>
        /// <param name="sender">Screen update button.</param>
        /// <param name="e">Click event arguments.</param>
        private void ShowPinpadLabel(object sender, RoutedEventArgs e)
        {
            DisplayPaddingType pinpadAlignment;

            if (this.uxCbxItemRight.IsSelected == true)
            {
                pinpadAlignment = DisplayPaddingType.Right;
            }
            else if (this.uxCbxItemCenter.IsSelected == true)
            {
                pinpadAlignment = DisplayPaddingType.Center;
            }
            else
            {
                pinpadAlignment = DisplayPaddingType.Left;
            }

            if (this.authorizer.PinpadController.Display.ShowMessage(this.uxTbxFirstRow.Text, this.uxTbxSecondRow.Text, pinpadAlignment) == true)
            {
                this.Dispatcher.RunAsync(CoreDispatcherPriority.Normal, () => { this.Log("Mensagem mostrada na tela do pinpad."); }).AsTask();
            }
            else
            {
                this.Dispatcher.RunAsync(CoreDispatcherPriority.Normal, () => { this.Log("A mensagem não foi mostrada."); }).AsTask();
            }

            if (this.uxChxWaitKey.IsChecked == true)
            {
                PinpadKeyCode key = PinpadKeyCode.Undefined;
                do
                {
                    key = this.authorizer.PinpadController.Keyboard.GetKey();
                }while (key == PinpadKeyCode.Undefined);
            }
        }
Beispiel #4
0
        /// <summary>
        /// Updates pinpad screen with input labels.
        /// </summary>
        /// <param name="sender">Screen update button.</param>
        /// <param name="e">Click event arguments.</param>
        private void OnShowPinpadLabel(object sender, RoutedEventArgs e)
        {
            // Limpa o log:
            this.uxLog.Items.Clear();

            ICardPaymentAuthorizer currentAuthorizer = this.GetCurrentPinpad();

            if (currentAuthorizer == null)
            {
                this.Log("Selecione um pinpad.");
                return;
            }

            DisplayPaddingType pinpadAlignment;

            // Define o alinhamento da mensagem a ser mostrada na tela do pinpad:
            switch (this.uxCbbxAlignment.Text)
            {
            case "Direita": pinpadAlignment = DisplayPaddingType.Right; break;

            case "Centro": pinpadAlignment = DisplayPaddingType.Center; break;

            default: pinpadAlignment = DisplayPaddingType.Left; break;
            }

            // Mostra a mensagom:
            bool status = currentAuthorizer.PinpadFacade.Display.ShowMessage(this.uxTbxLine1.Text, this.uxTbxLine2.Text, pinpadAlignment);

            // Atualiza o log:
            this.Log((status) ? "Mensagem mostrada na tela do pinpad." : "A mensagem não foi mostrada.");

            if (this.uxOptionWaitForKey.IsChecked == true)
            {
                PinpadKeyCode key = PinpadKeyCode.Undefined;

                // Espera uma tecla ser iniciada.
                do
                {
                    key = currentAuthorizer.PinpadFacade.Keyboard.GetKey();
                }while (key == PinpadKeyCode.Undefined);

                this.Log("Tecla <{0}> pressionada!", key);
            }
        }
Beispiel #5
0
        /// <summary>
        /// Show something in pinpad display.
        /// </summary>
        /// <param name="firstLine">Message presented in the first line.</param>
        /// <param name="secondLine">Message presented in the second line.</param>
        /// <param name="padding">Alignment.</param>
        /// <param name="waitForWey">Whether the pinpad should wait for a key.</param>
        public void ShowSomething(string firstLine, string secondLine, DisplayPaddingType padding, bool waitForWey = false)
        {
            this.authorizer.PinpadController.Display.ShowMessage(firstLine, secondLine, padding);

            Task waitForKeyTask = new Task(() =>
            {
                if (waitForWey == true)
                {
                    PinpadKeyCode key = PinpadKeyCode.Undefined;
                    do
                    {
                        key = this.authorizer.PinpadController.Keyboard.GetKey();
                    } while (key == PinpadKeyCode.Undefined);
                }
            });

            waitForKeyTask.Start();
            waitForKeyTask.Wait();
        }
        // Private methods
        /// <summary>
        /// Base method to picked options.
        /// </summary>
        /// <typeparam name="T">Return type.</typeparam>
        /// <typeparam name="V">Options type.</typeparam>
        /// <param name="label">Text to display on the first line of pinpad display.</param>
        /// <param name="options">Array with options.</param>
        /// <param name="circularBehavior">Behavior of the list.</param>
        /// <returns>Option picker or null if no one was picked.</returns>
        private T PickObjectInArray <T, V>(string label, bool circularBehavior, params V[] options)
        {
            PinpadKeyCode code = PinpadKeyCode.Undefined;
            int           index;

            if (circularBehavior == true)
            {
                code = this.AddCircularBehavior <V>(label, out index, options);
            }
            else
            {
                code = this.AddLinearBehavior <V>(label, out index, options);
            }

            if (code == PinpadKeyCode.Return)
            {
                return((T)(object)options[index]);
            }

            return(default(T));
        }