Example #1
0
        private void initialState()
        {
            var fragment = new FragmentPrinterText();

            //Fragment Inicial


            this.SupportFragmentManager.BeginTransaction().Add(Resource.Id.impressoraFragment, fragment, "FragmentImpressora").Commit();

            //Views selecionadas Inicialmente - Tela da Impressora
            btnPrintText.BackgroundTintList = GetColorStateList(Resource.Color.azul);
            radioImpInterna.Checked         = true;

            //Inicializando Impressora Interna
            Printer.printerInternalImpStart();
        }
Example #2
0
        private void initViewsFunc()
        {
            btnPrintText.Click += delegate
            {
                blackoutButtons();
                btnPrintText.BackgroundTintList = GetColorStateList(Resource.Color.azul);
                var fragment = new FragmentPrinterText();
                this.SupportFragmentManager.BeginTransaction().Replace(Resource.Id.impressoraFragment, fragment, "FragmentImpressora").Commit();
            };

            btnPrintBarcode.Click += delegate
            {
                blackoutButtons();
                btnPrintBarcode.BackgroundTintList = GetColorStateList(Resource.Color.azul);
                var fragment = new FragmentPrinterBarCode();
                this.SupportFragmentManager.BeginTransaction().Replace(Resource.Id.impressoraFragment, fragment, "FragmentImpressora").Commit();
            };

            btnPrintImage.Click += delegate
            {
                blackoutButtons();
                btnPrintImage.BackgroundTintList = GetColorStateList(Resource.Color.azul);
                var fragment = new FragmentPrinterImage();
                this.SupportFragmentManager.BeginTransaction().Replace(Resource.Id.impressoraFragment, fragment, "FragmentImpressora").Commit();
            };

            btnPrinterStatus.Click += delegate
            {
                int statusSensorPapel = Printer.statusSensorPapel();

                if (statusSensorPapel == 5)
                {
                    alert("Papel está presente e não está próximo do fim!");
                }

                else if (statusSensorPapel == 6)
                {
                    alert("Papel próximo do fim!");
                }

                else if (statusSensorPapel == 7)
                {
                    alert("Papel ausente!");
                }

                else
                {
                    alert("Status Desconhecido!");
                }
            };

            btnStatusGaveta.Click += delegate
            {
                int statusGaveta = Printer.statusGaveta();

                if (statusGaveta == 1)
                {
                    alert("Gaveta aberta!");
                }

                else if (statusGaveta == 2)
                {
                    alert("Gaveta fechada!");
                }

                else
                {
                    alert("Status Desconhecido!");
                }
            };

            btnAbrirGaveta.Click += delegate
            {
                int resultadoAbrirGaveta = Printer.abrirGaveta();
                Console.WriteLine("ResultadoAbrirGaveta: " + resultadoAbrirGaveta);
            };

            btnAbrirGaveta.Click += delegate
            {
                Printer.statusGaveta();
            };

            radioImpExterna.CheckedChange += (s, e) =>
            {
                if (radioImpExterna.Checked == true && isIpValid(editIp.Text) == true)
                {
                    //Separando Ip e Porta para iniciar a imp Externa
                    int    dividerIndex = editIp.Text.IndexOf(':');
                    string ip           = editIp.Text.Substring(0, dividerIndex);
                    string port         = editIp.Text.Substring(dividerIndex + 1);

                    Dictionary <string, string> IPdictionary = new Dictionary <string, string>();
                    IPdictionary.Add("ip", ip);
                    IPdictionary.Add("port", port);


                    radioImpInterna.Checked = false;
                    radioImpExterna.Checked = true;
                    Printer.printerExternalImpStart(IPdictionary);
                }
                else if (radioImpExterna.Checked == true && isIpValid(editIp.Text) == false)
                {
                    radioImpInterna.Checked = true;
                    radioImpExterna.Checked = false;
                    alert("Digite um endereço e porta IP válido!");
                }
            };

            radioImpInterna.CheckedChange += (s, e) =>
            {
                if (radioImpExterna.Checked == false || radioImpInterna.Checked == true)
                {
                    radioImpInterna.Checked = true;
                    Printer.printerInternalImpStart();
                }
                else
                {
                    radioImpInterna.Checked = false;
                }
            };
        }