/// <summary>
        /// Creates all pinpad messages.
        /// Establishes connection with the pinpad.
        /// </summary>
        public PizzaAuthorizer()
        {
            this.BoughtPizzas = new Collection <IAuthorizationReport>();

            // Creates all pinpad messages:
            this.PizzaMachineMessages = new DisplayableMessages();
            this.PizzaMachineMessages.ApprovedMessage       = "Aprovado, nham!";
            this.PizzaMachineMessages.DeclinedMessage       = "Nao autorizada";
            this.PizzaMachineMessages.InitializationMessage = "olá...";
            this.PizzaMachineMessages.MainLabel             = "pizza machine";
            this.PizzaMachineMessages.ProcessingMessage     = "assando pizza...";

            // Establishes connection with the pinpad.
            Microtef.Platform.Desktop.DesktopInitializer.Initialize();
            this.authorizer = DeviceProvider.ActivateAndGetOneOrFirst(this.StoneCode, this.PizzaMachineMessages);

            // Attach event to read all transaction status:
            this.authorizer.OnStateChanged += this.OnStatusChange;
        }
        /// <summary>
        /// Try to connect to the pinpad.
        /// </summary>
        /// <param name="activation">Data to connect to the pinpad.</param>
        /// <returns>True if the pinpad was found and connected.</returns>
        public bool TryActivate(ActivateOption activation)
        {
            try
            {
                // Tries to connect to one pinpad:
                this.StoneAuthorizer = DeviceProvider
                                       .ActivateAndGetOneOrFirst(activation.StoneCode, null, activation.Port);

                // Show result:
                this.StoneAuthorizer.ShowPinpadOnConsole();
            }
            catch (PinpadNotFoundException)
            {
                Console.WriteLine("Pinpad nao encontrado.");
            }
            catch (Exception)
            {
                Console.WriteLine("Erro ao ativar o terminal. Você está usando o StoneCode correto?");
            }

            return(this.IsUsable);
        }